IconMenu.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * The contents of this file are subject to the Mozilla Public
  3. * License Version 1.1 (the "License"); you may not use this file
  4. * except in compliance with the License. You may obtain a copy of
  5. * the License at http://www.mozilla.org/MPL/
  6. *
  7. * Software distributed under the License is distributed on an "AS
  8. * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9. * implied. See the License for the specific language governing
  10. * rights and limitations under the License.
  11. *
  12. * The Original Code is Vision.
  13. *
  14. * The Initial Developer of the Original Code is The Vision Team.
  15. * Portions created by The Vision Team are
  16. * Copyright (C) 1999, 2000, 2001 The Vision Team. All Rights
  17. * Reserved.
  18. *
  19. * Contributor(s): Rene Gollent
  20. * Alan Ellis <alan@cgsoftware.org>
  21. */
  22. //------------------------------------------------------------------------------
  23. // IconMenu.h
  24. //------------------------------------------------------------------------------
  25. // A menu item implementation that displays an icon as its label.
  26. //
  27. // IconMenu implementation Copyright (C) 1998 Tyler Riti <fizzboy@mail.utexas.edu>
  28. // Based on code Copyright (C) 1997 Jens Kilian
  29. // This code is free to use in any way so long as the credits above remain intact.
  30. // This code carries no warranties or guarantees of any kind. Use at your own risk.
  31. //------------------------------------------------------------------------------
  32. #ifndef ICON_MENU_H
  33. #define ICON_MENU_H
  34. //------------------------------------------------------------------------------
  35. // I N C L U D E S
  36. //------------------------------------------------------------------------------
  37. #include <interface/MenuItem.h>
  38. #include <interface/Rect.h>
  39. //------------------------------------------------------------------------------
  40. // D E C L A R A T I O N S
  41. //------------------------------------------------------------------------------
  42. class BBitmap;
  43. class TIconMenu : public BMenuItem
  44. {
  45. public:
  46. // Constructor
  47. // Description: Creates a menu item with the provided icon as its
  48. // label and menu as its content.
  49. // Requires: Both icon and menu must be valid.
  50. // Result: If icon is valid, then the icon it points to will
  51. // be used as the label for the menu. If icon is NULL
  52. // then the menu's name will be used instead. If icon
  53. // is invalid, a crash occurs. If menu is invalid or
  54. // NULL, a crash occurs.
  55. // Notes: Client code is still responsible for deleting the
  56. // data icon points to. IconMenu only copies the data,
  57. // it does not take posession of it.
  58. TIconMenu(BBitmap* icon, BMenu* menu);
  59. // Constructor
  60. // Description: Creates a menu item with the application's mini
  61. // icon as its label and menu as its content.
  62. // Requires: A valid BMenu pointer. The application should also
  63. // have a mini icon.
  64. // Result: If the application's mini icon is found then the
  65. // menu will be created with the icon as the label.
  66. // Otherwise, the name of menu will be used as the
  67. // label instead. If menu is invalid or NULL, a
  68. // crash will occur.
  69. TIconMenu(BMenu* menu);
  70. // Destructor
  71. virtual ~TIconMenu();
  72. protected:
  73. // Overridden Hook Functions
  74. virtual void GetContentSize(float* width, float* height);
  75. virtual void DrawContent();
  76. private:
  77. // Disabled Copy Constructor
  78. TIconMenu(const TIconMenu& iconMenu);
  79. // Disabled Assignment Operator
  80. TIconMenu& operator=(const TIconMenu& iconMenu);
  81. BRect bounds;
  82. BBitmap* iconLabel;
  83. };
  84. //---------------------------------------------------------------- IconMenu.h --
  85. #endif