Guest User

Untitled

a guest
Jan 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.08 KB | None | 0 0
  1. if( [bottomButtons count] != 0 )
  2. {
  3. NSMutableArray * newArray = [[[NSMutableArray alloc] init] autorelease];
  4. for( NSInteger i = [bottomButtons count] - 1; i >= 0; i-- )
  5. {
  6. [newArray addObject:[bottomButtons objectAtIndex:i]];
  7. }
  8.  
  9. float startY = 0.0 + ( CAFF_POPUP_SHADOW_PADDING + CAFF_POPUP_PADDING + CAFF_POPUP_ARROW_HEIGHT );
  10. float startX = 0.0 + ( CAFF_POPUP_SHADOW_PADDING + CAFF_POPUP_PADDING + CAFF_POPUP_ARROW_HEIGHT );
  11. float startHeight = 0;
  12.  
  13. float buttonWidth = view ? [view frame].size.width : width;
  14. NSInteger counter = 0;
  15. for( id button in newArray )
  16. {
  17. if( [button isKindOfClass:[UIPopoverViewButtonSeperator class]] )
  18. {
  19. startY += CAFF_POPUP_BOTTOM_BUTTON_SEPERATOR_MARGIN;
  20. if( [(UIPopoverViewButtonSeperator *)button indent] )
  21. {
  22. [button setFrame:NSMakeRect( CAFF_POPUP_SHADOW_PADDING + CAFF_POPUP_ARROW_HEIGHT, startY, buttonWidth + ( CAFF_POPUP_PADDING * 2 ), CAFF_POPUP_BOTTOM_BUTTON_SEPERATOR_HEIGHT)];
  23. [bgView addSubview:button];
  24. }
  25. startY += CAFF_POPUP_BOTTOM_BUTTON_SEPERATOR_HEIGHT + ( CAFF_POPUP_BOTTOM_BUTTON_SEPERATOR_MARGIN * 2 );
  26. startHeight += ( CAFF_POPUP_BOTTOM_BUTTON_SEPERATOR_HEIGHT + CAFF_POPUP_BOTTOM_BUTTON_SEPERATOR_MARGIN * 2 ) + CAFF_POPUP_PADDING;
  27. if( lastButtonRow != -1 )
  28. {
  29. startY += [previousButton frame].size.height + CAFF_POPUP_PADDING;
  30. startHeight += [previousButton frame].size.height + CAFF_POPUP_PADDING;
  31. previousButton = nil;
  32. lastButtonRow = -1;
  33. }
  34. counter++;
  35. continue;
  36. }
  37. float buttonHeight;
  38. switch( [(UIPopoverViewButton *)button UISize] )
  39. {
  40. case UIPopoverSizeLarge :
  41. buttonHeight = CAFF_POPUP_BOTTOM_BUTTON_LARGE_HEIGHT;
  42. break;
  43. case UIPopoverSizeNormal :
  44. buttonHeight = CAFF_POPUP_BOTTOM_BUTTON_NORMAL_HEIGHT;
  45. break;
  46. case UIPopoverSizeSmall :
  47. buttonHeight = CAFF_POPUP_BOTTOM_BUTTON_SMALL_HEIGHT;
  48. break;
  49. }
  50. if( [button row] != -1 )
  51. {
  52. lastButtonRow = [button row];
  53. previousButton = button;
  54. NSInteger index = 0;
  55. NSInteger countRow = [self buttonRowCountForButton:button
  56. index:&index];
  57. float cellWidth = ceil( buttonWidth / [self buttonRowCountForButton:button
  58. index:&index] ) - ( CAFF_POPUP_PADDING / ( countRow - 1 ) ) - ( CAFF_POPUP_PADDING / ( countRow - 1 ) );
  59. [button setFrame:NSMakeRect( ceil( startX + ( cellWidth * index ) + ( CAFF_POPUP_PADDING * index ) ), startY, ceil( cellWidth ), buttonHeight )];
  60. [bgView addSubview:button];
  61. if( counter == ( [bottomButtons count] - 1 ) )
  62. {
  63. startY += [previousButton frame].size.height + CAFF_POPUP_PADDING;
  64. startHeight += [previousButton frame].size.height + CAFF_POPUP_PADDING;
  65. }
  66. } else {
  67. if( [button row] != lastButtonRow )
  68. {
  69. lastButtonRow = [button row];
  70. startY += [previousButton frame].size.height + CAFF_POPUP_PADDING;
  71. startHeight += [previousButton frame].size.height + CAFF_POPUP_PADDING;
  72. }
  73. [button setFrame:NSMakeRect( startX, startY, buttonWidth, buttonHeight )];
  74. [bgView addSubview:button];
  75. startY += [button frame].size.height + CAFF_POPUP_PADDING;
  76. startHeight += [button frame].size.height + CAFF_POPUP_PADDING;
  77. }
  78. counter++;
  79. }
Add Comment
Please, Sign In to add comment