From 8c1ad886ee4b203883119c567543a653a8d86627 Mon Sep 17 00:00:00 2001 From: Ryan Leavengood Date: Thu, 13 Aug 2009 07:28:11 +0000 Subject: [PATCH] - Cleanup to match coding guidelines. The header cleanup might have been overkill. - Updating some copyright years. - ResizerWindow.h was not self-contained. Some of the other files were skipped due to complexity and planned code changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32296 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/showimage/EntryMenuItem.cpp | 69 +++++----- src/apps/showimage/EntryMenuItem.h | 67 ++++------ src/apps/showimage/PrintOptionsWindow.cpp | 132 ++++++++++--------- src/apps/showimage/PrintOptionsWindow.h | 140 ++++++++++----------- src/apps/showimage/ProgressWindow.cpp | 9 +- src/apps/showimage/ProgressWindow.h | 23 ++-- src/apps/showimage/ResizerWindow.cpp | 59 +++++---- src/apps/showimage/ResizerWindow.h | 34 ++--- src/apps/showimage/ShowImage.rdef | 2 +- src/apps/showimage/ShowImageApp.cpp | 16 +-- src/apps/showimage/ShowImageApp.h | 45 +++---- src/apps/showimage/ShowImageSettings.cpp | 54 ++++---- src/apps/showimage/ShowImageSettings.h | 85 +++++-------- src/apps/showimage/ShowImageStatusView.cpp | 48 +++---- src/apps/showimage/ShowImageStatusView.h | 59 +++------ src/apps/showimage/ShowImageUndo.cpp | 53 ++++---- src/apps/showimage/ShowImageUndo.h | 82 +++++------- 17 files changed, 446 insertions(+), 531 deletions(-) diff --git a/src/apps/showimage/EntryMenuItem.cpp b/src/apps/showimage/EntryMenuItem.cpp index b2f1d0e8b8..80ccc63144 100644 --- a/src/apps/showimage/EntryMenuItem.cpp +++ b/src/apps/showimage/EntryMenuItem.cpp @@ -1,48 +1,33 @@ -/*****************************************************************************/ -// EntryMenuItem -// Written by Michael Pfeiffer -// -// EntryMenuItem.cpp -// -// -// Copyright (c) 2003 OpenBeOS Project -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ +/* + * Copyright 2003-2009 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Michael Pfeiffer, laplace@haiku-os.org + */ + +#include "EntryMenuItem.h" #include #include -#include "EntryMenuItem.h" -EntryMenuItem::EntryMenuItem(entry_ref* ref, const char* label, BMessage* message, char shortcut, uint32 modifiers) - : BMenuItem(label, message, shortcut, modifiers) - , fEntry(*ref) - , fSmallIcon(NULL) +EntryMenuItem::EntryMenuItem(entry_ref* ref, const char* label, + BMessage* message, char shortcut, uint32 modifiers) + : + BMenuItem(label, message, shortcut, modifiers), + fEntry(*ref), + fSmallIcon(NULL) { } + EntryMenuItem::~EntryMenuItem() { delete fSmallIcon; } + void EntryMenuItem::GetContentSize(float* width, float* height) { @@ -53,6 +38,7 @@ EntryMenuItem::GetContentSize(float* width, float* height) } } + void EntryMenuItem::DrawContent() { @@ -60,7 +46,7 @@ EntryMenuItem::DrawContent() BPoint pos(view->PenLocation()); if (fSmallIcon == NULL) { - fSmallIcon = LoadIcon(); // load on demand + fSmallIcon = LoadIcon(); // Load on demand } view->MovePenBy(kTextIndent, 0); @@ -72,17 +58,20 @@ EntryMenuItem::DrawContent() } } + BBitmap* EntryMenuItem::GetIcon(BMimeType* mimeType) { BBitmap* icon; - icon = new BBitmap(BRect(0, 0, kIconSize-1, kIconSize-1), B_CMAP8); + icon = new BBitmap(BRect(0, 0, kIconSize - 1, kIconSize - 1), B_CMAP8); if (mimeType->GetIcon(icon, B_MINI_ICON) != B_OK) { - delete icon; icon = NULL; + delete icon; + icon = NULL; } return icon; } + BBitmap* EntryMenuItem::LoadIcon() { @@ -93,20 +82,21 @@ EntryMenuItem::LoadIcon() // Note: BNodeInfo::GetTrackerIcon does not work as expected! - // try to get the icon stored in file attribute + // Try to get the icon stored in file attribute icon = new BBitmap(BRect(0, 0, kIconSize-1, kIconSize-1), B_CMAP8); if (info.GetIcon(icon, B_MINI_ICON) == B_OK) { return icon; } - delete icon; icon = NULL; + delete icon; + icon = NULL; - // get the icon from type + // Get the icon from type if (info.GetType(type) == B_OK) { BMimeType mimeType(type); BMimeType superType; if (mimeType.InitCheck() == B_OK) { icon = GetIcon(&mimeType); - // or super type + // Or super type if (icon == NULL && mimeType.GetSupertype(&superType) == B_OK) { icon = GetIcon(&superType); } @@ -115,3 +105,4 @@ EntryMenuItem::LoadIcon() return icon; } + diff --git a/src/apps/showimage/EntryMenuItem.h b/src/apps/showimage/EntryMenuItem.h index 07f66a697c..f128ba189c 100644 --- a/src/apps/showimage/EntryMenuItem.h +++ b/src/apps/showimage/EntryMenuItem.h @@ -1,59 +1,42 @@ -/*****************************************************************************/ -// EntryMenuItem -// Written by Michael Pfeiffer -// -// EntryMenuItem.h -// -// -// Copyright (c) 2003 OpenBeOS Project -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ +/* + * Copyright 2003-2009 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Michael Pfeiffer, laplace@haiku-os.org + */ +#ifndef ENTRY_MENU_ITEM_H +#define ENTRY_MENU_ITEM_H -#ifndef _EntryMenuItem_h -#define _EntryMenuItem_h #include #include #include #include -class EntryMenuItem : public BMenuItem -{ + +class EntryMenuItem : public BMenuItem { public: - EntryMenuItem(entry_ref* entry, const char* label, BMessage* message, char shortcut = 0, uint32 modifiers = 0); - ~EntryMenuItem(); + EntryMenuItem(entry_ref* entry, const char* label, + BMessage* message, char shortcut = 0, uint32 modifiers = 0); + ~EntryMenuItem(); - void GetContentSize(float* width, float* height); - void DrawContent(); + void GetContentSize(float* width, float* height); + void DrawContent(); private: + BBitmap* GetIcon(BMimeType* mimeType); + BBitmap* LoadIcon(); + + entry_ref fEntry; + BBitmap* fSmallIcon; + enum { kIconSize = 16, kTextIndent = kIconSize + 4, }; - - BBitmap* GetIcon(BMimeType* mimeType); - BBitmap* LoadIcon(); - - entry_ref fEntry; - BBitmap* fSmallIcon; }; -#endif + +#endif // ENTRY_MENU_ITEM_H + diff --git a/src/apps/showimage/PrintOptionsWindow.cpp b/src/apps/showimage/PrintOptionsWindow.cpp index b186708aec..cf28898ab1 100644 --- a/src/apps/showimage/PrintOptionsWindow.cpp +++ b/src/apps/showimage/PrintOptionsWindow.cpp @@ -1,55 +1,41 @@ -/*****************************************************************************/ -// PrintOptionsWindow -// Written by Michael Pfeiffer -// -// PrintOptionsWindow.cpp -// -// -// Copyright (c) 2003 OpenBeOS Project -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ +/* + * Copyright 2003-2009 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Michael Pfeiffer, laplace@haiku-os.org + */ + +#include "PrintOptionsWindow.h" + +#include // for sprintf +#include // for atof #include #include #include -#include // for sprintf -#include // for atof -#include "PrintOptionsWindow.h" #include "ShowImageConstants.h" + PrintOptions::PrintOptions() - : fOption(kFitToPage) - , fZoomFactor(1.0) - , fDPI(72.0) - , fWidth(1024 / 72.0) - , fHeight(768 / 72.0) + : + fOption(kFitToPage), + fZoomFactor(1.0), + fDPI(72.0), + fWidth(1024/72.0), + fHeight(768/72.0) { } + void PrintOptions::SetBounds(BRect rect) { fBounds = rect; } + void PrintOptions::SetZoomFactor(float f) { @@ -57,6 +43,7 @@ PrintOptions::SetZoomFactor(float f) fDPI = 72.0 / fZoomFactor; } + void PrintOptions::SetDPI(float dpi) { @@ -64,13 +51,15 @@ PrintOptions::SetDPI(float dpi) fZoomFactor = 72.0 / dpi; } + void PrintOptions::SetWidth(float w) { fWidth = w; - fHeight = (fBounds.Height()+1) * w / (fBounds.Width()+1); + fHeight = (fBounds.Height() + 1) * w / (fBounds.Width() + 1); } + void PrintOptions::SetHeight(float h) { @@ -78,20 +67,24 @@ PrintOptions::SetHeight(float h) fHeight = h; } -PrintOptionsWindow::PrintOptionsWindow(BPoint at, PrintOptions *options, BWindow* listener) - : BWindow(BRect(at.x, at.y, at.x+300, at.y+200), "Print Options", - B_TITLED_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, - B_NOT_ZOOMABLE | B_NOT_RESIZABLE) - , fPrintOptions(options) - , fCurrentOptions(*options) - , fListener(listener) - , fStatus(B_ERROR) + +PrintOptionsWindow::PrintOptionsWindow(BPoint at, PrintOptions *options, + BWindow* listener) + : + BWindow(BRect(at.x, at.y, at.x + 300, at.y + 200), "Print Options", + B_TITLED_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, + B_NOT_ZOOMABLE | B_NOT_RESIZABLE), + fPrintOptions(options), + fCurrentOptions(*options), + fListener(listener), + fStatus(B_ERROR) { AddToSubset(listener); Setup(); Show(); } + PrintOptionsWindow::~PrintOptionsWindow() { BMessage msg(MSG_PRINT); @@ -99,8 +92,10 @@ PrintOptionsWindow::~PrintOptionsWindow() fListener.SendMessage(&msg); } + BRadioButton* -PrintOptionsWindow::AddRadioButton(BView* view, BPoint& at, const char* name, const char* label, uint32 what, bool selected) +PrintOptionsWindow::AddRadioButton(BView* view, BPoint& at, const char* name, + const char* label, uint32 what, bool selected) { BRect rect(0, 0, 100, 20); BRadioButton* button; @@ -113,8 +108,10 @@ PrintOptionsWindow::AddRadioButton(BView* view, BPoint& at, const char* name, co return button; } + BTextControl* -PrintOptionsWindow::AddTextControl(BView* view, BPoint& at, const char* name, const char* label, float value, float divider, uint32 what) +PrintOptionsWindow::AddTextControl(BView* view, BPoint& at, const char* name, + const char* label, float value, float divider, uint32 what) { BRect rect(0, 0, divider + 45, 20); BTextControl* text; @@ -129,6 +126,7 @@ PrintOptionsWindow::AddTextControl(BView* view, BPoint& at, const char* name, co return text; } + void PrintOptionsWindow::Setup() { @@ -145,24 +143,33 @@ PrintOptionsWindow::Setup() B_PLAIN_BORDER); AddChild(panel); - AddRadioButton(panel, at, "fit_to_page", "Fit Image to Page", kMsgFitToPageSelected, op == PrintOptions::kFitToPage); + AddRadioButton(panel, at, "fit_to_page", "Fit Image to Page", + kMsgFitToPageSelected, op == PrintOptions::kFitToPage); textAt = at; - rb = AddRadioButton(panel, at, "zoom_factor", "Zoom Factor in %: ", kMsgZoomFactorSelected, op == PrintOptions::kZoomFactor); + rb = AddRadioButton(panel, at, "zoom_factor", "Zoom Factor in %: ", + kMsgZoomFactorSelected, op == PrintOptions::kZoomFactor); textAt.x = rb->Bounds().right + 5; - fZoomFactor = AddTextControl(panel, textAt, "zoom_factor_text", "", fCurrentOptions.ZoomFactor()*100, 0, kMsgZoomFactorChanged); + fZoomFactor = AddTextControl(panel, textAt, "zoom_factor_text", "", + fCurrentOptions.ZoomFactor()*100, 0, kMsgZoomFactorChanged); textAt = at; - rb = AddRadioButton(panel, at, "dpi", "DPI: ", kMsgDPISelected, op == PrintOptions::kDPI); + rb = AddRadioButton(panel, at, "dpi", "DPI: ", kMsgDPISelected, + op == PrintOptions::kDPI); textAt.x = rb->Bounds().right + 5; - fDPI = AddTextControl(panel, textAt, "dpi_text", "", fCurrentOptions.DPI(), 0, kMsgDPIChanged); + fDPI = AddTextControl(panel, textAt, "dpi_text", "", fCurrentOptions.DPI(), + 0, kMsgDPIChanged); - rb = AddRadioButton(panel, at, "width_and_height", "Resize To (in 1/72 Inches):", kMsgWidthAndHeightSelected, op == PrintOptions::kWidth || op == PrintOptions::kHeight); + rb = AddRadioButton(panel, at, "width_and_height", + "Resize To (in 1/72 Inches):", kMsgWidthAndHeightSelected, + op == PrintOptions::kWidth || op == PrintOptions::kHeight); at.x += 15; textAt = at; - fWidth = AddTextControl(panel, textAt, "width", "Width: ", fCurrentOptions.Width(), 40, kMsgWidthChanged); + fWidth = AddTextControl(panel, textAt, "width", "Width: ", + fCurrentOptions.Width(), 40, kMsgWidthChanged); textAt = at; textAt.x += fWidth->Bounds().Width() + 5; - fHeight = AddTextControl(panel, textAt, "height", "Height: ", fCurrentOptions.Height(), 40, kMsgHeightChanged); + fHeight = AddTextControl(panel, textAt, "height", "Height: ", + fCurrentOptions.Height(), 40, kMsgHeightChanged); at.x = 0; at.y = textAt.y; @@ -172,7 +179,8 @@ PrintOptionsWindow::Setup() at.y += 10; rect.OffsetBy(at); - button = new BButton(rect, "job setup", "Job Setup", new BMessage(kMsgJobSetup)); + button = new BButton(rect, "job setup", "Job Setup", + new BMessage(kMsgJobSetup)); panel->AddChild(button); button->ResizeToPreferred(); @@ -182,11 +190,14 @@ PrintOptionsWindow::Setup() ResizeTo(fHeight->Frame().right + kIndent, button->Frame().bottom + kIndent); // center button - button->MoveTo((Bounds().Width()-button->Bounds().Width())/2, button->Frame().top); + button->MoveTo((Bounds().Width()-button->Bounds().Width())/2, + button->Frame().top); } + enum PrintOptions::Option -PrintOptionsWindow::MsgToOption(uint32 what) { +PrintOptionsWindow::MsgToOption(uint32 what) +{ switch (what) { case kMsgFitToPageSelected: return PrintOptions::kFitToPage; case kMsgZoomFactorSelected: return PrintOptions::kZoomFactor; @@ -196,6 +207,7 @@ PrintOptionsWindow::MsgToOption(uint32 what) { return PrintOptions::kFitToPage; } + bool PrintOptionsWindow::GetValue(BTextControl* text, float* value) { @@ -203,6 +215,7 @@ PrintOptionsWindow::GetValue(BTextControl* text, float* value) return true; } + void PrintOptionsWindow::SetValue(BTextControl* text, float value) { @@ -216,6 +229,7 @@ PrintOptionsWindow::SetValue(BTextControl* text, float value) text->SetModificationMessage(msg); } + void PrintOptionsWindow::MessageReceived(BMessage* msg) { @@ -229,7 +243,8 @@ PrintOptionsWindow::MessageReceived(BMessage* msg) break; case kMsgZoomFactorChanged: - if (GetValue(fZoomFactor, &value) && fCurrentOptions.ZoomFactor() != value) { + if (GetValue(fZoomFactor, &value) + && fCurrentOptions.ZoomFactor() != value) { fCurrentOptions.SetZoomFactor(value/100); SetValue(fDPI, fCurrentOptions.DPI()); } @@ -263,3 +278,4 @@ PrintOptionsWindow::MessageReceived(BMessage* msg) BWindow::MessageReceived(msg); } } + diff --git a/src/apps/showimage/PrintOptionsWindow.h b/src/apps/showimage/PrintOptionsWindow.h index acd5a632f3..e3262acd03 100644 --- a/src/apps/showimage/PrintOptionsWindow.h +++ b/src/apps/showimage/PrintOptionsWindow.h @@ -1,42 +1,29 @@ -/*****************************************************************************/ -// PrintOptionsWindow -// Written by Michael Pfeiffer -// -// PrintOptionsWindow.h -// -// -// Copyright (c) 2003 OpenBeOS Project -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ +/* + * Copyright 2003-2009 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Michael Pfeiffer, laplace@haiku-os.org + */ +#ifndef PRINT_OPTIONS_WINDOW_H +#define PRINT_OPTIONS_WINDOW_H -#ifndef _PrintOptionsWindow_h -#define _PrintOptionsWindow_h -#include -#include -#include #include +#include #include +#include +#include + class PrintOptions { public: + PrintOptions(); + + // bounds of the image + BRect Bounds() const { return fBounds; } + void SetBounds(BRect bounds); + enum Option { kFitToPage, kZoomFactor, @@ -45,50 +32,60 @@ public: kHeight, kNumberOfOptions }; - - PrintOptions(); + enum Option Option() const { return fOption; } + void SetOption(enum Option op) { fOption = op; } - // bounds of the image - BRect Bounds() const { return fBounds; } - void SetBounds(BRect bounds); - - enum Option Option() const { return fOption; } - void SetOption(enum Option op) { fOption = op; } - // zoomFactor = 72.0 / dpi - float ZoomFactor() const { return fZoomFactor; } - void SetZoomFactor(float z); - float DPI() const { return fDPI; } - void SetDPI(float dpi); - // setting width/height updates height/width to keep aspect ratio - float Width() const { return fWidth; } - float Height() const { return fHeight; } - void SetWidth(float width); - void SetHeight(float height); + // ZoomFactor = 72.0 / dpi + float ZoomFactor() const { return fZoomFactor; } + void SetZoomFactor(float z); + float DPI() const { return fDPI; } + void SetDPI(float dpi); + + // Setting width/height updates height/width to keep aspect ratio + float Width() const { return fWidth; } + float Height() const { return fHeight; } + void SetWidth(float width); + void SetHeight(float height); private: - BRect fBounds; - enum Option fOption; - float fZoomFactor; - float fDPI; - float fWidth, fHeight; // 1/72 Inches + BRect fBounds; + enum Option fOption; + float fZoomFactor; + float fDPI; + float fWidth, fHeight; // 1/72 Inches }; -class PrintOptionsWindow : public BWindow -{ +class PrintOptionsWindow : public BWindow { public: - PrintOptionsWindow(BPoint at, PrintOptions* options, BWindow* listener); - ~PrintOptionsWindow(); + PrintOptionsWindow(BPoint at, + PrintOptions* options, BWindow* listener); + ~PrintOptionsWindow(); - void MessageReceived(BMessage* msg); + void MessageReceived(BMessage* msg); private: - BRadioButton* AddRadioButton(BView* view, BPoint& at, const char* name, const char* label, uint32 what, bool selected); - BTextControl* AddTextControl(BView* view, BPoint& at, const char* name, const char* label, float value, float divider, uint32 what); - void Setup(); - enum PrintOptions::Option MsgToOption(uint32 what); - bool GetValue(BTextControl* text, float* value); - void SetValue(BTextControl* text, float value); + BRadioButton* AddRadioButton(BView* view, BPoint& at, + const char* name, const char* label, + uint32 what, bool selected); + + BTextControl* AddTextControl(BView* view, BPoint& at, + const char* name, const char* label, + float value, float divider, uint32 what); + + void Setup(); + enum PrintOptions::Option MsgToOption(uint32 what); + bool GetValue(BTextControl* text, float* value); + void SetValue(BTextControl* text, float value); + PrintOptions* fPrintOptions; + PrintOptions fCurrentOptions; + BMessenger fListener; + status_t fStatus; + BTextControl* fZoomFactor; + BTextControl* fDPI; + BTextControl* fWidth; + BTextControl* fHeight; + enum { kMsgOK = 'mPOW', kMsgFitToPageSelected, @@ -106,15 +103,8 @@ private: kIndent = 5, kLineSkip = 5, }; - - PrintOptions* fPrintOptions; - PrintOptions fCurrentOptions; - BMessenger fListener; - status_t fStatus; - BTextControl* fZoomFactor; - BTextControl* fDPI; - BTextControl* fWidth; - BTextControl* fHeight; }; + #endif + diff --git a/src/apps/showimage/ProgressWindow.cpp b/src/apps/showimage/ProgressWindow.cpp index 5407583b11..27bb2fc043 100644 --- a/src/apps/showimage/ProgressWindow.cpp +++ b/src/apps/showimage/ProgressWindow.cpp @@ -3,23 +3,24 @@ * Distributed under the terms of the MIT License. */ - #include "ProgressWindow.h" -#include "ShowImageConstants.h" + +#include #include #include #include #include -#include +#include "ShowImageConstants.h" static const uint32 kMsgShow = 'show'; ProgressWindow::ProgressWindow(BWindow* referenceWindow) - : BWindow(BRect(0, 0, 250, 100), "Progress Monitor", + : + BWindow(BRect(0, 0, 250, 100), "Progress Monitor", B_MODAL_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS), fRunner(NULL) diff --git a/src/apps/showimage/ProgressWindow.h b/src/apps/showimage/ProgressWindow.h index 7af34be565..3bbf56db3b 100644 --- a/src/apps/showimage/ProgressWindow.h +++ b/src/apps/showimage/ProgressWindow.h @@ -13,20 +13,21 @@ class BStatusBar; class ProgressWindow : public BWindow { - public: - ProgressWindow(BWindow* referenceWindow); - virtual ~ProgressWindow(); +public: + ProgressWindow(BWindow* referenceWindow); + virtual ~ProgressWindow(); - virtual void MessageReceived(BMessage *message); + virtual void MessageReceived(BMessage *message); - void Start(); - void Stop(); + void Start(); + void Stop(); - private: - BStatusBar* fStatusBar; - BMessageRunner* fRunner; - bool fRetrievedUpdate; - bool fRetrievedShow; +private: + BStatusBar* fStatusBar; + BMessageRunner* fRunner; + bool fRetrievedUpdate; + bool fRetrievedShow; }; + #endif // PROGRESS_WINDOW_H diff --git a/src/apps/showimage/ResizerWindow.cpp b/src/apps/showimage/ResizerWindow.cpp index 29fcd595c1..8ad58c660d 100644 --- a/src/apps/showimage/ResizerWindow.cpp +++ b/src/apps/showimage/ResizerWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd. * Copyright 2006 Bernd Korz. All Rights Reserved * Distributed under the terms of the MIT License. @@ -7,10 +7,13 @@ * Authors: * yellowTAB GmbH * Bernd Korz - * Michael Pfeiffer - * Ryan Leavengood + * Michael Pfeiffer + * Ryan Leavengood */ +#include "ResizerWindow.h" + +#include #include #include @@ -20,9 +23,6 @@ #include #include -#include - -#include "ResizerWindow.h" #include "ShowImageConstants.h" @@ -37,10 +37,12 @@ static const float kVerticalIndent = 10; ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height) - : BWindow(BRect(100, 100, 300, 300), "Resize", B_FLOATING_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE) - , fOriginalWidth(width) - , fOriginalHeight(height) - , fTarget(target) + : + BWindow(BRect(100, 100, 300, 300), "Resize", B_FLOATING_WINDOW, + B_NOT_ZOOMABLE | B_NOT_RESIZABLE), + fOriginalWidth(width), + fOriginalHeight(height), + fTarget(target) { BView* back_view = new BView(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW); back_view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); @@ -51,8 +53,10 @@ ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height) const float column2 = max_c(widthLabelWidth, heightLabelWidth); const float textControlWidth = column2 + back_view->StringWidth("999999"); - const float keepAspectRatioLabelWidth = 20 + back_view->StringWidth(kKeepAspectRatioLabel); - const float width2 = 2 * kHorizontalIndent + max_c(textControlWidth, keepAspectRatioLabelWidth); + const float keepAspectRatioLabelWidth = 20 + + back_view->StringWidth(kKeepAspectRatioLabel); + const float width2 = 2 * kHorizontalIndent + + max_c(textControlWidth, keepAspectRatioLabelWidth); ResizeTo(width2+1, Bounds().Height()+1); @@ -62,17 +66,20 @@ ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height) BString widthValue; widthValue << width; - fWidth = new BTextControl(rect, "width", kWidthLabel, widthValue.String(), NULL); + fWidth = new BTextControl(rect, "width", kWidthLabel, widthValue.String(), + NULL); fWidth->SetModificationMessage(new BMessage(kWidthModifiedMsg)); AddControl(back_view, fWidth, column2, rect); BString heightValue; heightValue << height; - fHeight = new BTextControl(rect, "height", kHeightLabel, heightValue.String(), NULL); + fHeight = new BTextControl(rect, "height", kHeightLabel, + heightValue.String(), NULL); fHeight->SetModificationMessage(new BMessage(kHeightModifiedMsg)); AddControl(back_view, fHeight, column2, rect); - fAspectRatio = new BCheckBox(rect, "Ratio", kKeepAspectRatioLabel, new BMessage(kWidthModifiedMsg)); + fAspectRatio = new BCheckBox(rect, "Ratio", kKeepAspectRatioLabel, + new BMessage(kWidthModifiedMsg)); fAspectRatio->SetValue(B_CONTROL_ON); AddControl(back_view, fAspectRatio, column2, rect); @@ -87,8 +94,14 @@ ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height) } +ResizerWindow::~ResizerWindow() +{ +} + + void -ResizerWindow::AddControl(BView* view, BControl* control, float column2, BRect& rect) +ResizerWindow::AddControl(BView* view, BControl* control, float column2, + BRect& rect) { float width, height; view->AddChild(control); @@ -116,7 +129,8 @@ ResizerWindow::AddSeparatorLine(BView* view, BRect& rect) line.right -= 3; line.top = rect.top; line.bottom = line.top + lineWidth - 1; - BBox* separatorLine = new BBox(line, "", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER); + BBox* separatorLine = new BBox(line, "", B_FOLLOW_LEFT_RIGHT, + B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER); view->AddChild(separatorLine); rect.OffsetBy(0, kLineDistance + lineWidth); } @@ -177,7 +191,8 @@ ResizerWindow::MessageReceived(BMessage* message) case kWidthModifiedMsg: if (fAspectRatio->Value() == B_CONTROL_ON) { int w = atoi(fWidth->Text()); - int h = (int)((int64)w * (int64) fOriginalHeight / (int64) fOriginalWidth); + int h = (int)((int64)w * (int64) fOriginalHeight + / (int64) fOriginalWidth); BString height; height << h; BMessage* msg = new BMessage(*fHeight->ModificationMessage()); @@ -189,7 +204,8 @@ ResizerWindow::MessageReceived(BMessage* message) case kHeightModifiedMsg: if (fAspectRatio->Value() == B_CONTROL_ON) { int h = atoi(fHeight->Text()); - int w = (int)((int64)h * (int64) fOriginalWidth / (int64) fOriginalHeight); + int w = (int)((int64)h * (int64) fOriginalWidth + / (int64) fOriginalHeight); BString width; width << w; BMessage* msg = new BMessage(*fWidth->ModificationMessage()); @@ -213,11 +229,6 @@ ResizerWindow::MessageReceived(BMessage* message) } -ResizerWindow::~ResizerWindow() -{ -} - - bool ResizerWindow::QuitRequested() { diff --git a/src/apps/showimage/ResizerWindow.h b/src/apps/showimage/ResizerWindow.h index e9be45b5da..e355fed814 100644 --- a/src/apps/showimage/ResizerWindow.h +++ b/src/apps/showimage/ResizerWindow.h @@ -1,5 +1,5 @@ /* - * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. * Copyright 2004-2005 yellowTAB GmbH. All Rights Reserverd. * Copyright 2006 Bernd Korz. All Rights Reserved * Distributed under the terms of the MIT License. @@ -7,15 +7,16 @@ * Authors: * yellowTAB GmbH * Bernd Korz - * Michael Pfeiffer - * Ryan Leavengood + * Michael Pfeiffer + * Ryan Leavengood */ -#ifndef _RESIZER_WINDOW_H -#define _RESIZER_WINDOW_H +#ifndef RESIZER_WINDOW_H +#define RESIZER_WINDOW_H -#include +#include #include +#include class BCheckBox; class BControl; @@ -24,7 +25,8 @@ class BTextControl; class ResizerWindow : public BWindow { public: - ResizerWindow(BMessenger target, int32 width, int32 height ); + ResizerWindow(BMessenger target, int32 width, + int32 height ); virtual void MessageReceived(BMessage* msg); virtual bool QuitRequested(); @@ -36,7 +38,8 @@ class ResizerWindow : public BWindow { kActivateMsg = 'RSRa', // activates the window kUpdateMsg, - // provides the new size of the image in two "int32" fields "width" and "height" + // provides the new size of the image in two "int32" fields + // "width" and "height" }; private: @@ -47,10 +50,10 @@ class ResizerWindow : public BWindow { kApplyMsg, }; - void AddControl(BView* parent, BControl* control, float column2, - BRect& rect); - void AddSeparatorLine(BView* parent, BRect& rect); - void LeftAlign(BControl* control); + void AddControl(BView* parent, BControl* control, + float column2, BRect& rect); + void AddSeparatorLine(BView* parent, BRect& rect); + void LeftAlign(BControl* control); BTextControl* fWidth; BTextControl* fHeight; @@ -58,9 +61,10 @@ class ResizerWindow : public BWindow { BButton* fApply; // the original size of the image use for aspect ratio calculation // to avoid rounding errors - int32 fOriginalWidth; - int32 fOriginalHeight; + int32 fOriginalWidth; + int32 fOriginalHeight; BMessenger fTarget; }; -#endif // _RESIZER_WINDOW_H + +#endif // RESIZER_WINDOW_H diff --git a/src/apps/showimage/ShowImage.rdef b/src/apps/showimage/ShowImage.rdef index 2bebecf957..2a4b8a0f22 100644 --- a/src/apps/showimage/ShowImage.rdef +++ b/src/apps/showimage/ShowImage.rdef @@ -13,7 +13,7 @@ resource app_version { internal = 0, short_info = "ShowImage", - long_info = "ShowImage ©2003-2007 Haiku, Inc." + long_info = "ShowImage ©2003-2009 Haiku, Inc." }; resource app_flags B_SINGLE_LAUNCH; diff --git a/src/apps/showimage/ShowImageApp.cpp b/src/apps/showimage/ShowImageApp.cpp index d86d9f7088..fcf297a47b 100644 --- a/src/apps/showimage/ShowImageApp.cpp +++ b/src/apps/showimage/ShowImageApp.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -9,10 +9,9 @@ * Ryan Leavengood */ - #include "ShowImageApp.h" -#include "ShowImageConstants.h" -#include "ShowImageWindow.h" + +#include #include #include @@ -21,7 +20,8 @@ #include #include -#include +#include "ShowImageConstants.h" +#include "ShowImageWindow.h" #define WINDOWS_TO_IGNORE 1 @@ -30,7 +30,8 @@ extern const char *kApplicationSignature = "application/x-vnd.Haiku-ShowImage"; ShowImageApp::ShowImageApp() - : BApplication(kApplicationSignature) + : + BApplication(kApplicationSignature) { fPulseStarted = false; fOpenPanel = new BFilePanel(B_OPEN_PANEL); @@ -109,7 +110,8 @@ ShowImageApp::ArgvReceived(int32 argc, char **argv) // get current working directory const char *cwd; - if (CurrentMessage() == NULL || CurrentMessage()->FindString("cwd", &cwd) != B_OK) + if (CurrentMessage() == NULL + || CurrentMessage()->FindString("cwd", &cwd) != B_OK) cwd = ""; for (int32 i = 1; i < argc; i++) { diff --git a/src/apps/showimage/ShowImageApp.h b/src/apps/showimage/ShowImageApp.h index 57e3492ce2..ffc8344501 100644 --- a/src/apps/showimage/ShowImageApp.h +++ b/src/apps/showimage/ShowImageApp.h @@ -1,5 +1,5 @@ /* - * Copyright 2003-2006, Haiku, Inc. All Rights Reserved. + * Copyright 2003-2009, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -18,36 +18,37 @@ class ShowImageApp : public BApplication { - public: - ShowImageApp(); - virtual ~ShowImageApp(); +public: + ShowImageApp(); + virtual ~ShowImageApp(); - public: - virtual void AboutRequested(); - virtual void ArgvReceived(int32 argc, char **argv); - virtual void MessageReceived(BMessage *message); - virtual void ReadyToRun(); - virtual void Pulse(); - virtual void RefsReceived(BMessage *message); - virtual bool QuitRequested(); + virtual void AboutRequested(); + virtual void ArgvReceived(int32 argc, char **argv); + virtual void MessageReceived(BMessage *message); + virtual void ReadyToRun(); + virtual void Pulse(); + virtual void RefsReceived(BMessage *message); + virtual bool QuitRequested(); - ShowImageSettings* Settings() { return &fSettings; } + ShowImageSettings* Settings() { return &fSettings; } - private: - void StartPulse(); - void Open(const entry_ref *ref); - void BroadcastToWindows(BMessage *message); - void CheckClipboard(); +private: + void StartPulse(); + void Open(const entry_ref *ref); + void BroadcastToWindows(BMessage *message); + void CheckClipboard(); - BMessenger fTrackerMessenger; // of the window this was launched - BFilePanel *fOpenPanel; - bool fPulseStarted; - ShowImageSettings fSettings; + BMessenger fTrackerMessenger; + BFilePanel *fOpenPanel; + bool fPulseStarted; + ShowImageSettings fSettings; }; + extern const char *kApplicationSignature; #define my_app dynamic_cast(be_app) + #endif // SHOW_IMAGE_APP_H diff --git a/src/apps/showimage/ShowImageSettings.cpp b/src/apps/showimage/ShowImageSettings.cpp index 3ce64f16b4..e03a8e3455 100644 --- a/src/apps/showimage/ShowImageSettings.cpp +++ b/src/apps/showimage/ShowImageSettings.cpp @@ -1,42 +1,24 @@ -/*****************************************************************************/ -// ShowImageSettings -// Written by Michael Pfeiffer -// -// ShowImageSettings.cpp -// -// -// Copyright (c) 2003 OpenBeOS Project -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ +/* + * Copyright 2003-2009 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Michael Pfeiffer, laplace@haiku-os.org + */ + +#include "ShowImageSettings.h" #include #include #include -#include "ShowImageSettings.h" ShowImageSettings::ShowImageSettings() { Load(); } + ShowImageSettings::~ShowImageSettings() { if (Lock()) { @@ -45,18 +27,21 @@ ShowImageSettings::~ShowImageSettings() } } + bool ShowImageSettings::Lock() { return fLock.Lock(); } + void ShowImageSettings::Unlock() { fLock.Unlock(); } + bool ShowImageSettings::GetBool(const char* name, bool defaultValue) { @@ -68,6 +53,7 @@ ShowImageSettings::GetBool(const char* name, bool defaultValue) } } + int32 ShowImageSettings::GetInt32(const char* name, int32 defaultValue) { @@ -79,6 +65,7 @@ ShowImageSettings::GetInt32(const char* name, int32 defaultValue) } } + float ShowImageSettings::GetFloat(const char* name, float defaultValue) { @@ -90,6 +77,7 @@ ShowImageSettings::GetFloat(const char* name, float defaultValue) } } + BRect ShowImageSettings::GetRect(const char* name, BRect defaultValue) { @@ -101,6 +89,7 @@ ShowImageSettings::GetRect(const char* name, BRect defaultValue) } } + const char* ShowImageSettings::GetString(const char* name, const char* defaultValue) { @@ -112,6 +101,7 @@ ShowImageSettings::GetString(const char* name, const char* defaultValue) } } + void ShowImageSettings::SetBool(const char* name, bool value) { @@ -122,6 +112,7 @@ ShowImageSettings::SetBool(const char* name, bool value) } } + void ShowImageSettings::SetInt32(const char* name, int32 value) { @@ -132,6 +123,7 @@ ShowImageSettings::SetInt32(const char* name, int32 value) } } + void ShowImageSettings::SetFloat(const char* name, float value) { @@ -142,6 +134,7 @@ ShowImageSettings::SetFloat(const char* name, float value) } } + void ShowImageSettings::SetRect(const char* name, BRect value) { @@ -152,6 +145,7 @@ ShowImageSettings::SetRect(const char* name, BRect value) } } + void ShowImageSettings::SetString(const char* name, const char* value) { @@ -162,6 +156,7 @@ ShowImageSettings::SetString(const char* name, const char* value) } } + bool ShowImageSettings::OpenSettingsFile(BFile* file, bool forReading) { @@ -182,6 +177,7 @@ ShowImageSettings::OpenSettingsFile(BFile* file, bool forReading) return st == B_OK; } + void ShowImageSettings::Load() { @@ -191,6 +187,7 @@ ShowImageSettings::Load() } } + void ShowImageSettings::Save() { @@ -199,3 +196,4 @@ ShowImageSettings::Save() fSettings.Flatten(&file); } } + diff --git a/src/apps/showimage/ShowImageSettings.h b/src/apps/showimage/ShowImageSettings.h index f6335dbaed..4ed3b4d265 100644 --- a/src/apps/showimage/ShowImageSettings.h +++ b/src/apps/showimage/ShowImageSettings.h @@ -1,64 +1,45 @@ -/*****************************************************************************/ -// ShowImageSettings -// Written by Michael Pfeiffer -// -// ShowImageSettings.cpp -// -// -// Copyright (c) 2003 OpenBeOS Project -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ +/* + * Copyright 2003-2009 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Michael Pfeiffer, laplace@haiku-os.org + */ +#ifndef SHOW_IMAGE_SETTINGS_H +#define SHOW_IMAGE_SETTINGS_H -#ifndef _ShowImageSettings_H -#define _ShowImageSettings_H #include #include #include -class ShowImageSettings -{ -public: - ShowImageSettings(); - ~ShowImageSettings(); - bool Lock(); - bool GetBool(const char* name, bool defaultValue); - int32 GetInt32(const char* name, int32 defaultValue); - float GetFloat(const char* name, float defaultValue); - BRect GetRect(const char* name, BRect defaultValue); - const char* GetString(const char* name, const char* defaultValue); - void SetBool(const char* name, bool value); - void SetInt32(const char* name, int32 value); - void SetFloat(const char* name, float value); - void SetRect(const char* name, BRect value); - void SetString(const char* name, const char* value); - void Unlock(); +class ShowImageSettings { +public: + ShowImageSettings(); + ~ShowImageSettings(); + + bool Lock(); + bool GetBool(const char* name, bool defaultValue); + int32 GetInt32(const char* name, int32 defaultValue); + float GetFloat(const char* name, float defaultValue); + BRect GetRect(const char* name, BRect defaultValue); + const char* GetString(const char* name, const char* defaultValue); + void SetBool(const char* name, bool value); + void SetInt32(const char* name, int32 value); + void SetFloat(const char* name, float value); + void SetRect(const char* name, BRect value); + void SetString(const char* name, const char* value); + void Unlock(); private: - bool OpenSettingsFile(BFile* file, bool forReading); - void Load(); - void Save(); + bool OpenSettingsFile(BFile* file, bool forReading); + void Load(); + void Save(); - BLocker fLock; - BMessage fSettings; + BLocker fLock; + BMessage fSettings; }; -#endif + +#endif // SHOW_IMAGE_SETTINGS_H diff --git a/src/apps/showimage/ShowImageStatusView.cpp b/src/apps/showimage/ShowImageStatusView.cpp index f9ff3ddd0f..b16f8621a9 100644 --- a/src/apps/showimage/ShowImageStatusView.cpp +++ b/src/apps/showimage/ShowImageStatusView.cpp @@ -1,44 +1,27 @@ -/*****************************************************************************/ -// ShowImageStatusView -// Written by Fernando Francisco de Oliveira, Michael Wilber -// -// ShowImageStatusView.cpp -// -// -// Copyright (c) 2003 OpenBeOS Project -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ +/* + * Copyright 2003-2009 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fernando Francisco de Oliveira + * Michael Wilber + */ #include "ShowImageStatusView.h" -#include "ShowImageView.h" -#include "ShowImageWindow.h" #include #include #include #include +#include "ShowImageView.h" +#include "ShowImageWindow.h" + ShowImageStatusView::ShowImageStatusView(BRect rect, const char* name, uint32 resizingMode, uint32 flags) - : BView(rect, name, resizingMode, flags) + : + BView(rect, name, resizingMode, flags) { SetViewColor(B_TRANSPARENT_32_BIT); SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); @@ -76,7 +59,7 @@ ShowImageStatusView::Draw(BRect updateRect) b.InsetBy(1.0, 1.0); - // truncate and layout text + // Truncate and layout text BString truncated(fText); BFont font; GetFont(&font); @@ -87,8 +70,7 @@ ShowImageStatusView::Draw(BRect updateRect) FillRect(b, B_SOLID_LOW); SetDrawingMode(B_OP_OVER); DrawString(truncated.String(), BPoint(b.left + 2.0, - floorf(b.top + b.Height() / 2.0 - + fh.ascent / 2.0))); + floorf(b.top + b.Height() / 2.0 + fh.ascent / 2.0))); } diff --git a/src/apps/showimage/ShowImageStatusView.h b/src/apps/showimage/ShowImageStatusView.h index 4dfa87424a..e1ca3b630c 100644 --- a/src/apps/showimage/ShowImageStatusView.h +++ b/src/apps/showimage/ShowImageStatusView.h @@ -1,50 +1,31 @@ -/*****************************************************************************/ -// ShowImageStatusView -// Written by Fernando Francisco de Oliveira, Michael Wilber -// -// ShowImageStatusView.h -// -// -// Copyright (c) 2003 OpenBeOS Project -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ +/* + * Copyright 2003-2009 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Fernando Francisco de Oliveira + * Michael Wilber + */ +#ifndef SHOW_IMAGE_STATUS_VIEW_H +#define SHOW_IMAGE_STATUS_VIEW_H -#ifndef _ShowImageStatusView_h -#define _ShowImageStatusView_h -#include #include +#include + class ShowImageStatusView : public BView { public: - ShowImageStatusView(BRect rect, const char *name, uint32 resizingMode, - uint32 flags); + ShowImageStatusView(BRect rect, const char *name, + uint32 resizingMode, uint32 flags); - virtual void Draw(BRect updateRect); - - virtual void MouseDown(BPoint where); - - void SetText(BString &text); + virtual void Draw(BRect updateRect); + virtual void MouseDown(BPoint where); + void SetText(BString &text); private: - BString fText; + BString fText; }; -#endif /* _ShowImageStatusView_h */ + +#endif // SHOW_IMAGE_STATUS_VIEW_H diff --git a/src/apps/showimage/ShowImageUndo.cpp b/src/apps/showimage/ShowImageUndo.cpp index 337c0c78ab..31a9073a68 100644 --- a/src/apps/showimage/ShowImageUndo.cpp +++ b/src/apps/showimage/ShowImageUndo.cpp @@ -1,49 +1,33 @@ -/*****************************************************************************/ -// ShowImageUndo -// Written by Michael Wilber -// -// ShowImageUndo.cpp -// -// -// Copyright (c) 2003 OpenBeOS Project -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ +/* + * Copyright 2003-2009 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Michael Wilber + */ #include "ShowImageUndo.h" #include #include + ShowImageUndo::ShowImageUndo() + : + fWindow(NULL), + fUndoType(0), + fRestore(NULL), + fSelection(NULL) { - fWindow = NULL; - fUndoType = 0; - fRestore = NULL; - fSelection = NULL; } + ShowImageUndo::~ShowImageUndo() { InternalClear(); } + void ShowImageUndo::InternalClear() { @@ -54,6 +38,7 @@ ShowImageUndo::InternalClear() fSelection = NULL; } + void ShowImageUndo::Clear() { @@ -61,12 +46,14 @@ ShowImageUndo::Clear() SendUndoStateMessage(false); } + void ShowImageUndo::SendUndoStateMessage(bool bCanUndo) { if (fWindow) { if (!fWindow->IsLocked()) { - fprintf(stderr, "ShowImageUndo::SendUndoStateMessage: window must be locked!"); + fprintf(stderr, + "ShowImageUndo::SendUndoStateMessage: window must be locked!"); exit(-1); } BMessage msg(MSG_UNDO_STATE); @@ -75,6 +62,7 @@ ShowImageUndo::SendUndoStateMessage(bool bCanUndo) } } + void ShowImageUndo::SetTo(BRect rect, BBitmap *restore, BBitmap *selection) { @@ -89,6 +77,7 @@ ShowImageUndo::SetTo(BRect rect, BBitmap *restore, BBitmap *selection) SendUndoStateMessage(true); } + void ShowImageUndo::Undo(BRect rect, BBitmap *restore, BBitmap *selection) { diff --git a/src/apps/showimage/ShowImageUndo.h b/src/apps/showimage/ShowImageUndo.h index d5bf046998..7cfc8d8159 100644 --- a/src/apps/showimage/ShowImageUndo.h +++ b/src/apps/showimage/ShowImageUndo.h @@ -1,79 +1,63 @@ -/*****************************************************************************/ -// ShowImageUndo -// Written by Michael Wilber -// -// ShowImageUndo.h -// -// -// Copyright (c) 2003 OpenBeOS Project -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -/*****************************************************************************/ +/* + * Copyright 2003-2009 Haiku Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Michael Wilber + */ +#ifndef SHOW_IMAGE_UNDO_H +#define SHOW_IMAGE_UNDO_H -#ifndef _ShowImageUndo_h -#define _ShowImageUndo_h -#include #include -#include #include #include +#include +#include + #include "ShowImageConstants.h" + // for Undo #define UNDO_UNDO 1 #define UNDO_REDO 2 + class ShowImageUndo { public: - ShowImageUndo(); - ~ShowImageUndo(); + ShowImageUndo(); + ~ShowImageUndo(); - void SetWindow(BWindow *win) { fWindow = win; } + void SetWindow(BWindow* win) { fWindow = win; } - void Clear(); + void Clear(); // NOTE: THESE TWO FUNCTIONS DO NOT MAKE COPIES OF THE // BITMAPS PASSED TO THEM - void SetTo(BRect rect, BBitmap *restore, BBitmap *selection); - void Undo(BRect rect, BBitmap *restore, BBitmap *selection); + void SetTo(BRect rect, BBitmap* restore, BBitmap* selection); + void Undo(BRect rect, BBitmap* restore, BBitmap* selection); - int32 GetType() { return fUndoType; } - BRect GetRect() { return fRect; } - BBitmap *GetRestoreBitmap() { return fRestore; } - BBitmap *GetSelectionBitmap() { return fSelection; } + int32 GetType() { return fUndoType; } + BRect GetRect() { return fRect; } + BBitmap* GetRestoreBitmap() { return fRestore; } + BBitmap* GetSelectionBitmap() { return fSelection; } private: - void InternalClear(); - void SendUndoStateMessage(bool bCanUndo); + void InternalClear(); + void SendUndoStateMessage(bool bCanUndo); - BWindow *fWindow; + BWindow* fWindow; // Window to which notification messages are sent - int32 fUndoType; + int32 fUndoType; // Nothing, Undo or Redo - BRect fRect; + BRect fRect; // Area of background bitmap where change took place - BBitmap *fRestore; + BBitmap* fRestore; // Changed portion of background bitmap, before change took place - BBitmap *fSelection; + BBitmap* fSelection; // Selection present before change took place }; -#endif /* _ShowImageUndo_h */ + +#endif // SHOW_IMAGE_UNDO_H