lo guys, i just started "playing" with SDL Library (dont ask me why, cuz i cant give you a decent answer-> its open source, seemed easy, and i need to work a bit more with GUI)
anywayz,
how can i make a class container that contains some other classes (widgets - windows) - ( these widgets contain some buttons that call my other functions - i have to send/receive data to/from IO serial COM - where my micro-controler is connected to )
so i ll have to make class hirarchy where the class cointainer will contain classes widgets (new window, send, receive, quit, and so on)
to make it a bit easier to understand my question, here is the code how to make new widget with a button
Code:make_widgets.cpp /* * The application processes only the event SDL_QUIT. * The WidgetClass processes the SDL_EXPOSE event via * the OnPaint() member function. * */ #include "widget.h" // Here is where the widgets are declared #include "button.h" #include "canvas.h" #include <iostream> using namespace std; class Container:public Canvas { }; class Label:public Widget { public: Label(Object* Parent=NULL, int x=0, int y=0, int w=320, int h=120):Widget(Parent, x,y,w,h) { setCaption("Label"); cout <<"Constructor Label is called !!!"<< endl; } }; class Btn : public Button { public: Btn(Object* Parent=NULL, int x=0, int y=0, int w=0, int h=0); virtual void clicked() { cout << "Virtual void clicked() is called" << endl; exit(0); } }; Btn::Btn(Object* Parent, int x, int y, int w, int h):Button(Parent, x,y,w,h) { setCaption("YES"); cout <<"Constructor Btn is called !!!"<< endl; } int main() { SDL_Event event; // A structure containing event information Label MainWindow; // Create the MainWindow. Btn QuitButtonYes(&MainWindow, 0,0,80,25); // Set the background color of the window MainWindow.setBgColorRGB(192,192,192); // The color is red=255, // blue = 0, and green = 0 QuitButtonYes.setBgColorRGB(192,192,192); bool done = false; // Flag showing whether we have to quit while ( SDL_WaitEvent(&event) && !done) { switch (event.type) { case SDL_QUIT: done = true; break; default: MainWindow.handleEvent(event); QuitButtonYes.handleEvent(event); break; } }/*while*/ return 0; }



LinkBack URL
About LinkBacks


