2 * Copyright 2010 Wim van der Meer <WPJvanderMeer@gmail.com>
3 * All rights reserved. Distributed under the terms of the MIT license.
10 #include "ScreenshotApp.h"
19 #include "ScreenshotWindow.h"
23 ScreenshotApp::ScreenshotApp()
25 BApplication("application/x-vnd.haiku-screenshot"),
26 fUtility(new Utility
),
33 ScreenshotApp::~ScreenshotApp()
40 ScreenshotApp::MessageReceived(BMessage
* message
)
42 status_t status
= B_OK
;
43 switch (message
->what
) {
47 status
= message
->FindMessage("wholeScreen", &bitmap
);
51 fUtility
->wholeScreen
= new BBitmap(&bitmap
);
53 status
= message
->FindMessage("cursorBitmap", &bitmap
);
57 fUtility
->cursorBitmap
= new BBitmap(&bitmap
);
59 status
= message
->FindMessage("cursorAreaBitmap", &bitmap
);
63 fUtility
->cursorAreaBitmap
= new BBitmap(&bitmap
);
65 status
= message
->FindPoint("cursorPosition",
66 &fUtility
->cursorPosition
);
70 status
= message
->FindRect("activeWindowFrame",
71 &fUtility
->activeWindowFrame
);
75 status
= message
->FindRect("tabFrame", &fUtility
->tabFrame
);
79 status
= message
->FindFloat("borderSize", &fUtility
->borderSize
);
87 BApplication::MessageReceived(message
);
92 be_app
->PostMessage(B_QUIT_REQUESTED
);
97 ScreenshotApp::ArgvReceived(int32 argc
, char** argv
)
99 for (int32 i
= 0; i
< argc
; i
++) {
100 if (strcmp(argv
[i
], "-s") == 0
101 || strcmp(argv
[i
], "--silent") == 0)
103 else if (strcmp(argv
[i
], "-c") == 0
104 || strcmp(argv
[i
], "--clipboard") == 0)
111 ScreenshotApp::ReadyToRun()
113 new ScreenshotWindow(*fUtility
, fSilent
, fClipboard
);