OP_STATUS QuickPagingLayout::GoToPreviousPage() { if (HasPreviousPage()) return GoToPage(m_active_pos - 1); return OpStatus::ERR; }
OP_STATUS QuickPagingLayout::GoToNextPage() { if (HasNextPage()) return GoToPage(m_active_pos + 1); return OpStatus::ERR; }
OP_STATUS QuickPagingLayout::InsertPage(QuickWidget* content, int pos) { OpAutoPtr<QuickWidget> content_holder(content); if (pos == -1) pos = m_pages.GetCount(); RETURN_IF_ERROR(m_pages.Insert(pos, content)); content_holder.release(); content->SetContainer(this); if (m_active_pos < 0) { GoToPage(0); } else { content->SetParentOpWidget(0); if (pos <= m_active_pos) ++m_active_pos; } Invalidate(); return OpStatus::OK; }
bool EbookController::GoToPrevPage(bool toBottom) { int dist = IsDoublePage() ? 2 : 1; if (currPageNo - dist < 1) return false; GoToPage(currPageNo - dist, false); return true; }
bool EbookController::GoToNextPage() { int dist = IsDoublePage() ? 2 : 1; if (currPageNo + dist > PageCount()) return false; GoToPage(currPageNo + dist, false); return true; }
// (x, y) is in the coordinates of w void EbookController::ClickedProgress(Control *c, int x, int y) { CrashIf(c != ctrls->progress); float perc = ctrls->progress->GetPercAt(x); int pageCount = (int)GetPages()->Count(); int newPageNo = IntFromPerc(pageCount, perc) + 1; GoToPage(newPageNo, true); }
UINT32 GoToPageDialog::OnOk() { OpString url; GetWidgetText("Address_field", url); GoToPage(url, 0); return 0; }
void EbookController::ScrollToLink(PageDestination *dest) { int reparseIdx = dest->GetDestPageNo() - 1; int pageNo = PageForReparsePoint(pages, reparseIdx); if (pageNo > 0) GoToPage(pageNo, true); else if (0 == pageNo) GoToLastPage(); }
static VOID CALLBACK GoToPageURL(ULONG_PTR param) { HTMLControl *thisControl = (HTMLControl *)TlsGetValue(threadStorage); if (thisControl) { GoToPage(param); thisControl->Release(); } }
// Going forward is a special case in that's the only case where we don't // need pagesFromBeginning. If we're currently showing a page from pagesFromPage // we'll show the next page void EbookController::GoOnePageForward() { if (GoOnePageForward(pagesFromPage)) return; if (GoOnePageForward(&formattingTemp.pagesFromPage)) return; if (!GetPagesFromBeginning() || (0 == currPageNo)) return; GoToPage(currPageNo + 1); }
// (x, y) is in the coordinates of w void EbookController::ClickedProgress(Control *c, int x, int y) { CrashIf(c != ctrls->progress); float perc = ctrls->progress->GetPercAt(x); // TODO: shouldn't be active if we don't have pages from // beginnign, but happened in real life, crash 1096004 if (!GetPagesFromBeginning()) return; int pageCount = GetPagesFromBeginning()->Count(); int newPageNo = IntFromPerc(pageCount, perc) + 1; GoToPage(newPageNo); }
void EbookController::AdvancePage(int dist) { if (1 == dist) { // a special case for moving forward GoOnePageForward(); return; } // if we don't know at which page we're on, we can't advance relative to it if (0 == currPageNo) return; GoToPage(currPageNo + dist); }
void EbookController::Navigate(int dir) { if (!CanNavigate(dir)) return; // update the current history entry int idx = currPageReparseIdx; if (navHistoryIx < navHistory.Count()) navHistory.At(navHistoryIx) = idx; else navHistory.Append(idx); navHistoryIx += dir; idx = navHistory.At(navHistoryIx); int pageNo = PageForReparsePoint(pages, idx); if (0 == pageNo) pageNo = GetMaxPageCount(); if (pageNo > 0) GoToPage(pageNo, false); }
void EbookController::HandlePagesFromEbookLayout(EbookFormattingData *ft) { if (formattingThreadNo != ft->threadNo) { // this is a message from cancelled thread, we can disregard lf("EbookController::HandlePagesFromEbookLayout() thread msg discarded, curr thread: %d, sending thread: %d", formattingThreadNo, ft->threadNo); DeleteEbookFormattingData(ft); return; } //lf("EbookController::HandlePagesFromEbookLayout() %d pages, ft=0x%x", ft->pageCount, (int)ft); if (incomingPages) { for (size_t i = 0; i < ft->pageCount; i++) { incomingPages->Append(ft->pages[i]); } int pageNo = PageForReparsePoint(incomingPages, currPageReparseIdx); if (pageNo > 0) { Vec<HtmlPage*> *toDelete = pages; pages = incomingPages; incomingPages = nullptr; DeletePages(&toDelete); GoToPage(pageNo, false); } } else { CrashIf(!pages); for (size_t i = 0; i < ft->pageCount; i++) { pages->Append(ft->pages[i]); } } if (ft->finished) { CrashIf(!pages); StopFormattingThread(); } UpdateStatus(); // don't call DeleteEbookFormattingData since // ft->pages are now owned by incomingPages or pages delete ft; }
void QuickPagingLayout::RemovePage(int pos) { if (0 > pos || UINT32(pos) >= m_pages.GetCount()) { OP_ASSERT(!"Index out of bounds"); return; } m_pages.Remove(pos); if (pos == m_active_pos) { // If active page is removed, then make the first page active. m_active_pos = -1; if (m_pages.GetCount() > 0) GoToPage(0); } else if (pos < m_active_pos) { --m_active_pos; } Invalidate(); }
int AppBrowser (void) { Debug ("AppBrowser"); u32 btn; redraw = 1; appsSelected = -1; // Current selected app with wimote spotSelected = -1; spotSelectedLast = -1; browserRet = -1; grlibSettings.color_window = RGBA(192,192,192,255); grlibSettings.color_windowBg = RGBA(32,32,32,128); grlib_SetRedrawCallback (Redraw, Overlay); apps = (s_app*) vars.bigblock; //malloc (usedBytes); memset (apps, 0, APPSMAX * sizeof(s_app)); config.run.enabled = 0; // Immediately draw the screen... AppsFree (); InitializeGui (); /* Redraw (); grlib_PushScreen (); grlib_PopScreen (); grlib_Render(); // Render the frame buffer to the TV */ AppsBrowse (0); if (config.appPage >= 0 && config.appPage <= pageMax) page = config.appPage; else page = 0; FeedCoverCache (); LiveCheck (1); // Loop forever while (browserRet == -1) { if (LiveCheck (0)) redraw = 1; btn = grlib_GetUserInput(); // If [HOME] was pressed on the first Wiimote, break out of the loop if (btn) { browserRet = ChooseDPadReturnMode (btn); if (browserRet != -1) break; if (btn & WPAD_BUTTON_1) { spotSelected = -1; page = GoToPage (page, pageMax); FeedCoverCache (); redraw = 1; } if (btn & WPAD_BUTTON_2) { ShowFilterMenu(); redraw = 1; } if (btn & WPAD_BUTTON_A && appsSelected != -1 && sortMode == 0) { if (apps[appsSelected].type == AT_HBA) { if (!QuerySelection (appsSelected)) { redraw = 1; continue; } AppsSetRun (appsSelected); browserRet = INTERACTIVE_RET_HBSEL; break; } else if (apps[appsSelected].type == AT_FOLDER) // This is a folder ! Jump inside { sprintf (config.subpath, "%s/", apps[appsSelected].path); sprintf (config.submount, "%s", apps[appsSelected].mount); AppsBrowse (0); redraw = 1; } else if (apps[appsSelected].type == AT_FOLDERUP) // This is a folder ! Jump inside { int i = strlen(config.subpath); if (i > 0) i--; if (i > 0) i--; while (i >= 0 && config.subpath[i] != '/') config.subpath[i--] = 0; gui.spotsIdx = 0; AppsBrowse (0); redraw = 1; } } ///////////////////////////////////////////////////////////////////////////////////////////// // We are in sort mode, check item if (btn & WPAD_BUTTON_A && appsSelected != -1 && sortMode > 0) { if (!apps[appsSelected].checked) { apps[appsSelected].priority = sortMode--; apps[appsSelected].checked = TRUE; redraw = 1; //Debug ("selected %s (%d)\n", apps[appsSelected].name, apps[appsSelected].priority); } else { } } ///////////////////////////////////////////////////////////////////////////////////////////// // Select application as default if (btn & WPAD_BUTTON_B && appsSelected != -1 && sortMode == 0) { ShowAppMenu (appsSelected); redraw = 1; } ///////////////////////////////////////////////////////////////////////////////////////////// // If user press (B) stop sort mode if (btn & WPAD_BUTTON_B && sortMode > 0) { SortItems(); int i; for (i = 0; i < appsCnt; i++) { apps[i].priority = appsCnt - i; apps[i].checked = FALSE; } sortMode = 0; needToSave = 1; redraw = 1; } if (btn & WPAD_BUTTON_HOME && sortMode > 0) { grlib_menu (0, "You are in sort mode.\n", "Close"); redraw = 1; } if (btn & WPAD_BUTTON_HOME && sortMode == 0) { ShowMainMenu (); redraw = 1; } if (btn & WPAD_BUTTON_MINUS) { page = ChangePage (0); } if (btn & WPAD_BUTTON_PLUS) { page = ChangePage (1); } } if (CoverCache_IsUpdated ()) { redraw = 1; } FindSpot (); if (redraw) { Redraw (); grlib_PushScreen (); redraw = 0; } REDRAW(); if (grlibSettings.wiiswitch_poweroff) { browserRet = INTERACTIVE_RET_SHUTDOWN; } if (grlibSettings.wiiswitch_reset) { browserRet = INTERACTIVE_RET_WIIMENU; } if (wiiload.status == WIILOAD_HBZREADY) { WiiloadZipMenu (); AppsBrowse (0); redraw = 1; } if (wiiload.status == WIILOAD_HBREADY) { if (WiiloadCheck()) browserRet = INTERACTIVE_RET_WIILOAD; else redraw = 1; } if (vars.themeReloaded) // Restart the browser { vars.themeReloaded = 0; browserRet = INTERACTIVE_RET_TOHOMEBREW; } } // Lets close the topbar, if needed CLOSETOPBAR(); CLOSEBOTTOMBAR(); // save current page config.appPage = page; SaveSettings (); // Clean up all data AppsFree (); gui_Clean (); //free (apps); grlib_SetRedrawCallback (NULL, NULL); return browserRet; }
BOOL GoToPageDialog::OnInputAction(OpInputAction* action) { switch (action->GetAction()) { case OpInputAction::ACTION_GO_TO_PAGE: case OpInputAction::ACTION_GO_TO_TYPED_ADDRESS: { OpString url; GetWidgetText("Address_field", url); CloseDialog(FALSE); GoToPage(url, action); return TRUE; break; } case OpInputAction::ACTION_GO: { OpEdit* widget = (OpEdit*) GetWidgetByName("Nick_field"); if(widget) { OpString nick; GetWidgetText("Nick_field", nick); if(g_hotlist_manager->HasNickname(nick, NULL, TRUE, TRUE)) { CloseDialog(FALSE); OpenNickname(nick,TRUE); } } return TRUE; break; } case OpInputAction::ACTION_PASTE_AND_GO: case OpInputAction::ACTION_PASTE_AND_GO_BACKGROUND: { OpString text; g_desktop_clipboard_manager->GetText(text); if (text.HasContent()) { OpAddressDropDown* dropdown = (OpAddressDropDown*) GetWidgetByName("Address_field"); if (dropdown) dropdown->EmulatePaste(text); // This is a bit tricky. Paste&Go has a default shortcut that includes Ctrl and Shift which // normally redirects a url to a new tab. That is why we test IsKeyboardInvoked() below. In // addition the 'NewWindow' pref tells us to open in a new tab/window no matter what (DSK-313944) if (g_pcdoc->GetIntegerPref(PrefsCollectionDoc::NewWindow)) { if (g_application->IsSDI()) g_input_manager->InvokeAction(OpInputAction::ACTION_OPEN_URL_IN_NEW_WINDOW, 0, text.CStr()); else { BOOL bg = action->GetAction() == OpInputAction::ACTION_PASTE_AND_GO_BACKGROUND; g_application->GoToPage(text, TRUE, bg, TRUE, NULL, (URL_CONTEXT_ID)-1, action->IsKeyboardInvoked()); } } else { BOOL bg = action->GetAction() == OpInputAction::ACTION_PASTE_AND_GO_BACKGROUND; g_application->GoToPage(text, bg, bg, TRUE, NULL, (URL_CONTEXT_ID)-1, action->IsKeyboardInvoked()); } CloseDialog(FALSE); } return TRUE; break; } #ifdef _X11_SELECTION_POLICY_ case OpInputAction::ACTION_PASTE_SELECTION_AND_GO: case OpInputAction::ACTION_PASTE_SELECTION_AND_GO_BACKGROUND: { OpString text; g_desktop_clipboard_manager->GetText(text, true); if (text.HasContent()) { OpAddressDropDown* dropdown = (OpAddressDropDown*) GetWidgetByName("Address_field"); if (dropdown) dropdown->EmulatePaste(text); BOOL bg = action->GetAction() == OpInputAction::ACTION_PASTE_SELECTION_AND_GO_BACKGROUND; if (g_pcdoc->GetIntegerPref(PrefsCollectionDoc::NewWindow)) { if (g_application->IsSDI()) g_input_manager->InvokeAction(OpInputAction::ACTION_OPEN_URL_IN_NEW_WINDOW, 0, text.CStr()); else g_application->GoToPage(text, TRUE, bg, TRUE, NULL, (URL_CONTEXT_ID)-1, action->IsKeyboardInvoked()); } else g_application->GoToPage(text.CStr(), bg, bg, TRUE, NULL, (URL_CONTEXT_ID)-1, action->IsKeyboardInvoked()); } return TRUE; } #endif case OpInputAction::ACTION_OPEN_URL_IN_CURRENT_PAGE: { // If Opera is configured not to reuse pages, it should be opened // in a new page or new window instead of in the current page if (g_pcdoc->GetIntegerPref(PrefsCollectionDoc::NewWindow)) { if (g_application->IsSDI()) g_input_manager->InvokeAction(OpInputAction::ACTION_OPEN_URL_IN_NEW_WINDOW, action->GetActionData(), action->GetActionDataString(), this); else // tabbed or MDI g_input_manager->InvokeAction(OpInputAction::ACTION_OPEN_URL_IN_NEW_PAGE, action->GetActionData(), action->GetActionDataString(), this); CloseDialog(FALSE); return TRUE; } // fall through } case OpInputAction::ACTION_OPEN_URL_IN_NEW_PAGE: case OpInputAction::ACTION_OPEN_URL_IN_NEW_BACKGROUND_PAGE: case OpInputAction::ACTION_OPEN_URL_IN_NEW_WINDOW: { CloseDialog(FALSE); // Do not kill the action, underlying components will handled it (application), // only close the dialog because the user is done entering a url in the addressdropdown return FALSE; } } return Dialog::OnInputAction(action); }
void EbookController::GoToLastPage() { if (GetPagesFromBeginning()) GoToPage(GetPagesFromBeginning()->Count()); }
OP_STATUS QuickPagingLayout::GoToPage(const QuickWidget* content) { const INT32 pos = m_pages.Find(const_cast<QuickWidget*>(content)); return pos >= 0 ? GoToPage(pos) : OpStatus::ERR; }