* cleanup, no functional change

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27201 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Karsten Heimrich
2008-08-25 21:48:06 +00:00
parent ec44f528d8
commit 56b0c7b90d
+81 -70
View File
@@ -51,7 +51,7 @@ RecentDocumentsMenu::RecentDocumentsMenu(const char *title, menu_layout layout)
} }
bool bool
RecentDocumentsMenu::AddDynamicItem(add_state addState) RecentDocumentsMenu::AddDynamicItem(add_state addState)
{ {
if (addState != B_INITIAL_ADD) if (addState != B_INITIAL_ADD)
@@ -98,10 +98,10 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref,
fSlideShowDelay = NULL; fSlideShowDelay = NULL;
fResizerWindowMessenger = NULL; fResizerWindowMessenger = NULL;
fHeight = fWidth = 0; fHeight = fWidth = 0;
LoadSettings();
// create menu bar LoadSettings();
// create menu bar
fBar = new BMenuBar(BRect(0, 0, Bounds().right, 1), "menu_bar"); fBar = new BMenuBar(BRect(0, 0, Bounds().right, 1), "menu_bar");
AddMenus(fBar); AddMenus(fBar);
AddChild(fBar); AddChild(fBar);
@@ -111,9 +111,9 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref,
viewFrame.right -= B_V_SCROLL_BAR_WIDTH; viewFrame.right -= B_V_SCROLL_BAR_WIDTH;
viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT; viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT;
// create the image view // create the image view
fImageView = new ShowImageView(viewFrame, "image_view", B_FOLLOW_ALL, fImageView = new ShowImageView(viewFrame, "image_view", B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED); B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE | B_PULSE_NEEDED);
// wrap a scroll view around the view // wrap a scroll view around the view
BScrollView *scrollView = new BScrollView("image_scroller", fImageView, BScrollView *scrollView = new BScrollView("image_scroller", fImageView,
B_FOLLOW_ALL, 0, false, false, B_PLAIN_BORDER); B_FOLLOW_ALL, 0, false, false, B_PLAIN_BORDER);
@@ -124,19 +124,19 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref,
rect = Bounds(); rect = Bounds();
rect.top = viewFrame.bottom + 1; rect.top = viewFrame.bottom + 1;
rect.left = viewFrame.left + kstatusWidth; rect.left = viewFrame.left + kstatusWidth;
rect.right = viewFrame.right + 1; rect.right = viewFrame.right + 1;
rect.bottom += 1; rect.bottom += 1;
BScrollBar *horizontalScrollBar = new BScrollBar(rect, "hscroll", BScrollBar *horizontalScrollBar = new BScrollBar(rect, "hscroll",
fImageView, 0, 150, B_HORIZONTAL); fImageView, 0, 150, B_HORIZONTAL);
AddChild(horizontalScrollBar); AddChild(horizontalScrollBar);
rect.left = 0; rect.left = 0;
rect.right = kstatusWidth - 1; rect.right = kstatusWidth - 1;
rect.bottom -= 1; rect.bottom -= 1;
fStatusView = new ShowImageStatusView(rect, "status_view", B_FOLLOW_BOTTOM, fStatusView = new ShowImageStatusView(rect, "status_view", B_FOLLOW_BOTTOM,
B_WILL_DRAW); B_WILL_DRAW);
AddChild(fStatusView); AddChild(fStatusView);
rect = Bounds(); rect = Bounds();
rect.top = viewFrame.top - 1; rect.top = viewFrame.top - 1;
rect.left = viewFrame.right + 1; rect.left = viewFrame.right + 1;
@@ -147,17 +147,16 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref,
AddChild(verticalScrollBar); AddChild(verticalScrollBar);
SetSizeLimits(250, 100000, 100, 100000); SetSizeLimits(250, 100000, 100, 100000);
// finish creating the window // finish creating the window
fImageView->SetImage(ref); fImageView->SetImage(ref);
fImageView->SetTrackerMessenger(trackerMessenger); fImageView->SetTrackerMessenger(trackerMessenger);
if (InitCheck() != B_OK) { if (InitCheck() != B_OK) {
BAlert* alert; BAlert* alert;
alert = new BAlert("ShowImage", alert = new BAlert("ShowImage",
"Could not load image! Either the file or an image translator for it does not exist.", "Could not load image! Either the file or an image translator for "
"OK", NULL, NULL, "it does not exist.", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT);
B_WIDTH_AS_USUAL, B_INFO_ALERT);
alert->Go(); alert->Go();
// quit if file could not be opened // quit if file could not be opened
@@ -165,10 +164,10 @@ ShowImageWindow::ShowImageWindow(const entry_ref *ref,
return; return;
} }
// add View menu here so it can access ShowImageView methods // add View menu here so it can access ShowImageView methods
BMenu* menu = new BMenu("View"); BMenu* menu = new BMenu("View");
BuildViewMenu(menu, false); BuildViewMenu(menu, false);
fBar->AddItem(menu); fBar->AddItem(menu);
MarkMenuItem(fBar, MSG_DITHER_IMAGE, fImageView->GetDither()); MarkMenuItem(fBar, MSG_DITHER_IMAGE, fImageView->GetDither());
UpdateTitle(); UpdateTitle();
@@ -208,12 +207,14 @@ ShowImageWindow::UpdateTitle()
SetTitle(path.String()); SetTitle(path.String());
} }
void
void
ShowImageWindow::BuildContextMenu(BMenu *menu) ShowImageWindow::BuildContextMenu(BMenu *menu)
{ {
BuildViewMenu(menu, true); BuildViewMenu(menu, true);
} }
void void
ShowImageWindow::BuildViewMenu(BMenu *menu, bool popupMenu) ShowImageWindow::BuildViewMenu(BMenu *menu, bool popupMenu)
{ {
@@ -224,9 +225,10 @@ ShowImageWindow::BuildViewMenu(BMenu *menu, bool popupMenu)
fSlideShowDelay = delayMenu; fSlideShowDelay = delayMenu;
delayMenu->SetRadioMode(true); delayMenu->SetRadioMode(true);
// Note: ShowImage loads images in window thread so it becomes unresponsive if // Note: ShowImage loads images in window thread so it becomes unresponsive
// slide show delay is too short! (Especially if loading the image takes as long as // if slide show delay is too short! (Especially if loading the image
// or longer than the slide show delay). Should load in background thread! // takes as long as or longer than the slide show delay). Should load
// in background thread!
AddDelayItem(delayMenu, "Three Seconds", 3); AddDelayItem(delayMenu, "Three Seconds", 3);
AddDelayItem(delayMenu, "Four Second", 4); AddDelayItem(delayMenu, "Four Second", 4);
AddDelayItem(delayMenu, "Five Seconds", 5); AddDelayItem(delayMenu, "Five Seconds", 5);
@@ -242,7 +244,7 @@ ShowImageWindow::BuildViewMenu(BMenu *menu, bool popupMenu)
AddItemMenu(menu, "Original Size", MSG_ORIGINAL_SIZE, 0, 0, 'W', true); AddItemMenu(menu, "Original Size", MSG_ORIGINAL_SIZE, 0, 0, 'W', true);
AddItemMenu(menu, "Zoom In", MSG_ZOOM_IN, '+', 0, 'W', true); AddItemMenu(menu, "Zoom In", MSG_ZOOM_IN, '+', 0, 'W', true);
AddItemMenu(menu, "Zoom Out", MSG_ZOOM_OUT, '-', 0, 'W', true); AddItemMenu(menu, "Zoom Out", MSG_ZOOM_OUT, '-', 0, 'W', true);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
@@ -260,7 +262,8 @@ ShowImageWindow::BuildViewMenu(BMenu *menu, bool popupMenu)
AddShortcut(B_ENTER, 0, new BMessage(MSG_FULL_SCREEN)); AddShortcut(B_ENTER, 0, new BMessage(MSG_FULL_SCREEN));
AddItemMenu(menu, "Show Caption in Full Screen Mode", MSG_SHOW_CAPTION, 0, 0, 'W', true); AddItemMenu(menu, "Show Caption in Full Screen Mode", MSG_SHOW_CAPTION, 0,
0, 'W', true);
MarkMenuItem(menu, MSG_SHOW_CAPTION, fShowCaption); MarkMenuItem(menu, MSG_SHOW_CAPTION, fShowCaption);
MarkMenuItem(menu, MSG_SCALE_BILINEAR, fImageView->GetScaleBilinear()); MarkMenuItem(menu, MSG_SCALE_BILINEAR, fImageView->GetScaleBilinear());
@@ -272,15 +275,15 @@ ShowImageWindow::BuildViewMenu(BMenu *menu, bool popupMenu)
MarkMenuItem(menu, MSG_SHRINK_TO_WINDOW, shrink); MarkMenuItem(menu, MSG_SHRINK_TO_WINDOW, shrink);
MarkMenuItem(menu, MSG_ZOOM_TO_WINDOW, zoom); MarkMenuItem(menu, MSG_ZOOM_TO_WINDOW, zoom);
enabled = !(shrink || zoom); enabled = !(shrink || zoom);
EnableMenuItem(menu, MSG_ORIGINAL_SIZE, enabled); EnableMenuItem(menu, MSG_ORIGINAL_SIZE, enabled);
EnableMenuItem(menu, MSG_ZOOM_IN, enabled); EnableMenuItem(menu, MSG_ZOOM_IN, enabled);
EnableMenuItem(menu, MSG_ZOOM_OUT, enabled); EnableMenuItem(menu, MSG_ZOOM_OUT, enabled);
if (popupMenu) { if (popupMenu) {
menu->AddSeparatorItem(); menu->AddSeparatorItem();
AddItemMenu(menu, "As Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0,
AddItemMenu(menu, "As Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0, 'W', true); 'W', true);
} }
} }
@@ -306,7 +309,8 @@ ShowImageWindow::AddMenus(BMenuBar *bar)
AddItemMenu(menu, "Page Setup" B_UTF8_ELLIPSIS, MSG_PAGE_SETUP, 0, 0, 'W', true); AddItemMenu(menu, "Page Setup" B_UTF8_ELLIPSIS, MSG_PAGE_SETUP, 0, 0, 'W', true);
AddItemMenu(menu, "Print" B_UTF8_ELLIPSIS, MSG_PREPARE_PRINT, 0, 0, 'W', true); AddItemMenu(menu, "Print" B_UTF8_ELLIPSIS, MSG_PREPARE_PRINT, 0, 0, 'W', true);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
AddItemMenu(menu, "About ShowImage" B_UTF8_ELLIPSIS, B_ABOUT_REQUESTED, 0, 0, 'A', true); AddItemMenu(menu, "About ShowImage" B_UTF8_ELLIPSIS, B_ABOUT_REQUESTED, 0, 0,
'A', true);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
AddItemMenu(menu, "Quit", B_QUIT_REQUESTED, 'Q', 0, 'A', true); AddItemMenu(menu, "Quit", B_QUIT_REQUESTED, 'Q', 0, 'A', true);
bar->AddItem(menu); bar->AddItem(menu);
@@ -344,18 +348,21 @@ ShowImageWindow::AddMenus(BMenuBar *bar)
menu->AddSeparatorItem(); menu->AddSeparatorItem();
AddItemMenu(menu, "Invert Colors", MSG_INVERT, 0, 0, 'W', true); AddItemMenu(menu, "Invert Colors", MSG_INVERT, 0, 0, 'W', true);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
fResizeItem = AddItemMenu(menu, "Resize" B_UTF8_ELLIPSIS, MSG_OPEN_RESIZER_WINDOW, 0, 0, 'W', true); fResizeItem = AddItemMenu(menu, "Resize" B_UTF8_ELLIPSIS,
MSG_OPEN_RESIZER_WINDOW, 0, 0, 'W', true);
bar->AddItem(menu); bar->AddItem(menu);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
AddItemMenu(menu, "Use as Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0, 'W', true); AddItemMenu(menu, "Use as Desktop Background", MSG_DESKTOP_BACKGROUND, 0, 0,
'W', true);
} }
BMenuItem * BMenuItem *
ShowImageWindow::AddItemMenu(BMenu *menu, char *caption, uint32 command, ShowImageWindow::AddItemMenu(BMenu *menu, char *caption, uint32 command,
char shortcut, uint32 modifier, char target, bool enabled) char shortcut, uint32 modifier, char target, bool enabled)
{ {
BMenuItem* item = new BMenuItem(caption, new BMessage(command), shortcut, modifier); BMenuItem* item =
new BMenuItem(caption, new BMessage(command), shortcut, modifier);
if (target == 'A') if (target == 'A')
item->SetTarget(be_app); item->SetTarget(be_app);
@@ -399,9 +406,10 @@ ShowImageWindow::WindowRedimension(BBitmap *pbitmap)
const float windowBorderHeight = 5; const float windowBorderHeight = 5;
float width = r.Width() + 2 * PEN_SIZE + B_V_SCROLL_BAR_WIDTH; float width = r.Width() + 2 * PEN_SIZE + B_V_SCROLL_BAR_WIDTH;
float height = r.Height() + 2 * PEN_SIZE + 1 + fBar->Frame().Height() + B_H_SCROLL_BAR_HEIGHT; float height = r.Height() + 2 * PEN_SIZE + 1 + fBar->Frame().Height() +
B_H_SCROLL_BAR_HEIGHT;
// dimensions so that window does not reach outside of screen // dimensions so that window does not reach outside of screen
float maxWidth = screen.Frame().Width() + 1 - windowBorderWidth - Frame().left; float maxWidth = screen.Frame().Width() + 1 - windowBorderWidth - Frame().left;
float maxHeight = screen.Frame().Height() + 1 - windowBorderHeight - Frame().top; float maxHeight = screen.Frame().Height() + 1 - windowBorderHeight - Frame().top;
@@ -409,7 +417,7 @@ ShowImageWindow::WindowRedimension(BBitmap *pbitmap)
// menu bar will be too short for small images. // menu bar will be too short for small images.
float minW, maxW, minH, maxH; float minW, maxW, minH, maxH;
GetSizeLimits(&minW, &maxW, &minH, &maxH); GetSizeLimits(&minW, &maxW, &minH, &maxH);
if (maxWidth > maxW) if (maxWidth > maxW)
maxWidth = maxW; maxWidth = maxW;
if (maxHeight > maxH) if (maxHeight > maxH)
@@ -422,7 +430,7 @@ ShowImageWindow::WindowRedimension(BBitmap *pbitmap)
if (width > maxWidth) if (width > maxWidth)
width = maxWidth; width = maxWidth;
if (height > maxHeight) if (height > maxHeight)
height = maxHeight; height = maxHeight;
ResizeTo(width, height); ResizeTo(width, height);
} }
@@ -459,7 +467,7 @@ ShowImageWindow::EnableMenuItem(BMenu *menu, uint32 what, bool enable)
} }
void void
ShowImageWindow::MarkMenuItem(BMenu *menu, uint32 what, bool marked) ShowImageWindow::MarkMenuItem(BMenu *menu, uint32 what, bool marked)
{ {
BMenuItem* item; BMenuItem* item;
@@ -537,24 +545,24 @@ ShowImageWindow::MessageReceived(BMessage *message)
int32 pages, curPage; int32 pages, curPage;
pages = fImageView->PageCount(); pages = fImageView->PageCount();
curPage = fImageView->CurrentPage(); curPage = fImageView->CurrentPage();
bool benable = (pages > 1) ? true : false; bool benable = (pages > 1) ? true : false;
EnableMenuItem(fBar, MSG_PAGE_FIRST, benable); EnableMenuItem(fBar, MSG_PAGE_FIRST, benable);
EnableMenuItem(fBar, MSG_PAGE_LAST, benable); EnableMenuItem(fBar, MSG_PAGE_LAST, benable);
EnableMenuItem(fBar, MSG_PAGE_NEXT, benable); EnableMenuItem(fBar, MSG_PAGE_NEXT, benable);
EnableMenuItem(fBar, MSG_PAGE_PREV, benable); EnableMenuItem(fBar, MSG_PAGE_PREV, benable);
EnableMenuItem(fBar, MSG_FILE_NEXT, fImageView->HasNextFile()); EnableMenuItem(fBar, MSG_FILE_NEXT, fImageView->HasNextFile());
EnableMenuItem(fBar, MSG_FILE_PREV, fImageView->HasPrevFile()); EnableMenuItem(fBar, MSG_FILE_PREV, fImageView->HasPrevFile());
if (fGoToPageMenu->CountItems() != pages) { if (fGoToPageMenu->CountItems() != pages) {
// Only rebuild the submenu if the number of // Only rebuild the submenu if the number of
// pages is different // pages is different
while (fGoToPageMenu->CountItems() > 0) while (fGoToPageMenu->CountItems() > 0)
// Remove all page numbers // Remove all page numbers
delete fGoToPageMenu->RemoveItem(0L); delete fGoToPageMenu->RemoveItem(0L);
for (int32 i = 1; i <= pages; i++) { for (int32 i = 1; i <= pages; i++) {
// Fill Go To page submenu with an entry for each page // Fill Go To page submenu with an entry for each page
BMessage *pgomsg; BMessage *pgomsg;
@@ -582,14 +590,14 @@ ShowImageWindow::MessageReceived(BMessage *message)
pcurItem->SetMarked(true); pcurItem->SetMarked(true);
} }
} }
// Disable the Invert menu item if the bitmap color space // Disable the Invert menu item if the bitmap color space
// is B_CMAP8. (B_CMAP8 is currently unsupported by the // is B_CMAP8. (B_CMAP8 is currently unsupported by the
// invert algorithm) // invert algorithm)
color_space colors = B_NO_COLOR_SPACE; color_space colors = B_NO_COLOR_SPACE;
message->FindInt32("colors", reinterpret_cast<int32 *>(&colors)); message->FindInt32("colors", reinterpret_cast<int32 *>(&colors));
EnableMenuItem(fBar, MSG_INVERT, (colors != B_CMAP8)); EnableMenuItem(fBar, MSG_INVERT, (colors != B_CMAP8));
BString status; BString status;
bool messageProvidesSize = false; bool messageProvidesSize = false;
if (message->FindInt32("width", &fWidth) >= B_OK if (message->FindInt32("width", &fWidth) >= B_OK
@@ -597,20 +605,20 @@ ShowImageWindow::MessageReceived(BMessage *message)
status << fWidth << "x" << fHeight; status << fWidth << "x" << fHeight;
messageProvidesSize = true; messageProvidesSize = true;
} }
BString str; BString str;
if (message->FindString("status", &str) == B_OK && str.Length() > 0) { if (message->FindString("status", &str) == B_OK && str.Length() > 0) {
if (status.Length() > 0) if (status.Length() > 0)
status << ", "; status << ", ";
status << str; status << str;
} }
if (messageProvidesSize) { if (messageProvidesSize) {
UpdateResizerWindow(fWidth, fHeight); UpdateResizerWindow(fWidth, fHeight);
} }
fStatusView->SetText(status); fStatusView->SetText(status);
UpdateTitle(); UpdateTitle();
break; break;
} }
@@ -626,7 +634,7 @@ ShowImageWindow::MessageReceived(BMessage *message)
} }
break; break;
} }
case MSG_SELECTION: case MSG_SELECTION:
{ {
// The view sends this message when a selection is // The view sends this message when a selection is
@@ -708,7 +716,7 @@ ShowImageWindow::MessageReceived(BMessage *message)
if (message->FindInt32("page", &newPage) == B_OK) { if (message->FindInt32("page", &newPage) == B_OK) {
curPage = fImageView->CurrentPage(); curPage = fImageView->CurrentPage();
pages = fImageView->PageCount(); pages = fImageView->PageCount();
if (newPage > 0 && newPage <= pages) { if (newPage > 0 && newPage <= pages) {
BMenuItem *pcurItem, *pnewItem; BMenuItem *pcurItem, *pnewItem;
pcurItem = fGoToPageMenu->ItemAt(curPage - 1); pcurItem = fGoToPageMenu->ItemAt(curPage - 1);
@@ -845,11 +853,11 @@ ShowImageWindow::MessageReceived(BMessage *message)
int h = message->FindInt32("h"); int h = message->FindInt32("h");
fImageView->ResizeImage(w, h); fImageView->ResizeImage(w, h);
break; break;
} }
case MSG_RESIZER_WINDOW_QUIT: case MSG_RESIZER_WINDOW_QUIT:
fResizerWindowMessenger = NULL; fResizerWindowMessenger = NULL;
break; break;
case MSG_DESKTOP_BACKGROUND: case MSG_DESKTOP_BACKGROUND:
{ {
BPath path; BPath path;
@@ -900,7 +908,7 @@ ShowImageWindow::SaveAs(BMessage *message)
void void
ShowImageWindow::SaveToFile(BMessage *message) ShowImageWindow::SaveToFile(BMessage *message)
{ {
// Read in where the file should be saved // Read in where the file should be saved
entry_ref dirRef; entry_ref dirRef;
if (message->FindRef("directory", &dirRef) != B_OK) if (message->FindRef("directory", &dirRef) != B_OK)
return; return;
@@ -958,7 +966,7 @@ ShowImageWindow::ClosePrompt()
prompt << " (page " << page << ")"; prompt << " (page " << page << ")";
prompt << " has been changed. " prompt << " has been changed. "
<< "Do you want to close the document?"; << "Do you want to close the document?";
BAlert *pAlert = new BAlert("Close document", prompt.String(), BAlert *pAlert = new BAlert("Close document", prompt.String(),
"Cancel", "Close"); "Cancel", "Close");
if (pAlert->Go() == 0) { if (pAlert->Go() == 0) {
@@ -1011,13 +1019,13 @@ ShowImageWindow::LoadSettings()
if (settings->Lock()) { if (settings->Lock()) {
fShowCaption = settings->GetBool("ShowCaption", fShowCaption); fShowCaption = settings->GetBool("ShowCaption", fShowCaption);
fPrintOptions.SetBounds(BRect(0, 0, 1023, 767)); fPrintOptions.SetBounds(BRect(0, 0, 1023, 767));
int32 op = settings->GetInt32("PO:Option", fPrintOptions.Option()); int32 op = settings->GetInt32("PO:Option", fPrintOptions.Option());
fPrintOptions.SetOption((enum PrintOptions::Option)op); fPrintOptions.SetOption((enum PrintOptions::Option)op);
float f = settings->GetFloat("PO:ZoomFactor", fPrintOptions.ZoomFactor()); float f = settings->GetFloat("PO:ZoomFactor", fPrintOptions.ZoomFactor());
fPrintOptions.SetZoomFactor(f); fPrintOptions.SetZoomFactor(f);
f = settings->GetFloat("PO:DPI", fPrintOptions.DPI()); f = settings->GetFloat("PO:DPI", fPrintOptions.DPI());
fPrintOptions.SetDPI(f); fPrintOptions.SetDPI(f);
@@ -1099,7 +1107,7 @@ ShowImageWindow::Print(BMessage *msg)
if (printJob.ConfigJob() == B_OK) { if (printJob.ConfigJob() == B_OK) {
BRect printableRect = printJob.PrintableRect(); BRect printableRect = printJob.PrintableRect();
float width, w1, w2; float width, w1, w2;
// first/lastPage is unused for now // first/lastPage is unused for now
int32 firstPage = printJob.FirstPage(); int32 firstPage = printJob.FirstPage();
int32 lastPage = printJob.LastPage(); int32 lastPage = printJob.LastPage();
@@ -1123,10 +1131,10 @@ ShowImageWindow::Print(BMessage *msg)
break; break;
case PrintOptions::kZoomFactor: case PrintOptions::kZoomFactor:
width = imageWidth * fPrintOptions.ZoomFactor(); width = imageWidth * fPrintOptions.ZoomFactor();
break; break;
case PrintOptions::kDPI: case PrintOptions::kDPI:
width = imageWidth * 72.0 / fPrintOptions.DPI(); width = imageWidth * 72.0 / fPrintOptions.DPI();
break; break;
case PrintOptions::kWidth: case PrintOptions::kWidth:
case PrintOptions::kHeight: case PrintOptions::kHeight:
width = fPrintOptions.Width(); width = fPrintOptions.Width();
@@ -1134,7 +1142,7 @@ ShowImageWindow::Print(BMessage *msg)
default: default:
// keep compiler silent; should not reach here // keep compiler silent; should not reach here
width = imageWidth; width = imageWidth;
} }
// TODO: eventually print large images on several pages // TODO: eventually print large images on several pages
@@ -1149,7 +1157,8 @@ ShowImageWindow::Print(BMessage *msg)
} }
} }
void
void
ShowImageWindow::OpenResizerWindow(int32 width, int32 height) ShowImageWindow::OpenResizerWindow(int32 width, int32 height)
{ {
if (fResizerWindowMessenger == NULL) { if (fResizerWindowMessenger == NULL) {
@@ -1157,25 +1166,27 @@ ShowImageWindow::OpenResizerWindow(int32 width, int32 height)
BWindow* window = new ResizerWindow(this, width, height); BWindow* window = new ResizerWindow(this, width, height);
fResizerWindowMessenger = new BMessenger(window); fResizerWindowMessenger = new BMessenger(window);
window->Show(); window->Show();
} else } else
fResizerWindowMessenger->SendMessage(ResizerWindow::kActivateMsg); fResizerWindowMessenger->SendMessage(ResizerWindow::kActivateMsg);
} }
void
void
ShowImageWindow::UpdateResizerWindow(int32 width, int32 height) ShowImageWindow::UpdateResizerWindow(int32 width, int32 height)
{ {
if (fResizerWindowMessenger == NULL) { if (fResizerWindowMessenger == NULL) {
// window not opened // window not opened
return; return;
} }
BMessage updateMsg(ResizerWindow::kUpdateMsg); BMessage updateMsg(ResizerWindow::kUpdateMsg);
updateMsg.AddInt32("width", width); updateMsg.AddInt32("width", width);
updateMsg.AddInt32("height", height); updateMsg.AddInt32("height", height);
fResizerWindowMessenger->SendMessage(&updateMsg); fResizerWindowMessenger->SendMessage(&updateMsg);
} }
void
void
ShowImageWindow::CloseResizerWindow() ShowImageWindow::CloseResizerWindow()
{ {
if (fResizerWindowMessenger == NULL) { if (fResizerWindowMessenger == NULL) {
@@ -1185,7 +1196,8 @@ ShowImageWindow::CloseResizerWindow()
fResizerWindowMessenger->SendMessage(B_QUIT_REQUESTED); fResizerWindowMessenger->SendMessage(B_QUIT_REQUESTED);
fResizerWindowMessenger = NULL; fResizerWindowMessenger = NULL;
} }
bool bool
ShowImageWindow::QuitRequested() ShowImageWindow::QuitRequested()
{ {
@@ -1198,7 +1210,7 @@ ShowImageWindow::QuitRequested()
if (quit) { if (quit) {
CloseResizerWindow(); CloseResizerWindow();
// tell the app to forget about this window // tell the app to forget about this window
be_app->PostMessage(MSG_WINDOW_QUIT); be_app->PostMessage(MSG_WINDOW_QUIT);
} }
@@ -1212,4 +1224,3 @@ ShowImageWindow::ScreenChanged(BRect frame, color_space mode)
{ {
fImageView->SetDither(mode == B_CMAP8); fImageView->SetDither(mode == B_CMAP8);
} }