UIFontButton.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. =======================================================================================
  3. Copyright (C) 2009-2011 id Software LLC, a ZeniMax Media company. All Right Reserved.
  4. This file is part of the DOOM Classic iOS v2.1 GPL Source Code.
  5. =======================================================================================
  6. */
  7. #import "UIFontButton.h"
  8. @implementation UIFontButton
  9. @synthesize label;
  10. @synthesize label2;
  11. - (void)awakeFromNib {
  12. CGFloat points = self.titleLabel.font.pointSize;
  13. self.titleLabel.font = [UIFont fontWithName:@"idGinza Narrow" size:points];
  14. if( self.label2 )
  15. label2Color = self.label2.textColor;
  16. if( self.label )
  17. labelColor = self.label.textColor;
  18. }
  19. - (void)setHighlighted:(BOOL)highlight {
  20. if( highlight ) {
  21. if( self.label )
  22. self.label.textColor = self.label.highlightedTextColor;
  23. if( self.label2 )
  24. self.label2.textColor = self.label2.highlightedTextColor;
  25. } else if( self.enabled ) {
  26. if( self.label )
  27. self.label.textColor = labelColor;
  28. if( self.label2 )
  29. self.label2.textColor = label2Color;
  30. }
  31. [super setHighlighted:highlight];
  32. }
  33. - (void)setEnabled:(BOOL)enabled {
  34. if( !enabled ) {
  35. if( self.label )
  36. self.label.textColor = self.label.highlightedTextColor;
  37. if( self.label2 )
  38. self.label2.textColor = self.label2.highlightedTextColor;
  39. } else {
  40. if( self.label )
  41. self.label.textColor = labelColor;
  42. if( self.label2 )
  43. self.label2.textColor = label2Color;
  44. }
  45. [super setEnabled:enabled];
  46. }
  47. - (void) Enable {
  48. self.enabled = YES;
  49. if( self.label )
  50. label.enabled = YES;
  51. if( self.label2 )
  52. label2.enabled = YES;
  53. }
  54. - (void) Disable {
  55. self.enabled = NO;
  56. if( self.label )
  57. label.enabled = NO;
  58. if( self.label2 )
  59. label2.enabled = NO;
  60. }
  61. - (void) Hide {
  62. [UIView beginAnimations:@"Hide" context:nil];
  63. [UIView setAnimationDuration:1.0f];
  64. [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
  65. [UIView setAnimationBeginsFromCurrentState:YES];
  66. [UIView setAnimationDelegate:self];
  67. [UIView setAnimationDidStopSelector:@selector(Disable)];
  68. self.alpha = 0.0f;
  69. if( self.label )
  70. label.alpha = 0.0f;
  71. if( self.label2 )
  72. label2.alpha = 0.0f;
  73. [UIView commitAnimations];
  74. }
  75. - (void) Show {
  76. [UIView beginAnimations:@"Show" context:nil];
  77. [UIView setAnimationDuration:1.0f];
  78. [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
  79. [UIView setAnimationBeginsFromCurrentState:YES];
  80. [UIView setAnimationDelegate:self];
  81. [UIView setAnimationDidStopSelector:@selector(Enable)];
  82. self.alpha = 1.0f;
  83. if( self.label )
  84. label.alpha = 1.0f;
  85. if( self.label2 )
  86. label2.alpha = 1.0f;
  87. [UIView commitAnimations];
  88. }
  89. @end