}
BC_TextBox::BC_TextBox(int x, int y, int w, int rows,
- int size, wchar_t *wtext, int has_border, int font)
+ int size, wchr_t *wtext, int has_border, int font)
: BC_SubWindow(x, y, w, 0, -1)
{
is_utf8 = 1;
skip_cursor = 0;
reset_parameters(rows, has_border, font, size);
- wdemand(wcslen(wtext));
- wcsncpy(this->wtext, wtext, wsize);
+ wdemand(wstrlen(wtext));
+ wstrncpy(this->wtext, wtext, wsize);
}
BC_TextBox::BC_TextBox(int x, int y, int w, int rows,
}
BC_TextBox::BC_TextBox(int x, int y, int w, int rows,
- const wchar_t *wtext, int has_border, int font, int is_utf8)
+ const wchr_t *wtext, int has_border, int font, int is_utf8)
: BC_SubWindow(x, y, w, 0, -1)
{
this->is_utf8 = is_utf8;
skip_cursor = 0;
reset_parameters(rows, has_border, font, BCTEXTLEN);
wsize = BCTEXTLEN;
- wtext = new wchar_t[wsize+1];
- wcsncpy(this->wtext, wtext, wsize);
+ wtext = new wchr_t[wsize+1];
+ wstrncpy(this->wtext, wtext, wsize);
this->wtext[wsize] = 0;
}
int nsize = tsize > 0 ? tsize : tlen + BCTEXTLEN;
wdemand(nsize);
wlen = BC_Resources::encode(src_enc, dst_enc, text, tlen,
- (char*)wtext, wsize*sizeof(wchar_t)) / sizeof(wchar_t);
+ (char*)wtext, wsize*sizeof(wchr_t)) / sizeof(wchr_t);
dirty = 0;
}
wtext[wlen] = 0;
return wlen;
}
-int BC_TextBox::text_update(const wchar_t *wcp, int wsz, char *tcp, int tsz)
+int BC_TextBox::text_update(const wchr_t *wcp, int wsz, char *tcp, int tsz)
{
const char *src_enc = BC_Resources::wide_encoding;
const char *dst_enc = BC_Resources::encoding;
- if( wsz < 0 ) wsz = wcslen(wcp);
+ if( wsz < 0 ) wsz = wstrlen(wcp);
int len = BC_Resources::encode(src_enc, dst_enc,
- (char*)wcp, wsz*sizeof(wchar_t), tcp, tsz);
+ (char*)wcp, wsz*sizeof(wchr_t), tcp, tsz);
tcp[len] = 0;
return len;
}
return 0;
}
-int BC_TextBox::update(const wchar_t *wtext)
+int BC_TextBox::update(const wchr_t *wtext)
{
- int wtext_len = wcslen(wtext);
+ int wtext_len = wstrlen(wtext);
wdemand(wtext_len);
- wcsncpy(this->wtext, wtext, wsize);
+ wstrncpy(this->wtext, wtext, wsize);
this->wlen = wtext_len;
if(highlight_letter1 > wtext_len) highlight_letter1 = wtext_len;
if(highlight_letter2 > wtext_len) highlight_letter2 = wtext_len;
return text;
}
-const wchar_t* BC_TextBox::get_wtext()
+const wchr_t* BC_TextBox::get_wtext()
{
wtext_update();
return wtext;
for(i=0, k=text_y; i < wtext_len && k < get_h(); k += text_height) {
// Draw row of text
row_begin = i;
- wchar_t *wtext_row = &wtext[i];
+ wchr_t *wtext_row = &wtext[i];
for( ; i<wtext_len && wtext[i]!='\n'; ++i );
if( (row_end=i) < wtext_len ) ++i;
void BC_TextBox::default_keypress(int &dispatch_event, int &result)
{
int key = top_level->get_keypress(), len;
- wchar_t *wkeys = top_level->get_wkeystring(&len);
+ wchr_t *wkeys = top_level->get_wkeystring(&len);
switch( key ) {
case KPENTER: key = '\n'; goto kpchr;
case KPMINUS: key = '-'; goto kpchr;
last_keypress = get_keypress();
if( unicode_active >= 0 ) {
- wchar_t wch = 0;
+ wchr_t wch = 0;
int wlen = -1;
switch( last_keypress ) {
//unicode active acitons
case 'u': case 'U': {
if( shift_down() ) {
unicode_active = ibeam_letter;
- wchar_t wkey = 'U';
+ wchr_t wkey = 'U';
insert_text(&wkey, 1);
find_ibeam(1);
highlight_letter1 = unicode_active;
{
if( wtext && wsize >= len ) return 0;
int nsize = len + wlen/2 + BCTEXTLEN;
- wchar_t *ntext = new wchar_t[nsize+1];
+ wchr_t *ntext = new wchr_t[nsize+1];
ntext[nsize] = 0;
memcpy(ntext, wtext, wsize*sizeof(wtext[0]));
delete [] wtext; wtext = ntext; wsize = nsize;
return 1;
}
-void BC_TextBox::insert_text(const wchar_t *wcp, int len)
+void BC_TextBox::insert_text(const wchr_t *wcp, int len)
{
- if( len < 0 ) len = wcslen(wcp);
+ if( len < 0 ) len = wstrlen(wcp);
int wtext_len = wtext_update();
wdemand(wtext_len + len + 1);
if( unicode_active < 0 && highlight_letter1 < highlight_letter2 ) {
int len = clipboard_len(clipboard_num);
if( len > 0 )
{
- char cstring[len]; wchar_t wstring[len];
+ char cstring[len]; wchr_t wstring[len];
from_clipboard(cstring, len, clipboard_num); --len;
//printf("BC_TextBox::paste_selection %d '%*.*s'\n",len,len,len,cstring);
len = BC_Resources::encode(BC_Resources::encoding, BC_Resources::wide_encoding,
- cstring,len, (char *)wstring,(len+1)*sizeof(wchar_t)) / sizeof(wchar_t);
+ cstring,len, (char *)wstring,(len+1)*sizeof(wchr_t)) / sizeof(wchr_t);
insert_text(wstring, len);
last_keypress = 0;
}
BC_ScrollTextBox::BC_ScrollTextBox(BC_WindowBase *parent_window,
int x, int y, int w, int rows,
- const wchar_t *default_wtext, int default_size)
+ const wchr_t *default_wtext, int default_size)
{
this->parent_window = parent_window;
this->x = x;
update_scrollbars();
}
-void BC_ScrollTextBox::update(const wchar_t *wtext)
+void BC_ScrollTextBox::update(const wchr_t *wtext)
{
this->text->update(wtext);
update_scrollbars();
int BC_ScrollTextBox::get_h() { return text->get_h(); }
const char *BC_ScrollTextBox::get_text() { return text->get_text(); }
-const wchar_t *BC_ScrollTextBox::get_wtext() { return text->get_wtext(); }
+const wchr_t *BC_ScrollTextBox::get_wtext() { return text->get_wtext(); }
int BC_ScrollTextBox::get_buttonpress()
{
this->gui = gui;
}
-BC_ScrollTextBoxText::BC_ScrollTextBoxText(BC_ScrollTextBox *gui, const wchar_t *wtext)
+BC_ScrollTextBoxText::BC_ScrollTextBoxText(BC_ScrollTextBox *gui, const wchr_t *wtext)
: BC_TextBox(gui->x, gui->y,
gui->w - get_resources()->vscroll_data[SCROLL_HANDLE_UP]->get_w(),
- gui->rows, gui->default_size, (wchar_t*)wtext, 1, MEDIUMFONT)
+ gui->rows, gui->default_size, (wchr_t*)wtext, 1, MEDIUMFONT)
{
this->gui = gui;
}
this->popup = popup;
}
-BC_PopupTextBoxText::BC_PopupTextBoxText(BC_PopupTextBox *popup, int x, int y, const wchar_t *wtext)
+BC_PopupTextBoxText::BC_PopupTextBoxText(BC_PopupTextBox *popup, int x, int y, const wchr_t *wtext)
: BC_TextBox(x, y, popup->text_w, 1, wtext, BCTEXTLEN)
{
this->popup = popup;
int BC_PopupTextBoxText::handle_event()
{
+ popup->list_item = -1;
popup->handle_event();
return 1;
}
}
int BC_PopupTextBoxList::handle_event()
{
- BC_ListBoxItem *item = get_selection(0, 0);
- if(item)
- {
- popup->textbox->update(item->get_text());
+ int k = get_selection_number(0, 0);
+ popup->list_item = k;
+ if( k >= 0 && k < popup->list_items->size() ) {
+ popup->textbox->update(popup->list_items->get(k)->get_text());
popup->textbox->set_text_row(0);
popup->handle_event();
}
void BC_PopupTextBox::update_list(ArrayList<BC_ListBoxItem*> *data)
{
+ list_items = data;
listbox->update(data, 0, 0, 1);
}
-
-const char* BC_PopupTextBox::get_text()
-{
- return textbox->get_text();
-}
-
-const wchar_t* BC_PopupTextBox::get_wtext()
-{
- return textbox->get_wtext();
-}
-
-int BC_PopupTextBox::get_number()
-{
- return listbox->get_selection_number(0, 0);
-}
-
-int BC_PopupTextBox::get_x()
-{
- return x;
-}
-
-int BC_PopupTextBox::get_y()
-{
- return y;
-}
-
-int BC_PopupTextBox::get_w()
-{
- return textbox->get_w() + listbox->get_w();
-}
-
-int BC_PopupTextBox::get_h()
-{
- return textbox->get_h();
-}
-
-int BC_PopupTextBox::get_show_query()
+int BC_PopupTextBox::handle_event()
{
- return listbox->get_show_query();
+ return 1;
}
-void BC_PopupTextBox::set_show_query(int v)
-{
- listbox->set_show_query(v);
-}
+const char *BC_PopupTextBox::get_text() { return textbox->get_text(); }
+const wchr_t *BC_PopupTextBox::get_wtext() { return textbox->get_wtext(); }
+int BC_PopupTextBox::get_number() { return list_item; }
+void BC_PopupTextBox::set_number(int v) { list_item = v; }
+int BC_PopupTextBox::get_x() { return x; }
+int BC_PopupTextBox::get_y() { return y; }
+int BC_PopupTextBox::get_w() { return textbox->get_w() + listbox->get_w(); }
+int BC_PopupTextBox::get_h() { return textbox->get_h(); }
+int BC_PopupTextBox::get_show_query() { return listbox->get_show_query(); }
+void BC_PopupTextBox::set_show_query(int v) { listbox->set_show_query(v); }
+int BC_PopupTextBox::get_back_color() { return textbox->get_back_color(); }
+void BC_PopupTextBox::set_back_color(int v) { textbox->set_back_color(v); }
-int BC_PopupTextBox::handle_event()
+void BC_PopupTextBox::set_tooltip(const char *text)
{
- return 1;
+ listbox->set_tooltip(text);
}
void BC_PopupTextBox::reposition_window(int x, int y)
}
-
-
-
-
-
-
-
-
-
-
-
-
BC_TumbleTextBoxText::BC_TumbleTextBoxText(BC_TumbleTextBox *popup,
int64_t default_value, int x, int y)
: BC_TextBox(x, y, popup->text_w, 1, default_value)
-
BC_TumbleTextBox::BC_TumbleTextBox(BC_WindowBase *parent_window,
- int64_t default_value,
- int64_t min,
- int64_t max,
- int x,
- int y,
- int text_w)
+ int64_t default_value, int64_t min, int64_t max,
+ int x, int y, int text_w)
{
reset();
this->x = x;
}
BC_TumbleTextBox::BC_TumbleTextBox(BC_WindowBase *parent_window,
- int default_value,
- int min,
- int max,
- int x,
- int y,
- int text_w)
+ int default_value, int min, int max,
+ int x, int y, int text_w)
{
reset();
this->x = x;
}
BC_TumbleTextBox::BC_TumbleTextBox(BC_WindowBase *parent_window,
- float default_value_f,
- float min_f,
- float max_f,
- int x,
- int y,
- int text_w)
+ float default_value_f, float min_f, float max_f,
+ int x, int y, int text_w, int precision)
{
reset();
this->x = x;
this->max_f = max_f;
this->default_value_f = default_value_f;
this->text_w = text_w;
+ this->precision = precision;
this->parent_window = parent_window;
use_float = 1;
- precision = 4;
increment = 1;
}
x += textbox->get_w();
tumbler = use_float ?
- (BC_Tumbler *)new BC_FTumbler(textbox, min_f, max_f, x, y) :
- (BC_Tumbler *)new BC_ITumbler(textbox, min, max, x, y);
+ (BC_Tumbler *)new BC_FTextTumbler(this, min_f, max_f, x, y) :
+ (BC_Tumbler *)new BC_ITextTumbler(this, min, max, x, y);
parent_window->add_subwindow(tumbler);
tumbler->set_increment(increment);
return 0;
}
+int BC_TumbleTextBox::handle_up_event()
+{
+ return use_float ?
+ ((BC_FTumbler *)tumbler)->BC_FTumbler::handle_up_event() :
+ ((BC_ITumbler *)tumbler)->BC_ITumbler::handle_up_event() ;
+}
+
+int BC_TumbleTextBox::handle_down_event()
+{
+ return use_float ?
+ ((BC_FTumbler *)tumbler)->BC_FTumbler::handle_down_event() :
+ ((BC_ITumbler *)tumbler)->BC_ITumbler::handle_down_event() ;
+}
+
const char* BC_TumbleTextBox::get_text()
{
return textbox->get_text();
}
-const wchar_t* BC_TumbleTextBox::get_wtext()
+const wchr_t* BC_TumbleTextBox::get_wtext()
{
return textbox->get_wtext();
}
this->x = x;
this->y = y;
- textbox->reposition_window(x,
- y,
- text_w,
- 1);
- tumbler->reposition_window(x + textbox->get_w(),
- y);
+ textbox->reposition_window(x, y, text_w, 1);
+ tumbler->reposition_window(x + textbox->get_w(), y);
// if(flush) parent_window->flush();
}