1 /* 2 * Copyright 2023 Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * John Scipione, jscipione@gmail.com 7 */ 8 #ifndef STATUS_MENU_FIELD_H 9 #define STATUS_MENU_FIELD_H 10 11 12 #include <MenuField.h> 13 #include <MenuItem.h> 14 #include <String.h> 15 16 17 class BBitmap; 18 19 20 class StatusMenuItem : public BMenuItem { 21 public: 22 StatusMenuItem(const char* name, BMessage* message = NULL); 23 StatusMenuItem(BMessage* archive); 24 25 static BArchivable* Instantiate(BMessage* archive); 26 virtual status_t Archive(BMessage* archive, 27 bool deep = true) const; 28 29 virtual void DrawContent(); 30 virtual void GetContentSize(float* _width, float* _height); 31 32 BBitmap* Icon(); 33 virtual void SetIcon(BBitmap* icon); 34 35 BRect IconRect(); 36 BSize IconSize(); 37 float Spacing(); 38 39 private: 40 BBitmap* fIcon; 41 }; 42 43 44 class StatusMenuField : public BMenuField { 45 public: 46 StatusMenuField(const char*, BMenu*); 47 ~StatusMenuField(); 48 49 virtual void SetDuplicate(bool on); 50 virtual void SetUnmatched(bool on); 51 52 BString Status() { return fStatus; }; 53 virtual void ClearStatus(); 54 virtual void SetStatus(BString status); 55 56 protected: 57 virtual void ShowStopIcon(bool show); 58 virtual void ShowWarnIcon(bool show); 59 60 private: 61 void _FillIcons(); 62 BRect _IconRect(); 63 64 private: 65 BString fStatus; 66 67 BBitmap* fStopIcon; 68 BBitmap* fWarnIcon; 69 }; 70 71 72 #endif // STATUS_MENU_FIELD_H 73