Beispiel #1
0
/*========================================================================*/
static int ControlClick(Block * block, int button, int x, int y, int mod)
{
  PyMOLGlobals *G = block->G;
  register CControl *I = G->Control;
  I->SkipRelease = false;
  if(x < (I->Block->rect.left + cControlLeftMargin)) {
    y -= I->Block->rect.top - cControlTopMargin;
    if((y <= 0) && (y > (-cControlBoxSize))) {
      double now = UtilGetSeconds(block->G);
      if((now - I->LastClickTime) < 0.35) {
        if(I->SaveWidth) {
          SettingSet(G, cSetting_internal_gui_width, (float) I->SaveWidth);
          OrthoReshape(G, -1, -1, false);
          I->SaveWidth = 0;
        } else {
          I->SaveWidth = (int) SettingGet(G, cSetting_internal_gui_width);
          SettingSet(G, cSetting_internal_gui_width, (float) cControlMinWidth);
          OrthoReshape(G, -1, -1, false);
        }
        I->SkipRelease = true;
      } else {
        I->LastPos = x;
        OrthoGrab(G, block);
        I->DragFlag = true;
        I->LastClickTime = UtilGetSeconds(G);
      }
    }
  } else {
    I->Pressed = which_button(I, x, y);
    I->Active = I->Pressed;
    if(I->Pressed)
      OrthoGrab(G, block);
    OrthoDirty(G);
  }
  return (1);
}
Beispiel #2
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
}