1 /* 2 * Copyright Karsten Heimrich, host.haiku@gmx.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Karsten Heimrich 7 * Fredrik Modéen 8 */ 9 #ifndef SCREENSHOT_WINDOW_H 10 #define SCREENSHOT_WINDOW_H 11 12 13 #include <String.h> 14 #include <Window.h> 15 #include <TranslationDefs.h> 16 #include <TranslatorFormats.h> 17 18 19 class BBitmap; 20 class BButton; 21 class BCardLayout; 22 class BCheckBox; 23 class BFilePanel; 24 class BMenu; 25 class BRadioButton; 26 class BTextControl; 27 class BTextView; 28 class BPath; 29 class PreviewView; 30 31 32 class ScreenshotWindow : public BWindow { 33 public: 34 ScreenshotWindow(bigtime_t delay = 0, 35 bool includeBorder = false, 36 bool includeMouse = false, 37 bool grabActiveWindow = false, 38 bool showConfigWindow = false, 39 bool saveScreenshotSilent = false, 40 int32 imageFileType = B_PNG_FORMAT, 41 const char* outputFilename = NULL); 42 virtual ~ScreenshotWindow(); 43 44 virtual void MessageReceived(BMessage* message); 45 46 private: 47 void _InitWindow(); 48 BPath _GetDirectory(); 49 void _SetupFirstLayoutItem(BCardLayout* layout); 50 void _SetupSecondLayoutItem(BCardLayout* layout); 51 void _DisallowChar(BTextView* textView); 52 void _SetupTranslatorMenu(BMenu* translatorMenu, 53 const BMessage& settings); 54 void _SetupOutputPathMenu(BMenu* outputPathMenu, 55 const BMessage& settings); 56 void _AddItemToPathMenu(const char* path, 57 BString& label, int32 index, bool markItem); 58 59 void _UpdatePreviewPanel(); 60 void _UpdateFilenameSelection(); 61 BString _FindValidFileName(const char* name); 62 int32 _PathIndexInMenu(const BString& path) const; 63 64 BMessage _ReadSettings() const; 65 void _WriteSettings() const; 66 67 void _TakeScreenshot(); 68 status_t _GetActiveWindowFrame(BRect* frame); 69 void _MakeTabSpaceTransparent(BRect* frame); 70 71 status_t _SaveScreenshot(); 72 73 status_t _FindTranslator(uint32 imageType, translator_id* id); 74 75 PreviewView* fPreview; 76 BRadioButton* fActiveWindow; 77 BRadioButton* fWholeDesktop; 78 BTextControl* fDelayControl; 79 BCheckBox* fWindowBorder; 80 BCheckBox* fShowMouse; 81 BButton* fBackToSave; 82 BButton* fTakeScreenshot; 83 BButton* fSaveScreenshot; 84 BTextControl* fNameControl; 85 BMenu* fTranslatorMenu; 86 BMenu* fOutputPathMenu; 87 BBitmap* fScreenshot; 88 BFilePanel* fOutputPathPanel; 89 BMenuItem* fLastSelectedPath; 90 91 bigtime_t fDelay; 92 float fTabHeight; 93 94 bool fIncludeBorder; 95 bool fIncludeMouse; 96 bool fGrabActiveWindow; 97 bool fShowConfigWindow; 98 bool fSaveScreenshotSilent; 99 BString fOutputFilename; 100 BString fExtension; 101 102 int32 fImageFileType; 103 }; 104 105 #endif /* SCREENSHOT_WINDOW_H */ 106