1 //------------------------------------------------------------------------------
2 // emTunnel.h
3 //
4 // Copyright (C) 2005-2010,2014,2016 Oliver Hamann.
5 //
6 // Homepage: http://eaglemode.sourceforge.net/
7 //
8 // This program is free software: you can redistribute it and/or modify it under
9 // the terms of the GNU General Public License version 3 as published by the
10 // Free Software Foundation.
11 //
12 // This program is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU General Public License version 3 for
15 // more details.
16 //
17 // You should have received a copy of the GNU General Public License version 3
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 //------------------------------------------------------------------------------
20 
21 #ifndef emTunnel_h
22 #define emTunnel_h
23 
24 #ifndef emBorder_h
25 #include <emCore/emBorder.h>
26 #endif
27 
28 
29 //==============================================================================
30 //================================== emTunnel ==================================
31 //==============================================================================
32 
33 class emTunnel : public emBorder {
34 
35 public:
36 
37 	// This panel shows a single child panel very small. Around that, a
38 	// decoration is painted which looks like a tunnel. Therefore the name
39 	// of this class. The single child panel is laid out automatically
40 	// whenever it is created by the user of this class.
41 
42 	emTunnel(
43 		ParentArg parent, const emString & name,
44 		const emString & caption=emString(),
45 		const emString & description=emString(),
46 		const emImage & icon=emImage()
47 	);
48 		// Constructor.
49 
50 	double GetChildTallness() const;
51 	void SetChildTallness(double childTallness);
52 		// Tallness for the child panel (end of tunnel). A value <=0.0
53 		// means to take the tallness of the content rectangle. That is
54 		// the default.
55 
56 	double GetDepth() const;
57 	void SetDepth(double depth);
58 		// Depth of the tunnel. The formula is more or less:
59 		//   AreaOfEnd = AreaOfEntrance/((Depth+1)*(Depth+1))
60 		// The default is 10.0.
61 
62 	virtual void GetChildRect(
63 		double * pX, double * pY, double * pW, double * pH,
64 		emColor * pCanvasColor=NULL
65 	) const;
66 		// Get coordinates and canvas color of the end of the tunnel.
67 
68 	// - - - - - - - - - - Depreciated methods - - - - - - - - - - - - - - -
69 	// The following virtual non-const methods have been replaced by const
70 	// methods (see above). The old versions still exist here with the
71 	// "final" keyword added, so that old overridings will fail to compile.
72 	// If you run into this, please adapt your overridings by adding "const".
73 	virtual void GetChildRect(
74 		double * pX, double * pY, double * pW, double * pH,
75 		emColor * pCanvasColor=NULL
76 	) final;
77 	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
78 
79 protected:
80 
81 	virtual void PaintContent(
82 		const emPainter & painter, double x, double y, double w,
83 		double h, emColor canvasColor
84 	) const;
85 
86 	virtual void LayoutChildren();
87 
88 private:
89 
90 	enum DoTunnelFunc {
91 		TUNNEL_FUNC_PAINT,
92 		TUNNEL_FUNC_CHILD_RECT
93 	};
94 	void DoTunnel(
95 		DoTunnelFunc func, const emPainter * painter,
96 		emColor canvasColor, double * pX, double * pY, double * pW,
97 		double * pH, emColor * pCanvasColor
98 	) const;
99 
100 	double ChildTallness,Depth;
101 };
102 
GetChildTallness()103 inline double emTunnel::GetChildTallness() const
104 {
105 	return ChildTallness;
106 }
107 
GetDepth()108 inline double emTunnel::GetDepth() const
109 {
110 	return Depth;
111 }
112 
113 
114 #endif
115