Ejemplo n.º 1
0
/** Stop dialog processing. */
void ShutdownDialogs(void)
{
    if(dialog) {
        DestroyConfirmDialog();
        dialog = NULL;
    }
}
Ejemplo n.º 2
0
/** Stop dialog processing. */
void ShutdownDialogs() {

   while(dialogList) {
      DestroyConfirmDialog(dialogList);
   }

}
Ejemplo n.º 3
0
/** Handle a key press. */
char HandleDialogKeyPress(const XKeyEvent *event)
{
    if(dialog && event->window == dialog->node->window) {
        KeyType key = GetKey(event);
        switch(key & 0xFF) {
        case KEY_ENTER:
            RunDialogAction();
            DestroyConfirmDialog();
            break;
        case KEY_ESC:
            DestroyConfirmDialog();
            break;
        default:
            break;
        }
        return 1;
    } else {
        return 0;
    }
}
Ejemplo n.º 4
0
/** Handle a key press. */
char HandleDialogKeyPress(const XKeyEvent *event)
{
   if(dialog && event->window == dialog->node->window) {
      const ActionType key = GetKey(MC_NONE, event->state, event->keycode);
      switch(key.action) {
      case ACTION_ENTER:
         RunDialogAction();
         DestroyConfirmDialog();
         break;
      case ACTION_ESC:
         DestroyConfirmDialog();
         break;
      default:
         break;
      }
      return 1;
   } else {
      return 0;
   }
}
Ejemplo n.º 5
0
/** Handle a mouse button release event. */
int HandleDialogButtonRelease(const XButtonEvent *event) {

   DialogType *dp;
   int x, y;
   int cancelPressed, okPressed;

   Assert(event);

   dp = FindDialogByWindow(event->window);
   if(dp) {
      cancelPressed = 0;
      okPressed = 0;
      y = event->y;
      if(y >= dp->buttony && y < dp->buttony + dp->buttonHeight) {
         x = event->x;
         if(x >= dp->okx && x < dp->okx + dp->buttonWidth) {
            okPressed = 1;
         } else if(x >= dp->cancelx && x < dp->cancelx + dp->buttonWidth) {
            cancelPressed = 1;
         }
      }

      if(okPressed) {
         (dp->action)(dp->client);
      }

      if(cancelPressed || okPressed) {
         DestroyConfirmDialog(dp);
      } else {
         dp->buttonState = DBS_NORMAL;
         DrawButtons(dp);
      }

      return 1;
   } else {

      for(dp = dialogList; dp; dp = dp->next) {
         if(dp->buttonState != DBS_NORMAL) {
            dp->buttonState = DBS_NORMAL;
            DrawButtons(dp);
         }
      }

      return 0;

   }

}
Ejemplo n.º 6
0
/** Handle a mouse button release event. */
char HandleDialogButtonRelease(const XButtonEvent *event)
{

    Assert(event);

    if(dialog && event->window == dialog->node->window) {
        char cancelPressed = 0;
        char okPressed = 0;
        const int y = event->y;
        if(y >= dialog->buttony && y < dialog->buttony + dialog->buttonHeight) {
            const int x = event->x;
            if(x >= dialog->okx && x < dialog->okx + dialog->buttonWidth) {
                okPressed = 1;
            } else if(x >= dialog->cancelx
                      && x < dialog->cancelx + dialog->buttonWidth) {
                cancelPressed = 1;
            }
        }

        if(okPressed) {
            RunDialogAction();
        }

        if(cancelPressed || okPressed) {
            DestroyConfirmDialog();
        } else {
            dialog->buttonState = DBS_NORMAL;
            DrawButtons();
            ExposeConfirmDialog();
        }

        return 1;
    } else {

        if(dialog) {
            if(dialog->buttonState != DBS_NORMAL) {
                dialog->buttonState = DBS_NORMAL;
                DrawButtons();
                ExposeConfirmDialog();
            }
        }

        return 0;

    }

}
Ejemplo n.º 7
0
/** Show a confirm dialog. */
void ShowConfirmDialog(ClientNode *np, void (*action)(ClientNode*), ...)
{

    va_list ap;
    XSetWindowAttributes attrs;
    XSizeHints shints;
    Window window;
    char *str;
    int x;

    Assert(action);

    /* Only allow one dialog at a time. */
    if(dialog) {
        DestroyConfirmDialog();
    }

    dialog = Allocate(sizeof(DialogType));
    dialog->client = np ? np->window : None;
    dialog->action = action;
    dialog->buttonState = DBS_NORMAL;

    /* Get the number of lines. */
    va_start(ap, action);
    for(dialog->lineCount = 0; va_arg(ap, char*); dialog->lineCount++);
    va_end(ap);

    dialog->message = Allocate(dialog->lineCount * sizeof(char*));
    va_start(ap, action);
    for(x = 0; x < dialog->lineCount; x++) {
        str = va_arg(ap, char*);
        dialog->message[x] = CopyString(str);
    }
    va_end(ap);

    ComputeDimensions(np);

    /* Create the pixmap used for rendering. */
    dialog->pmap = JXCreatePixmap(display, rootWindow,
                                  dialog->width, dialog->height,
                                  rootDepth);

    /* Create the window. */
    attrs.background_pixel = colors[COLOR_MENU_BG];
    attrs.event_mask = ButtonPressMask
                       | ButtonReleaseMask
                       | KeyPressMask
                       | ExposureMask;
    window = JXCreateWindow(display, rootWindow,
                            dialog->x, dialog->y,
                            dialog->width, dialog->height, 0,
                            CopyFromParent, InputOutput, CopyFromParent,
                            CWBackPixel | CWEventMask, &attrs);
    shints.x = dialog->x;
    shints.y = dialog->y;
    shints.flags = PPosition;
    JXSetWMNormalHints(display, window, &shints);
    JXStoreName(display, window, _("Confirm"));
    SetAtomAtom(window, ATOM_NET_WM_WINDOW_TYPE,
                ATOM_NET_WM_WINDOW_TYPE_DIALOG);

    /* Draw the dialog. */
    DrawDialog();

    /* Add the client and give it focus. */
    dialog->node = AddClientWindow(window, 0, 0);
    Assert(dialog->node);
    if(np) {
        dialog->node->owner = np->window;
    }
    dialog->node->state.status |= STAT_WMDIALOG;
    FocusClient(dialog->node);

    /* Grab the mouse. */
    JXGrabButton(display, AnyButton, AnyModifier, window, True,
                 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);


}