static int fill_task_folder(Menu *m, int desk, int flags) { struct en en; en.m = m, en.desk = desk, en.hwndTop = getWorkspaces().GetActiveTaskWindow(), en.flags = flags, en.i = en.n = 0; getWorkspaces().EnumTasks(task_enum_func, (LPARAM)&en); return en.n; }
ST void Desk_SetPosition(void) { SetWindowPos( hDesktopWnd, HWND_BOTTOM, getWorkspaces().GetVScreenX(), getWorkspaces().GetVScreenY(), getWorkspaces().GetVScreenWidth(), getWorkspaces().GetVScreenHeight(), SWP_NOACTIVATE|SWP_NOSENDCHANGING ); }
HBITMAP read_bitmap(const char* path, bool delete_after) { HWND hwnd_desk = GetDesktopWindow(); HDC hdc_desk = GetDC(hwnd_desk); BITMAP bm; #if 0 HBITMAP bmp = (HBITMAP)LoadImage(NULL, path, IMAGE_BITMAP, 0,0, LR_LOADFROMFILE); #else HBITMAP bmp = NULL; FILE *fp=fopen(path, "rb"); if (fp) { BITMAPFILEHEADER hdr; fread(&hdr, 1, sizeof(hdr), fp); if (0x4D42 == hdr.bfType) { BITMAPINFOHEADER bih, *pbih; int CU, s; void *lpBits; fread(&bih, 1, sizeof(bih), fp); CU = bih.biClrUsed * sizeof(RGBQUAD); pbih = (PBITMAPINFOHEADER)m_alloc(bih.biSize + CU); memmove(pbih, &bih, bih.biSize); fread(&((BITMAPINFO*)pbih)->bmiColors, 1, CU, fp); s = hdr.bfSize - hdr.bfOffBits; lpBits = m_alloc(s); fseek(fp, hdr.bfOffBits, SEEK_SET); fread(lpBits, 1, s, fp); bmp = CreateDIBitmap(hdc_desk, pbih, CBM_INIT, lpBits, (LPBITMAPINFO)pbih, DIB_RGB_COLORS); m_free(lpBits); m_free(pbih); } fclose(fp); } #endif if (bmp && GetObject(bmp, sizeof bm, &bm)) { // convert in any case (20ms), bc if it's compatible, it's faster to paint. HDC hdc_old = CreateCompatibleDC(hdc_desk); HGDIOBJ old_bmp = SelectObject(hdc_old, bmp); HDC hdc_new = CreateCompatibleDC(hdc_desk); HBITMAP bmp_new = CreateCompatibleBitmap(hdc_desk, getWorkspaces().GetVScreenWidth(), getWorkspaces().GetVScreenHeight()); SelectObject(hdc_new, bmp_new); StretchBlt(hdc_new, 0, 0, getWorkspaces().GetVScreenWidth(), getWorkspaces().GetVScreenHeight(), hdc_old, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); DeleteDC(hdc_new); DeleteObject(SelectObject(hdc_old, old_bmp)); DeleteDC(hdc_old); bmp = bmp_new; } ReleaseDC(hwnd_desk, hdc_desk); if (delete_after) DeleteFile(path); return bmp; }
void ShowRecoverMenu(void) { getWorkspaces().GatherWindows(); if (Settings_altMethod) { ShowMenu(MakeRecoverMenu(true)); } else { BBMessageBox(MB_OK, "Windows gathered in current workspace."); } }
HBITMAP make_root_bmp(const char *command) { struct rootinfo RI; struct rootinfo *r = &RI; HBITMAP bmp = NULL; init_root(r); if (parse_root(r, command) && (r->gradient | r->solid | r->mod) && 0 == r->bmp) { int width, height; RECT rect; HWND hwnd_desk; HDC hdc_desk, buf; HGDIOBJ B0; width = getWorkspaces().GetVScreenWidth(); height = getWorkspaces().GetVScreenHeight(); rect.left = rect.top = 0, rect.right = width, rect.bottom = height; hwnd_desk = GetDesktopWindow(); hdc_desk = GetDC(hwnd_desk); buf = CreateCompatibleDC(hdc_desk); bmp = CreateCompatibleBitmap(hdc_desk, width, height); B0 = SelectObject(buf, bmp); MakeGradientEx(buf, rect, r->type, r->color1, r->color2, r->color_from, r->color_to, 0 != r->interlaced, r->bevelstyle, r->bevelposition, 0, 0, 0); if (r->mod) Modula (buf, width, height, r->modx, r->mody, r->modfg); SelectObject(buf, B0); DeleteDC(buf); ReleaseDC(hwnd_desk, hdc_desk); } delete_root(r); return bmp; }
//=========================================================================== Menu * MakeTaskFolder(int n, bool popup) { DesktopInfo DI; struct string_node *sn; getWorkspaces().GetDesktopInfo(DI); if (n < 0 || n >= DI.nScreens) return NULL; sn = (struct string_node *)nth_node(DI.deskNames, n); return build_task_folder(n, sn->str, popup); }
//=========================================================================== Menu* MakeDesktopMenu(int mode, bool popup) { DesktopInfo DI; struct string_node *sl; int n, d; Menu *m, *s, *i = NULL; if (mode == 2) { m = MakeNamedMenu(NLS0("Tasks"), "Core_tasks_menu", popup); } else { i = build_task_folder(-1, NLS0("Icons"), popup); if (mode == 1) return i; m = MakeNamedMenu(NLS0("Workspaces"), "Core_tasks_workspaces", popup); } getWorkspaces().GetDesktopInfo(DI); for (n = 0, d = DI.nScreens, sl = DI.deskNames; n < d; ++n, sl = sl->next) { if (mode == 0) { char buf[100]; MenuItem *fi; fi = MakeSubmenu(m, build_task_folder(n, sl->str, popup), NULL); sprintf(buf, "@BBCore.SwitchToWorkspace %d", n+1); MenuItemOption(fi, BBMENUITEM_LCOMMAND, buf); if (n == DI.number) MenuItemOption(fi, BBMENUITEM_CHECKED); } else { fill_task_folder(m, n, e_alltasks); if (n == d-1) return m; MakeMenuNOP(m, NULL); } } MakeMenuNOP(m, NULL); MakeSubmenu(m, i, NULL); s = MakeNamedMenu(NLS0("New/Remove"), "Core_workspaces_setup", popup); MakeMenuItem(s, NLS0("New Workspace"), "@BBCore.AddWorkspace", false); if (d > 1) MakeMenuItem(s, NLS0("Remove Last"), "@BBCore.DelWorkspace", false); MakeMenuItemString(s, NLS0("Workspace Names"), "@BBCore.SetWorkspaceNames", Settings_workspaceNames); MakeSubmenu(m, s, NULL); MakeMenuGrip(s, "New/Remove"); MakeMenuGrip(m, "Workspaces"); return m; }
/** Execute the algorithm. */ void PoldiIndexKnownCompounds::exec() { g_log.information() << "Starting POLDI peak indexing." << std::endl; DataObjects::TableWorkspace_sptr peakTableWorkspace = getProperty("InputWorkspace"); PoldiPeakCollection_sptr unindexedPeaks = boost::make_shared<PoldiPeakCollection>(peakTableWorkspace); g_log.information() << " Number of peaks: " << unindexedPeaks->peakCount() << std::endl; std::vector<Workspace_sptr> workspaces = getWorkspaces(getProperty("CompoundWorkspaces")); std::vector<PoldiPeakCollection_sptr> peakCollections = getPeakCollections(workspaces); g_log.information() << " Number of phases: " << peakCollections.size() << std::endl; /* The procedure is much easier to formulate with some state stored in member * variables, * which are initialized either from user input or from some defaults. */ setMeasuredPeaks(unindexedPeaks); setExpectedPhases(peakCollections); setExpectedPhaseNames(getWorkspaceNames(workspaces)); initializeUnindexedPeaks(); initializeIndexedPeaks(m_expectedPhases); /* For calculating scores in the indexing procedure, scattering contributions * are used. * The structure factors are scaled accordingly. */ std::vector<double> contributions = getContributions(m_expectedPhases.size()); std::vector<double> normalizedContributions = getNormalizedContributions(contributions); scaleIntensityEstimates(peakCollections, normalizedContributions); scaleToExperimentalValues(peakCollections, unindexedPeaks); // Tolerances on the other hand are handled as "FWHM". std::vector<double> tolerances = getTolerances(m_expectedPhases.size()); assignFwhmEstimates(peakCollections, tolerances); // With all necessary state assigned, the indexing procedure can be executed indexPeaks(unindexedPeaks, peakCollections); g_log.information() << " Unindexed peaks: " << m_unindexedPeaks->peakCount() << std::endl; /* Finally, the peaks are put into separate workspaces, determined by * the phase they have been attributed to, plus unindexed peaks. */ std::string inputWorkspaceName = getPropertyValue("InputWorkspace"); WorkspaceGroup_sptr outputWorkspaces = boost::make_shared<WorkspaceGroup>(); for (size_t i = 0; i < m_indexedPeaks.size(); ++i) { PoldiPeakCollection_sptr intensitySorted = getIntensitySortedPeakCollection(m_indexedPeaks[i]); assignCrystalStructureParameters(intensitySorted, m_expectedPhases[i]); ITableWorkspace_sptr tableWs = intensitySorted->asTableWorkspace(); AnalysisDataService::Instance().addOrReplace( inputWorkspaceName + "_indexed_" + m_phaseNames[i], tableWs); outputWorkspaces->addWorkspace(tableWs); } ITableWorkspace_sptr unindexedTableWs = m_unindexedPeaks->asTableWorkspace(); AnalysisDataService::Instance().addOrReplace( inputWorkspaceName + "_unindexed", unindexedTableWs); outputWorkspaces->addWorkspace(unindexedTableWs); setProperty("OutputWorkspace", outputWorkspaces); }