ChgPane.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 <config.h>
  13. #include "XMenuInt.h"
  14. int
  15. XMenuChangePane(register XMenu *menu, register int p_num, char *label)
  16. /* Menu object to be modified. */
  17. /* Pane number to be modified. */
  18. /* Selection label. */
  19. {
  20. register XMPane *p_ptr; /* XMPane pointer. */
  21. int label_length; /* Label length in characters. */
  22. int label_width; /* Label width in pixels. */
  23. /*
  24. * Check for NULL pointers!
  25. */
  26. if (label == NULL) {
  27. _XMErrorCode = XME_ARG_BOUNDS;
  28. return(XM_FAILURE);
  29. }
  30. /*
  31. * Find the right pane.
  32. */
  33. p_ptr = _XMGetPanePtr(menu, p_num);
  34. if (p_ptr == NULL) return(XM_FAILURE);
  35. /*
  36. * Determine label size.
  37. */
  38. label_length = strlen(label);
  39. label_width = XTextWidth(menu->p_fnt_info, label, label_length);
  40. /*
  41. * Change the pane data.
  42. */
  43. p_ptr->label = label;
  44. p_ptr->label_width = label_width;
  45. p_ptr->label_length = label_length;
  46. /*
  47. * Schedule a recompute.
  48. */
  49. menu->recompute = 1;
  50. /*
  51. * Return the pane number just changed.
  52. */
  53. _XMErrorCode = XME_NO_ERROR;
  54. return(p_num);
  55. }