Issues with 'templatized' version of GG's Slider / CUISlider

Questions, problems and discussion about compiling FreeOrion.

Moderators: Oberlus, Oberlus

Post Reply
Message
Author
night
Space Kraken
Posts: 102
Joined: Sun Jun 12, 2011 1:21 pm

Issues with 'templatized' version of GG's Slider / CUISlider

#1 Post by night » Fri Oct 07, 2011 8:42 pm

Hi,
I wanted to do my weekly build for Mac OS but I am getting errors related to GG's new 'templatized' slider / the newly added CUISlider.h:

Code: Select all

../UI/CUISlider.h
../Xcode/../UI/CUISlider.h:25: error: there are no arguments to 'UpperLeft' that depend on a template parameter, so a declaration of 'UpperLeft' must be available
../Xcode/../UI/CUISlider.h:25: error: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
../Xcode/../UI/CUISlider.h:26: error: there are no arguments to 'LowerRight' that depend on a template parameter, so a declaration of 'LowerRight' must be available
../Xcode/../UI/CUISlider.h:27: error: there are no arguments to 'Disabled' that depend on a template parameter, so a declaration of 'Disabled' must be available
../Xcode/../UI/CUISlider.h:28: error: there are no arguments to 'GetOrientation' that depend on a template parameter, so a declaration of 'GetOrientation' must be available
../Xcode/../UI/CUISlider.h:28: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:28: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:30: error: there are no arguments to 'GetOrientation' that depend on a template parameter, so a declaration of 'GetOrientation' must be available
../Xcode/../UI/CUISlider.h:31: error: there are no arguments to 'LineWidth' that depend on a template parameter, so a declaration of 'LineWidth' must be available
../Xcode/../UI/CUISlider.h:32: error: there are no arguments to 'LineWidth' that depend on a template parameter, so a declaration of 'LineWidth' must be available
../Xcode/../UI/CUISlider.h:38: error: there are no arguments to 'LineWidth' that depend on a template parameter, so a declaration of 'LineWidth' must be available
../Xcode/../UI/CUISlider.h:39: error: there are no arguments to 'LineWidth' that depend on a template parameter, so a declaration of 'LineWidth' must be available
../Xcode/../UI/CUISlider.h:46: error: 'Wnd' has not been declared
../Xcode/../UI/CUISlider.h:47: error: there are no arguments to 'GetOrientation' that depend on a template parameter, so a declaration of 'GetOrientation' must be available
../Xcode/../UI/CUISlider.h:48: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:48: error: there are no arguments to 'TabWidth' that depend on a template parameter, so a declaration of 'TabWidth' must be available
../Xcode/../UI/CUISlider.h:48: error: there are no arguments to 'TabWidth' that depend on a template parameter, so a declaration of 'TabWidth' must be available
../Xcode/../UI/CUISlider.h:49: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:49: error: there are no arguments to 'Width' that depend on a template parameter, so a declaration of 'Width' must be available
../Xcode/../UI/CUISlider.h:49: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:49: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:50: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:50: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:52: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:52: error: there are no arguments to 'TabWidth' that depend on a template parameter, so a declaration of 'TabWidth' must be available
../Xcode/../UI/CUISlider.h:52: error: there are no arguments to 'TabWidth' that depend on a template parameter, so a declaration of 'TabWidth' must be available
../Xcode/../UI/CUISlider.h:53: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:53: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:53: error: there are no arguments to 'Height' that depend on a template parameter, so a declaration of 'Height' must be available
../Xcode/../UI/CUISlider.h:53: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:54: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:54: error: there are no arguments to 'Tab' that depend on a template parameter, so a declaration of 'Tab' must be available
../Xcode/../UI/CUISlider.h:56: error: there are no arguments to 'MoveTabToPosn' that depend on a template parameter, so a declaration of 'MoveTabToPosn' must be available

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12482
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Issues with 'templatized' version of GG's Slider / CUISl

#2 Post by Geoff the Medio » Fri Oct 07, 2011 10:25 pm

For all those calls that cause that error, try adding this-> before the method name.

If that doesn't work, try prepending GG::Slider<T>:: before all the method names.

(Based on this and this.)

night
Space Kraken
Posts: 102
Joined: Sun Jun 12, 2011 1:21 pm

Re: Issues with 'templatized' version of GG's Slider / CUISl

#3 Post by night » Sat Oct 08, 2011 9:19 am

Thank you! That worked perfectly :D
But now I get two errors with Boost and the Universe.cpp again (which brings back bad memories :():

Code: Select all

freeorion-sdk/FreeOrion/Xcode/dep/local/include/boost/graph/johnson_all_pairs_shortest.hpp
../dep/local/include/boost/graph/johnson_all_pairs_shortest.hpp:88: error: invalid initialization of reference of type 'const boost::detail::edge_desc_impl<boost::undirected_tag, unsigned int>&' from expression of type 'boost::detail::edge_desc_impl<boost::undirected_tag, long unsigned int>'
../dep/local/include/boost/graph/johnson_all_pairs_shortest.hpp:92: error: invalid initialization of reference of type 'const boost::detail::edge_desc_impl<boost::undirected_tag, unsigned int>&' from expression of type 'boost::detail::edge_desc_impl<boost::undirected_tag, long unsigned int>'

freeorion-sdk/FreeOrion/universe/Universe.cpp
../universe/Universe.cpp:101: error: in passing argument 2 of 'short int<unnamed>::get(const<unnamed>::constant_property&, const boost::detail::edge_desc_impl<boost::undirected_tag, unsigned int>&)'
../universe/Universe.cpp:101: error: in passing argument 2 of 'short int<unnamed>::get(const<unnamed>::constant_property&, const boost::detail::edge_desc_impl<boost::undirected_tag, unsigned int>&)'


User avatar
tzlaine
Programming Lead Emeritus
Posts: 1092
Joined: Thu Jun 26, 2003 1:33 pm

Re: Issues with 'templatized' version of GG's Slider / CUISl

#4 Post by tzlaine » Sat Oct 08, 2011 2:46 pm

What compiler are you using? Neither gcc 4.1 nor gcc 4.5 give meany errors (at least regarding the Slider code).

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12482
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Issues with 'templatized' version of GG's Slider / CUISl

#5 Post by Geoff the Medio » Sat Oct 08, 2011 5:29 pm

night wrote:Thank you! That worked perfectly :D
Does this make all the necessary changes? If not, please post your own functional patch...

Code: Select all

Index: CUISlider.h
===================================================================
--- CUISlider.h	(revision 4354)
+++ CUISlider.h	(working copy)
@@ -22,21 +22,21 @@
     /** \name Mutators */ //@{
     virtual void    Render()
     {
-        const GG::Pt UL = UpperLeft();
-        const GG::Pt LR = LowerRight();
-        GG::Clr border_color_to_use = Disabled() ? GG::DisabledColor(ClientUI::CtrlBorderColor()) : ClientUI::CtrlBorderColor();
-        int tab_width = GetOrientation() == GG::VERTICAL ? Value(Tab()->Height()) : Value(Tab()->Width());
+        const GG::Pt UL = this->UpperLeft();
+        const GG::Pt LR = this->LowerRight();
+        GG::Clr border_color_to_use = this->Disabled() ? GG::DisabledColor(ClientUI::CtrlBorderColor()) : ClientUI::CtrlBorderColor();
+        int tab_width = this->GetOrientation() == GG::VERTICAL ? Value(this->Tab()->Height()) : Value(this->Tab()->Width());
         GG::Pt ul, lr;
         if (GetOrientation() == GG::VERTICAL) {
-            ul.x = ((LR.x + UL.x) - static_cast<int>(LineWidth())) / 2;
-            lr.x   = ul.x + static_cast<int>(LineWidth());
+            ul.x = ((LR.x + UL.x) - static_cast<int>(this->LineWidth())) / 2;
+            lr.x   = ul.x + static_cast<int>(this->LineWidth());
             ul.y = UL.y + tab_width / 2;
             lr.y   = LR.y - tab_width / 2;
         } else {
             ul.x = UL.x + tab_width / 2;
             lr.x   = LR.x - tab_width / 2;
-            ul.y = ((LR.y + UL.y) - static_cast<int>(LineWidth())) / 2;
-            lr.y   = ul.y + static_cast<int>(LineWidth());
+            ul.y = ((LR.y + UL.y) - static_cast<int>(this->LineWidth())) / 2;
+            lr.y   = ul.y + static_cast<int>(this->LineWidth());
         }
         GG::FlatRectangle(ul, lr, GG::CLR_ZERO, border_color_to_use, 1);
     }
@@ -45,15 +45,15 @@
     {
         Wnd::SizeMove(ul, lr);
         if (GetOrientation() == GG::VERTICAL) {
-            Tab()->Resize(GG::Pt(GG::X(TabWidth()), GG::Y(TabWidth())));
-            Tab()->MoveTo(GG::Pt((Width() - Tab()->Width()) / 2, Tab()->RelativeUpperLeft().y));
-            Tab()->SetMinSize(GG::Pt(Tab()->MinSize().x, GG::Y(10)));
+            this->Tab()->Resize(GG::Pt(GG::X(this->TabWidth()), GG::Y(this->TabWidth())));
+            this->Tab()->MoveTo(GG::Pt((this->Width() - this->Tab()->Width()) / 2, Tab()->RelativeUpperLeft().y));
+            this->Tab()->SetMinSize(GG::Pt(this->Tab()->MinSize().x, GG::Y(10)));
         } else {
-            Tab()->SizeMove(GG::Pt(GG::X(2), GG::Y0), GG::Pt(GG::X(TabWidth()), GG::Y(TabWidth())));
-            Tab()->MoveTo(GG::Pt(Tab()->RelativeUpperLeft().x, (Height() - Tab()->Height()) / 2));
-            Tab()->SetMinSize(GG::Pt(GG::X(10), Tab()->MinSize().y));
+            this->Tab()->SizeMove(GG::Pt(GG::X(2), GG::Y0), GG::Pt(GG::X(this->TabWidth()), GG::Y(this->TabWidth())));
+            this->Tab()->MoveTo(GG::Pt(this->Tab()->RelativeUpperLeft().x, this->Height() - this->Tab()->Height() / 2));
+            this->Tab()->SetMinSize(GG::Pt(GG::X(10), this->Tab()->MinSize().y));
         }
-        MoveTabToPosn();
+        this->MoveTabToPosn();
     }
     //@}
 };

night
Space Kraken
Posts: 102
Joined: Sun Jun 12, 2011 1:21 pm

Re: Issues with 'templatized' version of GG's Slider / CUISl

#6 Post by night » Sun Oct 09, 2011 8:51 am

I am using Apple's LLVM GCC4.2 Compiler.

Here's my slightly different file:

Code: Select all

--- CUISlider.h
+++ CUISlider.h
@@ -22,38 +22,38 @@
     /** \name Mutators */ //@{
     virtual void    Render()
     {
-        const GG::Pt UL = UpperLeft();
-        const GG::Pt LR = LowerRight();
-        GG::Clr border_color_to_use = Disabled() ? GG::DisabledColor(ClientUI::CtrlBorderColor()) : ClientUI::CtrlBorderColor();
-        int tab_width = GetOrientation() == GG::VERTICAL ? Value(Tab()->Height()) : Value(Tab()->Width());
+        const GG::Pt UL = this->UpperLeft();
+        const GG::Pt LR = this->LowerRight();
+        GG::Clr border_color_to_use = this->Disabled() ? GG::DisabledColor(ClientUI::CtrlBorderColor()) : ClientUI::CtrlBorderColor();
+        int tab_width = this->GetOrientation() == GG::VERTICAL ? Value(this->Tab()->Height()) : Value(this->Tab()->Width());
         GG::Pt ul, lr;
-        if (GetOrientation() == GG::VERTICAL) {
-            ul.x = ((LR.x + UL.x) - static_cast<int>(LineWidth())) / 2;
-            lr.x   = ul.x + static_cast<int>(LineWidth());
+        if (this->GetOrientation() == GG::VERTICAL) {
+            ul.x = ((LR.x + UL.x) - static_cast<int>(this->LineWidth())) / 2;
+            lr.x   = ul.x + static_cast<int>(this->LineWidth());
             ul.y = UL.y + tab_width / 2;
             lr.y   = LR.y - tab_width / 2;
         } else {
             ul.x = UL.x + tab_width / 2;
             lr.x   = LR.x - tab_width / 2;
-            ul.y = ((LR.y + UL.y) - static_cast<int>(LineWidth())) / 2;
-            lr.y   = ul.y + static_cast<int>(LineWidth());
+            ul.y = ((LR.y + UL.y) - static_cast<int>(this->LineWidth())) / 2;
+            lr.y   = ul.y + static_cast<int>(this->LineWidth());
         }
         GG::FlatRectangle(ul, lr, GG::CLR_ZERO, border_color_to_use, 1);
     }
 
     virtual void    SizeMove(const GG::Pt& ul, const GG::Pt& lr)
     {
-        Wnd::SizeMove(ul, lr);
-        if (GetOrientation() == GG::VERTICAL) {
-            Tab()->Resize(GG::Pt(GG::X(TabWidth()), GG::Y(TabWidth())));
-            Tab()->MoveTo(GG::Pt((Width() - Tab()->Width()) / 2, Tab()->RelativeUpperLeft().y));
-            Tab()->SetMinSize(GG::Pt(Tab()->MinSize().x, GG::Y(10)));
+        GG::Wnd::SizeMove(ul, lr);
+        if (this->GetOrientation() == GG::VERTICAL) {
+            this->Tab()->Resize(GG::Pt(GG::X(this->TabWidth()), GG::Y(this->TabWidth())));
+            this->Tab()->MoveTo(GG::Pt((this->Width() - this->Tab()->Width()) / 2, this->Tab()->RelativeUpperLeft().y));
+            this->Tab()->SetMinSize(GG::Pt(this->Tab()->MinSize().x, GG::Y(10)));
         } else {
-            Tab()->SizeMove(GG::Pt(GG::X(2), GG::Y0), GG::Pt(GG::X(TabWidth()), GG::Y(TabWidth())));
-            Tab()->MoveTo(GG::Pt(Tab()->RelativeUpperLeft().x, (Height() - Tab()->Height()) / 2));
-            Tab()->SetMinSize(GG::Pt(GG::X(10), Tab()->MinSize().y));
+            this->Tab()->SizeMove(GG::Pt(GG::X(2), GG::Y0), GG::Pt(GG::X(this->TabWidth()), GG::Y(this->TabWidth())));
+            this->Tab()->MoveTo(GG::Pt(this->Tab()->RelativeUpperLeft().x, (this->Height() - this->Tab()->Height()) / 2));
+            this->Tab()->SetMinSize(GG::Pt(GG::X(10), this->Tab()->MinSize().y));
         }
-        MoveTabToPosn();
+        this->MoveTabToPosn();
     }
     //@}
 };

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 12482
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: Issues with 'templatized' version of GG's Slider / CUISl

#7 Post by Geoff the Medio » Sun Oct 09, 2011 8:06 pm

night, in case you missed it, tzlaine was asking about your Boost and Universe compile problems...
tzlaine wrote:What compiler are you using? Neither gcc 4.1 nor gcc 4.5 give meany errors (at least regarding the Slider code).
I'm wondering if this patch would help?

night
Space Kraken
Posts: 102
Joined: Sun Jun 12, 2011 1:21 pm

Re: Issues with 'templatized' version of GG's Slider / CUISl

#8 Post by night » Mon Oct 10, 2011 11:44 am

Thank you - that one worked.
I should read the forums more frequently :)

Post Reply