23#include <FL/Fl_Window.H>
24#include <FL/Fl_File_Chooser.H>
25#include <FL/Fl_Return_Button.H>
26#include <FL/Fl_Text_Display.H>
27#include <FL/Fl_Button.H>
28#include <FL/Fl_Return_Button.H>
29#include <FL/Fl_Output.H>
30#include <FL/Fl_Input.H>
31#include <FL/Fl_Secret_Input.H>
32#include <FL/Fl_Choice.H>
33#include <FL/Fl_Menu_Item.H>
58class CustInput3 :
public Fl_Input {
60 CustInput3 (
int x,
int y,
int w,
int h,
const char* l=0) :
61 Fl_Input(x,y,w,h,l) {};
64 void d_position(
int p);
69int CustInput3::d_position()
71#if FL_API_VERSION < 10400
72 return CustInput3::position();
74 return CustInput3::insert_position();
78void CustInput3::d_position(
int p)
80#if FL_API_VERSION < 10400
81 CustInput3::position(p);
83 CustInput3::insert_position(p);
87int CustInput3::handle(
int e)
89 int k = Fl::event_key();
91 _MSG(
"CustInput3::handle event=%d\n", e);
94 unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
96 if (e == FL_KEYBOARD && modifier == FL_CTRL) {
97 if (k ==
'a' || k ==
'e') {
98 d_position(k ==
'a' ? 0 : size());
100 }
else if (k ==
'k') {
101 cut(d_position(), size());
103 }
else if (k ==
'd') {
104 cut(d_position(), d_position()+1);
108 return Fl_Input::handle(e);
114class CustChoice2 :
public Fl_Choice {
116 CustChoice2 (
int x,
int y,
int w,
int h,
const char* l=0) :
117 Fl_Choice(x,y,w,h,l) {};
119 if (e == FL_KEYBOARD &&
120 (Fl::event_key() == FL_Enter || Fl::event_key() == FL_Down) &&
121 (Fl::event_state() & (FL_SHIFT|FL_CTRL|FL_ALT|FL_META)) == 0) {
122 return Fl_Choice::handle(FL_PUSH);
124 return Fl_Choice::handle(e);
128class EnterButton :
public Fl_Button {
130 EnterButton (
int x,
int y,
int w,
int h,
const char* label = 0) :
131 Fl_Button (x,y,w,h,label) {};
135int EnterButton::handle(
int e)
137 if (e == FL_KEYBOARD && Fl::focus() ==
this && Fl::event_key() == FL_Enter){
139 simulate_key_action();
143 return Fl_Button::handle(e);
154 if (!(title && *title))
155 title =
"Dillo: Message";
156 fl_message_title(title);
157 fl_message(
"%s", msg);
164static void input_cb(Fl_Widget *button,
void *number)
167 button->window()->hide();
178 static Fl_Menu_Item *pm = 0;
179 int ww = 450, wh = 130, gap = 10, ih = 60, bw = 80, bh = 30;
183 if (!(title && *title))
184 title =
"Dillo: Input";
186 Fl_Window *
window =
new Fl_Window(ww,wh,title);
189 Fl_Group* ib =
new Fl_Group(0,0,
window->w(),
window->h());
194 Fl_Box* o =
new Fl_Box(gap, gap, ih, ih);
195 o->box(FL_THIN_UP_BOX);
196 o->labelfont(FL_TIMES_BOLD);
201 Fl_Box *box =
new Fl_Box(ih+2*gap,gap,ww-(ih+3*gap),ih/2, msg);
202 box->labelfont(FL_HELVETICA);
204 box->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP|FL_ALIGN_WRAP);
206 CustInput3 *c_inp =
new CustInput3(ih+2*gap,gap+ih/2+gap,ww-(ih+3*gap),24);
207 c_inp->labelsize(14);
210 CustChoice2 *ch =
new CustChoice2(1*gap,ih+3*gap,180,24);
213 pm = (Fl_Menu_Item *) calloc(n_it+1,
sizeof(Fl_Menu_Item));
215 MSG(
"calloc failed: %s\n", strerror(errno));
218 for (
int i = 0, j = 0; i < n_it; i++) {
219 char *label, *url, *source;
223 pm[j++].label(FL_NORMAL_LABEL,
dStrdup(label));
226 ch->tooltip(
"Select search engine");
230 int xpos = ww-2*(gap+bw), ypos = ih+3*gap;
231 Fl_Return_Button *rb =
new Fl_Return_Button(xpos, ypos, bw, bh,
"OK");
232 rb->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
237 Fl_Button *b =
new Fl_Button(xpos, ypos, bw, bh,
"Cancel");
238 b->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
263 if (!(title && *title))
264 title =
"Dillo: Password";
265 fl_message_title(title);
266 return fl_password(
"%s",
"", msg);
275 const char *pattern,
const char *fname)
277 return fl_file_chooser(title, pattern, fname);
286 const char *pattern,
const char *fname)
301 const char *pattern,
const char *fname)
305 fc_name = fl_file_chooser(title, pattern, fname);
314 Fl_Text_Display *td = (Fl_Text_Display *)vtd;
315 Fl_Text_Buffer *buf = td->buffer();
317 delete (Fl_Window*)td->window();
328 if (!(title && *title))
329 title =
"Dillo: Text";
331 Fl_Window *
window =
new Fl_Window(ww, wh, title);
332 Fl_Group::current(0);
335 Fl_Text_Buffer *buf =
new Fl_Text_Buffer();
337 Fl_Text_Display *td =
new Fl_Text_Display(0,0,ww, wh-bh);
342 td->wrap_mode(Fl_Text_Display::WRAP_AT_BOUNDS, 0);
345 Fl_Return_Button *b =
new Fl_Return_Button (0, wh-bh, ww, bh,
"Close");
361 button->window()->hide();
375 if (title == NULL || *title ==
'\0')
376 title =
"Dillo: Choice";
379 for (n = 0; va_arg(ap,
char *) != NULL; n++);
383 MSG_ERR(
"Dialog_choice: no alternatives.\n");
388 int ww = 140 + n * 60, wh = 120;
389 int bw = (ww - gap) / n - gap, bh = 45;
391 Fl_Window *
window =
new Fl_Window(ww, wh, title);
395 Fl_Text_Buffer *buf =
new Fl_Text_Buffer();
397 Fl_Text_Display *td =
new Fl_Text_Display(0, 0, ww, wh - bh);
400 td->wrap_mode(Fl_Text_Display::WRAP_AT_BOUNDS, 0);
406 for (i = 1; i <= n; i++) {
407 Fl_Button *b =
new EnterButton(xpos, wh-bh, bw, bh, va_arg(ap,
char *));
408 b->align(FL_ALIGN_WRAP | FL_ALIGN_CLIP);
422 _MSG(
"Dialog_choice answer = %d\n", answer);
433 button->window()->user_data(button);
434 button->window()->hide();
445 int ok = 0, window_h = 280, y, msg_w, msg_h;
446 const int window_w = 300, input_x = 80, input_w = 200, input_h = 30,
450 if (!(title && *title))
451 title =
"Dillo: User/Password";
452 Fl_Window *
window =
new Fl_Window(window_w,window_h,title);
453 Fl_Group::current(0);
458 msg_w = window_w - 40;
459 Fl_Box *msg_box =
new Fl_Box(20, y, msg_w, 100);
461 msg_box->labelfont(FL_HELVETICA);
462 msg_box->labelsize(14);
463 msg_box->align(FL_ALIGN_INSIDE | FL_ALIGN_TOP_LEFT | FL_ALIGN_WRAP);
465 fl_font(msg_box->labelfont(), msg_box->labelsize());
467 fl_measure(msg_box->label(), msg_w, msg_h, 0);
468 msg_box->size(msg_box->w(), msg_h);
473 Fl_Input *user_input =
new Fl_Input(input_x, y, input_w, input_h,
"User");
474 user_input->labelsize(14);
475 user_input->textsize(14);
478 Fl_Secret_Input *password_input =
479 new Fl_Secret_Input(input_x, y, input_w, input_h,
"Password");
480 password_input->labelsize(14);
481 password_input->textsize(14);
482 window->add(password_input);
486 Fl_Button *ok_button =
new EnterButton(200, y, 50, button_h,
"OK");
487 ok_button->labelsize(14);
492 Fl_Button *cancel_button =
493 new EnterButton(50, y, 100, button_h,
"Cancel");
494 cancel_button->labelsize(14);
496 window->add(cancel_button);
500 window->size(window_w, window_h);
501 window->size_range(window_w, window_h, window_w, window_h);
508 ok = ((Fl_Widget *)
window->user_data()) == ok_button ? 1 : 0;
512 const char *user, *password;
513 user = user_input->value();
514 password = password_input->value();
515 _MSG(
"a_Dialog_user_passwd: ok = %d\n", ok);
516 (*cb)(user, password, vp);
char * a_Dialog_open_file(const char *title, const char *pattern, const char *fname)
Show the open file dialog.
int a_Dialog_choice(const char *title, const char *msg,...)
Make a question-dialog with a question and alternatives.
void a_Dialog_msg(const char *title, const char *msg)
Display a message in a popup window.
static void Dialog_user_password_cb(Fl_Widget *button, void *)
const char * a_Dialog_save_file(const char *title, const char *pattern, const char *fname)
Show the save file dialog.
const char * a_Dialog_passwd(const char *title, const char *msg)
Dialog for password.
static void choice_cb(Fl_Widget *button, void *number)
void a_Dialog_text_window(const char *title, const char *txt)
Show a new window with the provided text.
static void text_window_close_cb(Fl_Widget *, void *vtd)
Close text window.
static void input_cb(Fl_Widget *button, void *number)
Callback for a_Dialog_input()
const char * a_Dialog_select_file(const char *title, const char *pattern, const char *fname)
Show the select file dialog.
int a_Dialog_user_password(const char *title, const char *msg, UserPasswordCB cb, void *vp)
Make a user/password dialog.
const char * a_Dialog_input(const char *title, const char *msg)
Dialog for one line of Input with a message.
void(* UserPasswordCB)(const char *user, const char *password, void *vp)
char * dStrdup(const char *s)
int dList_length(Dlist *lp)
For completing the ADT.
void * dList_nth_data(Dlist *lp, int n0)
Return the nth data item, NULL when not found or 'n0' is out of range.
static Fl_Window * window
int a_Misc_parse_search_url(char *source, char **label, char **urlstr)
Parse dillorc's search_url string ([<label> ]<url>) Return value: -1 on error, 0 on success (and labe...
char * a_Misc_escape_chars(const char *str, const char *esc_set)
Escape characters as XX sequences.
DilloPrefs prefs
Global Data.