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:
@@ -46,6 +46,7 @@ const uint32 MSG_PAGE_FIRST = 'mPGF';
|
|||||||
const uint32 MSG_PAGE_LAST = 'mPGL';
|
const uint32 MSG_PAGE_LAST = 'mPGL';
|
||||||
const uint32 MSG_PAGE_NEXT = 'mPGN';
|
const uint32 MSG_PAGE_NEXT = 'mPGN';
|
||||||
const uint32 MSG_PAGE_PREV = 'mPGP';
|
const uint32 MSG_PAGE_PREV = 'mPGP';
|
||||||
|
const uint32 MSG_GOTO_PAGE = 'mGTP';
|
||||||
const uint32 MSG_FILE_NEXT = 'mFLN';
|
const uint32 MSG_FILE_NEXT = 'mFLN';
|
||||||
const uint32 MSG_FILE_PREV = 'mFLP';
|
const uint32 MSG_FILE_PREV = 'mFLP';
|
||||||
const uint32 MSG_FIT_TO_WINDOW_SIZE = 'mFWS';
|
const uint32 MSG_FIT_TO_WINDOW_SIZE = 'mFWS';
|
||||||
|
|||||||
@@ -914,6 +914,15 @@ ShowImageView::PrevPage()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ShowImageView::GoToPage(int32 page)
|
||||||
|
{
|
||||||
|
if (page > 0 && page <= fDocumentCount && page != fDocumentIndex) {
|
||||||
|
fDocumentIndex = page;
|
||||||
|
SetImage(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShowImageView::FreeEntries(BList* entries)
|
ShowImageView::FreeEntries(BList* entries)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ public:
|
|||||||
void LastPage();
|
void LastPage();
|
||||||
void NextPage();
|
void NextPage();
|
||||||
void PrevPage();
|
void PrevPage();
|
||||||
|
void GoToPage(int32 page);
|
||||||
bool NextFile();
|
bool NextFile();
|
||||||
bool PrevFile();
|
bool PrevFile();
|
||||||
void SetSlideShowDelay(float seconds);
|
void SetSlideShowDelay(float seconds);
|
||||||
|
|||||||
@@ -210,6 +210,8 @@ ShowImageWindow::LoadMenus(BMenuBar *pbar)
|
|||||||
AddItemMenu(pmenu, "Last Page", MSG_PAGE_LAST, 'L', 0, 'W', true);
|
AddItemMenu(pmenu, "Last Page", MSG_PAGE_LAST, 'L', 0, 'W', true);
|
||||||
AddItemMenu(pmenu, "Next Page", MSG_PAGE_NEXT, 'N', 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);
|
AddItemMenu(pmenu, "Previous Page", MSG_PAGE_PREV, 'P', 0, 'W', true);
|
||||||
|
fpGoToPageMenu = new BMenu("Go To Page");
|
||||||
|
pmenu->AddItem(fpGoToPageMenu);
|
||||||
pmenu->AddSeparatorItem();
|
pmenu->AddSeparatorItem();
|
||||||
AddItemMenu(pmenu, "Next File", MSG_FILE_NEXT, B_DOWN_ARROW, 0, 'W', true);
|
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);
|
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, "Eight Seconds", 8, false);
|
||||||
AddDelayItem(pDelay, "Nine Seconds", 9, false);
|
AddDelayItem(pDelay, "Nine Seconds", 9, false);
|
||||||
AddDelayItem(pDelay, "Ten Seconds", 10, false);
|
AddDelayItem(pDelay, "Ten Seconds", 10, false);
|
||||||
AddDelayItem(pDelay, "Tweenty Seconds", 20, false);
|
AddDelayItem(pDelay, "Twenty Seconds", 20, false);
|
||||||
pmenu->AddItem(pDelay);
|
pmenu->AddItem(pDelay);
|
||||||
pmenu->AddSeparatorItem();
|
pmenu->AddSeparatorItem();
|
||||||
AddItemMenu(pmenu, "Fit To Window Size", MSG_FIT_TO_WINDOW_SIZE, 0, 0, 'W', true);
|
AddItemMenu(pmenu, "Fit To Window Size", MSG_FIT_TO_WINDOW_SIZE, 0, 0, 'W', true);
|
||||||
@@ -386,12 +388,51 @@ ShowImageWindow::MessageReceived(BMessage *pmsg)
|
|||||||
|
|
||||||
case MSG_UPDATE_STATUS:
|
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_FIRST, benable);
|
||||||
EnableMenuItem(MSG_PAGE_LAST, benable);
|
EnableMenuItem(MSG_PAGE_LAST, benable);
|
||||||
EnableMenuItem(MSG_PAGE_NEXT, benable);
|
EnableMenuItem(MSG_PAGE_NEXT, benable);
|
||||||
EnableMenuItem(MSG_PAGE_PREV, 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;
|
BString str;
|
||||||
if (pmsg->FindString("status", &str) == B_OK)
|
if (pmsg->FindString("status", &str) == B_OK)
|
||||||
fpStatusView->SetText(str);
|
fpStatusView->SetText(str);
|
||||||
@@ -432,6 +473,27 @@ ShowImageWindow::MessageReceived(BMessage *pmsg)
|
|||||||
fpImageView->PrevPage();
|
fpImageView->PrevPage();
|
||||||
break;
|
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:
|
case MSG_DITHER_IMAGE:
|
||||||
ToggleMenuItem(pmsg->what);
|
ToggleMenuItem(pmsg->what);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ private:
|
|||||||
BMenuBar *fpBar;
|
BMenuBar *fpBar;
|
||||||
BMenu *fpOpenMenu;
|
BMenu *fpOpenMenu;
|
||||||
BMenu *fpBrowseMenu;
|
BMenu *fpBrowseMenu;
|
||||||
|
BMenu *fpGoToPageMenu;
|
||||||
ShowImageView *fpImageView;
|
ShowImageView *fpImageView;
|
||||||
ShowImageStatusView *fpStatusView;
|
ShowImageStatusView *fpStatusView;
|
||||||
bool fFullScreen;
|
bool fFullScreen;
|
||||||
|
|||||||
Reference in New Issue
Block a user