-/* $Id$
-
-This file is part of the MSP Märklin suite
-Copyright © 2006-2008, 2010 Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
#include <GL/gl.h>
#include <msp/gl/texture.h>
#include <msp/gltk/button.h>
+#include <msp/gltk/column.h>
+#include <msp/gltk/row.h>
#include <msp/input/keys.h>
#include "designer.h"
#include "input.h"
using namespace Msp;
InputDialog::InputDialog(Designer &d, const string &title, const string &text):
- GLtk::Widget(d.get_ui_resources()),
- GLtk::Dialog(d.get_ui_resources()),
designer(d)
{
- set_size(300, 100);
+ set_layout(new GLtk::Layout);
+ GLtk::Column col(*layout);
GLtk::Label *lbl;
- add(*(lbl=new GLtk::Label(res, title)));
- lbl->set_geometry(GLtk::Geometry(10, geom.h-30, geom.w-20, 20));
+ add(*(lbl=new GLtk::Label(title)));
+ lbl->set_style("title");
- add(*(entry=new GLtk::Entry(res, text)));
- entry->set_geometry(GLtk::Geometry(10, geom.h-60, geom.w-20, 20));
+ add(*(entry=new GLtk::Entry(text)));
+ entry->set_edit_size(60, 1);
GLtk::Button *btn;
- add_button(*(btn=new GLtk::Button(res, "Cncl")), 0);
- btn->set_geometry(GLtk::Geometry(geom.w-90, 10, 40, 24));
- btn->set_style("red");
+ {
+ GLtk::Row row(*layout);
+ row.split();
+ add_button(*(btn=new GLtk::Button("Cncl")), 0);
+ btn->set_style("red");
- add_button(*(btn=new GLtk::Button(res, "OK")), 1);
- btn->set_geometry(GLtk::Geometry(geom.w-50, 10, 40, 24));
- btn->set_style("green");
+ add_button(*(btn=new GLtk::Button("OK")), 1);
+ btn->set_style("green");
+ }
- designer.get_root().add(*this);
- const GLtk::Geometry &rgeom=designer.get_root().get_geometry();
- set_position((rgeom.w-geom.w)/2, (rgeom.h-geom.h)/2);
entry->set_focus();
}
-void InputDialog::key_press(unsigned key, unsigned mod, wchar_t ch)
+void InputDialog::key_press(unsigned key, unsigned mod)
{
if(key==Msp::Input::KEY_ENTER)
response(1);
else if(key==Msp::Input::KEY_ESC)
response(0);
else
- Dialog::key_press(key, mod, ch);
+ Dialog::key_press(key, mod);
}
void InputDialog::on_response(int code)