Ensemble Graphics Toolkit: Exercise Solution 1
Exercise 1
Use the EGT documentation and change the widget width.
- Increase the width to twice the widget’s old width.
- Set the widget height to 70.
The screen will look like this:
Observe the widget (button) X and Y coordinates are printed on the terminal console.
Solution
//----------------------------------------
//
// widgets.cpp
//
// Ensemble Graphics Toolkit - Exercise 1
//
//----------------------------------------
#include <egt/ui>
#include <iostream>
using namespace std;
using namespace egt;
int main(int argc, const char ** argv)
{
Application app;
TopWindow window;
Button button(window, "Press Me");
// center(button);
// button.align(AlignFlag::center | AlignFlag::left);
button.move(Point(300,300));
cout << "X:" << button.x() << " Y:" << button.y() << endl;
//change widget width and height
button.width(button.width()*2);
button.height(70);
cout << "width:" << button.width() << " height:" << button.height() << endl;
window.show();
return app.run();
}