diff options
author | Paul Gardiner <paul@glidos.net> | 2012-04-06 12:31:40 +0100 |
---|---|---|
committer | Paul Gardiner <paul@glidos.net> | 2012-05-08 14:50:50 +0100 |
commit | e605006bdf8909bc1e6f20dedecc291219526c64 (patch) | |
tree | 37095de347e29cd09d543cdf235f31dd133edcdc | |
parent | e81dadd0fe9b2335591ed7ec1f6424937857017e (diff) | |
download | mupdf-e605006bdf8909bc1e6f20dedecc291219526c64.tar.xz |
Forms: add text input dialog to win32 app
-rw-r--r-- | apps/pdfapp.c | 6 | ||||
-rw-r--r-- | apps/pdfapp.h | 1 | ||||
-rw-r--r-- | apps/win_main.c | 39 | ||||
-rw-r--r-- | apps/win_res.rc | 12 |
4 files changed, 54 insertions, 4 deletions
diff --git a/apps/pdfapp.c b/apps/pdfapp.c index 7d356ef4..9e26ba98 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -985,9 +985,9 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta if (widget && fz_widget_get_type(widget) == FZ_WIDGET_TYPE_TEXT) { char *text = fz_widget_text_get_text((fz_widget_text *)widget); - /* Should invoke dialog for text entry, but for now, - * just change any text field clicked to "Hello" */ - fz_widget_text_set_text((fz_widget_text *)widget, "Hello"); + char *newtext = wintextinput(app, text); + if (newtext) + fz_widget_text_set_text((fz_widget_text *)widget, newtext); } app->nowaitcursor = 1; diff --git a/apps/pdfapp.h b/apps/pdfapp.h index df17e832..4ce73742 100644 --- a/apps/pdfapp.h +++ b/apps/pdfapp.h @@ -23,6 +23,7 @@ extern void winresize(pdfapp_t*, int w, int h); extern void winrepaint(pdfapp_t*); extern void winrepaintsearch(pdfapp_t*); extern char *winpassword(pdfapp_t*, char *filename); +extern char *wintextinput(pdfapp_t*, char *inittext); extern void winopenuri(pdfapp_t*, char *s); extern void wincursor(pdfapp_t*, int curs); extern void windocopy(pdfapp_t*); diff --git a/apps/win_main.c b/apps/win_main.c index 8f293beb..555941a8 100644 --- a/apps/win_main.c +++ b/apps/win_main.c @@ -117,6 +117,7 @@ int winfilename(wchar_t *buf, int len) static char pd_filename[256] = "The file is encrypted."; static char pd_password[256] = ""; +static char td_textinput[1024] = ""; static int pd_okay = 0; INT CALLBACK @@ -145,6 +146,32 @@ dlogpassproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) return FALSE; } +INT CALLBACK +dlogtextinput(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch(message) + { + case WM_INITDIALOG: + SetDlgItemTextA(hwnd, 3, td_textinput); + return TRUE; + case WM_COMMAND: + switch(wParam) + { + case 1: + pd_okay = 1; + GetDlgItemTextA(hwnd, 3, td_textinput, sizeof td_textinput); + EndDialog(hwnd, 1); + return TRUE; + case 2: + pd_okay = 0; + EndDialog(hwnd, 1); + return TRUE; + } + break; + } + return FALSE; +} + char *winpassword(pdfapp_t *app, char *filename) { char buf[1024], *s; @@ -164,6 +191,18 @@ char *winpassword(pdfapp_t *app, char *filename) return NULL; } +char *wintextinput(pdfapp_t *app, char *inittext) +{ + int code; + strncpy(td_textinput, inittext?inittext:"", sizeof(td_textinput)); + code = DialogBoxW(NULL, L"IDD_DLOGTEXT", hwndframe, dlogtextinput); + if (code <= 0) + winerror(app, "cannot create text input dialog"); + if (pd_okay) + return td_textinput; + return NULL; +} + INT CALLBACK dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { diff --git a/apps/win_res.rc b/apps/win_res.rc index 0efd1411..3e8da3d3 100644 --- a/apps/win_res.rc +++ b/apps/win_res.rc @@ -49,7 +49,17 @@ BEGIN LTEXT "", 0x27, 60, 125, 100, 10, 0 END -IDD_DLOGABOUT DIALOG 50, 50, 200, 300 +IDD_DLOGTEXT DIALOG 50, 50, 204, 47 +//STYLE DS_MODALFRAME | WS_POPUP +CAPTION " MuPDF: fill out form" +FONT 8, "MS Shell Dlg" +BEGIN + EDITTEXT 3,8,7,183,12 + DEFPUSHBUTTON "Okay",1,89,26,50,14 + PUSHBUTTON "Cancel",2,147,26,50,14 +END + +IDD_DLOGABOUT DIALOG 50, 50, 200, 220 STYLE 128 | 0x80000000 CAPTION " About MuPDF " FONT 8, "MS Shell Dlg" |