Skip to content

Instantly share code, notes, and snippets.

@colltoaction
Created July 5, 2016 04:18
Show Gist options
  • Save colltoaction/dd74348fafb1f1c0165e0970015a35c9 to your computer and use it in GitHub Desktop.
Save colltoaction/dd74348fafb1f1c0165e0970015a35c9 to your computer and use it in GitHub Desktop.
Óvalo que ocupa toda la ventana usando gtkmm
/*
Implemente una rutina (en Windows o Linux) que dibuje un óvalo que ocupe toda la ventana.
*/
#include <gtkmm/drawingarea.h>
#include <gtkmm/application.h>
#include <gtkmm/window.h>
#include <cmath>
class Ovalo : public Gtk::DrawingArea {
protected:
virtual bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr) {
Gtk::Allocation allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();
cr->scale(width, height);
cr->arc(0.5, 0.5, 0.5, 0, 2 * M_PI);
cr->set_source_rgba(0, 0, 1.0, 1);
cr->stroke();
return true;
}
};
int main(int argc, char* argv[]) {
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv);
Gtk::Window win;
win.set_title("DrawingArea");
Ovalo area;
win.add(area);
area.show();
return app->run(win);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment