From: <geo...@us...> - 2012-09-03 00:58:23
|
Revision: 5201 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=5201&view=rev Author: geoffthemedio Date: 2012-09-03 00:58:17 +0000 (Mon, 03 Sep 2012) Log Message: ----------- Added a mechanism to GG::GUI to remap keypresses, so the GUI responds to one keyboard key as if it was another key. Modified Paths: -------------- trunk/FreeOrion/GG/GG/GUI.h trunk/FreeOrion/GG/src/GUI.cpp trunk/FreeOrion/GG/src/Ogre/Plugins/OISInput.cpp Modified: trunk/FreeOrion/GG/GG/GUI.h =================================================================== --- trunk/FreeOrion/GG/GG/GUI.h 2012-09-02 23:24:23 UTC (rev 5200) +++ trunk/FreeOrion/GG/GG/GUI.h 2012-09-03 00:58:17 UTC (rev 5201) @@ -185,6 +185,8 @@ Pt MouseMovement() const; ///< returns the relative position of mouse, based on the last mouse motion event Flags<ModKey> ModKeys() const; ///< returns the set of modifier keys that are currently depressed, based on the last event bool MouseLRSwapped() const; ///< returns true if the left and right mouse button press events are set to be swapped before event handling. This is to facilitate left-handed mouse users semi-automatically. + const std::map<Key, Key>& + KeyMap() const; ///< returns the the key remappings set, which causes the GUI to respond to one Key press as though a different Key were pressed. /** Returns the (begin, end) indices of the code points of all the word-tokens in the given string. This is perhaps an odd place for @@ -276,6 +278,9 @@ /** Sets whether to swap left and right mouse button events. */ void SetMouseLRSwapped(bool swapped = true); + /** Sets which Key presses are substitued for actual key presses before event handling. */ + void SetKeyMap(const std::map<Key, Key>& key_map); + /** Returns a shared_ptr to the desired font, supporting all printable ASCII characters. */ boost::shared_ptr<Font> GetFont(const std::string& font_filename, unsigned int pts); Modified: trunk/FreeOrion/GG/src/GUI.cpp =================================================================== --- trunk/FreeOrion/GG/src/GUI.cpp 2012-09-02 23:24:23 UTC (rev 5200) +++ trunk/FreeOrion/GG/src/GUI.cpp 2012-09-03 00:58:17 UTC (rev 5201) @@ -89,6 +89,13 @@ return mod_keys; } + Key KeyMappedKey(Key key, const std::map<Key, Key>& key_map) { + std::map<Key, Key>::const_iterator it = key_map.find(key); + if (it != key_map.end()) + return it->second; + return key; + } + WndEvent::EventType ButtonEvent(WndEvent::EventType left_type, unsigned int mouse_button) { return WndEvent::EventType(left_type + (WndEvent::MButtonDown - WndEvent::LButtonDown) * mouse_button); } @@ -238,6 +245,8 @@ m_accelerator_sigs; // the signals emitted by the keyboard accelerators bool m_mouse_lr_swap; // treat left and right mouse events as each other + std::map<Key, Key> + m_key_map; // substitute Key press events with different Key press events int m_delta_t; // the number of ms since the last frame bool m_rendering_drag_drop_wnds; @@ -613,6 +622,9 @@ bool GUI::MouseLRSwapped() const { return s_impl->m_mouse_lr_swap; } +const std::map<Key, Key>& GUI::KeyMap() const +{ return s_impl->m_key_map; } + std::set<std::pair<CPSize, CPSize> > GUI::FindWords(const std::string& str) const { std::set<std::pair<CPSize, CPSize> > retval; @@ -697,6 +709,7 @@ } break; } case KEYPRESS: { + key = KeyMappedKey(key, s_impl->m_key_map); s_impl->m_browse_info_wnd.reset(); s_impl->m_browse_info_mode = -1; s_impl->m_browse_target = 0; @@ -714,6 +727,7 @@ FocusWnd()->HandleEvent(WndEvent(WndEvent::KeyPress, key, key_code_point, mod_keys)); break; } case KEYRELEASE: { + key = KeyMappedKey(key, s_impl->m_key_map); s_impl->m_browse_info_wnd.reset(); s_impl->m_browse_info_mode = -1; s_impl->m_browse_target = 0; @@ -965,6 +979,9 @@ void GUI::SetMouseLRSwapped(bool swapped/* = true*/) { s_impl->m_mouse_lr_swap = swapped; } +void GUI::SetKeyMap(const std::map<Key, Key>& key_map) +{ s_impl->m_key_map = key_map; } + boost::shared_ptr<Font> GUI::GetFont(const std::string& font_filename, unsigned int pts) { return GetFontManager().GetFont(font_filename, pts); } @@ -1222,7 +1239,6 @@ void GUI::SetDeltaT(unsigned int delta_t) { s_impl->m_delta_t = delta_t; } - bool GG::MatchesOrContains(const Wnd* lwnd, const Wnd* rwnd) { if (rwnd) { Modified: trunk/FreeOrion/GG/src/Ogre/Plugins/OISInput.cpp =================================================================== --- trunk/FreeOrion/GG/src/Ogre/Plugins/OISInput.cpp 2012-09-02 23:24:23 UTC (rev 5200) +++ trunk/FreeOrion/GG/src/Ogre/Plugins/OISInput.cpp 2012-09-03 00:58:17 UTC (rev 5201) @@ -301,13 +301,13 @@ { Ogre::RenderWindow* window = GetRenderWindow(); - typedef OIS::ParamList::value_type ParamType; - - OIS::ParamList param_list; - std::size_t window_handle = 0; - std::ostringstream window_handle_string; + typedef OIS::ParamList::value_type ParamType; + + OIS::ParamList param_list; + std::size_t window_handle = 0; + std::ostringstream window_handle_string; window->getCustomAttribute("WINDOW", &window_handle); - window_handle_string << window_handle; + window_handle_string << window_handle; param_list.insert(ParamType(std::string("WINDOW"), window_handle_string.str())); OgreGUI* gui = OgreGUI::GetGUI(); |
From: <geo...@us...> - 2013-05-17 15:11:32
|
Revision: 6034 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=6034&view=rev Author: geoffthemedio Date: 2013-05-17 15:10:43 +0000 (Fri, 17 May 2013) Log Message: ----------- Added SubTexture constructor taking just a pointer to Texture, which uses the texture size for the subtexture size, and texture coordinates to cover the whole texture. Useful for converting a Texture into a SubTexture that covers all of the texture, when something else takes a SubTexture parameter and it is desired to use a whole texture. Modified Paths: -------------- trunk/FreeOrion/GG/GG/Texture.h trunk/FreeOrion/GG/src/Texture.cpp Modified: trunk/FreeOrion/GG/GG/Texture.h =================================================================== --- trunk/FreeOrion/GG/GG/Texture.h 2013-05-17 01:14:50 UTC (rev 6033) +++ trunk/FreeOrion/GG/GG/Texture.h 2013-05-17 15:10:43 UTC (rev 6034) @@ -180,6 +180,11 @@ coordinates are not well formed.*/ SubTexture(const boost::shared_ptr<const Texture>& texture, X x1, Y y1, X x2, Y y2); + /** Creates a SubTexture from a GG::Texture and uses coordinates to cover + the whole texture. + \throw GG::SubTexture::BadTexture Throws if the given Texture is null.*/ + SubTexture(const boost::shared_ptr<const Texture>& texture); + SubTexture(const SubTexture& rhs); ///< copy ctor const SubTexture& operator=(const SubTexture& rhs); ///< assignment operator virtual ~SubTexture(); ///< virtual dtor Modified: trunk/FreeOrion/GG/src/Texture.cpp =================================================================== --- trunk/FreeOrion/GG/src/Texture.cpp 2013-05-17 01:14:50 UTC (rev 6033) +++ trunk/FreeOrion/GG/src/Texture.cpp 2013-05-17 15:10:43 UTC (rev 6034) @@ -577,6 +577,23 @@ m_tex_coords[3] = Value(y2 * 1.0 / texture->Height()); } +SubTexture::SubTexture(const boost::shared_ptr<const Texture>& texture) : + m_texture(texture), + m_width(GG::X1), + m_height(GG::Y1), + m_tex_coords() +{ + if (!m_texture) throw BadTexture("Attempted to contruct subtexture from invalid texture"); + + m_width = texture->Width(); + m_height = texture->Height(); + + m_tex_coords[0] = 0.0; + m_tex_coords[1] = 0.0; + m_tex_coords[2] = 1.0; + m_tex_coords[3] = 1.0; +} + SubTexture::~SubTexture() {} |
From: <geo...@us...> - 2013-10-18 00:44:06
|
Revision: 6453 http://sourceforge.net/p/freeorion/code/6453 Author: geoffthemedio Date: 2013-10-18 00:44:04 +0000 (Fri, 18 Oct 2013) Log Message: ----------- -Added TextControl::Text that takes CPSize parameters to specify a range within the control's m_text from which to return a substring by value. -Added Edit::SelectedText that uses the previous function to return the text selected in the control. Modified Paths: -------------- trunk/FreeOrion/GG/GG/Edit.h trunk/FreeOrion/GG/GG/TextControl.h trunk/FreeOrion/GG/src/Edit.cpp trunk/FreeOrion/GG/src/TextControl.cpp Modified: trunk/FreeOrion/GG/GG/Edit.h =================================================================== --- trunk/FreeOrion/GG/GG/Edit.h 2013-10-15 05:54:23 UTC (rev 6452) +++ trunk/FreeOrion/GG/GG/Edit.h 2013-10-18 00:44:04 UTC (rev 6453) @@ -83,6 +83,9 @@ to one past the last selected one). */ const std::pair<CPSize, CPSize>& CursorPosn() const; + /** Returns the text that is selected in this control. */ + std::string SelectedText() const; + /** Returns the color used to render the iterior of the control. */ Clr InteriorColor() const; Modified: trunk/FreeOrion/GG/GG/TextControl.h =================================================================== --- trunk/FreeOrion/GG/GG/TextControl.h 2013-10-15 05:54:23 UTC (rev 6452) +++ trunk/FreeOrion/GG/GG/TextControl.h 2013-10-18 00:44:04 UTC (rev 6453) @@ -88,6 +88,10 @@ /** Returns the text displayed in this control. */ const std::string& Text() const; + /** Returns the text displayed in this control between the specified + position \a from through position \a to. */ + std::string Text(CPSize from, CPSize to) const; + /** Returns the text format (vertical and horizontal justification, use of word breaks and line wrapping, etc.) */ Flags<TextFormat> GetTextFormat() const; Modified: trunk/FreeOrion/GG/src/Edit.cpp =================================================================== --- trunk/FreeOrion/GG/src/Edit.cpp 2013-10-15 05:54:23 UTC (rev 6452) +++ trunk/FreeOrion/GG/src/Edit.cpp 2013-10-18 00:44:04 UTC (rev 6453) @@ -99,6 +99,9 @@ const std::pair<CPSize, CPSize>& Edit::CursorPosn() const { return m_cursor_pos; } +std::string Edit::SelectedText() const +{ return Text(m_cursor_pos.first, m_cursor_pos.second); } + Clr Edit::InteriorColor() const { return m_int_color; } Modified: trunk/FreeOrion/GG/src/TextControl.cpp =================================================================== --- trunk/FreeOrion/GG/src/TextControl.cpp 2013-10-15 05:54:23 UTC (rev 6452) +++ trunk/FreeOrion/GG/src/TextControl.cpp 2013-10-18 00:44:04 UTC (rev 6453) @@ -84,6 +84,18 @@ const std::string& TextControl::Text() const { return m_text; } +std::string TextControl::Text(CPSize from, CPSize to) const +{ + if (from == INVALID_CP_SIZE || to == INVALID_CP_SIZE) + return ""; + CPSize low = std::max(CPSize(0), std::min(from, to)); + CPSize high = std::min(Length(), std::max(from, to)); + + std::string::const_iterator it = m_text.begin() + Value(low); + std::string::const_iterator end_it = m_text.begin() + Value(high); + return std::string(it, end_it); +} + Flags<TextFormat> TextControl::GetTextFormat() const { return m_format; } |
From: <geo...@us...> - 2013-10-20 00:18:41
|
Revision: 6458 http://sourceforge.net/p/freeorion/code/6458 Author: geoffthemedio Date: 2013-10-20 00:18:37 +0000 (Sun, 20 Oct 2013) Log Message: ----------- Added some clipboard functions, not yet used, to GG::GUI. Modified Paths: -------------- trunk/FreeOrion/GG/GG/GUI.h trunk/FreeOrion/GG/GG/Wnd.h trunk/FreeOrion/GG/src/GUI.cpp Modified: trunk/FreeOrion/GG/GG/GUI.h =================================================================== --- trunk/FreeOrion/GG/GG/GUI.h 2013-10-19 21:08:01 UTC (rev 6457) +++ trunk/FreeOrion/GG/GG/GUI.h 2013-10-20 00:18:37 UTC (rev 6458) @@ -187,6 +187,8 @@ bool MouseLRSwapped() const; ///< returns true if the left and right mouse button press events are set to be swapped before event handling. This is to facilitate left-handed mouse users semi-automatically. const std::map<Key, Key>& KeyMap() const; ///< returns the the key remappings set, which causes the GUI to respond to one Key press as though a different Key were pressed. + virtual const std::string& + ClipboardText() const; ///< returns text stored in a clipboard /** Returns the (begin, end) indices of the code points of all the word-tokens in the given string. This is perhaps an odd place for @@ -325,6 +327,10 @@ void RenderCursor(bool render); ///< set this to true iff the GUI should render the cursor void SetCursor(const boost::shared_ptr<Cursor>& cursor); ///< sets the currently-installed cursor + + virtual void SetClipboardText(const std::string& text); ///< sets text stored in clipboard + virtual void CopyFocusWndText(); ///< copies current focus Wnd as text to clipboard + virtual void CopyWndText(const Wnd* wnd); ///< copies \a wnd as text to clipboard //@} static GUI* GetGUI(); ///< allows any GG code access to GUI framework by calling GUI::GetGUI() Modified: trunk/FreeOrion/GG/GG/Wnd.h =================================================================== --- trunk/FreeOrion/GG/GG/Wnd.h 2013-10-19 21:08:01 UTC (rev 6457) +++ trunk/FreeOrion/GG/GG/Wnd.h 2013-10-20 00:18:37 UTC (rev 6458) @@ -575,7 +575,6 @@ If no layout exists for the window, this has no effect. */ void SetLayoutCellMargin(unsigned int margin); - /** Draws this Wnd. Note that Wnds being dragged for a drag-and-drop operation are rendered twice -- once in-place as normal, once in the location of the drag operation, attached to the cursor. Such Wnds may Modified: trunk/FreeOrion/GG/src/GUI.cpp =================================================================== --- trunk/FreeOrion/GG/src/GUI.cpp 2013-10-19 21:08:01 UTC (rev 6457) +++ trunk/FreeOrion/GG/src/GUI.cpp 2013-10-20 00:18:37 UTC (rev 6458) @@ -26,12 +26,12 @@ #include <GG/BrowseInfoWnd.h> #include <GG/Config.h> -#include <GG/Control.h> #include <GG/Cursor.h> #include <GG/EventPump.h> #include <GG/Layout.h> #include <GG/PluginInterface.h> #include <GG/StyleFactory.h> +#include <GG/Edit.h> #include <GG/Timer.h> #include <GG/ZList.h> #include <GG/utf8/checked.h> @@ -230,6 +230,8 @@ const Wnd* m_save_as_png_wnd; std::string m_save_as_png_filename; + + std::string m_clipboard_text; }; GUIImpl::GUIImpl() : @@ -266,7 +268,8 @@ m_style_factory(new StyleFactory()), m_render_cursor(false), m_cursor(), - m_save_as_png_wnd(0) + m_save_as_png_wnd(0), + m_clipboard_text() { m_button_state[0] = m_button_state[1] = m_button_state[2] = false; m_drag_wnds[0] = m_drag_wnds[1] = m_drag_wnds[2] = 0; @@ -1058,6 +1061,37 @@ void GUI::SetCursor(const boost::shared_ptr<Cursor>& cursor) { s_impl->m_cursor = cursor; } +const std::string& GUI::ClipboardText() const +{ return s_impl->m_clipboard_text; } + +void GUI::SetClipboardText(const std::string& text) +{ s_impl->m_clipboard_text = text; } + +void GUI::CopyFocusWndText() +{ + const Wnd* focus_wnd = FocusWnd(); + if (!focus_wnd) + return; + CopyWndText(focus_wnd); +} + +void GUI::CopyWndText(const Wnd* wnd) +{ + // presently only TextControl copying is supported. + + if (const TextControl* text_control = dynamic_cast<const TextControl*>(wnd)) { + if (const Edit* edit_control = dynamic_cast<const Edit*>(text_control)) { + // if TextControl is an Edit, it may have a subset of its text + // selected. in that case, only copy the selected text. if nothing + // is selected, revert to copying the full text of the TextControl. + std::string selected_text = edit_control->SelectedText(); + if (!selected_text.empty()) + SetClipboardText(selected_text); + } + SetClipboardText(text_control->Text()); + } +} + GUI* GUI::GetGUI() { return s_gui; } |
From: <geo...@us...> - 2013-10-26 10:21:21
|
Revision: 6471 http://sourceforge.net/p/freeorion/code/6471 Author: geoffthemedio Date: 2013-10-26 10:21:17 +0000 (Sat, 26 Oct 2013) Log Message: ----------- Tweaked GG scroll and multiedit scrolling code, primarily to make mousewheel scrolling move a few more lines per tick. Modified Paths: -------------- trunk/FreeOrion/GG/GG/Scroll.h trunk/FreeOrion/GG/src/MultiEdit.cpp trunk/FreeOrion/GG/src/Scroll.cpp Modified: trunk/FreeOrion/GG/GG/Scroll.h =================================================================== --- trunk/FreeOrion/GG/GG/Scroll.h 2013-10-26 09:48:08 UTC (rev 6470) +++ trunk/FreeOrion/GG/GG/Scroll.h 2013-10-26 10:21:17 UTC (rev 6471) @@ -103,8 +103,8 @@ void SetPageSize(unsigned int page); ///< sets the size of a line page in the scroll. This is the number of logical units the tab moves when either of the page-up or page-down areas is clicked. void ScrollTo(int p); ///< scrolls the control to a certain spot - void ScrollLineIncr(); ///< scrolls the control down (or right) by a line - void ScrollLineDecr(); ///< scrolls the control up (or left) by a line + void ScrollLineIncr(int lines = 1); ///< scrolls the control down (or right) by \a lines lines + void ScrollLineDecr(int lines = 1); ///< scrolls the control up (or left) by \a lines lines void ScrollPageIncr(); ///< scrolls the control down (or right) by a page void ScrollPageDecr(); ///< scrolls the control up (or left) by a page //@} @@ -136,8 +136,7 @@ private: void UpdatePosn(); ///< adjusts m_posn due to a tab-drag void MoveTabToPosn(); ///< adjusts tab due to a button click, PgUp, etc. - void ScrollLineIncrImpl(bool signal); - void ScrollLineDecrImpl(bool signal); + void ScrollLineIncrDecrImpl(bool signal, int lines); Clr m_int_color; ///< color inside border of slide area const Orientation m_orientation; ///< vertical or horizontal scroll? (use enum for these declared above) Modified: trunk/FreeOrion/GG/src/MultiEdit.cpp =================================================================== --- trunk/FreeOrion/GG/src/MultiEdit.cpp 2013-10-26 09:48:08 UTC (rev 6470) +++ trunk/FreeOrion/GG/src/MultiEdit.cpp 2013-10-26 10:21:17 UTC (rev 6471) @@ -598,16 +598,18 @@ void MultiEdit::MouseWheel(const Pt& pt, int move, Flags<ModKey> mod_keys) { - if (!Disabled() && m_vscroll) { - for (int i = 0; i < move; ++i) { - m_vscroll->ScrollLineDecr(); - SignalScroll(*m_vscroll, i == move - 1); - } - for (int i = 0; i < -move; ++i) { - m_vscroll->ScrollLineIncr(); - SignalScroll(*m_vscroll, i == -move - 1); - } + if (Disabled() || !m_vscroll) + return; + + // repeatedly increment scroll position for the requested number of moves. + for (int i = 0; i < move; ++i) { + m_vscroll->ScrollLineDecr(2); + SignalScroll(*m_vscroll, i == move - 1); } + for (int i = 0; i < -move; ++i) { + m_vscroll->ScrollLineIncr(2); + SignalScroll(*m_vscroll, i == -move - 1); + } } void MultiEdit::KeyPress(Key key, boost::uint32_t key_code_point, Flags<ModKey> mod_keys) Modified: trunk/FreeOrion/GG/src/Scroll.cpp =================================================================== --- trunk/FreeOrion/GG/src/Scroll.cpp 2013-10-26 09:48:08 UTC (rev 6470) +++ trunk/FreeOrion/GG/src/Scroll.cpp 2013-10-26 10:21:17 UTC (rev 6471) @@ -101,8 +101,8 @@ AttachChild(m_decr); AttachChild(m_incr); AttachChild(m_tab); - Connect(m_decr->LeftClickedSignal, boost::bind(&Scroll::ScrollLineDecrImpl, this, true)); - Connect(m_incr->LeftClickedSignal, boost::bind(&Scroll::ScrollLineIncrImpl, this, true)); + Connect(m_decr->LeftClickedSignal, boost::bind(&Scroll::ScrollLineIncrDecrImpl, this, true, -1)); + Connect(m_incr->LeftClickedSignal, boost::bind(&Scroll::ScrollLineIncrDecrImpl, this, true, 1)); m_tab->InstallEventFilter(this); if (INSTRUMENT_ALL_SIGNALS) { @@ -232,11 +232,11 @@ MoveTabToPosn(); } -void Scroll::ScrollLineIncr() -{ ScrollLineIncrImpl(false); } +void Scroll::ScrollLineIncr(int lines) +{ ScrollLineIncrDecrImpl(false, lines); } -void Scroll::ScrollLineDecr() -{ ScrollLineDecrImpl(false); } +void Scroll::ScrollLineDecr(int lines) +{ ScrollLineIncrDecrImpl(false, -lines); } void Scroll::ScrollPageIncr() { @@ -411,27 +411,25 @@ Pt(X(static_cast<int>(tab_location)), m_tab->RelativeUpperLeft().y)); } -void Scroll::ScrollLineIncrImpl(bool signal) +void Scroll::ScrollLineIncrDecrImpl(bool signal, int lines) { int old_posn = m_posn; - if (static_cast<int>(m_posn + m_line_sz) <= static_cast<int>(m_range_max - m_page_sz)) - m_posn += m_line_sz; - else - m_posn = m_range_max - (m_page_sz - 1); - MoveTabToPosn(); - if (signal && old_posn != m_posn) { - ScrolledSignal(m_posn, m_posn + m_page_sz, m_range_min, m_range_max); - ScrolledAndStoppedSignal(m_posn, m_posn + m_page_sz, m_range_min, m_range_max); + int move = lines * m_line_sz; + + if (move == 0) { + return; + } else if (move > 0) { + if (static_cast<int>(m_posn + move) <= static_cast<int>(m_range_max - m_page_sz)) + m_posn += move; + else + m_posn = m_range_max - (m_page_sz - 1); + } else { + if (static_cast<int>(m_posn + move) >= m_range_min) + m_posn += move; + else + m_posn = m_range_min; } -} -void Scroll::ScrollLineDecrImpl(bool signal) -{ - int old_posn = m_posn; - if (static_cast<int>(m_posn - m_line_sz) >= m_range_min) - m_posn -= m_line_sz; - else - m_posn = m_range_min; MoveTabToPosn(); if (signal && old_posn != m_posn) { ScrolledSignal(m_posn, m_posn + m_page_sz, m_range_min, m_range_max); |
From: <geo...@us...> - 2014-01-27 07:27:45
|
Revision: 6750 http://sourceforge.net/p/freeorion/code/6750 Author: geoffthemedio Date: 2014-01-27 07:27:42 +0000 (Mon, 27 Jan 2014) Log Message: ----------- -Reworked MultiEdit::SizeMove to retain its scroll position during a resize. -Added MultiEdit::SetScrollPosition to facilitate this. -Made MultiEdit::ScrollPosition public, and rewrote it to return the actual scroll positions instead of the numbers of the first shown row and column. Modified Paths: -------------- trunk/FreeOrion/GG/GG/MultiEdit.h trunk/FreeOrion/GG/src/MultiEdit.cpp Modified: trunk/FreeOrion/GG/GG/MultiEdit.h =================================================================== --- trunk/FreeOrion/GG/GG/MultiEdit.h 2014-01-27 06:40:41 UTC (rev 6749) +++ trunk/FreeOrion/GG/GG/MultiEdit.h 2014-01-27 07:27:42 UTC (rev 6750) @@ -81,6 +81,9 @@ keeps. This number includes the lines that are visible in the control. A value of ALL_LINES indicates that there is no limit. */ std::size_t MaxLinesOfHistory() const; + + /** Returns the positions of the scrollbars. */ + Pt ScrollPosition() const; //@} /** \name Mutators */ ///@{ @@ -97,6 +100,9 @@ /** Sets the maximum number of rows of text that the control will keep. ALL_LINES indicates no limit. */ void SetMaxLinesOfHistory(std::size_t max); + + /** Sets scroll position, bound by valid range of scrolls of this MultiEdit. */ + void SetScrollPosition(Pt pt); //@} /** A sentinel value that indicates that there is no limit on the number @@ -133,9 +139,6 @@ character. */ std::pair<std::size_t, CPSize> CharAt(CPSize idx) const; - /** Returns the positions of the scrollbars. */ - Pt ScrollPosition() const; - /** Returns the code point index of the start of the UTF-8 sequence for the code point at \a <i>char_idx</i> in row \a row, using \a line_data instead of the current line data, if it is supplied. If \a row, \a Modified: trunk/FreeOrion/GG/src/MultiEdit.cpp =================================================================== --- trunk/FreeOrion/GG/src/MultiEdit.cpp 2014-01-27 06:40:41 UTC (rev 6749) +++ trunk/FreeOrion/GG/src/MultiEdit.cpp 2014-01-27 07:27:42 UTC (rev 6750) @@ -250,9 +250,19 @@ if (m_style & MULTI_INTEGRAL_HEIGHT) lower_right.y -= ((lr.y - ul.y) - (2 * PIXEL_MARGIN)) % GetFont()->Lineskip(); bool resized = lower_right - ul != Size(); + + // need to restore scroll position after SetText call below, so that + // resizing this control doesn't reset the scroll position to the top. + // just calling PreserveTextPositionOnNextSetText() before the SetText + // call doesn't work as that leaves the scrollbars unadjusted for the resize + GG::Pt initial_scroll_pos = ScrollPosition(); + Edit::SizeMove(ul, lower_right); - if (resized) - SetText(Text()); + + if (resized) { + SetText(Text()); // resets scroll position to (0, 0) + SetScrollPosition(initial_scroll_pos); // restores scroll position + } } void MultiEdit::SelectAll() @@ -370,6 +380,34 @@ SetText(Text()); } +void MultiEdit::SetScrollPosition(Pt pt) +{ + if (m_hscroll) { + std::pair<int, int> range = m_hscroll->ScrollRange(); + if (pt.x < range.first) + pt.x = GG::X(range.first); + if (pt.x > range.second) + pt.x = GG::X(range.second); + std::pair<int, int> posn_range = m_hscroll->PosnRange(); + if (pt.x != posn_range.first) { + m_hscroll->ScrollTo(Value(pt.x)); + SignalScroll(*m_hscroll, true); + } + } + if (m_vscroll) { + std::pair<int, int> range = m_vscroll->ScrollRange(); + if (pt.y < range.first) + pt.y = GG::Y(range.first); + if (pt.y > range.second) + pt.y = GG::Y(range.second); + std::pair<int, int> posn_range = m_vscroll->PosnRange(); + if (pt.y != posn_range.first) { + m_vscroll->ScrollTo(Value(pt.y)); + SignalScroll(*m_vscroll, true); + } + } +} + bool MultiEdit::MultiSelected() const { return m_cursor_begin != m_cursor_end; } @@ -403,7 +441,14 @@ } Pt MultiEdit::ScrollPosition() const -{ return Pt(m_first_col_shown, m_first_row_shown); } +{ + Pt retval(GG::X0, GG::Y0); + if (m_hscroll) + retval.x = GG::X(m_hscroll->PosnRange().first); + if (m_vscroll) + retval.y = GG::Y(m_vscroll->PosnRange().first); + return retval; +} CPSize MultiEdit::CharIndexOf(std::size_t row, CPSize char_idx, const std::vector<Font::LineData>* line_data) const { |
From: <geo...@us...> - 2014-01-29 18:12:30
|
Revision: 6769 http://sourceforge.net/p/freeorion/code/6769 Author: geoffthemedio Date: 2014-01-29 18:12:24 +0000 (Wed, 29 Jan 2014) Log Message: ----------- -Added menu separators with (planned) distinct rendering -Adjusted response to clicking on disabled menu items or separators, so that doing so doesn't close a popup menu. Modified Paths: -------------- trunk/FreeOrion/GG/GG/Menu.h trunk/FreeOrion/GG/src/Menu.cpp Modified: trunk/FreeOrion/GG/GG/Menu.h =================================================================== --- trunk/FreeOrion/GG/GG/Menu.h 2014-01-29 11:41:15 UTC (rev 6768) +++ trunk/FreeOrion/GG/GG/Menu.h 2014-01-29 18:12:24 UTC (rev 6769) @@ -61,7 +61,8 @@ /** \name Structors */ ///@{ MenuItem(); ///< default ctor - MenuItem(const std::string& str, int id, bool disable, bool check); ///< ctor + MenuItem(const std::string& str, int id, bool disable, bool check); + explicit MenuItem(bool separator); /** Ctor that allows direct attachment of this item's signal to a "slot" function or functor */ @@ -93,6 +94,7 @@ int item_ID; ///< ID number associated with this menu item bool disabled; ///< set to true when this menu item is disabled bool checked; ///< set to true when this menu item can be toggled, and is currently on + bool separator; ///< set to true to render this menu item as a separator bar, rather than showing its text std::vector<MenuItem> next_level; ///< submenu off of this menu item; may be emtpy }; Modified: trunk/FreeOrion/GG/src/Menu.cpp =================================================================== --- trunk/FreeOrion/GG/src/Menu.cpp 2014-01-29 11:41:15 UTC (rev 6768) +++ trunk/FreeOrion/GG/src/Menu.cpp 2014-01-29 18:12:24 UTC (rev 6769) @@ -52,21 +52,32 @@ //////////////////////////////////////////////// // GG::MenuItem //////////////////////////////////////////////// -MenuItem::MenuItem() : +MenuItem::MenuItem() : SelectedIDSignal(new SelectedIDSignalType()), SelectedSignal(new SelectedSignalType()), - item_ID(0), - disabled(false), - checked(false) + item_ID(0), + disabled(false), + checked(false), + separator(false) {} -MenuItem::MenuItem(const std::string& str, int id, bool disable, bool check) : +MenuItem::MenuItem(bool separator) : + SelectedIDSignal(), + SelectedSignal(), + item_ID(0), + disabled(true), + checked(false), + separator(true) +{} + +MenuItem::MenuItem(const std::string& str, int id, bool disable, bool check) : SelectedIDSignal(new SelectedIDSignalType()), SelectedSignal(new SelectedSignalType()), - label(str), - item_ID(id), - disabled(disable), - checked(check) + label(str), + item_ID(id), + disabled(disable), + checked(check), + separator(false) { if (INSTRUMENT_ALL_SIGNALS) { Connect(*SelectedIDSignal, MenuSignalEcho("MenuItem::SelectedIDSignal")); @@ -74,13 +85,14 @@ } } -MenuItem::MenuItem(const std::string& str, int id, bool disable, bool check, const SelectedIDSlotType& slot) : +MenuItem::MenuItem(const std::string& str, int id, bool disable, bool check, const SelectedIDSlotType& slot) : SelectedIDSignal(new SelectedIDSignalType()), SelectedSignal(new SelectedSignalType()), - label(str), - item_ID(id), - disabled(disable), - checked(check) + label(str), + item_ID(id), + disabled(disable), + checked(check), + separator(false) { SelectedIDSignal->connect(slot); @@ -90,13 +102,14 @@ } } -MenuItem::MenuItem(const std::string& str, int id, bool disable, bool check, const SelectedSlotType& slot) : +MenuItem::MenuItem(const std::string& str, int id, bool disable, bool check, const SelectedSlotType& slot) : SelectedIDSignal(new SelectedIDSignalType()), SelectedSignal(new SelectedSignalType()), - label(str), - item_ID(id), - disabled(disable), - checked(check) + label(str), + item_ID(id), + disabled(disable), + checked(check), + separator(false) { SelectedSignal->connect(slot); @@ -480,7 +493,7 @@ m_open_levels[i] = r; // paint caret, if any - if (m_caret[i] != INVALID_CARET) { + if (m_caret[i] != INVALID_CARET && !menu.next_level[m_caret[i]].separator) { Rect tmp_r = r; tmp_r.ul.y += static_cast<int>(m_caret[i]) * m_font->Lineskip(); tmp_r.lr.y = tmp_r.ul.y + m_font->Lineskip() + 3; @@ -498,22 +511,43 @@ line_rect.ul.x += HORIZONTAL_MARGIN; line_rect.lr.x -= HORIZONTAL_MARGIN; for (std::size_t j = 0; j < menu.next_level.size(); ++j) { - Clr clr = (m_caret[i] == j) ? - (menu.next_level[j].disabled ? DisabledColor(m_sel_text_color) : m_sel_text_color) : - (menu.next_level[j].disabled ? DisabledColor(m_text_color) : m_text_color); + Clr clr = (m_caret[i] == j) + ? (menu.next_level[j].disabled + ? DisabledColor(m_sel_text_color) + : m_sel_text_color) + : (menu.next_level[j].disabled + ? DisabledColor(m_text_color) + : m_text_color); glColor3ub(clr.r, clr.g, clr.b); - m_font->RenderText(line_rect.ul, line_rect.lr, menu.next_level[j].label, fmt); + + if (!menu.next_level[j].separator) { + m_font->RenderText(line_rect.ul, line_rect.lr, menu.next_level[j].label, fmt); + } else { + glDisable(GL_TEXTURE_2D); + glBegin(GL_LINE); + glVertex(line_rect.ul.x + HORIZONTAL_MARGIN, + line_rect.ul.y + Value(INDICATOR_HEIGHT / 2.0)); + glVertex(line_rect.lr.x - HORIZONTAL_MARGIN, + line_rect.ul.y + Value(INDICATOR_HEIGHT / 2.0)); + glEnd(); + glEnable(GL_TEXTURE_2D); + } + if (menu.next_level[j].checked) { FlatCheck(Pt(line_rect.lr.x - CHECK_WIDTH - HORIZONTAL_MARGIN, line_rect.ul.y + INDICATOR_VERTICAL_MARGIN), Pt(line_rect.lr.x - HORIZONTAL_MARGIN, line_rect.ul.y + INDICATOR_VERTICAL_MARGIN + CHECK_HEIGHT), clr); } - if (menu.next_level[j].next_level.size()) { + // submenu indicator arrow + if (menu.next_level[j].next_level.size() > 0u) { glDisable(GL_TEXTURE_2D); glBegin(GL_TRIANGLES); - glVertex(line_rect.lr.x - Value(INDICATOR_HEIGHT / 2.0) - HORIZONTAL_MARGIN, line_rect.ul.y + INDICATOR_VERTICAL_MARGIN); - glVertex(line_rect.lr.x - Value(INDICATOR_HEIGHT / 2.0) - HORIZONTAL_MARGIN, line_rect.ul.y + m_font->Lineskip() - INDICATOR_VERTICAL_MARGIN); - glVertex(line_rect.lr.x - HORIZONTAL_MARGIN, line_rect.ul.y + m_font->Lineskip() / 2.0); + glVertex(line_rect.lr.x - Value(INDICATOR_HEIGHT / 2.0) - HORIZONTAL_MARGIN, + line_rect.ul.y + INDICATOR_VERTICAL_MARGIN); + glVertex(line_rect.lr.x - Value(INDICATOR_HEIGHT / 2.0) - HORIZONTAL_MARGIN, + line_rect.ul.y + m_font->Lineskip() - INDICATOR_VERTICAL_MARGIN); + glVertex(line_rect.lr.x - HORIZONTAL_MARGIN, + line_rect.ul.y + m_font->Lineskip() / 2.0); glEnd(); glEnable(GL_TEXTURE_2D); } @@ -532,12 +566,14 @@ menu_ptr = &menu_ptr->next_level[m_caret[i]]; } } - if (!menu_ptr->disabled) { + if (!menu_ptr->disabled && !menu_ptr->separator) { m_item_selected = menu_ptr; + m_done = true; } + } else { + m_done = true; } BrowsedSignal(0); - m_done = true; } void PopupMenu::LClick(const Pt& pt, Flags<ModKey> mod_keys) |
From: <geo...@us...> - 2014-02-02 17:34:26
|
Revision: 6808 http://sourceforge.net/p/freeorion/code/6808 Author: geoffthemedio Date: 2014-02-02 17:34:23 +0000 (Sun, 02 Feb 2014) Log Message: ----------- Added some optional signal parameters to ListBox::Insert and DropDownList::Insert overloads. Defaults should replicate existing behaviour. Modified Paths: -------------- trunk/FreeOrion/GG/GG/DropDownList.h trunk/FreeOrion/GG/GG/ListBox.h trunk/FreeOrion/GG/src/DropDownList.cpp trunk/FreeOrion/GG/src/ListBox.cpp Modified: trunk/FreeOrion/GG/GG/DropDownList.h =================================================================== --- trunk/FreeOrion/GG/GG/DropDownList.h 2014-02-02 16:19:53 UTC (rev 6807) +++ trunk/FreeOrion/GG/GG/DropDownList.h 2014-02-02 17:34:23 UTC (rev 6808) @@ -126,15 +126,15 @@ list before \a it; returns index of insertion point. This Row becomes the property of the DropDownList and should not be deleted or inserted into any other DropDownLists */ - iterator Insert(Row* row, iterator it); + iterator Insert(Row* row, iterator it, bool signal = true); /** Insertion sorts \a row into a sorted list, or inserts into an unsorted list at the end of the list; returns index of insertion point. This Row becomes the property of the DropDownList and should not be deleted or inserted into any other DropDownLists */ - iterator Insert(Row* row); + iterator Insert(Row* row, bool signal = true); - Row* Erase(iterator it); ///< removes and returns \a it from the list, or 0 if no such row exists + Row* Erase(iterator it, bool signal = false); ///< removes and returns \a it from the list, or 0 if no such row exists void Clear(); ///< empties the list iterator begin(); ///< returns an iterator to the first list row iterator end(); ///< returns an iterator to the imaginary row one past the last one @@ -148,7 +148,7 @@ void Select(std::size_t n); ///< selects row-item \a it in the list void SetInteriorColor(Clr c); ///< sets the color painted into the client area of the control - void SetDropHeight(Y h); ///< sets the height of the drop-down list + void SetDropHeight(Y h); ///< sets the height of the drop-down list /** sets the style flags for the list to \a s (invalidates currently selected item). \see GG::ListBoxStyle */ void SetStyle(Flags<ListBoxStyle> s); Modified: trunk/FreeOrion/GG/GG/ListBox.h =================================================================== --- trunk/FreeOrion/GG/GG/ListBox.h 2014-02-02 16:19:53 UTC (rev 6807) +++ trunk/FreeOrion/GG/GG/ListBox.h 2014-02-02 17:34:23 UTC (rev 6808) @@ -350,21 +350,21 @@ /** Insertion sorts \a row into the ListBox if sorted, or inserts into an unsorted ListBox before \a it; returns insertion point. This Row becomes the property of the ListBox. */ - iterator Insert(Row* row, iterator it); + iterator Insert(Row* row, iterator it, bool signal = true); /** Insertion sorts \a row into the ListBox if sorted, or inserts into an unsorted ListBox at the end of the list; returns insertion point. This Row becomes the property of the ListBox. */ - iterator Insert(Row* row); + iterator Insert(Row* row, bool signal = true); - Row* Erase(iterator it); ///< removes and returns the row that \a it points to from the ListBox, or 0 if no such row exists - void Clear(); ///< empties the ListBox - void SelectRow(iterator it); ///< selects row \a it - void DeselectRow(iterator it); ///< deselects row \a it - void SelectAll(); ///< selects all rows - void DeselectAll(); ///< deselects all rows - iterator begin(); ///< returns an iterator to the first list row - iterator end(); ///< returns an iterator to the imaginary row one past the last one + Row* Erase(iterator it, bool signal = false); ///< removes and returns the row that \a it points to from the ListBox, or 0 if no such row exists + void Clear(); ///< empties the ListBox + void SelectRow(iterator it); ///< selects row \a it + void DeselectRow(iterator it); ///< deselects row \a it + void SelectAll(); ///< selects all rows + void DeselectAll(); ///< deselects all rows + iterator begin(); ///< returns an iterator to the first list row + iterator end(); ///< returns an iterator to the imaginary row one past the last one reverse_iterator rbegin(); ///< returns an iterator to the last list row reverse_iterator Modified: trunk/FreeOrion/GG/src/DropDownList.cpp =================================================================== --- trunk/FreeOrion/GG/src/DropDownList.cpp 2014-02-02 16:19:53 UTC (rev 6807) +++ trunk/FreeOrion/GG/src/DropDownList.cpp 2014-02-02 17:34:23 UTC (rev 6808) @@ -237,23 +237,23 @@ void DropDownList::SetColor(Clr c) { m_LB->SetColor(c); } -DropDownList::iterator DropDownList::Insert(Row* row, iterator it) +DropDownList::iterator DropDownList::Insert(Row* row, iterator it, bool signal/* = true*/) { row->SetDragDropDataType(""); - return m_LB->Insert(row, it); + return m_LB->Insert(row, it, signal); } -DropDownList::iterator DropDownList::Insert(Row* row) +DropDownList::iterator DropDownList::Insert(Row* row, bool signal/* = true*/) { row->SetDragDropDataType(""); - return m_LB->Insert(row); + return m_LB->Insert(row, signal); } -DropDownList::Row* DropDownList::Erase(iterator it) +DropDownList::Row* DropDownList::Erase(iterator it, bool signal/* = false*/) { if (it == m_current_item) m_current_item = m_LB->end(); - return m_LB->Erase(it); + return m_LB->Erase(it, signal); } void DropDownList::Clear() Modified: trunk/FreeOrion/GG/src/ListBox.cpp =================================================================== --- trunk/FreeOrion/GG/src/ListBox.cpp 2014-02-02 16:19:53 UTC (rev 6807) +++ trunk/FreeOrion/GG/src/ListBox.cpp 2014-02-02 17:34:23 UTC (rev 6808) @@ -814,14 +814,14 @@ m_hscroll->SetColor(c); } -ListBox::iterator ListBox::Insert(Row* row, iterator it) -{ return Insert(row, it, false, true); } +ListBox::iterator ListBox::Insert(Row* row, iterator it, bool signal/* = true*/) +{ return Insert(row, it, false, signal); } -ListBox::iterator ListBox::Insert(Row* row) -{ return Insert(row, m_rows.end(), false, true); } +ListBox::iterator ListBox::Insert(Row* row, bool signal/* = true*/) +{ return Insert(row, m_rows.end(), false, signal); } -ListBox::Row* ListBox::Erase(iterator it) -{ return Erase(it, false, false); } +ListBox::Row* ListBox::Erase(iterator it, bool signal/* = false*/) +{ return Erase(it, false, signal); } void ListBox::Clear() { |
From: <mar...@us...> - 2014-02-08 17:05:39
|
Revision: 6860 http://sourceforge.net/p/freeorion/code/6860 Author: marcel_metz Date: 2014-02-08 17:05:36 +0000 (Sat, 08 Feb 2014) Log Message: ----------- Removed unused GG tutorial and test features. Modified Paths: -------------- trunk/FreeOrion/GG/CMakeLists.txt trunk/FreeOrion/GG/doc/GGDoc.txt Removed Paths: ------------- trunk/FreeOrion/GG/test/ trunk/FreeOrion/GG/tutorial/ Modified: trunk/FreeOrion/GG/CMakeLists.txt =================================================================== --- trunk/FreeOrion/GG/CMakeLists.txt 2014-02-08 11:49:18 UTC (rev 6859) +++ trunk/FreeOrion/GG/CMakeLists.txt 2014-02-08 17:05:36 UTC (rev 6860) @@ -58,9 +58,6 @@ "Install development files." ON) -cmake_dependent_option(BUILD_TUTORIALS "Build tutorial applications." OFF BUILD_SDL_DRIVER OFF) -cmake_dependent_option(BUILD_TESTS "Build tests applications." OFF BUILD_SDL_DRIVER OFF) - if (NOT DEFINED USE_STATIC_LIBS) add_definitions(-DBOOST_ALL_DYN_LINK) endif () @@ -157,15 +154,6 @@ ######################################## add_subdirectory(src) -if (BUILD_TESTS) - add_subdirectory(test) -endif () - -if (BUILD_TUTORIALS) - add_subdirectory(tutorial) -endif () - - ######################################## # Documentation # ######################################## Modified: trunk/FreeOrion/GG/doc/GGDoc.txt =================================================================== --- trunk/FreeOrion/GG/doc/GGDoc.txt 2014-02-08 11:49:18 UTC (rev 6859) +++ trunk/FreeOrion/GG/doc/GGDoc.txt 2014-02-08 17:05:36 UTC (rev 6860) @@ -511,15 +511,6 @@ */ -/** \page tutorials Tutorials - \section tut_using Using the Tutorials - The following tutorials are available in the tutorial directory. They are built by default when you build GG. - \section tut_1 Tutorial 1: Minimal (minimal.cpp) - This is the minimal interesting GG application, and uses one of the default input drivers, SDL. - \section tut_2 Tutorial 2: Controls (controls.cpp) - This builds upon Tutorial 1 by adding one of every type of Control, and connecting some signals and slots. -*/ - /** \mainpage GG Documentation Overviews \section Overviews -# \ref design @@ -529,5 +520,4 @@ -# \ref drag_n_drop -# \ref brief_tour -# \ref building - -# \ref tutorials */ |
From: <geo...@us...> - 2014-03-27 15:54:55
|
Revision: 7000 http://sourceforge.net/p/freeorion/code/7000 Author: geoffthemedio Date: 2014-03-27 15:54:52 +0000 (Thu, 27 Mar 2014) Log Message: ----------- -Added storage of modal list picker to DropDownList, which is updated when a modal picker is created and can be used to EndRun on that picker if the containing drop list is destroyed while the picker Wnd is running. -grooming Modified Paths: -------------- trunk/FreeOrion/GG/GG/DropDownList.h trunk/FreeOrion/GG/src/DropDownList.cpp Modified: trunk/FreeOrion/GG/GG/DropDownList.h =================================================================== --- trunk/FreeOrion/GG/GG/DropDownList.h 2014-03-27 15:51:30 UTC (rev 6999) +++ trunk/FreeOrion/GG/GG/DropDownList.h 2014-03-27 15:54:52 UTC (rev 7000) @@ -33,6 +33,9 @@ #include <GG/ListBox.h> +namespace { + class ModalListPicker; +} namespace GG { @@ -195,8 +198,9 @@ private: void SelectImpl(iterator it, bool signal); - iterator m_current_item; ///< the currently-selected list item (end() if none is selected) - ListBox* m_LB; ///< the ListBox used to render the selected row and the popup list + iterator m_current_item; ///< the currently-selected list item (end() if none is selected) + ListBox* m_LB; ///< the ListBox used to render the selected row and the popup list + ModalListPicker*m_modal_picker; }; } // namespace GG Modified: trunk/FreeOrion/GG/src/DropDownList.cpp =================================================================== --- trunk/FreeOrion/GG/src/DropDownList.cpp 2014-03-27 15:51:30 UTC (rev 6999) +++ trunk/FreeOrion/GG/src/DropDownList.cpp 2014-03-27 15:54:52 UTC (rev 7000) @@ -110,14 +110,16 @@ DropDownList::DropDownList() : Control(), m_current_item(), - m_LB(0) + m_LB(0), + m_modal_picker(0) {} DropDownList::DropDownList(X x, Y y, X w, Y h, Y drop_ht, Clr color, Flags<WndFlag> flags/* = INTERACTIVE*/) : Control(x, y, w, h, flags), m_current_item(), - m_LB(GetStyleFactory()->NewDropDownListListBox(x, y, w, drop_ht, color, color, flags)) + m_LB(GetStyleFactory()->NewDropDownListListBox(x, y, w, drop_ht, color, color, flags)), + m_modal_picker(0) { SetStyle(LIST_SINGLESEL); // adjust size to keep correct height based on row height, etc. @@ -129,8 +131,12 @@ Connect(SelChangedSignal, SelChangedEcho(*this)); } -DropDownList::~DropDownList() -{ delete m_LB; } +DropDownList::~DropDownList() { + if (m_modal_picker) + m_modal_picker->EndRun(); + m_modal_picker = 0; + delete m_LB; +} DropDownList::iterator DropDownList::CurrentItem() const { return m_current_item; } @@ -275,6 +281,9 @@ void DropDownList::Clear() { m_current_item = m_LB->end(); + if (m_modal_picker) + m_modal_picker->EndRun(); + m_modal_picker = 0; m_LB->Clear(); } @@ -339,18 +348,22 @@ void DropDownList::LClick(const Pt& pt, Flags<ModKey> mod_keys) { - if (!Disabled()) { - ModalListPicker picker(this, m_LB); - const ListBox::SelectionSet& LB_sels = m_LB->Selections(); - if (!LB_sels.empty()) { - if (m_LB->m_vscroll) { - m_LB->m_vscroll->ScrollTo(0); - SignalScroll(*m_LB->m_vscroll, true); - } + if (Disabled()) + return; + + ModalListPicker picker(this, m_LB); + m_modal_picker = &picker; + + const ListBox::SelectionSet& LB_sels = m_LB->Selections(); + if (!LB_sels.empty()) { + if (m_LB->m_vscroll) { + m_LB->m_vscroll->ScrollTo(0); + SignalScroll(*m_LB->m_vscroll, true); } - m_LB->m_first_col_shown = 0; - picker.Run(); } + m_LB->m_first_col_shown = 0; + picker.Run(); + m_modal_picker = 0; } void DropDownList::KeyPress(Key key, boost::uint32_t key_code_point, Flags<ModKey> mod_keys) |
From: <mar...@us...> - 2014-04-02 12:55:43
|
Revision: 7008 http://sourceforge.net/p/freeorion/code/7008 Author: marcel_metz Date: 2014-04-02 12:55:40 +0000 (Wed, 02 Apr 2014) Log Message: ----------- Moved ModalListPicker out of the anonymous namespace to prevent issues with exporting the DropDownList symbols. Modified Paths: -------------- trunk/FreeOrion/GG/GG/DropDownList.h trunk/FreeOrion/GG/src/DropDownList.cpp Modified: trunk/FreeOrion/GG/GG/DropDownList.h =================================================================== --- trunk/FreeOrion/GG/GG/DropDownList.h 2014-04-01 10:27:24 UTC (rev 7007) +++ trunk/FreeOrion/GG/GG/DropDownList.h 2014-04-02 12:55:40 UTC (rev 7008) @@ -33,9 +33,7 @@ #include <GG/ListBox.h> -namespace { - class ModalListPicker; -} +class ModalListPicker; namespace GG { Modified: trunk/FreeOrion/GG/src/DropDownList.cpp =================================================================== --- trunk/FreeOrion/GG/src/DropDownList.cpp 2014-04-01 10:27:24 UTC (rev 7007) +++ trunk/FreeOrion/GG/src/DropDownList.cpp 2014-04-02 12:55:40 UTC (rev 7008) @@ -49,60 +49,60 @@ }; const int BORDER_THICK = 2; // should be the same as the BORDER_THICK value in GGListBox.h +} - class ModalListPicker : public Wnd +class ModalListPicker : public Wnd +{ +public: + ModalListPicker(DropDownList* drop_wnd, ListBox* lb_wnd) : + Wnd(X0, Y0, GUI::GetGUI()->AppWidth(), GUI::GetGUI()->AppHeight(), + INTERACTIVE | MODAL), + m_drop_wnd(drop_wnd), + m_lb_wnd(lb_wnd), + m_old_lb_ul(m_lb_wnd->UpperLeft()) { - public: - ModalListPicker(DropDownList* drop_wnd, ListBox* lb_wnd) : - Wnd(X0, Y0, GUI::GetGUI()->AppWidth(), GUI::GetGUI()->AppHeight(), - INTERACTIVE | MODAL), - m_drop_wnd(drop_wnd), - m_lb_wnd(lb_wnd), - m_old_lb_ul(m_lb_wnd->UpperLeft()) - { - m_connection_1 = - Connect(m_lb_wnd->SelChangedSignal, &ModalListPicker::LBSelChangedSlot, this); - m_connection_2 = - Connect(m_lb_wnd->LeftClickedSignal, &ModalListPicker::LBLeftClickSlot, this); - m_lb_ul = m_old_lb_ul + m_drop_wnd->UpperLeft(); - AttachChild(m_lb_wnd); - } + m_connection_1 = + Connect(m_lb_wnd->SelChangedSignal, &ModalListPicker::LBSelChangedSlot, this); + m_connection_2 = + Connect(m_lb_wnd->LeftClickedSignal, &ModalListPicker::LBLeftClickSlot, this); + m_lb_ul = m_old_lb_ul + m_drop_wnd->UpperLeft(); + AttachChild(m_lb_wnd); + } - virtual void Render() - { m_lb_wnd->MoveTo(m_lb_ul); } + virtual void Render() + { m_lb_wnd->MoveTo(m_lb_ul); } - ~ModalListPicker() - { - m_lb_wnd->MoveTo(m_old_lb_ul); - DetachChild(m_lb_wnd); - } + ~ModalListPicker() + { + m_lb_wnd->MoveTo(m_old_lb_ul); + DetachChild(m_lb_wnd); + } - protected: - virtual void LClick(const Pt& pt, Flags<ModKey> mod_keys) - { m_done = true; } +protected: + virtual void LClick(const Pt& pt, Flags<ModKey> mod_keys) + { m_done = true; } - private: - void LBSelChangedSlot(const ListBox::SelectionSet& rows) - { - if (!rows.empty()) { - m_drop_wnd->Select(*rows.begin()); - m_drop_wnd->SelChangedSignal(m_drop_wnd->CurrentItem()); - m_done = true; - } +private: + void LBSelChangedSlot(const ListBox::SelectionSet& rows) + { + if (!rows.empty()) { + m_drop_wnd->Select(*rows.begin()); + m_drop_wnd->SelChangedSignal(m_drop_wnd->CurrentItem()); + m_done = true; } + } - void LBLeftClickSlot(ListBox::iterator it, const Pt&) - { m_done = true; } + void LBLeftClickSlot(ListBox::iterator it, const Pt&) + { m_done = true; } - DropDownList* m_drop_wnd; - ListBox* m_lb_wnd; - Pt m_old_lb_ul; - Pt m_lb_ul; + DropDownList* m_drop_wnd; + ListBox* m_lb_wnd; + Pt m_old_lb_ul; + Pt m_lb_ul; - boost::signals2::scoped_connection m_connection_1; - boost::signals2::scoped_connection m_connection_2; - }; -} + boost::signals2::scoped_connection m_connection_1; + boost::signals2::scoped_connection m_connection_2; +}; //////////////////////////////////////////////// // GG::DropDownList |
From: <geo...@us...> - 2014-04-05 23:34:51
|
Revision: 7019 http://sourceforge.net/p/freeorion/code/7019 Author: geoffthemedio Date: 2014-04-05 23:34:45 +0000 (Sat, 05 Apr 2014) Log Message: ----------- Added Left, Right, Bottom, and Top functions to Wnd to allow replacing UpperLeft().x and similar with slightly shorter equivalents. Modified Paths: -------------- trunk/FreeOrion/GG/GG/Wnd.h trunk/FreeOrion/GG/src/Wnd.cpp Modified: trunk/FreeOrion/GG/GG/Wnd.h =================================================================== --- trunk/FreeOrion/GG/GG/Wnd.h 2014-04-05 23:14:54 UTC (rev 7018) +++ trunk/FreeOrion/GG/GG/Wnd.h 2014-04-05 23:34:45 UTC (rev 7019) @@ -319,11 +319,15 @@ /** Returns the upper-left corner of window in \a screen \a coordinates (taking into account parent's screen position, if any) */ Pt UpperLeft() const; + X Left() const; + Y Top() const; /** Returns (one pixel past) the lower-right corner of window in \a screen \a coordinates (taking into account parent's screen position, if any) */ Pt LowerRight() const; + X Right() const; + Y Bottom() const; /** Returns the upper-left corner of window, relative to its parent's client area, or in screen coordinates if no parent exists. */ Modified: trunk/FreeOrion/GG/src/Wnd.cpp =================================================================== --- trunk/FreeOrion/GG/src/Wnd.cpp 2014-04-05 23:14:54 UTC (rev 7018) +++ trunk/FreeOrion/GG/src/Wnd.cpp 2014-04-05 23:34:45 UTC (rev 7019) @@ -72,25 +72,25 @@ bool operator()(const Pt& pt, Y y) const {return y < pt.y;} }; struct Pointer {}; - struct Left {}; - struct Top {}; - struct Right {}; - struct Bottom {}; + struct LayoutLeft {}; + struct LayoutTop {}; + struct LayoutRight {}; + struct LayoutBottom {}; typedef multi_index_container< GridLayoutWnd, indexed_by< - ordered_unique<tag<Pointer>, member<GridLayoutWnd, Wnd*, &GridLayoutWnd::wnd> >, - ordered_non_unique<tag<Left>, member<GridLayoutWnd, Pt, &GridLayoutWnd::ul>, IsLeft>, - ordered_non_unique<tag<Top>, member<GridLayoutWnd, Pt, &GridLayoutWnd::ul>, IsTop>, - ordered_non_unique<tag<Right>, member<GridLayoutWnd, Pt, &GridLayoutWnd::lr>, IsRight>, - ordered_non_unique<tag<Bottom>, member<GridLayoutWnd, Pt, &GridLayoutWnd::lr>, IsBottom> + ordered_unique<tag<Pointer>, member<GridLayoutWnd, Wnd*, &GridLayoutWnd::wnd> >, + ordered_non_unique<tag<LayoutLeft>, member<GridLayoutWnd, Pt, &GridLayoutWnd::ul>, IsLeft>, + ordered_non_unique<tag<LayoutTop>, member<GridLayoutWnd, Pt, &GridLayoutWnd::ul>, IsTop>, + ordered_non_unique<tag<LayoutRight>, member<GridLayoutWnd, Pt, &GridLayoutWnd::lr>, IsRight>, + ordered_non_unique<tag<LayoutBottom>, member<GridLayoutWnd, Pt, &GridLayoutWnd::lr>, IsBottom> > > GridLayoutWndContainer; - typedef GridLayoutWndContainer::index<Pointer>::type::iterator PointerIter; - typedef GridLayoutWndContainer::index<Left>::type::iterator LeftIter; - typedef GridLayoutWndContainer::index<Top>::type::iterator TopIter; - typedef GridLayoutWndContainer::index<Right>::type::iterator RightIter; - typedef GridLayoutWndContainer::index<Bottom>::type::iterator BottomIter; + typedef GridLayoutWndContainer::index<Pointer>::type::iterator PointerIter; + typedef GridLayoutWndContainer::index<LayoutLeft>::type::iterator LeftIter; + typedef GridLayoutWndContainer::index<LayoutTop>::type::iterator TopIter; + typedef GridLayoutWndContainer::index<LayoutRight>::type::iterator RightIter; + typedef GridLayoutWndContainer::index<LayoutBottom>::type::iterator BottomIter; struct WndHorizontalLess { @@ -278,6 +278,12 @@ return retval; } +X Wnd::Left() const +{ return UpperLeft().x; } + +Y Wnd::Top() const +{ return UpperLeft().y; } + Pt Wnd::LowerRight() const { Pt retval = m_lowerright; @@ -286,6 +292,12 @@ return retval; } +X Wnd::Right() const +{ return LowerRight().x; } + +Y Wnd::Bottom() const +{ return LowerRight().y; } + Pt Wnd::RelativeUpperLeft() const { return m_upperleft; } @@ -688,60 +700,62 @@ // align left sides of windows - for (LeftIter it = grid_layout.get<Left>().begin(); it != grid_layout.get<Left>().end(); ++it) { + for (LeftIter it = grid_layout.get<LayoutLeft>().begin(); + it != grid_layout.get<LayoutLeft>().end(); ++it) + { Pt ul = it->ul; for (X x = ul.x - 1; x >= 0; --x) { - if (grid_layout.get<Right>().find(x + 1, IsRight()) != grid_layout.get<Right>().end()) { + if (grid_layout.get<LayoutRight>().find(x + 1, IsRight()) != grid_layout.get<LayoutRight>().end()) { break; - } else if (grid_layout.get<Left>().find(x, IsLeft()) != grid_layout.get<Left>().end()) { + } else if (grid_layout.get<LayoutLeft>().find(x, IsLeft()) != grid_layout.get<LayoutLeft>().end()) { GridLayoutWnd grid_wnd = *it; grid_wnd.ul.x = x; - grid_layout.get<Left>().replace(it, grid_wnd); + grid_layout.get<LayoutLeft>().replace(it, grid_wnd); break; } } } // align right sides of windows - for (RightIter it = grid_layout.get<Right>().begin(); it != grid_layout.get<Right>().end(); ++it) { + for (RightIter it = grid_layout.get<LayoutRight>().begin(); it != grid_layout.get<LayoutRight>().end(); ++it) { Pt lr = it->lr; for (X x = lr.x + 1; x < client_sz.x; ++x) { - if (grid_layout.get<Left>().find(x - 1, IsLeft()) != grid_layout.get<Left>().end()) { + if (grid_layout.get<LayoutLeft>().find(x - 1, IsLeft()) != grid_layout.get<LayoutLeft>().end()) { break; - } else if (grid_layout.get<Right>().find(x, IsRight()) != grid_layout.get<Right>().end()) { + } else if (grid_layout.get<LayoutRight>().find(x, IsRight()) != grid_layout.get<LayoutRight>().end()) { GridLayoutWnd grid_wnd = *it; grid_wnd.lr.x = x; - grid_layout.get<Right>().replace(it, grid_wnd); + grid_layout.get<LayoutRight>().replace(it, grid_wnd); break; } } } // align tops of windows - for (TopIter it = grid_layout.get<Top>().begin(); it != grid_layout.get<Top>().end(); ++it) { + for (TopIter it = grid_layout.get<LayoutTop>().begin(); it != grid_layout.get<LayoutTop>().end(); ++it) { Pt ul = it->ul; for (Y y = ul.y - 1; y >= 0; --y) { - if (grid_layout.get<Bottom>().find(y + 1, IsBottom()) != grid_layout.get<Bottom>().end()) { + if (grid_layout.get<LayoutBottom>().find(y + 1, IsBottom()) != grid_layout.get<LayoutBottom>().end()) { break; - } else if (grid_layout.get<Top>().find(y, IsTop()) != grid_layout.get<Top>().end()) { + } else if (grid_layout.get<LayoutTop>().find(y, IsTop()) != grid_layout.get<LayoutTop>().end()) { GridLayoutWnd grid_wnd = *it; grid_wnd.ul.y = y; - grid_layout.get<Top>().replace(it, grid_wnd); + grid_layout.get<LayoutTop>().replace(it, grid_wnd); break; } } } // align bottoms of windows - for (BottomIter it = grid_layout.get<Bottom>().begin(); it != grid_layout.get<Bottom>().end(); ++it) { + for (BottomIter it = grid_layout.get<LayoutBottom>().begin(); it != grid_layout.get<LayoutBottom>().end(); ++it) { Pt lr = it->lr; for (Y y = lr.y + 1; y < client_sz.y; ++y) { - if (grid_layout.get<Top>().find(y - 1, IsTop()) != grid_layout.get<Top>().end()) { + if (grid_layout.get<LayoutTop>().find(y - 1, IsTop()) != grid_layout.get<LayoutTop>().end()) { break; - } else if (grid_layout.get<Bottom>().find(y, IsBottom()) != grid_layout.get<Bottom>().end()) { + } else if (grid_layout.get<LayoutBottom>().find(y, IsBottom()) != grid_layout.get<LayoutBottom>().end()) { GridLayoutWnd grid_wnd = *it; grid_wnd.lr.y = y; - grid_layout.get<Bottom>().replace(it, grid_wnd); + grid_layout.get<LayoutBottom>().replace(it, grid_wnd); break; } } @@ -750,10 +764,10 @@ // create an actual layout with a more reasonable number of cells from the pixel-grid layout std::set<X> unique_lefts; std::set<Y> unique_tops; - for (LeftIter it = grid_layout.get<Left>().begin(); it != grid_layout.get<Left>().end(); ++it) { + for (LeftIter it = grid_layout.get<LayoutLeft>().begin(); it != grid_layout.get<LayoutLeft>().end(); ++it) { unique_lefts.insert(it->ul.x); } - for (TopIter it = grid_layout.get<Top>().begin(); it != grid_layout.get<Top>().end(); ++it) { + for (TopIter it = grid_layout.get<LayoutTop>().begin(); it != grid_layout.get<LayoutTop>().end(); ++it) { unique_tops.insert(it->ul.y); } |
From: <geo...@us...> - 2014-04-06 12:06:14
|
Revision: 7020 http://sourceforge.net/p/freeorion/code/7020 Author: geoffthemedio Date: 2014-04-06 12:06:12 +0000 (Sun, 06 Apr 2014) Log Message: ----------- -Reworked DropDownList ModalListPicker to have its ListBox as a child, rather than taking its parent's ListBox as a parameter to the constructor and then storing a separate pointer, as this was leading to some crashes when the parent was destructed while the picker was open. -grooming Modified Paths: -------------- trunk/FreeOrion/GG/GG/DropDownList.h trunk/FreeOrion/GG/src/DropDownList.cpp Modified: trunk/FreeOrion/GG/GG/DropDownList.h =================================================================== --- trunk/FreeOrion/GG/GG/DropDownList.h 2014-04-05 23:34:45 UTC (rev 7019) +++ trunk/FreeOrion/GG/GG/DropDownList.h 2014-04-06 12:06:12 UTC (rev 7020) @@ -75,65 +75,65 @@ //@} /** \name Accessors */ ///@{ - iterator CurrentItem() const; ///< returns the currently selected list item (returns end() if none is selected) - std::size_t CurrentItemIndex() const; ///< returns the position of the currently selected list item within the list (returns -1 if none is selected) + iterator CurrentItem() const; ///< returns the currently selected list item (returns end() if none is selected) + std::size_t CurrentItemIndex() const; ///< returns the position of the currently selected list item within the list (returns -1 if none is selected) - std::size_t IteratorToIndex(iterator it) const; ///< returns the position of \a it within the list (returns -1 if \a it == end()) - iterator IndexToIterator(std::size_t n) const; ///< returns an iterator to the row in position \a n (returns end() if \a n is an invalid index) + std::size_t IteratorToIndex(iterator it) const; ///< returns the position of \a it within the list (returns -1 if \a it == end()) + iterator IndexToIterator(std::size_t n) const; ///< returns an iterator to the row in position \a n (returns end() if \a n is an invalid index) - bool Empty() const; ///< returns true when the list is empty - const_iterator begin() const; ///< returns an iterator to the first list row - const_iterator end() const; ///< returns an iterator to the imaginary row one past the last - const_reverse_iterator - rbegin() const; ///< returns an iterator to the last list row - const_reverse_iterator - rend() const; ///< returns an iterator to the imaginary row one past the first - const Row& GetRow(std::size_t n) const; ///< returns a const reference to the row at index \a n; not range-checked. \note This function is O(n). - bool Selected(iterator it) const; ///< returns true if row \a it is selected - bool Selected(std::size_t n) const; ///< returns true if row at position \a n is selected - Clr InteriorColor() const; ///< returns the color painted into the client area of the control + bool Empty() const; ///< returns true when the list is empty - Y DropHeight() const; ///< returns the height of the drop-down list + const_iterator begin() const; ///< returns an iterator to the first list row + const_iterator end() const; ///< returns an iterator to the imaginary row one past the last + const_reverse_iterator rbegin() const; ///< returns an iterator to the last list row + const_reverse_iterator rend() const; ///< returns an iterator to the imaginary row one past the first + const Row& GetRow(std::size_t n) const; ///< returns a const reference to the row at index \a n; not range-checked. \note This function is O(n). + bool Selected(iterator it) const; ///< returns true if row \a it is selected + bool Selected(std::size_t n) const; ///< returns true if row at position \a n is selected + Clr InteriorColor() const; ///< returns the color painted into the client area of the control + + Y DropHeight() const; ///< returns the height of the drop-down list + /** Returns the style flags of the list \see GG::ListBoxStyle */ Flags<ListBoxStyle> Style() const; - std::size_t NumRows() const; ///< returns the total number of items in the list - std::size_t NumCols() const; ///< returns the total number of columns in each list item + std::size_t NumRows() const; ///< returns the total number of items in the list + std::size_t NumCols() const; ///< returns the total number of columns in each list item /** Returns the index of the column used to sort items, when sorting is enabled. \note The sort column is not range checked when it is set by the user; it may be >= NumCols(). */ - std::size_t SortCol() const; + std::size_t SortCol() const; - X ColWidth(std::size_t n) const; ///< returns the width of column \a n in pixels; not range-checked - Alignment ColAlignment(std::size_t n) const; ///< returns the alignment of column \a n; must be LIST_LEFT, LIST_CENTER, or LIST_RIGHT; not range-checked - Alignment RowAlignment(iterator it) const; ///< returns the alignment of row \a n; must be LIST_TOP, LIST_VCENTER, or LIST_BOTTOM; not range-checked + X ColWidth(std::size_t n) const; ///< returns the width of column \a n in pixels; not range-checked + Alignment ColAlignment(std::size_t n) const; ///< returns the alignment of column \a n; must be LIST_LEFT, LIST_CENTER, or LIST_RIGHT; not range-checked + Alignment RowAlignment(iterator it) const; ///< returns the alignment of row \a n; must be LIST_TOP, LIST_VCENTER, or LIST_BOTTOM; not range-checked - virtual Pt ClientUpperLeft() const; - virtual Pt ClientLowerRight() const; + virtual Pt ClientUpperLeft() const; + virtual Pt ClientLowerRight() const; mutable SelChangedSignalType SelChangedSignal; ///< the selection change signal object for this DropDownList //@} /** \name Mutators */ ///@{ - virtual void Render(); + virtual void Render(); - virtual void SizeMove(const Pt& ul, const Pt& lr); ///< resizes the control, ensuring the proper height is maintained based on the list's row height + virtual void SizeMove(const Pt& ul, const Pt& lr); ///< resizes the control, ensuring the proper height is maintained based on the list's row height - virtual void SetColor(Clr c); + virtual void SetColor(Clr c); /** Insertion sorts \a row into a sorted list, or inserts into an unsorted list before \a it; returns index of insertion point. This Row becomes the property of the DropDownList and should not be deleted or inserted into any other DropDownLists */ - iterator Insert(Row* row, iterator it, bool signal = true); + iterator Insert(Row* row, iterator it, bool signal = true); /** Insertion sorts \a row into a sorted list, or inserts into an unsorted list at the end of the list; returns index of insertion point. This Row becomes the property of the DropDownList and should not be deleted or inserted into any other DropDownLists */ - iterator Insert(Row* row, bool signal = true); + iterator Insert(Row* row, bool signal = true); /** Insertion sorts \a rows into a sorted list, or inserts into an unsorted list before \a it. The Rows become the property of this DropDownList. */ @@ -144,41 +144,42 @@ DropDownList. */ void Insert(const std::vector<Row*>& rows, bool signal = true); - Row* Erase(iterator it, bool signal = false); ///< removes and returns \a it from the list, or 0 if no such row exists - void Clear(); ///< empties the list - iterator begin(); ///< returns an iterator to the first list row - iterator end(); ///< returns an iterator to the imaginary row one past the last one - reverse_iterator - rbegin(); ///< returns an iterator to the last list row - reverse_iterator - rend(); ///< returns an iterator to the imaginary row one past the first - Row& GetRow(std::size_t n); ///< returns a reference to the Row at row index \a n; not range-checked. \note This function is O(n). + Row* Erase(iterator it, bool signal = false); ///< removes and returns \a it from the list, or 0 if no such row exists + void Clear(); ///< empties the list - void Select(iterator it); ///< selects row-item \a it in the list - void Select(std::size_t n); ///< selects row-item \a it in the list + iterator begin(); ///< returns an iterator to the first list row + iterator end(); ///< returns an iterator to the imaginary row one past the last one + reverse_iterator rbegin(); ///< returns an iterator to the last list row + reverse_iterator rend(); ///< returns an iterator to the imaginary row one past the first - void SetInteriorColor(Clr c); ///< sets the color painted into the client area of the control - void SetDropHeight(Y h); ///< sets the height of the drop-down list + Row& GetRow(std::size_t n); ///< returns a reference to the Row at row index \a n; not range-checked. \note This function is O(n). - /** sets the style flags for the list to \a s (invalidates currently selected item). \see GG::ListBoxStyle */ - void SetStyle(Flags<ListBoxStyle> s); + void Select(iterator it); ///< selects row-item \a it in the list + void Select(std::size_t n); ///< selects row-item \a it in the list - void SetNumCols(std::size_t n); ///< sets the number of columns in each list item to \a n; if no column widths exist before this call, proportional widths are calulated and set, otherwise no column widths are set - void SetSortCol(std::size_t n); ///< sets the index of the column used to sort rows when sorting is enabled (invalidates currently selected item); not range-checked - void SetColWidth(std::size_t n, X w); ///< sets the width of column \n to \a w; not range-checked + void SetInteriorColor(Clr c); ///< sets the color painted into the client area of the control + void SetDropHeight(Y h); ///< sets the height of the drop-down list + /** sets the style flags for the list to \a s (invalidates currently + selected item). \see GG::ListBoxStyle */ + void SetStyle(Flags<ListBoxStyle> s); + + void SetNumCols(std::size_t n); ///< sets the number of columns in each list item to \a n; if no column widths exist before this call, proportional widths are calulated and set, otherwise no column widths are set + void SetSortCol(std::size_t n); ///< sets the index of the column used to sort rows when sorting is enabled (invalidates currently selected item); not range-checked + void SetColWidth(std::size_t n, X w);///< sets the width of column \n to \a w; not range-checked + /** Fixes the column widths; by default, an empty list will take on the number of columns of its first added row. \note The number of columns and their widths may still be set via SetNumCols() and SetColWidth() after this function has been called. */ - void LockColWidths(); + void LockColWidths(); /** Allows the number of columns to be determined by the first row added to an empty ListBox */ - void UnLockColWidths(); + void UnLockColWidths(); - void SetColAlignment(std::size_t n, Alignment align); ///< sets the alignment of column \a n to \a align; not range-checked - void SetRowAlignment(iterator it, Alignment align); ///< sets the alignment of the Row at row index \a n to \a align; not range-checked + void SetColAlignment(std::size_t n, Alignment align); ///< sets the alignment of column \a n to \a align; not range-checked + void SetRowAlignment(iterator it, Alignment align); ///< sets the alignment of the Row at row index \a n to \a align; not range-checked //@} protected: @@ -187,18 +188,18 @@ //@} /** \name Mutators */ ///@{ - virtual void LClick(const Pt& pt, Flags<ModKey> mod_keys); - virtual void KeyPress(Key key, boost::uint32_t key_code_point, Flags<ModKey> mod_keys); + virtual void LClick(const Pt& pt, Flags<ModKey> mod_keys); + virtual void KeyPress(Key key, boost::uint32_t key_code_point, Flags<ModKey> mod_keys); - ListBox* LB(); ///< returns the ListBox used to render the selected row and the popup list + ListBox* LB(); ///< returns the ListBox used to render the selected row and the popup list //@} private: - void SelectImpl(iterator it, bool signal); + void SelectImpl(iterator it, bool signal); + const ListBox* LB() const; - iterator m_current_item; ///< the currently-selected list item (end() if none is selected) - ListBox* m_LB; ///< the ListBox used to render the selected row and the popup list - ModalListPicker*m_modal_picker; + iterator m_current_item; ///< the currently-selected list item (end() if none is selected) + ModalListPicker* m_modal_picker; }; } // namespace GG Modified: trunk/FreeOrion/GG/src/DropDownList.cpp =================================================================== --- trunk/FreeOrion/GG/src/DropDownList.cpp 2014-04-05 23:34:45 UTC (rev 7019) +++ trunk/FreeOrion/GG/src/DropDownList.cpp 2014-04-06 12:06:12 UTC (rev 7020) @@ -33,109 +33,144 @@ using namespace GG; +class ModalListPicker : public Wnd +{ +public: + typedef ListBox::iterator iterator; + typedef boost::signals2::signal<void (iterator)> SelChangedSignalType; + + ModalListPicker(X w, Y drop_ht, Clr color, const Wnd* relative_to_wnd); + + virtual void LClick(const Pt& pt, Flags<ModKey> mod_keys); + virtual void ModalInit(); + + ListBox* LB() + { return m_lb_wnd; } + + const ListBox* LB() const + { return m_lb_wnd; } + + mutable SelChangedSignalType SelChangedSignal; ///< the selection change signal object for this DropDownList + +private: + void LBSelChangedSlot(const ListBox::SelectionSet& rows); + + void LBLeftClickSlot(ListBox::iterator it, const Pt&); + + ListBox* m_lb_wnd; + const Wnd* m_relative_to_wnd; +}; + namespace { - struct SelChangedEcho + struct DropDownListSelChangedEcho { - SelChangedEcho(const DropDownList& drop_list) : + DropDownListSelChangedEcho(const DropDownList& drop_list) : m_drop_list(drop_list) {} void operator()(const DropDownList::iterator& it) { std::cerr << "GG SIGNAL : DropDownList::SelChangedSignal(row=" - << m_drop_list.IteratorToIndex(it) - << ")\n"; + << m_drop_list.IteratorToIndex(it) + << ")\n"; } const DropDownList& m_drop_list; }; + struct ModalListPickerSelChangedEcho + { + ModalListPickerSelChangedEcho(ModalListPicker& picker) : + m_picker(picker) + {} + void operator()(const ListBox::iterator& it) + { + std::cerr << "GG SIGNAL : ModalListPicker::SelChangedSignal(row=" + << std::distance(m_picker.LB()->begin(), it) + << ")\n"; + } + ModalListPicker& m_picker; + }; + const int BORDER_THICK = 2; // should be the same as the BORDER_THICK value in GGListBox.h } -class ModalListPicker : public Wnd +//////////////////////////////////////////////// +// ModalListPicker +//////////////////////////////////////////////// +ModalListPicker::ModalListPicker(X w, Y drop_ht, Clr color, const Wnd* relative_to_wnd) : + Wnd(X0, Y0, GUI::GetGUI()->AppWidth(), GUI::GetGUI()->AppHeight(), INTERACTIVE | MODAL), + m_lb_wnd(GetStyleFactory()->NewDropDownListListBox(X0, Y0, w, drop_ht, color, color)), + m_relative_to_wnd(relative_to_wnd) { -public: - ModalListPicker(DropDownList* drop_wnd, ListBox* lb_wnd) : - Wnd(X0, Y0, GUI::GetGUI()->AppWidth(), GUI::GetGUI()->AppHeight(), - INTERACTIVE | MODAL), - m_drop_wnd(drop_wnd), - m_lb_wnd(lb_wnd), - m_old_lb_ul(m_lb_wnd->UpperLeft()) - { - m_connection_1 = - Connect(m_lb_wnd->SelChangedSignal, &ModalListPicker::LBSelChangedSlot, this); - m_connection_2 = - Connect(m_lb_wnd->LeftClickedSignal, &ModalListPicker::LBLeftClickSlot, this); - m_lb_ul = m_old_lb_ul + m_drop_wnd->UpperLeft(); - AttachChild(m_lb_wnd); - } + Connect(m_lb_wnd->SelChangedSignal, &ModalListPicker::LBSelChangedSlot, this); + Connect(m_lb_wnd->LeftClickedSignal, &ModalListPicker::LBLeftClickSlot, this); + AttachChild(m_lb_wnd); - virtual void Render() - { m_lb_wnd->MoveTo(m_lb_ul); } + if (INSTRUMENT_ALL_SIGNALS) + Connect(SelChangedSignal, ModalListPickerSelChangedEcho(*this)); +} - ~ModalListPicker() - { - m_lb_wnd->MoveTo(m_old_lb_ul); - DetachChild(m_lb_wnd); - } +void ModalListPicker::LClick(const Pt& pt, Flags<ModKey> mod_keys) +{ m_done = true; } -protected: - virtual void LClick(const Pt& pt, Flags<ModKey> mod_keys) - { m_done = true; } +void ModalListPicker::ModalInit() +{ + if (m_relative_to_wnd) + m_lb_wnd->MoveTo(Pt(m_relative_to_wnd->Left(), m_relative_to_wnd->Bottom())); + Show(); +} -private: - void LBSelChangedSlot(const ListBox::SelectionSet& rows) - { - if (!rows.empty()) { - m_drop_wnd->Select(*rows.begin()); - m_drop_wnd->SelChangedSignal(m_drop_wnd->CurrentItem()); - m_done = true; - } +void ModalListPicker::LBSelChangedSlot(const ListBox::SelectionSet& rows) +{ + Hide(); + if (rows.empty()) { + SelChangedSignal(m_lb_wnd->end()); + } else { + ListBox::iterator sel_it = *rows.begin(); + SelChangedSignal(sel_it); } + m_done = true; +} - void LBLeftClickSlot(ListBox::iterator it, const Pt&) - { m_done = true; } +void ModalListPicker::LBLeftClickSlot(ListBox::iterator it, const Pt&) +{ + Hide(); + m_done = true; +} - DropDownList* m_drop_wnd; - ListBox* m_lb_wnd; - Pt m_old_lb_ul; - Pt m_lb_ul; - boost::signals2::scoped_connection m_connection_1; - boost::signals2::scoped_connection m_connection_2; -}; - //////////////////////////////////////////////// // GG::DropDownList //////////////////////////////////////////////// DropDownList::DropDownList() : Control(), m_current_item(), - m_LB(0), m_modal_picker(0) {} -DropDownList::DropDownList(X x, Y y, X w, Y h, Y drop_ht, Clr color, - Flags<WndFlag> flags/* = INTERACTIVE*/) : +DropDownList::DropDownList(X x, Y y, X w, Y h, Y drop_ht, Clr color, Flags<WndFlag> flags/* = INTERACTIVE*/) : Control(x, y, w, h, flags), m_current_item(), - m_LB(GetStyleFactory()->NewDropDownListListBox(x, y, w, drop_ht, color, color, flags)), - m_modal_picker(0) + m_modal_picker(new ModalListPicker(w, drop_ht, color, this)) { SetStyle(LIST_SINGLESEL); + // adjust size to keep correct height based on row height, etc. - Wnd::SizeMove(Pt(x, y), Pt(x + Size().x, y + h + 2 * static_cast<int>(m_LB->CellMargin()) + 2 * BORDER_THICK)); - m_LB->SizeMove(Pt(X0, Height()), Pt(Width(), Height() + m_LB->Height())); - m_current_item = m_LB->end(); + Wnd::SizeMove(Pt(x, y), + Pt(x + Size().x, + y + h + 2 * static_cast<int>(LB()->CellMargin()) + 2 * BORDER_THICK)); + m_current_item = LB()->end(); + Connect(m_modal_picker->SelChangedSignal, SelChangedSignal); + if (INSTRUMENT_ALL_SIGNALS) - Connect(SelChangedSignal, SelChangedEcho(*this)); + Connect(SelChangedSignal, DropDownListSelChangedEcho(*this)); } DropDownList::~DropDownList() { if (m_modal_picker) m_modal_picker->EndRun(); - m_modal_picker = 0; - delete m_LB; + DetachChild(m_modal_picker); + delete m_modal_picker; } DropDownList::iterator DropDownList::CurrentItem() const @@ -145,61 +180,61 @@ { return IteratorToIndex(m_current_item); } std::size_t DropDownList::IteratorToIndex(iterator it) const -{ return it == m_LB->end() ? -1 : std::distance(m_LB->begin(), it); } +{ return it == m_modal_picker->LB()->end() ? -1 : std::distance(m_modal_picker->LB()->begin(), it); } DropDownList::iterator DropDownList::IndexToIterator(std::size_t n) const -{ return n < m_LB->NumRows() ? boost::next(m_LB->begin(), n) : m_LB->end(); } +{ return n < LB()->NumRows() ? boost::next(m_modal_picker->LB()->begin(), n) : m_modal_picker->LB()->end(); } bool DropDownList::Empty() const -{ return m_LB->Empty(); } +{ return LB()->Empty(); } DropDownList::const_iterator DropDownList::begin() const -{ return m_LB->begin(); } +{ return LB()->begin(); } DropDownList::const_iterator DropDownList::end() const -{ return m_LB->end(); } +{ return LB()->end(); } DropDownList::const_reverse_iterator DropDownList::rbegin() const -{ return m_LB->rbegin(); } +{ return LB()->rbegin(); } DropDownList::const_reverse_iterator DropDownList::rend() const -{ return m_LB->rend(); } +{ return LB()->rend(); } const DropDownList::Row& DropDownList::GetRow(std::size_t n) const -{ return m_LB->GetRow(n); } +{ return LB()->GetRow(n); } bool DropDownList::Selected(iterator it) const -{ return m_LB->Selected(it); } +{ return LB()->Selected(it); } bool DropDownList::Selected(std::size_t n) const -{ return n < m_LB->NumRows() ? m_LB->Selected(boost::next(m_LB->begin(), n)) : false; } +{ return n < LB()->NumRows() ? LB()->Selected(boost::next(m_modal_picker->LB()->begin(), n)) : false; } Clr DropDownList::InteriorColor() const -{ return m_LB->InteriorColor(); } +{ return LB()->InteriorColor(); } Y DropDownList::DropHeight() const -{ return m_LB->Height(); } +{ return LB()->Height(); } Flags<ListBoxStyle> DropDownList::Style() const -{ return m_LB->Style(); } +{ return LB()->Style(); } std::size_t DropDownList::NumRows() const -{ return m_LB->NumRows(); } +{ return LB()->NumRows(); } std::size_t DropDownList::NumCols() const -{ return m_LB->NumCols(); } +{ return LB()->NumCols(); } std::size_t DropDownList::SortCol() const -{ return m_LB->SortCol(); } +{ return LB()->SortCol(); } X DropDownList::ColWidth(std::size_t n) const -{ return m_LB->ColWidth(n); } +{ return LB()->ColWidth(n); } Alignment DropDownList::ColAlignment(std::size_t n) const -{ return m_LB->ColAlignment(n); } +{ return LB()->ColAlignment(n); } Alignment DropDownList::RowAlignment(iterator it) const -{ return m_LB->RowAlignment(it); } +{ return LB()->RowAlignment(it); } Pt DropDownList::ClientUpperLeft() const { return UpperLeft() + Pt(X(BORDER_THICK), Y(BORDER_THICK)); } @@ -211,13 +246,13 @@ { // draw beveled rectangle around client area Pt ul = UpperLeft(), lr = LowerRight(); - Clr color_to_use = Disabled() ? DisabledColor(m_LB->Color()) : m_LB->Color(); - Clr int_color_to_use = Disabled() ? DisabledColor(m_LB->m_int_color) : m_LB->m_int_color; + Clr color_to_use = Disabled() ? DisabledColor(LB()->Color()) : LB()->Color(); + Clr int_color_to_use = Disabled() ? DisabledColor(LB()->m_int_color) : LB()->m_int_color; BeveledRectangle(ul, lr, int_color_to_use, color_to_use, false, BORDER_THICK); // Draw the ListBox::Row of currently displayed item, if any. - if (m_current_item != m_LB->end()) { + if (m_current_item != LB()->end()) { Row* current_item = *m_current_item; Pt offset = ClientUpperLeft() - current_item->UpperLeft(); bool visible = current_item->Visible(); @@ -237,22 +272,22 @@ { // adjust size to keep correct height based on row height, etc. Wnd::SizeMove(ul, lr); - m_LB->SizeMove(Pt(X0, Height()), Pt(Width(), Height() + m_LB->Height())); + LB()->SizeMove(Pt(X0, Height()), Pt(Width(), Height() + LB()->Height())); } void DropDownList::SetColor(Clr c) -{ m_LB->SetColor(c); } +{ LB()->SetColor(c); } DropDownList::iterator DropDownList::Insert(Row* row, iterator it, bool signal/* = true*/) { row->SetDragDropDataType(""); - return m_LB->Insert(row, it, signal); + return LB()->Insert(row, it, signal); } DropDownList::iterator DropDownList::Insert(Row* row, bool signal/* = true*/) { row->SetDragDropDataType(""); - return m_LB->Insert(row, signal); + return LB()->Insert(row, signal); } void DropDownList::Insert(const std::vector<Row*>& rows, iterator it, bool signal/* = true*/) @@ -260,7 +295,7 @@ for (std::vector<Row*>::const_iterator rows_it = rows.begin(); rows_it != rows.end(); ++rows_it) { (*rows_it)->SetDragDropDataType(""); } - m_LB->Insert(rows, it, signal); + LB()->Insert(rows, it, signal); } void DropDownList::Insert(const std::vector<Row*>& rows, bool signal/* = true*/) @@ -268,102 +303,97 @@ for (std::vector<Row*>::const_iterator rows_it = rows.begin(); rows_it != rows.end(); ++rows_it) { (*rows_it)->SetDragDropDataType(""); } - m_LB->Insert(rows, signal); + LB()->Insert(rows, signal); } DropDownList::Row* DropDownList::Erase(iterator it, bool signal/* = false*/) { if (it == m_current_item) - m_current_item = m_LB->end(); - return m_LB->Erase(it, signal); + m_current_item = LB()->end(); + return LB()->Erase(it, signal); } void DropDownList::Clear() { - m_current_item = m_LB->end(); - if (m_modal_picker) - m_modal_picker->EndRun(); - m_modal_picker = 0; - m_LB->Clear(); + m_current_item = LB()->end(); + m_modal_picker->EndRun(); + LB()->Clear(); } DropDownList::iterator DropDownList::begin() -{ return m_LB->begin(); } +{ return LB()->begin(); } DropDownList::iterator DropDownList::end() -{ return m_LB->end(); } +{ return LB()->end(); } DropDownList::reverse_iterator DropDownList::rbegin() -{ return m_LB->rbegin(); } +{ return LB()->rbegin(); } DropDownList::reverse_iterator DropDownList::rend() -{ return m_LB->rend(); } +{ return LB()->rend(); } DropDownList::Row& DropDownList::GetRow(std::size_t n) -{ return m_LB->GetRow(n); } +{ return LB()->GetRow(n); } void DropDownList::Select(iterator it) { SelectImpl(it, false); } void DropDownList::Select(std::size_t n) -{ SelectImpl(n < m_LB->NumRows() ? boost::next(m_LB->begin(), n) : m_LB->end(), false); } +{ SelectImpl(n < LB()->NumRows() ? boost::next(LB()->begin(), n) : LB()->end(), false); } void DropDownList::SetInteriorColor(Clr c) -{ m_LB->SetInteriorColor(c); } +{ LB()->SetInteriorColor(c); } void DropDownList::SetDropHeight(Y h) -{ m_LB->Resize(Pt(Width(), h)); } +{ LB()->Resize(Pt(Width(), h)); } void DropDownList::SetStyle(Flags<ListBoxStyle> s) { s &= ~(LIST_NOSEL | LIST_QUICKSEL | LIST_USERDELETE | LIST_BROWSEUPDATES); s |= LIST_SINGLESEL; - m_LB->SetStyle(s); - m_current_item = m_LB->end(); + LB()->SetStyle(s); + m_current_item = LB()->end(); } void DropDownList::SetNumCols(std::size_t n) -{ m_LB->SetNumCols(n); } +{ LB()->SetNumCols(n); } void DropDownList::SetSortCol(std::size_t n) { - m_LB->SetSortCol(n); - m_current_item = m_LB->end(); + LB()->SetSortCol(n); + m_current_item = LB()->end(); } void DropDownList::SetColWidth(std::size_t n, X w) -{ m_LB->SetColWidth(n, w); } +{ LB()->SetColWidth(n, w); } void DropDownList::LockColWidths() -{ m_LB->LockColWidths(); } +{ LB()->LockColWidths(); } void DropDownList::UnLockColWidths() -{ m_LB->UnLockColWidths(); } +{ LB()->UnLockColWidths(); } void DropDownList::SetColAlignment(std::size_t n, Alignment align) -{ m_LB->SetColAlignment(n, align); } +{ LB()->SetColAlignment(n, align); } void DropDownList::SetRowAlignment(iterator it, Alignment align) -{ m_LB->SetRowAlignment(it, align); } +{ LB()->SetRowAlignment(it, align); } void DropDownList::LClick(const Pt& pt, Flags<ModKey> mod_keys) { if (Disabled()) return; - ModalListPicker picker(this, m_LB); - m_modal_picker = &picker; - - const ListBox::SelectionSet& LB_sels = m_LB->Selections(); + const ListBox::SelectionSet& LB_sels = LB()->Selections(); if (!LB_sels.empty()) { - if (m_LB->m_vscroll) { - m_LB->m_vscroll->ScrollTo(0); - SignalScroll(*m_LB->m_vscroll, true); + if (LB()->m_vscroll) { + LB()->m_vscroll->ScrollTo(0); + SignalScroll(*LB()->m_vscroll, true); } } - m_LB->m_first_col_shown = 0; - picker.Run(); - m_modal_picker = 0; + LB()->m_first_col_shown = 0; + + m_modal_picker->Run(); } void DropDownList::KeyPress(Key key, boost::uint32_t key_code_point, Flags<ModKey> mod_keys) @@ -371,18 +401,18 @@ if (!Disabled()) { switch (key) { case GGK_UP: // arrow-up (not numpad arrow) - if (m_current_item != m_LB->end() && m_current_item != m_LB->begin()) + if (m_current_item != LB()->end() && m_current_item != LB()->begin()) SelectImpl(boost::prior(m_current_item), true); break; case GGK_DOWN: // arrow-down (not numpad arrow) - if (m_current_item != m_LB->end() && m_current_item != --m_LB->end()) + if (m_current_item != LB()->end() && m_current_item != --LB()->end()) SelectImpl(boost::next(m_current_item), true); break; case GGK_PAGEUP: // page up key (not numpad key) - if (m_LB->NumRows() && m_current_item != m_LB->end()) { + if (LB()->NumRows() && m_current_item != LB()->end()) { std::size_t i = 10; iterator it = m_current_item; - while (i && it != m_LB->begin()) { + while (i && it != LB()->begin()) { --it; --i; } @@ -390,10 +420,10 @@ } break; case GGK_PAGEDOWN: // page down key (not numpad key) - if (m_LB->NumRows()) { + if (LB()->NumRows()) { std::size_t i = 10; iterator it = m_current_item; - while (i && it != --m_LB->end()) { + while (i && it != --LB()->end()) { ++it; ++i; } @@ -401,12 +431,12 @@ } break; case GGK_HOME: // home key (not numpad) - if (m_LB->NumRows()) - SelectImpl(m_LB->begin(), true); + if (LB()->NumRows()) + SelectImpl(LB()->begin(), true); break; case GGK_END: // end key (not numpad) - if (m_LB->NumRows() && !m_LB->Empty()) - SelectImpl(--m_LB->end(), true); + if (LB()->NumRows() && !LB()->Empty()) + SelectImpl(--LB()->end(), true); break; default: Control::KeyPress(key, key_code_point, mod_keys); @@ -417,17 +447,20 @@ } ListBox* DropDownList::LB() -{ return m_LB; } +{ return m_modal_picker->LB(); } +const ListBox* DropDownList::LB() const +{ return m_modal_picker->LB(); } + void DropDownList::SelectImpl(iterator it, bool signal) { iterator old_m_current_item = m_current_item; - if (it == m_LB->end()) { - m_current_item = m_LB->end(); - m_LB->DeselectAll(); + if (it == LB()->end()) { + m_current_item = LB()->end(); + LB()->DeselectAll(); } else { m_current_item = it; - m_LB->SelectRow(m_current_item); + LB()->SelectRow(m_current_item); } if (signal && m_current_item != old_m_current_item) |
From: <geo...@us...> - 2014-04-07 00:09:01
|
Revision: 7023 http://sourceforge.net/p/freeorion/code/7023 Author: geoffthemedio Date: 2014-04-07 00:08:57 +0000 (Mon, 07 Apr 2014) Log Message: ----------- Replaced separate storage of selected item in DropDownList with a forwarded call to the enclosed ListBox's selected item. This should fix the CurrentItem() function, which was broken by recent changes. Modified Paths: -------------- trunk/FreeOrion/GG/GG/DropDownList.h trunk/FreeOrion/GG/src/DropDownList.cpp Modified: trunk/FreeOrion/GG/GG/DropDownList.h =================================================================== --- trunk/FreeOrion/GG/GG/DropDownList.h 2014-04-07 00:07:01 UTC (rev 7022) +++ trunk/FreeOrion/GG/GG/DropDownList.h 2014-04-07 00:08:57 UTC (rev 7023) @@ -198,7 +198,6 @@ void SelectImpl(iterator it, bool signal); const ListBox* LB() const; - iterator m_current_item; ///< the currently-selected list item (end() if none is selected) ModalListPicker* m_modal_picker; }; Modified: trunk/FreeOrion/GG/src/DropDownList.cpp =================================================================== --- trunk/FreeOrion/GG/src/DropDownList.cpp 2014-04-07 00:07:01 UTC (rev 7022) +++ trunk/FreeOrion/GG/src/DropDownList.cpp 2014-04-07 00:08:57 UTC (rev 7023) @@ -143,13 +143,11 @@ //////////////////////////////////////////////// DropDownList::DropDownList() : Control(), - m_current_item(), m_modal_picker(0) {} DropDownList::DropDownList(X x, Y y, X w, Y h, Y drop_ht, Clr color, Flags<WndFlag> flags/* = INTERACTIVE*/) : Control(x, y, w, h, flags), - m_current_item(), m_modal_picker(new ModalListPicker(w, drop_ht, color, this)) { SetStyle(LIST_SINGLESEL); @@ -158,7 +156,6 @@ Wnd::SizeMove(Pt(x, y), Pt(x + Size().x, y + h + 2 * static_cast<int>(LB()->CellMargin()) + 2 * BORDER_THICK)); - m_current_item = LB()->end(); Connect(m_modal_picker->SelChangedSignal, SelChangedSignal); @@ -174,10 +171,15 @@ } DropDownList::iterator DropDownList::CurrentItem() const -{ return m_current_item; } +{ + if (m_modal_picker->LB()->Selections().empty()) + return m_modal_picker->LB()->end(); + else + return *m_modal_picker->LB()->Selections().begin(); +} std::size_t DropDownList::CurrentItemIndex() const -{ return IteratorToIndex(m_current_item); } +{ return IteratorToIndex(CurrentItem()); } std::size_t DropDownList::IteratorToIndex(iterator it) const { return it == m_modal_picker->LB()->end() ? -1 : std::distance(m_modal_picker->LB()->begin(), it); } @@ -252,8 +254,8 @@ BeveledRectangle(ul, lr, int_color_to_use, color_to_use, false, BORDER_THICK); // Draw the ListBox::Row of currently displayed item, if any. - if (m_current_item != LB()->end()) { - Row* current_item = *m_current_item; + if (CurrentItem() != LB()->end()) { + Row* current_item = *CurrentItem(); Pt offset = ClientUpperLeft() - current_item->UpperLeft(); bool visible = current_item->Visible(); current_item->OffsetMove(offset); @@ -307,15 +309,10 @@ } DropDownList::Row* DropDownList::Erase(iterator it, bool signal/* = false*/) -{ - if (it == m_current_item) - m_current_item = LB()->end(); - return LB()->Erase(it, signal); -} +{ return LB()->Erase(it, signal); } void DropDownList::Clear() { - m_current_item = LB()->end(); m_modal_picker->EndRun(); LB()->Clear(); } @@ -352,17 +349,13 @@ s &= ~(LIST_NOSEL | LIST_QUICKSEL | LIST_USERDELETE | LIST_BROWSEUPDATES); s |= LIST_SINGLESEL; LB()->SetStyle(s); - m_current_item = LB()->end(); } void DropDownList::SetNumCols(std::size_t n) { LB()->SetNumCols(n); } void DropDownList::SetSortCol(std::size_t n) -{ - LB()->SetSortCol(n); - m_current_item = LB()->end(); -} +{ LB()->SetSortCol(n); } void DropDownList::SetColWidth(std::size_t n, X w) { LB()->SetColWidth(n, w); } @@ -401,17 +394,17 @@ if (!Disabled()) { switch (key) { case GGK_UP: // arrow-up (not numpad arrow) - if (m_current_item != LB()->end() && m_current_item != LB()->begin()) - SelectImpl(boost::prior(m_current_item), true); + if (CurrentItem() != LB()->end() && CurrentItem() != LB()->begin()) + SelectImpl(boost::prior(CurrentItem()), true); break; case GGK_DOWN: // arrow-down (not numpad arrow) - if (m_current_item != LB()->end() && m_current_item != --LB()->end()) - SelectImpl(boost::next(m_current_item), true); + if (CurrentItem() != LB()->end() && CurrentItem() != --LB()->end()) + SelectImpl(boost::next(CurrentItem()), true); break; case GGK_PAGEUP: // page up key (not numpad key) - if (LB()->NumRows() && m_current_item != LB()->end()) { + if (LB()->NumRows() && CurrentItem() != LB()->end()) { std::size_t i = 10; - iterator it = m_current_item; + iterator it = CurrentItem(); while (i && it != LB()->begin()) { --it; --i; @@ -422,7 +415,7 @@ case GGK_PAGEDOWN: // page down key (not numpad key) if (LB()->NumRows()) { std::size_t i = 10; - iterator it = m_current_item; + iterator it = CurrentItem(); while (i && it != --LB()->end()) { ++it; ++i; @@ -454,15 +447,13 @@ void DropDownList::SelectImpl(iterator it, bool signal) { - iterator old_m_current_item = m_current_item; + iterator old_m_current_item = CurrentItem(); if (it == LB()->end()) { - m_current_item = LB()->end(); LB()->DeselectAll(); } else { - m_current_item = it; - LB()->SelectRow(m_current_item); + LB()->SelectRow(it); } - if (signal && m_current_item != old_m_current_item) - SelChangedSignal(m_current_item); + if (signal && CurrentItem() != old_m_current_item) + SelChangedSignal(CurrentItem()); } |
From: <geo...@us...> - 2014-04-12 08:58:49
|
Revision: 7044 http://sourceforge.net/p/freeorion/code/7044 Author: geoffthemedio Date: 2014-04-12 08:58:43 +0000 (Sat, 12 Apr 2014) Log Message: ----------- -Added signal on/off parameters to ListBox selection functions. This allows the fix of a server crash when entering the multiplayer setup screen caused by signalling from programmatic list selection setting before all other selections were done, which was sending a message to the server with incomplete setup info, which cause the sever to abort. -grooming Modified Paths: -------------- trunk/FreeOrion/GG/GG/ListBox.h trunk/FreeOrion/GG/src/GUI.cpp trunk/FreeOrion/GG/src/ListBox.cpp Modified: trunk/FreeOrion/GG/GG/ListBox.h =================================================================== --- trunk/FreeOrion/GG/GG/ListBox.h 2014-04-11 22:28:33 UTC (rev 7043) +++ trunk/FreeOrion/GG/GG/ListBox.h 2014-04-12 08:58:43 UTC (rev 7044) @@ -364,87 +364,88 @@ of this ListBox. */ void Insert(const std::vector<Row*>& rows, bool signal = true); - Row* Erase(iterator it, bool signal = false); ///< removes and returns the row that \a it points to from the ListBox, or 0 if no such row exists - void Clear(); ///< empties the ListBox - void SelectRow(iterator it); ///< selects row \a it - void DeselectRow(iterator it); ///< deselects row \a it - void SelectAll(); ///< selects all rows - void DeselectAll(); ///< deselects all rows + Row* Erase(iterator it, bool signal = false); ///< removes and returns the row that \a it points to from the ListBox, or 0 if no such row exists + void Clear(); ///< empties the ListBox + void SelectRow(iterator it, bool signal = false); ///< selects row \a it + void DeselectRow(iterator it, bool signal = false); ///< deselects row \a it + void SelectAll(bool signal = false); ///< selects all rows + void DeselectAll(bool signal = false); ///< deselects all rows + void SetSelections(const SelectionSet& s, + bool signal = false); ///< sets the set of selected rows to \a s - iterator begin(); ///< returns an iterator to the first list row - iterator end(); ///< returns an iterator to the imaginary row one past the last one - reverse_iterator rbegin(); ///< returns an iterator to the last list row - reverse_iterator rend(); ///< returns an iterator to the imaginary row one past the first one + iterator begin(); ///< returns an iterator to the first list row + iterator end(); ///< returns an iterator to the imaginary row one past the last one + reverse_iterator rbegin(); ///< returns an iterator to the last list row + reverse_iterator rend(); ///< returns an iterator to the imaginary row one past the first one - Row& GetRow(std::size_t n); ///< returns a reference to the Row at row index \a n; not range-checked. \note This function is O(n). + Row& GetRow(std::size_t n); ///< returns a reference to the Row at row index \a n; not range-checked. \note This function is O(n). - void SetSelections(const SelectionSet& s); ///< sets the set of selected rows to \a s - void SetCaret(iterator it); ///< sets the position of the caret to \a it - void BringRowIntoView(iterator it); ///< moves the scrollbars so that row \a it is visible - void SetFirstRowShown(iterator it); ///< moves the scrollbars so that row \a it is the first visible + void SetCaret(iterator it); ///< sets the position of the caret to \a it + void BringRowIntoView(iterator it); ///< moves the scrollbars so that row \a it is visible + void SetFirstRowShown(iterator it); ///< moves the scrollbars so that row \a it is the first visible /** Sets how much to scroll when scrolled using the mousewheel. */ - void SetVScrollWheelIncrement(unsigned int increment); - void SetHScrollWheelIncrement(unsigned int increment); + void SetVScrollWheelIncrement(unsigned int increment); + void SetHScrollWheelIncrement(unsigned int increment); - void SetInteriorColor(Clr c); ///< sets the color painted into the client area of the control - void SetHiliteColor(Clr c); ///< sets the color behind selected line items + void SetInteriorColor(Clr c); ///< sets the color painted into the client area of the control + void SetHiliteColor(Clr c); ///< sets the color behind selected line items /** sets the style flags for the ListBox to \a s. \see GG::ListBoxStyle */ - void SetStyle(Flags<ListBoxStyle> s); + void SetStyle(Flags<ListBoxStyle> s); - void SetColHeaders(Row* r); ///< sets the row used as headings for the columns; this Row becomes property of the ListBox. - void RemoveColHeaders(); ///< removes any columns headings set + void SetColHeaders(Row* r); ///< sets the row used as headings for the columns; this Row becomes property of the ListBox. + void RemoveColHeaders(); ///< removes any columns headings set - void SetColWidth(std::size_t n, X w); ///< sets the width of column \n to \a w; not range-checked - void SetNumCols(std::size_t n); ///< sets the number of columns in the ListBox to \a n; if no column widths exist before this call, proportional widths are calulated and set, otherwise no column widths are set - void SetSortCol(std::size_t n); ///< sets the index of the column used to sort rows when sorting is enabled; not range-checked + void SetColWidth(std::size_t n, X w); ///< sets the width of column \n to \a w; not range-checked + void SetNumCols(std::size_t n); ///< sets the number of columns in the ListBox to \a n; if no column widths exist before this call, proportional widths are calulated and set, otherwise no column widths are set + void SetSortCol(std::size_t n); ///< sets the index of the column used to sort rows when sorting is enabled; not range-checked /** Sets the comparison function used to sort a given pair of Rows during row sorting. Note that \a sort_cmp is assumed to produce an ascending order when used to sort; setting the LIST_SORTDESCENDING style can be used to produce a reverse sort. */ - void SetSortCmp(const boost::function<bool (const Row&, const Row&, std::size_t)>& sort_cmp); + void SetSortCmp(const boost::function<bool (const Row&, const Row&, std::size_t)>& sort_cmp); /** Fixes the column widths; by default, an empty ListBox will take on the number of columns of its first added row. \note The number of columns and their widths may still be set via SetNumCols() and SetColWidth() after this function has been called. */ - void LockColWidths(); + void LockColWidths(); /** Allows the number of columns to be determined by the first row added to an empty ListBox */ - void UnLockColWidths(); + void UnLockColWidths(); /** Sets the alignment of column \a n to \a align; not range-checked */ - void SetColAlignment(std::size_t n, Alignment align); + void SetColAlignment(std::size_t n, Alignment align); /** Sets the alignment of row \a it to \a align; not range-checked */ - void SetRowAlignment(iterator it, Alignment align); + void SetRowAlignment(iterator it, Alignment align); /** Allows Rows with data type \a str to be dropped over this ListBox when drag-and-drop is enabled. \note Passing "" enables all drop types. */ - void AllowDropType(const std::string& str); + void AllowDropType(const std::string& str); /** Disallows Rows with data type \a str to be dropped over this ListBox when drag-and-drop is enabled. \note If "" is still an allowed drop type, drops of type \a str will still be allowed, even after disallowed with a call to this function. */ - void DisallowDropType(const std::string& str); + void DisallowDropType(const std::string& str); /** Set this to determine whether the list should autoscroll when the user is attempting to drop an item into a location that is not currently visible. */ - void AutoScrollDuringDragDrops(bool auto_scroll); + void AutoScrollDuringDragDrops(bool auto_scroll); /** Sets the thickness of the area around the border of the client area that will provoke an auto-scroll, if AutoScrollDuringDragDrops() returns true. */ - void SetAutoScrollMargin(unsigned int margin); + void SetAutoScrollMargin(unsigned int margin); /** Sets the number of milliseconds that elapse between row/column scrolls when auto-scrolling. */ - void SetAutoScrollInterval(unsigned int interval); + void SetAutoScrollInterval(unsigned int interval); //@} /** \brief Sorts two Rows of a ListBox using operator<() on the Modified: trunk/FreeOrion/GG/src/GUI.cpp =================================================================== --- trunk/FreeOrion/GG/src/GUI.cpp 2014-04-11 22:28:33 UTC (rev 7043) +++ trunk/FreeOrion/GG/src/GUI.cpp 2014-04-12 08:58:43 UTC (rev 7044) @@ -1182,7 +1182,7 @@ edit_control->SelectAll(); return true; } else if (ListBox* list_control = dynamic_cast<ListBox*>(wnd)) { - list_control->SelectAll(); + list_control->SelectAll(true); return true; } return false; @@ -1196,7 +1196,7 @@ edit_control->DeselectAll(); return true; } else if (ListBox* list_control = dynamic_cast<ListBox*>(wnd)) { - list_control->DeselectAll(); + list_control->DeselectAll(true); return true; } return false; Modified: trunk/FreeOrion/GG/src/ListBox.cpp =================================================================== --- trunk/FreeOrion/GG/src/ListBox.cpp 2014-04-11 22:28:33 UTC (rev 7043) +++ trunk/FreeOrion/GG/src/ListBox.cpp 2014-04-12 08:58:43 UTC (rev 7044) @@ -876,7 +876,7 @@ ClearedSignal(); } -void ListBox::SelectRow(iterator it) +void ListBox::SelectRow(iterator it, bool signal/* = false*/) { if (m_style & LIST_NOSEL) return; @@ -892,22 +892,22 @@ m_selections.insert(it); - if (previous_selections != m_selections) + if (signal && previous_selections != m_selections) SelChangedSignal(m_selections); } -void ListBox::DeselectRow(iterator it) +void ListBox::DeselectRow(iterator it, bool signal/* = false*/) { SelectionSet previous_selections = m_selections; if (m_selections.find(it) != m_selections.end()) m_selections.erase(it); - if (previous_selections != m_selections) + if (signal && previous_selections != m_selections) SelChangedSignal(m_selections); } -void ListBox::SelectAll() +void ListBox::SelectAll(bool signal/* = false*/) { if (m_style & LIST_NOSEL) return; @@ -926,11 +926,11 @@ } } - if (previous_selections != m_selections) + if (signal && previous_selections != m_selections) SelChangedSignal(m_selections); } -void ListBox::DeselectAll() +void ListBox::DeselectAll(bool signal/* = false*/) { SelectionSet previous_selections = m_selections; @@ -939,7 +939,7 @@ m_caret = m_rows.end(); } - if (previous_selections != m_selections) + if (signal && previous_selections != m_selections) SelChangedSignal(m_selections); } @@ -961,7 +961,7 @@ return **boost::next(m_rows.begin(), n); } -void ListBox::SetSelections(const SelectionSet& s) +void ListBox::SetSelections(const SelectionSet& s, bool signal/* = false*/) { if (m_style & LIST_NOSEL) return; @@ -970,7 +970,7 @@ m_selections = s; - if (previous_selections != m_selections) + if (signal && previous_selections != m_selections) SelChangedSignal(m_selections); } |
From: <geo...@us...> - 2014-04-12 11:49:24
|
Revision: 7048 http://sourceforge.net/p/freeorion/code/7048 Author: geoffthemedio Date: 2014-04-12 11:49:21 +0000 (Sat, 12 Apr 2014) Log Message: ----------- -Allowed drag-selection of text in non-editable MultiEdits. -Fixed SelectAll / DeselectAll in MultiEdit. Modified Paths: -------------- trunk/FreeOrion/GG/GG/MultiEdit.h trunk/FreeOrion/GG/src/MultiEdit.cpp Modified: trunk/FreeOrion/GG/GG/MultiEdit.h =================================================================== --- trunk/FreeOrion/GG/GG/MultiEdit.h 2014-04-12 10:16:36 UTC (rev 7047) +++ trunk/FreeOrion/GG/GG/MultiEdit.h 2014-04-12 11:49:21 UTC (rev 7048) @@ -92,6 +92,7 @@ virtual void SizeMove(const Pt& ul, const Pt& lr); virtual void SelectAll(); + virtual void DeselectAll(); virtual void SetText(const std::string& str); /** Sets the style flags for this MultiEdit to \a style. */ Modified: trunk/FreeOrion/GG/src/MultiEdit.cpp =================================================================== --- trunk/FreeOrion/GG/src/MultiEdit.cpp 2014-04-12 10:16:36 UTC (rev 7047) +++ trunk/FreeOrion/GG/src/MultiEdit.cpp 2014-04-12 11:49:21 UTC (rev 7048) @@ -272,9 +272,17 @@ void MultiEdit::SelectAll() { m_cursor_begin = std::pair<std::size_t, CPSize>(0, CP0); - m_cursor_end = std::pair<std::size_t, CPSize>(GetLineData().size() - 1, CPSize(GetLineData()[GetLineData().size() - 1].char_data.size())); + m_cursor_end = std::pair<std::size_t, CPSize>( + GetLineData().size() - 1, + CPSize(GetLineData()[GetLineData().size() - 1].char_data.size())); } +void MultiEdit::DeselectAll() +{ + m_cursor_begin = std::pair<std::size_t, CPSize>(0, CP0); + m_cursor_end = m_cursor_begin; +} + void MultiEdit::SetText(const std::string& str) { if (m_preserve_text_position_on_next_set_text) { @@ -601,60 +609,63 @@ void MultiEdit::LButtonDown(const Pt& pt, Flags<ModKey> mod_keys) { + if (Disabled()) + return; + // when a button press occurs, record the character position under the // cursor, and remove any previous selection range - if (!Disabled() && !(m_style & MULTI_READ_ONLY)) { - std::pair<std::size_t, CPSize> click_pos = CharAt(ScreenToClient(pt)); - m_cursor_begin = m_cursor_end = click_pos; - std::pair<CPSize, CPSize> word_indices = - GetDoubleButtonDownWordIndices(CodePointIndexOf(m_cursor_begin.first, m_cursor_begin.second, - GetLineData())); - if (word_indices.first != word_indices.second) { - m_cursor_begin = CharAt(word_indices.first); - m_cursor_end = CharAt(word_indices.second); - } - AdjustView(); + std::pair<std::size_t, CPSize> click_pos = CharAt(ScreenToClient(pt)); + m_cursor_begin = m_cursor_end = click_pos; + std::pair<CPSize, CPSize> word_indices = + GetDoubleButtonDownWordIndices(CodePointIndexOf(m_cursor_begin.first, m_cursor_begin.second, + GetLineData())); + if (word_indices.first != word_indices.second) { + m_cursor_begin = CharAt(word_indices.first); + m_cursor_end = CharAt(word_indices.second); } + AdjustView(); } void MultiEdit::LDrag(const Pt& pt, const Pt& move, Flags<ModKey> mod_keys) { - if (!Disabled() && !(m_style & MULTI_READ_ONLY)) { - // when a drag occurs, move m_cursor_end to where the mouse is, which selects a range of characters - Pt click_pos = ScreenToClient(pt); - m_cursor_end = CharAt(click_pos); - if (InDoubleButtonDownMode()) { - std::pair<CPSize, CPSize> initial_indices = DoubleButtonDownCursorPos(); - CPSize idx = CharIndexOf(m_cursor_end.first, m_cursor_end.second); - std::pair<CPSize, CPSize> word_indices = GetDoubleButtonDownDragWordIndices(idx); - std::pair<CPSize, CPSize> final_indices; - if (word_indices.first == word_indices.second) { - if (idx < initial_indices.first) { - final_indices.second = idx; - final_indices.first = initial_indices.second; - } else if (initial_indices.second < idx) { - final_indices.second = idx; - final_indices.first = initial_indices.first; - } else { - final_indices = initial_indices; - } + if (Disabled()) + return; + + // when a drag occurs, move m_cursor_end to where the mouse is, which + // selects a range of characters + Pt click_pos = ScreenToClient(pt); + m_cursor_end = CharAt(click_pos); + if (InDoubleButtonDownMode()) { + std::pair<CPSize, CPSize> initial_indices = DoubleButtonDownCursorPos(); + CPSize idx = CharIndexOf(m_cursor_end.first, m_cursor_end.second); + std::pair<CPSize, CPSize> word_indices = GetDoubleButtonDownDragWordIndices(idx); + std::pair<CPSize, CPSize> final_indices; + if (word_indices.first == word_indices.second) { + if (idx < initial_indices.first) { + final_indices.second = idx; + final_indices.first = initial_indices.second; + } else if (initial_indices.second < idx) { + final_indices.second = idx; + final_indices.first = initial_indices.first; } else { - if (word_indices.first <= initial_indices.first) { - final_indices.second = word_indices.first; - final_indices.first = initial_indices.second; - } else { - final_indices.second = word_indices.second; - final_indices.first = initial_indices.first; - } + final_indices = initial_indices; } - m_cursor_begin = CharAt(final_indices.first); - m_cursor_end = CharAt(final_indices.second); + } else { + if (word_indices.first <= initial_indices.first) { + final_indices.second = word_indices.first; + final_indices.first = initial_indices.second; + } else { + final_indices.second = word_indices.second; + final_indices.first = initial_indices.first; + } } - // if we're dragging past the currently visible text, adjust the view so more text can be selected - if (click_pos.x < 0 || click_pos.x > ClientSize().x || - click_pos.y < 0 || click_pos.y > ClientSize().y) - AdjustView(); + m_cursor_begin = CharAt(final_indices.first); + m_cursor_end = CharAt(final_indices.second); } + // if we're dragging past the currently visible text, adjust the view so more text can be selected + if (click_pos.x < 0 || click_pos.x > ClientSize().x || + click_pos.y < 0 || click_pos.y > ClientSize().y) + AdjustView(); } void MultiEdit::MouseWheel(const Pt& pt, int move, Flags<ModKey> mod_keys) |
From: <geo...@us...> - 2014-04-12 13:01:30
|
Revision: 7049 http://sourceforge.net/p/freeorion/code/7049 Author: geoffthemedio Date: 2014-04-12 13:01:26 +0000 (Sat, 12 Apr 2014) Log Message: ----------- Modified Edit and MultiEdit so that MultiEdit sets Edit::m_cursor_pos while setting MultiEdit's own internal cursor position tracking. This lets functions like Edit::SelectedText that reference Edit::m_cursor_pos work correctly when selecting text in a MultiEdit. Modified Paths: -------------- trunk/FreeOrion/GG/GG/Edit.h trunk/FreeOrion/GG/src/Edit.cpp trunk/FreeOrion/GG/src/MultiEdit.cpp Modified: trunk/FreeOrion/GG/GG/Edit.h =================================================================== --- trunk/FreeOrion/GG/GG/Edit.h 2014-04-12 11:49:21 UTC (rev 7048) +++ trunk/FreeOrion/GG/GG/Edit.h 2014-04-12 13:01:26 UTC (rev 7049) @@ -216,15 +216,15 @@ frame. */ static const int PIXEL_MARGIN; -private: - void ClearSelected(); ///< Clears (deletes) selected characters, as when a del, backspace, or character is entered - void AdjustView(); ///< Makes sure the caret ends up in view after an arbitrary move - /** If .first == .second, the caret is drawn before character at m_cursor_pos.first; otherwise, the range is selected (when range is selected, caret is considered at .second) */ std::pair<CPSize, CPSize> m_cursor_pos; +private: + void ClearSelected(); ///< Clears (deletes) selected characters, as when a del, backspace, or character is entered + void AdjustView(); ///< Makes sure the caret ends up in view after an arbitrary move + CPSize m_first_char_shown; ///< Index of the first character on the left end of the control's viewable area Clr m_int_color; ///< Color of background inside text box Clr m_hilite_color; ///< Color behind selected range Modified: trunk/FreeOrion/GG/src/Edit.cpp =================================================================== --- trunk/FreeOrion/GG/src/Edit.cpp 2014-04-12 11:49:21 UTC (rev 7048) +++ trunk/FreeOrion/GG/src/Edit.cpp 2014-04-12 13:01:26 UTC (rev 7049) @@ -100,10 +100,7 @@ { return m_cursor_pos; } std::string Edit::SelectedText() const -{ - //std::cout << Text(m_cursor_pos.first, m_cursor_pos.second) << std::endl; - return Text(m_cursor_pos.first, m_cursor_pos.second); -} +{ return Text(m_cursor_pos.first, m_cursor_pos.second); } Clr Edit::InteriorColor() const { return m_int_color; } Modified: trunk/FreeOrion/GG/src/MultiEdit.cpp =================================================================== --- trunk/FreeOrion/GG/src/MultiEdit.cpp 2014-04-12 11:49:21 UTC (rev 7048) +++ trunk/FreeOrion/GG/src/MultiEdit.cpp 2014-04-12 13:01:26 UTC (rev 7049) @@ -275,12 +275,19 @@ m_cursor_end = std::pair<std::size_t, CPSize>( GetLineData().size() - 1, CPSize(GetLineData()[GetLineData().size() - 1].char_data.size())); + + CPSize begin_cursor_pos = CharIndexOf(m_cursor_begin.first, m_cursor_begin.second); + CPSize end_cursor_pos = CharIndexOf(m_cursor_end.first, m_cursor_end.second); + this->m_cursor_pos = std::make_pair(begin_cursor_pos, end_cursor_pos); } void MultiEdit::DeselectAll() { m_cursor_begin = std::pair<std::size_t, CPSize>(0, CP0); m_cursor_end = m_cursor_begin; + + CPSize cursor_pos = CharIndexOf(m_cursor_begin.first, m_cursor_begin.second); + this->m_cursor_pos = std::make_pair(cursor_pos, cursor_pos); } void MultiEdit::SetText(const std::string& str) @@ -349,6 +356,9 @@ } m_cursor_begin = m_cursor_end; // eliminate any hiliting + CPSize cursor_pos = CharIndexOf(m_cursor_end.first, m_cursor_end.second); + this->m_cursor_pos = std::make_pair(cursor_pos, cursor_pos); + m_contents_sz = GetFont()->TextExtent(Text(), GetLineData()); AdjustScrolls(); @@ -358,6 +368,7 @@ SignalScroll(*m_vscroll, true); } } + m_preserve_text_position_on_next_set_text = false; } @@ -474,7 +485,8 @@ return retval; } -CPSize MultiEdit::CharIndexOf(std::size_t row, CPSize char_idx, const std::vector<Font::LineData>* line_data) const +CPSize MultiEdit::CharIndexOf(std::size_t row, CPSize char_idx, + const std::vector<Font::LineData>* line_data) const { CPSize retval = CP0; const std::vector<Font::LineData>& lines = line_data ? *line_data : GetLineData(); @@ -486,7 +498,8 @@ } if (char_idx != lines[row].char_data.size()) { retval = lines[row].char_data[Value(char_idx)].code_point_index; - // "rewind" the first position to encompass all tag text that is associated with that position + // "rewind" the first position to encompass all tag text that is + // associated with that position for (std::size_t i = 0; i < lines[row].char_data[Value(char_idx)].tags.size(); ++i) { retval -= lines[row].char_data[Value(char_idx)].tags[i]->CodePointSize(); } @@ -591,20 +604,26 @@ std::pair<std::size_t, CPSize> MultiEdit::HighCursorPos() const { - if (m_cursor_begin.first < m_cursor_end.first || - (m_cursor_begin.first == m_cursor_end.first && m_cursor_begin.second < m_cursor_end.second)) + if (m_cursor_begin.first < m_cursor_end.first || + (m_cursor_begin.first == m_cursor_end.first && + m_cursor_begin.second < m_cursor_end.second)) + { return m_cursor_end; - else + } else { return m_cursor_begin; + } } std::pair<std::size_t, CPSize> MultiEdit::LowCursorPos() const { - if (m_cursor_begin.first < m_cursor_end.first || - (m_cursor_begin.first == m_cursor_end.first && m_cursor_begin.second < m_cursor_end.second)) + if (m_cursor_begin.first < m_cursor_end.first || + (m_cursor_begin.first == m_cursor_end.first && + m_cursor_begin.second < m_cursor_end.second)) + { return m_cursor_begin; - else + } else { return m_cursor_end; + } } void MultiEdit::LButtonDown(const Pt& pt, Flags<ModKey> mod_keys) @@ -616,6 +635,7 @@ // cursor, and remove any previous selection range std::pair<std::size_t, CPSize> click_pos = CharAt(ScreenToClient(pt)); m_cursor_begin = m_cursor_end = click_pos; + std::pair<CPSize, CPSize> word_indices = GetDoubleButtonDownWordIndices(CodePointIndexOf(m_cursor_begin.first, m_cursor_begin.second, GetLineData())); @@ -623,6 +643,11 @@ m_cursor_begin = CharAt(word_indices.first); m_cursor_end = CharAt(word_indices.second); } + + CPSize begin_cursor_pos = CharIndexOf(m_cursor_begin.first, m_cursor_begin.second); + CPSize end_cursor_pos = CharIndexOf(m_cursor_end.first, m_cursor_end.second); + this->m_cursor_pos = std::make_pair(begin_cursor_pos, end_cursor_pos); + AdjustView(); } @@ -662,10 +687,15 @@ m_cursor_begin = CharAt(final_indices.first); m_cursor_end = CharAt(final_indices.second); } + + CPSize begin_cursor_pos = CharIndexOf(m_cursor_begin.first, m_cursor_begin.second); + CPSize end_cursor_pos = CharIndexOf(m_cursor_end.first, m_cursor_end.second); + this->m_cursor_pos = std::make_pair(begin_cursor_pos, end_cursor_pos); + // if we're dragging past the currently visible text, adjust the view so more text can be selected - if (click_pos.x < 0 || click_pos.x > ClientSize().x || - click_pos.y < 0 || click_pos.y > ClientSize().y) - AdjustView(); + if (click_pos.x < 0 || click_pos.x > ClientSize().x || + click_pos.y < 0 || click_pos.y > ClientSize().y) + { AdjustView(); } } void MultiEdit::MouseWheel(const Pt& pt, int move, Flags<ModKey> mod_keys) @@ -678,202 +708,210 @@ void MultiEdit::KeyPress(Key key, boost::uint32_t key_code_point, Flags<ModKey> mod_keys) { - if (!Disabled()) { - if (!(m_style & MULTI_READ_ONLY)) { - bool shift_down = mod_keys & (MOD_KEY_LSHIFT | MOD_KEY_RSHIFT); - bool emit_signal = false; - switch (key) { - case GGK_RETURN: - case GGK_KP_ENTER: { - if (MultiSelected()) - ClearSelected(); - Insert(m_cursor_end.first, m_cursor_end.second, '\n'); - ++m_cursor_end.first; - m_cursor_end.second = CP0; - // the cursor might be off the bottom if the bottom row was just chopped off to satisfy m_max_lines_history - if (GetLineData().size() <= m_cursor_end.first) { - m_cursor_end.first = GetLineData().size() - 1; - m_cursor_end.second = CPSize(GetLineData()[m_cursor_end.first].char_data.size()); - if (LineEndsWithEndlineCharacter(GetLineData(), m_cursor_end.first, Text())) - --m_cursor_end.second; - } - m_cursor_begin = m_cursor_end; - emit_signal = true; - break; - } + if (Disabled()) { + TextControl::KeyPress(key, key_code_point, mod_keys); + return; + } - case GGK_LEFT: { - if (MultiSelected() && !shift_down) { - m_cursor_begin = m_cursor_end = LowCursorPos(); - } else if (0 < m_cursor_end.second) { - --m_cursor_end.second; - } else if (0 < m_cursor_end.first) { - --m_cursor_end.first; - m_cursor_end.second = CPSize(GetLineData()[m_cursor_end.first].char_data.size()); - if (LineEndsWithEndlineCharacter(GetLineData(), m_cursor_end.first, Text())) - --m_cursor_end.second; - } - if (!shift_down) - m_cursor_begin = m_cursor_end; - break; - } + if (m_style & MULTI_READ_ONLY) + return; - case GGK_RIGHT: { - if (MultiSelected() && !shift_down) { - m_cursor_begin = m_cursor_end = HighCursorPos(); - } else if (m_cursor_end.second < - GetLineData()[m_cursor_end.first].char_data.size() - - (LineEndsWithEndlineCharacter(GetLineData(), m_cursor_end.first, Text()) ? 1 : 0)) { - ++m_cursor_end.second; - } else if (m_cursor_end.first < GetLineData().size() - 1) { - ++m_cursor_end.first; - m_cursor_end.second = CP0; - } - if (!shift_down) - m_cursor_begin = m_cursor_end; - break; - } + bool shift_down = mod_keys & (MOD_KEY_LSHIFT | MOD_KEY_RSHIFT); + bool emit_signal = false; + switch (key) { + case GGK_RETURN: + case GGK_KP_ENTER: { + if (MultiSelected()) + ClearSelected(); + Insert(m_cursor_end.first, m_cursor_end.second, '\n'); + ++m_cursor_end.first; + m_cursor_end.second = CP0; + // the cursor might be off the bottom if the bottom row was just chopped off to satisfy m_max_lines_history + if (GetLineData().size() <= m_cursor_end.first) { + m_cursor_end.first = GetLineData().size() - 1; + m_cursor_end.second = CPSize(GetLineData()[m_cursor_end.first].char_data.size()); + if (LineEndsWithEndlineCharacter(GetLineData(), m_cursor_end.first, Text())) + --m_cursor_end.second; + } + m_cursor_begin = m_cursor_end; + emit_signal = true; + break; + } - case GGK_UP: { - if (MultiSelected() && !shift_down) { - m_cursor_begin = m_cursor_end = LowCursorPos(); - } else if (0 < m_cursor_end.first) { - X row_start = RowStartX(m_cursor_end.first); - X char_offset = CharXOffset(m_cursor_end.first, m_cursor_end.second); - --m_cursor_end.first; - m_cursor_end.second = CharAt(m_cursor_end.first, row_start + char_offset); - if (!shift_down) - m_cursor_begin = m_cursor_end; - } - break; - } + case GGK_LEFT: { + if (MultiSelected() && !shift_down) { + m_cursor_begin = m_cursor_end = LowCursorPos(); + } else if (0 < m_cursor_end.second) { + --m_cursor_end.second; + } else if (0 < m_cursor_end.first) { + --m_cursor_end.first; + m_cursor_end.second = CPSize(GetLineData()[m_cursor_end.first].char_data.size()); + if (LineEndsWithEndlineCharacter(GetLineData(), m_cursor_end.first, Text())) + --m_cursor_end.second; + } + if (!shift_down) + m_cursor_begin = m_cursor_end; + break; + } - case GGK_DOWN: { - if (MultiSelected() && !shift_down) { - m_cursor_begin = m_cursor_end = HighCursorPos(); - } else if (m_cursor_end.first < GetLineData().size() - 1) { - X row_start = RowStartX(m_cursor_end.first); - X char_offset = CharXOffset(m_cursor_end.first, m_cursor_end.second); - ++m_cursor_end.first; - m_cursor_end.second = CharAt(m_cursor_end.first, row_start + char_offset); - if (!shift_down) - m_cursor_begin = m_cursor_end; - } - break; - } + case GGK_RIGHT: { + if (MultiSelected() && !shift_down) { + m_cursor_begin = m_cursor_end = HighCursorPos(); + } else if (m_cursor_end.second < + GetLineData()[m_cursor_end.first].char_data.size() - + (LineEndsWithEndlineCharacter(GetLineData(), m_cursor_end.first, Text()) ? 1 : 0)) { + ++m_cursor_end.second; + } else if (m_cursor_end.first < GetLineData().size() - 1) { + ++m_cursor_end.first; + m_cursor_end.second = CP0; + } + if (!shift_down) + m_cursor_begin = m_cursor_end; + break; + } - case GGK_HOME: { - m_cursor_end.second = CP0; - if (!shift_down) - m_cursor_begin = m_cursor_end; - break; - } + case GGK_UP: { + if (MultiSelected() && !shift_down) { + m_cursor_begin = m_cursor_end = LowCursorPos(); + } else if (0 < m_cursor_end.first) { + X row_start = RowStartX(m_cursor_end.first); + X char_offset = CharXOffset(m_cursor_end.first, m_cursor_end.second); + --m_cursor_end.first; + m_cursor_end.second = CharAt(m_cursor_end.first, row_start + char_offset); + if (!shift_down) + m_cursor_begin = m_cursor_end; + } + break; + } - case GGK_END: { + case GGK_DOWN: { + if (MultiSelected() && !shift_down) { + m_cursor_begin = m_cursor_end = HighCursorPos(); + } else if (m_cursor_end.first < GetLineData().size() - 1) { + X row_start = RowStartX(m_cursor_end.first); + X char_offset = CharXOffset(m_cursor_end.first, m_cursor_end.second); + ++m_cursor_end.first; + m_cursor_end.second = CharAt(m_cursor_end.first, row_start + char_offset); + if (!shift_down) + m_cursor_begin = m_cursor_end; + } + break; + } + + case GGK_HOME: { + m_cursor_end.second = CP0; + if (!shift_down) + m_cursor_begin = m_cursor_end; + break; + } + + case GGK_END: { + m_cursor_end.second = CPSize(GetLineData()[m_cursor_end.first].char_data.size()); + if (LineEndsWithEndlineCharacter(GetLineData(), m_cursor_end.first, Text())) + --m_cursor_end.second; + if (!shift_down) + m_cursor_begin = m_cursor_end; + break; + } + + case GGK_PAGEUP: { + if (m_vscroll) { + m_vscroll->ScrollPageDecr(); + SignalScroll(*m_vscroll, true); + std::size_t rows_moved = m_vscroll->PageSize() / Value(GetFont()->Lineskip()); + m_cursor_end.first = m_cursor_end.first < rows_moved ? 0 : m_cursor_end.first - rows_moved; + if (GetLineData()[m_cursor_end.first].char_data.size() < m_cursor_end.second) m_cursor_end.second = CPSize(GetLineData()[m_cursor_end.first].char_data.size()); - if (LineEndsWithEndlineCharacter(GetLineData(), m_cursor_end.first, Text())) - --m_cursor_end.second; - if (!shift_down) - m_cursor_begin = m_cursor_end; - break; - } + m_cursor_begin = m_cursor_end; + } + break; + } - case GGK_PAGEUP: { - if (m_vscroll) { - m_vscroll->ScrollPageDecr(); - SignalScroll(*m_vscroll, true); - std::size_t rows_moved = m_vscroll->PageSize() / Value(GetFont()->Lineskip()); - m_cursor_end.first = m_cursor_end.first < rows_moved ? 0 : m_cursor_end.first - rows_moved; - if (GetLineData()[m_cursor_end.first].char_data.size() < m_cursor_end.second) - m_cursor_end.second = CPSize(GetLineData()[m_cursor_end.first].char_data.size()); - m_cursor_begin = m_cursor_end; - } - break; - } + case GGK_PAGEDOWN: { + if (m_vscroll) { + m_vscroll->ScrollPageIncr(); + SignalScroll(*m_vscroll, true); + std::size_t rows_moved = m_vscroll->PageSize() / Value(GetFont()->Lineskip()); + m_cursor_end.first = std::min(m_cursor_end.first + rows_moved, GetLineData().size() - 1); + if (GetLineData()[m_cursor_end.first].char_data.size() < m_cursor_end.second) + m_cursor_end.second = CPSize(GetLineData()[m_cursor_end.first].char_data.size()); + m_cursor_begin = m_cursor_end; + } + break; + } - case GGK_PAGEDOWN: { - if (m_vscroll) { - m_vscroll->ScrollPageIncr(); - SignalScroll(*m_vscroll, true); - std::size_t rows_moved = m_vscroll->PageSize() / Value(GetFont()->Lineskip()); - m_cursor_end.first = std::min(m_cursor_end.first + rows_moved, GetLineData().size() - 1); - if (GetLineData()[m_cursor_end.first].char_data.size() < m_cursor_end.second) - m_cursor_end.second = CPSize(GetLineData()[m_cursor_end.first].char_data.size()); - m_cursor_begin = m_cursor_end; - } - break; - } + case GGK_BACKSPACE: { + if (MultiSelected()) { + ClearSelected(); + emit_signal = true; + } else if (0 < m_cursor_begin.second) { + m_cursor_end.second = --m_cursor_begin.second; + Erase(m_cursor_begin.first, m_cursor_begin.second, CP1); + emit_signal = true; + } else if (0 < m_cursor_begin.first) { + m_cursor_end.first = --m_cursor_begin.first; + m_cursor_begin.second = CPSize(GetLineData()[m_cursor_begin.first].char_data.size()); + if (LineEndsWithEndlineCharacter(GetLineData(), m_cursor_begin.first, Text())) + --m_cursor_begin.second; + m_cursor_end.second = m_cursor_begin.second; + Erase(m_cursor_begin.first, m_cursor_begin.second, CP1); + emit_signal = true; + } + break; + } - case GGK_BACKSPACE: { - if (MultiSelected()) { - ClearSelected(); - emit_signal = true; - } else if (0 < m_cursor_begin.second) { - m_cursor_end.second = --m_cursor_begin.second; - Erase(m_cursor_begin.first, m_cursor_begin.second, CP1); - emit_signal = true; - } else if (0 < m_cursor_begin.first) { - m_cursor_end.first = --m_cursor_begin.first; - m_cursor_begin.second = CPSize(GetLineData()[m_cursor_begin.first].char_data.size()); - if (LineEndsWithEndlineCharacter(GetLineData(), m_cursor_begin.first, Text())) - --m_cursor_begin.second; - m_cursor_end.second = m_cursor_begin.second; - Erase(m_cursor_begin.first, m_cursor_begin.second, CP1); - emit_signal = true; - } - break; - } + case GGK_DELETE: { + if (MultiSelected()) { + ClearSelected(); + emit_signal = true; + } else if (m_cursor_begin.second < GetLineData()[m_cursor_begin.first].char_data.size()) { + Erase(m_cursor_begin.first, m_cursor_begin.second, CP1); + emit_signal = true; + } else if (m_cursor_begin.first < GetLineData().size() - 1) { + Erase(m_cursor_begin.first, m_cursor_begin.second, CP1); + emit_signal = true; + } + break; + } - case GGK_DELETE: { - if (MultiSelected()) { - ClearSelected(); - emit_signal = true; - } else if (m_cursor_begin.second < GetLineData()[m_cursor_begin.first].char_data.size()) { - Erase(m_cursor_begin.first, m_cursor_begin.second, CP1); - emit_signal = true; - } else if (m_cursor_begin.first < GetLineData().size() - 1) { - Erase(m_cursor_begin.first, m_cursor_begin.second, CP1); - emit_signal = true; - } - break; + default: { + std::string translated_code_point; + GetTranslatedCodePoint(key, key_code_point, mod_keys, translated_code_point); + if (!translated_code_point.empty() && + !(mod_keys & (MOD_KEY_CTRL | MOD_KEY_ALT | MOD_KEY_META))) { + if (MultiSelected()) + ClearSelected(); + // insert the character to the right of the caret + Insert(m_cursor_begin.first, m_cursor_begin.second, translated_code_point); + // then move the caret fwd one. + if (m_cursor_begin.second < GetLineData()[m_cursor_begin.first].char_data.size()) { + ++m_cursor_begin.second; + } else { + ++m_cursor_begin.first; + m_cursor_begin.second = CP1; } - - default: { - std::string translated_code_point; - GetTranslatedCodePoint(key, key_code_point, mod_keys, translated_code_point); - if (!translated_code_point.empty() && - !(mod_keys & (MOD_KEY_CTRL | MOD_KEY_ALT | MOD_KEY_META))) { - if (MultiSelected()) - ClearSelected(); - // insert the character to the right of the caret - Insert(m_cursor_begin.first, m_cursor_begin.second, translated_code_point); - // then move the caret fwd one. - if (m_cursor_begin.second < GetLineData()[m_cursor_begin.first].char_data.size()) { - ++m_cursor_begin.second; - } else { - ++m_cursor_begin.first; - m_cursor_begin.second = CP1; - } - // the cursor might be off the bottom if the bottom row was just chopped off to satisfy m_max_lines_history - if (GetLineData().size() - 1 < m_cursor_begin.first) { - m_cursor_begin.first = GetLineData().size() - 1; - m_cursor_begin.second = CPSize(GetLineData()[m_cursor_begin.first].char_data.size()); - } - m_cursor_end = m_cursor_begin; - emit_signal = true; - } else { - TextControl::KeyPress(key, key_code_point, mod_keys); - } - break; + // the cursor might be off the bottom if the bottom row was just + // chopped off to satisfy m_max_lines_history + if (GetLineData().size() - 1 < m_cursor_begin.first) { + m_cursor_begin.first = GetLineData().size() - 1; + m_cursor_begin.second = CPSize(GetLineData()[m_cursor_begin.first].char_data.size()); } - } - AdjustView(); - if (emit_signal) - EditedSignal(Text()); + m_cursor_end = m_cursor_begin; + emit_signal = true; + } else { + TextControl::KeyPress(key, key_code_point, mod_keys); } - } else { - TextControl::KeyPress(key, key_code_point, mod_keys); + break; } + } + + CPSize begin_cursor_pos = CharIndexOf(m_cursor_begin.first, m_cursor_begin.second); + CPSize end_cursor_pos = CharIndexOf(m_cursor_end.first, m_cursor_end.second); + this->m_cursor_pos = std::make_pair(begin_cursor_pos, end_cursor_pos); + + AdjustView(); + if (emit_signal) + EditedSignal(Text()); } void MultiEdit::RecreateScrolls() @@ -916,7 +954,13 @@ CPSize idx_1 = CharIndexOf(m_cursor_begin.first, m_cursor_begin.second); CPSize idx_2 = CharIndexOf(m_cursor_end.first, m_cursor_end.second); m_cursor_begin = m_cursor_end = LowCursorPos(); - Erase(m_cursor_begin.first, m_cursor_begin.second, idx_1 < idx_2 ? idx_2 - idx_1 : idx_1 - idx_2); + Erase(m_cursor_begin.first, m_cursor_begin.second, + idx_1 < idx_2 ? + idx_2 - idx_1 : + idx_1 - idx_2); + + CPSize cursor_pos = CharIndexOf(m_cursor_end.first, m_cursor_end.second); + this->m_cursor_pos = std::make_pair(cursor_pos, cursor_pos); } void MultiEdit::AdjustView() |
From: <geo...@us...> - 2014-04-13 12:27:55
|
Revision: 7061 http://sourceforge.net/p/freeorion/code/7061 Author: geoffthemedio Date: 2014-04-13 12:27:51 +0000 (Sun, 13 Apr 2014) Log Message: ----------- Publically exposed GG::MassagedAccelModKeys. Modified Paths: -------------- trunk/FreeOrion/GG/GG/GUI.h trunk/FreeOrion/GG/src/GUI.cpp Modified: trunk/FreeOrion/GG/GG/GUI.h =================================================================== --- trunk/FreeOrion/GG/GG/GUI.h 2014-04-13 11:56:43 UTC (rev 7060) +++ trunk/FreeOrion/GG/GG/GUI.h 2014-04-13 12:27:51 UTC (rev 7061) @@ -394,7 +394,13 @@ /** Returns true if lwnd == rwnd or if lwnd contains rwnd */ GG_API bool MatchesOrContains(const Wnd* lwnd, const Wnd* rwnd); +/* returns the storage value of mod_keys that should be used with keyboard + accelerators the accelerators don't care which side of the keyboard you + use for CTRL, SHIFT, etc., and whether or not the numlock or capslock are + engaged.*/ +GG_API Flags<ModKey> MassagedAccelModKeys(Flags<ModKey> mod_keys); + // template implementations template<class InIt> bool GUI::OrCombiner::operator()(InIt first, InIt last) const Modified: trunk/FreeOrion/GG/src/GUI.cpp =================================================================== --- trunk/FreeOrion/GG/src/GUI.cpp 2014-04-13 11:56:43 UTC (rev 7060) +++ trunk/FreeOrion/GG/src/GUI.cpp 2014-04-13 12:27:51 UTC (rev 7061) @@ -72,24 +72,6 @@ std::string m_str; }; - /* returns the storage value of mod_keys that should be used with keyboard - accelerators the accelerators don't care which side of the keyboard you - use for CTRL, SHIFT, etc., and whether or not the numlock or capslock are - engaged.*/ - Flags<ModKey> MassagedAccelModKeys(Flags<ModKey> mod_keys) - { - mod_keys &= ~(MOD_KEY_NUM | MOD_KEY_CAPS); - if (mod_keys & MOD_KEY_CTRL) - mod_keys |= MOD_KEY_CTRL; - if (mod_keys & MOD_KEY_SHIFT) - mod_keys |= MOD_KEY_SHIFT; - if (mod_keys & MOD_KEY_ALT) - mod_keys |= MOD_KEY_ALT; - if (mod_keys & MOD_KEY_META) - mod_keys |= MOD_KEY_META; - return mod_keys; - } - Key KeyMappedKey(Key key, const std::map<Key, Key>& key_map) { std::map<Key, Key>::const_iterator it = key_map.find(key); if (it != key_map.end()) @@ -147,6 +129,7 @@ } } + // implementation data types struct GG::GUIImpl { @@ -1638,3 +1621,17 @@ } return false; } + +Flags<ModKey> GG::MassagedAccelModKeys(Flags<ModKey> mod_keys) +{ + mod_keys &= ~(MOD_KEY_NUM | MOD_KEY_CAPS); + if (mod_keys & MOD_KEY_CTRL) + mod_keys |= MOD_KEY_CTRL; + if (mod_keys & MOD_KEY_SHIFT) + mod_keys |= MOD_KEY_SHIFT; + if (mod_keys & MOD_KEY_ALT) + mod_keys |= MOD_KEY_ALT; + if (mod_keys & MOD_KEY_META) + mod_keys |= MOD_KEY_META; + return mod_keys; +} \ No newline at end of file |
From: <geo...@us...> - 2014-04-17 19:01:33
|
Revision: 7067 http://sourceforge.net/p/freeorion/code/7067 Author: geoffthemedio Date: 2014-04-17 19:01:30 +0000 (Thu, 17 Apr 2014) Log Message: ----------- -Made SortKey and Control getters virtual. -grooming Modified Paths: -------------- trunk/FreeOrion/GG/GG/ListBox.h trunk/FreeOrion/GG/src/ListBox.cpp Modified: trunk/FreeOrion/GG/GG/ListBox.h =================================================================== --- trunk/FreeOrion/GG/GG/ListBox.h 2014-04-17 19:00:38 UTC (rev 7066) +++ trunk/FreeOrion/GG/GG/ListBox.h 2014-04-17 19:01:30 UTC (rev 7067) @@ -168,17 +168,17 @@ //@} /** \name Accessors */ ///@{ - SortKeyType SortKey(std::size_t column) const; ///< returns the string by which this row may be sorted - std::size_t size() const; ///< returns the number of Controls in this Row - bool empty() const; ///< returns true iff there are 0 Controls in this Row + virtual SortKeyType SortKey(std::size_t column) const; ///< returns the string by which this row may be sorted + std::size_t size() const; ///< returns the number of Controls in this Row + bool empty() const; ///< returns true iff there are 0 Controls in this Row - Control* operator[](std::size_t n) const; ///< returns the Control in the \a nth cell of this Row; not range checked - Control* at(std::size_t n) const; ///< returns the Control in the \a nth cell of this Row \throw std::range_error throws when size() <= \a n + virtual Control* operator[](std::size_t n) const; ///< returns the Control in the \a nth cell of this Row; not range checked + virtual Control* at(std::size_t n) const; ///< returns the Control in the \a nth cell of this Row \throw std::range_error throws when size() <= \a n - Alignment RowAlignment() const; ///< returns the vertical alignment of this Row + Alignment RowAlignment() const; ///< returns the vertical alignment of this Row Alignment ColAlignment(std::size_t n) const; ///< returns the horizontal alignment of the Control in the \a nth cell of this Row; not range checked - X ColWidth(std::size_t n) const; ///< returns the width of the \a nth cell of this Row; not range checked - unsigned int Margin() const; ///< returns the amount of space left between the contents of adjacent cells, in pixels + X ColWidth(std::size_t n) const; ///< returns the width of the \a nth cell of this Row; not range checked + unsigned int Margin() const; ///< returns the amount of space left between the contents of adjacent cells, in pixels Control* CreateControl(const std::string& str, const boost::shared_ptr<Font>& font, Clr color) const; ///< creates a "shrink-fit" TextControl from text, font, and color parameters Control* CreateControl(const SubTexture& st) const; ///< creates a "shrink-fit" StaticGraphic Control from a SubTexture parameter Modified: trunk/FreeOrion/GG/src/ListBox.cpp =================================================================== --- trunk/FreeOrion/GG/src/ListBox.cpp 2014-04-17 19:00:38 UTC (rev 7066) +++ trunk/FreeOrion/GG/src/ListBox.cpp 2014-04-17 19:01:30 UTC (rev 7067) @@ -84,13 +84,16 @@ public: RowSorter(const boost::function<bool (const ListBox::Row&, const ListBox::Row&, std::size_t)>& cmp, std::size_t col, bool invert) : - m_cmp(cmp), m_sort_col(col), m_invert(invert) {} + m_cmp(cmp), + m_sort_col(col), + m_invert(invert) + {} bool operator()(const ListBox::Row* l, const ListBox::Row* r) - { - bool retval = m_cmp(*l, *r, m_sort_col); - return m_invert ? !retval : retval; - } + { + bool retval = m_cmp(*l, *r, m_sort_col); + return m_invert ? !retval : retval; + } private: boost::function<bool (const ListBox::Row&, const ListBox::Row&, std::size_t)> m_cmp; @@ -120,9 +123,11 @@ { ScopedSet(ListBox::iterator*& var, ListBox::iterator* value) : m_var(var = value) - {} + {} + ~ScopedSet() - { m_var = 0; } + { m_var = 0; } + ListBox::iterator*& m_var; }; @@ -262,9 +267,8 @@ m_cells.push_back(c); m_col_widths.push_back(X(5)); m_col_alignments.push_back(ALIGN_NONE); - if (1 < m_cells.size()) { + if (1 < m_cells.size()) m_col_widths.back() = m_col_widths[m_cells.size() - 1]; - } AdjustLayout(); } @@ -401,9 +405,8 @@ Layout* layout = GetLayout(); for (std::size_t i = 0; i < m_cells.size(); ++i) { layout->SetMinimumColumnWidth(i, m_col_widths[i]); - if (m_cells[i]) { + if (m_cells[i]) layout->Add(m_cells[i], 0, i, m_row_alignment | m_col_alignments[i]); - } } } @@ -1786,10 +1789,10 @@ selections.insert(**it); } m_selections.clear(); - Row* old_sel_row = SafeDeref(m_old_sel_row, m_rows.end()); - Row* old_rdown_row = SafeDeref(m_old_rdown_row, m_rows.end()); - Row* lclick_row = SafeDeref(m_lclick_row, m_rows.end()); - Row* rclick_row = SafeDeref(m_rclick_row, m_rows.end()); + Row* old_sel_row = SafeDeref(m_old_sel_row, m_rows.end()); + Row* old_rdown_row = SafeDeref(m_old_rdown_row, m_rows.end()); + Row* lclick_row = SafeDeref(m_lclick_row, m_rows.end()); + Row* rclick_row = SafeDeref(m_rclick_row, m_rows.end()); Row* last_row_browsed = SafeDeref(m_last_row_browsed, m_rows.end()); std::vector<Row*> rows_vec(m_rows.size()); |
From: <geo...@us...> - 2014-04-18 20:35:49
|
Revision: 7077 http://sourceforge.net/p/freeorion/code/7077 Author: geoffthemedio Date: 2014-04-18 20:35:46 +0000 (Fri, 18 Apr 2014) Log Message: ----------- -Added a NO_WND_FLAGS constant, which is the case where no WndFlag is set. This is less verbose to use than Flags<WndFlag>() or GG::Flags<GG::WndFlag>(). -Replaced various uses of Flags<WndFlag>() with the constant. -grooming Modified Paths: -------------- trunk/FreeOrion/GG/GG/DynamicGraphic.h trunk/FreeOrion/GG/GG/Flags.h trunk/FreeOrion/GG/GG/GroupBox.h trunk/FreeOrion/GG/GG/StaticGraphic.h trunk/FreeOrion/GG/GG/StyleFactory.h trunk/FreeOrion/GG/GG/TabWnd.h trunk/FreeOrion/GG/GG/TextControl.h trunk/FreeOrion/GG/GG/Wnd.h trunk/FreeOrion/GG/src/AlignmentFlags.cpp trunk/FreeOrion/GG/src/Font.cpp trunk/FreeOrion/GG/src/GroupBox.cpp trunk/FreeOrion/GG/src/Layout.cpp trunk/FreeOrion/GG/src/MultiEdit.cpp trunk/FreeOrion/GG/src/StaticGraphic.cpp trunk/FreeOrion/GG/src/StyleFactory.cpp trunk/FreeOrion/GG/src/TextControl.cpp trunk/FreeOrion/GG/src/Wnd.cpp trunk/FreeOrion/GG/src/dialogs/ColorDlg.cpp Modified: trunk/FreeOrion/GG/GG/DynamicGraphic.h =================================================================== --- trunk/FreeOrion/GG/GG/DynamicGraphic.h 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/GG/DynamicGraphic.h 2014-04-18 20:35:46 UTC (rev 7077) @@ -95,7 +95,7 @@ DynamicGraphic(X x, Y y, X w, Y h, bool loop, X frame_width, Y frame_height, unsigned int margin, const std::vector<boost::shared_ptr<Texture> >& textures, Flags<GraphicStyle> style = GRAPHIC_NONE, std::size_t frames = ALL_FRAMES, - Flags<WndFlag> flags = Flags<WndFlag>()); + Flags<WndFlag> flags = NO_WND_FLAGS); //@} /** \name Accessors */ ///@{ Modified: trunk/FreeOrion/GG/GG/Flags.h =================================================================== --- trunk/FreeOrion/GG/GG/Flags.h 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/GG/Flags.h 2014-04-18 20:35:46 UTC (rev 7077) @@ -177,44 +177,44 @@ /** \name Accessors */ ///@{ /** Returns true iff FlagSpec contains \a flag. */ bool contains(FlagType flag) const - { return find(flag) != end(); } + { return find(flag) != end(); } /** Returns true iff \a flag is a "permanent" flag -- a flag used internally by the GG library, as opposed to a user-added flag. */ bool permanent(FlagType flag) const - { return m_permanent.find(flag) != m_permanent.end(); } + { return m_permanent.find(flag) != m_permanent.end(); } /** Returns an iterator to \a flag, if flag is in the FlagSpec, or end() otherwise. */ const_iterator find(FlagType flag) const - { return m_flags.find(flag); } + { return m_flags.find(flag); } /** Returns an iterator to the first flag in the FlagSpec. */ const_iterator begin() const - { return m_flags.begin(); } + { return m_flags.begin(); } /** Returns an iterator to one past the last flag in the FlagSpec. */ const_iterator end() const - { return m_flags.end(); } + { return m_flags.end(); } /** Returns the stringification of \a flag provided when \a flag was added to the FlagSpec. \throw Throws GG::FlagSpec::UnknownFlag if an unknown flag's stringification is requested. */ const std::string& ToString(FlagType flag) const - { - typename std::map<FlagType, std::string>::const_iterator it = m_strings.find(flag); - if (it == m_strings.end()) - throw UnknownFlag("Could not find string corresponding to unknown flag"); - return it->second; - } + { + typename std::map<FlagType, std::string>::const_iterator it = m_strings.find(flag); + if (it == m_strings.end()) + throw UnknownFlag("Could not find string corresponding to unknown flag"); + return it->second; + } /** Returns the flag whose stringification is \a str. \throw Throws GG::FlagSpec::UnknownString if an unknown string is provided. */ FlagType FromString(const std::string& str) const - { - for (typename std::map<FlagType, std::string>::const_iterator it = m_strings.begin(); - it != m_strings.end(); - ++it) { - if (it->second == str) - return it->first; - } - throw UnknownString("Could not find flag corresponding to unknown string"); - return FlagType(0); + { + for (typename std::map<FlagType, std::string>::const_iterator it = m_strings.begin(); + it != m_strings.end(); + ++it) { + if (it->second == str) + return it->first; } + throw UnknownString("Could not find flag corresponding to unknown string"); + return FlagType(0); + } //@} /** \name Mutators */ ///@{ @@ -223,35 +223,35 @@ added by GG are added as permanent flags. User-added flags should not be added as permanent. */ void insert(FlagType flag, const std::string& name, bool permanent = false) - { + { #ifndef NDEBUG - std::pair<typename std::set<FlagType>::iterator, bool> result = + std::pair<typename std::set<FlagType>::iterator, bool> result = #endif - m_flags.insert(flag); + m_flags.insert(flag); #ifndef NDEBUG - assert(result.second); + assert(result.second); #endif - if (permanent) - m_permanent.insert(flag); - m_strings[flag] = name; - } + if (permanent) + m_permanent.insert(flag); + m_strings[flag] = name; + } /** Removes \a flag from the FlagSpec, returning whether the flag was actually removed or not. Permanent flags are not removed. The removal of flags will probably only be necessary in cases where flags were added for classes in a runtime-loaded DLL/shared library at DLL/shared library unload-time. */ bool erase(FlagType flag) - { - bool retval = true; - if (permanent(flag)) { - retval = false; - } else { - m_flags.erase(flag); - m_permanent.erase(flag); - m_strings.erase(flag); - } - return retval; + { + bool retval = true; + if (permanent(flag)) { + retval = false; + } else { + m_flags.erase(flag); + m_permanent.erase(flag); + m_strings.erase(flag); } + return retval; + } //@} private: @@ -328,22 +328,19 @@ //@} /** \name Mutators */ ///@{ - /** Performs a bitwise-or of *this and \a rhs, placing the result in - *this. */ + /** Performs a bitwise-or of *this and \a rhs, placing the result in *this. */ Flags<FlagType>& operator|=(Flags<FlagType> rhs) { m_flags |= rhs.m_flags; return *this; } - /** Performs a bitwise-and of *this and \a rhs, placing the result in - *this. */ + /** Performs a bitwise-and of *this and \a rhs, placing the result in *this. */ Flags<FlagType>& operator&=(Flags<FlagType> rhs) { m_flags &= rhs.m_flags; return *this; } - /** Performs a bitwise-xor of *this and \a rhs, placing the result in - *this. */ + /** Performs a bitwise-xor of *this and \a rhs, placing the result in *this. */ Flags<FlagType>& operator^=(Flags<FlagType> rhs) { m_flags ^= rhs.m_flags; Modified: trunk/FreeOrion/GG/GG/GroupBox.h =================================================================== --- trunk/FreeOrion/GG/GG/GroupBox.h 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/GG/GroupBox.h 2014-04-18 20:35:46 UTC (rev 7077) @@ -45,7 +45,7 @@ /** \name Structors */ ///@{ /** Ctor. Height is determined from the font and point size used. */ GroupBox(X x, Y y, X w, Y h, const std::string& label, const boost::shared_ptr<Font>& font, Clr color, - Clr text_color = CLR_BLACK, Clr interior = CLR_ZERO, Flags<WndFlag> flags = Flags<WndFlag>()); + Clr text_color = CLR_BLACK, Clr interior = CLR_ZERO, Flags<WndFlag> flags = NO_WND_FLAGS); //@} /** \name Accessors */ ///@{ Modified: trunk/FreeOrion/GG/GG/StaticGraphic.h =================================================================== --- trunk/FreeOrion/GG/GG/StaticGraphic.h 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/GG/StaticGraphic.h 2014-04-18 20:35:46 UTC (rev 7077) @@ -60,10 +60,10 @@ /** \name Structors */ ///@{ ///< creates a StaticGraphic from a pre-existing Texture. StaticGraphic(X x, Y y, X w, Y h, const boost::shared_ptr<Texture>& texture, - Flags<GraphicStyle> style = GRAPHIC_NONE, Flags<WndFlag> flags = Flags<WndFlag>()); + Flags<GraphicStyle> style = GRAPHIC_NONE, Flags<WndFlag> flags = NO_WND_FLAGS); ///< creates a StaticGraphic from a pre-existing SubTexture. StaticGraphic(X x, Y y, X w, Y h, const SubTexture& subtexture, - Flags<GraphicStyle> style = GRAPHIC_NONE, Flags<WndFlag> flags = Flags<WndFlag>()); + Flags<GraphicStyle> style = GRAPHIC_NONE, Flags<WndFlag> flags = NO_WND_FLAGS); //@} /** \name Accessors */ ///@{ Modified: trunk/FreeOrion/GG/GG/StyleFactory.h =================================================================== --- trunk/FreeOrion/GG/GG/StyleFactory.h 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/GG/StyleFactory.h 2014-04-18 20:35:46 UTC (rev 7077) @@ -119,7 +119,7 @@ virtual DynamicGraphic* NewDynamicGraphic(X x, Y y, X w, Y h, bool loop, X frame_width, Y frame_height, int margin, const std::vector<boost::shared_ptr<Texture> >& textures, Flags<GraphicStyle> style = GRAPHIC_NONE, int frames = DynamicGraphic::ALL_FRAMES, - Flags<WndFlag> flags = Flags<WndFlag>()) const; + Flags<WndFlag> flags = NO_WND_FLAGS) const; /** Returns a new GG Edit. */ virtual Edit* NewEdit(X x, Y y, X w, const std::string& str, const boost::shared_ptr<Font>& font, @@ -167,7 +167,7 @@ /** Returns a new GG StaticGraphic. */ virtual StaticGraphic* NewStaticGraphic(X x, Y y, X w, Y h, const boost::shared_ptr<Texture>& texture, - Flags<GraphicStyle> style = GRAPHIC_NONE, Flags<WndFlag> flags = Flags<WndFlag>()) const; + Flags<GraphicStyle> style = GRAPHIC_NONE, Flags<WndFlag> flags = NO_WND_FLAGS) const; /** Returns a new GG TabBar. */ virtual TabBar* NewTabBar(X x, Y y, X w, const boost::shared_ptr<Font>& font, Clr color, @@ -177,17 +177,17 @@ /** Returns a new GG TextControl. */ virtual TextControl* NewTextControl(X x, Y y, X w, Y h, const std::string& str, const boost::shared_ptr<Font>& font, Clr color = CLR_BLACK, - Flags<TextFormat> format = FORMAT_NONE, Flags<WndFlag> flags = Flags<WndFlag>()) const; + Flags<TextFormat> format = FORMAT_NONE, Flags<WndFlag> flags = NO_WND_FLAGS) const; /** Returns a new GG TextControl whose size is exactly that required to hold its text. */ virtual TextControl* NewTextControl(X x, Y y, const std::string& str, const boost::shared_ptr<Font>& font, Clr color = CLR_BLACK, Flags<TextFormat> format = FORMAT_NONE, - Flags<WndFlag> flags = Flags<WndFlag>()) const; + Flags<WndFlag> flags = NO_WND_FLAGS) const; /** Returns a new GG GroupBox. */ virtual GroupBox* NewGroupBox(X x, Y y, X w, Y h, const std::string& label, const boost::shared_ptr<Font>& font, Clr color, Clr text_color = CLR_BLACK, Clr interior = CLR_ZERO, - Flags<WndFlag> flags = Flags<WndFlag>()) const; + Flags<WndFlag> flags = NO_WND_FLAGS) const; //@} /** \name Subcontrols */ ///@{ Modified: trunk/FreeOrion/GG/GG/TabWnd.h =================================================================== --- trunk/FreeOrion/GG/GG/TabWnd.h 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/GG/TabWnd.h 2014-04-18 20:35:46 UTC (rev 7077) @@ -51,7 +51,7 @@ /** \name Structors */ ///@{ /** Basic ctor. */ - OverlayWnd(X x, Y y, X w, Y h, Flags<WndFlag> flags = Flags<WndFlag>()); + OverlayWnd(X x, Y y, X w, Y h, Flags<WndFlag> flags = NO_WND_FLAGS); ~OverlayWnd(); //@} Modified: trunk/FreeOrion/GG/GG/TextControl.h =================================================================== --- trunk/FreeOrion/GG/GG/TextControl.h 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/GG/TextControl.h 2014-04-18 20:35:46 UTC (rev 7077) @@ -71,7 +71,7 @@ /** Ctor. */ TextControl(X x, Y y, X w, Y h, const std::string& str, const boost::shared_ptr<Font>& font, Clr color = CLR_BLACK, Flags<TextFormat> format = FORMAT_NONE, - Flags<WndFlag> flags = Flags<WndFlag>()); + Flags<WndFlag> flags = NO_WND_FLAGS); /** Ctor that does not require window size. Window size is determined from the string and font; the window will be large enough to fit the @@ -79,7 +79,7 @@ also return true. \see TextControl::SetText() */ TextControl(X x, Y y, const std::string& str, const boost::shared_ptr<Font>& font, Clr color = CLR_BLACK, Flags<TextFormat> format = FORMAT_NONE, - Flags<WndFlag> flags = Flags<WndFlag>()); + Flags<WndFlag> flags = NO_WND_FLAGS); //@} /** \name Accessors */ ///@{ Modified: trunk/FreeOrion/GG/GG/Wnd.h =================================================================== --- trunk/FreeOrion/GG/GG/Wnd.h 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/GG/Wnd.h 2014-04-18 20:35:46 UTC (rev 7077) @@ -78,7 +78,10 @@ expects to receive KeyPress messages. */ extern GG_API const WndFlag REPEAT_KEY_PRESS; +/** None of the above flags */ +extern GG_API const WndFlag NO_WND_FLAGS; + /** \brief This is the basic GG window class. <h3>Window Geometry</h3> Modified: trunk/FreeOrion/GG/src/AlignmentFlags.cpp =================================================================== --- trunk/FreeOrion/GG/src/AlignmentFlags.cpp 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/src/AlignmentFlags.cpp 2014-04-18 20:35:46 UTC (rev 7077) @@ -45,13 +45,13 @@ bool RegisterAlignments() { FlagSpec<Alignment>& spec = FlagSpec<Alignment>::instance(); - spec.insert(ALIGN_NONE, "ALIGN_NONE", true); - spec.insert(ALIGN_VCENTER, "ALIGN_VCENTER", true); - spec.insert(ALIGN_TOP, "ALIGN_TOP", true); - spec.insert(ALIGN_BOTTOM, "ALIGN_BOTTOM", true); - spec.insert(ALIGN_CENTER, "ALIGN_CENTER", true); - spec.insert(ALIGN_LEFT, "ALIGN_LEFT", true); - spec.insert(ALIGN_RIGHT, "ALIGN_RIGHT", true); + spec.insert(ALIGN_NONE, "ALIGN_NONE", true); + spec.insert(ALIGN_VCENTER, "ALIGN_VCENTER",true); + spec.insert(ALIGN_TOP, "ALIGN_TOP", true); + spec.insert(ALIGN_BOTTOM, "ALIGN_BOTTOM", true); + spec.insert(ALIGN_CENTER, "ALIGN_CENTER", true); + spec.insert(ALIGN_LEFT, "ALIGN_LEFT", true); + spec.insert(ALIGN_RIGHT, "ALIGN_RIGHT", true); return true; } bool dummy = RegisterAlignments(); Modified: trunk/FreeOrion/GG/src/Font.cpp =================================================================== --- trunk/FreeOrion/GG/src/Font.cpp 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/src/Font.cpp 2014-04-18 20:35:46 UTC (rev 7077) @@ -237,16 +237,16 @@ bool RegisterTextFormats() { FlagSpec<TextFormat>& spec = FlagSpec<TextFormat>::instance(); - spec.insert(FORMAT_NONE, "FORMAT_NONE", true); - spec.insert(FORMAT_VCENTER, "FORMAT_VCENTER", true); - spec.insert(FORMAT_TOP, "FORMAT_TOP", true); - spec.insert(FORMAT_BOTTOM, "FORMAT_BOTTOM", true); - spec.insert(FORMAT_CENTER, "FORMAT_CENTER", true); - spec.insert(FORMAT_LEFT, "FORMAT_LEFT", true); - spec.insert(FORMAT_RIGHT, "FORMAT_RIGHT", true); - spec.insert(FORMAT_WORDBREAK, "FORMAT_WORDBREAK", true); - spec.insert(FORMAT_LINEWRAP, "FORMAT_LINEWRAP", true); - spec.insert(FORMAT_IGNORETAGS, "FORMAT_IGNORETAGS", true); + spec.insert(FORMAT_NONE, "FORMAT_NONE", true); + spec.insert(FORMAT_VCENTER, "FORMAT_VCENTER", true); + spec.insert(FORMAT_TOP, "FORMAT_TOP", true); + spec.insert(FORMAT_BOTTOM, "FORMAT_BOTTOM", true); + spec.insert(FORMAT_CENTER, "FORMAT_CENTER", true); + spec.insert(FORMAT_LEFT, "FORMAT_LEFT", true); + spec.insert(FORMAT_RIGHT, "FORMAT_RIGHT", true); + spec.insert(FORMAT_WORDBREAK, "FORMAT_WORDBREAK", true); + spec.insert(FORMAT_LINEWRAP, "FORMAT_LINEWRAP", true); + spec.insert(FORMAT_IGNORETAGS, "FORMAT_IGNORETAGS",true); return true; } bool dummy = RegisterTextFormats(); Modified: trunk/FreeOrion/GG/src/GroupBox.cpp =================================================================== --- trunk/FreeOrion/GG/src/GroupBox.cpp 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/src/GroupBox.cpp 2014-04-18 20:35:46 UTC (rev 7077) @@ -51,7 +51,7 @@ GroupBox::GroupBox(X x, Y y, X w, Y h, const std::string& label, const boost::shared_ptr<Font>& font, Clr color, Clr text_color/* = CLR_BLACK*/, Clr interior/* = CLR_ZERO*/, - Flags<WndFlag> flags/* = Flags<WndFlag>()*/) : + Flags<WndFlag> flags/* = NO_WND_FLAGS*/) : m_color(color), m_text_color(text_color), m_int_color(interior), Modified: trunk/FreeOrion/GG/src/Layout.cpp =================================================================== --- trunk/FreeOrion/GG/src/Layout.cpp 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/src/Layout.cpp 2014-04-18 20:35:46 UTC (rev 7077) @@ -89,7 +89,7 @@ Layout::Layout(X x, Y y, X w, Y h, std::size_t rows, std::size_t columns, unsigned int border_margin/* = 0*/, unsigned int cell_margin/* = INVALID_CELL_MARGIN*/) : - Wnd(x, y, w, h, Flags<WndFlag>()), + Wnd(x, y, w, h, NO_WND_FLAGS), m_cells(rows, std::vector<Wnd*>(columns)), m_border_margin(border_margin), m_cell_margin(cell_margin == INVALID_CELL_MARGIN ? border_margin : cell_margin), Modified: trunk/FreeOrion/GG/src/MultiEdit.cpp =================================================================== --- trunk/FreeOrion/GG/src/MultiEdit.cpp 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/src/MultiEdit.cpp 2014-04-18 20:35:46 UTC (rev 7077) @@ -72,20 +72,20 @@ bool RegisterMultiEditStyles() { FlagSpec<MultiEditStyle>& spec = FlagSpec<MultiEditStyle>::instance(); - spec.insert(MULTI_NONE, "MULTI_NONE", true); - spec.insert(MULTI_WORDBREAK, "MULTI_WORDBREAK", true); - spec.insert(MULTI_LINEWRAP, "MULTI_LINEWRAP", true); - spec.insert(MULTI_VCENTER, "MULTI_VCENTER", true); - spec.insert(MULTI_TOP, "MULTI_TOP", true); - spec.insert(MULTI_BOTTOM, "MULTI_BOTTOM", true); - spec.insert(MULTI_CENTER, "MULTI_CENTER", true); - spec.insert(MULTI_LEFT, "MULTI_LEFT", true); - spec.insert(MULTI_RIGHT, "MULTI_RIGHT", true); - spec.insert(MULTI_READ_ONLY, "MULTI_READ_ONLY", true); - spec.insert(MULTI_TERMINAL_STYLE, "MULTI_TERMINAL_STYLE", true); - spec.insert(MULTI_INTEGRAL_HEIGHT, "MULTI_INTEGRAL_HEIGHT", true); - spec.insert(MULTI_NO_VSCROLL, "MULTI_NO_VSCROLL", true); - spec.insert(MULTI_NO_HSCROLL, "MULTI_NO_HSCROLL", true); + spec.insert(MULTI_NONE, "MULTI_NONE", true); + spec.insert(MULTI_WORDBREAK, "MULTI_WORDBREAK", true); + spec.insert(MULTI_LINEWRAP, "MULTI_LINEWRAP", true); + spec.insert(MULTI_VCENTER, "MULTI_VCENTER", true); + spec.insert(MULTI_TOP, "MULTI_TOP", true); + spec.insert(MULTI_BOTTOM, "MULTI_BOTTOM", true); + spec.insert(MULTI_CENTER, "MULTI_CENTER", true); + spec.insert(MULTI_LEFT, "MULTI_LEFT", true); + spec.insert(MULTI_RIGHT, "MULTI_RIGHT", true); + spec.insert(MULTI_READ_ONLY, "MULTI_READ_ONLY", true); + spec.insert(MULTI_TERMINAL_STYLE, "MULTI_TERMINAL_STYLE", true); + spec.insert(MULTI_INTEGRAL_HEIGHT, "MULTI_INTEGRAL_HEIGHT",true); + spec.insert(MULTI_NO_VSCROLL, "MULTI_NO_VSCROLL", true); + spec.insert(MULTI_NO_HSCROLL, "MULTI_NO_HSCROLL", true); return true; } bool dummy = RegisterMultiEditStyles(); Modified: trunk/FreeOrion/GG/src/StaticGraphic.cpp =================================================================== --- trunk/FreeOrion/GG/src/StaticGraphic.cpp 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/src/StaticGraphic.cpp 2014-04-18 20:35:46 UTC (rev 7077) @@ -52,16 +52,16 @@ bool RegisterGraphicStyles() { FlagSpec<GraphicStyle>& spec = FlagSpec<GraphicStyle>::instance(); - spec.insert(GRAPHIC_NONE, "GRAPHIC_NONE", true); - spec.insert(GRAPHIC_VCENTER, "GRAPHIC_VCENTER", true); - spec.insert(GRAPHIC_TOP, "GRAPHIC_TOP", true); - spec.insert(GRAPHIC_BOTTOM, "GRAPHIC_BOTTOM", true); - spec.insert(GRAPHIC_CENTER, "GRAPHIC_CENTER", true); - spec.insert(GRAPHIC_LEFT, "GRAPHIC_LEFT", true); - spec.insert(GRAPHIC_RIGHT, "GRAPHIC_RIGHT", true); - spec.insert(GRAPHIC_FITGRAPHIC, "GRAPHIC_FITGRAPHIC", true); - spec.insert(GRAPHIC_SHRINKFIT, "GRAPHIC_SHRINKFIT", true); - spec.insert(GRAPHIC_PROPSCALE, "GRAPHIC_PROPSCALE", true); + spec.insert(GRAPHIC_NONE, "GRAPHIC_NONE", true); + spec.insert(GRAPHIC_VCENTER, "GRAPHIC_VCENTER", true); + spec.insert(GRAPHIC_TOP, "GRAPHIC_TOP", true); + spec.insert(GRAPHIC_BOTTOM, "GRAPHIC_BOTTOM", true); + spec.insert(GRAPHIC_CENTER, "GRAPHIC_CENTER", true); + spec.insert(GRAPHIC_LEFT, "GRAPHIC_LEFT", true); + spec.insert(GRAPHIC_RIGHT, "GRAPHIC_RIGHT", true); + spec.insert(GRAPHIC_FITGRAPHIC, "GRAPHIC_FITGRAPHIC", true); + spec.insert(GRAPHIC_SHRINKFIT, "GRAPHIC_SHRINKFIT", true); + spec.insert(GRAPHIC_PROPSCALE, "GRAPHIC_PROPSCALE", true); return true; } bool dummy = RegisterGraphicStyles(); Modified: trunk/FreeOrion/GG/src/StyleFactory.cpp =================================================================== --- trunk/FreeOrion/GG/src/StyleFactory.cpp 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/src/StyleFactory.cpp 2014-04-18 20:35:46 UTC (rev 7077) @@ -97,7 +97,7 @@ DynamicGraphic* StyleFactory::NewDynamicGraphic(X x, Y y, X w, Y h, bool loop, X frame_width, Y frame_height, int margin, const std::vector<boost::shared_ptr<Texture> >& textures, Flags<GraphicStyle> style/* = GRAPHIC_NONE*/, - int frames/* = DynamicGraphic::ALL_FRAMES*/, Flags<WndFlag> flags/* = Flags<WndFlag>()*/) const + int frames/* = DynamicGraphic::ALL_FRAMES*/, Flags<WndFlag> flags/* = NO_WND_FLAGS*/) const { return new DynamicGraphic(x, y, w, h, loop, frame_width, frame_height, margin, textures, style, frames, flags); } Edit* StyleFactory::NewEdit(X x, Y y, X w, const std::string& str, const boost::shared_ptr<Font>& font, @@ -143,21 +143,21 @@ { return new Spin<double>(x, y, w, value, step, min, max, edits, font, color, text_color, interior, flags); } StaticGraphic* StyleFactory::NewStaticGraphic(X x, Y y, X w, Y h, const boost::shared_ptr<Texture>& texture, - Flags<GraphicStyle> style/* = GRAPHIC_NONE*/, Flags<WndFlag> flags/* = Flags<WndFlag>()*/) const + Flags<GraphicStyle> style/* = GRAPHIC_NONE*/, Flags<WndFlag> flags/* = NO_WND_FLAGS*/) const { return new StaticGraphic(x, y, w, h, texture, style, flags); } TextControl* StyleFactory::NewTextControl(X x, Y y, X w, Y h, const std::string& str, const boost::shared_ptr<Font>& font, Clr color/* = CLR_BLACK*/, - Flags<TextFormat> format/* = FORMAT_NONE*/, Flags<WndFlag> flags/* = Flags<WndFlag>()*/) const + Flags<TextFormat> format/* = FORMAT_NONE*/, Flags<WndFlag> flags/* = NO_WND_FLAGS*/) const { return new TextControl(x, y, w, h, str, font, color, format, flags); } TextControl* StyleFactory::NewTextControl(X x, Y y, const std::string& str, const boost::shared_ptr<Font>& font, - Clr color/* = CLR_BLACK*/, Flags<TextFormat> format/* = FORMAT_NONE*/, Flags<WndFlag> flags/* = Flags<WndFlag>()*/) const + Clr color/* = CLR_BLACK*/, Flags<TextFormat> format/* = FORMAT_NONE*/, Flags<WndFlag> flags/* = NO_WND_FLAGS*/) const { return new TextControl(x, y, str, font, color, format, flags); } GroupBox* StyleFactory::NewGroupBox(X x, Y y, X w, Y h, const std::string& label, const boost::shared_ptr<Font>& font, Clr color, Clr text_color/* = CLR_BLACK*/, Clr interior/* = CLR_ZERO*/, - Flags<WndFlag> flags/* = Flags<WndFlag>()*/) const + Flags<WndFlag> flags/* = NO_WND_FLAGS*/) const { return new GroupBox(x, y, w, h, label, font, color, text_color, interior, flags); } TabBar* StyleFactory::NewTabBar(X x, Y y, X w, const boost::shared_ptr<Font>& font, Clr color, Clr text_color/* = CLR_BLACK*/, Modified: trunk/FreeOrion/GG/src/TextControl.cpp =================================================================== --- trunk/FreeOrion/GG/src/TextControl.cpp 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/src/TextControl.cpp 2014-04-18 20:35:46 UTC (rev 7077) @@ -49,7 +49,7 @@ {} TextControl::TextControl(X x, Y y, X w, Y h, const std::string& str, const boost::shared_ptr<Font>& font, Clr color/* = CLR_BLACK*/, - Flags<TextFormat> format/* = FORMAT_NONE*/, Flags<WndFlag> flags/* = Flags<WndFlag>()*/) : + Flags<TextFormat> format/* = FORMAT_NONE*/, Flags<WndFlag> flags/* = NO_WND_FLAGS*/) : Control(x, y, w, h, flags), m_format(format), m_text_color(color), @@ -64,7 +64,7 @@ } TextControl::TextControl(X x, Y y, const std::string& str, const boost::shared_ptr<Font>& font, Clr color/* = CLR_BLACK*/, - Flags<TextFormat> format/* = FORMAT_NONE*/, Flags<WndFlag> flags/* = Flags<WndFlag>()*/) : + Flags<TextFormat> format/* = FORMAT_NONE*/, Flags<WndFlag> flags/* = NO_WND_FLAGS*/) : Control(x, y, X0, Y0, flags), m_format(format), m_text_color(color), Modified: trunk/FreeOrion/GG/src/Wnd.cpp =================================================================== --- trunk/FreeOrion/GG/src/Wnd.cpp 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/src/Wnd.cpp 2014-04-18 20:35:46 UTC (rev 7077) @@ -137,6 +137,7 @@ /////////////////////////////////////// // WndFlags /////////////////////////////////////// +const WndFlag GG::NO_WND_FLAGS (0); const WndFlag GG::INTERACTIVE (1 << 0); const WndFlag GG::REPEAT_BUTTON_DOWN (1 << 1); const WndFlag GG::DRAGABLE (1 << 2); @@ -151,13 +152,14 @@ bool RegisterWndFlags() { FlagSpec<WndFlag>& spec = FlagSpec<WndFlag>::instance(); - spec.insert(INTERACTIVE, "INTERACTIVE", true); - spec.insert(REPEAT_BUTTON_DOWN, "REPEAT_BUTTON_DOWN", true); - spec.insert(DRAGABLE, "DRAGABLE", true); - spec.insert(RESIZABLE, "RESIZABLE", true); - spec.insert(ONTOP, "ONTOP", true); - spec.insert(MODAL, "MODAL", true); - spec.insert(REPEAT_KEY_PRESS, "REPEAT_KEY_PRESS", true); + spec.insert(NO_WND_FLAGS, "NO_WND_FLAGS", true); + spec.insert(INTERACTIVE, "INTERACTIVE", true); + spec.insert(REPEAT_BUTTON_DOWN, "REPEAT_BUTTON_DOWN", true); + spec.insert(DRAGABLE, "DRAGABLE", true); + spec.insert(RESIZABLE, "RESIZABLE", true); + spec.insert(ONTOP, "ONTOP", true); + spec.insert(MODAL, "MODAL", true); + spec.insert(REPEAT_KEY_PRESS, "REPEAT_KEY_PRESS", true); return true; } bool dummy = RegisterWndFlags(); Modified: trunk/FreeOrion/GG/src/dialogs/ColorDlg.cpp =================================================================== --- trunk/FreeOrion/GG/src/dialogs/ColorDlg.cpp 2014-04-18 13:50:11 UTC (rev 7076) +++ trunk/FreeOrion/GG/src/dialogs/ColorDlg.cpp 2014-04-18 20:35:46 UTC (rev 7077) @@ -361,7 +361,7 @@ {} ColorDlg::ColorDisplay::ColorDisplay(Clr color) : - Control(X0, Y0, X1, Y1, Flags<WndFlag>()) + Control(X0, Y0, X1, Y1, NO_WND_FLAGS) { SetColor(color); } void ColorDlg::ColorDisplay::Render() |
From: <geo...@us...> - 2014-04-27 11:29:10
|
Revision: 7101 http://sourceforge.net/p/freeorion/code/7101 Author: geoffthemedio Date: 2014-04-27 11:29:06 +0000 (Sun, 27 Apr 2014) Log Message: ----------- -SetText safety checks -grooming Modified Paths: -------------- trunk/FreeOrion/GG/GG/Edit.h trunk/FreeOrion/GG/src/Edit.cpp trunk/FreeOrion/GG/src/MultiEdit.cpp trunk/FreeOrion/GG/src/TextControl.cpp Modified: trunk/FreeOrion/GG/GG/Edit.h =================================================================== --- trunk/FreeOrion/GG/GG/Edit.h 2014-04-27 11:20:37 UTC (rev 7100) +++ trunk/FreeOrion/GG/GG/Edit.h 2014-04-27 11:29:06 UTC (rev 7101) @@ -206,7 +206,7 @@ (its .first and .second members will be equal). This function should be called in LDrag() overrides when InDoubleButtonDownMode() is true. */ - std::pair<CPSize, CPSize> GetDoubleButtonDownDragWordIndices(CPSize char_index); + virtual std::pair<CPSize, CPSize> GetDoubleButtonDownDragWordIndices(CPSize char_index); /** Sets the value of InDoubleButtonDownMode() to false. This should be called in LClick() and LButtonUp() overrides. */ Modified: trunk/FreeOrion/GG/src/Edit.cpp =================================================================== --- trunk/FreeOrion/GG/src/Edit.cpp 2014-04-27 11:20:37 UTC (rev 7100) +++ trunk/FreeOrion/GG/src/Edit.cpp 2014-04-27 11:29:06 UTC (rev 7101) @@ -225,7 +225,7 @@ m_cursor_pos.second = m_cursor_pos.first; // eliminate any hiliting // make sure the change in text did not make the cursor or view position invalid - if (str.empty() || GetLineData().empty() || GetLineData()[0].char_data.size() < m_cursor_pos.first) { + if (Text().empty() || GetLineData().empty() || GetLineData()[0].char_data.size() < m_cursor_pos.first) { m_first_char_shown = CP0; m_cursor_pos = std::make_pair(CP0, CP0); } @@ -237,6 +237,8 @@ { if (!Interactive()) return; + if (!utf8::is_valid(text.begin(), text.end())) + return; bool emit_signal = false; @@ -502,25 +504,22 @@ if (ticks - m_last_button_down_time <= GUI::GetGUI()->DoubleClickInterval()) m_in_double_click_mode = true; m_last_button_down_time = ticks; - m_double_click_cursor_pos = std::pair<CPSize, CPSize>(CP0, CP0); - if (m_in_double_click_mode) { - std::set<std::pair<CPSize, CPSize> > words = - GUI::GetGUI()->FindWords(Text()); - std::set<std::pair<CPSize, CPSize> >::const_iterator it = - std::find_if(words.begin(), words.end(), InRange(char_index)); - if (it != words.end()) - m_double_click_cursor_pos = *it; - } + + m_double_click_cursor_pos = std::pair<CPSize, CPSize>(char_index, char_index); + if (m_in_double_click_mode) + m_double_click_cursor_pos = GetDoubleButtonDownDragWordIndices(char_index); + return m_double_click_cursor_pos; } std::pair<CPSize, CPSize> Edit::GetDoubleButtonDownDragWordIndices(CPSize char_index) { - std::pair<CPSize, CPSize> retval(CP0, CP0); - std::set<std::pair<CPSize, CPSize> > words = - GUI::GetGUI()->FindWords(Text()); + std::pair<CPSize, CPSize> retval(char_index, char_index); + + std::set<std::pair<CPSize, CPSize> > words = GUI::GetGUI()->FindWords(Text()); std::set<std::pair<CPSize, CPSize> >::const_iterator it = std::find_if(words.begin(), words.end(), InRange(char_index)); + if (it != words.end()) retval = *it; return retval; Modified: trunk/FreeOrion/GG/src/MultiEdit.cpp =================================================================== --- trunk/FreeOrion/GG/src/MultiEdit.cpp 2014-04-27 11:20:37 UTC (rev 7100) +++ trunk/FreeOrion/GG/src/MultiEdit.cpp 2014-04-27 11:29:06 UTC (rev 7101) @@ -292,6 +292,9 @@ void MultiEdit::SetText(const std::string& str) { + if (!utf8::is_valid(str.begin(), str.end())) + return; + if (m_preserve_text_position_on_next_set_text) { TextControl::SetText(str); } else { Modified: trunk/FreeOrion/GG/src/TextControl.cpp =================================================================== --- trunk/FreeOrion/GG/src/TextControl.cpp 2014-04-27 11:20:37 UTC (rev 7100) +++ trunk/FreeOrion/GG/src/TextControl.cpp 2014-04-27 11:29:06 UTC (rev 7101) @@ -138,20 +138,24 @@ void TextControl::SetText(const std::string& str) { + if (!utf8::is_valid(str.begin(), str.end())) + return; m_text = str; - if (m_font) { - m_code_points = CPSize(utf8::distance(str.begin(), str.end())); - m_text_elements.clear(); - Pt text_sz = - m_font->DetermineLines(m_text, m_format, ClientSize().x, m_line_data, m_text_elements); - m_text_ul = Pt(); - m_text_lr = text_sz; - AdjustMinimumSize(); - if (m_fit_to_text) { - Resize(text_sz); - } else { - RecomputeTextBounds(); - } + + if (!m_font) + return; + + m_code_points = CPSize(utf8::distance(str.begin(), str.end())); + m_text_elements.clear(); + Pt text_sz = + m_font->DetermineLines(m_text, m_format, ClientSize().x, m_line_data, m_text_elements); + m_text_ul = Pt(); + m_text_lr = text_sz; + AdjustMinimumSize(); + if (m_fit_to_text) { + Resize(text_sz); + } else { + RecomputeTextBounds(); } } @@ -245,13 +249,15 @@ void TextControl::Insert(std::size_t line, CPSize pos, char c) { if (!detail::ValidUTFChar<char>()(c)) - throw utf8::invalid_utf8(c); + return; m_text.insert(Value(StringIndexOf(line, pos, m_line_data)), 1, c); SetText(m_text); } void TextControl::Insert(std::size_t line, CPSize pos, const std::string& s) { + if (!utf8::is_valid(s.begin(), s.end())) + return; m_text.insert(Value(StringIndexOf(line, pos, m_line_data)), s); SetText(m_text); } |
From: <mar...@us...> - 2014-08-11 08:20:22
|
Revision: 7429 http://sourceforge.net/p/freeorion/code/7429 Author: marcel_metz Date: 2014-08-11 08:20:13 +0000 (Mon, 11 Aug 2014) Log Message: ----------- Removed unused GG::ListBox and DropDownList reverse iterator interface. Modified Paths: -------------- trunk/FreeOrion/GG/GG/DropDownList.h trunk/FreeOrion/GG/GG/ListBox.h trunk/FreeOrion/GG/src/DropDownList.cpp trunk/FreeOrion/GG/src/ListBox.cpp Modified: trunk/FreeOrion/GG/GG/DropDownList.h =================================================================== --- trunk/FreeOrion/GG/GG/DropDownList.h 2014-08-11 05:11:21 UTC (rev 7428) +++ trunk/FreeOrion/GG/GG/DropDownList.h 2014-08-11 08:20:13 UTC (rev 7429) @@ -58,8 +58,6 @@ typedef ListBox::iterator iterator; typedef ListBox::const_iterator const_iterator; - typedef ListBox::reverse_iterator reverse_iterator; - typedef ListBox::const_reverse_iterator const_reverse_iterator; /** \name Signal Types */ ///@{ /** emitted when a new item is selected; will be end() when no item is @@ -85,8 +83,6 @@ const_iterator begin() const; ///< returns an iterator to the first list row const_iterator end() const; ///< returns an iterator to the imaginary row one past the last - const_reverse_iterator rbegin() const; ///< returns an iterator to the last list row - const_reverse_iterator rend() const; ///< returns an iterator to the imaginary row one past the first const Row& GetRow(std::size_t n) const; ///< returns a const reference to the row at index \a n; not range-checked. \note This function is O(n). bool Selected(iterator it) const; ///< returns true if row \a it is selected @@ -149,8 +145,6 @@ iterator begin(); ///< returns an iterator to the first list row iterator end(); ///< returns an iterator to the imaginary row one past the last one - reverse_iterator rbegin(); ///< returns an iterator to the last list row - reverse_iterator rend(); ///< returns an iterator to the imaginary row one past the first Row& GetRow(std::size_t n); ///< returns a reference to the Row at row index \a n; not range-checked. \note This function is O(n). Modified: trunk/FreeOrion/GG/GG/ListBox.h =================================================================== --- trunk/FreeOrion/GG/GG/ListBox.h 2014-08-11 05:11:21 UTC (rev 7428) +++ trunk/FreeOrion/GG/GG/ListBox.h 2014-08-11 08:20:13 UTC (rev 7429) @@ -220,8 +220,6 @@ typedef std::list<Row*>::iterator iterator; typedef std::list<Row*>::const_iterator const_iterator; - typedef std::list<Row*>::reverse_iterator reverse_iterator; - typedef std::list<Row*>::const_reverse_iterator const_reverse_iterator; typedef std::set<iterator, RowPtrIteratorLess<std::list<Row*> > > SelectionSet; @@ -268,8 +266,6 @@ bool Empty() const; ///< returns true when the ListBox is empty const_iterator begin() const; ///< returns an iterator to the first list row const_iterator end() const; ///< returns an iterator to the imaginary row one past the last - const_reverse_iterator rbegin() const; ///< returns an iterator to the last list row - const_reverse_iterator rend() const; ///< returns an iterator to the imaginary row one past the first one const Row& GetRow(std::size_t n) const; ///< returns a const reference to the row at index \a n; not range-checked. \note This function is O(n). iterator Caret() const; ///< returns the row that has the caret const SelectionSet& Selections() const; ///< returns a const reference to the set row indexes that is currently selected @@ -375,8 +371,6 @@ iterator begin(); ///< returns an iterator to the first list row iterator end(); ///< returns an iterator to the imaginary row one past the last one - reverse_iterator rbegin(); ///< returns an iterator to the last list row - reverse_iterator rend(); ///< returns an iterator to the imaginary row one past the first one Row& GetRow(std::size_t n); ///< returns a reference to the Row at row index \a n; not range-checked. \note This function is O(n). Modified: trunk/FreeOrion/GG/src/DropDownList.cpp =================================================================== --- trunk/FreeOrion/GG/src/DropDownList.cpp 2014-08-11 05:11:21 UTC (rev 7428) +++ trunk/FreeOrion/GG/src/DropDownList.cpp 2014-08-11 08:20:13 UTC (rev 7429) @@ -196,12 +196,6 @@ DropDownList::const_iterator DropDownList::end() const { return LB()->end(); } -DropDownList::const_reverse_iterator DropDownList::rbegin() const -{ return LB()->rbegin(); } - -DropDownList::const_reverse_iterator DropDownList::rend() const -{ return LB()->rend(); } - const DropDownList::Row& DropDownList::GetRow(std::size_t n) const { return LB()->GetRow(n); } @@ -323,12 +317,6 @@ DropDownList::iterator DropDownList::end() { return LB()->end(); } -DropDownList::reverse_iterator DropDownList::rbegin() -{ return LB()->rbegin(); } - -DropDownList::reverse_iterator DropDownList::rend() -{ return LB()->rend(); } - DropDownList::Row& DropDownList::GetRow(std::size_t n) { return LB()->GetRow(n); } Modified: trunk/FreeOrion/GG/src/ListBox.cpp =================================================================== --- trunk/FreeOrion/GG/src/ListBox.cpp 2014-08-11 05:11:21 UTC (rev 7428) +++ trunk/FreeOrion/GG/src/ListBox.cpp 2014-08-11 08:20:13 UTC (rev 7429) @@ -557,12 +557,6 @@ ListBox::const_iterator ListBox::end() const { return m_rows.end(); } -ListBox::const_reverse_iterator ListBox::rbegin() const -{ return m_rows.rbegin(); } - -ListBox::const_reverse_iterator ListBox::rend() const -{ return m_rows.rend(); } - const ListBox::Row& ListBox::GetRow(std::size_t n) const { assert(n < m_rows.size()); @@ -954,12 +948,6 @@ ListBox::iterator ListBox::end() { return m_rows.end(); } -ListBox::reverse_iterator ListBox::rbegin() -{ return m_rows.rbegin(); } - -ListBox::reverse_iterator ListBox::rend() -{ return m_rows.rend(); } - ListBox::Row& ListBox::GetRow(std::size_t n) { assert(n < m_rows.size()); |
From: <mar...@us...> - 2014-08-13 06:46:52
|
Revision: 7436 http://sourceforge.net/p/freeorion/code/7436 Author: marcel_metz Date: 2014-08-13 06:46:49 +0000 (Wed, 13 Aug 2014) Log Message: ----------- Simplified GG::ListBox::RowPtrIteratorLess comparator. Modified Paths: -------------- trunk/FreeOrion/GG/GG/ListBox.h trunk/FreeOrion/GG/src/ListBox.cpp Modified: trunk/FreeOrion/GG/GG/ListBox.h =================================================================== --- trunk/FreeOrion/GG/GG/ListBox.h 2014-08-12 20:18:56 UTC (rev 7435) +++ trunk/FreeOrion/GG/GG/ListBox.h 2014-08-13 06:46:49 UTC (rev 7436) @@ -100,26 +100,6 @@ class GG_API ListBox : public Control { public: - /** \brief Sorts iterators to ListBox::Row*s from a container of - ListBox::Row*s. - - For instance for use in a std::map<> or std::set<> (eg, - ListBox::SelectionSet). The iterators must refer to pointers to - ListBox::Rows that are laid out vertically (as in a ListBox). This - layout is used to define a y-ordering that is used to sort the - iterators. */ - template <class Cont> - struct RowPtrIteratorLess - { - typedef typename Cont::iterator Iter; - RowPtrIteratorLess(); - RowPtrIteratorLess(Cont* c); - bool operator()(Iter lhs, Iter rhs) const; - static bool LessThan(Iter lhs, Iter rhs, Iter end); - private: - Cont* m_container; - }; - /** \brief A single item in a listbox. A Row is primarily a container for Controls. Each cell in a Row @@ -221,8 +201,21 @@ typedef std::list<Row*>::iterator iterator; typedef std::list<Row*>::const_iterator const_iterator; - typedef std::set<iterator, RowPtrIteratorLess<std::list<Row*> > > SelectionSet; + /** \brief Sorts iterators to ListBox::Row*s from a container of + ListBox::Row*s. + For instance for use in a std::map<> or std::set<> (eg, + ListBox::SelectionSet). The iterators must refer to pointers to + ListBox::Rows that are laid out vertically (as in a ListBox). This + layout is used to define a y-ordering that is used to sort the + iterators. */ + struct RowPtrIteratorLess + { + bool operator()(const iterator& lhs, const iterator& rhs) const; + }; + + typedef std::set<iterator, RowPtrIteratorLess> SelectionSet; + /** \name Signal Types */ ///@{ /** emitted when the list box is cleared */ typedef boost::signals2::signal<void ()> ClearedSignalType; @@ -575,35 +568,6 @@ // template implementations -template <class Cont> -GG::ListBox::RowPtrIteratorLess<Cont>::RowPtrIteratorLess() : - m_container() -{ assert(m_container); } - -template <class Cont> -GG::ListBox::RowPtrIteratorLess<Cont>::RowPtrIteratorLess(Cont* c) : - m_container(c) -{ assert(m_container); } - -template <class Cont> -bool GG::ListBox::RowPtrIteratorLess<Cont>::operator()(Iter lhs, Iter rhs) const -{ - // If you've seen an error message that lead you here, it is because you - // are attempting to use RowPtrIteratorLess to sort a type that is not - // iterators-to-pointers-to-ListBox::Rows! - BOOST_MPL_ASSERT((boost::is_same<typename Iter::value_type, ::GG::ListBox::Row*>)); - return LessThan(lhs, rhs, m_container->end()); -} - -template <class Cont> -bool GG::ListBox::RowPtrIteratorLess<Cont>::LessThan(Iter lhs, Iter rhs, Iter end) -{ - return lhs == end ? - false : - (rhs == end ? - true : (*lhs)->Top() < (*rhs)->Top()); -} - template <class RowType> bool GG::ListBox::DefaultRowCmp<RowType>::operator()(const GG::ListBox::Row& lhs, const GG::ListBox::Row& rhs, std::size_t column) const { Modified: trunk/FreeOrion/GG/src/ListBox.cpp =================================================================== --- trunk/FreeOrion/GG/src/ListBox.cpp 2014-08-12 20:18:56 UTC (rev 7435) +++ trunk/FreeOrion/GG/src/ListBox.cpp 2014-08-13 06:46:49 UTC (rev 7436) @@ -101,13 +101,13 @@ bool m_invert; }; - bool LessThan(ListBox::iterator lhs, ListBox::iterator rhs, ListBox::iterator end) - { return ListBox::RowPtrIteratorLess<std::list<ListBox::Row*> >::LessThan(lhs, rhs, end); } - bool LessThanEqual(ListBox::iterator lhs, ListBox::iterator rhs, ListBox::iterator end) { - return lhs == rhs || - ListBox::RowPtrIteratorLess<std::list<ListBox::Row*> >::LessThan(lhs, rhs, end); + if (rhs == end) + return true; + if (lhs == end) + return false; + return lhs == rhs || ListBox::RowPtrIteratorLess()(lhs, rhs); } void ResetIfEqual(ListBox::iterator& val, ListBox::iterator other, ListBox::iterator end) @@ -410,7 +410,17 @@ } } + //////////////////////////////////////////////// +// GG::ListBox::RowPtrIteratorLess +//////////////////////////////////////////////// +bool ListBox::RowPtrIteratorLess::operator()(const ListBox::iterator& lhs, const ListBox::iterator& rhs) const +{ + return (*lhs)->Top() < (*rhs)->Top(); +} + + +//////////////////////////////////////////////// // GG::ListBox //////////////////////////////////////////////// // static(s) @@ -424,7 +434,7 @@ m_vscroll_wheel_scroll_increment(0), m_hscroll_wheel_scroll_increment(0), m_caret(m_rows.end()), - m_selections(RowPtrIteratorLess<std::list<Row*> >(&m_rows)), + m_selections(), m_old_sel_row(m_rows.end()), m_old_sel_row_selected(false), m_old_rdown_row(m_rows.end()), @@ -462,7 +472,7 @@ m_vscroll_wheel_scroll_increment(0), m_hscroll_wheel_scroll_increment(0), m_caret(m_rows.end()), - m_selections(RowPtrIteratorLess<std::list<Row*> >(&m_rows)), + m_selections(), m_old_sel_row(m_rows.end()), m_old_sel_row_selected(false), m_old_rdown_row(m_rows.end()), @@ -973,7 +983,7 @@ void ListBox::BringRowIntoView(iterator it) { if (it != m_rows.end()) { - if (LessThan(it, m_first_row_shown, m_rows.end())) { + if (RowPtrIteratorLess()(it, m_first_row_shown)) { m_first_row_shown = it; } else if (LessThanEqual(LastVisibleRow(), it, m_rows.end())) { // Find the row that preceeds the target row by about ClientSize().y @@ -2054,8 +2064,8 @@ if (mod_keys & MOD_KEY_CTRL) { // control key depressed if (mod_keys & MOD_KEY_SHIFT && m_caret != m_rows.end()) { // Both shift and control keys are depressed. - iterator low = LessThan(m_caret, it, m_rows.end()) ? m_caret : it; - iterator high = LessThan(m_caret, it, m_rows.end()) ? it : m_caret; + iterator low = RowPtrIteratorLess()(m_caret, it) ? m_caret : it; + iterator high = RowPtrIteratorLess()(m_caret, it) ? it : m_caret; bool erase = m_selections.find(m_caret) == m_selections.end(); if (high != m_rows.end()) ++high; @@ -2081,8 +2091,8 @@ m_selections.insert(it); m_caret = it; } else { // select all rows between the caret and this row (inclusive), don't move the caret - iterator low = LessThan(m_caret, it, m_rows.end()) ? m_caret : it; - iterator high = LessThan(m_caret, it, m_rows.end()) ? it : m_caret; + iterator low = RowPtrIteratorLess()(m_caret, it) ? m_caret : it; + iterator high = RowPtrIteratorLess()(m_caret, it) ? it : m_caret; if (high != m_rows.end()) ++high; for (iterator it2 = low; it2 != high; ++it2) { |
From: <geo...@us...> - 2014-08-14 08:26:53
|
Revision: 7442 http://sourceforge.net/p/freeorion/code/7442 Author: geoffthemedio Date: 2014-08-14 08:26:39 +0000 (Thu, 14 Aug 2014) Log Message: ----------- Moved drag-drop wnd rendering into separate function. Modified Paths: -------------- trunk/FreeOrion/GG/GG/GUI.h trunk/FreeOrion/GG/src/GUI.cpp Modified: trunk/FreeOrion/GG/GG/GUI.h =================================================================== --- trunk/FreeOrion/GG/GG/GUI.h 2014-08-14 06:35:20 UTC (rev 7441) +++ trunk/FreeOrion/GG/GG/GUI.h 2014-08-14 08:26:39 UTC (rev 7442) @@ -345,8 +345,9 @@ bool SetNextFocusWndInCycle(); ///< sets the focus Wnd to the next in the cycle. //@} - static GUI* GetGUI(); ///< allows any GG code access to GUI framework by calling GUI::GetGUI() - static void RenderWindow(Wnd* wnd); ///< renders a window (if it is visible) and all its visible descendents recursively + static GUI* GetGUI(); ///< allows any GG code access to GUI framework by calling GUI::GetGUI() + static void RenderWindow(Wnd* wnd); ///< renders a window (if it is visible) and all its visible descendents recursively + virtual void RenderDragDropWnds(); ///< renders Wnds currently being drag-dropped /** \name Exceptions */ ///@{ /** The base class for GUI exceptions. */ Modified: trunk/FreeOrion/GG/src/GUI.cpp =================================================================== --- trunk/FreeOrion/GG/src/GUI.cpp 2014-08-14 06:35:20 UTC (rev 7441) +++ trunk/FreeOrion/GG/src/GUI.cpp 2014-08-14 08:26:39 UTC (rev 7442) @@ -691,7 +691,7 @@ m_prev_wnd_under_cursor = m_curr_wnd_under_cursor; // update this for the next time around } -void GUIImpl::HandleMouseEnter (Flags< ModKey > mod_keys, const GG::Pt& pos, Wnd* w) +void GUIImpl::HandleMouseEnter(Flags< ModKey > mod_keys, const GG::Pt& pos, Wnd* w) { w->HandleEvent(WndEvent(WndEvent::MouseEnter, pos, mod_keys)); m_curr_wnd_under_cursor = w; @@ -1427,7 +1427,10 @@ void GUI::RenderWindow(Wnd* wnd) { - if (wnd && wnd->Visible()) { + if (!wnd) + return; + + if (wnd->Visible()) { wnd->Render(); Wnd::ChildClippingMode clip_mode = wnd->GetChildClippingMode(); @@ -1475,6 +1478,25 @@ } } +void GUI::RenderDragDropWnds() +{ + // render drag-and-drop windows in arbitrary order (sorted by pointer value) + s_impl->m_rendering_drag_drop_wnds = true; + for (std::map<Wnd*, Pt>::const_iterator it = s_impl->m_drag_drop_wnds.begin(); it != s_impl->m_drag_drop_wnds.end(); ++it) { + bool old_visible = it->first->Visible(); + if (!old_visible) + it->first->Show(); + Pt parent_offset = it->first->Parent() ? it->first->Parent()->ClientUpperLeft() : Pt(); + Pt old_pos = it->first->UpperLeft() - parent_offset; + it->first->MoveTo(s_impl->m_mouse_pos - parent_offset - it->second); + RenderWindow(it->first); + it->first->MoveTo(old_pos); + if (!old_visible) + it->first->Hide(); + } + s_impl->m_rendering_drag_drop_wnds = false; +} + void GUI::ProcessBrowseInfo() { assert(s_impl->m_curr_wnd_under_cursor); @@ -1519,21 +1541,9 @@ RenderWindow(s_impl->m_browse_info_wnd.get()); } } - // render drag-and-drop windows in arbitrary order (sorted by pointer value) - s_impl->m_rendering_drag_drop_wnds = true; - for (std::map<Wnd*, Pt>::const_iterator it = s_impl->m_drag_drop_wnds.begin(); it != s_impl->m_drag_drop_wnds.end(); ++it) { - bool old_visible = it->first->Visible(); - if (!old_visible) - it->first->Show(); - Pt parent_offset = it->first->Parent() ? it->first->Parent()->ClientUpperLeft() : Pt(); - Pt old_pos = it->first->UpperLeft() - parent_offset; - it->first->MoveTo(s_impl->m_mouse_pos - parent_offset - it->second); - RenderWindow(it->first); - it->first->MoveTo(old_pos); - if (!old_visible) - it->first->Hide(); - } - s_impl->m_rendering_drag_drop_wnds = false; + + RenderDragDropWnds(); + if (s_impl->m_render_cursor && s_impl->m_cursor) s_impl->m_cursor->Render(s_impl->m_mouse_pos); Exit2DMode(); |
From: <mar...@us...> - 2014-08-14 10:03:58
|
Revision: 7446 http://sourceforge.net/p/freeorion/code/7446 Author: marcel_metz Date: 2014-08-14 10:03:55 +0000 (Thu, 14 Aug 2014) Log Message: ----------- Removed unused GG::* default constructors. Modified Paths: -------------- trunk/FreeOrion/GG/GG/BrowseInfoWnd.h trunk/FreeOrion/GG/GG/Button.h trunk/FreeOrion/GG/GG/DropDownList.h trunk/FreeOrion/GG/GG/DynamicGraphic.h trunk/FreeOrion/GG/GG/Edit.h trunk/FreeOrion/GG/GG/Layout.h trunk/FreeOrion/GG/GG/ListBox.h trunk/FreeOrion/GG/GG/Menu.h trunk/FreeOrion/GG/GG/MultiEdit.h trunk/FreeOrion/GG/GG/Scroll.h trunk/FreeOrion/GG/GG/Slider.h trunk/FreeOrion/GG/GG/Spin.h trunk/FreeOrion/GG/GG/StaticGraphic.h trunk/FreeOrion/GG/GG/TabWnd.h trunk/FreeOrion/GG/GG/TextControl.h trunk/FreeOrion/GG/GG/dialogs/ColorDlg.h trunk/FreeOrion/GG/GG/dialogs/FileDlg.h trunk/FreeOrion/GG/GG/dialogs/ThreeButtonDlg.h trunk/FreeOrion/GG/src/BrowseInfoWnd.cpp trunk/FreeOrion/GG/src/Button.cpp trunk/FreeOrion/GG/src/DropDownList.cpp trunk/FreeOrion/GG/src/DynamicGraphic.cpp trunk/FreeOrion/GG/src/Edit.cpp trunk/FreeOrion/GG/src/Layout.cpp trunk/FreeOrion/GG/src/ListBox.cpp trunk/FreeOrion/GG/src/Menu.cpp trunk/FreeOrion/GG/src/MultiEdit.cpp trunk/FreeOrion/GG/src/Scroll.cpp trunk/FreeOrion/GG/src/StaticGraphic.cpp trunk/FreeOrion/GG/src/TabWnd.cpp trunk/FreeOrion/GG/src/TextControl.cpp trunk/FreeOrion/GG/src/dialogs/ColorDlg.cpp trunk/FreeOrion/GG/src/dialogs/FileDlg.cpp trunk/FreeOrion/GG/src/dialogs/ThreeButtonDlg.cpp Modified: trunk/FreeOrion/GG/GG/BrowseInfoWnd.h =================================================================== --- trunk/FreeOrion/GG/GG/BrowseInfoWnd.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/BrowseInfoWnd.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -84,7 +84,6 @@ protected: /** \name Structors */ ///@{ - BrowseInfoWnd(); ///< default ctor BrowseInfoWnd(X x, Y y, X w, Y h); ///< basic ctor //@} @@ -140,11 +139,6 @@ void SetTextMargin(unsigned int text_margin); ///< sets the margin to leave between the text and the text box //@} -protected: - /** \name Structors */ ///@{ - TextBoxBrowseInfoWnd(); ///< default ctor - //@} - private: virtual void UpdateImpl(std::size_t mode, const Wnd* target); Modified: trunk/FreeOrion/GG/GG/Button.h =================================================================== --- trunk/FreeOrion/GG/GG/Button.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/Button.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -93,10 +93,6 @@ //@} protected: - /** \name Structors */ ///@{ - Button(); ///< default ctor - //@} - /** \name Mutators */ ///@{ virtual void LButtonDown(const Pt& pt, Flags<ModKey> mod_keys); virtual void LDrag(const Pt& pt, const Pt& move, Flags<ModKey> mod_keys); @@ -179,10 +175,6 @@ //@} protected: - /** \name Structors */ ///@{ - StateButton(); ///< default ctor - //@} - /** \name Accessors */ ///@{ Pt ButtonUpperLeft() const; ///< Returns the upper-left of the button part of the control Pt ButtonLowerRight() const; ///< Returns the lower-right of the button part of the control @@ -341,10 +333,6 @@ boost::signals2::connection connection; }; - /** \name Structors */ ///@{ - RadioButtonGroup(); ///< default ctor - //@} - /** \name Accessors */ ///@{ const std::vector<ButtonSlot>& ButtonSlots() const; ///< returns the state buttons in the group //@} Modified: trunk/FreeOrion/GG/GG/DropDownList.h =================================================================== --- trunk/FreeOrion/GG/GG/DropDownList.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/DropDownList.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -177,10 +177,6 @@ //@} protected: - /** \name Structors */ ///@{ - DropDownList(); ///< default ctor - //@} - /** \name Mutators */ ///@{ virtual void LClick(const Pt& pt, Flags<ModKey> mod_keys); virtual void KeyPress(Key key, boost::uint32_t key_code_point, Flags<ModKey> mod_keys); Modified: trunk/FreeOrion/GG/GG/DynamicGraphic.h =================================================================== --- trunk/FreeOrion/GG/GG/DynamicGraphic.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/DynamicGraphic.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -210,10 +210,6 @@ std::size_t frames; ///< the number of frames in this texture }; - /** \name Structors */ ///@{ - DynamicGraphic(); ///< default ctor - //@} - /** \name Accessors */ ///@{ std::size_t FramesInTexture(const Texture* t) const; ///< returns the maximum number of frames that could be stored in \a t given the size of the control and Margin() const std::vector<FrameSet>& Textures() const; ///< returns the shared_ptrs to texture objects with all animation frames Modified: trunk/FreeOrion/GG/GG/Edit.h =================================================================== --- trunk/FreeOrion/GG/GG/Edit.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/Edit.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -140,10 +140,6 @@ //@} protected: - /** \name Structors */ ///@{ - Edit(); ///< Default ctor. - //@} - /** \name Accessors */ ///@{ /** Returns true if >= 1 characters selected. */ virtual bool MultiSelected() const; Modified: trunk/FreeOrion/GG/GG/Layout.h =================================================================== --- trunk/FreeOrion/GG/GG/Layout.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/Layout.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -238,10 +238,6 @@ static const unsigned int INVALID_CELL_MARGIN; protected: - /** \name Structors */ ///@{ - Layout(); ///< default ctor - //@} - /** \name Mutators */ ///@{ virtual void MouseWheel(const Pt& pt, int move, Flags<ModKey> mod_keys); virtual void KeyPress(Key key, boost::uint32_t key_code_point, Flags<ModKey> mod_keys); Modified: trunk/FreeOrion/GG/GG/ListBox.h =================================================================== --- trunk/FreeOrion/GG/GG/ListBox.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/ListBox.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -454,10 +454,6 @@ //@} protected: - /** \name Structors */ ///@{ - ListBox(); ///< default ctor - //@} - /** \name Accessors */ ///@{ X RightMargin() const; ///< space skipped at right of client area for vertical scroll bar Y BottomMargin() const; ///< space skipped at bottom of client area for horizontal scroll bar Modified: trunk/FreeOrion/GG/GG/Menu.h =================================================================== --- trunk/FreeOrion/GG/GG/Menu.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/Menu.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -187,10 +187,6 @@ static const std::size_t INVALID_CARET; protected: - /** \name Structors */ ///@{ - MenuBar(); ///< default ctor - //@} - /** \name Accessors */ ///@{ const boost::shared_ptr<Font>& GetFont() const; ///< returns the font used to render text in the control const std::vector<TextControl*>& MenuLabels() const; ///< returns the text for each top-level menu item Modified: trunk/FreeOrion/GG/GG/MultiEdit.h =================================================================== --- trunk/FreeOrion/GG/GG/MultiEdit.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/MultiEdit.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -119,10 +119,6 @@ static const unsigned int BORDER_THICK; protected: - /** \name Structors */ ///@{ - MultiEdit(); ///< Default ctor. - //@} - /** \name Accessors */ ///@{ /** Returns true if >= 1 characters are selected. */ virtual bool MultiSelected() const; Modified: trunk/FreeOrion/GG/GG/Scroll.h =================================================================== --- trunk/FreeOrion/GG/GG/Scroll.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/Scroll.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -118,10 +118,6 @@ //@} protected: - /** \name Structors */ ///@{ - Scroll(); ///< defalt ctor - //@} - /** \name Accessors */ ///@{ unsigned int TabSpace() const; ///< returns the space the tab has to move about in (the control's width less the width of the incr & decr buttons) unsigned int TabWidth() const; ///< returns the calculated width of the tab, based on PageSize() and the logical size of the control, in pixels Modified: trunk/FreeOrion/GG/GG/Slider.h =================================================================== --- trunk/FreeOrion/GG/GG/Slider.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/Slider.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -117,10 +117,6 @@ static const T INVALID_PAGE_SIZE; protected: - /** \name Structors */ ///@{ - Slider(); ///< default ctor - //@} - /** \name Accessors */ ///@{ Button* Tab() const; ///< returns a pointer to the Button used as this control's sliding tab T PtToPosn(const Pt& pt) const; ///< maps an arbitrary screen point to its nearest logical slider position @@ -164,22 +160,6 @@ const T Slider<T>::INVALID_PAGE_SIZE = std::numeric_limits<T>::max(); template <class T> -Slider<T>::Slider() : - Control(), - m_posn(0), - m_range_min(T(0)), - m_range_max(T(99)), - m_page_sz(INVALID_PAGE_SIZE), - m_orientation(VERTICAL), - m_line_width(5), - m_tab_width(5), - m_line_style(RAISED), - m_tab_drag_offset(-1), - m_tab(0), - m_dragging_tab(false) -{} - -template <class T> Slider<T>::Slider(X x, Y y, X w, Y h, T min, T max, Orientation orientation, SliderLineStyle style, Clr color, int unsigned tab_width, int unsigned line_width/* = 5*/, Flags<WndFlag> flags/* = INTERACTIVE*/) : Modified: trunk/FreeOrion/GG/GG/Spin.h =================================================================== --- trunk/FreeOrion/GG/GG/Spin.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/Spin.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -140,10 +140,6 @@ enum {BORDER_THICK = 2, PIXEL_MARGIN = 5}; - /** \name Structors */ ///@{ - Spin(); ///< default ctor - //@} - /** \name Accessors */ ///@{ Button* UpButton() const; ///< returns a pointer to the Button control used as this control's up button Button* DownButton() const; ///< returns a pointer to the Button control used as this control's down button @@ -184,20 +180,6 @@ // template implementations template<class T> -Spin<T>::Spin() : - Control(), - m_value(), - m_step_size(), - m_min_value(), - m_max_value(), - m_editable(false), - m_edit(0), - m_up_button(0), - m_down_button(0), - m_button_width(15) -{} - -template<class T> Spin<T>::Spin(X x, Y y, X w, T value, T step, T min, T max, bool edits, const boost::shared_ptr<Font>& font, Clr color, Clr text_color/* = CLR_BLACK*/, Clr interior/* = CLR_ZERO*/, Flags<WndFlag> flags/* = INTERACTIVE*/) : Control(x, y, w, font->Height() + 2 * PIXEL_MARGIN, flags), Modified: trunk/FreeOrion/GG/GG/StaticGraphic.h =================================================================== --- trunk/FreeOrion/GG/GG/StaticGraphic.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/StaticGraphic.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -84,11 +84,6 @@ void SetStyle(Flags<GraphicStyle> style); //@} -protected: - /** \name Structors */ ///@{ - StaticGraphic(); ///< default ctor - //@} - private: void Init(const SubTexture& subtexture); ///< initializes a StaticGraphic from a SubTexture void ValidateStyle(); ///< ensures that the style flags are consistent Modified: trunk/FreeOrion/GG/GG/TabWnd.h =================================================================== --- trunk/FreeOrion/GG/GG/TabWnd.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/TabWnd.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -105,11 +105,6 @@ Wnd. */ static const std::size_t NO_WND; -protected: - /** \name Structors */ ///@{ - OverlayWnd(); ///< default ctor - //@} - private: std::vector<Wnd*> m_wnds; std::size_t m_current_wnd_index; @@ -181,10 +176,6 @@ static const std::size_t NO_WND; protected: - /** \name Structors */ ///@{ - TabWnd(); ///< default ctor - //@} - /** \name Accessors */ ///@{ /** Returns the TabBar at the top of this TabWnd. */ const TabBar* GetTabBar() const; @@ -279,10 +270,6 @@ static const X BUTTON_WIDTH; protected: - /** \name Structors */ ///@{ - TabBar(); ///< default ctor - //@} - /** \name Accessors */ ///@{ const Button* LeftButton() const; const Button* RightButton() const; Modified: trunk/FreeOrion/GG/GG/TextControl.h =================================================================== --- trunk/FreeOrion/GG/GG/TextControl.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/TextControl.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -231,10 +231,6 @@ //@} protected: - /** \name Structors */ ///@{ - TextControl(); ///< Default ctor. - //@} - /** \name Accessors */ ///@{ /** Returns the line data for the text in this TextControl. */ const std::vector<Font::LineData>& GetLineData() const; Modified: trunk/FreeOrion/GG/GG/dialogs/ColorDlg.h =================================================================== --- trunk/FreeOrion/GG/GG/dialogs/ColorDlg.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/dialogs/ColorDlg.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -77,11 +77,6 @@ mutable ChangedSignalType ChangedSignal; ///< emitted whenever the hue or saturation in the picker changes -protected: - /** \name Structors */ ///@{ - HueSaturationPicker(); ///< default ctor - //@} - private: void SetHueSaturationFromPt(Pt pt); @@ -119,11 +114,6 @@ mutable ChangedSignalType ChangedSignal; ///< emitted whenever the hue or saturation in the picker changes -protected: - /** \name Structors */ ///@{ - ValuePicker(); ///< default ctor - //@} - private: void SetValueFromPt(Pt pt); @@ -164,10 +154,6 @@ //@} protected: - /** \name Structors */ ///@{ - ColorButton(); ///< default ctor - //@} - /** \name Mutators */ ///@{ virtual void RenderUnpressed(); virtual void RenderPressed(); @@ -194,11 +180,6 @@ /** \name Accessors */ ///@{ virtual void Render(); //@} - - protected: - /** \name Structors */ ///@{ - ColorDisplay(); ///< default ctor - //@} }; /** \name Structors */ ///@{ @@ -252,11 +233,6 @@ static const std::size_t INVALID_COLOR_BUTTON; -protected: - /** \name Structors */ ///@{ - ColorDlg(); ///< default ctor - //@} - private: struct ColorButtonClickFunctor { Modified: trunk/FreeOrion/GG/GG/dialogs/FileDlg.h =================================================================== --- trunk/FreeOrion/GG/GG/dialogs/FileDlg.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/dialogs/FileDlg.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -161,10 +161,6 @@ static const X DEFAULT_WIDTH; ///< default width for the dialog static const Y DEFAULT_HEIGHT; ///< default height for the dialog - /** \name Structors */ ///@{ - FileDlg(); ///< default ctor - //@} - private: void CreateChildren(const std::string& filename, bool multi); void PlaceLabelsAndEdits(X button_width, Y button_height); Modified: trunk/FreeOrion/GG/GG/dialogs/ThreeButtonDlg.h =================================================================== --- trunk/FreeOrion/GG/GG/dialogs/ThreeButtonDlg.h 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/GG/dialogs/ThreeButtonDlg.h 2014-08-14 10:03:55 UTC (rev 7446) @@ -87,11 +87,6 @@ static const std::size_t NO_BUTTON; -protected: - /** \name Structors */ ///@{ - ThreeButtonDlg(); ///< default ctor - //@} - private: std::size_t NumButtons() const; void Init(const std::string& msg, const boost::shared_ptr<Font>& font, std::size_t buttons, Modified: trunk/FreeOrion/GG/src/BrowseInfoWnd.cpp =================================================================== --- trunk/FreeOrion/GG/src/BrowseInfoWnd.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/BrowseInfoWnd.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -39,10 +39,6 @@ //////////////////////////////////////////////// // GG::BrowseInfoWnd //////////////////////////////////////////////// -BrowseInfoWnd::BrowseInfoWnd() : - Wnd() -{} - BrowseInfoWnd::BrowseInfoWnd(X x, Y y, X w, Y h) : Wnd(x, y, w, h) {} @@ -80,14 +76,6 @@ //////////////////////////////////////////////// // GG::TextBoxBrowseInfoWnd //////////////////////////////////////////////// -TextBoxBrowseInfoWnd::TextBoxBrowseInfoWnd() : - BrowseInfoWnd(), - m_text_from_target(true), - m_border_width(1), - m_preferred_width(1), - m_text_control(0) -{} - TextBoxBrowseInfoWnd::TextBoxBrowseInfoWnd(X w, const boost::shared_ptr<Font>& font, Clr color, Clr border_color, Clr text_color, Flags<TextFormat> format/* = FORMAT_LEFT | FORMAT_WORDBREAK*/, unsigned int border_width/* = 2*/, unsigned int text_margin/* = 4*/) : Modified: trunk/FreeOrion/GG/src/Button.cpp =================================================================== --- trunk/FreeOrion/GG/src/Button.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/Button.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -51,11 +51,6 @@ //////////////////////////////////////////////// // GG::Button //////////////////////////////////////////////// -Button::Button() : - TextControl(), - m_state(BN_UNPRESSED) -{} - Button::Button(X x, Y y, X w, Y h, const std::string& str, const boost::shared_ptr<Font>& font, Clr color, Clr text_color/* = CLR_BLACK*/, Flags<WndFlag> flags/* = INTERACTIVE*/) : TextControl(x, y, w, h, str, font, text_color, FORMAT_NONE, flags), @@ -241,12 +236,6 @@ //////////////////////////////////////////////// // GG::StateButton //////////////////////////////////////////////// -StateButton::StateButton() : - TextControl(), - m_checked(false), - m_style(SBSTYLE_3D_XBOX) -{} - StateButton::StateButton(X x, Y y, X w, Y h, const std::string& str, const boost::shared_ptr<Font>& font, Flags<TextFormat> format, Clr color, Clr text_color/* = CLR_BLACK*/, Clr interior/* = CLR_ZERO*/, StateButtonStyle style/* = SBSTYLE_3D_XBOX*/, Flags<WndFlag> flags/* = INTERACTIVE*/) : @@ -512,15 +501,6 @@ // static(s) const std::size_t RadioButtonGroup::NO_BUTTON = std::numeric_limits<std::size_t>::max(); -RadioButtonGroup::RadioButtonGroup() : - Control(), - m_orientation(VERTICAL), - m_checked_button(NO_BUTTON), - m_expand_buttons(false), - m_expand_buttons_proportionally(false), - m_render_outline(false) -{ SetColor(CLR_YELLOW); } - RadioButtonGroup::RadioButtonGroup(X x, Y y, X w, Y h, Orientation orientation) : Control(x, y, w, h), m_orientation(orientation), Modified: trunk/FreeOrion/GG/src/DropDownList.cpp =================================================================== --- trunk/FreeOrion/GG/src/DropDownList.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/DropDownList.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -141,11 +141,6 @@ //////////////////////////////////////////////// // GG::DropDownList //////////////////////////////////////////////// -DropDownList::DropDownList() : - Control(), - m_modal_picker(0) -{} - DropDownList::DropDownList(X x, Y y, X w, Y h, Y drop_ht, Clr color, Flags<WndFlag> flags/* = INTERACTIVE*/) : Control(x, y, w, h, flags), m_modal_picker(new ModalListPicker(w, drop_ht, color, this)) Modified: trunk/FreeOrion/GG/src/DynamicGraphic.cpp =================================================================== --- trunk/FreeOrion/GG/src/DynamicGraphic.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/DynamicGraphic.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -54,24 +54,6 @@ const std::size_t DynamicGraphic::INVALID_INDEX = std::numeric_limits<std::size_t>::max(); const unsigned int DynamicGraphic::INVALID_TIME = std::numeric_limits<unsigned int>::max(); -DynamicGraphic::DynamicGraphic() : - Control(), - m_margin(0), - m_frame_width(0), - m_frame_height(0), - m_FPS(DEFAULT_FPS), - m_playing(true), - m_looping(true), - m_curr_texture(0), - m_curr_subtexture(0), - m_frames(0), - m_curr_frame(0), - m_first_frame_time(INVALID_TIME), - m_last_frame_time(INVALID_TIME), - m_first_frame_idx(0), - m_style(GRAPHIC_NONE) -{} - DynamicGraphic::DynamicGraphic(X x, Y y, X w, Y h, bool loop, X frame_width, Y frame_height, unsigned int margin, const std::vector<boost::shared_ptr<Texture> >& textures, Flags<GraphicStyle> style/* = GRAPHIC_NONE*/, std::size_t frames/* = ALL_FRAMES*/, Modified: trunk/FreeOrion/GG/src/Edit.cpp =================================================================== --- trunk/FreeOrion/GG/src/Edit.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/Edit.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -59,19 +59,6 @@ // static(s) const int Edit::PIXEL_MARGIN = 5; -Edit::Edit() : - TextControl(), - m_cursor_pos(CP0, CP0), - m_last_button_down_time(0), - m_in_double_click_mode(false), - m_double_click_cursor_pos(CP0, CP0), - m_first_char_shown(0), - m_int_color(CLR_ZERO), - m_hilite_color(CLR_WHITE), - m_sel_text_color(CLR_CYAN), - m_recently_edited(false) -{} - Edit::Edit(X x, Y y, X w, const std::string& str, const boost::shared_ptr<Font>& font, Clr color, Clr text_color/* = CLR_BLACK*/, Clr interior/* = CLR_ZERO*/, Flags<WndFlag> flags/* = INTERACTIVE*/) : TextControl(x, y, w, HeightFromFont(font, PIXEL_MARGIN), str, font, text_color, FORMAT_LEFT | FORMAT_IGNORETAGS, flags), Modified: trunk/FreeOrion/GG/src/Layout.cpp =================================================================== --- trunk/FreeOrion/GG/src/Layout.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/Layout.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -77,16 +77,6 @@ // Layout const unsigned int Layout::INVALID_CELL_MARGIN = std::numeric_limits<unsigned int>::max(); -Layout::Layout() : - Wnd(), - m_border_margin(0), - m_cell_margin(0), - m_ignore_child_resize(false), - m_ignore_parent_resize(false), - m_render_outline(false), - m_outline_color(CLR_MAGENTA) -{} - Layout::Layout(X x, Y y, X w, Y h, std::size_t rows, std::size_t columns, unsigned int border_margin/* = 0*/, unsigned int cell_margin/* = INVALID_CELL_MARGIN*/) : Wnd(x, y, w, h, NO_WND_FLAGS), Modified: trunk/FreeOrion/GG/src/ListBox.cpp =================================================================== --- trunk/FreeOrion/GG/src/ListBox.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/ListBox.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -409,43 +409,6 @@ // static(s) const unsigned int ListBox::BORDER_THICK = 2; -ListBox::ListBox() : - Control(), - m_rows(), - m_vscroll(0), - m_hscroll(0), - m_vscroll_wheel_scroll_increment(0), - m_hscroll_wheel_scroll_increment(0), - m_caret(m_rows.end()), - m_selections(), - m_old_sel_row(m_rows.end()), - m_old_sel_row_selected(false), - m_old_rdown_row(m_rows.end()), - m_lclick_row(m_rows.end()), - m_rclick_row(m_rows.end()), - m_last_row_browsed(m_rows.end()), - m_first_row_shown(m_rows.end()), - m_first_col_shown(0), - m_cell_margin(2), - m_style(LIST_NONE), - m_header_row(0), - m_keep_col_widths(false), - m_clip_cells(false), - m_sort_col(0), - m_sort_cmp(DefaultRowCmp<Row>()), - m_auto_scroll_during_drag_drops(true), - m_auto_scroll_margin(8), - m_auto_scrolling_up(false), - m_auto_scrolling_down(false), - m_auto_scrolling_left(false), - m_auto_scrolling_right(false), - m_auto_scroll_timer(250), - m_iterator_being_erased(0) -{ - m_auto_scroll_timer.Stop(); - m_auto_scroll_timer.Connect(this); -} - ListBox::ListBox(X x, Y y, X w, Y h, Clr color, Clr interior/* = CLR_ZERO*/, Flags<WndFlag> flags/* = INTERACTIVE*/) : Control(x, y, w, h, flags), Modified: trunk/FreeOrion/GG/src/Menu.cpp =================================================================== --- trunk/FreeOrion/GG/src/Menu.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/Menu.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -128,11 +128,6 @@ //////////////////////////////////////////////// const std::size_t MenuBar::INVALID_CARET = std::numeric_limits<std::size_t>::max(); -MenuBar::MenuBar() : - Control(), - m_caret(INVALID_CARET) -{} - MenuBar::MenuBar(X x, Y y, X w, const boost::shared_ptr<Font>& font, Clr text_color/* = CLR_WHITE*/, Clr color/* = CLR_BLACK*/, Clr interior/* = CLR_SHADOW*/) : Control(x, y, w, font->Lineskip()), Modified: trunk/FreeOrion/GG/src/MultiEdit.cpp =================================================================== --- trunk/FreeOrion/GG/src/MultiEdit.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/MultiEdit.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -102,22 +102,6 @@ const unsigned int MultiEdit::SCROLL_WIDTH = 14; const unsigned int MultiEdit::BORDER_THICK = 2; -MultiEdit::MultiEdit() : - Edit(), - m_style(MULTI_NONE), - m_cursor_begin(0, CP0), - m_cursor_end(0, CP0), - m_first_col_shown(0), - m_first_row_shown(0), - m_max_lines_history(ALL_LINES), - m_vscroll(0), - m_hscroll(0), - m_vscroll_wheel_scroll_increment(0), - m_hscroll_wheel_scroll_increment(0), - m_preserve_text_position_on_next_set_text(false), - m_ignore_adjust_scrolls(false) -{} - MultiEdit::MultiEdit(X x, Y y, X w, Y h, const std::string& str, const boost::shared_ptr<Font>& font, Clr color, Flags<MultiEditStyle> style/* = MULTI_LINEWRAP*/, Clr text_color/* = CLR_BLACK*/, Clr interior/* = CLR_ZERO*/, Flags<WndFlag> flags/* = INTERACTIVE*/) : Modified: trunk/FreeOrion/GG/src/Scroll.cpp =================================================================== --- trunk/FreeOrion/GG/src/Scroll.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/Scroll.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -52,23 +52,6 @@ //////////////////////////////////////////////// // GG::Scroll //////////////////////////////////////////////// -Scroll::Scroll() : - Control(), - m_orientation(VERTICAL), - m_posn(0), - m_range_min(0), - m_range_max(99), - m_line_sz(5), - m_page_sz(25), - m_tab(0), - m_incr(0), - m_decr(0), - m_initial_depressed_region(SBR_NONE), - m_depressed_region(SBR_NONE), - m_dragging_tab(false), - m_tab_dragged(false) -{} - Scroll::Scroll(X x, Y y, X w, Y h, Orientation orientation, Clr color, Clr interior, Flags<WndFlag> flags/* = INTERACTIVE | REPEAT_BUTTON_DOWN*/) : Control(x, y, w, h, flags), m_int_color(interior), Modified: trunk/FreeOrion/GG/src/StaticGraphic.cpp =================================================================== --- trunk/FreeOrion/GG/src/StaticGraphic.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/StaticGraphic.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -71,11 +71,6 @@ //////////////////////////////////////////////// // GG::StaticGraphic //////////////////////////////////////////////// -StaticGraphic::StaticGraphic() : - Control(), - m_style(GRAPHIC_NONE) -{} - StaticGraphic::StaticGraphic(X x, Y y, X w, Y h, const boost::shared_ptr<Texture>& texture, Flags<GraphicStyle> style/* = GRAPHIC_NONE*/, Flags<WndFlag> flags/* = 0*/) : Control(x, y, w, h, flags), Modified: trunk/FreeOrion/GG/src/TabWnd.cpp =================================================================== --- trunk/FreeOrion/GG/src/TabWnd.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/TabWnd.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -51,10 +51,6 @@ // static(s) const std::size_t OverlayWnd::NO_WND = std::numeric_limits<std::size_t>::max(); -OverlayWnd::OverlayWnd() : - m_current_wnd_index(NO_WND) -{} - OverlayWnd::OverlayWnd(X x, Y y, X w, Y h, Flags<WndFlag> flags) : Wnd(x, y, w, h, flags), m_current_wnd_index(NO_WND) @@ -153,11 +149,6 @@ // static(s) const std::size_t TabWnd::NO_WND = std::numeric_limits<std::size_t>::max(); -TabWnd::TabWnd() : - m_tab_bar(0), - m_overlay(0) -{} - TabWnd::TabWnd(X x, Y y, X w, Y h, const boost::shared_ptr<Font>& font, Clr color, Clr text_color/* = CLR_BLACK*/, TabBarStyle style/* = TAB_BAR_ATTACHED*/, Flags<WndFlag> flags/* = INTERACTIVE*/) : @@ -261,17 +252,6 @@ const std::size_t TabBar::NO_TAB = TabWnd::NO_WND; const X TabBar::BUTTON_WIDTH(10); -TabBar::TabBar() : - Control(), - m_tabs(0), - m_left_button(0), - m_right_button(0), - m_left_right_button_layout(0), - m_text_color(CLR_BLACK), - m_style(TAB_BAR_ATTACHED), - m_first_tab_shown(0) -{} - TabBar::TabBar(X x, Y y, X w, const boost::shared_ptr<Font>& font, Clr color, Clr text_color/* = CLR_BLACK*/, TabBarStyle style/* = TAB_BAR_ATTACHED*/, Flags<WndFlag> flags/* = INTERACTIVE*/) : Control(x, y, w, TabHeightFromFont(font), flags), Modified: trunk/FreeOrion/GG/src/TextControl.cpp =================================================================== --- trunk/FreeOrion/GG/src/TextControl.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/TextControl.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -39,14 +39,6 @@ //////////////////////////////////////////////// // GG::TextControl //////////////////////////////////////////////// -TextControl::TextControl() : - Control(), - m_format(FORMAT_NONE), - m_clip_text(false), - m_set_min_size(false), - m_code_points(0) -{} - TextControl::TextControl(X x, Y y, X w, Y h, const std::string& str, const boost::shared_ptr<Font>& font, Clr color/* = CLR_BLACK*/, Flags<TextFormat> format/* = FORMAT_NONE*/, Flags<WndFlag> flags/* = NO_WND_FLAGS*/) : Control(x, y, w, h, flags), Modified: trunk/FreeOrion/GG/src/dialogs/ColorDlg.cpp =================================================================== --- trunk/FreeOrion/GG/src/dialogs/ColorDlg.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/dialogs/ColorDlg.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -153,12 +153,6 @@ //////////////////////////////////////////////// // HueSaturationPicker //////////////////////////////////////////////// -HueSaturationPicker::HueSaturationPicker() : - Control(), - m_hue(0.0), - m_saturation(0.0) -{} - HueSaturationPicker::HueSaturationPicker(X x, Y y, X w, Y h) : Control(x, y, w, h, INTERACTIVE), m_hue(0.0), @@ -242,13 +236,6 @@ //////////////////////////////////////////////// // ValuePicker //////////////////////////////////////////////// -ValuePicker::ValuePicker() : - Control(), - m_hue(0.0), - m_saturation(0.0), - m_value(0.0) -{} - ValuePicker::ValuePicker(X x, Y y, X w, Y h, Clr arrow_color) : Control(x, y, w, h, INTERACTIVE), m_hue(0.0), @@ -322,10 +309,6 @@ //////////////////////////////////////////////// // ColorDlg::ColorButton -ColorDlg::ColorButton::ColorButton() : - Button() -{} - ColorDlg::ColorButton::ColorButton(const Clr& color) : Button(X0, Y0, X1, Y1, "", boost::shared_ptr<Font>(), color), m_represented_color(CLR_BLACK) @@ -356,10 +339,6 @@ // ColorDlg::ColorDisplay -ColorDlg::ColorDisplay::ColorDisplay() : - Control() -{} - ColorDlg::ColorDisplay::ColorDisplay(Clr color) : Control(X0, Y0, X1, Y1, NO_WND_FLAGS) { SetColor(color); } @@ -420,25 +399,6 @@ std::vector<Clr> ColorDlg::s_custom_colors; const std::size_t ColorDlg::INVALID_COLOR_BUTTON = std::numeric_limits<std::size_t>::max(); -ColorDlg::ColorDlg() : - Wnd(), - m_original_color_specified(false), - m_color_was_picked(false), - m_hue_saturation_picker(0), - m_value_picker(0), - m_pickers_layout(0), - m_new_color_square(0), - m_old_color_square(0), - m_new_color_square_text(0), - m_old_color_square_text(0), - m_color_squares_layout(0), - m_color_buttons_layout(0), - m_current_color_button(INVALID_COLOR_BUTTON), - m_ok(0), - m_cancel(0), - m_sliders_ok_cancel_layout(0) -{} - ColorDlg::ColorDlg(X x, Y y, const boost::shared_ptr<Font>& font, Clr dialog_color, Clr border_color, Clr text_color/* = CLR_BLACK*/) : Wnd(x, y, X(315), Y(300), INTERACTIVE | DRAGABLE | MODAL), Modified: trunk/FreeOrion/GG/src/dialogs/FileDlg.cpp =================================================================== --- trunk/FreeOrion/GG/src/dialogs/FileDlg.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/dialogs/FileDlg.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -135,21 +135,6 @@ const Y FileDlg::DEFAULT_HEIGHT(450); -FileDlg::FileDlg() : - Wnd(), - m_select_directories(false), - m_append_missing_save_extension(false), - m_in_win32_drive_selection(false), - m_curr_dir_text(0), - m_files_list(0), - m_files_edit(0), - m_filter_list(0), - m_ok_button(0), - m_cancel_button(0), - m_files_label(0), - m_file_types_label(0) -{} - FileDlg::FileDlg(const std::string& directory, const std::string& filename, bool save, bool multi, const boost::shared_ptr<Font>& font, Clr color, Clr border_color, Clr text_color/* = CLR_BLACK*/) : Wnd((GUI::GetGUI()->AppWidth() - DEFAULT_WIDTH) / 2, Modified: trunk/FreeOrion/GG/src/dialogs/ThreeButtonDlg.cpp =================================================================== --- trunk/FreeOrion/GG/src/dialogs/ThreeButtonDlg.cpp 2014-08-14 09:47:32 UTC (rev 7445) +++ trunk/FreeOrion/GG/src/dialogs/ThreeButtonDlg.cpp 2014-08-14 10:03:55 UTC (rev 7446) @@ -37,16 +37,6 @@ const std::size_t ThreeButtonDlg::NO_BUTTON = std::numeric_limits<std::size_t>::max(); -ThreeButtonDlg::ThreeButtonDlg() : - Wnd(), - m_default(0), - m_escape(0), - m_result(0), - m_button_0(0), - m_button_1(0), - m_button_2(0) -{} - ThreeButtonDlg::ThreeButtonDlg(X x, Y y, X w, Y h, const std::string& msg, const boost::shared_ptr<Font>& font, Clr color, Clr border_color, Clr button_color, Clr text_color, std::size_t buttons, const std::string& zero/* = ""*/, const std::string& one/* = ""*/, |