1 /* 2 * Copyright 2008 Ralf Schülke, ralf.schuelke@googlemail.com. 3 * Copyright 2010 Adam Smith <adamd.smith@utoronto.ca> 4 * Copyright 2014 Haiku, Inc. All rights reserved. 5 * 6 * Distributed under the terms of the MIT License. 7 * 8 * Authors: 9 * Ralf Schülke, ralf.schuelke@googlemail.com 10 * John Scipione, jscipione@gmail.com 11 * Adam Smith, adamd.smith@utoronto.ca 12 */ 13 #ifndef PAIRS_VIEW_H 14 #define PAIRS_VIEW_H 15 16 17 #include <ObjectList.h> 18 #include <View.h> 19 20 21 const uint8 kSmallIconSize = 32; 22 const uint8 kMediumIconSize = 64; 23 const uint8 kLargeIconSize = 128; 24 25 const uint32 kMsgCardButton = 'card'; 26 27 28 class BBitmap; 29 class PairsButton; 30 31 32 class PairsView : public BView { 33 public: 34 PairsView(BRect frame, const char* name, 35 uint8 rows, uint8 cols, uint8 iconSize); 36 37 virtual ~PairsView(); 38 virtual void AttachedToWindow(); 39 virtual void Draw(BRect updateRect); 40 virtual void FrameResized(float newWidth, float newHeight); 41 42 virtual void CreateGameBoard(); 43 44 int32 Rows() const { return fRows; }; 45 int32 Cols() const { return fCols; }; 46 BObjectList<PairsButton>* PairsButtonList() const 47 { return fPairsButtonList; }; 48 49 int32 GetIconPosition(int32 index); 50 51 int32 IconSize() const { return fIconSize; }; 52 void SetIconSize(int32 size) { fIconSize = size; }; 53 54 int32 Spacing() const { return fIconSize / 6; }; 55 56 private: 57 void _GenerateCardPositions(); 58 void _ReadRandomIcons(); 59 void _SetPairsBoard(); 60 void _SetPositions(); 61 62 uint8 fRows; 63 uint8 fCols; 64 uint8 fIconSize; 65 int32 fButtonsCount; 66 int32 fCardsCount; 67 BObjectList<PairsButton>* fPairsButtonList; 68 BObjectList<BBitmap>* fSmallBitmapsList; 69 BObjectList<BBitmap>* fMediumBitmapsList; 70 BObjectList<BBitmap>* fLargeBitmapsList; 71 int32* fRandomPosition; 72 int32* fPositionX; 73 int32* fPositionY; 74 }; 75 76 77 #endif // PAIRS_VIEW_H 78