Beispiel #1
0
/*========================================================================*/
static int WizardClick(Block * block, int button, int x, int y, int mod)
{
#ifdef _PYMOL_NOPY
  return 0;
#else
  PyMOLGlobals *G = block->G;
  register CWizard *I = G->Wizard;
  int a;
  PyObject *menuList = NULL;
  int LineHeight = SettingGetGlobal_i(G, cSetting_internal_gui_control_size);

  a = ((I->Block->rect.top - (y + cWizardClickOffset)) - cWizardTopMargin) / LineHeight;
  if((a >= 0) && ((ov_size) a < I->NLine)) {
    switch (I->Line[a].type) {
    case cWizTypeButton:
      OrthoGrab(G, I->Block);
      I->Pressed = (int) a;
      OrthoDirty(G);
      break;
    case cWizTypePopUp:
      PBlock(G);
      if(I->Stack >= 0)
        if(I->Wiz[I->Stack]) {
          if(PyObject_HasAttrString(I->Wiz[I->Stack], "get_menu")) {
            menuList =
              PyObject_CallMethod(I->Wiz[I->Stack], "get_menu", "s", I->Line[a].code);
            if(PyErr_Occurred())
              PyErr_Print();
          }
        }

      if(PyErr_Occurred())
        PyErr_Print();
      if(menuList && (menuList != Py_None)) {
        int my = I->Block->rect.top - (cWizardTopMargin + a * LineHeight) - 2;

        PopUpNew(G, x, my, x, y, false, menuList, NULL);
      }
      Py_XDECREF(menuList);
      PUnblock(G);
      break;
    }
  }
  return (1);
#endif
}
Beispiel #2
0
void MenuActivate1Arg(PyMOLGlobals * G, int x, int y, int last_x, int last_y, int passive,
                      char *name, char *arg1)
{
#ifndef _PYMOL_NOPY
    PyObject *list;

    PBlock(G);

    list = PyObject_CallMethod(P_menu, name, "Os", G->P_inst->cmd, arg1);
    if(PyErr_Occurred())
        PyErr_Print();
    if(list) {
        PopUpNew(G, x, y, last_x, last_y, passive, list, NULL);
        Py_DECREF(list);
    }
    PUnblock(G);
#endif
}