<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[...wait_for_button...]]></title><description><![CDATA[<p>Hey Leute,</p>
<p>ich möchte in VC++ 2010 ein simples leeres Fenster erzeugen.</p>
<p>Ich nutze FLTK und habe die libs auch korekt eingetragen.</p>
<p>Folgender Code funktioniert demnach einwandfrei:</p>
<pre><code>#include &lt;FL/Fl.H&gt;
#include &lt;FL/Fl_Box.H&gt;
#include &lt;FL/Fl_Window.H&gt;

int main()
{
	Fl_Window window(200,200,&quot;Fenstertitel&quot;);
	Fl_Box box(0,0,200,200,&quot;Hi Daaa&quot;);
	window.show();
	return Fl::run();
}
</code></pre>
<p>Nun möchte ich aber mit Hilfe eines Buches mit folgendem Code ein Fenster erzeugen:</p>
<pre><code>#include &quot;../../../Simple_window.h&quot;
#include &quot;../../../Graph.h&quot;
#include &quot;../../../GUI.h&quot;
#include &quot;../../../std_lib_facilities.h&quot;

int main()
{
	using namespace Graph_lib;

	Point tl(100,100);

	Simple_window win(tl,600,400,&quot;Leinwand&quot;);

	win.wait_for_button();
}
</code></pre>
<p>Die 2 angehefteten Quelldateien sehen wie folgt aus:</p>
<p>Graph.cpp:</p>
<pre><code>#include &lt;FL/Fl_GIF_Image.H&gt;
#include &lt;FL/Fl_JPEG_Image.H&gt;
#include &quot;Graph.h&quot;

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

namespace Graph_lib {

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

Shape::Shape() : 
    lcolor(fl_color()),      // Standardfarbe für Linien und Zeichen
    ls(0),                   // Standardstil
    fcolor(Color::invisible) // keine Füllung
{}

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

void Shape::add(Point p)     // ist als protected deklariert 
{
    points.push_back(p);
}

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

void Shape::set_point(int i,Point p)        // wird nicht verwendet; bisher nicht nötig
{
    points[i] = p;
}

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

void Shape::draw_lines() const
{
    if (color().visibility() &amp;&amp; 1&lt;points.size())    // einzelnen Pixel zeichnen?
        for (unsigned int i=1; i&lt;points.size(); ++i)
            fl_line(points[i-1].x,points[i-1].y,points[i].x,points[i].y);
}

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

void Shape::draw() const
{
    Fl_Color oldc = fl_color();
    // leider gibt es keinen wirklich guten, portablen Weg den aktuellen Stil wiederherzustellen
    fl_color(lcolor.as_int());            //Farbe festlegen
    fl_line_style(ls.style(),ls.width()); // Stil festlegen
    draw_lines();
    fl_color(oldc);      // (alte) Farbe wiederherstellen (to previous)
    fl_line_style(0);    // (Standard-)Linienstil wiederherstellen 
}

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

void Shape::move(int dx, int dy)    // verschiebe die Form um +=dx und +=dy
{
    for (int i = 0; i&lt;points.size(); ++i) {
        points[i].x+=dx;
        points[i].y+=dy;
    }
}

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

Line::Line(Point p1, Point p2)    // erzeuge aus zwei Punkten ein Line-Objekt
{
    add(p1);    // füge p1 zu dieser Form hinzu
    add(p2);    // füge p2 zu dieser Form hinzu
}

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

void Lines::add(Point p1, Point p2)
{
    Shape::add(p1);
    Shape::add(p2);
}

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

// zeichne Verbindungslinien zwischen Punktepaaren
void Lines::draw_lines() const
{
    if (color().visibility())
        for (int i=1; i&lt;number_of_points(); i+=2)
            fl_line(point(i-1).x,point(i-1).y,point(i).x,point(i).y);
}

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

//schneiden sich die beiden Linien (p1,p2) und (p3,p4) ?
// Wenn ja, liefere den Abstand des Schnittpunkts als Abstand von p1 zurück
inline pair&lt;double,double&gt; line_intersect(Point p1, Point p2, Point p3, Point p4, bool&amp; parallel) 
{
    double x1 = p1.x;
    double x2 = p2.x;
    double x3 = p3.x;
    double x4 = p4.x;
    double y1 = p1.y;
    double y2 = p2.y;
    double y3 = p3.y;
    double y4 = p4.y;

    double denom = ((y4 - y3)*(x2-x1) - (x4-x3)*(y2-y1));
    if (denom == 0){
        parallel= true;
        return pair&lt;double,double&gt;(0,0);
    }
    parallel = false;
    return pair&lt;double,double&gt;( ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3))/denom,
                                ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3))/denom);
}

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

//Schnitt zwischen zwei Liniensegmenten
//Liefert true, wenn sich die beiden Liniensegmente schneiden,
//in diesem Fall wird der Schnittpunkt in intersection gespeichert
bool line_segment_intersect(Point p1, Point p2, Point p3, Point p4, Point&amp; intersection){
   bool parallel;
   pair&lt;double,double&gt; u = line_intersect(p1,p2,p3,p4,parallel);
   if (parallel || u.first &lt; 0 || u.first &gt; 1 || u.second &lt; 0 || u.second &gt; 1) return false;
   intersection.x = p1.x + u.first*(p2.x - p1.x);
   intersection.y = p1.y + u.first*(p2.y - p1.y);
   return true;
}

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

void Polygon::add(Point p)
{
    int np = number_of_points();

    if (1&lt;np) {    // sicherstellen, dass die neue Linie nicht parallel zu einer anderen Linie ist
        if (p==point(np-1)) error(&quot;Polygonpunkt ist identisch zu letztem Punkt&quot;);
        bool parallel;
        line_intersect(point(np-1),p,point(np-2),point(np-1),parallel);
        if (parallel)
            error(&quot;Zwei Polygonpunkte liegen auf einer Linie&quot;);
    }

    for (int i = 1; i&lt;np-1; ++i) {    // sicherstellen, dass sich das neue Segment  nicht mit einer bestehenden Linie schneidet 
        Point ignore(0,0);
        if (line_segment_intersect(point(np-1),p,point(i-1),point(i),ignore))
            error(&quot;Poylgonlinien schneiden sich&quot;);
    }

    Closed_polyline::add(p);
}

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

void Polygon::draw_lines() const
{
    if (number_of_points() &lt; 3) error(&quot;weniger als 3 Punkte in Polygon&quot;);
    Closed_polyline::draw_lines();
}

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

void Open_polyline::draw_lines() const
{
    if (fill_color().visibility()) {
        fl_color(fill_color().as_int());
        fl_begin_complex_polygon();
        for(int i=0; i&lt;number_of_points(); ++i){
            fl_vertex(point(i).x, point(i).y);
        }
        fl_end_complex_polygon();
        fl_color(color().as_int());    // Farbe zurücksetzen
    }

    if (color().visibility())
        Shape::draw_lines();
}

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

void Closed_polyline::draw_lines() const
{
    Open_polyline::draw_lines();    // zeichne zuerst den &quot;offenen&quot; Teil des Linienzugs
    // dann zeichne die schließende Linie:
    if (color().visibility())
        fl_line(point(number_of_points()-1).x, 
        point(number_of_points()-1).y,
        point(0).x,
        point(0).y);
}

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

void draw_mark(Point xy, char c)
{
    static const int dx = 4;
    static const int dy = 4;

    string m(1,c);
    fl_draw(m.c_str(),xy.x-dx,xy.y+dy);
}

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

void Marked_polyline::draw_lines() const
{
    Open_polyline::draw_lines();
    for (int i=0; i&lt;number_of_points(); ++i) 
        draw_mark(point(i),mark[i%mark.size()]);
}

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

void Rectangle::draw_lines() const
{
    if (fill_color().visibility()) {    //füllen
        fl_color(fill_color().as_int());
        fl_rectf(point(0).x,point(0).y,w,h);
    }

    if (color().visibility()) {    // Linien über Füllung anzeigen
        fl_color(color().as_int());
        fl_rect(point(0).x,point(0).y,w,h);
    }
}

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

Circle::Circle(Point p, int rr)    // Mittelpunkt und Radius
:r(rr)
{
    add(Point(p.x-r,p.y-r));       // speichere die linke obere Ecke
}

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

Point Circle::center() const
{
    return Point(point(0).x+r, point(0).y+r);
}

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

void Circle::draw_lines() const
{
    if (color().visibility())
        fl_arc(point(0).x,point(0).y,r+r,r+r,0,360);
}

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

void Ellipse::draw_lines() const
{
    if (color().visibility())
        fl_arc(point(0).x,point(0).y,w+w,h+h,0,360);
}

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

void Text::draw_lines() const
{
    int ofnt = fl_font();
    int osz = fl_size();
    fl_font(fnt.as_int(),fnt_sz);
    fl_draw(lab.c_str(),point(0).x,point(0).y);
    fl_font(ofnt,osz);
}

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

Axis::Axis(Orientation d, Point xy, int length, int n, string lab) :
    label(Point(0,0),lab)
{
    if (length&lt;0) error(&quot;ungueltige Achsenlaenge&quot;);
    switch (d){
    case Axis::x:
    {
        Shape::add(xy); // Achsenlinie
        Shape::add(Point(xy.x+length,xy.y));

        if (1&lt;n) {      // Skalenstriche hinzufügen
            int dist = length/n;
            int x = xy.x+dist;
            for (int i = 0; i&lt;n; ++i) {
                notches.add(Point(x,xy.y),Point(x,xy.y-5));
                x += dist;
            }
        }
        // Beschriftung unter der Linie
        label.move(length/3,xy.y+20);
        break;
    }
    case Axis::y:
    {
        Shape::add(xy); //die y-Achse steht senkrecht
        Shape::add(Point(xy.x,xy.y-length));

        if (1&lt;n) {      // Skalenstriche hinzufügen
            int dist = length/n;
            int y = xy.y-dist;
            for (int i = 0; i&lt;n; ++i) {
                notches.add(Point(xy.x,y),Point(xy.x+5,y));
                y -= dist;
            }
        }
        // Beschriftung am oberen Ende
        label.move(xy.x-10,xy.y-length-10);
        break;
    }
    case Axis::z:
        error(&quot;z-Achse ist nicht implementiert&quot;);
    }
}

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

void Axis::draw_lines() const
{
    Shape::draw_lines();
    notches.draw();   // die Skalenstriche können eine eigene Farbe verwenden 
    label.draw();     // die Beschriftung kann eine eigene Farbe verwenden
}

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

void Axis::set_color(Color c)
{
    Shape::set_color(c);
    notches.set_color(c);
    label.set_color(c);
}

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

void Axis::move(int dx, int dy)
{
    Shape::move(dx,dy);
    notches.move(dx,dy);
    label.move(dx,dy);
}

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

Function::Function(Fct f, double r1, double r2, Point xy,
                   int count, double xscale, double yscale)
// erzeugt Graph f(x) für x in [r1:r2) mithilfe von count Liniensegmenten. 
// (0,0) liegt auf dem Punkt xy
// x-Koordinaten werden mit xscale, y-Koordinaten mit yscale skaliert
{
    if (r2-r1&lt;=0) error(&quot;ungueltiger Bereich fuer Graphen&quot;);
    if (count &lt;=0) error(&quot;Anzahl Liniensegmente null oder negativ&quot;);
    double dist = (r2-r1)/count;
    double r = r1;
    for (int i = 0; i&lt;count; ++i) {
        add(Point(xy.x+int(r*xscale),xy.y-int(f(r)*yscale)));
        r += dist;
    }
}

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

bool can_open(const string&amp; s)
// prüfe, ob eine Datei namens s existiert und zum Lesen geöffnet werden kann
{
    ifstream ff(s.c_str());
    return ff;
}

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

#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))

Suffix::Encoding get_encoding(const string&amp; s)
{
    struct SuffixMap 
    { 
        const char*      extension;
        Suffix::Encoding suffix;
    };

    static SuffixMap smap[] = {
        {&quot;.jpg&quot;,  Suffix::jpg},
        {&quot;.jpeg&quot;, Suffix::jpg},
        {&quot;.gif&quot;,  Suffix::gif},
    };

    for (int i = 0, n = ARRAY_SIZE(smap); i &lt; n; i++)
    {
        int len = strlen(smap[i].extension);

        if (s.length() &gt;= len &amp;&amp; s.substr(s.length()-len, len) == smap[i].extension)
            return smap[i].suffix;
    }

    return Suffix::none;
}

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

// besonders sorgfältig ausgearbeiteter Konstruktor (aber Fehler in
// Verbindung mit Bilddateien können so schwierig zu debuggen sein)
Image::Image(Point xy, string s, Suffix::Encoding e)
    :w(0), h(0), fn(xy,&quot;&quot;)
{
    add(xy);

    if (!can_open(s)) {    // können wir s öffnen?
        fn.set_label(&quot;nicht zu öffnen: \&quot;&quot;+s+'\&quot;');
        p = new Bad_image(30,20);    // das &quot;Fehler&quot;-Bild
        return;
    }

    if (e == Suffix::none) e = get_encoding(s);

    switch(e) {        // liegt eine bekannte Codierung vor?
    case Suffix::jpg:
        p = new Fl_JPEG_Image(s.c_str());
        break;
    case Suffix::gif:
        p = new Fl_GIF_Image(s.c_str());
        break;
    default:    // nicht unterstützte Bild-Codierung
        fn.set_label(&quot;nicht unterstützter Dateityp \&quot;&quot;+s+'\&quot;');
        p = new Bad_image(30,20);    // das &quot;Fehler&quot;-Bild
    }
}

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

void Image::draw_lines() const
{
    if (fn.label()!=&quot;&quot;) fn.draw_lines();

    if (w&amp;&amp;h)
        p-&gt;draw(point(0).x,point(0).y,w,h,cx,cy);
    else
        p-&gt;draw(point(0).x,point(0).y);
}

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

} //von Namensbereich Graph_lib
</code></pre>
<p>Window.cpp:</p>
<pre><code>#include &quot;Window.h&quot;
#include &quot;Graph.h&quot;
#include &quot;GUI.h&quot;

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

namespace Graph_lib {

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

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

Window::Window(Point xy, int ww, int hh, const string&amp; 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&lt;shapes.size(); ++i) shapes[i]-&gt;draw();
}

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

void Window::attach(Widget&amp; w)
{
    begin();         // FTLK: beginne damit neue  Fl_Wigets mit diesem Fenster zu verbinden
    w.attach(*this); // lass das Fenster seine Fl_Wigits erzeugen
    end();           // FTLK: das Verbinden neuer Fl_Wigets mit diesem Fenster beenden
}

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

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

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

void Window::detach(Shape&amp; s)
    // die zuletzt verbundene Form wird als Erstes freigegeben
{
    for (unsigned int i = shapes.size(); 0&lt;i; --i)    
        if (shapes[i-1]==&amp;s)
            shapes.erase(shapes.begin()+(i-1));
}

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

void Window::put_on_top(Shape&amp; p) {
    for (int i=0; i&lt;shapes.size(); ++i) {
        if (&amp;p==shapes[i]) {
            for (++i; i&lt;shapes.size(); ++i)
                shapes[i-1] = shapes[i];
            shapes[shapes.size()-1] = &amp;p;
            return;
        }
    }
}

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

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

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

}; //von Namensbereich Graph_lib
</code></pre>
<p>Ich bekomme 3 Fehler:</p>
<blockquote>
<p>Fehler 10 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: bool __thiscall Simple_window::wait_for_button(void)&quot; (?wait_for_button@Simple_window@@QAE_NXZ)&quot; in Funktion &quot;_main&quot;. C:\Users\Alexander\Documents\Visual Studio 2010\Projects\Buch\Buch\Main.obj<br />
Fehler 11 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: __thiscall Simple_window::Simple_window(struct Point,int,int,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;)&quot; (??0Simple_window@@QAE@UPoint@@HHABV?<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>b</mi><mi>a</mi><mi>s</mi><mi>i</mi><mi>c</mi><mi mathvariant="normal">_</mi><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi mathvariant="normal">@</mi><mi>D</mi><mi>U</mi><mo>?</mo></mrow><annotation encoding="application/x-tex">basic\_string@DU?</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:1.00444em;vertical-align:-0.31em;"></span><span class="base textstyle uncramped"><span class="mord mathit">b</span><span class="mord mathit">a</span><span class="mord mathit">s</span><span class="mord mathit">i</span><span class="mord mathit">c</span><span class="mord mathrm" style="margin-right:0.02778em;">_</span><span class="mord mathit">s</span><span class="mord mathit">t</span><span class="mord mathit" style="margin-right:0.02778em;">r</span><span class="mord mathit">i</span><span class="mord mathit">n</span><span class="mord mathit" style="margin-right:0.03588em;">g</span><span class="mord mathrm">@</span><span class="mord mathit" style="margin-right:0.02778em;">D</span><span class="mord mathit" style="margin-right:0.10903em;">U</span><span class="mclose">?</span></span></span></span>char_traits@D@std@@V?$allocator@D@2@@std@@@Z)&quot; in Funktion &quot;_main&quot;. C:\Users\Alexander\Documents\Visual Studio 2010\Projects\Buch\Buch\Main.obj<br />
Fehler 12 error LNK1120: 2 nicht aufgelöste externe Verweise. C:\Users\Alexander\Documents\Visual Studio 2010\Projects\Buch\Debug\Buch.exe</p>
</blockquote>
<p>Das &quot;win.wait_for_button()&quot; macht i-wie Probleme meiner Meinung nach</p>
<p>Wie ist das zu lösen?</p>
<p>Danke schonmal im Vorraus</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/297436/wait_for_button</link><generator>RSS for Node</generator><lastBuildDate>Fri, 14 Aug 2026 10:58:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/297436.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 28 Dec 2011 16:35:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ...wait_for_button... on Wed, 28 Dec 2011 16:35:16 GMT]]></title><description><![CDATA[<p>Hey Leute,</p>
<p>ich möchte in VC++ 2010 ein simples leeres Fenster erzeugen.</p>
<p>Ich nutze FLTK und habe die libs auch korekt eingetragen.</p>
<p>Folgender Code funktioniert demnach einwandfrei:</p>
<pre><code>#include &lt;FL/Fl.H&gt;
#include &lt;FL/Fl_Box.H&gt;
#include &lt;FL/Fl_Window.H&gt;

int main()
{
	Fl_Window window(200,200,&quot;Fenstertitel&quot;);
	Fl_Box box(0,0,200,200,&quot;Hi Daaa&quot;);
	window.show();
	return Fl::run();
}
</code></pre>
<p>Nun möchte ich aber mit Hilfe eines Buches mit folgendem Code ein Fenster erzeugen:</p>
<pre><code>#include &quot;../../../Simple_window.h&quot;
#include &quot;../../../Graph.h&quot;
#include &quot;../../../GUI.h&quot;
#include &quot;../../../std_lib_facilities.h&quot;

int main()
{
	using namespace Graph_lib;

	Point tl(100,100);

	Simple_window win(tl,600,400,&quot;Leinwand&quot;);

	win.wait_for_button();
}
</code></pre>
<p>Die 2 angehefteten Quelldateien sehen wie folgt aus:</p>
<p>Graph.cpp:</p>
<pre><code>#include &lt;FL/Fl_GIF_Image.H&gt;
#include &lt;FL/Fl_JPEG_Image.H&gt;
#include &quot;Graph.h&quot;

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

namespace Graph_lib {

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

Shape::Shape() : 
    lcolor(fl_color()),      // Standardfarbe für Linien und Zeichen
    ls(0),                   // Standardstil
    fcolor(Color::invisible) // keine Füllung
{}

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

void Shape::add(Point p)     // ist als protected deklariert 
{
    points.push_back(p);
}

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

void Shape::set_point(int i,Point p)        // wird nicht verwendet; bisher nicht nötig
{
    points[i] = p;
}

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

void Shape::draw_lines() const
{
    if (color().visibility() &amp;&amp; 1&lt;points.size())    // einzelnen Pixel zeichnen?
        for (unsigned int i=1; i&lt;points.size(); ++i)
            fl_line(points[i-1].x,points[i-1].y,points[i].x,points[i].y);
}

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

void Shape::draw() const
{
    Fl_Color oldc = fl_color();
    // leider gibt es keinen wirklich guten, portablen Weg den aktuellen Stil wiederherzustellen
    fl_color(lcolor.as_int());            //Farbe festlegen
    fl_line_style(ls.style(),ls.width()); // Stil festlegen
    draw_lines();
    fl_color(oldc);      // (alte) Farbe wiederherstellen (to previous)
    fl_line_style(0);    // (Standard-)Linienstil wiederherstellen 
}

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

void Shape::move(int dx, int dy)    // verschiebe die Form um +=dx und +=dy
{
    for (int i = 0; i&lt;points.size(); ++i) {
        points[i].x+=dx;
        points[i].y+=dy;
    }
}

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

Line::Line(Point p1, Point p2)    // erzeuge aus zwei Punkten ein Line-Objekt
{
    add(p1);    // füge p1 zu dieser Form hinzu
    add(p2);    // füge p2 zu dieser Form hinzu
}

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

void Lines::add(Point p1, Point p2)
{
    Shape::add(p1);
    Shape::add(p2);
}

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

// zeichne Verbindungslinien zwischen Punktepaaren
void Lines::draw_lines() const
{
    if (color().visibility())
        for (int i=1; i&lt;number_of_points(); i+=2)
            fl_line(point(i-1).x,point(i-1).y,point(i).x,point(i).y);
}

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

//schneiden sich die beiden Linien (p1,p2) und (p3,p4) ?
// Wenn ja, liefere den Abstand des Schnittpunkts als Abstand von p1 zurück
inline pair&lt;double,double&gt; line_intersect(Point p1, Point p2, Point p3, Point p4, bool&amp; parallel) 
{
    double x1 = p1.x;
    double x2 = p2.x;
    double x3 = p3.x;
    double x4 = p4.x;
    double y1 = p1.y;
    double y2 = p2.y;
    double y3 = p3.y;
    double y4 = p4.y;

    double denom = ((y4 - y3)*(x2-x1) - (x4-x3)*(y2-y1));
    if (denom == 0){
        parallel= true;
        return pair&lt;double,double&gt;(0,0);
    }
    parallel = false;
    return pair&lt;double,double&gt;( ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3))/denom,
                                ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3))/denom);
}

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

//Schnitt zwischen zwei Liniensegmenten
//Liefert true, wenn sich die beiden Liniensegmente schneiden,
//in diesem Fall wird der Schnittpunkt in intersection gespeichert
bool line_segment_intersect(Point p1, Point p2, Point p3, Point p4, Point&amp; intersection){
   bool parallel;
   pair&lt;double,double&gt; u = line_intersect(p1,p2,p3,p4,parallel);
   if (parallel || u.first &lt; 0 || u.first &gt; 1 || u.second &lt; 0 || u.second &gt; 1) return false;
   intersection.x = p1.x + u.first*(p2.x - p1.x);
   intersection.y = p1.y + u.first*(p2.y - p1.y);
   return true;
}

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

void Polygon::add(Point p)
{
    int np = number_of_points();

    if (1&lt;np) {    // sicherstellen, dass die neue Linie nicht parallel zu einer anderen Linie ist
        if (p==point(np-1)) error(&quot;Polygonpunkt ist identisch zu letztem Punkt&quot;);
        bool parallel;
        line_intersect(point(np-1),p,point(np-2),point(np-1),parallel);
        if (parallel)
            error(&quot;Zwei Polygonpunkte liegen auf einer Linie&quot;);
    }

    for (int i = 1; i&lt;np-1; ++i) {    // sicherstellen, dass sich das neue Segment  nicht mit einer bestehenden Linie schneidet 
        Point ignore(0,0);
        if (line_segment_intersect(point(np-1),p,point(i-1),point(i),ignore))
            error(&quot;Poylgonlinien schneiden sich&quot;);
    }

    Closed_polyline::add(p);
}

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

void Polygon::draw_lines() const
{
    if (number_of_points() &lt; 3) error(&quot;weniger als 3 Punkte in Polygon&quot;);
    Closed_polyline::draw_lines();
}

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

void Open_polyline::draw_lines() const
{
    if (fill_color().visibility()) {
        fl_color(fill_color().as_int());
        fl_begin_complex_polygon();
        for(int i=0; i&lt;number_of_points(); ++i){
            fl_vertex(point(i).x, point(i).y);
        }
        fl_end_complex_polygon();
        fl_color(color().as_int());    // Farbe zurücksetzen
    }

    if (color().visibility())
        Shape::draw_lines();
}

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

void Closed_polyline::draw_lines() const
{
    Open_polyline::draw_lines();    // zeichne zuerst den &quot;offenen&quot; Teil des Linienzugs
    // dann zeichne die schließende Linie:
    if (color().visibility())
        fl_line(point(number_of_points()-1).x, 
        point(number_of_points()-1).y,
        point(0).x,
        point(0).y);
}

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

void draw_mark(Point xy, char c)
{
    static const int dx = 4;
    static const int dy = 4;

    string m(1,c);
    fl_draw(m.c_str(),xy.x-dx,xy.y+dy);
}

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

void Marked_polyline::draw_lines() const
{
    Open_polyline::draw_lines();
    for (int i=0; i&lt;number_of_points(); ++i) 
        draw_mark(point(i),mark[i%mark.size()]);
}

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

void Rectangle::draw_lines() const
{
    if (fill_color().visibility()) {    //füllen
        fl_color(fill_color().as_int());
        fl_rectf(point(0).x,point(0).y,w,h);
    }

    if (color().visibility()) {    // Linien über Füllung anzeigen
        fl_color(color().as_int());
        fl_rect(point(0).x,point(0).y,w,h);
    }
}

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

Circle::Circle(Point p, int rr)    // Mittelpunkt und Radius
:r(rr)
{
    add(Point(p.x-r,p.y-r));       // speichere die linke obere Ecke
}

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

Point Circle::center() const
{
    return Point(point(0).x+r, point(0).y+r);
}

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

void Circle::draw_lines() const
{
    if (color().visibility())
        fl_arc(point(0).x,point(0).y,r+r,r+r,0,360);
}

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

void Ellipse::draw_lines() const
{
    if (color().visibility())
        fl_arc(point(0).x,point(0).y,w+w,h+h,0,360);
}

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

void Text::draw_lines() const
{
    int ofnt = fl_font();
    int osz = fl_size();
    fl_font(fnt.as_int(),fnt_sz);
    fl_draw(lab.c_str(),point(0).x,point(0).y);
    fl_font(ofnt,osz);
}

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

Axis::Axis(Orientation d, Point xy, int length, int n, string lab) :
    label(Point(0,0),lab)
{
    if (length&lt;0) error(&quot;ungueltige Achsenlaenge&quot;);
    switch (d){
    case Axis::x:
    {
        Shape::add(xy); // Achsenlinie
        Shape::add(Point(xy.x+length,xy.y));

        if (1&lt;n) {      // Skalenstriche hinzufügen
            int dist = length/n;
            int x = xy.x+dist;
            for (int i = 0; i&lt;n; ++i) {
                notches.add(Point(x,xy.y),Point(x,xy.y-5));
                x += dist;
            }
        }
        // Beschriftung unter der Linie
        label.move(length/3,xy.y+20);
        break;
    }
    case Axis::y:
    {
        Shape::add(xy); //die y-Achse steht senkrecht
        Shape::add(Point(xy.x,xy.y-length));

        if (1&lt;n) {      // Skalenstriche hinzufügen
            int dist = length/n;
            int y = xy.y-dist;
            for (int i = 0; i&lt;n; ++i) {
                notches.add(Point(xy.x,y),Point(xy.x+5,y));
                y -= dist;
            }
        }
        // Beschriftung am oberen Ende
        label.move(xy.x-10,xy.y-length-10);
        break;
    }
    case Axis::z:
        error(&quot;z-Achse ist nicht implementiert&quot;);
    }
}

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

void Axis::draw_lines() const
{
    Shape::draw_lines();
    notches.draw();   // die Skalenstriche können eine eigene Farbe verwenden 
    label.draw();     // die Beschriftung kann eine eigene Farbe verwenden
}

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

void Axis::set_color(Color c)
{
    Shape::set_color(c);
    notches.set_color(c);
    label.set_color(c);
}

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

void Axis::move(int dx, int dy)
{
    Shape::move(dx,dy);
    notches.move(dx,dy);
    label.move(dx,dy);
}

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

Function::Function(Fct f, double r1, double r2, Point xy,
                   int count, double xscale, double yscale)
// erzeugt Graph f(x) für x in [r1:r2) mithilfe von count Liniensegmenten. 
// (0,0) liegt auf dem Punkt xy
// x-Koordinaten werden mit xscale, y-Koordinaten mit yscale skaliert
{
    if (r2-r1&lt;=0) error(&quot;ungueltiger Bereich fuer Graphen&quot;);
    if (count &lt;=0) error(&quot;Anzahl Liniensegmente null oder negativ&quot;);
    double dist = (r2-r1)/count;
    double r = r1;
    for (int i = 0; i&lt;count; ++i) {
        add(Point(xy.x+int(r*xscale),xy.y-int(f(r)*yscale)));
        r += dist;
    }
}

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

bool can_open(const string&amp; s)
// prüfe, ob eine Datei namens s existiert und zum Lesen geöffnet werden kann
{
    ifstream ff(s.c_str());
    return ff;
}

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

#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))

Suffix::Encoding get_encoding(const string&amp; s)
{
    struct SuffixMap 
    { 
        const char*      extension;
        Suffix::Encoding suffix;
    };

    static SuffixMap smap[] = {
        {&quot;.jpg&quot;,  Suffix::jpg},
        {&quot;.jpeg&quot;, Suffix::jpg},
        {&quot;.gif&quot;,  Suffix::gif},
    };

    for (int i = 0, n = ARRAY_SIZE(smap); i &lt; n; i++)
    {
        int len = strlen(smap[i].extension);

        if (s.length() &gt;= len &amp;&amp; s.substr(s.length()-len, len) == smap[i].extension)
            return smap[i].suffix;
    }

    return Suffix::none;
}

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

// besonders sorgfältig ausgearbeiteter Konstruktor (aber Fehler in
// Verbindung mit Bilddateien können so schwierig zu debuggen sein)
Image::Image(Point xy, string s, Suffix::Encoding e)
    :w(0), h(0), fn(xy,&quot;&quot;)
{
    add(xy);

    if (!can_open(s)) {    // können wir s öffnen?
        fn.set_label(&quot;nicht zu öffnen: \&quot;&quot;+s+'\&quot;');
        p = new Bad_image(30,20);    // das &quot;Fehler&quot;-Bild
        return;
    }

    if (e == Suffix::none) e = get_encoding(s);

    switch(e) {        // liegt eine bekannte Codierung vor?
    case Suffix::jpg:
        p = new Fl_JPEG_Image(s.c_str());
        break;
    case Suffix::gif:
        p = new Fl_GIF_Image(s.c_str());
        break;
    default:    // nicht unterstützte Bild-Codierung
        fn.set_label(&quot;nicht unterstützter Dateityp \&quot;&quot;+s+'\&quot;');
        p = new Bad_image(30,20);    // das &quot;Fehler&quot;-Bild
    }
}

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

void Image::draw_lines() const
{
    if (fn.label()!=&quot;&quot;) fn.draw_lines();

    if (w&amp;&amp;h)
        p-&gt;draw(point(0).x,point(0).y,w,h,cx,cy);
    else
        p-&gt;draw(point(0).x,point(0).y);
}

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

} //von Namensbereich Graph_lib
</code></pre>
<p>Window.cpp:</p>
<pre><code>#include &quot;Window.h&quot;
#include &quot;Graph.h&quot;
#include &quot;GUI.h&quot;

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

namespace Graph_lib {

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

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

Window::Window(Point xy, int ww, int hh, const string&amp; 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&lt;shapes.size(); ++i) shapes[i]-&gt;draw();
}

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

void Window::attach(Widget&amp; w)
{
    begin();         // FTLK: beginne damit neue  Fl_Wigets mit diesem Fenster zu verbinden
    w.attach(*this); // lass das Fenster seine Fl_Wigits erzeugen
    end();           // FTLK: das Verbinden neuer Fl_Wigets mit diesem Fenster beenden
}

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

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

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

void Window::detach(Shape&amp; s)
    // die zuletzt verbundene Form wird als Erstes freigegeben
{
    for (unsigned int i = shapes.size(); 0&lt;i; --i)    
        if (shapes[i-1]==&amp;s)
            shapes.erase(shapes.begin()+(i-1));
}

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

void Window::put_on_top(Shape&amp; p) {
    for (int i=0; i&lt;shapes.size(); ++i) {
        if (&amp;p==shapes[i]) {
            for (++i; i&lt;shapes.size(); ++i)
                shapes[i-1] = shapes[i];
            shapes[shapes.size()-1] = &amp;p;
            return;
        }
    }
}

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

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

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

}; //von Namensbereich Graph_lib
</code></pre>
<p>Ich bekomme 3 Fehler:</p>
<blockquote>
<p>Fehler 10 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: bool __thiscall Simple_window::wait_for_button(void)&quot; (?wait_for_button@Simple_window@@QAE_NXZ)&quot; in Funktion &quot;_main&quot;. C:\Users\Alexander\Documents\Visual Studio 2010\Projects\Buch\Buch\Main.obj<br />
Fehler 11 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;public: __thiscall Simple_window::Simple_window(struct Point,int,int,class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;)&quot; (??0Simple_window@@QAE@UPoint@@HHABV?<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>b</mi><mi>a</mi><mi>s</mi><mi>i</mi><mi>c</mi><mi mathvariant="normal">_</mi><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi mathvariant="normal">@</mi><mi>D</mi><mi>U</mi><mo>?</mo></mrow><annotation encoding="application/x-tex">basic\_string@DU?</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:1.00444em;vertical-align:-0.31em;"></span><span class="base textstyle uncramped"><span class="mord mathit">b</span><span class="mord mathit">a</span><span class="mord mathit">s</span><span class="mord mathit">i</span><span class="mord mathit">c</span><span class="mord mathrm" style="margin-right:0.02778em;">_</span><span class="mord mathit">s</span><span class="mord mathit">t</span><span class="mord mathit" style="margin-right:0.02778em;">r</span><span class="mord mathit">i</span><span class="mord mathit">n</span><span class="mord mathit" style="margin-right:0.03588em;">g</span><span class="mord mathrm">@</span><span class="mord mathit" style="margin-right:0.02778em;">D</span><span class="mord mathit" style="margin-right:0.10903em;">U</span><span class="mclose">?</span></span></span></span>char_traits@D@std@@V?$allocator@D@2@@std@@@Z)&quot; in Funktion &quot;_main&quot;. C:\Users\Alexander\Documents\Visual Studio 2010\Projects\Buch\Buch\Main.obj<br />
Fehler 12 error LNK1120: 2 nicht aufgelöste externe Verweise. C:\Users\Alexander\Documents\Visual Studio 2010\Projects\Buch\Debug\Buch.exe</p>
</blockquote>
<p>Das &quot;win.wait_for_button()&quot; macht i-wie Probleme meiner Meinung nach</p>
<p>Wie ist das zu lösen?</p>
<p>Danke schonmal im Vorraus</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2161561</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2161561</guid><dc:creator><![CDATA[Noob_der_Ersten_Stunde]]></dc:creator><pubDate>Wed, 28 Dec 2011 16:35:16 GMT</pubDate></item><item><title><![CDATA[Reply to ...wait_for_button... on Wed, 28 Dec 2011 16:49:05 GMT]]></title><description><![CDATA[<p>Dir fehlt aber noch die Klasse für Simple_Window. In Window.cpp ist nur die Klasse Window drin (anscheinend die Basisklasse von Simple_Window).<br />
Such mal nach Simple_Window.cpp und binde diese ebenfalls in dein Projekt ein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2161563</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2161563</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Wed, 28 Dec 2011 16:49:05 GMT</pubDate></item><item><title><![CDATA[Reply to ...wait_for_button... on Wed, 28 Dec 2011 17:51:43 GMT]]></title><description><![CDATA[<p>Danke, hab ich gemacht, jetzt kommt nur noch folgender Fehler:</p>
<blockquote>
<p>Fehler 18 error LNK2001: Nicht aufgelöstes externes Symbol &quot;&quot;public: virtual void __thiscall Graph_lib::Button::attach(class Graph_lib::Window &amp;)&quot; (?attach@Button@Graph_lib@@UAEXAAVWindow@2@@Z)&quot;. C:\Users\Alexander\Documents\Visual Studio 2010\Projects\Buch\Buch\Simple_window.obj</p>
</blockquote>
<p>Woran kann das liegen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2161575</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2161575</guid><dc:creator><![CDATA[Noob_der_Ersten_Stunde]]></dc:creator><pubDate>Wed, 28 Dec 2011 17:51:43 GMT</pubDate></item><item><title><![CDATA[Reply to ...wait_for_button... on Wed, 28 Dec 2011 18:48:29 GMT]]></title><description><![CDATA[<p>Sonst klappt alles nur der letzte Fehler noch, das wärs dann</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2161590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2161590</guid><dc:creator><![CDATA[Noob_der_Ersten_Stunde]]></dc:creator><pubDate>Wed, 28 Dec 2011 18:48:29 GMT</pubDate></item><item><title><![CDATA[Reply to ...wait_for_button... on Wed, 28 Dec 2011 20:46:26 GMT]]></title><description><![CDATA[<p>Ich brauche eure Hilfe wirklich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2161639</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2161639</guid><dc:creator><![CDATA[Noob_der_Ersten_Stunde]]></dc:creator><pubDate>Wed, 28 Dec 2011 20:46:26 GMT</pubDate></item><item><title><![CDATA[Reply to ...wait_for_button... on Wed, 28 Dec 2011 20:54:26 GMT]]></title><description><![CDATA[<p>Noob_der_Ersten_Stunde schrieb:</p>
<blockquote>
<p>Ich brauche eure Hilfe wirklich <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
</blockquote>
<p>komisch.. du bist im falschen forum und hast nach fast 3 stunden noch immer keine antwort bekommen... wirst du wohl noch einmal schreiben müssen, dass du hilfe braucht; hier ist 3 'ne unglückszahl. da wird niemand drauf antworten !</p>
<p>edit: zeig mal simple_window</p>
<p>header und source</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2161640</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2161640</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Wed, 28 Dec 2011 20:54:26 GMT</pubDate></item><item><title><![CDATA[Reply to ...wait_for_button... on Wed, 28 Dec 2011 21:21:01 GMT]]></title><description><![CDATA[<p>Wenn du schon im falschen Forum schreibst, dann habe wenigstens die Geduld, bis ein Mod es sieht und dich verschiebt, anstatt rumzuspammen. So provozierst du bloß die Moderatoren. Zum Beispiel mich, der ich Gespamme und Genörgel gar nicht mag. /closed</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2161648</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2161648</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 28 Dec 2011 21:21:01 GMT</pubDate></item></channel></rss>