mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-18 20:42:31 +00:00
Convert jentry to Entry class.
This commit is contained in:
parent
2e87a9013f
commit
c5ba3076a5
@ -68,7 +68,7 @@ void LayerPropertiesCommand::onExecute(Context* context)
|
|||||||
Widget* box2 = jbox_new(JI_HORIZONTAL);
|
Widget* box2 = jbox_new(JI_HORIZONTAL);
|
||||||
Widget* box3 = jbox_new(JI_HORIZONTAL + JI_HOMOGENEOUS);
|
Widget* box3 = jbox_new(JI_HORIZONTAL + JI_HOMOGENEOUS);
|
||||||
Widget* label_name = new Label("Name:");
|
Widget* label_name = new Label("Name:");
|
||||||
Widget* entry_name = jentry_new(256, layer->getName().c_str());
|
Entry* entry_name = new Entry(256, layer->getName().c_str());
|
||||||
Button* button_ok = new Button("&OK");
|
Button* button_ok = new Button("&OK");
|
||||||
Button* button_cancel = new Button("&Cancel");
|
Button* button_cancel = new Button("&Cancel");
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ base::string ase_file_selector(const base::string& message,
|
|||||||
{
|
{
|
||||||
static Frame* window = NULL;
|
static Frame* window = NULL;
|
||||||
Widget* fileview;
|
Widget* fileview;
|
||||||
Widget* filename_entry;
|
Entry* filename_entry;
|
||||||
ComboBox* filetype;
|
ComboBox* filetype;
|
||||||
base::string result;
|
base::string result;
|
||||||
|
|
||||||
@ -145,13 +145,13 @@ base::string ase_file_selector(const base::string& message,
|
|||||||
window = static_cast<Frame*>(load_widget("file_selector.xml", "file_selector"));
|
window = static_cast<Frame*>(load_widget("file_selector.xml", "file_selector"));
|
||||||
|
|
||||||
JWidget box = jwidget_find_name(window, "box");
|
JWidget box = jwidget_find_name(window, "box");
|
||||||
Button* goback = dynamic_cast<Button*>(jwidget_find_name(window, "goback"));
|
Button* goback = window->findChildT<Button>("goback");
|
||||||
Button* goforward = dynamic_cast<Button*>(jwidget_find_name(window, "goforward"));
|
Button* goforward = window->findChildT<Button>("goforward");
|
||||||
Button* goup = dynamic_cast<Button*>(jwidget_find_name(window, "goup"));
|
Button* goup = window->findChildT<Button>("goup");
|
||||||
JWidget location = jwidget_find_name(window, "location");
|
JWidget location = window->findChild("location");
|
||||||
filetype = dynamic_cast<ComboBox*>(jwidget_find_name(window, "filetype"));
|
filetype = window->findChildT<ComboBox>("filetype");
|
||||||
ASSERT(filetype != NULL);
|
ASSERT(filetype != NULL);
|
||||||
filename_entry = jwidget_find_name(window, "filename");
|
filename_entry = window->findChildT<Entry>("filename");
|
||||||
|
|
||||||
jwidget_focusrest(goback, false);
|
jwidget_focusrest(goback, false);
|
||||||
jwidget_focusrest(goforward, false);
|
jwidget_focusrest(goforward, false);
|
||||||
@ -190,9 +190,9 @@ base::string ase_file_selector(const base::string& message,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fileview = jwidget_find_name(window, "fileview");
|
fileview = jwidget_find_name(window, "fileview");
|
||||||
filetype = dynamic_cast<ComboBox*>(jwidget_find_name(window, "filetype"));
|
filetype = window->findChildT<ComboBox>("filetype");
|
||||||
ASSERT(filetype != NULL);
|
ASSERT(filetype != NULL);
|
||||||
filename_entry = jwidget_find_name(window, "filename");
|
filename_entry = window->findChildT<Entry>("filename");
|
||||||
|
|
||||||
jwidget_signal_off(fileview);
|
jwidget_signal_off(fileview);
|
||||||
fileview_set_current_folder(fileview, start_folder);
|
fileview_set_current_folder(fileview, start_folder);
|
||||||
@ -220,7 +220,7 @@ base::string ase_file_selector(const base::string& message,
|
|||||||
// file name entry field
|
// file name entry field
|
||||||
filename_entry->setText(base::get_file_name(init_path).c_str());
|
filename_entry->setText(base::get_file_name(init_path).c_str());
|
||||||
select_filetype_from_filename(window);
|
select_filetype_from_filename(window);
|
||||||
jentry_select_text(filename_entry, 0, -1);
|
filename_entry->selectText(0, -1);
|
||||||
|
|
||||||
// setup the title of the window
|
// setup the title of the window
|
||||||
window->setText(message.c_str());
|
window->setText(message.c_str());
|
||||||
@ -432,7 +432,7 @@ static void update_location(JWidget window)
|
|||||||
jwidget_signal_off(location);
|
jwidget_signal_off(location);
|
||||||
location->setSelectedItem(selected_index);
|
location->setSelectedItem(selected_index);
|
||||||
location->getEntryWidget()->setText(current_folder->getDisplayName().c_str());
|
location->getEntryWidget()->setText(current_folder->getDisplayName().c_str());
|
||||||
jentry_deselect_text(location->getEntryWidget());
|
location->getEntryWidget()->deselectText();
|
||||||
jwidget_signal_on(location);
|
jwidget_signal_on(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,7 +649,7 @@ static bool filetype_msg_proc(JWidget widget, JMessage msg)
|
|||||||
case JI_SIGNAL_COMBOBOX_SELECT: {
|
case JI_SIGNAL_COMBOBOX_SELECT: {
|
||||||
std::string ext = combobox->getItemText(combobox->getSelectedItem());
|
std::string ext = combobox->getItemText(combobox->getSelectedItem());
|
||||||
Frame* window = static_cast<Frame*>(combobox->getRoot());
|
Frame* window = static_cast<Frame*>(combobox->getRoot());
|
||||||
Widget* entry = window->findChild("filename");
|
Entry* entry = window->findChildT<Entry>("filename");
|
||||||
char buf[MAX_PATH];
|
char buf[MAX_PATH];
|
||||||
char* p;
|
char* p;
|
||||||
|
|
||||||
@ -658,7 +658,7 @@ static bool filetype_msg_proc(JWidget widget, JMessage msg)
|
|||||||
if (p && *p != 0) {
|
if (p && *p != 0) {
|
||||||
ustrcpy(p, ext.c_str());
|
ustrcpy(p, ext.c_str());
|
||||||
entry->setText(buf);
|
entry->setText(buf);
|
||||||
jentry_select_text(entry, 0, -1);
|
entry->selectText(0, -1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -704,9 +704,8 @@ static bool filename_msg_proc(JWidget widget, JMessage msg)
|
|||||||
// Is the pattern (left_part) in the child_name's beginning?
|
// Is the pattern (left_part) in the child_name's beginning?
|
||||||
if (it2 == left_part.end()) {
|
if (it2 == left_part.end()) {
|
||||||
widget->setText(child_name.c_str());
|
widget->setText(child_name.c_str());
|
||||||
jentry_select_text(widget,
|
((Entry*)widget)->selectText(child_name.size(),
|
||||||
child_name.size(),
|
left_part.size());
|
||||||
left_part.size());
|
|
||||||
clear_keybuf();
|
clear_keybuf();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "gui/entry.h"
|
||||||
#include "gui/jclipboard.h"
|
#include "gui/jclipboard.h"
|
||||||
#include "gui/jfont.h"
|
#include "gui/jfont.h"
|
||||||
#include "gui/jmanager.h"
|
#include "gui/jmanager.h"
|
||||||
@ -18,55 +19,14 @@
|
|||||||
#include "gui/jrect.h"
|
#include "gui/jrect.h"
|
||||||
#include "gui/jsystem.h"
|
#include "gui/jsystem.h"
|
||||||
#include "gui/jtheme.h"
|
#include "gui/jtheme.h"
|
||||||
|
#include "gui/preferred_size_event.h"
|
||||||
#include "gui/widget.h"
|
#include "gui/widget.h"
|
||||||
|
|
||||||
#define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length((f), (c)))
|
#define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length((f), (c)))
|
||||||
|
|
||||||
namespace EntryCmd {
|
Entry::Entry(size_t maxsize, const char *format, ...)
|
||||||
enum Type {
|
: Widget(JI_ENTRY)
|
||||||
NoOp,
|
|
||||||
InsertChar,
|
|
||||||
ForwardChar,
|
|
||||||
ForwardWord,
|
|
||||||
BackwardChar,
|
|
||||||
BackwardWord,
|
|
||||||
BeginningOfLine,
|
|
||||||
EndOfLine,
|
|
||||||
DeleteForward,
|
|
||||||
DeleteBackward,
|
|
||||||
Cut,
|
|
||||||
Copy,
|
|
||||||
Paste,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct Entry
|
|
||||||
{
|
{
|
||||||
size_t maxsize;
|
|
||||||
int cursor;
|
|
||||||
int scroll;
|
|
||||||
int select;
|
|
||||||
int timer_id;
|
|
||||||
bool hidden : 1;
|
|
||||||
bool state : 1; /* show or not the text cursor */
|
|
||||||
bool readonly : 1;
|
|
||||||
bool password : 1;
|
|
||||||
bool recent_focused : 1;
|
|
||||||
} Entry;
|
|
||||||
|
|
||||||
static bool entry_msg_proc(JWidget widget, JMessage msg);
|
|
||||||
static void entry_request_size(JWidget widget, int *w, int *h);
|
|
||||||
|
|
||||||
static int entry_get_cursor_from_mouse(JWidget widget, JMessage msg);
|
|
||||||
|
|
||||||
static void entry_execute_cmd(JWidget widget, EntryCmd::Type cmd, int ascii, bool shift_pressed);
|
|
||||||
static void entry_forward_word(JWidget widget);
|
|
||||||
static void entry_backward_word(JWidget widget);
|
|
||||||
|
|
||||||
JWidget jentry_new(size_t maxsize, const char *format, ...)
|
|
||||||
{
|
|
||||||
Widget* widget = new Widget(JI_ENTRY);
|
|
||||||
Entry* entry = (Entry*)jnew(Entry, 1);
|
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
|
|
||||||
// formatted string
|
// formatted string
|
||||||
@ -81,141 +41,120 @@ JWidget jentry_new(size_t maxsize, const char *format, ...)
|
|||||||
ustrcpy(buf, empty_string);
|
ustrcpy(buf, empty_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
jwidget_add_hook(widget, JI_ENTRY, entry_msg_proc, entry);
|
m_maxsize = maxsize;
|
||||||
|
m_caret = 0;
|
||||||
entry->maxsize = maxsize;
|
m_scroll = 0;
|
||||||
entry->cursor = 0;
|
m_select = 0;
|
||||||
entry->scroll = 0;
|
m_timer_id = jmanager_add_timer(this, 500);
|
||||||
entry->select = 0;
|
m_hidden = false;
|
||||||
entry->timer_id = jmanager_add_timer(widget, 500);
|
m_state = false;
|
||||||
entry->hidden = false;
|
m_password = false;
|
||||||
entry->state = false;
|
m_readonly = false;
|
||||||
entry->password = false;
|
m_recent_focused = false;
|
||||||
entry->readonly = false;
|
|
||||||
entry->recent_focused = false;
|
|
||||||
|
|
||||||
/* TODO support for text alignment and multi-line */
|
/* TODO support for text alignment and multi-line */
|
||||||
/* widget->align = JI_LEFT | JI_MIDDLE; */
|
/* widget->align = JI_LEFT | JI_MIDDLE; */
|
||||||
widget->setText(buf);
|
setText(buf);
|
||||||
|
|
||||||
jwidget_focusrest(widget, true);
|
jwidget_focusrest(this, true);
|
||||||
jwidget_init_theme(widget);
|
jwidget_init_theme(this);
|
||||||
|
|
||||||
return widget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void jentry_readonly(JWidget widget, bool state)
|
Entry::~Entry()
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
jmanager_remove_timer(m_timer_id);
|
||||||
|
|
||||||
entry->readonly = state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void jentry_password(JWidget widget, bool state)
|
bool Entry::isReadOnly() const
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
return m_readonly;
|
||||||
|
|
||||||
entry->password = state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool jentry_is_readonly(JWidget widget)
|
bool Entry::isPassword() const
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
return m_password;
|
||||||
|
|
||||||
return entry->readonly;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool jentry_is_password(JWidget widget)
|
void Entry::setReadOnly(bool state)
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
m_readonly = state;
|
||||||
|
|
||||||
return entry->password;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void jentry_show_cursor(JWidget widget)
|
void Entry::setPassword(bool state)
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
m_password = state;
|
||||||
|
|
||||||
entry->hidden = false;
|
|
||||||
|
|
||||||
jwidget_dirty(widget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void jentry_hide_cursor(JWidget widget)
|
void Entry::showCaret()
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
m_hidden = false;
|
||||||
|
dirty();
|
||||||
entry->hidden = true;
|
|
||||||
|
|
||||||
jwidget_dirty(widget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void jentry_set_cursor_pos(JWidget widget, int pos)
|
void Entry::hideCaret()
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
m_hidden = true;
|
||||||
const char *text = widget->getText();
|
dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Entry::setCaretPos(int pos)
|
||||||
|
{
|
||||||
|
const char *text = this->getText();
|
||||||
int x, c;
|
int x, c;
|
||||||
|
|
||||||
entry->cursor = pos;
|
m_caret = pos;
|
||||||
|
|
||||||
/* backward scroll */
|
/* backward scroll */
|
||||||
if (entry->cursor < entry->scroll)
|
if (m_caret < m_scroll)
|
||||||
entry->scroll = entry->cursor;
|
m_scroll = m_caret;
|
||||||
|
|
||||||
/* forward scroll */
|
/* forward scroll */
|
||||||
entry->scroll--;
|
m_scroll--;
|
||||||
do {
|
do {
|
||||||
x = widget->rc->x1 + widget->border_width.l;
|
x = this->rc->x1 + this->border_width.l;
|
||||||
for (c=++entry->scroll; ; c++) {
|
for (c=++m_scroll; ; c++) {
|
||||||
x += CHARACTER_LENGTH(widget->getFont(),
|
x += CHARACTER_LENGTH(this->getFont(),
|
||||||
(c < ustrlen(text))? ugetat(text, c): ' ');
|
(c < ustrlen(text))? ugetat(text, c): ' ');
|
||||||
|
|
||||||
if (x >= widget->rc->x2-widget->border_width.r)
|
if (x >= this->rc->x2-this->border_width.r)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (entry->cursor >= c);
|
} while (m_caret >= c);
|
||||||
|
|
||||||
jmanager_start_timer(entry->timer_id);
|
jmanager_start_timer(m_timer_id);
|
||||||
entry->state = true;
|
m_state = true;
|
||||||
|
|
||||||
jwidget_dirty(widget);
|
dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void jentry_select_text(JWidget widget, int from, int to)
|
void Entry::selectText(int from, int to)
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
int end = ustrlen(this->getText());
|
||||||
int end = ustrlen(widget->getText());
|
|
||||||
|
|
||||||
entry->select = from;
|
m_select = from;
|
||||||
jentry_set_cursor_pos(widget, from); // to move scroll
|
setCaretPos(from); // to move scroll
|
||||||
jentry_set_cursor_pos(widget, (to >= 0)? to: end+to+1);
|
setCaretPos((to >= 0)? to: end+to+1);
|
||||||
|
|
||||||
jwidget_dirty(widget);
|
dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void jentry_deselect_text(JWidget widget)
|
void Entry::deselectText()
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
m_select = -1;
|
||||||
|
dirty();
|
||||||
entry->select = -1;
|
|
||||||
|
|
||||||
jwidget_dirty(widget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void jtheme_entry_info(JWidget widget,
|
void Entry::getEntryThemeInfo(int* scroll, int* caret, int* state,
|
||||||
int *scroll, int *cursor, int *state,
|
int* selbeg, int* selend)
|
||||||
int *selbeg, int *selend)
|
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
if (scroll) *scroll = m_scroll;
|
||||||
|
if (caret) *caret = m_caret;
|
||||||
|
if (state) *state = !m_hidden && m_state;
|
||||||
|
|
||||||
if (scroll) *scroll = entry->scroll;
|
if ((m_select >= 0) &&
|
||||||
if (cursor) *cursor = entry->cursor;
|
(m_caret != m_select)) {
|
||||||
if (state) *state = !entry->hidden && entry->state;
|
*selbeg = MIN(m_caret, m_select);
|
||||||
|
*selend = MAX(m_caret, m_select)-1;
|
||||||
if ((entry->select >= 0) &&
|
|
||||||
(entry->cursor != entry->select)) {
|
|
||||||
*selbeg = MIN(entry->cursor, entry->select);
|
|
||||||
*selend = MAX(entry->cursor, entry->select)-1;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*selbeg = -1;
|
*selbeg = -1;
|
||||||
@ -223,55 +162,44 @@ void jtheme_entry_info(JWidget widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool entry_msg_proc(JWidget widget, JMessage msg)
|
bool Entry::onProcessMessage(JMessage msg)
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
|
||||||
|
|
||||||
switch (msg->type) {
|
switch (msg->type) {
|
||||||
|
|
||||||
case JM_DESTROY:
|
|
||||||
jmanager_remove_timer(entry->timer_id);
|
|
||||||
jfree(entry);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case JM_REQSIZE:
|
|
||||||
entry_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case JM_DRAW:
|
case JM_DRAW:
|
||||||
widget->theme->draw_entry(widget, &msg->draw.rect);
|
this->theme->draw_entry(this, &msg->draw.rect);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case JM_TIMER:
|
case JM_TIMER:
|
||||||
if (widget->hasFocus() &&
|
if (this->hasFocus() &&
|
||||||
msg->timer.timer_id == entry->timer_id) {
|
msg->timer.timer_id == m_timer_id) {
|
||||||
// blinking cursor
|
// Blinking caret
|
||||||
entry->state = entry->state ? false: true;
|
m_state = m_state ? false: true;
|
||||||
jwidget_dirty(widget);
|
dirty();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JM_FOCUSENTER:
|
case JM_FOCUSENTER:
|
||||||
jmanager_start_timer(entry->timer_id);
|
jmanager_start_timer(m_timer_id);
|
||||||
|
|
||||||
entry->state = true;
|
m_state = true;
|
||||||
jwidget_dirty(widget);
|
dirty();
|
||||||
|
|
||||||
jentry_select_text(widget, 0, -1);
|
selectText(0, -1);
|
||||||
entry->recent_focused = true;
|
m_recent_focused = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JM_FOCUSLEAVE:
|
case JM_FOCUSLEAVE:
|
||||||
jwidget_dirty(widget);
|
dirty();
|
||||||
|
|
||||||
jmanager_stop_timer(entry->timer_id);
|
jmanager_stop_timer(m_timer_id);
|
||||||
|
|
||||||
jentry_deselect_text(widget);
|
deselectText();
|
||||||
entry->recent_focused = false;
|
m_recent_focused = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JM_KEYPRESSED:
|
case JM_KEYPRESSED:
|
||||||
if (widget->hasFocus() && !jentry_is_readonly(widget)) {
|
if (this->hasFocus() && !isReadOnly()) {
|
||||||
// Command to execute
|
// Command to execute
|
||||||
EntryCmd::Type cmd = EntryCmd::NoOp;
|
EntryCmd::Type cmd = EntryCmd::NoOp;
|
||||||
|
|
||||||
@ -335,81 +263,81 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cmd == EntryCmd::NoOp)
|
if (cmd == EntryCmd::NoOp)
|
||||||
return false;
|
break;
|
||||||
|
|
||||||
entry_execute_cmd(widget, cmd,
|
executeCmd(cmd,
|
||||||
msg->key.ascii,
|
msg->key.ascii,
|
||||||
(msg->any.shifts & KB_SHIFT_FLAG) ? true: false);
|
(msg->any.shifts & KB_SHIFT_FLAG) ? true: false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JM_BUTTONPRESSED:
|
case JM_BUTTONPRESSED:
|
||||||
widget->captureMouse();
|
this->captureMouse();
|
||||||
|
|
||||||
case JM_MOTION:
|
case JM_MOTION:
|
||||||
if (widget->hasCapture()) {
|
if (this->hasCapture()) {
|
||||||
const char *text = widget->getText();
|
const char *text = this->getText();
|
||||||
bool move, dirty;
|
bool move, is_dirty;
|
||||||
int c, x;
|
int c, x;
|
||||||
|
|
||||||
move = true;
|
move = true;
|
||||||
dirty = false;
|
is_dirty = false;
|
||||||
|
|
||||||
/* backward scroll */
|
/* backward scroll */
|
||||||
if (msg->mouse.x < widget->rc->x1) {
|
if (msg->mouse.x < this->rc->x1) {
|
||||||
if (entry->scroll > 0) {
|
if (m_scroll > 0) {
|
||||||
entry->cursor = --entry->scroll;
|
m_caret = --m_scroll;
|
||||||
move = false;
|
move = false;
|
||||||
dirty = true;
|
is_dirty = true;
|
||||||
jwidget_dirty(widget);
|
dirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* forward scroll */
|
/* forward scroll */
|
||||||
else if (msg->mouse.x >= widget->rc->x2) {
|
else if (msg->mouse.x >= this->rc->x2) {
|
||||||
if (entry->scroll < ustrlen(text)) {
|
if (m_scroll < ustrlen(text)) {
|
||||||
entry->scroll++;
|
m_scroll++;
|
||||||
x = widget->rc->x1 + widget->border_width.l;
|
x = this->rc->x1 + this->border_width.l;
|
||||||
for (c=entry->scroll; ; c++) {
|
for (c=m_scroll; ; c++) {
|
||||||
x += CHARACTER_LENGTH(widget->getFont(),
|
x += CHARACTER_LENGTH(this->getFont(),
|
||||||
(c < ustrlen(text))? ugetat(text, c): ' ');
|
(c < ustrlen(text))? ugetat(text, c): ' ');
|
||||||
if (x > widget->rc->x2-widget->border_width.r) {
|
if (x > this->rc->x2-this->border_width.r) {
|
||||||
c--;
|
c--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if (!ugetat (text, c))
|
else if (!ugetat (text, c))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
entry->cursor = c;
|
m_caret = c;
|
||||||
move = false;
|
move = false;
|
||||||
dirty = true;
|
is_dirty = true;
|
||||||
jwidget_dirty(widget);
|
dirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* move cursor */
|
// Move caret
|
||||||
if (move) {
|
if (move) {
|
||||||
c = entry_get_cursor_from_mouse(widget, msg);
|
c = getCaretFromMouse(msg);
|
||||||
|
|
||||||
if (entry->cursor != c) {
|
if (m_caret != c) {
|
||||||
entry->cursor = c;
|
m_caret = c;
|
||||||
dirty = true;
|
is_dirty = true;
|
||||||
jwidget_dirty(widget);
|
dirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* move selection */
|
// Move selection
|
||||||
if (entry->recent_focused) {
|
if (m_recent_focused) {
|
||||||
entry->recent_focused = false;
|
m_recent_focused = false;
|
||||||
entry->select = entry->cursor;
|
m_select = m_caret;
|
||||||
}
|
}
|
||||||
else if (msg->type == JM_BUTTONPRESSED)
|
else if (msg->type == JM_BUTTONPRESSED)
|
||||||
entry->select = entry->cursor;
|
m_select = m_caret;
|
||||||
|
|
||||||
/* show the cursor */
|
// Show the caret
|
||||||
if (dirty) {
|
if (is_dirty) {
|
||||||
jmanager_start_timer(entry->timer_id);
|
jmanager_start_timer(m_timer_id);
|
||||||
entry->state = true;
|
m_state = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -417,83 +345,86 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case JM_BUTTONRELEASED:
|
case JM_BUTTONRELEASED:
|
||||||
if (widget->hasCapture())
|
if (this->hasCapture())
|
||||||
widget->releaseMouse();
|
this->releaseMouse();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case JM_DOUBLECLICK:
|
case JM_DOUBLECLICK:
|
||||||
entry_forward_word(widget);
|
forwardWord();
|
||||||
entry->select = entry->cursor;
|
m_select = m_caret;
|
||||||
entry_backward_word(widget);
|
backwardWord();
|
||||||
jwidget_dirty(widget);
|
dirty();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case JM_MOUSEENTER:
|
case JM_MOUSEENTER:
|
||||||
case JM_MOUSELEAVE:
|
case JM_MOUSELEAVE:
|
||||||
/* TODO theme stuff */
|
/* TODO theme stuff */
|
||||||
if (widget->isEnabled())
|
if (this->isEnabled())
|
||||||
jwidget_dirty(widget);
|
dirty();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return Widget::onProcessMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void entry_request_size(JWidget widget, int *w, int *h)
|
void Entry::onPreferredSize(PreferredSizeEvent& ev)
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
int w =
|
||||||
|
+ border_width.l
|
||||||
|
+ ji_font_char_len(getFont(), 'w') * MIN(m_maxsize, 6)
|
||||||
|
+ 2 + border_width.r;
|
||||||
|
|
||||||
*w =
|
w = MIN(w, JI_SCREEN_W/2);
|
||||||
+ widget->border_width.l
|
|
||||||
+ ji_font_char_len(widget->getFont(), 'w') * MIN(entry->maxsize, 6)
|
|
||||||
+ 2 + widget->border_width.r;
|
|
||||||
|
|
||||||
*w = MIN(*w, JI_SCREEN_W/2);
|
int h =
|
||||||
|
+ border_width.t
|
||||||
|
+ text_height(getFont())
|
||||||
|
+ border_width.b;
|
||||||
|
|
||||||
*h =
|
ev.setPreferredSize(w, h);
|
||||||
+ widget->border_width.t
|
|
||||||
+ text_height(widget->getFont())
|
|
||||||
+ widget->border_width.b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int entry_get_cursor_from_mouse(JWidget widget, JMessage msg)
|
void Entry::onEntryChange()
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
EntryChange();
|
||||||
int c, x, w, mx, cursor = entry->cursor;
|
jwidget_emit_signal(this, JI_SIGNAL_ENTRY_CHANGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Entry::getCaretFromMouse(JMessage msg)
|
||||||
|
{
|
||||||
|
int c, x, w, mx, caret = m_caret;
|
||||||
|
|
||||||
mx = msg->mouse.x;
|
mx = msg->mouse.x;
|
||||||
mx = MID(widget->rc->x1+widget->border_width.l,
|
mx = MID(this->rc->x1+this->border_width.l,
|
||||||
mx,
|
mx,
|
||||||
widget->rc->x2-widget->border_width.r-1);
|
this->rc->x2-this->border_width.r-1);
|
||||||
|
|
||||||
x = widget->rc->x1 + widget->border_width.l;
|
x = this->rc->x1 + this->border_width.l;
|
||||||
for (c=entry->scroll; ugetat(widget->getText(), c); c++) {
|
for (c=m_scroll; ugetat(this->getText(), c); c++) {
|
||||||
w = CHARACTER_LENGTH(widget->getFont(), ugetat(widget->getText(), c));
|
w = CHARACTER_LENGTH(this->getFont(), ugetat(this->getText(), c));
|
||||||
if (x+w >= widget->rc->x2-widget->border_width.r)
|
if (x+w >= this->rc->x2-this->border_width.r)
|
||||||
break;
|
break;
|
||||||
if ((mx >= x) && (mx < x+w)) {
|
if ((mx >= x) && (mx < x+w)) {
|
||||||
cursor = c;
|
caret = c;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
x += w;
|
x += w;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ugetat(widget->getText(), c))
|
if (!ugetat(this->getText(), c))
|
||||||
if ((mx >= x) &&
|
if ((mx >= x) &&
|
||||||
(mx <= widget->rc->x2-widget->border_width.r-1))
|
(mx <= this->rc->x2-this->border_width.r-1))
|
||||||
cursor = c;
|
caret = c;
|
||||||
|
|
||||||
return cursor;
|
return caret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void entry_execute_cmd(JWidget widget, EntryCmd::Type cmd,
|
void Entry::executeCmd(EntryCmd::Type cmd, int ascii, bool shift_pressed)
|
||||||
int ascii, bool shift_pressed)
|
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
std::string text = this->getText();
|
||||||
std::string text = widget->getText();
|
|
||||||
int c, selbeg, selend;
|
int c, selbeg, selend;
|
||||||
|
|
||||||
jtheme_entry_info(widget, NULL, NULL, NULL, &selbeg, &selend);
|
getEntryThemeInfo(NULL, NULL, NULL, &selbeg, &selend);
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
|
|
||||||
@ -505,33 +436,33 @@ static void entry_execute_cmd(JWidget widget, EntryCmd::Type cmd,
|
|||||||
if (selbeg >= 0) {
|
if (selbeg >= 0) {
|
||||||
text.erase(selbeg, selend-selbeg+1);
|
text.erase(selbeg, selend-selbeg+1);
|
||||||
|
|
||||||
entry->cursor = selbeg;
|
m_caret = selbeg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// put the character
|
// put the character
|
||||||
if (text.size() < entry->maxsize)
|
if (text.size() < m_maxsize)
|
||||||
text.insert(entry->cursor++, 1, ascii);
|
text.insert(m_caret++, 1, ascii);
|
||||||
|
|
||||||
entry->select = -1;
|
m_select = -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EntryCmd::BackwardChar:
|
case EntryCmd::BackwardChar:
|
||||||
case EntryCmd::BackwardWord:
|
case EntryCmd::BackwardWord:
|
||||||
// selection
|
// selection
|
||||||
if (shift_pressed) {
|
if (shift_pressed) {
|
||||||
if (entry->select < 0)
|
if (m_select < 0)
|
||||||
entry->select = entry->cursor;
|
m_select = m_caret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
entry->select = -1;
|
m_select = -1;
|
||||||
|
|
||||||
// backward word
|
// backward word
|
||||||
if (cmd == EntryCmd::BackwardWord) {
|
if (cmd == EntryCmd::BackwardWord) {
|
||||||
entry_backward_word(widget);
|
backwardWord();
|
||||||
}
|
}
|
||||||
// backward char
|
// backward char
|
||||||
else if (entry->cursor > 0) {
|
else if (m_caret > 0) {
|
||||||
entry->cursor--;
|
m_caret--;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -539,44 +470,44 @@ static void entry_execute_cmd(JWidget widget, EntryCmd::Type cmd,
|
|||||||
case EntryCmd::ForwardWord:
|
case EntryCmd::ForwardWord:
|
||||||
// selection
|
// selection
|
||||||
if (shift_pressed) {
|
if (shift_pressed) {
|
||||||
if (entry->select < 0)
|
if (m_select < 0)
|
||||||
entry->select = entry->cursor;
|
m_select = m_caret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
entry->select = -1;
|
m_select = -1;
|
||||||
|
|
||||||
// forward word
|
// forward word
|
||||||
if (cmd == EntryCmd::ForwardWord) {
|
if (cmd == EntryCmd::ForwardWord) {
|
||||||
entry_forward_word(widget);
|
forwardWord();
|
||||||
}
|
}
|
||||||
// forward char
|
// forward char
|
||||||
else if (entry->cursor < (int)text.size()) {
|
else if (m_caret < (int)text.size()) {
|
||||||
entry->cursor++;
|
m_caret++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EntryCmd::BeginningOfLine:
|
case EntryCmd::BeginningOfLine:
|
||||||
// selection
|
// selection
|
||||||
if (shift_pressed) {
|
if (shift_pressed) {
|
||||||
if (entry->select < 0)
|
if (m_select < 0)
|
||||||
entry->select = entry->cursor;
|
m_select = m_caret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
entry->select = -1;
|
m_select = -1;
|
||||||
|
|
||||||
entry->cursor = 0;
|
m_caret = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EntryCmd::EndOfLine:
|
case EntryCmd::EndOfLine:
|
||||||
// selection
|
// selection
|
||||||
if (shift_pressed) {
|
if (shift_pressed) {
|
||||||
if (entry->select < 0)
|
if (m_select < 0)
|
||||||
entry->select = entry->cursor;
|
m_select = m_caret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
entry->select = -1;
|
m_select = -1;
|
||||||
|
|
||||||
entry->cursor = text.size();
|
m_caret = text.size();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EntryCmd::DeleteForward:
|
case EntryCmd::DeleteForward:
|
||||||
@ -592,15 +523,15 @@ static void entry_execute_cmd(JWidget widget, EntryCmd::Type cmd,
|
|||||||
// remove text
|
// remove text
|
||||||
text.erase(selbeg, selend-selbeg+1);
|
text.erase(selbeg, selend-selbeg+1);
|
||||||
|
|
||||||
entry->cursor = selbeg;
|
m_caret = selbeg;
|
||||||
}
|
}
|
||||||
// delete the next character
|
// delete the next character
|
||||||
else {
|
else {
|
||||||
if (entry->cursor < (int)text.size())
|
if (m_caret < (int)text.size())
|
||||||
text.erase(entry->cursor, 1);
|
text.erase(m_caret, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->select = -1;
|
m_select = -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EntryCmd::Paste: {
|
case EntryCmd::Paste: {
|
||||||
@ -611,18 +542,18 @@ static void entry_execute_cmd(JWidget widget, EntryCmd::Type cmd,
|
|||||||
if (selbeg >= 0) {
|
if (selbeg >= 0) {
|
||||||
text.erase(selbeg, selend-selbeg+1);
|
text.erase(selbeg, selend-selbeg+1);
|
||||||
|
|
||||||
entry->cursor = selbeg;
|
m_caret = selbeg;
|
||||||
entry->select = -1;
|
m_select = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// paste text
|
// paste text
|
||||||
for (c=0; c<ustrlen(clipboard); c++)
|
for (c=0; c<ustrlen(clipboard); c++)
|
||||||
if (text.size() < entry->maxsize)
|
if (text.size() < m_maxsize)
|
||||||
text.insert(entry->cursor+c, 1, ugetat(clipboard, c));
|
text.insert(m_caret+c, 1, ugetat(clipboard, c));
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
|
||||||
jentry_set_cursor_pos(widget, entry->cursor+c);
|
setCaretPos(m_caret+c);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -639,70 +570,68 @@ static void entry_execute_cmd(JWidget widget, EntryCmd::Type cmd,
|
|||||||
if (selbeg >= 0) {
|
if (selbeg >= 0) {
|
||||||
text.erase(selbeg, selend-selbeg+1);
|
text.erase(selbeg, selend-selbeg+1);
|
||||||
|
|
||||||
entry->cursor = selbeg;
|
m_caret = selbeg;
|
||||||
}
|
}
|
||||||
// delete the previous character
|
// delete the previous character
|
||||||
else {
|
else {
|
||||||
if (entry->cursor > 0)
|
if (m_caret > 0)
|
||||||
text.erase(--entry->cursor, 1);
|
text.erase(--m_caret, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->select = -1;
|
m_select = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text != widget->getText()) {
|
if (text != this->getText()) {
|
||||||
widget->setText(text.c_str());
|
this->setText(text.c_str());
|
||||||
jwidget_emit_signal(widget, JI_SIGNAL_ENTRY_CHANGE);
|
onEntryChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
jentry_set_cursor_pos(widget, entry->cursor);
|
setCaretPos(m_caret);
|
||||||
widget->dirty();
|
dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IS_WORD_CHAR(ch) \
|
#define IS_WORD_CHAR(ch) \
|
||||||
(!((!ch) || (uisspace(ch)) || \
|
(!((!ch) || (uisspace(ch)) || \
|
||||||
((ch) == '/') || ((ch) == OTHER_PATH_SEPARATOR)))
|
((ch) == '/') || ((ch) == OTHER_PATH_SEPARATOR)))
|
||||||
|
|
||||||
static void entry_forward_word(JWidget widget)
|
void Entry::forwardWord()
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
for (; entry->cursor<ustrlen(widget->getText()); entry->cursor++) {
|
for (; m_caret<ustrlen(this->getText()); m_caret++) {
|
||||||
ch = ugetat(widget->getText(), entry->cursor);
|
ch = ugetat(this->getText(), m_caret);
|
||||||
if (IS_WORD_CHAR (ch))
|
if (IS_WORD_CHAR (ch))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; entry->cursor<ustrlen(widget->getText()); entry->cursor++) {
|
for (; m_caret<ustrlen(this->getText()); m_caret++) {
|
||||||
ch = ugetat(widget->getText(), entry->cursor);
|
ch = ugetat(this->getText(), m_caret);
|
||||||
if (!IS_WORD_CHAR(ch)) {
|
if (!IS_WORD_CHAR(ch)) {
|
||||||
entry->cursor++;
|
m_caret++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void entry_backward_word(JWidget widget)
|
void Entry::backwardWord()
|
||||||
{
|
{
|
||||||
Entry* entry = reinterpret_cast<Entry*>(jwidget_get_data(widget, JI_ENTRY));
|
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
for (entry->cursor--; entry->cursor >= 0; entry->cursor--) {
|
for (m_caret--; m_caret >= 0; m_caret--) {
|
||||||
ch = ugetat(widget->getText(), entry->cursor);
|
ch = ugetat(this->getText(), m_caret);
|
||||||
if (IS_WORD_CHAR(ch))
|
if (IS_WORD_CHAR(ch))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; entry->cursor >= 0; entry->cursor--) {
|
for (; m_caret >= 0; m_caret--) {
|
||||||
ch = ugetat(widget->getText(), entry->cursor);
|
ch = ugetat(this->getText(), m_caret);
|
||||||
if (!IS_WORD_CHAR(ch)) {
|
if (!IS_WORD_CHAR(ch)) {
|
||||||
entry->cursor++;
|
m_caret++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry->cursor < 0)
|
if (m_caret < 0)
|
||||||
entry->cursor = 0;
|
m_caret = 0;
|
||||||
}
|
}
|
||||||
|
@ -7,25 +7,76 @@
|
|||||||
#ifndef GUI_ENTRY_H_INCLUDED
|
#ifndef GUI_ENTRY_H_INCLUDED
|
||||||
#define GUI_ENTRY_H_INCLUDED
|
#define GUI_ENTRY_H_INCLUDED
|
||||||
|
|
||||||
#include "gui/jbase.h"
|
#include "base/signal.h"
|
||||||
|
#include "gui/widget.h"
|
||||||
|
|
||||||
JWidget jentry_new(size_t maxsize, const char *format, ...);
|
class Entry : public Widget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Entry(size_t maxsize, const char *format, ...);
|
||||||
|
~Entry();
|
||||||
|
|
||||||
void jentry_readonly(JWidget entry, bool state);
|
bool isPassword() const;
|
||||||
void jentry_password(JWidget entry, bool state);
|
bool isReadOnly() const;
|
||||||
bool jentry_is_password(JWidget entry);
|
void setReadOnly(bool state);
|
||||||
bool jentry_is_readonly(JWidget entry);
|
void setPassword(bool state);
|
||||||
|
|
||||||
void jentry_show_cursor(JWidget entry);
|
void showCaret();
|
||||||
void jentry_hide_cursor(JWidget entry);
|
void hideCaret();
|
||||||
|
|
||||||
void jentry_set_cursor_pos(JWidget entry, int pos);
|
void setCaretPos(int pos);
|
||||||
void jentry_select_text(JWidget entry, int from, int to);
|
void selectText(int from, int to);
|
||||||
void jentry_deselect_text(JWidget entry);
|
void deselectText();
|
||||||
|
|
||||||
/* for themes */
|
// for themes
|
||||||
void jtheme_entry_info(JWidget entry,
|
void getEntryThemeInfo(int* scroll, int* caret, int* state,
|
||||||
int *scroll, int *cursor, int *state,
|
int* selbeg, int* selend);
|
||||||
int *selbeg, int *selend);
|
|
||||||
|
// Signals
|
||||||
|
Signal0<void> EntryChange;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Events
|
||||||
|
bool onProcessMessage(JMessage msg);
|
||||||
|
void onPreferredSize(PreferredSizeEvent& ev);
|
||||||
|
|
||||||
|
// New Events
|
||||||
|
void onEntryChange();
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct EntryCmd {
|
||||||
|
enum Type {
|
||||||
|
NoOp,
|
||||||
|
InsertChar,
|
||||||
|
ForwardChar,
|
||||||
|
ForwardWord,
|
||||||
|
BackwardChar,
|
||||||
|
BackwardWord,
|
||||||
|
BeginningOfLine,
|
||||||
|
EndOfLine,
|
||||||
|
DeleteForward,
|
||||||
|
DeleteBackward,
|
||||||
|
Cut,
|
||||||
|
Copy,
|
||||||
|
Paste,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
int getCaretFromMouse(JMessage msg);
|
||||||
|
void executeCmd(EntryCmd::Type cmd, int ascii, bool shift_pressed);
|
||||||
|
void forwardWord();
|
||||||
|
void backwardWord();
|
||||||
|
|
||||||
|
size_t m_maxsize;
|
||||||
|
int m_caret;
|
||||||
|
int m_scroll;
|
||||||
|
int m_select;
|
||||||
|
int m_timer_id;
|
||||||
|
bool m_hidden : 1;
|
||||||
|
bool m_state : 1; // show or not the text caret
|
||||||
|
bool m_readonly : 1;
|
||||||
|
bool m_password : 1;
|
||||||
|
bool m_recent_focused : 1;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,7 +32,7 @@ static bool combobox_listbox_msg_proc(JWidget widget, JMessage msg);
|
|||||||
ComboBox::ComboBox()
|
ComboBox::ComboBox()
|
||||||
: Widget(JI_COMBOBOX)
|
: Widget(JI_COMBOBOX)
|
||||||
{
|
{
|
||||||
m_entry = jentry_new(256, "");
|
m_entry = new Entry(256, "");
|
||||||
m_button = new Button("");
|
m_button = new Button("");
|
||||||
m_window = NULL;
|
m_window = NULL;
|
||||||
m_selected = 0;
|
m_selected = 0;
|
||||||
@ -73,12 +73,12 @@ void ComboBox::setEditable(bool state)
|
|||||||
m_editable = state;
|
m_editable = state;
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
jentry_readonly(m_entry, false);
|
m_entry->setReadOnly(false);
|
||||||
jentry_show_cursor(m_entry);
|
m_entry->showCaret();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
jentry_readonly(m_entry, true);
|
m_entry->setReadOnly(true);
|
||||||
jentry_hide_cursor(m_entry);
|
m_entry->hideCaret();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ void ComboBox::setItemData(int itemIndex, void* data)
|
|||||||
item->data = data;
|
item->data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget* ComboBox::getEntryWidget()
|
Entry* ComboBox::getEntryWidget()
|
||||||
{
|
{
|
||||||
return m_entry;
|
return m_entry;
|
||||||
}
|
}
|
||||||
@ -350,8 +350,10 @@ static bool combobox_entry_msg_proc(JWidget widget, JMessage msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case JM_DRAW:
|
case JM_DRAW:
|
||||||
widget->theme->draw_combobox_entry(widget, &msg->draw.rect);
|
widget->theme->draw_combobox_entry(static_cast<Entry*>(widget),
|
||||||
|
&msg->draw.rect);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -11,8 +11,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class Frame;
|
|
||||||
class Button;
|
class Button;
|
||||||
|
class Entry;
|
||||||
|
class Frame;
|
||||||
|
|
||||||
class ComboBox : public Widget
|
class ComboBox : public Widget
|
||||||
{
|
{
|
||||||
@ -45,7 +46,7 @@ public:
|
|||||||
void* getItemData(int itemIndex);
|
void* getItemData(int itemIndex);
|
||||||
void setItemData(int itemIndex, void* data);
|
void setItemData(int itemIndex, void* data);
|
||||||
|
|
||||||
Widget* getEntryWidget();
|
Entry* getEntryWidget();
|
||||||
Button* getButtonWidget();
|
Button* getButtonWidget();
|
||||||
|
|
||||||
void openListBox();
|
void openListBox();
|
||||||
@ -62,7 +63,7 @@ private:
|
|||||||
|
|
||||||
struct Item;
|
struct Item;
|
||||||
|
|
||||||
Widget* m_entry;
|
Entry* m_entry;
|
||||||
Button* m_button;
|
Button* m_button;
|
||||||
Frame* m_window;
|
Frame* m_window;
|
||||||
Widget* m_listbox;
|
Widget* m_listbox;
|
||||||
|
@ -9,9 +9,11 @@
|
|||||||
|
|
||||||
#include "gui/jbase.h"
|
#include "gui/jbase.h"
|
||||||
|
|
||||||
struct FONT;
|
|
||||||
struct BITMAP;
|
struct BITMAP;
|
||||||
|
struct FONT;
|
||||||
|
|
||||||
class ButtonBase;
|
class ButtonBase;
|
||||||
|
class Entry;
|
||||||
class Slider;
|
class Slider;
|
||||||
|
|
||||||
class jtheme
|
class jtheme
|
||||||
@ -46,7 +48,7 @@ public:
|
|||||||
virtual void draw_box(JWidget widget, JRect clip) = 0;
|
virtual void draw_box(JWidget widget, JRect clip) = 0;
|
||||||
virtual void draw_button(ButtonBase* widget, JRect clip) = 0;
|
virtual void draw_button(ButtonBase* widget, JRect clip) = 0;
|
||||||
virtual void draw_check(ButtonBase* widget, JRect clip) = 0;
|
virtual void draw_check(ButtonBase* widget, JRect clip) = 0;
|
||||||
virtual void draw_entry(JWidget widget, JRect clip) = 0;
|
virtual void draw_entry(Entry* widget, JRect clip) = 0;
|
||||||
virtual void draw_grid(JWidget widget, JRect clip) = 0;
|
virtual void draw_grid(JWidget widget, JRect clip) = 0;
|
||||||
virtual void draw_label(JWidget widget, JRect clip) = 0;
|
virtual void draw_label(JWidget widget, JRect clip) = 0;
|
||||||
virtual void draw_link_label(JWidget widget, JRect clip) = 0;
|
virtual void draw_link_label(JWidget widget, JRect clip) = 0;
|
||||||
@ -58,7 +60,7 @@ public:
|
|||||||
virtual void draw_radio(ButtonBase* widget, JRect clip) = 0;
|
virtual void draw_radio(ButtonBase* widget, JRect clip) = 0;
|
||||||
virtual void draw_separator(JWidget widget, JRect clip) = 0;
|
virtual void draw_separator(JWidget widget, JRect clip) = 0;
|
||||||
virtual void draw_slider(Slider* widget, JRect clip) = 0;
|
virtual void draw_slider(Slider* widget, JRect clip) = 0;
|
||||||
virtual void draw_combobox_entry(JWidget widget, JRect clip) = 0;
|
virtual void draw_combobox_entry(Entry* widget, JRect clip) = 0;
|
||||||
virtual void draw_combobox_button(ButtonBase* widget, JRect clip) = 0;
|
virtual void draw_combobox_button(ButtonBase* widget, JRect clip) = 0;
|
||||||
virtual void draw_textbox(JWidget widget, JRect clip) = 0;
|
virtual void draw_textbox(JWidget widget, JRect clip) = 0;
|
||||||
virtual void draw_view(JWidget widget, JRect clip) = 0;
|
virtual void draw_view(JWidget widget, JRect clip) = 0;
|
||||||
|
@ -89,7 +89,7 @@ public:
|
|||||||
void draw_box(JWidget widget, JRect clip);
|
void draw_box(JWidget widget, JRect clip);
|
||||||
void draw_button(ButtonBase* widget, JRect clip);
|
void draw_button(ButtonBase* widget, JRect clip);
|
||||||
void draw_check(ButtonBase* widget, JRect clip);
|
void draw_check(ButtonBase* widget, JRect clip);
|
||||||
void draw_entry(JWidget widget, JRect clip);
|
void draw_entry(Entry* widget, JRect clip);
|
||||||
void draw_grid(JWidget widget, JRect clip);
|
void draw_grid(JWidget widget, JRect clip);
|
||||||
void draw_label(JWidget widget, JRect clip);
|
void draw_label(JWidget widget, JRect clip);
|
||||||
void draw_link_label(JWidget widget, JRect clip);
|
void draw_link_label(JWidget widget, JRect clip);
|
||||||
@ -101,7 +101,7 @@ public:
|
|||||||
void draw_radio(ButtonBase* widget, JRect clip);
|
void draw_radio(ButtonBase* widget, JRect clip);
|
||||||
void draw_separator(JWidget widget, JRect clip);
|
void draw_separator(JWidget widget, JRect clip);
|
||||||
void draw_slider(Slider* widget, JRect clip);
|
void draw_slider(Slider* widget, JRect clip);
|
||||||
void draw_combobox_entry(JWidget widget, JRect clip);
|
void draw_combobox_entry(Entry* widget, JRect clip);
|
||||||
void draw_combobox_button(ButtonBase* widget, JRect clip);
|
void draw_combobox_button(ButtonBase* widget, JRect clip);
|
||||||
void draw_textbox(JWidget widget, JRect clip);
|
void draw_textbox(JWidget widget, JRect clip);
|
||||||
void draw_view(JWidget widget, JRect clip);
|
void draw_view(JWidget widget, JRect clip);
|
||||||
@ -115,7 +115,7 @@ private:
|
|||||||
void draw_textstring(const char *t, int fg_color, int bg_color,
|
void draw_textstring(const char *t, int fg_color, int bg_color,
|
||||||
bool fill_bg, JWidget widget, const JRect rect,
|
bool fill_bg, JWidget widget, const JRect rect,
|
||||||
int selected_offset);
|
int selected_offset);
|
||||||
void draw_entry_cursor(JWidget widget, int x, int y);
|
void draw_entry_caret(Entry* widget, int x, int y);
|
||||||
void draw_icons(int x, int y, JWidget widget, int edge_icon);
|
void draw_icons(int x, int y, JWidget widget, int edge_icon);
|
||||||
void draw_edges(int x1, int y1, int x2, int y2, int c1, int c2);
|
void draw_edges(int x1, int y1, int x2, int y2, int c1, int c2);
|
||||||
|
|
||||||
@ -587,16 +587,16 @@ void jstandard_theme::draw_grid(JWidget widget, JRect clip)
|
|||||||
jdraw_rectfill(clip, get_bg_color(widget));
|
jdraw_rectfill(clip, get_bg_color(widget));
|
||||||
}
|
}
|
||||||
|
|
||||||
void jstandard_theme::draw_entry(JWidget widget, JRect clip)
|
void jstandard_theme::draw_entry(Entry* widget, JRect clip)
|
||||||
{
|
{
|
||||||
bool password = jentry_is_password(widget);
|
bool password = widget->isPassword();
|
||||||
int scroll, cursor, state, selbeg, selend;
|
int scroll, caret, state, selbeg, selend;
|
||||||
const char *text = widget->getText();
|
const char *text = widget->getText();
|
||||||
int c, ch, x, y, w, fg, bg;
|
int c, ch, x, y, w, fg, bg;
|
||||||
int x1, y1, x2, y2;
|
int x1, y1, x2, y2;
|
||||||
int cursor_x;
|
int caret_x;
|
||||||
|
|
||||||
jtheme_entry_info(widget, &scroll, &cursor, &state, &selbeg, &selend);
|
widget->getEntryThemeInfo(&scroll, &caret, &state, &selbeg, &selend);
|
||||||
|
|
||||||
/* main pos */
|
/* main pos */
|
||||||
x1 = widget->rc->x1;
|
x1 = widget->rc->x1;
|
||||||
@ -651,22 +651,22 @@ void jstandard_theme::draw_entry(JWidget widget, JRect clip)
|
|||||||
if (x+w > widget->rc->x2-3)
|
if (x+w > widget->rc->x2-3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cursor_x = x;
|
caret_x = x;
|
||||||
ji_font_set_aa_mode(widget->getFont(), bg >= 0 ? bg: COLOR_BACKGROUND);
|
ji_font_set_aa_mode(widget->getFont(), bg >= 0 ? bg: COLOR_BACKGROUND);
|
||||||
widget->getFont()->vtable->render_char(widget->getFont(),
|
widget->getFont()->vtable->render_char(widget->getFont(),
|
||||||
ch, fg, bg, ji_screen, x, y);
|
ch, fg, bg, ji_screen, x, y);
|
||||||
x += w;
|
x += w;
|
||||||
|
|
||||||
/* cursor */
|
/* caret */
|
||||||
if ((c == cursor) && (state) && (widget->hasFocus()))
|
if ((c == caret) && (state) && (widget->hasFocus()))
|
||||||
draw_entry_cursor(widget, cursor_x, y);
|
draw_entry_caret(widget, caret_x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw the cursor if it is next of the last character */
|
/* draw the caret if it is next of the last character */
|
||||||
if ((c == cursor) && (state) &&
|
if ((c == caret) && (state) &&
|
||||||
(widget->hasFocus()) &&
|
(widget->hasFocus()) &&
|
||||||
(widget->isEnabled()))
|
(widget->isEnabled()))
|
||||||
draw_entry_cursor(widget, x, y);
|
draw_entry_caret(widget, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void jstandard_theme::draw_label(JWidget widget, JRect clip)
|
void jstandard_theme::draw_label(JWidget widget, JRect clip)
|
||||||
@ -1109,7 +1109,7 @@ void jstandard_theme::draw_slider(Slider* widget, JRect clip)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void jstandard_theme::draw_combobox_entry(JWidget widget, JRect clip)
|
void jstandard_theme::draw_combobox_entry(Entry* widget, JRect clip)
|
||||||
{
|
{
|
||||||
draw_entry(widget, clip);
|
draw_entry(widget, clip);
|
||||||
}
|
}
|
||||||
@ -1334,7 +1334,7 @@ void jstandard_theme::draw_textstring(const char *t, int fg_color, int bg_color,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void jstandard_theme::draw_entry_cursor(JWidget widget, int x, int y)
|
void jstandard_theme::draw_entry_caret(Entry* widget, int x, int y)
|
||||||
{
|
{
|
||||||
int h = jwidget_get_text_height(widget);
|
int h = jwidget_get_text_height(widget);
|
||||||
|
|
||||||
|
@ -749,16 +749,16 @@ void SkinneableTheme::draw_grid(JWidget widget, JRect clip)
|
|||||||
jdraw_rectfill(clip, BGCOLOR);
|
jdraw_rectfill(clip, BGCOLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinneableTheme::draw_entry(JWidget widget, JRect clip)
|
void SkinneableTheme::draw_entry(Entry* widget, JRect clip)
|
||||||
{
|
{
|
||||||
bool password = jentry_is_password(widget);
|
bool password = widget->isPassword();
|
||||||
int scroll, cursor, state, selbeg, selend;
|
int scroll, caret, state, selbeg, selend;
|
||||||
const char *text = widget->getText();
|
const char *text = widget->getText();
|
||||||
int c, ch, x, y, w, fg, bg;
|
int c, ch, x, y, w, fg, bg;
|
||||||
int x1, y1, x2, y2;
|
int x1, y1, x2, y2;
|
||||||
int cursor_x;
|
int caret_x;
|
||||||
|
|
||||||
jtheme_entry_info(widget, &scroll, &cursor, &state, &selbeg, &selend);
|
widget->getEntryThemeInfo(&scroll, &caret, &state, &selbeg, &selend);
|
||||||
|
|
||||||
/* main pos */
|
/* main pos */
|
||||||
x1 = widget->rc->x1;
|
x1 = widget->rc->x1;
|
||||||
@ -803,22 +803,22 @@ void SkinneableTheme::draw_entry(JWidget widget, JRect clip)
|
|||||||
if (x+w > widget->rc->x2-3)
|
if (x+w > widget->rc->x2-3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cursor_x = x;
|
caret_x = x;
|
||||||
ji_font_set_aa_mode(widget->getFont(), bg >= 0 ? bg: COLOR_BACKGROUND);
|
ji_font_set_aa_mode(widget->getFont(), bg >= 0 ? bg: COLOR_BACKGROUND);
|
||||||
widget->getFont()->vtable->render_char(widget->getFont(),
|
widget->getFont()->vtable->render_char(widget->getFont(),
|
||||||
ch, fg, bg, ji_screen, x, y);
|
ch, fg, bg, ji_screen, x, y);
|
||||||
x += w;
|
x += w;
|
||||||
|
|
||||||
/* cursor */
|
/* caret */
|
||||||
if ((c == cursor) && (state) && (widget->hasFocus()))
|
if ((c == caret) && (state) && (widget->hasFocus()))
|
||||||
draw_entry_cursor(widget, cursor_x, y);
|
draw_entry_caret(widget, caret_x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw the cursor if it is next of the last character */
|
/* draw the caret if it is next of the last character */
|
||||||
if ((c == cursor) && (state) &&
|
if ((c == caret) && (state) &&
|
||||||
(widget->hasFocus()) &&
|
(widget->hasFocus()) &&
|
||||||
(widget->isEnabled()))
|
(widget->isEnabled()))
|
||||||
draw_entry_cursor(widget, x, y);
|
draw_entry_caret(widget, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinneableTheme::draw_label(JWidget widget, JRect clip)
|
void SkinneableTheme::draw_label(JWidget widget, JRect clip)
|
||||||
@ -1195,16 +1195,16 @@ void SkinneableTheme::draw_slider(Slider* widget, JRect clip)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinneableTheme::draw_combobox_entry(JWidget widget, JRect clip)
|
void SkinneableTheme::draw_combobox_entry(Entry* widget, JRect clip)
|
||||||
{
|
{
|
||||||
bool password = jentry_is_password(widget);
|
bool password = widget->isPassword();
|
||||||
int scroll, cursor, state, selbeg, selend;
|
int scroll, caret, state, selbeg, selend;
|
||||||
const char *text = widget->getText();
|
const char *text = widget->getText();
|
||||||
int c, ch, x, y, w, fg, bg;
|
int c, ch, x, y, w, fg, bg;
|
||||||
int x1, y1, x2, y2;
|
int x1, y1, x2, y2;
|
||||||
int cursor_x;
|
int caret_x;
|
||||||
|
|
||||||
jtheme_entry_info(widget, &scroll, &cursor, &state, &selbeg, &selend);
|
widget->getEntryThemeInfo(&scroll, &caret, &state, &selbeg, &selend);
|
||||||
|
|
||||||
/* main pos */
|
/* main pos */
|
||||||
x1 = widget->rc->x1;
|
x1 = widget->rc->x1;
|
||||||
@ -1249,22 +1249,22 @@ void SkinneableTheme::draw_combobox_entry(JWidget widget, JRect clip)
|
|||||||
if (x+w > widget->rc->x2-3)
|
if (x+w > widget->rc->x2-3)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cursor_x = x;
|
caret_x = x;
|
||||||
ji_font_set_aa_mode(widget->getFont(), bg >= 0 ? bg: COLOR_BACKGROUND);
|
ji_font_set_aa_mode(widget->getFont(), bg >= 0 ? bg: COLOR_BACKGROUND);
|
||||||
widget->getFont()->vtable->render_char(widget->getFont(),
|
widget->getFont()->vtable->render_char(widget->getFont(),
|
||||||
ch, fg, bg, ji_screen, x, y);
|
ch, fg, bg, ji_screen, x, y);
|
||||||
x += w;
|
x += w;
|
||||||
|
|
||||||
/* cursor */
|
/* caret */
|
||||||
if ((c == cursor) && (state) && (widget->hasFocus()))
|
if ((c == caret) && (state) && (widget->hasFocus()))
|
||||||
draw_entry_cursor(widget, cursor_x, y);
|
draw_entry_caret(widget, caret_x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw the cursor if it is next of the last character */
|
/* draw the caret if it is next of the last character */
|
||||||
if ((c == cursor) && (state) &&
|
if ((c == caret) && (state) &&
|
||||||
(widget->hasFocus()) &&
|
(widget->hasFocus()) &&
|
||||||
(widget->isEnabled()))
|
(widget->isEnabled()))
|
||||||
draw_entry_cursor(widget, x, y);
|
draw_entry_caret(widget, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinneableTheme::draw_combobox_button(ButtonBase* widget, JRect clip)
|
void SkinneableTheme::draw_combobox_button(ButtonBase* widget, JRect clip)
|
||||||
@ -1514,7 +1514,7 @@ void SkinneableTheme::draw_textstring(const char *t, int fg_color, int bg_color,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinneableTheme::draw_entry_cursor(JWidget widget, int x, int y)
|
void SkinneableTheme::draw_entry_caret(Entry* widget, int x, int y)
|
||||||
{
|
{
|
||||||
int h = jwidget_get_text_height(widget);
|
int h = jwidget_get_text_height(widget);
|
||||||
|
|
||||||
|
@ -450,7 +450,7 @@ public:
|
|||||||
void draw_box(JWidget widget, JRect clip);
|
void draw_box(JWidget widget, JRect clip);
|
||||||
void draw_button(ButtonBase* widget, JRect clip);
|
void draw_button(ButtonBase* widget, JRect clip);
|
||||||
void draw_check(ButtonBase* widget, JRect clip);
|
void draw_check(ButtonBase* widget, JRect clip);
|
||||||
void draw_entry(JWidget widget, JRect clip);
|
void draw_entry(Entry* widget, JRect clip);
|
||||||
void draw_grid(JWidget widget, JRect clip);
|
void draw_grid(JWidget widget, JRect clip);
|
||||||
void draw_label(JWidget widget, JRect clip);
|
void draw_label(JWidget widget, JRect clip);
|
||||||
void draw_link_label(JWidget widget, JRect clip);
|
void draw_link_label(JWidget widget, JRect clip);
|
||||||
@ -462,7 +462,7 @@ public:
|
|||||||
void draw_radio(ButtonBase* widget, JRect clip);
|
void draw_radio(ButtonBase* widget, JRect clip);
|
||||||
void draw_separator(JWidget widget, JRect clip);
|
void draw_separator(JWidget widget, JRect clip);
|
||||||
void draw_slider(Slider* widget, JRect clip);
|
void draw_slider(Slider* widget, JRect clip);
|
||||||
void draw_combobox_entry(JWidget widget, JRect clip);
|
void draw_combobox_entry(Entry* widget, JRect clip);
|
||||||
void draw_combobox_button(ButtonBase* widget, JRect clip);
|
void draw_combobox_button(ButtonBase* widget, JRect clip);
|
||||||
void draw_textbox(JWidget widget, JRect clip);
|
void draw_textbox(JWidget widget, JRect clip);
|
||||||
void draw_view(JWidget widget, JRect clip);
|
void draw_view(JWidget widget, JRect clip);
|
||||||
@ -542,7 +542,7 @@ private:
|
|||||||
void draw_textstring(const char *t, int fg_color, int bg_color,
|
void draw_textstring(const char *t, int fg_color, int bg_color,
|
||||||
bool fill_bg, JWidget widget, const JRect rect,
|
bool fill_bg, JWidget widget, const JRect rect,
|
||||||
int selected_offset);
|
int selected_offset);
|
||||||
void draw_entry_cursor(JWidget widget, int x, int y);
|
void draw_entry_caret(Entry* widget, int x, int y);
|
||||||
void draw_bevel_box(int x1, int y1, int x2, int y2, int c1, int c2, int *bevel);
|
void draw_bevel_box(int x1, int y1, int x2, int y2, int c1, int c2, int *bevel);
|
||||||
void less_bevel(int *bevel);
|
void less_bevel(int *bevel);
|
||||||
|
|
||||||
|
@ -177,11 +177,11 @@ static Widget* convert_xmlelement_to_widget(TiXmlElement* elem, Widget* root)
|
|||||||
if (maxsize != NULL) {
|
if (maxsize != NULL) {
|
||||||
bool readonly = bool_attr_is_true(elem, "readonly");
|
bool readonly = bool_attr_is_true(elem, "readonly");
|
||||||
|
|
||||||
widget = jentry_new(ustrtol(maxsize, NULL, 10),
|
widget = new Entry(ustrtol(maxsize, NULL, 10),
|
||||||
text ? TRANSLATE_ATTR(text): NULL);
|
text ? TRANSLATE_ATTR(text): NULL);
|
||||||
|
|
||||||
if (readonly)
|
if (readonly)
|
||||||
jentry_readonly(widget, true);
|
((Entry*)widget)->setReadOnly(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* grid */
|
/* grid */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user