repository_infos: Enable automatic updates on the main Haiku repostiory.
[haiku.git] / src / apps / pairs / PairsView.h
blobed229f46ea44caaf6fbd1bf5af3a0664ed19f674
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.
6 * Distributed under the terms of the MIT License.
8 * Authors:
9 * Ralf Schülke, ralf.schuelke@googlemail.com
10 * John Scipione, jscipione@gmail.com
11 * Adam Smith, adamd.smith@utoronto.ca
13 #ifndef PAIRS_VIEW_H
14 #define PAIRS_VIEW_H
17 #include <ObjectList.h>
18 #include <View.h>
21 const uint8 kSmallIconSize = 32;
22 const uint8 kMediumIconSize = 64;
23 const uint8 kLargeIconSize = 128;
25 const uint32 kMsgCardButton = 'card';
28 class BBitmap;
29 class PairsButton;
32 class PairsView : public BView {
33 public:
34 PairsView(BRect frame, const char* name,
35 uint8 rows, uint8 cols, uint8 iconSize);
37 virtual ~PairsView();
38 virtual void AttachedToWindow();
39 virtual void Draw(BRect updateRect);
40 virtual void FrameResized(float newWidth, float newHeight);
42 virtual void CreateGameBoard();
44 int32 Rows() const { return fRows; };
45 int32 Cols() const { return fCols; };
46 BObjectList<PairsButton>* PairsButtonList() const
47 { return fPairsButtonList; };
49 int32 GetIconPosition(int32 index);
51 int32 IconSize() const { return fIconSize; };
52 void SetIconSize(int32 size) { fIconSize = size; };
54 int32 Spacing() const { return fIconSize / 6; };
56 private:
57 void _GenerateCardPositions();
58 void _ReadRandomIcons();
59 void _SetPairsBoard();
60 void _SetPositions();
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;
77 #endif // PAIRS_VIEW_H