diff --git a/src/apps/sudoku/CenteredViewContainer.cpp b/src/apps/sudoku/CenteredViewContainer.cpp deleted file mode 100644 index 3cd278d2dc..0000000000 --- a/src/apps/sudoku/CenteredViewContainer.cpp +++ /dev/null @@ -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() -} diff --git a/src/apps/sudoku/CenteredViewContainer.h b/src/apps/sudoku/CenteredViewContainer.h deleted file mode 100644 index 3c3b04df0b..0000000000 --- a/src/apps/sudoku/CenteredViewContainer.h +++ /dev/null @@ -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 - - - -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 diff --git a/src/apps/sudoku/Jamfile b/src/apps/sudoku/Jamfile index 5724d0a6f9..7f7176eb6d 100644 --- a/src/apps/sudoku/Jamfile +++ b/src/apps/sudoku/Jamfile @@ -3,7 +3,6 @@ SubDir HAIKU_TOP src apps sudoku ; UsePrivateHeaders shared ; Application Sudoku : - CenteredViewContainer.cpp ProgressWindow.cpp Sudoku.cpp SudokuField.cpp diff --git a/src/apps/sudoku/SudokuView.cpp b/src/apps/sudoku/SudokuView.cpp index ae12cc39fc..d2a1324abd 100644 --- a/src/apps/sudoku/SudokuView.cpp +++ b/src/apps/sudoku/SudokuView.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) diff --git a/src/apps/sudoku/SudokuView.h b/src/apps/sudoku/SudokuView.h index 15239bd7ad..ae30889fea 100644 --- a/src/apps/sudoku/SudokuView.h +++ b/src/apps/sudoku/SudokuView.h @@ -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(); diff --git a/src/apps/sudoku/SudokuWindow.cpp b/src/apps/sudoku/SudokuWindow.cpp index 73e87b699f..f84dd5aa8d 100644 --- a/src/apps/sudoku/SudokuWindow.cpp +++ b/src/apps/sudoku/SudokuWindow.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -22,7 +23,6 @@ #include -#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"));