/Mac/Modules/ctl/ctledit.py

http://unladen-swallow.googlecode.com/ · Python · 45 lines · 33 code · 7 blank · 5 comment · 3 complexity · 597db21ecf841757620a726ce3c3fbd3 MD5 · raw file

  1. # FindControlUnderMouse() returns an existing control, not a new one,
  2. # so create this one by hand.
  3. f = Function(ExistingControlHandle, 'FindControlUnderMouse',
  4. (Point, 'inWhere', InMode),
  5. (WindowRef, 'inWindow', InMode),
  6. (SInt16, 'outPart', OutMode),
  7. )
  8. functions.append(f)
  9. f = Function(ControlHandle, 'as_Control',
  10. (Handle, 'h', InMode))
  11. functions.append(f)
  12. f = Method(Handle, 'as_Resource', (ControlHandle, 'ctl', InMode))
  13. methods.append(f)
  14. f = Method(void, 'GetControlRect', (ControlHandle, 'ctl', InMode), (Rect, 'rect', OutMode))
  15. methods.append(f)
  16. DisposeControl_body = """
  17. if (!PyArg_ParseTuple(_args, ""))
  18. return NULL;
  19. if ( _self->ob_itself ) {
  20. SetControlReference(_self->ob_itself, (long)0); /* Make it forget about us */
  21. DisposeControl(_self->ob_itself);
  22. _self->ob_itself = NULL;
  23. }
  24. Py_INCREF(Py_None);
  25. _res = Py_None;
  26. return _res;
  27. """
  28. f = ManualGenerator("DisposeControl", DisposeControl_body)
  29. f.docstring = lambda : "() -> None"
  30. methods.append(f)
  31. # All CreateXxxXxxControl() functions return a new object in an output
  32. # parameter; these should however be managed by us (we're creating them
  33. # after all), so set the type to ControlRef.
  34. for f in functions:
  35. if f.name.startswith("Create"):
  36. v = f.argumentList[-1]
  37. if v.type == ExistingControlHandle:
  38. v.type = ControlRef