2013-03-15 13:11:33 +00:00
|
|
|
namespace phoenix {
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
static void LineEdit_activate(LineEdit* self) {
|
2011-02-24 09:27:21 +00:00
|
|
|
if(self->onActivate) self->onActivate();
|
|
|
|
}
|
|
|
|
|
2013-05-02 11:25:45 +00:00
|
|
|
static void LineEdit_change(LineEdit* self) {
|
2011-09-05 03:48:23 +00:00
|
|
|
self->state.text = self->text();
|
2011-02-24 09:27:21 +00:00
|
|
|
if(self->p.locked == false && self->onChange) self->onChange();
|
|
|
|
}
|
|
|
|
|
2013-03-15 13:11:33 +00:00
|
|
|
Size pLineEdit::minimumSize() {
|
|
|
|
Size size = pFont::size(widget.state.font, lineEdit.state.text);
|
|
|
|
return {size.width + 10, size.height + 10};
|
2011-03-22 12:56:49 +00:00
|
|
|
}
|
|
|
|
|
2011-02-24 09:27:21 +00:00
|
|
|
void pLineEdit::setEditable(bool editable) {
|
2011-08-06 14:03:52 +00:00
|
|
|
gtk_editable_set_editable(GTK_EDITABLE(gtkWidget), editable);
|
2011-02-24 09:27:21 +00:00
|
|
|
}
|
|
|
|
|
2013-05-05 09:21:30 +00:00
|
|
|
void pLineEdit::setText(string text) {
|
2011-02-24 09:27:21 +00:00
|
|
|
locked = true;
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(gtkWidget), text);
|
|
|
|
locked = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
string pLineEdit::text() {
|
|
|
|
return gtk_entry_get_text(GTK_ENTRY(gtkWidget));
|
|
|
|
}
|
|
|
|
|
|
|
|
void pLineEdit::constructor() {
|
|
|
|
gtkWidget = gtk_entry_new();
|
|
|
|
g_signal_connect_swapped(G_OBJECT(gtkWidget), "activate", G_CALLBACK(LineEdit_activate), (gpointer)&lineEdit);
|
|
|
|
g_signal_connect_swapped(G_OBJECT(gtkWidget), "changed", G_CALLBACK(LineEdit_change), (gpointer)&lineEdit);
|
2011-09-05 03:48:23 +00:00
|
|
|
|
|
|
|
setEditable(lineEdit.state.editable);
|
|
|
|
setText(lineEdit.state.text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pLineEdit::destructor() {
|
|
|
|
gtk_widget_destroy(gtkWidget);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pLineEdit::orphan() {
|
|
|
|
destructor();
|
|
|
|
constructor();
|
2011-02-24 09:27:21 +00:00
|
|
|
}
|
2013-03-15 13:11:33 +00:00
|
|
|
|
|
|
|
}
|