Added Go To Page submenu so the user can directly go to the page that they want. Also fixed a typo.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5290 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matthew Wilber
2003-11-09 14:10:26 +00:00
parent e6a50d9c7b
commit 6c3054116e
5 changed files with 76 additions and 2 deletions
+1
View File
@@ -46,6 +46,7 @@ const uint32 MSG_PAGE_FIRST = 'mPGF';
const uint32 MSG_PAGE_LAST = 'mPGL';
const uint32 MSG_PAGE_NEXT = 'mPGN';
const uint32 MSG_PAGE_PREV = 'mPGP';
const uint32 MSG_GOTO_PAGE = 'mGTP';
const uint32 MSG_FILE_NEXT = 'mFLN';
const uint32 MSG_FILE_PREV = 'mFLP';
const uint32 MSG_FIT_TO_WINDOW_SIZE = 'mFWS';
+9
View File
@@ -914,6 +914,15 @@ ShowImageView::PrevPage()
}
}
void
ShowImageView::GoToPage(int32 page)
{
if (page > 0 && page <= fDocumentCount && page != fDocumentIndex) {
fDocumentIndex = page;
SetImage(NULL);
}
}
void
ShowImageView::FreeEntries(BList* entries)
{
+1
View File
@@ -72,6 +72,7 @@ public:
void LastPage();
void NextPage();
void PrevPage();
void GoToPage(int32 page);
bool NextFile();
bool PrevFile();
void SetSlideShowDelay(float seconds);
+64 -2
View File
@@ -210,6 +210,8 @@ ShowImageWindow::LoadMenus(BMenuBar *pbar)
AddItemMenu(pmenu, "Last Page", MSG_PAGE_LAST, 'L', 0, 'W', true);
AddItemMenu(pmenu, "Next Page", MSG_PAGE_NEXT, 'N', 0, 'W', true);
AddItemMenu(pmenu, "Previous Page", MSG_PAGE_PREV, 'P', 0, 'W', true);
fpGoToPageMenu = new BMenu("Go To Page");
pmenu->AddItem(fpGoToPageMenu);
pmenu->AddSeparatorItem();
AddItemMenu(pmenu, "Next File", MSG_FILE_NEXT, B_DOWN_ARROW, 0, 'W', true);
AddItemMenu(pmenu, "Previous File", MSG_FILE_PREV, B_UP_ARROW, 0, 'W', true);
@@ -245,7 +247,7 @@ ShowImageWindow::LoadMenus(BMenuBar *pbar)
AddDelayItem(pDelay, "Eight Seconds", 8, false);
AddDelayItem(pDelay, "Nine Seconds", 9, false);
AddDelayItem(pDelay, "Ten Seconds", 10, false);
AddDelayItem(pDelay, "Tweenty Seconds", 20, false);
AddDelayItem(pDelay, "Twenty Seconds", 20, false);
pmenu->AddItem(pDelay);
pmenu->AddSeparatorItem();
AddItemMenu(pmenu, "Fit To Window Size", MSG_FIT_TO_WINDOW_SIZE, 0, 0, 'W', true);
@@ -386,11 +388,50 @@ ShowImageWindow::MessageReceived(BMessage *pmsg)
case MSG_UPDATE_STATUS:
{
bool benable = (fpImageView->PageCount() > 1) ? true : false;
int32 pages, curPage;
pages = fpImageView->PageCount();
curPage = fpImageView->CurrentPage();
bool benable = (pages > 1) ? true : false;
EnableMenuItem(MSG_PAGE_FIRST, benable);
EnableMenuItem(MSG_PAGE_LAST, benable);
EnableMenuItem(MSG_PAGE_NEXT, benable);
EnableMenuItem(MSG_PAGE_PREV, benable);
if (fpGoToPageMenu->CountItems() != pages) {
// Only rebuild the submenu if the number of
// pages is different
while (fpGoToPageMenu->CountItems() > 0)
// Remove all page numbers
delete fpGoToPageMenu->RemoveItem(0L);
for (int32 i = 1; i > 0 && i <= pages; i++) {
// Fill Go To page submenu with an entry for each page
BMessage *pgomsg;
pgomsg = new BMessage(MSG_GOTO_PAGE);
pgomsg->AddInt32("page", i);
BString strCaption;
strCaption << i;
BMenuItem *pitem;
pitem = new BMenuItem(strCaption.String(), pgomsg, 0);
if (curPage == i)
pitem->SetMarked(true);
fpGoToPageMenu->AddItem(pitem);
}
} else {
// Make sure the correct page is marked
BMenuItem *pcurItem;
pcurItem = fpGoToPageMenu->ItemAt(curPage - 1);
if (!pcurItem->IsMarked()) {
// If the current page isn't marked, unmark everything
// then mark the current page
int32 items = fpGoToPageMenu->CountItems();
for (int32 i = 0; i < items; i++)
fpGoToPageMenu->ItemAt(i)->SetMarked(false);
pcurItem->SetMarked(true);
}
}
BString str;
if (pmsg->FindString("status", &str) == B_OK)
@@ -431,6 +472,27 @@ ShowImageWindow::MessageReceived(BMessage *pmsg)
case MSG_PAGE_PREV:
fpImageView->PrevPage();
break;
case MSG_GOTO_PAGE:
{
int32 curPage, newPage, pages;
if (pmsg->FindInt32("page", &newPage) == B_OK) {
curPage = fpImageView->CurrentPage();
pages = fpImageView->PageCount();
if (newPage > 0 && newPage <= pages) {
BMenuItem *pcurItem, *pnewItem;
pcurItem = fpGoToPageMenu->ItemAt(curPage - 1);
pnewItem = fpGoToPageMenu->ItemAt(newPage - 1);
if (!pcurItem || !pnewItem)
break;
pcurItem->SetMarked(false);
pnewItem->SetMarked(true);
fpImageView->GoToPage(newPage);
}
}
}
break;
case MSG_DITHER_IMAGE:
ToggleMenuItem(pmsg->what);
+1
View File
@@ -82,6 +82,7 @@ private:
BMenuBar *fpBar;
BMenu *fpOpenMenu;
BMenu *fpBrowseMenu;
BMenu *fpGoToPageMenu;
ShowImageView *fpImageView;
ShowImageStatusView *fpStatusView;
bool fFullScreen;