NameItem.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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): Wade Majors <wade@ezri.org>
  20. * Rene Gollent
  21. * Todd Lair
  22. * Andrew Bazan
  23. * Jamie Wilkinson
  24. */
  25. #include <stdio.h>
  26. #include "Vision.h"
  27. #include "Names.h"
  28. #include "Theme.h"
  29. NameItem::NameItem (
  30. const char *name,
  31. int32 userStatus)
  32. : BListItem (),
  33. myName (name),
  34. myAddress (""),
  35. myStatus (userStatus)
  36. {
  37. }
  38. BString
  39. NameItem::Name (void) const
  40. {
  41. return myName;
  42. }
  43. BString
  44. NameItem::Address (void) const
  45. {
  46. return myAddress;
  47. }
  48. int32
  49. NameItem::Status() const
  50. {
  51. return myStatus;
  52. }
  53. void
  54. NameItem::SetName (const char *name)
  55. {
  56. myName = name;
  57. }
  58. void
  59. NameItem::SetAddress (const char *address)
  60. {
  61. myAddress = address;
  62. }
  63. void
  64. NameItem::SetStatus (int32 userStatus)
  65. {
  66. myStatus = userStatus;
  67. }
  68. void
  69. NameItem::DrawItem (BView *father, BRect frame, bool complete)
  70. {
  71. Theme *activeTheme (vision_app->ActiveTheme());
  72. activeTheme->ReadLock();
  73. if (IsSelected())
  74. {
  75. father->SetLowColor (activeTheme->ForegroundAt (C_NAMES_SELECTION));
  76. father->FillRect (frame, B_SOLID_LOW);
  77. }
  78. else if (complete)
  79. {
  80. father->SetLowColor (activeTheme->ForegroundAt (C_NAMES_BACKGROUND));
  81. father->FillRect (frame, B_SOLID_LOW);
  82. }
  83. font_height fh;
  84. father->GetFontHeight (&fh);
  85. father->MovePenTo (
  86. frame.left + 4,
  87. frame.bottom - fh.descent);
  88. BString drawString (myName);
  89. rgb_color color = activeTheme->ForegroundAt (C_NAMES);
  90. if ((myStatus & STATUS_FOUNDER_BIT) != 0)
  91. {
  92. drawString.Prepend ("*");
  93. color = activeTheme->ForegroundAt (C_OP);
  94. }
  95. else if ((myStatus & STATUS_PROTECTED_BIT) != 0)
  96. {
  97. drawString.Prepend ("!");
  98. color = activeTheme->ForegroundAt (C_OP);
  99. }
  100. else if ((myStatus & STATUS_OP_BIT) != 0)
  101. {
  102. drawString.Prepend ("@");
  103. color = activeTheme->ForegroundAt (C_OP);
  104. }
  105. else if ((myStatus & STATUS_HELPER_BIT) != 0)
  106. {
  107. drawString.Prepend ("%");
  108. color = activeTheme->ForegroundAt (C_HELPER);
  109. }
  110. else if ((myStatus & STATUS_VOICE_BIT) != 0)
  111. {
  112. drawString.Prepend("+");
  113. color = activeTheme->ForegroundAt (C_VOICE);
  114. }
  115. if ((myStatus & STATUS_IGNORE_BIT) != 0)
  116. color = activeTheme->ForegroundAt (C_IGNORE);
  117. activeTheme->ReadUnlock();
  118. father->SetHighColor (color);
  119. father->SetDrawingMode (B_OP_OVER);
  120. father->DrawString (drawString.String());
  121. father->SetDrawingMode (B_OP_COPY);
  122. }