Exemple #1
0
void pListView::constructor() {
  lostFocus = false;
  hwnd = CreateWindowEx(
    WS_EX_CLIENTEDGE, WC_LISTVIEW, L"",
    WS_CHILD | WS_TABSTOP | LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | LVS_NOCOLUMNHEADER,
    0, 0, 0, 0, parentWindow->p.hwnd, (HMENU)id, GetModuleHandle(0), 0
  );
  SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&listView);
  setDefaultFont();
  setHeaderText(listView.state.headerText);
  setHeaderVisible(listView.state.headerVisible);
  setCheckable(listView.state.checkable);
  for(auto &text : listView.state.text) append(text);
  for(unsigned n = 0; n < listView.state.checked.size(); n++) setChecked(n, listView.state.checked[n]);
  setImageList();
  if(listView.state.selected) setSelection(listView.state.selection);
  autoSizeColumns();
  synchronize();
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    connect(ui->actionBackground, SIGNAL(triggered()), this, SLOT(background_file_open()));
    connect(ui->actionClosed_Aperature, SIGNAL(triggered()), this, SLOT(closedapp_file_open()));
    connect(ui->actionImage_Stack, SIGNAL(triggered()), this, SLOT(imagelist_file_open()));
    connect(ui->actionRun_Experiment, SIGNAL(triggered()), this, SLOT(run_experiment()));

    set_background = false;
    set_closed = false;
    set_image_list = false;

    ui->actionClosed_Aperature->setDisabled(true);
    ui->actionImage_Stack->setDisabled(true);
    ui->actionRun_Experiment->setDisabled(true);
    ui->actionShow_Graph->setDisabled(true);

    frapmodel = new FrapModel(0);

    connect(this,SIGNAL(primaset(QString)),frapmodel,SLOT(setPrima(QString)));
    connect(this,SIGNAL(closedset(QString)),frapmodel,SLOT(setClosed(QString)));
    connect(this,SIGNAL(doselection()),frapmodel,SLOT(doSelection()));
    connect(this,SIGNAL(imagelistset(QStringList)),frapmodel,SLOT(setImageList(QStringList)));

    connect(ui->actionShow_Graph, SIGNAL(triggered()),frapmodel, SLOT(prepareLinearFit()));

    //connect(frapmodel,SIGNAL(dataChanged(QModelIndex,QModelIndex)), ui->tableView,SLOT(dataChanged(QModelIndex,QModelIndex)));
    connect(frapmodel,SIGNAL(update_result(QString)), this, SLOT(show_result(QString)));
    connect(frapmodel,SIGNAL(plotLinearFit(int,std::vector<double>&,std::vector<double>&,std::vector<double>&,double,double)), ui->pl_widget, SLOT(plotLinearFit(int,std::vector<double>&,std::vector<double>&,std::vector<double>&,double,double)));

    ui->tabWidget->setCurrentIndex(0);
    starting_dir = "/home/jon/Programming/C/frap-tool-old";
}
INT_PTR CALLBACK ProjectPanel::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_INITDIALOG :
    {
        ProjectPanel::initMenus();

        // Create toolbar menu
        int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST;
        _hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style,
                                       0,0,0,0,_hSelf,(HMENU)0, _hInst, NULL);
        TBBUTTON tbButtons[2];

        NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker();
        generic_string workspace_entry = pNativeSpeaker->getProjectPanelLangMenuStr("Entries", 0, PM_WORKSPACEMENUENTRY);
        generic_string edit_entry = pNativeSpeaker->getProjectPanelLangMenuStr("Entries", 1, PM_EDITMENUENTRY);

        tbButtons[0].idCommand = IDB_PROJECT_BTN;
        tbButtons[0].iBitmap = I_IMAGENONE;
        tbButtons[0].fsState = TBSTATE_ENABLED;
        tbButtons[0].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
        tbButtons[0].iString = (INT_PTR)workspace_entry.c_str();

        tbButtons[1].idCommand = IDB_EDIT_BTN;
        tbButtons[1].iBitmap = I_IMAGENONE;
        tbButtons[1].fsState = TBSTATE_ENABLED;
        tbButtons[1].fsStyle = BTNS_BUTTON | BTNS_AUTOSIZE;
        tbButtons[1].iString = (INT_PTR)edit_entry.c_str();

        SendMessage(_hToolbarMenu, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
        SendMessage(_hToolbarMenu, TB_ADDBUTTONS,       (WPARAM)sizeof(tbButtons) / sizeof(TBBUTTON),       (LPARAM)&tbButtons);
        SendMessage(_hToolbarMenu, TB_AUTOSIZE, 0, 0);
        ShowWindow(_hToolbarMenu, SW_SHOW);

        _treeView.init(_hInst, _hSelf, ID_PROJECTTREEVIEW);

        setImageList(IDI_PROJECT_WORKSPACE, IDI_PROJECT_WORKSPACEDIRTY, IDI_PROJECT_PROJECT, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE, IDI_PROJECT_FILEINVALID);
        _treeView.addCanNotDropInList(INDEX_LEAF);
        _treeView.addCanNotDropInList(INDEX_LEAF_INVALID);

        _treeView.addCanNotDragOutList(INDEX_CLEAN_ROOT);
        _treeView.addCanNotDragOutList(INDEX_DIRTY_ROOT);
        _treeView.addCanNotDragOutList(INDEX_PROJECT);

        _treeView.display();
        if (!openWorkSpace(_workSpaceFilePath.c_str()))
            newWorkSpace();

        return TRUE;
    }


    case WM_MOUSEMOVE:
        if (_treeView.isDragging())
            _treeView.dragItem(_hSelf, LOWORD(lParam), HIWORD(lParam));
        break;
    case WM_LBUTTONUP:
        if (_treeView.isDragging())
            if (_treeView.dropItem())
                setWorkSpaceDirty(true);
        break;

    case WM_NOTIFY:
    {
        notified((LPNMHDR)lParam);
    }
    return TRUE;

    case WM_SIZE:
    {
        int width = LOWORD(lParam);
        int height = HIWORD(lParam);
        RECT toolbarMenuRect;
        ::GetClientRect(_hToolbarMenu, &toolbarMenuRect);

        ::MoveWindow(_hToolbarMenu, 0, 0, width, toolbarMenuRect.bottom, TRUE);

        HWND hwnd = _treeView.getHSelf();
        if (hwnd)
            ::MoveWindow(hwnd, 0, toolbarMenuRect.bottom + 2, width, height - toolbarMenuRect.bottom - 2, TRUE);
        break;
    }

    case WM_CONTEXTMENU:
        if (!_treeView.isDragging())
            showContextMenu(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
        return TRUE;

    case WM_COMMAND:
    {
        popupMenuCmd(LOWORD(wParam));
        break;
    }

    case WM_DESTROY:
    {
        _treeView.destroy();
        destroyMenus();
        ::DestroyWindow(_hToolbarMenu);
        break;
    }
    case WM_KEYDOWN:
        //if (wParam == VK_F2)
    {
        ::MessageBoxA(NULL,"vkF2","",MB_OK);
    }
    break;

    default :
        return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
    }
    return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
}
INT_PTR CALLBACK FileBrowser::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_INITDIALOG :
        {
			FileBrowser::initPopupMenus();

			_treeView.init(_hInst, _hSelf, ID_FILEBROWSERTREEVIEW);
			setImageList(IDI_PROJECT_WORKSPACE, IDI_PROJECT_WORKSPACEDIRTY, IDI_PROJECT_PROJECT, IDI_PROJECT_FOLDEROPEN, IDI_PROJECT_FOLDERCLOSE, IDI_PROJECT_FILE, IDI_PROJECT_FILEINVALID);

			_treeView.addCanNotDropInList(INDEX_OPEN_ROOT);
			_treeView.addCanNotDropInList(INDEX_CLOSE_ROOT);
			_treeView.addCanNotDropInList(INDEX_OPEN_NODE);
			_treeView.addCanNotDropInList(INDEX_CLOSED_NODE);
			_treeView.addCanNotDropInList(INDEX_LEAF);
			_treeView.addCanNotDropInList(INDEX_LEAF_INVALID);

			_treeView.addCanNotDragOutList(INDEX_OPEN_ROOT);
			_treeView.addCanNotDragOutList(INDEX_CLOSE_ROOT);
			_treeView.addCanNotDragOutList(INDEX_OPEN_NODE);
			_treeView.addCanNotDragOutList(INDEX_CLOSED_NODE);
			_treeView.addCanNotDragOutList(INDEX_LEAF);
			_treeView.addCanNotDragOutList(INDEX_LEAF_INVALID);

			_treeView.makeLabelEditable(false);
			_treeView.display();

            return TRUE;
        }

		case WM_MOUSEMOVE:
			if (_treeView.isDragging())
				_treeView.dragItem(_hSelf, LOWORD(lParam), HIWORD(lParam));
			break;
		case WM_LBUTTONUP:
			if (_treeView.isDragging())
				if (_treeView.dropItem())
				{
				
				}
			break;

		case WM_NOTIFY:
		{
			notified((LPNMHDR)lParam);
		}
		return TRUE;

        case WM_SIZE:
        {
            int width = LOWORD(lParam);
            int height = HIWORD(lParam);

			HWND hwnd = _treeView.getHSelf();
			if (hwnd)
				::MoveWindow(hwnd, 0, 0, width, height, TRUE);
            break;
        }

        case WM_CONTEXTMENU:
			if (!_treeView.isDragging())
				showContextMenu(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
        return TRUE;

		case WM_COMMAND:
		{
			popupMenuCmd(LOWORD(wParam));
			break;
		}

		case WM_DESTROY:
        {
			_treeView.destroy();
			destroyMenus();
            break;
        }

		case FB_ADDFILE:
		{
			const std::vector<generic_string> file2Change = *(std::vector<generic_string> *)lParam;
			generic_string separator = TEXT("\\\\");

			size_t sepPos = file2Change[0].find(separator);
			if (sepPos == generic_string::npos)
				return false;

			generic_string pathSuffix = file2Change[0].substr(sepPos + separator.length(), file2Change[0].length() - 1);

			// remove prefix of file/folder in changeInfo, splite the remained path
			vector<generic_string> linarPathArray = split(pathSuffix, '\\');

			generic_string rootPath = file2Change[0].substr(0, sepPos);
			generic_string path = rootPath;

			generic_string addedFilePath = file2Change[0].substr(0, sepPos + 1);
			addedFilePath += pathSuffix;
			bool isAdded = addInTree(rootPath, addedFilePath, nullptr, linarPathArray);
			if (not isAdded)
			{
				//MessageBox(NULL, addedFilePath.c_str(), TEXT("file/folder is not added"), MB_OK);
			}
			break;
		}

		case FB_RMFILE:
		{
			const std::vector<generic_string> file2Change = *(std::vector<generic_string> *)lParam;
			generic_string separator = TEXT("\\\\");

			size_t sepPos = file2Change[0].find(separator);
			if (sepPos == generic_string::npos)
				return false;

			generic_string pathSuffix = file2Change[0].substr(sepPos + separator.length(), file2Change[0].length() - 1);

			// remove prefix of file/folder in changeInfo, splite the remained path
			vector<generic_string> linarPathArray = split(pathSuffix, '\\');

			generic_string rootPath = file2Change[0].substr(0, sepPos);
			// search recursively and modify the tree structure

			bool isRemoved = deleteFromTree(rootPath, nullptr, linarPathArray);
			if (not isRemoved)
			{
				//MessageBox(NULL, file2Change[0].c_str(), TEXT("file/folder is not removed"), MB_OK);
			}
			break;
		}

		case FB_RNFILE:
		{
			const std::vector<generic_string> file2Change = *(std::vector<generic_string> *)lParam;
			generic_string separator = TEXT("\\\\");

			size_t sepPos = file2Change[0].find(separator);
			if (sepPos == generic_string::npos)
				return false;

			generic_string pathSuffix = file2Change[0].substr(sepPos + separator.length(), file2Change[0].length() - 1);

			// remove prefix of file/folder in changeInfo, splite the remained path
			vector<generic_string> linarPathArray = split(pathSuffix, '\\');

			generic_string rootPath = file2Change[0].substr(0, sepPos);

			size_t sepPos2 = file2Change[1].find(separator);
			if (sepPos2 == generic_string::npos)
				return false;

			generic_string pathSuffix2 = file2Change[1].substr(sepPos2 + separator.length(), file2Change[1].length() - 1);
			vector<generic_string> linarPathArray2 = split(pathSuffix2, '\\');

			bool isRenamed = renameInTree(rootPath, nullptr, linarPathArray, linarPathArray2);
			if (not isRenamed)
			{
				//MessageBox(NULL, file2Change[0].c_str(), TEXT("file/folder is not removed"), MB_OK);
			}
			break;
		}

        default :
            return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
    }
	return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
}
Exemple #5
0
void pListView::remove(unsigned row) {
  ListView_DeleteItem(hwnd, row);
  setImageList();
}
Exemple #6
0
void pListView::setImage(unsigned row, unsigned column, const image &image) {
  setImageList();
}