本文整理汇总了C++中WindowInfo类的典型用法代码示例。如果您正苦于以下问题:C++ WindowInfo类的具体用法?C++ WindowInfo怎么用?C++ WindowInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WindowInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindWindowInfoByFile
// Synchronization command format:
// [<DDECOMMAND_SYNC>(["<pdffile>",]"<srcfile>",<line>,<col>[,<newwindow>,<setfocus>])]
static const WCHAR *HandleSyncCmd(const WCHAR *cmd, DDEACK& ack)
{
ScopedMem<WCHAR> pdfFile, srcFile;
BOOL line = 0, col = 0, newWindow = 0, setFocus = 0;
const WCHAR *next = str::Parse(cmd, L"[" DDECOMMAND_SYNC L"(\"%S\",%? \"%S\",%u,%u)]",
&pdfFile, &srcFile, &line, &col);
if (!next)
next = str::Parse(cmd, L"[" DDECOMMAND_SYNC L"(\"%S\",%? \"%S\",%u,%u,%u,%u)]",
&pdfFile, &srcFile, &line, &col, &newWindow, &setFocus);
// allow to omit the pdffile path, so that editors don't have to know about
// multi-file projects (requires that the PDF has already been opened)
if (!next) {
pdfFile.Set(NULL);
next = str::Parse(cmd, L"[" DDECOMMAND_SYNC L"(\"%S\",%u,%u)]",
&srcFile, &line, &col);
if (!next)
next = str::Parse(cmd, L"[" DDECOMMAND_SYNC L"(\"%S\",%u,%u,%u,%u)]",
&srcFile, &line, &col, &newWindow, &setFocus);
}
if (!next)
return NULL;
WindowInfo *win = NULL;
if (pdfFile) {
// check if the PDF is already opened
win = FindWindowInfoByFile(pdfFile);
// if not then open it
if (newWindow || !win) {
LoadArgs args(pdfFile, !newWindow ? win : NULL);
win = LoadDocument(args);
} else if (win && !win->IsDocLoaded()) {
ReloadDocument(win);
}
}
else {
// check if any opened PDF has sync information for the source file
win = FindWindowInfoBySyncFile(srcFile);
if (newWindow) {
LoadArgs args(win->loadedFilePath);
win = LoadDocument(args);
}
}
if (!win || !win->IsDocLoaded())
return next;
if (!win->pdfsync)
return next;
ack.fAck = 1;
assert(win->IsDocLoaded());
UINT page;
Vec<RectI> rects;
int ret = win->pdfsync->SourceToDoc(srcFile, line, col, &page, rects);
ShowForwardSearchResult(win, srcFile, line, col, ret, page, rects);
if (setFocus)
win->Focus();
return next;
}
示例2: AddTocItemToView
static HTREEITEM AddTocItemToView(HWND hwnd, DocTocItem *entry, HTREEITEM parent, bool toggleItem)
{
TV_INSERTSTRUCT tvinsert;
tvinsert.hParent = parent;
tvinsert.hInsertAfter = TVI_LAST;
tvinsert.itemex.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE;
tvinsert.itemex.state = entry->child && entry->open != toggleItem ? TVIS_EXPANDED : 0;
tvinsert.itemex.stateMask = TVIS_EXPANDED;
tvinsert.itemex.lParam = (LPARAM)entry;
// Replace unprintable whitespace with regular spaces
str::NormalizeWS(entry->title);
tvinsert.itemex.pszText = entry->title;
#ifdef DISPLAY_TOC_PAGE_NUMBERS
WindowInfo *win = FindWindowInfoByHwnd(hwnd);
if (entry->pageNo && win && win->IsDocLoaded() && !win->AsEbook()) {
ScopedMem<WCHAR> label(win->ctrl->GetPageLabel(entry->pageNo));
ScopedMem<WCHAR> text(str::Format(L"%s %s", entry->title, label));
tvinsert.itemex.pszText = text;
return TreeView_InsertItem(hwnd, &tvinsert);
}
#endif
return TreeView_InsertItem(hwnd, &tvinsert);
}
示例3: fullPath
void LinkHandler::LaunchFile(const WCHAR *path, PageDestination *link)
{
// for safety, only handle relative paths and only open them in SumatraPDF
// (unless they're of an allowed perceived type) and never launch any external
// file in plugin mode (where documents are supposed to be self-contained)
WCHAR drive;
if (str::StartsWith(path, L"\\") || str::Parse(path, L"%c:\\", &drive) || gPluginMode) {
return;
}
ScopedMem<WCHAR> fullPath(path::GetDir(owner->dm->FilePath()));
fullPath.Set(path::Join(fullPath, path));
fullPath.Set(path::Normalize(fullPath));
// TODO: respect link->ld.gotor.new_window for PDF documents ?
WindowInfo *newWin = FindWindowInfoByFile(fullPath);
// TODO: don't show window until it's certain that there was no error
if (!newWin) {
LoadArgs args(fullPath, owner);
newWin = LoadDocument(args);
if (!newWin)
return;
}
if (!newWin->IsDocLoaded()) {
CloseWindow(newWin, true);
// OpenFileExternally rejects files we'd otherwise
// have to show a notification to be sure (which we
// consider bad UI and thus simply don't)
bool ok = OpenFileExternally(fullPath);
if (!ok) {
ScopedMem<WCHAR> msg(str::Format(_TR("Error loading %s"), fullPath));
ShowNotification(owner, msg, true /* autoDismiss */, true /* highlight */);
}
return;
}
newWin->Focus();
if (!link)
return;
ScopedMem<WCHAR> name(link->GetDestName());
if (!name)
newWin->linkHandler->ScrollTo(link);
else {
PageDestination *dest = newWin->dm->engine->GetNamedDest(name);
if (dest) {
newWin->linkHandler->ScrollTo(dest);
delete dest;
}
}
}
示例4: GetDocForWindow
Doc GetDocForWindow(SumatraWindow& win)
{
if (win.AsWindowInfo()) {
WindowInfo *iwin = win.AsWindowInfo();
if (!iwin->IsDocLoaded())
return Doc();
return Doc(iwin->dm->engine, iwin->dm->engineType);
}
if (win.AsEbookWindow()) {
EbookWindow *ewin = win.AsEbookWindow();
return ewin->ebookController->GetDoc();
}
CrashIf(true);
return Doc();
}
示例5: GetStressTestInfo
// note: used from CrashHandler.cpp, should not allocate memory
void GetStressTestInfo(str::Str<char>* s)
{
// only add paths to files encountered during an explicit stress test
// (for privacy reasons, users should be able to decide themselves
// whether they want to share what files they had opened during a crash)
if (!IsStressTesting())
return;
for (size_t i = 0; i < gWindows.Count(); i++) {
WindowInfo *w = gWindows.At(i);
if (!w || !w->IsDocLoaded() || !w->loadedFilePath)
continue;
s->Append("File: ");
char buf[256];
str::conv::ToCodePageBuf(buf, dimof(buf), w->loadedFilePath, CP_UTF8);
s->Append(buf);
w->stressTest->GetLogInfo(s);
s->Append("\r\n");
}
}
示例6: args
static WindowInfo *LoadOnStartup(const TCHAR *filePath, CommandLineInfo& i, bool isFirstWin)
{
bool showWin = !(i.printDialog && i.exitOnPrint) && !gPluginMode;
LoadArgs args(filePath, NULL, showWin);
WindowInfo *win = LoadDocument(args);
if (!win)
return win;
if (win->IsDocLoaded() && i.destName && isFirstWin) {
win->linkHandler->GotoNamedDest(i.destName);
} else if (win->IsDocLoaded() && i.pageNumber > 0 && isFirstWin) {
if (win->dm->ValidPageNo(i.pageNumber))
win->dm->GoToPage(i.pageNumber, 0);
}
if (i.hwndPluginParent)
MakePluginWindow(*win, i.hwndPluginParent);
if (!win->IsDocLoaded() || !isFirstWin)
return win;
if (i.enterPresentation || i.enterFullscreen)
EnterFullscreen(*win, i.enterPresentation);
if (i.startView != DM_AUTOMATIC)
SwitchToDisplayMode(win, i.startView);
if (i.startZoom != INVALID_ZOOM)
ZoomToSelection(win, i.startZoom);
if (i.startScroll.x != -1 || i.startScroll.y != -1) {
ScrollState ss = win->dm->GetScrollState();
ss.x = i.startScroll.x;
ss.y = i.startScroll.y;
win->dm->SetScrollState(ss);
}
if (i.forwardSearchOrigin && i.forwardSearchLine && win->pdfsync) {
UINT page;
Vec<RectI> rects;
ScopedMem<TCHAR> sourcePath(path::Normalize(i.forwardSearchOrigin));
int ret = win->pdfsync->SourceToDoc(sourcePath, i.forwardSearchLine, 0, &page, rects);
ShowForwardSearchResult(win, sourcePath, i.forwardSearchLine, 0, ret, page, rects);
}
return win;
}
示例7: Execute
virtual void Execute() {
if (!WindowInfoStillValid(win))
return;
SetForegroundWindow(win->hwndFrame);
if (win->IsDocLoaded()) {
if (-1 != pageNo)
win->dm->GoToPage(pageNo, 0, true);
// we might have been invoked by clicking on a tree view
// switch focus so that keyboard navigation works, which enables
// a fluid experience
SetFocus(win->hwndFrame);
}
}
示例8: scroll
// Set view mode and zoom level. Format:
// [<DDECOMMAND_SETVIEW>("<pdffilepath>", "<view mode>", <zoom level>[, <scrollX>, <scrollY>])]
static const WCHAR *HandleSetViewCmd(const WCHAR *cmd, DDEACK& ack)
{
ScopedMem<WCHAR> pdfFile, viewMode;
float zoom = INVALID_ZOOM;
PointI scroll(-1, -1);
const WCHAR *next = str::Parse(cmd, L"[" DDECOMMAND_SETVIEW L"(\"%S\",%? \"%S\",%f)]",
&pdfFile, &viewMode, &zoom);
if (!next)
next = str::Parse(cmd, L"[" DDECOMMAND_SETVIEW L"(\"%S\",%? \"%S\",%f,%d,%d)]",
&pdfFile, &viewMode, &zoom, &scroll.x, &scroll.y);
if (!next)
return NULL;
WindowInfo *win = FindWindowInfoByFile(pdfFile);
if (!win)
return next;
if (!win->IsDocLoaded()) {
ReloadDocument(win);
if (!win->IsDocLoaded())
return next;
}
DisplayMode mode = DisplayModeConv::EnumFromName(viewMode, DM_AUTOMATIC);
if (mode != DM_AUTOMATIC)
SwitchToDisplayMode(win, mode);
if (zoom != INVALID_ZOOM)
ZoomToSelection(win, zoom);
if (scroll.x != -1 || scroll.y != -1) {
ScrollState ss = win->dm->GetScrollState();
ss.x = scroll.x;
ss.y = scroll.y;
win->dm->SetScrollState(ss);
}
ack.fAck = 1;
return next;
}
示例9: ShowSearchResult
static void ShowSearchResult(WindowInfo& win, TextSel *result, bool addNavPt)
{
CrashIf(0 == result->len || !result->pages || !result->rects);
if (0 == result->len || !result->pages || !result->rects)
return;
if (addNavPt || !win.dm->PageShown(result->pages[0]) ||
(win.dm->ZoomVirtual() == ZOOM_FIT_PAGE || win.dm->ZoomVirtual() == ZOOM_FIT_CONTENT))
{
win.dm->GoToPage(result->pages[0], 0, addNavPt);
}
win.dm->textSelection->CopySelection(win.dm->textSearch);
UpdateTextSelection(&win, false);
win.dm->ShowResultRectToScreen(result);
win.RepaintAsync();
}
示例10: Execute
virtual void Execute() {
if (!WindowInfoStillValid(win))
return;
if (win->findThread != thread) {
// Race condition: FindTextOnThread/AbortFinding was
// called after the previous find thread ended but
// before this FindEndTask could be executed
return;
}
if (!win->IsDocLoaded()) {
// the UI has already been disabled and hidden
} else if (textSel) {
ShowSearchResult(*win, textSel, wasModifiedCanceled);
ftd->HideUI(true, loopedAround);
} else {
// nothing found or search canceled
ClearSearchResult(win);
ftd->HideUI(false, !wasModifiedCanceled);
}
win->findThread = NULL;
}
示例11: if
WindowElement::WindowElement(WindowInfo info, QObject *parent) :
QObject(parent),
m_title(info.title()),
m_windowId(info.window())
{
SystemIconProvider provider;
if (info.icon())
m_pixmap = QPixmap::fromX11Pixmap(info.icon());
else if (!info.iconName().isEmpty())
{
m_pixmap = provider.requestPixmap(info.iconName(), NULL, QSize());
}
else
{
// App icon wasn't set, and iconName wasn't set... fallback to default
m_pixmap = provider.requestPixmap("default", NULL, QSize());
}
if (!info.notificationIconName().isEmpty())
{
m_notify = provider.requestPixmap(info.notificationIconName(), NULL, QSize());
}
}
示例12: CrashIf
void LinkHandler::GotoLink(PageDestination *link)
{
CrashIf(!owner || owner->linkHandler != this);
if (!link || !owner->IsDocLoaded())
return;
ScopedMem<WCHAR> path(link->GetDestValue());
PageDestType type = link->GetDestType();
if (Dest_ScrollTo == type) {
// TODO: respect link->ld.gotor.new_window for PDF documents ?
ScrollTo(link);
}
else if (Dest_LaunchURL == type) {
if (!path)
/* ignore missing URLs */;
else {
WCHAR *colon = str::FindChar(path, ':');
WCHAR *hash = str::FindChar(path, '#');
if (!colon || (hash && colon > hash)) {
// treat relative URIs as file paths (without fragment identifier)
if (hash)
*hash = '\0';
// LaunchFile will reject unsupported file types
LaunchFile(path, NULL);
}
else {
// LaunchBrowser will reject unsupported URI schemes
LaunchBrowser(path);
}
}
}
else if (Dest_LaunchEmbedded == type) {
// open embedded PDF documents in a new window
if (path && str::StartsWith(path.Get(), owner->ctrl->FilePath())) {
WindowInfo *newWin = FindWindowInfoByFile(path, true);
if (!newWin) {
LoadArgs args(path, owner);
newWin = LoadDocument(args);
}
if (newWin)
newWin->Focus();
}
// offer to save other attachments to a file
else {
LinkSaver linkSaverTmp(*owner, path);
link->SaveEmbedded(linkSaverTmp);
}
}
else if (Dest_LaunchFile == type) {
if (path) {
// LaunchFile only opens files inside SumatraPDF
// (except for allowed perceived file types)
LaunchFile(path, link);
}
}
// predefined named actions
else if (Dest_NextPage == type)
owner->ctrl->GoToNextPage();
else if (Dest_PrevPage == type)
owner->ctrl->GoToPrevPage();
else if (Dest_FirstPage == type)
owner->ctrl->GoToFirstPage();
else if (Dest_LastPage == type)
owner->ctrl->GoToLastPage();
// Adobe Reader extensions to the spec, cf. http://www.tug.org/applications/hyperref/manual.html
else if (Dest_FindDialog == type)
PostMessage(owner->hwndFrame, WM_COMMAND, IDM_FIND_FIRST, 0);
else if (Dest_FullScreen == type)
PostMessage(owner->hwndFrame, WM_COMMAND, IDM_VIEW_PRESENTATION_MODE, 0);
else if (Dest_GoBack == type)
owner->ctrl->Navigate(-1);
else if (Dest_GoForward == type)
owner->ctrl->Navigate(1);
else if (Dest_GoToPageDialog == type)
PostMessage(owner->hwndFrame, WM_COMMAND, IDM_GOTO_PAGE, 0);
else if (Dest_PrintDialog == type)
PostMessage(owner->hwndFrame, WM_COMMAND, IDM_PRINT, 0);
else if (Dest_SaveAsDialog == type)
PostMessage(owner->hwndFrame, WM_COMMAND, IDM_SAVEAS, 0);
else if (Dest_ZoomToDialog == type)
PostMessage(owner->hwndFrame, WM_COMMAND, IDM_ZOOM_CUSTOM, 0);
else
CrashIf(Dest_None != type);
}
示例13: rand
bool StressTest::OpenFile(const TCHAR *fileName)
{
bool reuse = rand() % 3 != 1;
_tprintf(_T("%s\n"), fileName);
fflush(stdout);
LoadArgs args(fileName, NULL, true /* show */, reuse);
WindowInfo *w = LoadDocument(args);
if (!w)
return false;
if (w == win) { // WindowInfo reused
if (!win->dm)
return false;
} else if (!w->dm) { // new WindowInfo
CloseWindow(w, false, true);
return false;
}
// transfer ownership of stressTest object to a new window and close the
// current one
assert(this == win->stressTest);
if (w != win) {
if (win->IsDocLoaded()) {
// try to provoke a crash in RenderCache cleanup code
ClientRect rect(win->hwndFrame);
rect.Inflate(rand() % 10, rand() % 10);
SendMessage(win->hwndFrame, WM_SIZE, 0, MAKELONG(rect.dx, rect.dy));
win->RenderPage(1);
win->RepaintAsync();
}
WindowInfo *toClose = win;
w->stressTest = win->stressTest;
win->stressTest = NULL;
win = w;
CloseWindow(toClose, false, false);
}
if (!win->dm)
return false;
win->dm->ChangeDisplayMode(DM_CONTINUOUS);
win->dm->ZoomTo(ZOOM_FIT_PAGE);
win->dm->GoToFirstPage();
if (win->tocVisible || gGlobalPrefs.favVisible)
SetSidebarVisibility(win, win->tocVisible, gGlobalPrefs.favVisible);
currPage = pageRanges.At(0).start;
win->dm->GoToPage(currPage, 0);
currPageRenderTime.Start();
++filesCount;
pageForSearchStart = (rand() % win->dm->PageCount()) + 1;
// search immediately in single page documents
if (1 == pageForSearchStart) {
// use text that is unlikely to be found, so that we search all pages
win::SetText(win->hwndFindBox, _T("!z_yt"));
FindTextOnThread(win);
}
int secs = SecsSinceSystemTime(stressStartTime);
ScopedMem<TCHAR> tm(FormatTime(secs));
ScopedMem<TCHAR> s(str::Format(_T("File %d: %s, time: %s"), filesCount, fileName, tm));
ShowNotification(win, s, false, false, NG_STRESS_TEST_SUMMARY);
return true;
}
示例14: wprintf
bool StressTest::OpenFile(const WCHAR* fileName) {
wprintf(L"%s\n", fileName);
fflush(stdout);
LoadArgs args(fileName);
args.forceReuse = rand() % 3 != 1;
WindowInfo* w = LoadDocument(args);
if (!w)
return false;
if (w == win) { // WindowInfo reused
if (!win->IsDocLoaded())
return false;
} else if (!w->IsDocLoaded()) { // new WindowInfo
CloseWindow(w, false);
return false;
}
// transfer ownership of stressTest object to a new window and close the
// current one
AssertCrash(this == win->stressTest);
if (w != win) {
if (win->IsDocLoaded()) {
// try to provoke a crash in RenderCache cleanup code
ClientRect rect(win->hwndFrame);
rect.Inflate(rand() % 10, rand() % 10);
SendMessage(win->hwndFrame, WM_SIZE, 0, MAKELONG(rect.dx, rect.dy));
if (win->AsFixed())
win->cbHandler->RequestRendering(1);
win->RepaintAsync();
}
WindowInfo* toClose = win;
w->stressTest = win->stressTest;
win->stressTest = nullptr;
win = w;
CloseWindow(toClose, false);
}
if (!win->IsDocLoaded())
return false;
win->ctrl->SetDisplayMode(DM_CONTINUOUS);
win->ctrl->SetZoomVirtual(ZOOM_FIT_PAGE, nullptr);
win->ctrl->GoToFirstPage();
if (win->tocVisible || gGlobalPrefs->showFavorites)
SetSidebarVisibility(win, win->tocVisible, gGlobalPrefs->showFavorites);
currPage = pageRanges.at(0).start;
win->ctrl->GoToPage(currPage, false);
currPageRenderTime.Start();
++filesCount;
pageForSearchStart = (rand() % win->ctrl->PageCount()) + 1;
// search immediately in single page documents
if (1 == pageForSearchStart) {
// use text that is unlikely to be found, so that we search all pages
win::SetText(win->hwndFindBox, L"!z_yt");
FindTextOnThread(win, TextSearchDirection::Forward, true);
}
int secs = SecsSinceSystemTime(stressStartTime);
AutoFreeW tm(FormatTime(secs));
AutoFreeW s(str::Format(L"File %d: %s, time: %s", filesCount, fileName, tm));
win->ShowNotification(s, NOS_PERSIST, NG_STRESS_TEST_SUMMARY);
return true;
}
示例15: process_event
static int process_event(XEvent* event) {
KeySym sym;
WindowInfo* info = find_handle(event->xany.window);
if (!info)
return 1;
if (event->type == ClientMessage) {
if ((Atom)event->xclient.data.l[0] == s_wm_delete_window) {
info->update = 0;
mfb_close(info);
return 0;
}
}
switch (event->type)
{
case KeyPress:
{
sym = XLookupKeysym(&event->xkey, 0);
if (handle_special_keys(info, event, 1))
break;
if (info->key_callback)
info->key_callback(info->rust_data, sym, 1);
if (info->char_callback) {
unsigned int t = keySym2Unicode(sym);
if (t != -1)
info->char_callback(info->rust_data, t);
}
break;
}
case KeyRelease:
{
if (handle_special_keys(info, event, 0))
break;
sym = XLookupKeysym(&event->xkey, 0);
if (info->key_callback)
info->key_callback(info->rust_data, sym, 0);
break;
}
case ButtonPress:
{
if (!info->shared_data)
break;
if (event->xbutton.button == Button1)
info->shared_data->state[0] = 1;
else if (event->xbutton.button == Button2)
info->shared_data->state[1] = 1;
else if (event->xbutton.button == Button3)
info->shared_data->state[2] = 1;
else if (event->xbutton.button == Button4)
info->shared_data->scroll_y = 10.0f;
else if (event->xbutton.button == Button5)
info->shared_data->scroll_y = -10.0f;
else if (event->xbutton.button == Button6)
info->shared_data->scroll_x = 10.0f;
else if (event->xbutton.button == Button7)
info->shared_data->scroll_y = -10.0f;
break;
}
case ButtonRelease:
{
if (!info->shared_data)
break;
if (event->xbutton.button == Button1)
info->shared_data->state[0] = 0;
else if (event->xbutton.button == Button2)
info->shared_data->state[1] = 0;
else if (event->xbutton.button == Button3)
info->shared_data->state[2] = 0;
break;
}
case ConfigureNotify:
{
info->width = event->xconfigure.width;
info->height = event->xconfigure.height;
break;
}
}
return 1;
}