Window Graphics Errors

How do I correct the following errors?:

1>------ Build started: Project: C12Window, Configuration: Debug Win32 ------
1>  Window.cpp
1>c:\users\phztfte1\documents\visual studio 2013\projects\c12window\c12window\gui.h(122): error C2228: left of '.attach' must have class/struct/union
1>          type is 'Window'
1>          did you intend to use '->' instead?
1>c:\users\phztfte1\documents\visual studio 2013\projects\c12window\c12window\window.cpp(36): error C2664: 'void Graph_lib::Widget::attach(Window &)' : cannot convert argument 1 from 'Graph_lib::Window' to 'Window &'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Here is part of GUI.h. Line 122 is boldfaced.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 struct Menu : Widget {
		enum Kind { horizontal, vertical };
		Menu(Point xy, int w, int h, Kind kk, const string& label)
			: Widget(xy, w, h, label, 0), k(kk), offset(0)
		{}

		Vector_ref<Button> selection;
		Kind k;
		int offset;
		int attach(Button& b);      // Menu does not delete &b
		int attach(Button* p);      // Menu deletes p

		void show()                 // show all buttons
		{
			for (int i = 0; i < selection.size(); ++i)
				selection[i].show();
		}
		void hide()                 // hide all buttons
		{
			for (int i = 0; i<selection.size(); ++i)
				selection[i].hide();
		}
		void move(int dx, int dy)   // move all buttons
		{
			for (int i = 0; i<selection.size(); ++i)
				selection[i].move(dx, dy);
		}

		void attach(Window& win)    // attach all buttons
		{
			for (int i = 0; i<selection.size(); ++i) win.attach(selection[i]);
			own = &win;
		}
	};



Here is Window.cpp. Line 36 is boldfaced.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "Window.h"
#include "Graph.h"
#include "GUI.h"

namespace Graph_lib {

	Window::Window(int ww, int hh, const string& title)
		:Fl_Window(ww, hh, title.c_str()), w(ww), h(hh)
	{
		init();
	}

	Window::Window(Point xy, int ww, int hh, const string& title)
		: Fl_Window(xy.x, xy.y, ww, hh, title.c_str()), w(ww), h(hh)
	{
		init();
	}

	void Window::init()
	{
		resizable(this);
		show();
	}

	//---------------------------------------------------- 

	void Window::draw()
	{
		Fl_Window::draw();
		for (unsigned int i = 0; i<shapes.size(); ++i) shapes[i]->draw();
	}

	void Window::attach(Widget& w)
	{
		begin();			// FTLK: begin attaching new Fl_Wigets to this window
		w.attach(*this);	// let the Widget create its Fl_Wigits
		end();				// FTLK: stop attaching new Fl_Wigets to this window
	}

	void Window::detach(Widget& b)
	{
		b.hide();
	}

	void Window::attach(Shape& s)
	{
		shapes.push_back(&s);
		//		s.attached = this;
	}
	void Window::detach(Shape& s)
	{
		for (unsigned int i = shapes.size(); 0<i; --i)	// guess last attached will be first released
			if (shapes[i - 1] == &s)
				shapes.erase(shapes.begin() + (i - 1));//&shapes[i-1]);
	}

//phztfte1 - changed int to size_t in line 59
	void Window::put_on_top(Shape& p) {
		for (size_t i = 0; i<shapes.size(); ++i) {
			if (&p == shapes[i]) {
				for (++i; i<shapes.size(); ++i)
					shapes[i - 1] = shapes[i];
				shapes[shapes.size() - 1] = &p;
				return;
			}
		}
	}

	int gui_main() { return Fl::run(); }

} // Graph 



Last edited on
Topic archived. No new replies allowed.