* Style cleanups.

* Removed former dead print-screen code.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31797 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-07-27 10:50:53 +00:00
parent e5a19b2505
commit f09d0bff87

View File

@ -1,5 +1,5 @@
/*
* Copyright 2001-2008, Haiku.
* Copyright 2001-2009, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@ -63,6 +63,7 @@
void do_minimize_team(BRect zoomRect, team_id team, bool zoom);
struct BWindow::unpack_cookie {
unpack_cookie();
@ -77,9 +78,10 @@ struct BWindow::unpack_cookie {
class BWindow::Shortcut {
public:
Shortcut(uint32 key, uint32 modifiers, BMenuItem* item);
Shortcut(uint32 key, uint32 modifiers, BMessage* message,
BHandler* target);
Shortcut(uint32 key, uint32 modifiers,
BMenuItem* item);
Shortcut(uint32 key, uint32 modifiers,
BMessage* message, BHandler* target);
~Shortcut();
bool Matches(uint32 key, uint32 modifiers) const;
@ -350,8 +352,7 @@ BWindow::BWindow(BMessage* data)
int32 i = 0;
while (data->FindMessage("_views", i++, &msg) == B_OK) {
BArchivable* obj = instantiate_object(&msg);
BView *child = dynamic_cast<BView *>(obj);
if (child)
if (BView* child = dynamic_cast<BView*>(obj))
AddChild(child);
}
}
@ -1030,10 +1031,10 @@ FrameMoved(origin);
{
if (!_HandleKeyDown(msg)) {
if (BView* view = dynamic_cast<BView*>(target)) {
// TODO: cannot use "string" here if we support having different
// font encoding per view (it's supposed to be converted by
// _HandleKeyDown() one day)
const char *string = NULL;
// TODO: cannot use "string" here if we support having
// different font encoding per view (it's supposed to be
// converted by _HandleKeyDown() one day)
const char* string;
if (msg->FindString("bytes", &string) == B_OK)
view->KeyDown(string, strlen(string));
} else
@ -1095,7 +1096,6 @@ FrameMoved(origin);
case B_MOUSE_MOVED:
{
if (BView* view = dynamic_cast<BView*>(target)) {
uint32 eventOptions = view->fEventOptions
| view->fMouseEventOptions;
bool noHistory = eventOptions & B_NO_POINTER_HISTORY;
@ -1129,7 +1129,8 @@ FrameMoved(origin);
queue->Lock();
BMessage* moved;
for (int32 i = 0; (moved = queue->FindMessage(i)) != NULL; i++) {
for (int32 i = 0; (moved = queue->FindMessage(i)) != NULL;
i++) {
if (moved != msg && moved->what == B_MOUSE_MOVED) {
// there is a newer mouse moved message in the
// queue, just ignore the current one, the newer one
@ -1149,7 +1150,8 @@ FrameMoved(origin);
BMessage* dragMessage = NULL;
if (msg->HasMessage("be:drag_message")) {
dragMessage = new BMessage();
if (msg->FindMessage("be:drag_message", dragMessage) != B_OK) {
if (msg->FindMessage("be:drag_message", dragMessage)
!= B_OK) {
delete dragMessage;
dragMessage = NULL;
}
@ -1410,14 +1412,18 @@ BWindow::SetSizeLimits(float minWidth, float maxWidth,
void
BWindow::GetSizeLimits(float *minWidth, float *maxWidth,
float *minHeight, float *maxHeight)
BWindow::GetSizeLimits(float* _minWidth, float* _maxWidth, float* _minHeight,
float* _maxHeight)
{
// TODO: What about locking?!?
*minHeight = fMinHeight;
*minWidth = fMinWidth;
*maxHeight = fMaxHeight;
*maxWidth = fMaxWidth;
if (_minHeight != NULL)
*_minHeight = fMinHeight;
if (_minWidth != NULL)
*_minWidth = fMinWidth;
if (_maxHeight != NULL)
*_maxHeight = fMaxHeight;
if (_maxWidth != NULL)
*_maxWidth = fMaxWidth;
}
@ -1430,28 +1436,27 @@ BWindow::SetDecoratorSettings(const BMessage& settings)
int32 size = settings.FlattenedSize();
char buffer[size];
status_t ret = settings.Flatten(buffer, size);
if (ret < B_OK)
return ret;
status_t status = settings.Flatten(buffer, size);
if (status != B_OK)
return status;
if (!Lock())
return B_ERROR;
ret = fLink->StartMessage(AS_SET_DECORATOR_SETTINGS);
status = fLink->StartMessage(AS_SET_DECORATOR_SETTINGS);
if (ret == B_OK)
ret = fLink->Attach<int32>(size);
if (status == B_OK)
status = fLink->Attach<int32>(size);
if (ret == B_OK)
ret = fLink->Attach(buffer, size);
if (status == B_OK)
status = fLink->Attach(buffer, size);
if (ret == B_OK)
ret = fLink->Flush();
if (status == B_OK)
status = fLink->Flush();
Unlock();
return ret;
return status;
}
@ -1464,30 +1469,30 @@ BWindow::GetDecoratorSettings(BMessage* settings) const
if (!const_cast<BWindow*>(this)->Lock())
return B_ERROR;
status_t ret = fLink->StartMessage(AS_GET_DECORATOR_SETTINGS);
status_t status = fLink->StartMessage(AS_GET_DECORATOR_SETTINGS);
if (ret == B_OK) {
if (status == B_OK) {
int32 code;
ret = fLink->FlushWithReply(code);
if (ret == B_OK && code != B_OK)
ret = code;
status = fLink->FlushWithReply(code);
if (status == B_OK && code != B_OK)
status = code;
}
if (ret == B_OK) {
if (status == B_OK) {
int32 size;
ret = fLink->Read<int32>(&size);
if (ret == B_OK) {
status = fLink->Read<int32>(&size);
if (status == B_OK) {
char buffer[size];
ret = fLink->Read(buffer, size);
if (ret == B_OK) {
ret = settings->Unflatten(buffer);
status = fLink->Read(buffer, size);
if (status == B_OK) {
status = settings->Unflatten(buffer);
}
}
}
const_cast<BWindow*>(this)->Unlock();
return ret;
return status;
}
@ -1521,17 +1526,10 @@ void
BWindow::Zoom()
{
// TODO: What about locking?!?
/*
from BeBook:
However, if the window's rectangle already matches these "zoom" dimensions
(give or take a few pixels), Zoom() passes the window's previous
("non-zoomed") size and location. (??????)
*/
/* From BeBook:
The dimensions that non-virtual Zoom() passes to hook Zoom() are deduced from
the smallest of three rectangles:
*/
// From BeBook:
// The dimensions that non-virtual Zoom() passes to hook Zoom() are deduced
// from the smallest of three rectangles:
float borderWidth;
float tabHeight;
@ -1560,18 +1558,20 @@ BWindow::Zoom()
BPoint zoomedLeftTop = screen.Frame().LeftTop() + BPoint(borderWidth,
tabHeight + borderWidth);
// UN-ZOOM:
// Un-Zoom
if (fPreviousFrame.IsValid()
// NOTE: don't check for fFrame.LeftTop() == zoomedLeftTop
// -> makes it easier on the user to get a window back into place
&& fFrame.Width() == zoomedWidth
&& fFrame.Height() == zoomedHeight) {
// already zoomed!
Zoom(fPreviousFrame.LeftTop(), fPreviousFrame.Width(), fPreviousFrame.Height());
Zoom(fPreviousFrame.LeftTop(), fPreviousFrame.Width(),
fPreviousFrame.Height());
return;
}
// ZOOM:
// Zoom
// remember fFrame for later "unzooming"
fPreviousFrame = fFrame;
@ -1591,7 +1591,8 @@ void
BWindow::SetPulseRate(bigtime_t rate)
{
// TODO: What about locking?!?
if (rate < 0 || (rate == fPulseRate && !((rate == 0) ^ (fPulseRunner == NULL))))
if (rate < 0
|| (rate == fPulseRate && !((rate == 0) ^ (fPulseRunner == NULL))))
return;
fPulseRate = rate;
@ -2478,7 +2479,8 @@ BWindow::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier,
} else {
BMessage replyMsg(B_MESSAGE_NOT_UNDERSTOOD);
replyMsg.AddInt32("error", B_NAME_NOT_FOUND);
replyMsg.AddString("message", "This window doesn't have a main MenuBar");
replyMsg.AddString("message",
"This window doesn't have a main MenuBar");
msg->SendReply(&replyMsg);
return NULL;
}
@ -2500,7 +2502,8 @@ BWindow::_InitData(BRect frame, const char* title, window_look look,
STRACE(("BWindow::InitData()\n"));
if (be_app == NULL) {
debugger("You need a valid BApplication object before interacting with the app_server");
debugger("You need a valid BApplication object before interacting with "
"the app_server");
return;
}
@ -3388,7 +3391,6 @@ BWindow::_HandleKeyDown(BMessage* event)
// Check for Print Screen
int32 rawKey;
if (event->FindInt32("key", &rawKey) == B_OK && rawKey == B_PRINT_KEY) {
#ifdef __HAIKU__
BMessage message(B_REFS_RECEIVED);
message.AddBool("silent", true);
@ -3400,41 +3402,6 @@ BWindow::_HandleKeyDown(BMessage* event)
be_roster->Launch("application/x-vnd.haiku-screenshot", &message);
return true;
#else
// Get filename
BPath homePath;
if (find_directory(B_USER_DIRECTORY, &homePath) != B_OK) {
fprintf(stderr, "failed to find user home directory\n");
return true;
}
BPath path;
BEntry entry;
int32 index = 1;
do {
char filename[32];
sprintf(filename, "screen%ld.png", index++);
path = homePath;
path.Append(filename);
entry.SetTo(path.Path());
} while (entry.Exists());
// Get the screen bitmap
BScreen screen(this);
BBitmap* screenDump;
screen.GetBitmap(&screenDump, false);
// Dump to PNG
SaveToPNG(path.Path(), screen.Frame(), screenDump->ColorSpace(),
screenDump->Bits(),
screenDump->BitsLength(),
screenDump->BytesPerRow());
// Free the bitmap allocated by BScreen.GetBitmap
delete screenDump;
#endif
return true;
}
}