diff --git a/src/apps/screenshot/Jamfile b/src/apps/screenshot/Jamfile index 1cc320f971..8f69a08c8e 100644 --- a/src/apps/screenshot/Jamfile +++ b/src/apps/screenshot/Jamfile @@ -6,6 +6,7 @@ UsePrivateHeaders interface ; Application Screenshot : main.cpp PNGDump.cpp + PreviewView.cpp Screenshot.cpp ScreenshotWindow.cpp : be tracker translation libpng.so libz.so diff --git a/src/apps/screenshot/PreviewView.cpp b/src/apps/screenshot/PreviewView.cpp new file mode 100644 index 0000000000..59a4201410 --- /dev/null +++ b/src/apps/screenshot/PreviewView.cpp @@ -0,0 +1,27 @@ +/* + * Copyright 2009, Philippe Saint-Pierre, stpere@gmail.com + * Distributed under the terms of the MIT License. + */ + +#include "PreviewView.h" +#include + + +PreviewView::PreviewView() + : BView("preview", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE) +{ +} + + +PreviewView::~PreviewView() +{ +} + + +void +PreviewView::Draw(BRect updateRect) +{ + BRect rect = Frame(); + be_control_look->DrawTextControlBorder(this, rect, rect, + ui_color(B_PANEL_BACKGROUND_COLOR)); +} diff --git a/src/apps/screenshot/PreviewView.h b/src/apps/screenshot/PreviewView.h new file mode 100644 index 0000000000..0a922c72d7 --- /dev/null +++ b/src/apps/screenshot/PreviewView.h @@ -0,0 +1,22 @@ +/* + * Copyright 2009, Philippe Saint-Pierre, stpere@gmail.com + * Distributed under the terms of the MIT License. + */ + +#ifndef PREVIEW_VIEW_H +#define PREVIEW_VIEW_H + + +#include + + +class PreviewView : public BView { +public: + PreviewView(); + ~PreviewView(); + +protected: + virtual void Draw(BRect updateRect); +}; + +#endif /* PREVIEW_VIEW_H */ diff --git a/src/apps/screenshot/ScreenshotWindow.cpp b/src/apps/screenshot/ScreenshotWindow.cpp index 9c7e5be0f6..4845ba4c41 100644 --- a/src/apps/screenshot/ScreenshotWindow.cpp +++ b/src/apps/screenshot/ScreenshotWindow.cpp @@ -7,7 +7,6 @@ #include "PNGDump.h" - #include #include #include @@ -324,9 +323,7 @@ ScreenshotWindow::_SetupFirstLayoutItem(BCardLayout* layout) void ScreenshotWindow::_SetupSecondLayoutItem(BCardLayout* layout) { - fPreviewBox = new BBox(BRect(0.0, 0.0, 200.0, 150.0)); - fPreviewBox->SetExplicitMinSize(BSize(200.0, B_SIZE_UNSET)); - fPreviewBox->SetFlags(fPreviewBox->Flags() | B_FULL_UPDATE_ON_RESIZE); + fPreview = new PreviewView(); fNameControl = new BTextControl("", "Name:", "screenshot1", NULL); @@ -354,7 +351,7 @@ ScreenshotWindow::_SetupSecondLayoutItem(BCardLayout* layout) layout->AddView(1, BGroupLayoutBuilder(B_VERTICAL) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10.0) - .Add(fPreviewBox) + .Add(fPreview) .AddGroup(B_VERTICAL) .Add(gridLayout->View()) .AddGlue() @@ -514,13 +511,13 @@ ScreenshotWindow::_UpdatePreviewPanel() fScreenshot->Bounds().Width()) * width; } - fPreviewBox->SetExplicitMinSize(BSize(width, height)); - fPreviewBox->SetExplicitMaxSize(BSize(width, height)); - - fPreviewBox->ClearViewBitmap(); - fPreviewBox->SetViewBitmap(fScreenshot, fScreenshot->Bounds(), - fPreviewBox->Bounds(), B_FOLLOW_ALL, 0); + fPreview->SetExplicitMinSize(BSize(width, height)); + fPreview->SetExplicitMaxSize(BSize(width, height)); + fPreview->ClearViewBitmap(); + fPreview->SetViewBitmap(fScreenshot, fScreenshot->Bounds(), + fPreview->Bounds(), B_FOLLOW_ALL, 0); + BCardLayout* layout = dynamic_cast (GetLayout()); if (layout) layout->SetVisibleItem(1L); diff --git a/src/apps/screenshot/ScreenshotWindow.h b/src/apps/screenshot/ScreenshotWindow.h index eed6585d37..98e6449c18 100644 --- a/src/apps/screenshot/ScreenshotWindow.h +++ b/src/apps/screenshot/ScreenshotWindow.h @@ -5,6 +5,7 @@ #include #include +#include "PreviewView.h" class BBitmap; class BBox; @@ -57,7 +58,7 @@ private: void _SaveScreenshotSilent() const; private: - BBox* fPreviewBox; + PreviewView* fPreview; BRadioButton* fActiveWindow; BRadioButton* fWholeDesktop; BTextControl* fDelayControl;