% +------------------------------------------------------------------------+ % | CGAL Reference Manual: Reference manual for Qt_widget.tex % +------------------------------------------------------------------------+ % | % | 02.04.2003 Radu Ursu % | % | \RCSdef{\qtwidgetRev}{$Id$} % | \RCSdefDate{\qtwidgetDate}{$Date$} % +------------------------------------------------------------------------+ % +-----------------------------------------------------+ \begin{ccRefClass}{Qt_widget_standard_toolbar} \ccDefinition The standard toolbar includes the basic tools used for zooming and translating in a \ccc{Qt_widget}. \ccInclude{CGAL/IO/Qt_widget_standard_toolbar.h} \ccGlue \ccInheritsFrom \ccc{QToolBar} \ccCreation \ccCreationVariable{stoolbar} \ccSetTwoColumns{Qt_widget_standard_toolbar}{} \ccConstructor{Qt_widget_standard_toolbar(Qt_widget *w, QMainWindow *mw , QWidget* parent, bool newline = true, const char* name = 0);} { This constructor creates a new toolbar, called \ccc{name}, in your application, containing all the standard tools. The first parameter \ccc{w} is a non-null pointer to the Qt\_widget object on which the toolbar functionalities act. The second parameter \ccc{mw} is a pointer to the \ccc{QMainWindow} that manages the toolbar. The later is added to the top area of the \ccc{QMainWindow}, unless \ccc{mw=0}. \ccc{mw}, \ccc{parent}, \ccc{newline}, \ccc{name} are passed to the \ccc{QMainWindow} constructor (with first parameter \ccc{label=''Qt_widget standard toolbar''}). } \ccConstructor{Qt_widget_standard_toolbar(Qt_widget *w, QMainWindow *parent = 0, const char* name = 0);} { Simplified version of the previous one. The \ccc{parent} is the \ccc{QMainWindow} that manages the toolbar. } \ccMethod{const QToolBar* toolbar();}{Deprecated: (in CGAL-2.4 the standard toolbar was not derived from \ccc{QToolBar}) Returns a pointer to the \ccc{QToolBar this} itself. } \ccHeading{public slots:} \ccMethod{void back();}{Goes back in the history list of the standard toolbar.} \ccMethod{void forward();}{Goes forward in the history list of the standard toolbar.} \ccMethod{void clear_history();}{Clears the history list of the standard toolbar.} \ccExample \begin{ccExampleCode} #include #include #include #include #include #include #include #include #include typedef CGAL::Cartesian Rep; typedef CGAL::Point_2 Point; typedef CGAL::Delaunay_triangulation_2 Delaunay; Delaunay dt; class My_layer : public CGAL::Qt_widget_layer{ void draw(){ *widget << CGAL::BLACK; *widget << dt; } }; class My_widget : public CGAL::Qt_widget { public: My_widget(QMainWindow* c) : CGAL::Qt_widget(c) {}; private: //this event is called only when the user presses the mouse void mousePressEvent(QMouseEvent *e) { Qt_widget::mousePressEvent(e); dt.insert(Point(x_real(e->x()), y_real(e->y()))); redraw(); } }; class My_window : public QMainWindow{ public: My_window(int x, int y) { widget = new My_widget(this); setCentralWidget(widget); resize(x,y); widget->set_window(0, x, 0, y); //How to attach the standard toolbar stoolbar = new CGAL::Qt_widget_standard_toolbar(widget, this, "Standard toolbar"); widget->attach(&v); } private: My_widget *widget; My_layer v; CGAL::Qt_widget_standard_toolbar *stoolbar; }; int main( int argc, char **argv ) { QApplication app( argc, argv ); My_window W(400,400); app.setMainWidget( &W ); W.show(); W.setCaption("Using the Standard Toolbar"); return app.exec(); } \end{ccExampleCode} This example is implemented in the fifth tutorial. You can look over the code to see how the code works. \end{ccRefClass} % +-----------------------------------------------------+ % EOF