Sudoku: use the layout API.
* This removes the CenteredViewContainer class, as it is no longer being used. * However, it also removes its functionality, ie. the Sudoku view now fills the complete window (even without any borders), again.
This commit is contained in:
parent
2e14f933e5
commit
5ab027fdc9
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007, Michael Pfeiffer, laplace@users.sourceforge.net.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "CenteredViewContainer.h"
|
||||
|
||||
|
||||
CenteredViewContainer::CenteredViewContainer(BView* target, const char* name)
|
||||
:
|
||||
BView(name, B_WILL_DRAW | B_FRAME_EVENTS),
|
||||
fTarget(target)
|
||||
{
|
||||
SetViewColor(B_TRANSPARENT_COLOR);
|
||||
// to avoid flickering
|
||||
AddChild(fTarget);
|
||||
_CenterTarget(frame.Width(), frame.Height());
|
||||
}
|
||||
|
||||
CenteredViewContainer::~CenteredViewContainer()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
CenteredViewContainer::Draw(BRect updateRect)
|
||||
{
|
||||
FillRect(updateRect);
|
||||
}
|
||||
|
||||
void
|
||||
CenteredViewContainer::FrameResized(float width, float height)
|
||||
{
|
||||
BView::FrameResized(width, height);
|
||||
_CenterTarget(width, height);
|
||||
}
|
||||
|
||||
void CenteredViewContainer::_CenterTarget(float width, float height)
|
||||
{
|
||||
float size = width < height ? width : height;
|
||||
float left = floor((width - size) / 2);
|
||||
float top = floor((height - size) / 2);
|
||||
fTarget->MoveTo(left, top);
|
||||
fTarget->ResizeTo(size, size);
|
||||
fTarget->FrameResized(size, size);
|
||||
// in BeOS R5 BView::FrameResized is not (always) called automatically
|
||||
// after ResizeTo()
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2007, Michael Pfeiffer, laplace@users.sourceforge.net. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef CENTERED_VIEW_CONTAINER_H
|
||||
#define CENTERED_VIEW_CONTAINER_H
|
||||
|
||||
|
||||
#include <View.h>
|
||||
|
||||
|
||||
|
||||
class CenteredViewContainer : public BView {
|
||||
public:
|
||||
CenteredViewContainer(BView *target, BRect frame, const char* name, uint32 resizingMode);
|
||||
virtual ~CenteredViewContainer();
|
||||
|
||||
void Draw(BRect updateRect);
|
||||
void FrameResized(float width, float height);
|
||||
|
||||
private:
|
||||
void _CenterTarget(float width, float height);
|
||||
|
||||
BView *fTarget;
|
||||
};
|
||||
|
||||
#endif // CENTERED_VIEW_CONTAINER_H
|
@ -3,7 +3,6 @@ SubDir HAIKU_TOP src apps sudoku ;
|
||||
UsePrivateHeaders shared ;
|
||||
|
||||
Application Sudoku :
|
||||
CenteredViewContainer.cpp
|
||||
ProgressWindow.cpp
|
||||
Sudoku.cpp
|
||||
SudokuField.cpp
|
||||
|
@ -61,6 +61,15 @@ SudokuView::SudokuView(BRect frame, const char* name,
|
||||
}
|
||||
|
||||
|
||||
SudokuView::SudokuView(const char* name, const BMessage& settings)
|
||||
:
|
||||
BView(name,
|
||||
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS)
|
||||
{
|
||||
_InitObject(&settings);
|
||||
}
|
||||
|
||||
|
||||
SudokuView::SudokuView(BMessage* archive)
|
||||
:
|
||||
BView(archive)
|
||||
|
@ -35,6 +35,8 @@ public:
|
||||
SudokuView(BRect frame, const char* name,
|
||||
const BMessage& settings,
|
||||
uint32 resizingMode);
|
||||
SudokuView(const char* name,
|
||||
const BMessage& settings);
|
||||
SudokuView(BMessage* archive);
|
||||
virtual ~SudokuView();
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <File.h>
|
||||
#include <FilePanel.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuBar.h>
|
||||
#include <MenuItem.h>
|
||||
@ -22,7 +23,6 @@
|
||||
|
||||
#include <be_apps/Tracker/RecentItems.h>
|
||||
|
||||
#include "CenteredViewContainer.h"
|
||||
#include "ProgressWindow.h"
|
||||
#include "Sudoku.h"
|
||||
#include "SudokuField.h"
|
||||
@ -176,27 +176,16 @@ SudokuWindow::SudokuWindow()
|
||||
int32 level = 0;
|
||||
settings.FindInt32("level", &level);
|
||||
|
||||
// create GUI
|
||||
// Create GUI
|
||||
|
||||
BMenuBar* menuBar = new BMenuBar(Bounds(), "menu");
|
||||
AddChild(menuBar);
|
||||
BMenuBar* menuBar = new BMenuBar("menu");
|
||||
fSudokuView = new SudokuView("sudoku view", settings);
|
||||
|
||||
frame.top = menuBar->Frame().bottom;
|
||||
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
|
||||
.Add(menuBar)
|
||||
.Add(fSudokuView);
|
||||
|
||||
BView* top = new BView(frame, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
|
||||
top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
AddChild(top);
|
||||
|
||||
fSudokuView = new SudokuView(
|
||||
top->Bounds().InsetByCopy(10, 10).OffsetToSelf(0, 0),
|
||||
"sudoku view", settings, B_FOLLOW_NONE);
|
||||
CenteredViewContainer* container = new CenteredViewContainer(fSudokuView,
|
||||
top->Bounds().InsetByCopy(10, 10),
|
||||
"center", B_FOLLOW_ALL);
|
||||
container->SetHighColor(top->ViewColor());
|
||||
top->AddChild(container);
|
||||
|
||||
// add menu
|
||||
// Build menu
|
||||
|
||||
// "File" menu
|
||||
BMenu* menu = new BMenu(B_TRANSLATE("File"));
|
||||
|
Loading…
Reference in New Issue
Block a user