1cdb89ebbSMatthew Wilber /*****************************************************************************/ 2cdb89ebbSMatthew Wilber // ShowImageWindow 3ad13f387SMichael Pfeiffer // Written by Fernando Francisco de Oliveira, Michael Wilber, Michael Pfeiffer 4cdb89ebbSMatthew Wilber // 5cdb89ebbSMatthew Wilber // ShowImageWindow.cpp 6cdb89ebbSMatthew Wilber // 7cdb89ebbSMatthew Wilber // 8cdb89ebbSMatthew Wilber // Copyright (c) 2003 OpenBeOS Project 9cdb89ebbSMatthew Wilber // 10cdb89ebbSMatthew Wilber // Permission is hereby granted, free of charge, to any person obtaining a 11cdb89ebbSMatthew Wilber // copy of this software and associated documentation files (the "Software"), 12cdb89ebbSMatthew Wilber // to deal in the Software without restriction, including without limitation 13cdb89ebbSMatthew Wilber // the rights to use, copy, modify, merge, publish, distribute, sublicense, 14cdb89ebbSMatthew Wilber // and/or sell copies of the Software, and to permit persons to whom the 15cdb89ebbSMatthew Wilber // Software is furnished to do so, subject to the following conditions: 16cdb89ebbSMatthew Wilber // 17cdb89ebbSMatthew Wilber // The above copyright notice and this permission notice shall be included 18cdb89ebbSMatthew Wilber // in all copies or substantial portions of the Software. 19cdb89ebbSMatthew Wilber // 20cdb89ebbSMatthew Wilber // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21cdb89ebbSMatthew Wilber // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22cdb89ebbSMatthew Wilber // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23cdb89ebbSMatthew Wilber // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24cdb89ebbSMatthew Wilber // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25cdb89ebbSMatthew Wilber // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26cdb89ebbSMatthew Wilber // DEALINGS IN THE SOFTWARE. 27cdb89ebbSMatthew Wilber /*****************************************************************************/ 2813afa642SPhil Greenway 2913afa642SPhil Greenway #include <algobase.h> 3007caaa8eSMatthew Wilber #include <stdio.h> 3113afa642SPhil Greenway #include <Application.h> 3213afa642SPhil Greenway #include <Bitmap.h> 33fc0a275bSMatthew Wilber #include <BitmapStream.h> 3413afa642SPhil Greenway #include <Entry.h> 35fc0a275bSMatthew Wilber #include <File.h> 3613afa642SPhil Greenway #include <Menu.h> 3713afa642SPhil Greenway #include <MenuBar.h> 3813afa642SPhil Greenway #include <MenuItem.h> 3913afa642SPhil Greenway #include <Path.h> 4013afa642SPhil Greenway #include <ScrollView.h> 4113afa642SPhil Greenway #include <TranslationUtils.h> 4213afa642SPhil Greenway #include <TranslatorRoster.h> 4313afa642SPhil Greenway #include <Alert.h> 4407caaa8eSMatthew Wilber #include <SupportDefs.h> 45ad13f387SMichael Pfeiffer #include <Screen.h> 46d10d5947SMichael Pfeiffer #include <Roster.h> 4713afa642SPhil Greenway 4813afa642SPhil Greenway #include "ShowImageConstants.h" 4913afa642SPhil Greenway #include "ShowImageWindow.h" 5013afa642SPhil Greenway #include "ShowImageView.h" 5113afa642SPhil Greenway #include "ShowImageStatusView.h" 5213afa642SPhil Greenway 5303839579SMatthew Wilber ShowImageWindow::ShowImageWindow(const entry_ref *pref) 54cdb89ebbSMatthew Wilber : BWindow(BRect(50, 50, 350, 250), "", B_DOCUMENT_WINDOW, 0) 5513afa642SPhil Greenway { 567eca0987SMichael Pfeiffer fpSavePanel = NULL; 57ad13f387SMichael Pfeiffer fFullScreen = false; 58e6a50d9cSMichael Pfeiffer fShowCaption = true; // XXX what is best for default? 59fc0a275bSMatthew Wilber 6013afa642SPhil Greenway // create menu bar 617eca0987SMichael Pfeiffer fpBar = new BMenuBar(BRect(0, 0, Bounds().right, 20), "menu_bar"); 627eca0987SMichael Pfeiffer LoadMenus(fpBar); 637eca0987SMichael Pfeiffer AddChild(fpBar); 6413afa642SPhil Greenway 6513afa642SPhil Greenway BRect viewFrame = Bounds(); 667eca0987SMichael Pfeiffer viewFrame.top = fpBar->Bounds().bottom + 1; 6713afa642SPhil Greenway viewFrame.right -= B_V_SCROLL_BAR_WIDTH; 6813afa642SPhil Greenway viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT; 6913afa642SPhil Greenway 7013afa642SPhil Greenway // create the image view 717eca0987SMichael Pfeiffer fpImageView = new ShowImageView(viewFrame, "image_view", B_FOLLOW_ALL, 727eca0987SMichael Pfeiffer B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED); 7313afa642SPhil Greenway // wrap a scroll view around the view 747eca0987SMichael Pfeiffer BScrollView *pscrollView = new BScrollView("image_scroller", fpImageView, 75cdb89ebbSMatthew Wilber B_FOLLOW_ALL, 0, false, false, B_PLAIN_BORDER); 76cdb89ebbSMatthew Wilber AddChild(pscrollView); 7713afa642SPhil Greenway 7807caaa8eSMatthew Wilber const int32 kstatusWidth = 190; 79cdb89ebbSMatthew Wilber BRect rect; 8013afa642SPhil Greenway rect = Bounds(); 8113afa642SPhil Greenway rect.top = viewFrame.bottom + 1; 8207caaa8eSMatthew Wilber rect.left = viewFrame.left + kstatusWidth; 8313afa642SPhil Greenway rect.right = viewFrame.right; 84cdb89ebbSMatthew Wilber BScrollBar *phscroll; 857eca0987SMichael Pfeiffer phscroll = new BScrollBar(rect, "hscroll", fpImageView, 0, 150, 86cdb89ebbSMatthew Wilber B_HORIZONTAL); 87cdb89ebbSMatthew Wilber AddChild(phscroll); 8813afa642SPhil Greenway 8913afa642SPhil Greenway rect.left = 0; 9007caaa8eSMatthew Wilber rect.right = kstatusWidth - 1; 917eca0987SMichael Pfeiffer fpStatusView = new ShowImageStatusView(rect, "status_view", B_FOLLOW_BOTTOM, 92cdb89ebbSMatthew Wilber B_WILL_DRAW); 937eca0987SMichael Pfeiffer fpStatusView->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR)); 947eca0987SMichael Pfeiffer AddChild(fpStatusView); 9513afa642SPhil Greenway 9613afa642SPhil Greenway rect = Bounds(); 9713afa642SPhil Greenway rect.top = viewFrame.top; 9813afa642SPhil Greenway rect.left = viewFrame.right + 1; 9913afa642SPhil Greenway rect.bottom = viewFrame.bottom; 100cdb89ebbSMatthew Wilber BScrollBar *pvscroll; 1017eca0987SMichael Pfeiffer pvscroll = new BScrollBar(rect, "vscroll", fpImageView, 0, 150, B_VERTICAL); 102cdb89ebbSMatthew Wilber AddChild(pvscroll); 10313afa642SPhil Greenway 10403839579SMatthew Wilber SetSizeLimits(250, 100000, 100, 100000); 10513afa642SPhil Greenway 10613afa642SPhil Greenway // finish creating window 10713afa642SPhil Greenway UpdateTitle(); 10813afa642SPhil Greenway 1097eca0987SMichael Pfeiffer fpImageView->SetImage(pref); 1107eca0987SMichael Pfeiffer 1117eca0987SMichael Pfeiffer SetPulseRate(100000); // every 1/10 second; ShowImageView needs it for marching ants 11203839579SMatthew Wilber 113d10d5947SMichael Pfeiffer if (InitCheck() == B_OK) { 114d10d5947SMichael Pfeiffer fpImageView->FlushToLeftTop(); 115d10d5947SMichael Pfeiffer WindowRedimension(fpImageView->GetBitmap()); 11613afa642SPhil Greenway Show(); 117d10d5947SMichael Pfeiffer } else { 118e6a50d9cSMichael Pfeiffer BAlert* alert; 119e6a50d9cSMichael Pfeiffer alert = new BAlert("ShowImage", 120e6a50d9cSMichael Pfeiffer "Could not load image! Either the file or an image translator for it does not exist.", 121e6a50d9cSMichael Pfeiffer "OK", NULL, NULL, 122e6a50d9cSMichael Pfeiffer B_WIDTH_AS_USUAL, B_INFO_ALERT); 123e6a50d9cSMichael Pfeiffer alert->Go(); 124d10d5947SMichael Pfeiffer // exit if file could not be opened 125d10d5947SMichael Pfeiffer Quit(); 126d10d5947SMichael Pfeiffer } 12713afa642SPhil Greenway } 12813afa642SPhil Greenway 12913afa642SPhil Greenway ShowImageWindow::~ShowImageWindow() 13013afa642SPhil Greenway { 13113afa642SPhil Greenway } 13213afa642SPhil Greenway 133cdb89ebbSMatthew Wilber status_t 134cdb89ebbSMatthew Wilber ShowImageWindow::InitCheck() 13513afa642SPhil Greenway { 136e6a50d9cSMichael Pfeiffer if (!fpImageView || fpImageView->GetBitmap() == NULL) 13713afa642SPhil Greenway return B_ERROR; 138cdb89ebbSMatthew Wilber else 13913afa642SPhil Greenway return B_OK; 14013afa642SPhil Greenway } 141cdb89ebbSMatthew Wilber 142cdb89ebbSMatthew Wilber void 143cdb89ebbSMatthew Wilber ShowImageWindow::UpdateTitle() 14413afa642SPhil Greenway { 145e6a50d9cSMichael Pfeiffer BString path; 146e6a50d9cSMichael Pfeiffer fpImageView->GetPath(&path); 147e6a50d9cSMichael Pfeiffer SetTitle(path.String()); 14813afa642SPhil Greenway } 14913afa642SPhil Greenway 150cdb89ebbSMatthew Wilber void 151d10d5947SMichael Pfeiffer ShowImageWindow::UpdateRecentDocumentsMenu() 152d10d5947SMichael Pfeiffer { 153d10d5947SMichael Pfeiffer BMenuItem *item; 154d10d5947SMichael Pfeiffer BMessage list, *msg; 155d10d5947SMichael Pfeiffer entry_ref ref; 156d10d5947SMichael Pfeiffer char name[B_FILE_NAME_LENGTH]; 157d10d5947SMichael Pfeiffer 158d10d5947SMichael Pfeiffer while ((item = fpOpenMenu->RemoveItem((int32)0)) != NULL) { 159d10d5947SMichael Pfeiffer delete item; 160d10d5947SMichael Pfeiffer } 161d10d5947SMichael Pfeiffer 162d10d5947SMichael Pfeiffer be_roster->GetRecentDocuments(&list, 20, NULL, APP_SIG); 163d10d5947SMichael Pfeiffer for (int i = 0; list.FindRef("refs", i, &ref) == B_OK; i++) { 164d10d5947SMichael Pfeiffer BEntry entry(&ref); 165d10d5947SMichael Pfeiffer entry.GetName(name); 166d10d5947SMichael Pfeiffer msg = new BMessage(B_REFS_RECEIVED); 167d10d5947SMichael Pfeiffer msg->AddRef("refs", &ref); 168d10d5947SMichael Pfeiffer item = new BMenuItem(name, msg, 0, 0); 169d10d5947SMichael Pfeiffer fpOpenMenu->AddItem(item); 170d10d5947SMichael Pfeiffer item->SetTarget(be_app, NULL); 171d10d5947SMichael Pfeiffer } 172d10d5947SMichael Pfeiffer } 173d10d5947SMichael Pfeiffer 174d10d5947SMichael Pfeiffer void 175cdb89ebbSMatthew Wilber ShowImageWindow::LoadMenus(BMenuBar *pbar) 17613afa642SPhil Greenway { 177cdb89ebbSMatthew Wilber BMenu *pmenu = new BMenu("File"); 178d10d5947SMichael Pfeiffer fpOpenMenu = new BMenu("Open"); 179d10d5947SMichael Pfeiffer pmenu->AddItem(fpOpenMenu); 180d10d5947SMichael Pfeiffer fpOpenMenu->Superitem()->SetTrigger('O'); 181d10d5947SMichael Pfeiffer fpOpenMenu->Superitem()->SetMessage(new BMessage(MSG_FILE_OPEN)); 182d10d5947SMichael Pfeiffer fpOpenMenu->Superitem()->SetTarget(be_app); 183d10d5947SMichael Pfeiffer fpOpenMenu->Superitem()->SetShortcut('O', 0); 184cdb89ebbSMatthew Wilber pmenu->AddSeparatorItem(); 185cdb89ebbSMatthew Wilber BMenu *pmenuSaveAs = new BMenu("Save As...", B_ITEMS_IN_COLUMN); 186cdb89ebbSMatthew Wilber BTranslationUtils::AddTranslationItems(pmenuSaveAs, B_TRANSLATOR_BITMAP); 187fc0a275bSMatthew Wilber // Fill Save As submenu with all types that can be converted 188fc0a275bSMatthew Wilber // to from the Be bitmap image format 189cdb89ebbSMatthew Wilber pmenu->AddItem(pmenuSaveAs); 190cdb89ebbSMatthew Wilber AddItemMenu(pmenu, "Close", MSG_CLOSE, 'W', 0, 'W', true); 191cdb89ebbSMatthew Wilber pmenu->AddSeparatorItem(); 192cdb89ebbSMatthew Wilber AddItemMenu(pmenu, "About ShowImage...", B_ABOUT_REQUESTED, 0, 0, 'A', true); 193cdb89ebbSMatthew Wilber pmenu->AddSeparatorItem(); 194cdb89ebbSMatthew Wilber AddItemMenu(pmenu, "Quit", B_QUIT_REQUESTED, 'Q', 0, 'A', true); 195cdb89ebbSMatthew Wilber pbar->AddItem(pmenu); 19613afa642SPhil Greenway 197cdb89ebbSMatthew Wilber pmenu = new BMenu("Edit"); 198cdb89ebbSMatthew Wilber AddItemMenu(pmenu, "Undo", B_UNDO, 'Z', 0, 'W', false); 199cdb89ebbSMatthew Wilber pmenu->AddSeparatorItem(); 200cdb89ebbSMatthew Wilber AddItemMenu(pmenu, "Cut", B_CUT, 'X', 0, 'W', false); 201d10d5947SMichael Pfeiffer AddItemMenu(pmenu, "Copy", B_COPY, 'C', 0, 'W', true); 202cdb89ebbSMatthew Wilber AddItemMenu(pmenu, "Paste", B_PASTE, 'V', 0, 'W', false); 203d10d5947SMichael Pfeiffer AddItemMenu(pmenu, "Clear", MSG_CLEAR_SELECT, 0, 0, 'W', true); 204cdb89ebbSMatthew Wilber pmenu->AddSeparatorItem(); 205d10d5947SMichael Pfeiffer AddItemMenu(pmenu, "Select All", MSG_SELECT_ALL, 'A', 0, 'W', true); 206cdb89ebbSMatthew Wilber pbar->AddItem(pmenu); 20713afa642SPhil Greenway 208e6a50d9cSMichael Pfeiffer pmenu = fpBrowseMenu = new BMenu("Browse"); 209e6a50d9cSMichael Pfeiffer AddItemMenu(pmenu, "First Page", MSG_PAGE_FIRST, 'F', 0, 'W', true); 210e6a50d9cSMichael Pfeiffer AddItemMenu(pmenu, "Last Page", MSG_PAGE_LAST, 'L', 0, 'W', true); 211e6a50d9cSMichael Pfeiffer AddItemMenu(pmenu, "Next Page", MSG_PAGE_NEXT, 'N', 0, 'W', true); 212e6a50d9cSMichael Pfeiffer AddItemMenu(pmenu, "Previous Page", MSG_PAGE_PREV, 'P', 0, 'W', true); 213*6c305411SMatthew Wilber fpGoToPageMenu = new BMenu("Go To Page"); 214*6c305411SMatthew Wilber pmenu->AddItem(fpGoToPageMenu); 215e6a50d9cSMichael Pfeiffer pmenu->AddSeparatorItem(); 216e6a50d9cSMichael Pfeiffer AddItemMenu(pmenu, "Next File", MSG_FILE_NEXT, B_DOWN_ARROW, 0, 'W', true); 217e6a50d9cSMichael Pfeiffer AddItemMenu(pmenu, "Previous File", MSG_FILE_PREV, B_UP_ARROW, 0, 'W', true); 21803839579SMatthew Wilber pbar->AddItem(pmenu); 21903839579SMatthew Wilber 220cdb89ebbSMatthew Wilber pmenu = new BMenu("Image"); 221cdb89ebbSMatthew Wilber AddItemMenu(pmenu, "Dither Image", MSG_DITHER_IMAGE, 0, 0, 'W', true); 222ad13f387SMichael Pfeiffer pmenu->AddSeparatorItem(); 223ad13f387SMichael Pfeiffer AddItemMenu(pmenu, "Rotate Clockwise", MSG_ROTATE_CLOCKWISE, B_RIGHT_ARROW, 0, 'W', true); 224ad13f387SMichael Pfeiffer AddItemMenu(pmenu, "Rotate Anticlockwise", MSG_ROTATE_ACLKWISE, B_LEFT_ARROW, 0, 'W', true); 225ad13f387SMichael Pfeiffer pmenu->AddSeparatorItem(); 226ad13f387SMichael Pfeiffer AddItemMenu(pmenu, "Mirror Vertical", MSG_MIRROR_VERTICAL, 0, 0, 'W', true); 227ad13f387SMichael Pfeiffer AddItemMenu(pmenu, "Mirror Horizontal", MSG_MIRROR_HORIZONTAL, 0, 0, 'W', true); 228ad13f387SMichael Pfeiffer pmenu->AddSeparatorItem(); 229ad13f387SMichael Pfeiffer AddItemMenu(pmenu, "Invert", MSG_INVERT, 0, 0, 'W', true); 230ad13f387SMichael Pfeiffer pbar->AddItem(pmenu); 231ad13f387SMichael Pfeiffer 232ad13f387SMichael Pfeiffer pmenu = new BMenu("View"); 233e6a50d9cSMichael Pfeiffer AddItemMenu(pmenu, "Slide Show", MSG_SLIDE_SHOW, 0, 0, 'W', true); 234e6a50d9cSMichael Pfeiffer BMenu* pDelay = new BMenu("Slide Delay"); 235e6a50d9cSMichael Pfeiffer pDelay->SetRadioMode(true); 236e6a50d9cSMichael Pfeiffer // Note: ShowImage loades images in window thread so it becomes unresponsive if 237e6a50d9cSMichael Pfeiffer // slide show delay is too short! (Especially if loading the image takes as long as 238e6a50d9cSMichael Pfeiffer // or longer than the slide show delay). Should load in background thread! 239e6a50d9cSMichael Pfeiffer // AddDelayItem(pDelay, "Half a Second", 0.5, false); 240e6a50d9cSMichael Pfeiffer // AddDelayItem(pDelay, "One Second", 1, false); 241e6a50d9cSMichael Pfeiffer // AddDelayItem(pDelay, "Two Second", 2, false); 242e6a50d9cSMichael Pfeiffer AddDelayItem(pDelay, "Three Seconds", 3, true); 243e6a50d9cSMichael Pfeiffer AddDelayItem(pDelay, "Four Second", 4, false); 244e6a50d9cSMichael Pfeiffer AddDelayItem(pDelay, "Five Seconds", 5, false); 245e6a50d9cSMichael Pfeiffer AddDelayItem(pDelay, "Six Seconds", 6, false); 246e6a50d9cSMichael Pfeiffer AddDelayItem(pDelay, "Seven Seconds", 7, false); 247e6a50d9cSMichael Pfeiffer AddDelayItem(pDelay, "Eight Seconds", 8, false); 248e6a50d9cSMichael Pfeiffer AddDelayItem(pDelay, "Nine Seconds", 9, false); 249e6a50d9cSMichael Pfeiffer AddDelayItem(pDelay, "Ten Seconds", 10, false); 250*6c305411SMatthew Wilber AddDelayItem(pDelay, "Twenty Seconds", 20, false); 251e6a50d9cSMichael Pfeiffer pmenu->AddItem(pDelay); 252e6a50d9cSMichael Pfeiffer pmenu->AddSeparatorItem(); 2537eca0987SMichael Pfeiffer AddItemMenu(pmenu, "Fit To Window Size", MSG_FIT_TO_WINDOW_SIZE, 0, 0, 'W', true); 254ad13f387SMichael Pfeiffer AddItemMenu(pmenu, "Full Screen", MSG_FULL_SCREEN, B_ENTER, 0, 'W', true); 255e6a50d9cSMichael Pfeiffer AddItemMenu(pmenu, "Show Caption in Full Screen Mode", MSG_SHOW_CAPTION, 0, 0, 'W', true); 256cdb89ebbSMatthew Wilber pbar->AddItem(pmenu); 257e6a50d9cSMichael Pfeiffer MarkMenuItem(MSG_SHOW_CAPTION, fShowCaption); 258d10d5947SMichael Pfeiffer 259d10d5947SMichael Pfeiffer UpdateRecentDocumentsMenu(); 26013afa642SPhil Greenway } 26113afa642SPhil Greenway 262cdb89ebbSMatthew Wilber BMenuItem * 263cdb89ebbSMatthew Wilber ShowImageWindow::AddItemMenu(BMenu *pmenu, char *caption, long unsigned int msg, 264cdb89ebbSMatthew Wilber char shortcut, uint32 modifier, char target, bool benabled) 265cdb89ebbSMatthew Wilber { 266cdb89ebbSMatthew Wilber BMenuItem* pitem; 267cdb89ebbSMatthew Wilber pitem = new BMenuItem(caption, new BMessage(msg), shortcut); 26813afa642SPhil Greenway 26913afa642SPhil Greenway if (target == 'A') 270cdb89ebbSMatthew Wilber pitem->SetTarget(be_app); 27113afa642SPhil Greenway 272cdb89ebbSMatthew Wilber pitem->SetEnabled(benabled); 273cdb89ebbSMatthew Wilber pmenu->AddItem(pitem); 27413afa642SPhil Greenway 275cdb89ebbSMatthew Wilber return pitem; 27613afa642SPhil Greenway } 27713afa642SPhil Greenway 278ad13f387SMichael Pfeiffer BMenuItem* 279ad13f387SMichael Pfeiffer ShowImageWindow::AddDelayItem(BMenu *pmenu, char *caption, float value, bool marked) 280ad13f387SMichael Pfeiffer { 281ad13f387SMichael Pfeiffer BMenuItem* pitem; 282ad13f387SMichael Pfeiffer BMessage* pmsg; 283e6a50d9cSMichael Pfeiffer pmsg = new BMessage(MSG_SLIDE_SHOW_DELAY); 284ad13f387SMichael Pfeiffer pmsg->AddFloat("value", value); 285ad13f387SMichael Pfeiffer 286ad13f387SMichael Pfeiffer pitem = new BMenuItem(caption, pmsg, 0); 287ad13f387SMichael Pfeiffer 288ad13f387SMichael Pfeiffer if (marked) pitem->SetMarked(true); 289ad13f387SMichael Pfeiffer pmenu->AddItem(pitem); 290ad13f387SMichael Pfeiffer 291ad13f387SMichael Pfeiffer return pitem; 292ad13f387SMichael Pfeiffer } 293ad13f387SMichael Pfeiffer 294cdb89ebbSMatthew Wilber void 295cdb89ebbSMatthew Wilber ShowImageWindow::WindowRedimension(BBitmap *pbitmap) 29613afa642SPhil Greenway { 297d10d5947SMichael Pfeiffer BScreen screen; 298d10d5947SMichael Pfeiffer BRect r(pbitmap->Bounds()); 299d10d5947SMichael Pfeiffer float width, height; 300d10d5947SMichael Pfeiffer float maxWidth, maxHeight; 301d10d5947SMichael Pfeiffer const float windowBorderWidth = 5; 302d10d5947SMichael Pfeiffer const float windowBorderHeight = 5; 30313afa642SPhil Greenway 304d10d5947SMichael Pfeiffer if (screen.Frame().right == 0.0) { 305d10d5947SMichael Pfeiffer return; // invalid screen object 306d10d5947SMichael Pfeiffer } 307cdb89ebbSMatthew Wilber 308d10d5947SMichael Pfeiffer width = r.Width() + B_V_SCROLL_BAR_WIDTH; 309d10d5947SMichael Pfeiffer height = r.Height() + 1 + fpBar->Frame().Height() + B_H_SCROLL_BAR_HEIGHT; 310cdb89ebbSMatthew Wilber 311d10d5947SMichael Pfeiffer // dimensions so that window does not reach outside of screen 312d10d5947SMichael Pfeiffer maxWidth = screen.Frame().Width() + 1 - windowBorderWidth - Frame().left; 313d10d5947SMichael Pfeiffer maxHeight = screen.Frame().Height() + 1 - windowBorderHeight - Frame().top; 314cdb89ebbSMatthew Wilber 315d10d5947SMichael Pfeiffer if (width > maxWidth) width = maxWidth; 316d10d5947SMichael Pfeiffer if (height > maxHeight) height = maxHeight; 317d10d5947SMichael Pfeiffer 318d10d5947SMichael Pfeiffer ResizeTo(width, height); 31913afa642SPhil Greenway } 32013afa642SPhil Greenway 321cdb89ebbSMatthew Wilber void 322cdb89ebbSMatthew Wilber ShowImageWindow::FrameResized(float width, float height) 32313afa642SPhil Greenway { 32413afa642SPhil Greenway } 32513afa642SPhil Greenway 3267eca0987SMichael Pfeiffer bool 3277eca0987SMichael Pfeiffer ShowImageWindow::ToggleMenuItem(uint32 what) 3287eca0987SMichael Pfeiffer { 3297eca0987SMichael Pfeiffer BMenuItem *item; 3307eca0987SMichael Pfeiffer bool marked = false; 3317eca0987SMichael Pfeiffer item = fpBar->FindItem(what); 3327eca0987SMichael Pfeiffer if (item != NULL) { 3337eca0987SMichael Pfeiffer marked = !item->IsMarked(); 3347eca0987SMichael Pfeiffer item->SetMarked(marked); 3357eca0987SMichael Pfeiffer } 3367eca0987SMichael Pfeiffer return marked; 3377eca0987SMichael Pfeiffer } 3387eca0987SMichael Pfeiffer 339cdb89ebbSMatthew Wilber void 340e6a50d9cSMichael Pfeiffer ShowImageWindow::EnableMenuItem(uint32 what, bool enable) 341e6a50d9cSMichael Pfeiffer { 342e6a50d9cSMichael Pfeiffer BMenuItem* item; 343e6a50d9cSMichael Pfeiffer item = fpBar->FindItem(what); 344e6a50d9cSMichael Pfeiffer if (item && item->IsEnabled() != enable) { 345e6a50d9cSMichael Pfeiffer // XXX: Does this apply to menu items too? 346e6a50d9cSMichael Pfeiffer // Only call this function if the state is changing 347e6a50d9cSMichael Pfeiffer // to avoid flickering 348e6a50d9cSMichael Pfeiffer item->SetEnabled(enable); 349e6a50d9cSMichael Pfeiffer } 350e6a50d9cSMichael Pfeiffer } 351e6a50d9cSMichael Pfeiffer 352e6a50d9cSMichael Pfeiffer void 353e6a50d9cSMichael Pfeiffer ShowImageWindow::MarkMenuItem(uint32 what, bool marked) 354e6a50d9cSMichael Pfeiffer { 355e6a50d9cSMichael Pfeiffer BMenuItem* item; 356e6a50d9cSMichael Pfeiffer item = fpBar->FindItem(what); 357e6a50d9cSMichael Pfeiffer if (item && item->IsMarked() != marked) { 358e6a50d9cSMichael Pfeiffer item->SetMarked(marked); 359e6a50d9cSMichael Pfeiffer } 360e6a50d9cSMichael Pfeiffer } 361e6a50d9cSMichael Pfeiffer 362e6a50d9cSMichael Pfeiffer 363e6a50d9cSMichael Pfeiffer void 364cdb89ebbSMatthew Wilber ShowImageWindow::MessageReceived(BMessage *pmsg) 36513afa642SPhil Greenway { 366cdb89ebbSMatthew Wilber switch (pmsg->what) { 367fc0a275bSMatthew Wilber case MSG_OUTPUT_TYPE: 368fc0a275bSMatthew Wilber // User clicked Save As then choose an output format 3697eca0987SMichael Pfeiffer if (!fpSavePanel) 370cdb89ebbSMatthew Wilber // If user doesn't already have a save panel open 371cdb89ebbSMatthew Wilber SaveAs(pmsg); 37213afa642SPhil Greenway break; 373fc0a275bSMatthew Wilber 374fc0a275bSMatthew Wilber case MSG_SAVE_PANEL: 375fc0a275bSMatthew Wilber // User specified where to save the output image 376cdb89ebbSMatthew Wilber SaveToFile(pmsg); 377fc0a275bSMatthew Wilber break; 378fc0a275bSMatthew Wilber 37907caaa8eSMatthew Wilber case MSG_CLOSE: 380cdb89ebbSMatthew Wilber if (CanQuit()) 38107caaa8eSMatthew Wilber Quit(); 38207caaa8eSMatthew Wilber break; 38307caaa8eSMatthew Wilber 384cdb89ebbSMatthew Wilber case B_CANCEL: 3857eca0987SMichael Pfeiffer delete fpSavePanel; 3867eca0987SMichael Pfeiffer fpSavePanel = NULL; 387cdb89ebbSMatthew Wilber break; 388cdb89ebbSMatthew Wilber 38903839579SMatthew Wilber case MSG_UPDATE_STATUS: 39003839579SMatthew Wilber { 391*6c305411SMatthew Wilber int32 pages, curPage; 392*6c305411SMatthew Wilber pages = fpImageView->PageCount(); 393*6c305411SMatthew Wilber curPage = fpImageView->CurrentPage(); 394*6c305411SMatthew Wilber 395*6c305411SMatthew Wilber bool benable = (pages > 1) ? true : false; 396e6a50d9cSMichael Pfeiffer EnableMenuItem(MSG_PAGE_FIRST, benable); 397e6a50d9cSMichael Pfeiffer EnableMenuItem(MSG_PAGE_LAST, benable); 398e6a50d9cSMichael Pfeiffer EnableMenuItem(MSG_PAGE_NEXT, benable); 399e6a50d9cSMichael Pfeiffer EnableMenuItem(MSG_PAGE_PREV, benable); 4001d592070SMatthew Wilber 401*6c305411SMatthew Wilber if (fpGoToPageMenu->CountItems() != pages) { 402*6c305411SMatthew Wilber // Only rebuild the submenu if the number of 403*6c305411SMatthew Wilber // pages is different 404*6c305411SMatthew Wilber 405*6c305411SMatthew Wilber while (fpGoToPageMenu->CountItems() > 0) 406*6c305411SMatthew Wilber // Remove all page numbers 407*6c305411SMatthew Wilber delete fpGoToPageMenu->RemoveItem(0L); 408*6c305411SMatthew Wilber 409*6c305411SMatthew Wilber for (int32 i = 1; i > 0 && i <= pages; i++) { 410*6c305411SMatthew Wilber // Fill Go To page submenu with an entry for each page 411*6c305411SMatthew Wilber BMessage *pgomsg; 412*6c305411SMatthew Wilber pgomsg = new BMessage(MSG_GOTO_PAGE); 413*6c305411SMatthew Wilber pgomsg->AddInt32("page", i); 414*6c305411SMatthew Wilber BString strCaption; 415*6c305411SMatthew Wilber strCaption << i; 416*6c305411SMatthew Wilber BMenuItem *pitem; 417*6c305411SMatthew Wilber pitem = new BMenuItem(strCaption.String(), pgomsg, 0); 418*6c305411SMatthew Wilber if (curPage == i) 419*6c305411SMatthew Wilber pitem->SetMarked(true); 420*6c305411SMatthew Wilber fpGoToPageMenu->AddItem(pitem); 421*6c305411SMatthew Wilber } 422*6c305411SMatthew Wilber } else { 423*6c305411SMatthew Wilber // Make sure the correct page is marked 424*6c305411SMatthew Wilber BMenuItem *pcurItem; 425*6c305411SMatthew Wilber pcurItem = fpGoToPageMenu->ItemAt(curPage - 1); 426*6c305411SMatthew Wilber if (!pcurItem->IsMarked()) { 427*6c305411SMatthew Wilber // If the current page isn't marked, unmark everything 428*6c305411SMatthew Wilber // then mark the current page 429*6c305411SMatthew Wilber int32 items = fpGoToPageMenu->CountItems(); 430*6c305411SMatthew Wilber for (int32 i = 0; i < items; i++) 431*6c305411SMatthew Wilber fpGoToPageMenu->ItemAt(i)->SetMarked(false); 432*6c305411SMatthew Wilber pcurItem->SetMarked(true); 433*6c305411SMatthew Wilber } 434*6c305411SMatthew Wilber } 435*6c305411SMatthew Wilber 43603839579SMatthew Wilber BString str; 43703839579SMatthew Wilber if (pmsg->FindString("status", &str) == B_OK) 4387eca0987SMichael Pfeiffer fpStatusView->SetText(str); 4397eca0987SMichael Pfeiffer 4407eca0987SMichael Pfeiffer UpdateTitle(); 44103839579SMatthew Wilber break; 44203839579SMatthew Wilber } 44303839579SMatthew Wilber 44413afa642SPhil Greenway case B_UNDO: 44513afa642SPhil Greenway break; 44613afa642SPhil Greenway case B_CUT: 44713afa642SPhil Greenway break; 44813afa642SPhil Greenway case B_COPY: 449d10d5947SMichael Pfeiffer fpImageView->CopySelectionToClipboard(); 45013afa642SPhil Greenway break; 45113afa642SPhil Greenway case B_PASTE: 45213afa642SPhil Greenway break; 45313afa642SPhil Greenway case MSG_CLEAR_SELECT: 454d10d5947SMichael Pfeiffer fpImageView->Unselect(); 45513afa642SPhil Greenway break; 45613afa642SPhil Greenway case MSG_SELECT_ALL: 457d10d5947SMichael Pfeiffer fpImageView->SelectAll(); 45813afa642SPhil Greenway break; 45913afa642SPhil Greenway 46003839579SMatthew Wilber case MSG_PAGE_FIRST: 4617eca0987SMichael Pfeiffer fpImageView->FirstPage(); 46203839579SMatthew Wilber break; 46303839579SMatthew Wilber 46403839579SMatthew Wilber case MSG_PAGE_LAST: 4657eca0987SMichael Pfeiffer fpImageView->LastPage(); 46603839579SMatthew Wilber break; 46703839579SMatthew Wilber 46803839579SMatthew Wilber case MSG_PAGE_NEXT: 4697eca0987SMichael Pfeiffer fpImageView->NextPage(); 47003839579SMatthew Wilber break; 47103839579SMatthew Wilber 47203839579SMatthew Wilber case MSG_PAGE_PREV: 4737eca0987SMichael Pfeiffer fpImageView->PrevPage(); 47403839579SMatthew Wilber break; 47503839579SMatthew Wilber 476*6c305411SMatthew Wilber case MSG_GOTO_PAGE: 477*6c305411SMatthew Wilber { 478*6c305411SMatthew Wilber int32 curPage, newPage, pages; 479*6c305411SMatthew Wilber if (pmsg->FindInt32("page", &newPage) == B_OK) { 480*6c305411SMatthew Wilber curPage = fpImageView->CurrentPage(); 481*6c305411SMatthew Wilber pages = fpImageView->PageCount(); 482*6c305411SMatthew Wilber 483*6c305411SMatthew Wilber if (newPage > 0 && newPage <= pages) { 484*6c305411SMatthew Wilber BMenuItem *pcurItem, *pnewItem; 485*6c305411SMatthew Wilber pcurItem = fpGoToPageMenu->ItemAt(curPage - 1); 486*6c305411SMatthew Wilber pnewItem = fpGoToPageMenu->ItemAt(newPage - 1); 487*6c305411SMatthew Wilber if (!pcurItem || !pnewItem) 488*6c305411SMatthew Wilber break; 489*6c305411SMatthew Wilber pcurItem->SetMarked(false); 490*6c305411SMatthew Wilber pnewItem->SetMarked(true); 491*6c305411SMatthew Wilber fpImageView->GoToPage(newPage); 492*6c305411SMatthew Wilber } 493*6c305411SMatthew Wilber } 494*6c305411SMatthew Wilber } 495*6c305411SMatthew Wilber break; 496*6c305411SMatthew Wilber 497cdb89ebbSMatthew Wilber case MSG_DITHER_IMAGE: 4987eca0987SMichael Pfeiffer ToggleMenuItem(pmsg->what); 4997eca0987SMichael Pfeiffer break; 5007eca0987SMichael Pfeiffer 5017eca0987SMichael Pfeiffer case MSG_FIT_TO_WINDOW_SIZE: 5027eca0987SMichael Pfeiffer { 5037eca0987SMichael Pfeiffer bool resize; 5047eca0987SMichael Pfeiffer resize = ToggleMenuItem(pmsg->what); 5057eca0987SMichael Pfeiffer fpImageView->ResizeToViewBounds(resize); 5067eca0987SMichael Pfeiffer } 5077eca0987SMichael Pfeiffer break; 5087eca0987SMichael Pfeiffer 5097eca0987SMichael Pfeiffer case MSG_FILE_PREV: 5107eca0987SMichael Pfeiffer fpImageView->PrevFile(); 5117eca0987SMichael Pfeiffer break; 5127eca0987SMichael Pfeiffer 5137eca0987SMichael Pfeiffer case MSG_FILE_NEXT: 5147eca0987SMichael Pfeiffer fpImageView->NextFile(); 51513afa642SPhil Greenway break; 51613afa642SPhil Greenway 517ad13f387SMichael Pfeiffer case MSG_ROTATE_CLOCKWISE: 518ad13f387SMichael Pfeiffer fpImageView->Rotate(90); 519ad13f387SMichael Pfeiffer break; 520ad13f387SMichael Pfeiffer case MSG_ROTATE_ACLKWISE: 521ad13f387SMichael Pfeiffer fpImageView->Rotate(270); 522ad13f387SMichael Pfeiffer break; 523ad13f387SMichael Pfeiffer case MSG_MIRROR_VERTICAL: 524ad13f387SMichael Pfeiffer fpImageView->Mirror(true); 525ad13f387SMichael Pfeiffer break; 526ad13f387SMichael Pfeiffer case MSG_MIRROR_HORIZONTAL: 527ad13f387SMichael Pfeiffer fpImageView->Mirror(false); 528ad13f387SMichael Pfeiffer break; 529ad13f387SMichael Pfeiffer case MSG_INVERT: 530ad13f387SMichael Pfeiffer fpImageView->Invert(); 531ad13f387SMichael Pfeiffer break; 532e6a50d9cSMichael Pfeiffer case MSG_SLIDE_SHOW: 533ad13f387SMichael Pfeiffer if (ToggleMenuItem(pmsg->what)) { 534e6a50d9cSMichael Pfeiffer fpImageView->StartSlideShow(); 535ad13f387SMichael Pfeiffer } else { 536e6a50d9cSMichael Pfeiffer fpImageView->StopSlideShow(); 537ad13f387SMichael Pfeiffer } 538e6a50d9cSMichael Pfeiffer case MSG_SLIDE_SHOW_DELAY: 539ad13f387SMichael Pfeiffer { 540ad13f387SMichael Pfeiffer float value; 541ad13f387SMichael Pfeiffer if (pmsg->FindFloat("value", &value) == B_OK) { 542e6a50d9cSMichael Pfeiffer fpImageView->SetSlideShowDelay(value); 543ad13f387SMichael Pfeiffer } 544ad13f387SMichael Pfeiffer } 545ad13f387SMichael Pfeiffer break; 546ad13f387SMichael Pfeiffer 547ad13f387SMichael Pfeiffer case MSG_FULL_SCREEN: 548ad13f387SMichael Pfeiffer ToggleFullScreen(); 549ad13f387SMichael Pfeiffer break; 550e6a50d9cSMichael Pfeiffer case MSG_SHOW_CAPTION: 551e6a50d9cSMichael Pfeiffer fShowCaption = ToggleMenuItem(pmsg->what); 552e6a50d9cSMichael Pfeiffer if (fFullScreen) { 553e6a50d9cSMichael Pfeiffer fpImageView->SetShowCaption(fShowCaption); 554e6a50d9cSMichael Pfeiffer } 555e6a50d9cSMichael Pfeiffer break; 556ad13f387SMichael Pfeiffer 557d10d5947SMichael Pfeiffer case MSG_UPDATE_RECENT_DOCUMENTS: 558d10d5947SMichael Pfeiffer UpdateRecentDocumentsMenu(); 559d10d5947SMichael Pfeiffer break; 560d10d5947SMichael Pfeiffer 56113afa642SPhil Greenway default: 562cdb89ebbSMatthew Wilber BWindow::MessageReceived(pmsg); 56313afa642SPhil Greenway break; 56413afa642SPhil Greenway } 56513afa642SPhil Greenway } 566fc0a275bSMatthew Wilber 567fc0a275bSMatthew Wilber void 568fc0a275bSMatthew Wilber ShowImageWindow::SaveAs(BMessage *pmsg) 569fc0a275bSMatthew Wilber { 570cdb89ebbSMatthew Wilber // Read the translator and output type the user chose 571cdb89ebbSMatthew Wilber translator_id outTranslator; 572cdb89ebbSMatthew Wilber uint32 outType; 573cdb89ebbSMatthew Wilber if (pmsg->FindInt32(TRANSLATOR_FLD, 574cdb89ebbSMatthew Wilber reinterpret_cast<int32 *>(&outTranslator)) != B_OK) 575fc0a275bSMatthew Wilber return; 576cdb89ebbSMatthew Wilber if (pmsg->FindInt32(TYPE_FLD, 577cdb89ebbSMatthew Wilber reinterpret_cast<int32 *>(&outType)) != B_OK) 578fc0a275bSMatthew Wilber return; 579fc0a275bSMatthew Wilber 580cdb89ebbSMatthew Wilber // Add the chosen translator and output type to the 581cdb89ebbSMatthew Wilber // message that the save panel will send back 582cdb89ebbSMatthew Wilber BMessage *ppanelMsg = new BMessage(MSG_SAVE_PANEL); 583cdb89ebbSMatthew Wilber ppanelMsg->AddInt32(TRANSLATOR_FLD, outTranslator); 584cdb89ebbSMatthew Wilber ppanelMsg->AddInt32(TYPE_FLD, outType); 585cdb89ebbSMatthew Wilber 586cdb89ebbSMatthew Wilber // Create save panel and show it 5877eca0987SMichael Pfeiffer fpSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this), NULL, 0, 588cdb89ebbSMatthew Wilber false, ppanelMsg); 5897eca0987SMichael Pfeiffer if (!fpSavePanel) 590fc0a275bSMatthew Wilber return; 5917eca0987SMichael Pfeiffer fpSavePanel->Window()->SetWorkspaces(B_CURRENT_WORKSPACE); 5927eca0987SMichael Pfeiffer fpSavePanel->Show(); 593fc0a275bSMatthew Wilber } 594fc0a275bSMatthew Wilber 595fc0a275bSMatthew Wilber void 596fc0a275bSMatthew Wilber ShowImageWindow::SaveToFile(BMessage *pmsg) 597fc0a275bSMatthew Wilber { 598cdb89ebbSMatthew Wilber // Read in where the file should be saved 599fc0a275bSMatthew Wilber entry_ref dirref; 600fc0a275bSMatthew Wilber if (pmsg->FindRef("directory", &dirref) != B_OK) 601fc0a275bSMatthew Wilber return; 602fc0a275bSMatthew Wilber const char *filename; 603fc0a275bSMatthew Wilber if (pmsg->FindString("name", &filename) != B_OK) 604fc0a275bSMatthew Wilber return; 605fc0a275bSMatthew Wilber 606cdb89ebbSMatthew Wilber // Read in the translator and type to be used 607cdb89ebbSMatthew Wilber // to save the output image 608cdb89ebbSMatthew Wilber translator_id outTranslator; 609cdb89ebbSMatthew Wilber uint32 outType; 610cdb89ebbSMatthew Wilber if (pmsg->FindInt32(TRANSLATOR_FLD, 611cdb89ebbSMatthew Wilber reinterpret_cast<int32 *>(&outTranslator)) != B_OK) 612cdb89ebbSMatthew Wilber return; 613cdb89ebbSMatthew Wilber if (pmsg->FindInt32(TYPE_FLD, 614cdb89ebbSMatthew Wilber reinterpret_cast<int32 *>(&outType)) != B_OK) 615cdb89ebbSMatthew Wilber return; 616cdb89ebbSMatthew Wilber 617cdb89ebbSMatthew Wilber // Create the output file 618fc0a275bSMatthew Wilber BDirectory dir(&dirref); 619fc0a275bSMatthew Wilber BFile file(&dir, filename, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); 620fc0a275bSMatthew Wilber if (file.InitCheck() != B_OK) 621fc0a275bSMatthew Wilber return; 622fc0a275bSMatthew Wilber 623cdb89ebbSMatthew Wilber // Translate the image and write it out to the output file 6247eca0987SMichael Pfeiffer BBitmapStream stream(fpImageView->GetBitmap()); 625fc0a275bSMatthew Wilber BTranslatorRoster *proster = BTranslatorRoster::Default(); 626cdb89ebbSMatthew Wilber if (proster->Translate(outTranslator, &stream, NULL, 627cdb89ebbSMatthew Wilber &file, outType) != B_OK) { 628fc0a275bSMatthew Wilber BAlert *palert = new BAlert(NULL, "Error writing image file.", "Ok"); 629fc0a275bSMatthew Wilber palert->Go(); 630fc0a275bSMatthew Wilber } 631fc0a275bSMatthew Wilber 632fc0a275bSMatthew Wilber BBitmap *pout = NULL; 633fc0a275bSMatthew Wilber stream.DetachBitmap(&pout); 634fc0a275bSMatthew Wilber // bitmap used by stream still belongs to the view, 635fc0a275bSMatthew Wilber // detach so it doesn't get deleted 636fc0a275bSMatthew Wilber } 637fc0a275bSMatthew Wilber 638cdb89ebbSMatthew Wilber bool 639cdb89ebbSMatthew Wilber ShowImageWindow::CanQuit() 640cdb89ebbSMatthew Wilber { 6417eca0987SMichael Pfeiffer if (fpSavePanel) 642cdb89ebbSMatthew Wilber // Don't allow this window to be closed if a save panel is open 643cdb89ebbSMatthew Wilber return false; 644cdb89ebbSMatthew Wilber else 645cdb89ebbSMatthew Wilber return true; 646cdb89ebbSMatthew Wilber } 647cdb89ebbSMatthew Wilber 648ad13f387SMichael Pfeiffer void 649ad13f387SMichael Pfeiffer ShowImageWindow::ToggleFullScreen() 650ad13f387SMichael Pfeiffer { 651ad13f387SMichael Pfeiffer BRect frame; 652ad13f387SMichael Pfeiffer fFullScreen = !fFullScreen; 653ad13f387SMichael Pfeiffer if (fFullScreen) { 654ad13f387SMichael Pfeiffer BScreen screen; 655ad13f387SMichael Pfeiffer fWindowFrame = Frame(); 656ad13f387SMichael Pfeiffer frame = screen.Frame(); 657ad13f387SMichael Pfeiffer frame.top -= fpBar->Bounds().Height()+1; 658ad13f387SMichael Pfeiffer frame.right += B_V_SCROLL_BAR_WIDTH; 659ad13f387SMichael Pfeiffer frame.bottom += B_H_SCROLL_BAR_HEIGHT; 660ad13f387SMichael Pfeiffer frame.InsetBy(-1, -1); // PEN_SIZE in ShowImageView 661ad13f387SMichael Pfeiffer 662ad13f387SMichael Pfeiffer SetFlags(Flags() | B_NOT_RESIZABLE | B_NOT_MOVABLE); 663ad13f387SMichael Pfeiffer } else { 664ad13f387SMichael Pfeiffer frame = fWindowFrame; 665ad13f387SMichael Pfeiffer 666ad13f387SMichael Pfeiffer SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_MOVABLE)); 667ad13f387SMichael Pfeiffer } 668e6a50d9cSMichael Pfeiffer fpImageView->SetShowCaption(fFullScreen && fShowCaption); 669ad13f387SMichael Pfeiffer MoveTo(frame.left, frame.top); 670ad13f387SMichael Pfeiffer ResizeTo(frame.Width(), frame.Height()); 671ad13f387SMichael Pfeiffer } 672ad13f387SMichael Pfeiffer 673cdb89ebbSMatthew Wilber bool 674cdb89ebbSMatthew Wilber ShowImageWindow::QuitRequested() 675cdb89ebbSMatthew Wilber { 676cdb89ebbSMatthew Wilber return CanQuit(); 677cdb89ebbSMatthew Wilber } 678cdb89ebbSMatthew Wilber 67907caaa8eSMatthew Wilber void 68007caaa8eSMatthew Wilber ShowImageWindow::Quit() 68107caaa8eSMatthew Wilber { 68207caaa8eSMatthew Wilber // tell the app to forget about this window 68307caaa8eSMatthew Wilber be_app->PostMessage(MSG_WINDOW_QUIT); 68407caaa8eSMatthew Wilber BWindow::Quit(); 68507caaa8eSMatthew Wilber } 686fc0a275bSMatthew Wilber 687