Skip to content
Snippets Groups Projects
Commit 38ef7e3b authored by Fodor Ágoston's avatar Fodor Ágoston
Browse files

pálya kirajzolása

parent 83a552ed
No related branches found
No related tags found
No related merge requests found
#include "application.hpp"
#include "graphics.hpp"
#include "widget.hpp"
using namespace genv;
Application::Application()
{
gout.open(900,900);
gout.open(910,910);
}
void Application::event_loop()
......@@ -30,7 +34,7 @@ void Application::event_loop()
}
for (Widget * w : widgets)
{
w->draw();
w->draw2();
}
gout << refresh;
}
......
......@@ -14,7 +14,7 @@ public:
virtual void event_loop();
virtual void registerWidget(Widget*);
virtual void action(std::string) = 0;
protected:
std::vector<Widget*> widgets;
......
......@@ -117,3 +117,4 @@ string ListBox::getter()
}
#include "graphics.hpp"
#include "application.hpp"
#include "spinbox.hpp"
#include <vector>
#include "widget.hpp"
using namespace genv;
using namespace std;
class MyApp : public Application
{
public:
MyApp()
{
}
void palya()
{
for (int i = 5; i < 890; i+=100)
{
for (int j = 5; j < 890; j+=100)
{
sp = new SpinBox(this, i,j,100,0,9);
}
}
}
protected:
vector<Widget*> widgets;
SpinBox * sp;
};
int main()
{
gout.open(400,400);
gout <<text("hello world")<< refresh;
event ev;
while(gin >> ev) {
}
MyApp app;
app.palya();
app.event_loop();
return 0;
}
......@@ -11,7 +11,7 @@ int mouse_y = 0;
SpinBox::SpinBox(Application* parent,int x, int y, int sizey, int min, int max) : Widget(parent,x,y,sizey*3,sizey), _min(min), _max(max), _isselected(0)
{
_num = (_min + _max)/2;
_num = 0;
}
void SpinBox::draw()
......@@ -45,6 +45,25 @@ void SpinBox::draw()
<< line_to(_x + _sizex - _sizey / 2 - _sizey / 6, _y + _sizey / 2 + _sizey / 6)
<< line_to(_x + _sizex - _sizey / 2, _y + _sizey / 2 - _sizey / 6);
}
void SpinBox::draw2()
{
_sizex = _sizey;
gout << move_to (_x,_y) << color(50,50,50) << box(_sizex,_sizey);
gout << move_to(_x + 1, _y + 1) << color(0,0,0) << box(_sizey - 2, _sizey -2);
gout << move_to(_x + _sizey + 1, _y + 1) << color(0,0,0) << box(_sizey - 2, _sizey -2);
gout << move_to(_x +2*_sizey + 1, _y + 1) << color(0,0,0) << box(_sizey - 2, _sizey -2);
int text_width = gout.twidth(to_string(_num));
int text_height = gout.cascent() + gout.cdescent();
gout << move_to(_x + (_sizex - text_width) / 2, _y + (_sizey - text_height) / 2 + gout.cascent())
<< color(255, 255, 255)
<< text(to_string(_num));
}
bool SpinBox::isover(int ms_x, int ms_y)
{
......
......@@ -16,6 +16,7 @@ public:
void handle(genv::event) override;
bool isover(int mouse_x,int mouse_y) override;
std::string getter() override;
void draw2();
......
#include "widget.hpp"
#include "application.hpp"
#include "graphics.hpp"
using namespace genv;
Widget::Widget(Application * parent,int x, int y, int sizex, int sizey) : _x(x), _y(y), _sizex(sizex), _sizey(sizey), _parent(parent)
......@@ -8,3 +7,7 @@ Widget::Widget(Application * parent,int x, int y, int sizex, int sizey) : _x(x),
{
_parent->registerWidget(this);
}
void draw2()
{
}
......@@ -16,6 +16,7 @@ public:
virtual void handle(genv::event ev) = 0;
virtual bool isover(int ms_x, int ms_y) = 0;
virtual std::string getter() = 0;
virtual void draw2() = 0;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment