示例#1
0
long CMainWindow::OnCommand(unsigned short id, unsigned short cmd, HWND)
{
	switch(id)
	{
	case ID_FILE_SAVE:
		SaveCurrentDocument();
		break;
	case ID_FILE_QUIT:
		Destroy();
		break;
	case ID_MAINMENU_MODIFY_ZONE:
		ShowZoneEditor();
		break;
	case ID_MAINMENU_INSPECT_WEAPONS:
		ShowAppearanceViewer();
		break;
	case ID_MAINMENU_INSPECT_WORLD_GRIDANIAINN:
		ShowWorldViewer(0xA09B0000);
		break;
	case ID_MAINMENU_INSPECT_WORLD_LIMSALOMINSAINN:
		ShowWorldViewer(0xA09B0001);
		break;
	case ID_MAINMENU_INSPECT_WORLD_ULDAHINN:
		ShowWorldViewer(0xA09B0002);
		break;
	case ID_MAINMENU_INSPECT_GAMEDATASHEETS:
		ShowSheetViewer(CSheetSchema::GAME_SCHEMA_FILE_ID);
		break;
	case ID_MAINMENU_INSPECT_VARDATASHEETS:
		ShowSheetViewer(CSheetSchema::VAR_SCHEMA_FILE_ID);
		break;
	case ID_MAINMENU_SETTINGS_GENERALSETTINGS:
		InsertDocument(std::move(std::make_unique<CSettingsPage>(m_hWnd)));
		break;
	case ID_MAINMENU_HELP_ABOUT:
		ShowAbout();
		break;
	case ID_TABCONTEXT_CLOSETAB:
		if(m_tabs.GetItemCount())
		{
			if(m_tabContextMenuSelection == -1)
			{
				CloseTab(m_tabs.GetSelection());
			}
			else
			{
				CloseTab(m_tabContextMenuSelection);
			}
		}
		break;
	}
	return FALSE;
}
示例#2
0
void CContextControl::OnTabClosing_Deferred(wxCommandEvent& event)
{
	int tab = event.GetId();
	if (tab < 0)
	{
		tab++;
		int count = GetTabCount();
		for (int i = count - 1; i >= 0; i--)
		{
			if (i != -tab)
				CloseTab(i);
		}
	}
	else
		CloseTab(tab);
}
示例#3
0
void UzblTreeTab::GotoTab(int i)
{
    currenttab = i;
    
    if (currenttab < 0)
        currenttab = totaltabs -1;
    if (currenttab >= totaltabs)
        currenttab = 0;
    
    GtkTreeIter iter;
    UzblInstance* uz = (UzblInstance*)g_list_nth(uzblinstances, currenttab)->data;
    GtkTreeRowReference* r = uz->GetRowRef();
    GtkTreePath* p = gtk_tree_row_reference_get_path(r);
    gtk_tree_model_get_iter(GTK_TREE_MODEL(tabmodel), &iter, p);
    
    int page = gtk_notebook_page_num(notebook, GTK_WIDGET(uz->GetSocket()));
    if (page == -1) {
        CloseTab(uz, false);
        return;
    }
    
    gtk_notebook_set_current_page(notebook, page);
    GtkTreeSelection* sel = gtk_tree_view_get_selection(tabtree);
    gtk_tree_selection_select_iter(sel, &iter);
}
示例#4
0
// On tab selection, we save the data for the tab which is losing selection and
// load the data of the selected tab into the WindowInfo.
LRESULT TabsOnNotify(WindowInfo *win, LPARAM lparam, int tab1, int tab2)
{
    LPNMHDR data = (LPNMHDR)lparam;
    int current;

    switch(data->code) {
    case TCN_SELCHANGING:
        // TODO: Should we allow the switch of the tab if we are in process of printing?
        SaveCurrentTabInfo(win);
        return FALSE;

    case TCN_SELCHANGE:
        current = TabCtrl_GetCurSel(win->hwndTabBar);
        LoadModelIntoTab(win, win->tabs.At(current));
        break;

    case T_CLOSING:
        // allow the closure
        return FALSE;

    case T_CLOSE:
        current = TabCtrl_GetCurSel(win->hwndTabBar);
        if (tab1 == current)
            CloseTab(win);
        else
            RemoveTab(win, tab1);
        break;

    case T_DRAG:
        SwapTabs(win, tab1, tab2);
        break;
    }
    return TRUE;
}
void MessagesDlg::OnCloseAllTabs()
{
	int i = 0;
	while (i < tab->GetItemCount()) {
		if (CloseTab(i,TRUE)) {
			i = 0;
		} else {
			i++;
		}
	}
}
示例#6
0
// On tab selection, we save the data for the tab which is losing selection and
// load the data of the selected tab into the WindowInfo.
LRESULT TabsOnNotify(WindowInfo *win, LPARAM lparam, int tab1, int tab2)
{
    LPNMHDR data = (LPNMHDR)lparam;

    switch(data->code) {
    case TCN_SELCHANGING:
        // TODO: Should we allow the switch of the tab if we are in process of printing?

        SaveCurrentTabData(win);
        return FALSE;

    case TCN_SELCHANGE:
        {
            int current = TabCtrl_GetCurSel(win->hwndTabBar);
            LoadModelIntoTab(win, GetTabData(win, current));
            UpdateCurrentTabBgColForWindow(win);
        }
        break;

    case T_CLOSING:
        // allow the closure
        return FALSE;

    case T_CLOSE:
        {
            int current = TabCtrl_GetCurSel(win->hwndTabBar);
            if (tab1 == current) {
                CloseTab(win);
            }
            else {
                TabData *tdata = GetTabData(win, tab1);
                win->tabSelectionHistory->Remove(tdata);
                UpdateTabFileDisplayStateForWin(win, tdata);
                DeleteTabData(tdata, true);
                TabCtrl_DeleteItem(win->hwndTabBar, tab1);
                UpdateTabWidth(win);
            }
        }
        break;

    case T_DRAG:
        SwapTabs(win, tab1, tab2);
        break;
    }
    return TRUE;
}
示例#7
0
void __fastcall TmForm::PCMouseUp(TObject *Sender, TMouseButton Button,
    TShiftState Shift, int X, int Y)
{
    // страбатывание кнопки
    TPageControl *PC=(TPageControl *)Sender;
    TRect btn=DrawCloseTabBtn(PC, 0, X, Y, -1, 0);
    if(X>=btn.Left&&X<=btn.Right&&Y>=btn.Top&&Y<=btn.Bottom)
        // проверить диапазон кнопки
    {
        TTabSheet *t=PC->Pages[PC->IndexOfTabAt(X, Y)];
        CloseTab(t);
    }
    if(PC->Tag==1)
    {
        PC->EndDrag(false);
        PC->Tag=0;
    }
}
示例#8
0
void CClosableTabCtrl::OnLButtonDown(UINT nFlags, CPoint point){
	//CTabCtrl::OnLButtonDown(nFlags, point);
	int offset=5;
	int idx=-1;
	int firstItem=0;
	if(m_pSpinCtrl)firstItem=LOWORD(m_pSpinCtrl->GetPos());
	for(int i=firstItem;i<itemWidths.size();i++){
		offset+=itemWidths[i];
		if(offset>point.x){
			idx=i;
			break;
		}
	}

	if(offset-point.x<18 && idx!=-1){
		CloseTab(idx);
		return;
	}

	if(idx==-1 || idx==GetCurSel())return;

	NMHDR nmh;
	nmh.code = TCN_SELCHANGING;
	nmh.idFrom = NULL;
	nmh.hwndFrom = GetSafeHwnd();
	GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetSafeHwnd(), (LPARAM)&nmh);
	SetCurSel(idx);
	nmh.code = TCN_SELCHANGE;
	GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetSafeHwnd(), (LPARAM)&nmh);
	RECT rect;
	GetWindowRect(&rect);
	rect.right-=rect.left;
	rect.left=0;
	rect.top=0;
	rect.bottom=TAB_HEIGHT+TAB_TOP_MARGIN;
	RedrawWindow();
}
示例#9
0
LRESULT CALLBACK Explorerplusplus::TabSubclassProc(HWND hTab,UINT msg,WPARAM wParam,LPARAM lParam)
{
	switch(msg)
	{
		case WM_INITMENU:
			OnInitTabMenu(wParam);
			SendMessage(m_hContainer,WM_INITMENU,wParam,lParam);
			break;

		case WM_MENUSELECT:
			/* Forward the message to the main window so it can
			handle menu help. */
			SendMessage(m_hContainer,WM_MENUSELECT,wParam,lParam);
			break;

		case WM_MEASUREITEM:
			SendMessage(m_hContainer,WM_MEASUREITEM,wParam,lParam);
			break;

		case WM_DRAWITEM:
			SendMessage(m_hContainer,WM_DRAWITEM,wParam,lParam);
			break;

		case WM_LBUTTONDOWN:
			OnTabCtrlLButtonDown(wParam,lParam);
			break;

		case WM_LBUTTONUP:
			OnTabCtrlLButtonUp();
			break;

		case WM_MOUSEMOVE:
			OnTabCtrlMouseMove(wParam,lParam);
			break;

		case WM_MBUTTONUP:
			SendMessage(m_hContainer,WM_APP_TABMCLICK,wParam,lParam);
			break;

		case WM_RBUTTONUP:
			OnTabCtrlRButtonUp(wParam,lParam);
			break;

		case WM_CAPTURECHANGED:
			{
				if((HWND)lParam != hTab)
					ReleaseCapture();

				m_bTabBeenDragged = FALSE;
			}
			break;

		case WM_LBUTTONDBLCLK:
			{
				TCHITTESTINFO info;
				int ItemNum;
				DWORD dwPos;
				POINT MousePos;

				dwPos = GetMessagePos();
				MousePos.x = GET_X_LPARAM(dwPos);
				MousePos.y = GET_Y_LPARAM(dwPos);
				ScreenToClient(hTab,&MousePos);

				/* The cursor position will be tested to see if
				there is a tab beneath it. */
				info.pt.x	= LOWORD(lParam);
				info.pt.y	= HIWORD(lParam);

				ItemNum = TabCtrl_HitTest(m_hTabCtrl,&info);

				if(info.flags != TCHT_NOWHERE && m_bDoubleClickTabClose)
				{
					CloseTab(ItemNum);
				}
			}
			break;

		case WM_NCDESTROY:
			RemoveWindowSubclass(m_hTabCtrl,TabSubclassProcStub,0);
			break;
	}

	return DefSubclassProc(hTab,msg,wParam,lParam);
}
示例#10
0
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;
    }

    // TODO: link is deleted when opening the document in a new tab
    RemoteDestination *remoteLink = NULL;
    if (link) {
        remoteLink = new RemoteDestination(link);
        link = NULL;
    }

    ScopedMem<WCHAR> fullPath(path::GetDir(owner->ctrl->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, true);
    // 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) {
            delete remoteLink;
            return;
        }
    }

    if (!newWin->IsDocLoaded()) {
        CloseTab(newWin);
        // 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));
            owner->ShowNotification(msg, true /* autoDismiss */, true /* highlight */);
        }
        delete remoteLink;
        return;
    }

    newWin->Focus();
    if (!remoteLink)
        return;

    ScopedMem<WCHAR> destName(remoteLink->GetDestName());
    if (destName) {
        PageDestination *dest = newWin->ctrl->GetNamedDest(destName);
        if (dest) {
            newWin->linkHandler->ScrollTo(dest);
            delete dest;
        }
    }
    else {
        newWin->linkHandler->ScrollTo(remoteLink);
    }
    delete remoteLink;
}
示例#11
0
void UzblTreeTab::Command(char* c)
{
    char** cmd = g_strsplit(c, " ", -1);
    do {
    if (!g_strcmp0(cmd[0], "new")) {
        if (cmd[1]) {
            char* u = g_strjoinv(" ",cmd+1);
            NewTab(u);
            g_free(u);
        }
        else 
            NewTab("about:blank");
        SaveSession();
    }
    if (!g_strcmp0(cmd[0], "cnew")) {
        if (cmd[2]) {
            int i = 0;
            for(GList* l = uzblinstances; l != NULL; l = g_list_next(l), i++) {
                UzblInstance* uzin = (UzblInstance*)l->data;
                if (!g_strcmp0(uzin->GetName(), cmd[1])) {
                    char* u = g_strjoinv(" ",cmd+2);
                    NewTab(u, i);
                    g_free(u);
                    break;
                }
            }
        }
        else 
            NewTab("about:blank", currenttab);
        SaveSession();
    }
    if (!g_strcmp0(cmd[0], "close")) {
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
            UzblInstance* uzin = (UzblInstance*)l->data;
            if (!g_strcmp0(uzin->GetName(), cmd[1])) {
                CloseTab(uzin, false);
                break;
            }
        }
    }
    if (!g_strcmp0(cmd[0], "treeclose")) {
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
            UzblInstance* uzin = (UzblInstance*)l->data;
            if (!g_strcmp0(uzin->GetName(), cmd[1])) {
                CloseTab(uzin, true);
                break;
            }
        }
    }
    if (!g_strcmp0(cmd[0], "next")) {
        GotoTab(currenttab+1);
    }
    if (!g_strcmp0(cmd[0], "prev")) {
        GotoTab(currenttab-1);
    }
    if (!g_strcmp0(cmd[0], "first")) {
        GotoTab(0);
    }
    if (!g_strcmp0(cmd[0], "last")) {
        GotoTab(totaltabs-1);
    }
    if (!g_strcmp0(cmd[0], "goto")) {
        int a;
        if (cmd[1]) {
            sscanf(cmd[1], "%d", &a);
            GotoTab(a);
        }
    }
    if (!g_strcmp0(cmd[0], "attach")) {
        int a;
        if (cmd[1]) {
            sscanf(cmd[1], "%d", &a);
            if (a > totaltabs)
                break;
            
            UzblInstance* cuz = (UzblInstance*)g_list_nth(uzblinstances, currenttab)->data;
            UzblInstance* puz = (UzblInstance*)g_list_nth(uzblinstances, a)->data;
            
            if (cuz == puz)
                break;
            
            if (cuz->GetNum() < puz->GetNum()) {
                uzblinstances = g_list_remove(uzblinstances, cuz);
                uzblinstances = g_list_insert(uzblinstances, cuz, puz->GetNum()+1);
            }
            
            cuz->SetParent(puz);
            RebuildTree();
            UpdateTablist();
            SaveSession();
        }
    }
    if (!g_strcmp0(cmd[0], "move")) {
        int a;
        if (cmd[1]) {
            sscanf(cmd[1], "%d", &a);
            UzblInstance* cuz = (UzblInstance*)g_list_nth(uzblinstances, currenttab)->data;
            uzblinstances = g_list_remove(uzblinstances, cuz);
            
            if (a > totaltabs)
                a = totaltabs;
            
            uzblinstances = g_list_insert(uzblinstances, cuz, a);
            currenttab = a;
            RebuildTree();
            UpdateTablist();
            SaveSession();
        }
    }
    if (!g_strcmp0(cmd[0], "tabtitle")) {
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
           if (!strcmp(cmd[1], ((UzblInstance*)l->data)->GetName())) {
               char* title = g_strjoinv(" ", cmd+2);
               ((UzblInstance*)l->data)->SetTitle(title);
               g_free(title);
           }
        }
        UpdateTablist();
    }
    if (!g_strcmp0(cmd[0], "taburi")) {
        for(GList* l = uzblinstances; l != NULL; l = g_list_next(l)) {
           if (!strcmp(cmd[1], ((UzblInstance*)l->data)->GetName())) {
               char* url = g_strjoinv(" ", cmd+2);
               ((UzblInstance*)l->data)->SetURL(url);
               g_free(url);
               SaveSession();
           }
        }
    }
    if (!g_strcmp0(cmd[0], "showtree")) {
        gtk_paned_set_position(pane, panepos);
    }
    if (!g_strcmp0(cmd[0], "hidetree")) {
        panepos = gtk_paned_get_position(pane);
        gtk_paned_set_position(pane, 0);
    }
    } while(0);
    g_strfreev(cmd);
}
LRESULT CALLBACK Explorerplusplus::TabProxyWndProc(HWND hwnd,UINT Msg,WPARAM wParam,LPARAM lParam,int iTabId)
{
	switch(Msg)
	{
	case WM_ACTIVATE:
		/* Restore the main window if necessary, and switch
		to the actual tab. */
		if(IsIconic(m_hContainer))
		{
			ShowWindow(m_hContainer,SW_RESTORE);
		}

		OnSelectTab(iTabId,FALSE);
		return 0;
		break;

	case WM_SETFOCUS:
		SetFocus(m_hListView[iTabId]);
		break;

	case WM_SYSCOMMAND:
		switch(wParam)
		{
		case SC_CLOSE:
			break;

		default:
			SendMessage(m_hListView[iTabId],WM_SYSCOMMAND,wParam,lParam);
			break;
		}
		break;

	/* Generate a thumbnail of the current tab. Basic procedure:
	1. Generate a full-scale bitmap of the main window.
	2. Overlay a bitmap of the specified tab onto the main
	window bitmap.
	3. Shrink the resulting bitmap down to the correct thumbnail size.
	
	A thumbnail will be dynamically generated, provided the main window
	is not currently minimized (as we won't be able to grap a screenshot
	of it). If the main window is minimized, we'll use a cached screenshot
	of the tab (taken before the main window was minimized). */
	case WM_DWMSENDICONICTHUMBNAIL:
		{
			HDC hdc;
			HDC hdcSrc;
			HBITMAP hbmTab = NULL;
			HBITMAP hPrevBitmap;
			Gdiplus::Color color(0,0,0);
			HRESULT hr;
			int iBitmapWidth;
			int iBitmapHeight;
			int iWidth;
			int iHeight;
			int iMaxWidth;
			int iMaxHeight;

			iMaxWidth = HIWORD(lParam);
			iMaxHeight = LOWORD(lParam);

			/* If the main window is minimized, it won't be possible
			to generate a thumbnail for any of the tabs. In that
			case, use a static 'No Preview Available' bitmap. */
			if(IsIconic(m_hContainer))
			{
				hbmTab = (HBITMAP)LoadImage(GetModuleHandle(0),MAKEINTRESOURCE(IDB_NOPREVIEWAVAILABLE),IMAGE_BITMAP,0,0,0);

				SetBitmapDimensionEx(hbmTab,223,130,NULL);
			}
			else
			{
				hbmTab = CaptureTabScreenshot(iTabId);
			}

			SIZE sz;

			GetBitmapDimensionEx(hbmTab,&sz);

			iBitmapWidth = sz.cx;
			iBitmapHeight = sz.cy;


			/* Shrink the bitmap. */
			HDC hdcThumbnailSrc;
			HBITMAP hbmThumbnail;
			POINT pt;

			hdc = GetDC(m_hContainer);
			hdcSrc = CreateCompatibleDC(hdc);

			SelectObject(hdcSrc,hbmTab);

			hdcThumbnailSrc = CreateCompatibleDC(hdc);

			/* If the current height of the main window
			is less than the width, we'll create a thumbnail
			of maximum width; else maximum height. */
			if((iBitmapWidth / iMaxWidth) > (iBitmapHeight / iMaxHeight))
			{
				iWidth = iMaxWidth;
				iHeight = iMaxWidth * iBitmapHeight / iBitmapWidth;
			}
			else
			{
				iHeight = iMaxHeight;
				iWidth = iMaxHeight * iBitmapWidth / iBitmapHeight;
			}

			/* Thumbnail bitmap. */
			Gdiplus::Bitmap bmpThumbnail(iWidth,iHeight,PixelFormat32bppARGB);

			bmpThumbnail.GetHBITMAP(color,&hbmThumbnail);

			hPrevBitmap = (HBITMAP)SelectObject(hdcThumbnailSrc,hbmThumbnail);

			/* Finally, shrink the full-scale bitmap down into a thumbnail. */
			SetStretchBltMode(hdcThumbnailSrc,HALFTONE);
			SetBrushOrgEx(hdcThumbnailSrc,0,0,&pt);
			StretchBlt(hdcThumbnailSrc,0,0,iWidth,iHeight,hdcSrc,0,0,iBitmapWidth,iBitmapHeight,SRCCOPY);

			SelectObject(hdcThumbnailSrc,hPrevBitmap);
			DeleteDC(hdcThumbnailSrc);

			HMODULE hDwmapi;
			DwmSetIconicThumbnailProc DwmSetIconicThumbnail;

			hDwmapi = LoadLibrary(_T("dwmapi.dll"));

			if(hDwmapi != NULL)
			{
				DwmSetIconicThumbnail = (DwmSetIconicThumbnailProc)GetProcAddress(hDwmapi,"DwmSetIconicThumbnail");

				if(DwmSetIconicThumbnail != NULL)
				{
					hr = DwmSetIconicThumbnail(hwnd,hbmThumbnail,0);
				}
			}

			FreeLibrary(hDwmapi);

			/* Delete the thumbnail bitmap. */
			DeleteObject(hbmTab);
			SelectObject(hdcSrc,hPrevBitmap);
			DeleteObject(hbmThumbnail);
			DeleteDC(hdcSrc);
			ReleaseDC(m_hContainer,hdc);

			return 0;
		}
		break;

	case WM_DWMSENDICONICLIVEPREVIEWBITMAP:
		{
			HMODULE hDwmapi;
			TabPreviewInfo_t tpi;

			DwmSetIconicLivePreviewBitmapProc DwmSetIconicLivePreviewBitmap;

			tpi.hbm = NULL;

			if(IsIconic(m_hContainer))
			{
				/* TODO: Show an image here... */
			}
			else
			{
				GetTabLivePreviewBitmap(iTabId,&tpi);
			}

			hDwmapi = LoadLibrary(_T("dwmapi.dll"));

			if(hDwmapi != NULL)
			{
				DwmSetIconicLivePreviewBitmap = (DwmSetIconicLivePreviewBitmapProc)GetProcAddress(hDwmapi,"DwmSetIconicLivePreviewBitmap");

				if(DwmSetIconicLivePreviewBitmap != NULL)
				{
					DwmSetIconicLivePreviewBitmap(hwnd,tpi.hbm,&tpi.ptOrigin,0);
				}
			}

			FreeLibrary(hDwmapi);

			if(tpi.hbm != NULL)
			{
				DeleteObject(tpi.hbm);
			}

			return 0;
		}
		break;

	case WM_CLOSE:
		{
			TCITEM tcItem;
			int nTabs;
			int i = 0;

			nTabs = TabCtrl_GetItemCount(m_hTabCtrl);

			if(nTabs == 1)
			{
				/* If this is the last tab, we'll close
				the whole application. */
				SendMessage(m_hContainer,WM_CLOSE,0,0);
			}
			else
			{
				for(i = 0;i < nTabs;i++)
				{
					tcItem.mask = TCIF_PARAM;
					TabCtrl_GetItem(m_hTabCtrl,i,&tcItem);

					if((int)tcItem.lParam == iTabId)
					{
						/* Close the tab... */
						CloseTab(i);
						break;
					}
				}
			}
		}
		break;
	}

	return DefWindowProc(hwnd,Msg,wParam,lParam);
}
示例#13
0
LRESULT  MessagesDlg::OnCloseTab(WPARAM wParam,LPARAM lParam)
{
	int i=wParam;
	CloseTab(i);
	return TRUE;
}
示例#14
0
void MyTabWidget::OnCloseTab(int index)
{
    CloseTab(index);
}