ChgPane.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Copyright Massachusetts Institute of Technology 1985 */
  2. #include "copyright.h"
  3. /*
  4. * XMenu: MIT Project Athena, X Window system menu package
  5. *
  6. * XMenuChangePane - Change the label of a menu pane.
  7. *
  8. * Author: Tony Della Fera, DEC
  9. * December 19, 1985
  10. *
  11. */
  12. #include "XMenuInt.h"
  13. int
  14. XMenuChangePane(register XMenu *menu, register int p_num, char *label)
  15. /* Menu object to be modified. */
  16. /* Pane number to be modified. */
  17. /* Selection label. */
  18. {
  19. register XMPane *p_ptr; /* XMPane pointer. */
  20. int label_length; /* Label length in characters. */
  21. int label_width; /* Label width in pixels. */
  22. /*
  23. * Check for NULL pointers!
  24. */
  25. if (label == NULL) {
  26. _XMErrorCode = XME_ARG_BOUNDS;
  27. return(XM_FAILURE);
  28. }
  29. /*
  30. * Find the right pane.
  31. */
  32. p_ptr = _XMGetPanePtr(menu, p_num);
  33. if (p_ptr == NULL) return(XM_FAILURE);
  34. /*
  35. * Determine label size.
  36. */
  37. label_length = strlen(label);
  38. label_width = XTextWidth(menu->p_fnt_info, label, label_length);
  39. /*
  40. * Change the pane data.
  41. */
  42. p_ptr->label = label;
  43. p_ptr->label_width = label_width;
  44. p_ptr->label_length = label_length;
  45. /*
  46. * Schedule a recompute.
  47. */
  48. menu->recompute = 1;
  49. /*
  50. * Return the pane number just changed.
  51. */
  52. _XMErrorCode = XME_NO_ERROR;
  53. return(p_num);
  54. }