예제 #1
0
void
KeyboardControl::move_buttons()
{
  move_buttons_to_row(_T("1234567890"), 0);
  move_buttons_to_row(_T("QWERTYUIOP"), 1);
  move_buttons_to_row(_T("ASDFGHJKL"), 2, button_width / 3);
  move_buttons_to_row(_T("ZXCVBNM,."), 3, button_width * 2 / 3);

  if (is_landscape()) {
    move_button(_T('-'), button_width * 9, Layout::Scale(160));

    move_button(_T(' '), Layout::Scale(80), Layout::Scale(160));
    resize_button(_T(' '), Layout::Scale(93), Layout::Scale(40));
  } else {
    move_button(_T('-'), button_width * 8, button_height * 4);

    move_button(_T(' '), button_width * 2, button_height * 4);
    resize_button(_T(' '), button_width * 11 / 2, button_height);
  }
}
예제 #2
0
/* Dialog processing loop.  */
static BOOL CALLBACK
dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
    static pinentry_t pe;
    static int item;


    /*   { */
    /*     int idx; */

    /*     for (idx=0; msgcodes[idx].string; idx++) */
    /*       if (msg == msgcodes[idx].msg) */
    /*         break; */
    /*     if (msgcodes[idx].string) */
    /*       fprintf (debugfp, "received %s\n", msgcodes[idx].string); */
    /*     else */
    /*       fprintf (debugfp, "received WM_%u\n", msg); */
    /*   } */

    switch (msg)
    {
    case WM_INITDIALOG:
        dialog_handle = dlg;
        pe = (pinentry_t)lparam;
        if (!pe)
            abort ();
        set_dlg_item_text (dlg, IDC_PINENT_PROMPT, pe->prompt);
        set_dlg_item_text (dlg, IDC_PINENT_DESC, pe->description);
        set_dlg_item_text (dlg, IDC_PINENT_TEXT, "");
        if (pe->ok)
        {
            set_dlg_item_text (dlg, IDOK, pe->ok);
            resize_button (GetDlgItem (dlg, IDOK), pe->ok);
        }
        if (pe->cancel)
        {
            set_dlg_item_text (dlg, IDCANCEL, pe->cancel);
            resize_button (GetDlgItem (dlg, IDCANCEL), pe->cancel);
        }
        if (pe->error)
            set_dlg_item_text (dlg, IDC_PINENT_ERR, pe->error);

        if (confirm_mode)
        {
            EnableWindow (GetDlgItem (dlg, IDC_PINENT_TEXT), FALSE);
            SetWindowPos (GetDlgItem (dlg, IDC_PINENT_TEXT), NULL, 0, 0, 0, 0,
                          (SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_HIDEWINDOW));

            item = IDOK;
        }
        else
            item = IDC_PINENT_TEXT;

        center_window (dlg, HWND_TOP);

        /* Unfortunately we can't use SetForegroundWindow because there
           is no easy eay to have all the calling processes do an
           AllowSetForegroundWindow.  What we do instead is to bad hack
           by simulating a click to the Window. */
        /*       if (SetForegroundWindow (dlg) && lock_set_foreground_window) */
        /*         { */
        /*           lock_set_foreground_window (LSFW_LOCK); */
        /*         } */

        /*       show_window_hierarchy (GetDesktopWindow (), 0); */

        ShowWindow (dlg, SW_SHOW);
        move_mouse_and_click ( GetDlgItem (dlg, IDC_PINENT_PROMPT) );
        raise_sip (dlg);
        break;

    case WM_COMMAND:
        switch (LOWORD (wparam))
        {
        case IDOK:
            if (confirm_mode)
                confirm_yes = 1;
            else
                ok_button_clicked (dlg, pe);
            EndDialog (dlg, TRUE);
            break;

        case IDCANCEL:
            pe->result = -1;
            EndDialog (dlg, FALSE);
            break;
        }
        break;

    case WM_KEYDOWN:
        if (wparam == VK_RETURN)
        {
            if (confirm_mode)
                confirm_yes = 1;
            else
                ok_button_clicked (dlg, pe);
            EndDialog (dlg, TRUE);
        }
        break;

    }
    return FALSE;
}