Пример #1
0
//---------------------------------------------------------
void CINFO_Messages::On_SelectAll(wxCommandEvent &WXUNUSED(event))
{
	SelectAll();
}
Пример #2
0
void csDiagramView::OnSelectAll(wxCommandEvent& WXUNUSED(event))
{
    SelectAll(true);
}
Пример #3
0
void CChildView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
  int i;
	CPoint point;
	CRect r;

  if (theApp.m_map.IsEmpty()) goto mend;

  BOOL CtrlPressed;
  CtrlPressed = (GetAsyncKeyState(VK_CONTROL) & 0x8000);
  UpdateCursor();

	switch(nChar) {
    case VK_ADD:
    case VK_SUBTRACT:
    case VK_OEM_PLUS:
    case VK_OEM_MINUS:
      if (!CtrlPressed) {
	      GetClientRect(&r);
	      point.x = r.Width()/2;
	      point.y = r.Height()/2;
        i = g_pMainFrame->m_cbZoom.GetCurSel();
      }
      break;
  }
	switch(nChar) {
		case VK_UP:
			theApp.m_map.ScrollMap(0, -32);
			break;
		case VK_DOWN:
			theApp.m_map.ScrollMap(0, 32);
			break;
		case VK_LEFT:
			theApp.m_map.ScrollMap(-32, 0);
			break;
		case VK_RIGHT:
			theApp.m_map.ScrollMap(32, 0);
			break;
		case VK_NEXT:
			if (theApp.m_map.m_iLevel > theApp.m_map.m_iMinLevel) {
        SelectAll(FALSE);
				theApp.m_map.m_iLevel--;
				Invalidate(FALSE);
			  g_pMainFrame->m_cbLevel.SelectString(-1, theApp.m_map.GetLevelStr(theApp.m_map.m_iLevel));
			}
			break;
		case VK_PRIOR:
			if (theApp.m_map.m_iLevel < theApp.m_map.m_iMaxLevel) {
        SelectAll(FALSE);
				theApp.m_map.m_iLevel++;
				Invalidate(FALSE);
			  g_pMainFrame->m_cbLevel.SelectString(-1, theApp.m_map.GetLevelStr(theApp.m_map.m_iLevel));
			}
			break;
    case VK_F9:
      if (CtrlPressed) {
        theApp.m_map.m_ShowSquares = !theApp.m_map.m_ShowSquares;
		    Invalidate(FALSE);
      }
      break;
    case VK_ADD:
    case VK_OEM_PLUS:
      if (CtrlPressed) {
        if (theApp.m_map.Overlay)
          g_pMainFrame->SetShading(theApp.m_map.Shading - 1);
      }
      else
        if (i > 0) {
          ChangeZoom(point, i - 1);
          m_LastZoomIdx = -1;
        }
      break;
    case VK_SUBTRACT:
    case VK_OEM_MINUS:
      if (CtrlPressed) {
        if (theApp.m_map.Overlay)
          g_pMainFrame->SetShading(theApp.m_map.Shading + 1);
      }
      else
        if (i < g_pMainFrame->m_cbZoom.GetCount() - 1) {
          ChangeZoom(point, i + 1);
          m_LastZoomIdx = -1;
        }
      break;
    case VK_ESCAPE:
      if (m_EditorMode)
        OnSelectMode();
      break;
	}
mend:	
	CWnd ::OnKeyDown(nChar, nRepCnt, nFlags);
}
Пример #4
0
/*---------------------------------------------------------------------------*/
void wxSQLEditorBase::OnSelectAllClick(wxCommandEvent& event)
{
  wxUnusedVar(event);
  SelectAll();
}
Пример #5
0
void wxComboBox::OnSelectAll(wxCommandEvent& WXUNUSED(event))
{
    SelectAll();
}
void MediaRoutingView::MessageReceived(
	BMessage* message)
{
	D_METHOD(("MediaRoutingView::MessageReceived()\n"));

	switch (message->what)
	{
		case B_MEDIA_NODE_CREATED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_NODE_CREATED)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("media_node_id", &type, &count) == B_OK)
			{
				for(int32 n = 0; n < count; n++) 
				{
					int32 id;
					if (message->FindInt32("media_node_id", n, &id) == B_OK)
					{
						// [e.moon 8dec99] allow for existing panel
						MediaNodePanel* panel;
						if(_findPanelFor(id, &panel) < B_OK)
							_addPanelFor(id, BPoint(5.0, 5.0));
					}
				}
			}
			break;
		}
		case B_MEDIA_NODE_DELETED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_NODE_DELETED)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("media_node_id", &type, &count) == B_OK)
			{
				for (int32 n = 0; n < count; n++) 
				{
					int32 id;
					if (message->FindInt32("media_node_id", n, &id) == B_OK)
					{
						_removePanelFor(id);
					}
				}
			}			
			break;
		}
		case B_MEDIA_CONNECTION_MADE:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_CONNECTION_MADE)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("output", &type, &count) == B_OK)
			{
				for (int32 n = 0; n < count; n++)
				{
					media_output output;
					const void *data;
					ssize_t dataSize;
					if (message->FindData("output", B_RAW_TYPE, n, &data, &dataSize) == B_OK)
					{
						output = *reinterpret_cast<const media_output *>(data);
						Connection connection;
						if (manager->findConnection(output.node.node, output.source, &connection) == B_OK)
						{
							_addWireFor(connection);
						}
					}
				}
			}
			break;
		}
		case B_MEDIA_CONNECTION_BROKEN:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_CONNECTION_BROKEN)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("__connection_id", &type, &count) == B_OK)
			{
				for (int32 n = 0; n < count; n++)
				{
					int32 id;
					if (message->FindInt32("__connection_id", n, &id) == B_OK)
					{
						_removeWireFor(id);
					}	
				}
			}
			break;
		}
		case B_MEDIA_FORMAT_CHANGED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(B_MEDIA_FORMAT_CHANGED)\n"));
			
			media_node_id nodeID;
			if(message->FindInt32("__source_node_id", &nodeID) < B_OK)
				break;

			uint32 connectionID;
			if(message->FindInt32("__connection_id", (int32*)&connectionID) < B_OK)
				break;

			media_source* source;
			ssize_t dataSize;
			if(message->FindData("be:source", B_RAW_TYPE, (const void**)&source, &dataSize) < B_OK)
				break;
				
			MediaWire* wire;
			if(_findWireFor(connectionID, &wire) == B_OK) {
				// copy new connection data
				manager->findConnection(nodeID, *source, &wire->connection);
			}
			break;
		}
		case M_CLEANUP_REQUESTED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_M_CLEANUP_REQUESTED)\n"));
			cleanUp();
			break;
		}
		case M_SELECT_ALL:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_SELECT_ALL)\n"));
			SelectAll(DiagramItem::M_BOX);
			break;
		}
		case M_DELETE_SELECTION:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_DELETE_SELECTION)\n"));
			_deleteSelection();
			break;
		}
		case M_NODE_CHANGE_CYCLING:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_CYCLING_CHANGED)\n"));
			bool cycle;
			if (message->FindBool("cycle", &cycle) == B_OK)
			{
				_changeCyclingForSelection(cycle);
			}
			break;
		}
		case M_NODE_CHANGE_RUN_MODE:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_RUNMODE_CHANGED)\n"));
			int32 mode;
			if (message->FindInt32("run_mode", &mode) == B_OK)
			{
				_changeRunModeForSelection(static_cast<uint32>(mode));
			}
			break;
		}
		case M_LAYOUT_CHANGED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_LAYOUT_CHANGED)\n"));
			layout_t layout;
			if (message->FindInt32("layout", (int32*)&layout) == B_OK)
			{
				if (layout != m_layout)
				{
					layoutChanged(layout);
					updateDataRect();
					Invalidate();
				}
			}
			break;
		}
		case M_NODE_START_TIME_SOURCE:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_START_TIME_SOURCE)\n"));
			int32 id;
			if(message->FindInt32("nodeID", &id) < B_OK)
				break;
			NodeRef* ref;
			if(manager->getNodeRef(id, &ref) < B_OK)
				break;
			
			bigtime_t when = system_time();
			status_t err = manager->roster->StartTimeSource(ref->node(), when);
			if(err < B_OK) {
				PRINT((
					"! StartTimeSource(%ld): '%s'\n",
					ref->id(), strerror(err)));
			}
			break;
		}
		case M_NODE_STOP_TIME_SOURCE:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_STOP_TIME_SOURCE)\n"));
			int32 id;
			if(message->FindInt32("nodeID", &id) < B_OK)
				break;
			NodeRef* ref;
			if(manager->getNodeRef(id, &ref) < B_OK)
				break;
			
			bigtime_t when = system_time();
			status_t err = manager->roster->StopTimeSource(ref->node(), when);
			if(err < B_OK) {
				PRINT((
					"! StopTimeSource(%ld): '%s'\n",
					ref->id(), strerror(err)));
			}
			break;
		}
		case M_NODE_TWEAK_PARAMETERS: {
			D_MESSAGE((" -> M_NODE_TWEAK_PARAMETERS\n"));
			_openParameterWindowsForSelection();
			break;
		}
		case M_NODE_START_CONTROL_PANEL: {
			D_MESSAGE((" -> M_NODE_START_CONTROL_PANEL\n"));
			_startControlPanelsForSelection();
			break;
		}
		case M_GROUP_SET_LOCKED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(M_GROUP_SET_LOCKED)\n"));
			int32 groupID;
			if(message->FindInt32("groupID", &groupID) < B_OK)
				break;
			bool locked;
			if(message->FindBool("locked", &locked) < B_OK)
				break;
			NodeGroup* group;
			if(manager->findGroup(groupID, &group) < B_OK)
				break;
			uint32 f = locked ?
				group->groupFlags() | NodeGroup::GROUP_LOCKED :
				group->groupFlags() & ~NodeGroup::GROUP_LOCKED;
			group->setGroupFlags(f);
			break;
		}
		case M_BROADCAST_SELECTION: {
			D_MESSAGE((" -> M_BROADCAST_SELECTION\n"));
			_broadcastSelection();
			break;
		}
		case InfoWindowManager::M_INFO_WINDOW_REQUESTED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(InfoView::M_INFO_WINDOW_REQUESTED)\n"));
			type_code type;
			int32 count;
			if (message->GetInfo("input", &type, &count) == B_OK)
			{
				for (int32 i = 0; i < count; i++)
				{
					media_input input;
					const void *data;
					ssize_t dataSize;
					if (message->FindData("input", B_RAW_TYPE, i, &data, &dataSize) == B_OK)
					{
						input = *reinterpret_cast<const media_input *>(data);
						InfoWindowManager *manager = InfoWindowManager::Instance();
						if (manager && manager->Lock()) {
							manager->openWindowFor(input);
							manager->Unlock();
						}
					}
				}
			}
			else if (message->GetInfo("output", &type, &count) == B_OK)
			{
				for (int32 i = 0; i < count; i++)
				{
					media_output output;
					const void *data;
					ssize_t dataSize;
					if (message->FindData("output", B_RAW_TYPE, i, &data, &dataSize) == B_OK)
					{
						output = *reinterpret_cast<const media_output *>(data);
						InfoWindowManager *manager = InfoWindowManager::Instance();
						if (manager && manager->Lock()) {
							manager->openWindowFor(output);
							manager->Unlock();
						}
					}
				}
			}
			else
			{
				_openInfoWindowsForSelection();
			}
			break;
		}
		case NodeManager::M_RELEASED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(NodeManager::M_RELEASED)\n"));
			remove_observer(this, manager);
			const_cast<RouteAppNodeManager*&>(manager) = 0;	
			// +++++ disable view!
			break;
		}			
		case NodeRef::M_RELEASED:
		{
			D_MESSAGE(("MediaRoutingView::MessageReceived(NodeRef::M_RELEASED)\n"));
			// only relevant on shutdown; do nothing
			break;
		}
		default:
		{
			DiagramView::MessageReceived(message);
		}
	}
}
Пример #7
0
void FileListView::keyPressEvent( QKeyEvent *event )
{
    int overridden_key = 0;
    QModelIndex wasCurrent = currentIndex();

    bool isControlEnter = (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) && (event->modifiers() & Qt::ControlModifier);
    switch (event->key())
    {
    case Qt::Key_Shift:
        currentSelectionAction = selectionModel()->isSelected(currentIndex()) ? QItemSelectionModel::Deselect : QItemSelectionModel::Select;
        break;

    case Qt::Key_Plus:
    case Qt::Key_Minus:
    case Qt::Key_Asterisk:
        SelectAll(event->key() == Qt::Key_Plus ? QItemSelectionModel::Select :
                  event->key() == Qt::Key_Minus ? QItemSelectionModel::Deselect :
                  QItemSelectionModel::Toggle);
        break;

    case Qt::Key_Left:
        overridden_key = Qt::Key_PageUp;
        break;
    case Qt::Key_Right:
        overridden_key = Qt::Key_PageDown;
        break;

    case Qt::Key_Insert:
        overridden_key = Qt::Key_Down;
        selectionModel()->select(currentIndex(), QItemSelectionModel::Toggle);
        break;

    case Qt::Key_Enter:
    case Qt::Key_Return:
        if (!isControlEnter)
        {
            if (event->modifiers() & Qt::ShiftModifier)
                emit OpenSelected();
            else
                emit EnterSelected();
        }
        break;
    }

    if (isSearchMode && !isControlEnter)
        switch (event->key())
        {
        case Qt::Key_Return:
        case Qt::Key_Enter:
        case Qt::Key_Escape:
        case Qt::Key_Left:
        case Qt::Key_Right:
        case Qt::Key_Up:
        case Qt::Key_Down:
        case Qt::Key_PageUp:
        case Qt::Key_PageDown:
        case Qt::Key_Home:
        case Qt::Key_End:
            Action_CloseQuickFind();
            break;
        }

    if ((isControlEnter && isSearchMode) ||
            (!event->text().isEmpty() && event->text() != "\x0d" &&
             !(event->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier)) &&
             !edit(currentIndex(), AnyKeyPressed, event)))
    {
        Action_OpenQuickFind();
        if (!isControlEnter)
            Action_QuickFindProcessKeyPressEvent(event);

        bool isFound = (event->modifiers() & Qt::ShiftModifier) ? Action_QuickFindPrev() : Action_QuickFindNext(!isControlEnter);
        if (!isControlEnter)
        {
            static bool wasFound = true;
            if (wasFound != isFound)
            {
                wasFound = isFound;

                QPalette pal = searchEdit->palette();
                pal.setColor(QPalette::Base, QColor(255, 200, 200));
                if (isFound)
                    pal = palette();
                searchEdit->setPalette(pal);
            }
        }

        setDirtyRegion(QRegion(0, 0, width(), height()));
        //keyboardSearch(event->text());
        event->accept();
    }
    else
    {
        event->ignore();

        if (overridden_key)
        {
            QKeyEvent newEvent(event->type(), overridden_key, event->modifiers(), event->text(), event->isAutoRepeat(), event->count());
            QTreeView::keyPressEvent(&newEvent);
        }
        else
            QTreeView::keyPressEvent(event);
    }

    if (event->modifiers() & Qt::ShiftModifier)
    {
        QModelIndex current = currentIndex();
        switch (event->key())
        {
        case Qt::Key_Up:
        case Qt::Key_Down:
            selectionModel()->select(wasCurrent, currentSelectionAction);
            break;

        case Qt::Key_Left:
        case Qt::Key_PageUp:
        case Qt::Key_Right:
        case Qt::Key_PageDown:
        case Qt::Key_Home:
        case Qt::Key_End:
            if (current.row() < wasCurrent.row())
                qSwap(wasCurrent, current);

            QItemSelection toSelect;
            toSelect << QItemSelectionRange(model()->index(wasCurrent.row(), 0), model()->index(current.row(), 1));
            selectionModel()->select(toSelect, currentSelectionAction);
            break;
        }
    }
}
Пример #8
0
INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES);

	switch (message) {
	case WM_INITDIALOG:
		hwndDialog = hDlg;
		TranslateDialogDefault( hDlg );
		oldWndProc = (WNDPROC)SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)PluginListWndProc);

		SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon("plg_list", 1));
		SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon("plg_list"));
		{
			HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0);
			ImageList_AddIconFromIconLib(hIml, "info");
			ListView_SetImageList(hwndList, hIml, LVSIL_SMALL);

			OSVERSIONINFO osver = { sizeof(osver) };
			if (GetVersionEx(&osver) && osver.dwMajorVersion >= 6) {
				wchar_t szPath[MAX_PATH];
				GetModuleFileName(NULL, szPath, SIZEOF(szPath));
				TCHAR *ext = _tcsrchr(szPath, '.');
				if (ext != NULL)
					*ext = '\0';
				_tcscat(szPath, _T(".test"));
				HANDLE hFile = CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
				if (hFile == INVALID_HANDLE_VALUE)
					// Running Windows Vista or later (major version >= 6).
					Button_SetElevationRequiredState(GetDlgItem(hDlg, IDOK), !IsProcessElevated());
				else {
					CloseHandle(hFile);
					DeleteFile(szPath);
				}
			}
			RECT r;
			GetClientRect(hwndList, &r);

			///
			LVCOLUMN lvc = {0};
			lvc.mask = LVCF_WIDTH | LVCF_TEXT;
			//lvc.fmt = LVCFMT_LEFT;

			lvc.pszText = TranslateT("Component Name");
			lvc.cx = 220; // width of column in pixels
			ListView_InsertColumn(hwndList, 0, &lvc);

			lvc.pszText = L"";
			lvc.cx = 32 - GetSystemMetrics(SM_CXVSCROLL); // width of column in pixels
			ListView_InsertColumn(hwndList, 1, &lvc);

			lvc.pszText = TranslateT("State");
			lvc.cx = 100 - GetSystemMetrics(SM_CXVSCROLL); // width of column in pixels
			ListView_InsertColumn(hwndList, 2, &lvc);

			///
			LVGROUP lvg;
			lvg.cbSize = sizeof(LVGROUP);
			lvg.mask = LVGF_HEADER | LVGF_GROUPID;

			lvg.pszHeader = TranslateT("Plugins");
			lvg.iGroupId = 1;
			ListView_InsertGroup(hwndList, 0, &lvg);

			lvg.pszHeader = TranslateT("Icons");
			lvg.iGroupId = 2;
			ListView_InsertGroup(hwndList, 0, &lvg);

			lvg.pszHeader = TranslateT("Other");
			lvg.iGroupId = 3;
			ListView_InsertGroup(hwndList, 0, &lvg);

			ListView_EnableGroupView(hwndList, TRUE);

			///
			SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP);
			ListView_DeleteAllItems(hwndList);

			///
			OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)lParam;
			for (int i = 0; i < todo.getCount(); ++i) {
				int groupId = 3;
				LVITEM lvi = {0};
				lvi.mask = LVIF_PARAM | LVIF_GROUPID | LVIF_TEXT | LVIF_IMAGE;
				
				if (_tcschr(todo[i].tszOldName, L'\\') != NULL)
					groupId = _tcsstr(todo[i].tszOldName, L"Plugins") != NULL ? 1 : 2;

				lvi.iItem = i;
				lvi.lParam = (LPARAM)&todo[i];
				lvi.iGroupId = groupId;
				lvi.iImage = -1;
				lvi.pszText = todo[i].tszOldName;
				int iRow = ListView_InsertItem(hwndList, &lvi);

				if (iRow != -1) {
					lvi.iItem = iRow;
					if (groupId == 1) {
						lvi.mask = LVIF_IMAGE;
						lvi.iSubItem = 1;
						lvi.iImage = 0;
						ListView_SetItem(hwndList, &lvi);
					}
				}
				todo[i].bEnabled = false;
			}
			HWND hwOk = GetDlgItem(hDlg, IDOK);
			EnableWindow(hwOk, false);
		}

		// do this after filling list - enables 'ITEMCHANGED' below
		SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
		Utils_RestoreWindowPosition(hDlg, 0, MODNAME, "ListWindow");
		return TRUE;

	case WM_NOTIFY:
		if (((LPNMHDR) lParam)->hwndFrom == hwndList) {
			switch (((LPNMHDR) lParam)->code) {
			case LVN_ITEMCHANGED:
				if (GetWindowLongPtr(hDlg, GWLP_USERDATA)) {
					NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;

					LVITEM lvI = {0};
					lvI.iItem = nmlv->iItem;
					lvI.iSubItem = 0;
					lvI.mask = LVIF_PARAM;
					ListView_GetItem(hwndList, &lvI);

					OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
					if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) {
						todo[lvI.iItem].bEnabled = ListView_GetCheckState(hwndList, nmlv->iItem);

						bool enableOk = false;
						for (int i=0; i < todo.getCount(); ++i) {
							if (todo[i].bEnabled) {
								enableOk = true;
								break;
							}
						}
						HWND hwOk = GetDlgItem(hDlg, IDOK);
						EnableWindow(hwOk, enableOk ? TRUE : FALSE);
					}
				}
				break;
			}
		}
		break;

	case WM_COMMAND:
		if (HIWORD( wParam ) == BN_CLICKED) {
			switch(LOWORD(wParam)) {
			case IDOK:
				EnableWindow( GetDlgItem(hDlg, IDOK), FALSE);
				EnableWindow( GetDlgItem(hDlg, IDC_SELNONE), FALSE);

				mir_forkthread(ApplyDownloads, hDlg);
				return TRUE;

			case IDC_SELNONE:
				SelectAll(hDlg, false);
				break;

			case IDCANCEL:
				DestroyWindow(hDlg);
				return TRUE;
			}
		}
		break;

	case WM_SIZE: // make the dlg resizeable
		if (!IsIconic(hDlg)) {
			UTILRESIZEDIALOG urd = { sizeof(urd) };
			urd.hInstance = hInst;
			urd.hwndDlg = hDlg;
			urd.lpTemplate = MAKEINTRESOURCEA(IDD_LIST);
			urd.pfnResizer = ListDlg_Resize;
			CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
		}
		break;

	case WM_GETMINMAXINFO: 
		{
			LPMINMAXINFO mmi = (LPMINMAXINFO)lParam;

			// The minimum width in points
			mmi->ptMinTrackSize.x = 370;
			// The minimum height in points
			mmi->ptMinTrackSize.y = 300;
		}
		break;

	case WM_DESTROY:
		Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ListWindow");
		Skin_ReleaseIcon((HICON)SendMessage(hDlg, WM_SETICON, ICON_BIG, 0));
		Skin_ReleaseIcon((HICON)SendMessage(hDlg, WM_SETICON, ICON_SMALL, 0));
		hwndDialog = NULL;
		delete (OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA);
		SetWindowLongPtr(hDlg, GWLP_USERDATA, 0);
		break;
	}

	return FALSE;
}
Пример #9
0
void ConstructionManager::update()
{
  std::set<BWAPI::Unit*> myPlayerUnits = SelectAll()(isCompleted)(GetAddon,(BWAPI::Unit*)NULL).not(isCarryingMinerals,isCarryingGas,isGatheringGas);

  //iterate through all the builder types
  for(std::map<BWAPI::UnitType,std::set<Building*> >::iterator i=this->buildingsNeedingBuilders.begin();i!=this->buildingsNeedingBuilders.end();i++)
  {
    if (!i->second.empty()) //if its empty, we don't really need builders of this type
    {
      for(std::set<BWAPI::Unit*>::iterator u = myPlayerUnits.begin(); u != myPlayerUnits.end(); u++)
      {
        //if this unit is completed and the right type, and doesn't have an addon, and we aren't already using it
        if ((*u)->getType()==i->first && this->builders.find(*u)==this->builders.end())
        {
          //bid value depends on distance - we like closer builders better
          double min_dist=1000000;
          for(std::set<Building*>::iterator b = i->second.begin(); b != i->second.end(); b++)
          {
            double dist = (*u)->getPosition().getDistance((*b)->position);
            if (dist < min_dist)
              min_dist = dist;
          }
          if (min_dist < 10)
            min_dist = 10;
          if (min_dist > 256*32 + 10)
            min_dist = 256*32 + 10;
          double bid = 80 - (min_dist - 10)/(256*32)*60;
          //if this isn't a worker, we don't care about distance
          if (!(*u)->getType().isWorker())
            arbitrator->setBid(this, *u, 80);
          else
            arbitrator->setBid(this, *u, bid);
        }
      }
    }
  }
  std::list<Building>::iterator i_next;
  int index=0;

  //iterate through all the incomplete buildings
  for(std::list<Building>::iterator i=this->incompleteBuildings.begin();i!=this->incompleteBuildings.end();i=i_next)
  {
    index++;
    i_next=i;
    i_next++;
    Building* b = &(*i);
    if (!b->started && b->buildingUnit!=NULL) //buildingUnit exists, so we've started actual construction
    {
      startedCount[b->type]++;
      b->started=true;
    }
    if (b->type.isAddon()) //if the type is an addon
    {
      if (b->builderUnit!=NULL)
        b->buildingUnit=b->builderUnit->getAddon(); //set buildingUnit to the addon (whether the addon exists or not)

      BWAPI::Unit* u = b->builderUnit;
      BWAPI::Unit* s = b->buildingUnit;
      if (s!=NULL && s->isCompleted()) //if the building exists and is completed
      {
        startedCount[b->type]--;
        plannedCount[b->type]--;
        if (u != NULL)
        {
          this->builders.erase(u);
          arbitrator->removeBid(this,u);
        }
        this->placer->freeTiles(b->tilePosition, 4,3);
        this->placer->freeTiles(b->tilePosition+BWAPI::TilePosition(4,1), 2,2);

        //If the building is complete, we can forget about it.
        this->incompleteBuildings.erase(i);
      }
      else //building either does not exist, or is incomplete
      {
        if (BWAPI::Broodwar->canMake(NULL,b->type))
        {
          if (u == NULL) //if we don't have a builder, ask for one and wait for it to be offered
            buildingsNeedingBuilders[*b->type.whatBuilds().first].insert(b);
          else
          {
            if (u->getAddon() == NULL) //if the addon does not exist yet
            {
              if (u->isLifted()) //if the builder is lifted, find somehwere to land
              {
                if (BWAPI::Broodwar->getFrameCount()>b->lastOrderFrame+BWAPI::Broodwar->getLatency()*2)
                {
                  if (!this->placer->canBuildHereWithSpace(b->tilePosition,b->type))
                  {
                    this->placer->freeTiles(b->tilePosition, 4,3);
                    this->placer->freeTiles(b->tilePosition+BWAPI::TilePosition(4,1), 2,2);
                    b->tilePosition=placer->getBuildLocationNear(b->tilePosition,*b->type.whatBuilds().first);
                    this->placer->reserveTiles(b->tilePosition, 4,3);
                    this->placer->reserveTiles(b->tilePosition+BWAPI::TilePosition(4,1), 2,2);
                  }
                  u->land(b->tilePosition);
                  b->lastOrderFrame = BWAPI::Broodwar->getFrameCount();
                }
              }
              else
              {
                if (u->isTraining()) //if the builder is training, cancel it - we have control over the builder
                {
                  u->cancelTrain();
                }
                else
                {
                  if (u->getTilePosition()!=b->tilePosition) //we may need to lift to find a build site with enough space for an add-on
                  { //b->tilePosition is set in onOffer()
                    u->lift();
                    b->lastOrderFrame = BWAPI::Broodwar->getFrameCount();
                  }
                  else //otherwise, we may be in a good spot to make the add-on
                  {
                    //check to see if we can build here
                    bool buildable=true;
                    for(int x=b->tilePosition.x()+4;x<b->tilePosition.x()+6;x++)
                      for(int y=b->tilePosition.y()+1;y<b->tilePosition.y()+3;y++)
                        if (!this->placer->buildable(x,y) || BWAPI::Broodwar->hasCreep(x,y))
                          buildable=false;
                    if (buildable) //if so, start making the add-on
                    {
                      u->buildAddon(b->type);
                    }
                    else
                    {
                      //otherwise, lift up (once we are lifted we will look for a valid spot to land and build)
                      u->lift();
                      b->lastOrderFrame = BWAPI::Broodwar->getFrameCount();
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    else //if the type is a normal building (not an addon)
    {
      if (b->tilePosition==BWAPI::TilePositions::None) //if we don't have a build location yet
      {
        if ((BWAPI::Broodwar->getFrameCount()+index)%25==0)
        {
          //get a build location near the goal position
          b->tilePosition = this->placer->getBuildLocationNear(b->goalPosition, b->type);
          if (b->tilePosition!=BWAPI::TilePositions::None)
          {
            b->position = BWAPI::Position(b->tilePosition.x()*32 + b->type.tileWidth()*16, b->tilePosition.y()*32 + b->type.tileHeight()*16);
            this->placer->reserveTiles(b->tilePosition, b->type.tileWidth(), b->type.tileHeight());
          }
        }
        //if we didn't find a build location yet, or cannot make the building, skip this building for now
        if (b->tilePosition==BWAPI::TilePositions::None)
          continue;
      }

      //if the builder dies, set it to null
      if (b->builderUnit!=NULL && !b->builderUnit->exists())
        b->builderUnit=NULL;

      //if the building dies, or isn't the right type, set it to null
      if (b->buildingUnit!=NULL && (!b->buildingUnit->exists() || b->buildingUnit->getType()!=b->type))
        b->buildingUnit=NULL;

      if (b->buildingUnit == NULL) //if we don't have a building yet, look for it
      {
        //look at the units on the tile to see if it exists yet
        std::set<BWAPI::Unit*> unitsOnTile = BWAPI::Broodwar->unitsOnTile(b->tilePosition.x(), b->tilePosition.y());
        for(std::set<BWAPI::Unit*>::iterator t = unitsOnTile.begin(); t != unitsOnTile.end(); t++)
          if ((*t)->getType() == b->type && !(*t)->isLifted())
          {
            //we found the building
            b->buildingUnit = *t;
            break;
          }
        //maybe the builder _is_ the building! (Zerg)
        if (b->buildingUnit == NULL && b->builderUnit!=NULL && b->builderUnit->getType().isBuilding())
        {
          //we found the building
          b->buildingUnit = b->builderUnit;
        }
      }
      BWAPI::Unit* u = b->builderUnit;
      BWAPI::Unit* s = b->buildingUnit;
      if (s != NULL && s->isCompleted()) //if the building is completed, we're done
      {
        startedCount[b->type]--;
        plannedCount[b->type]--;
        if (u != NULL)
        {
          this->builders.erase(u);
          arbitrator->removeBid(this,u);
        }
        this->placer->freeTiles(b->tilePosition, b->type.tileWidth(), b->type.tileHeight());

        //If the building is complete, we can forget about it.
        this->incompleteBuildings.erase(i);
      }
      else //otherwise, it doesn't exist or is incomplete
      {
        if (s == NULL) //if the building doesn't even exist
        {
          if (u == NULL) //ask for a builder if we don't have one yet
            buildingsNeedingBuilders[*b->type.whatBuilds().first].insert(b);
          else //if we have a worker
          {
            if (!u->isConstructing()) //if the worker isn't constructing
            {
              double distance = u->getPosition().getDistance(b->position);
              if (distance > 100) //if its too far away, tell it to go to the build site
                u->rightClick(b->position);
              else //if its close enough, tell it to build
                if (BWAPI::Broodwar->canBuildHere(u, b->tilePosition, b->type)) //if we can build here, tell the worker to build
                {
                  if (BWAPI::Broodwar->canMake(u, b->type))
                    u->build(b->tilePosition, b->type);
                }
                else //if we cannot build here, we need to find another build site (reset the tilePosition)
                {
                  this->placer->freeTiles(b->tilePosition, b->type.tileWidth(), b->type.tileHeight());
                  b->tilePosition = BWAPI::TilePositions::None;
                  b->position = BWAPI::Positions::None;
                }              
            }
          }
        }
        else //if the building does exist
        {
          if (b->type.getRace() != BWAPI::Races::Terran) //if its not terran, we can forget about the builder (i.e. probe is not needed to finish construction)
          {
            if (u != NULL)
            {
              this->builders.erase(u);
              arbitrator->removeBid(this, u);
              b->builderUnit = NULL;  
              u = b->builderUnit;
            }
          }
          else
          {
            //if the buildind is terran, the worker may have been killed
            if (u == NULL) //looks like the worker was killed, or revoked. In either case we need to ask for another worker to finish our building
              buildingsNeedingBuilders[*b->type.whatBuilds().first].insert(b);
            else
            {
              //we have a worker, so lets rightClick it on the incomplete building so it can resume construction
              if (BWAPI::Broodwar->getFrameCount()%(4*BWAPI::Broodwar->getLatency())==0)
              {
                if (!u->isConstructing() || !s->isBeingConstructed())
                {
                  //right click builder on building
                  u->rightClick(s);
                  //also right click building on builder for good luck! :D
                  s->rightClick(u);
                }
              }
            }
          }
        }
      }
    }
  }
}
Пример #10
0
RipCDDialog::RipCDDialog(QWidget* parent)
    : QDialog(parent),
      ui_(new Ui_RipCDDialog),
      ripper_(new Ripper(this)),
      working_(false) {
  // Init
  ui_->setupUi(this);

  // Set column widths in the QTableWidget.
  ui_->tableWidget->horizontalHeader()->setResizeMode(
      kCheckboxColumn, QHeaderView::ResizeToContents);
  ui_->tableWidget->horizontalHeader()->setResizeMode(
      kTrackNumberColumn, QHeaderView::ResizeToContents);
  ui_->tableWidget->horizontalHeader()->setResizeMode(kTrackTitleColumn,
                                                      QHeaderView::Stretch);

  // Add a rip button
  rip_button_ = ui_->button_box->addButton(tr("Start ripping"),
                                           QDialogButtonBox::ActionRole);
  cancel_button_ = ui_->button_box->button(QDialogButtonBox::Cancel);
  close_button_ = ui_->button_box->button(QDialogButtonBox::Close);

  // Hide elements
  cancel_button_->hide();
  ui_->progress_group->hide();

  connect(ui_->select_all_button, SIGNAL(clicked()), SLOT(SelectAll()));
  connect(ui_->select_none_button, SIGNAL(clicked()), SLOT(SelectNone()));
  connect(ui_->invert_selection_button, SIGNAL(clicked()),
          SLOT(InvertSelection()));
  connect(rip_button_, SIGNAL(clicked()), SLOT(ClickedRipButton()));
  connect(cancel_button_, SIGNAL(clicked()), ripper_, SLOT(Cancel()));
  connect(close_button_, SIGNAL(clicked()), SLOT(hide()));

  connect(ui_->options, SIGNAL(clicked()), SLOT(Options()));
  connect(ui_->select, SIGNAL(clicked()), SLOT(AddDestination()));

  connect(ripper_, SIGNAL(Finished()), SLOT(Finished()));
  connect(ripper_, SIGNAL(Cancelled()), SLOT(Cancelled()));
  connect(ripper_, SIGNAL(ProgressInterval(int, int)),
          SLOT(SetupProgressBarLimits(int, int)));
  connect(ripper_, SIGNAL(Progress(int)), SLOT(UpdateProgressBar(int)));

  setWindowTitle(tr("Rip CD"));
  AddDestinationDirectory(QDir::homePath());

  // Get presets
  QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
  qSort(presets.begin(), presets.end(), ComparePresetsByName);
  for (const TranscoderPreset& preset : presets) {
    ui_->format->addItem(
        QString("%1 (.%2)").arg(preset.name_).arg(preset.extension_),
        QVariant::fromValue(preset));
  }

  // Load settings
  QSettings s;
  s.beginGroup(kSettingsGroup);
  last_add_dir_ = s.value("last_add_dir", QDir::homePath()).toString();

  QString last_output_format = s.value("last_output_format", "ogg").toString();
  for (int i = 0; i < ui_->format->count(); ++i) {
    if (last_output_format ==
        ui_->format->itemData(i).value<TranscoderPreset>().extension_) {
      ui_->format->setCurrentIndex(i);
      break;
    }
  }
}
Пример #11
0
BOOL LListCtrl::PreTranslateMessage(MSG* pMsg)
{
    // If edit control is visible in tree view control, sending a
    // WM_KEYDOWN message to the edit control will dismiss the edit
    // control.  When ENTER key was sent to the edit control, the parent
    // window of the tree view control is responsible for updating the
    // item's label in TVN_ENDLABELEDIT notification code.
    if ( pMsg->message == WM_KEYDOWN )
    {
        CHAR ckey=toupper( pMsg->wParam &0xFF );

        if ( VK_RETURN == pMsg->wParam )
            m_bEditNext = TRUE;
        if ( VK_ESCAPE == pMsg->wParam )
            m_bEditNext = FALSE;


        if( GetKeyState( VK_CONTROL )<-1 && (ckey== 'A') )
        {
            SelectAll();
            return TRUE;
        }
        if( GetKeyState( VK_CONTROL )<-1 && (ckey== 'N') )
        {
            SelectNone();
            return TRUE;
        }


        CEdit* edit = GetEditControl();
        if (edit)
        {
            //			LTRACE("Control key status = %d %d\n",LOBYTE(GetKeyState( VK_CONTROL )),HIWORD(GetKeyState( VK_CONTROL )));

            if( GetKeyState( VK_CONTROL )<-1 && (ckey== _T( 'C' ) ) )
            {
                edit->Copy();
                return TRUE;
            }
            if( GetKeyState( VK_CONTROL )<-1 && (ckey== _T( 'V' ) ) )
            {
                edit->Paste();
                return TRUE;
            }
            if( GetKeyState( VK_CONTROL )<-1 && (ckey== _T( 'X' ) ) )
            {
                edit->Cut();
                return TRUE;
            }
            if( GetKeyState( VK_CONTROL )<-1 && (ckey== _T( 'Z' ) ) )
            {
                edit->Undo();
                return TRUE;
            }
            if( pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_CONTROL || pMsg->wParam == VK_INSERT || pMsg->wParam == VK_SHIFT )
            {
                edit->SendMessage(WM_KEYDOWN, pMsg->wParam, pMsg->lParam);
                return TRUE;
            }
        }
    }
    return CListCtrl::PreTranslateMessage(pMsg);
}
Пример #12
0
 void ScoutManager::requestScout( double bid )
 {
   // Bid on all completed workers.
   std::set< BWAPI::Unit > usefulUnits = SelectAll()( isWorker, Overlord )( isCompleted ).not( isCarryingMinerals, isCarryingGas, isGatheringGas );
   m_arbitrator->setBid( this, usefulUnits, bid );
 }
Пример #13
0
void CTrkObjList::OnSelectAll(CWnd* pWnd,double Zoom,
                              int UpdateMode)
{
   SelectAll(pWnd,Zoom,UpdateMode);
}
Пример #14
0
bool TextViewBase::HandleWndProc(UINT msg, WPARAM wParam, LPARAM lParam, LONG *pResult)
{
	HIMC hIMC = NULL;
	switch (msg)
	{
		// Draw contents of TextView whenever window needs updating
	case WM_ERASEBKGND:
		*pResult = 1;
		return true;
		// Need to custom-draw the border for XP/Vista themes
	case WM_NCPAINT:
		*pResult = OnNcPaint((HRGN)wParam);
		return true;

	case WM_PAINT:
		*pResult = OnPaint();
		return true;
		// Set a new font 
	case WM_SETFONT:
		*pResult = OnSetFont((HFONT)wParam);
		return true;

	case WM_SIZE:
		*pResult = OnSize(wParam, LOWORD(lParam), HIWORD(lParam));
		return true;

	case WM_VSCROLL:
		*pResult = OnVScroll(LOWORD(wParam), HIWORD(wParam));
		return true;

	case WM_HSCROLL:
		*pResult = OnHScroll(LOWORD(wParam), HIWORD(wParam));
		return true;

	case WM_MOUSEACTIVATE:
		*pResult = OnMouseActivate((HWND)wParam, LOWORD(lParam), HIWORD(lParam));
		return true;

		//case WM_CONTEXTMENU:
		//	return OnContextMenu((HWND)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));

	case WM_MOUSEWHEEL:
		if (IsKeyPressed(VK_CONTROL))
			return false;
		else
			*pResult = OnMouseWheel((short)HIWORD(wParam));
		return true;

	case WM_SETFOCUS:
		*pResult = OnSetFocus((HWND)wParam);
		return true;

	case WM_KILLFOCUS:
		*pResult = OnKillFocus((HWND)wParam);
		return true;

		// make sure we get arrow-keys, enter, tab, etc when hosted inside a dialog
	case WM_GETDLGCODE:
		*pResult = DLGC_WANTALLKEYS;//DLGC_WANTMESSAGE;//DLGC_WANTARROWS;
		return true;

	case WM_LBUTTONDOWN:
		*pResult = OnLButtonDown(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;

	case WM_LBUTTONUP:
		*pResult = OnLButtonUp(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;

	case WM_LBUTTONDBLCLK:
		*pResult = OnLButtonDblClick(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;

	case WM_RBUTTONDOWN:
		*pResult = OnRButtonDown(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;
	case WM_MOUSEMOVE:
		*pResult = OnMouseMove(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam));
		return true;

	case WM_KEYDOWN:
		*pResult = OnKeyDown(wParam, lParam);
		return true;

	case WM_UNDO: case TXM_UNDO: case EM_UNDO:
		*pResult = Undo();
		return true;

	case TXM_REDO : case EM_REDO:
		*pResult = Redo();
		return true;

	case TXM_CANUNDO: case EM_CANUNDO:
		*pResult = CanUndo();
		return true;

	case TXM_CANREDO: case EM_CANREDO:
		*pResult = CanRedo();
		return true;

	case WM_CHAR:
		OutputDebugString(L"WM_CHAR\n");
		*pResult = OnChar(wParam, lParam);
		return true;

	case WM_SETCURSOR:

		if (LOWORD(lParam) == HTCLIENT)
		{
			*pResult = TRUE;
			return true;
		}
		else
			return false;
	case WM_COPY:
		*pResult = OnCopy();
		return true;

	case WM_CUT:
		*pResult = OnCut();
		return true;

	case WM_PASTE:
		*pResult = OnPaste();
		return true;

	case WM_CLEAR:
		*pResult = OnClear();
		return true;
	
	case WM_GETTEXT:
		*pResult = GetText((WCHAR*)lParam, 0, (ULONG)wParam);
		return true;

	case WM_SETTEXT:
		*pResult = OnSetText((WCHAR*)lParam, lstrlen((WCHAR*)lParam));
		return true;
		//case TXM_SETTEXT:
		//	{
		//		ClearFile();
		//		EnterText((WCHAR*)lParam, (LONG)wParam);
		//		return 0;
		//	}
	case WM_TIMER:
		*pResult = OnTimer(wParam);
		return true;

	case WM_IME_STARTCOMPOSITION:
		OutputDebugString(L"WM_IME_STARTCOMPOSITION\n");
		*pResult = OnStartComposition(wParam, lParam);
		return true;
		//return DefWindowProc(m_hWnd, WM_IME_STARTCOMPOSITION, wParam, lParam);

	case WM_IME_COMPOSITION:
		OutputDebugString(L"WM_IME_COMPOSITION\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_COMPOSITION, wParam, lParam);
		return true;
		//return OnComposition(wParam, lParam);

	case WM_IME_ENDCOMPOSITION:
		OutputDebugString(L"WM_IME_ENDCOMPOSITION\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_ENDCOMPOSITION, wParam, lParam);
		return true;
		//return OnEndComposition(wParam, lParam);

	case WM_IME_CHAR:
		OutputDebugString(L"WM_IME_CHAR\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_CHAR, wParam, lParam);
		return true;

	case WM_IME_CONTROL:
		OutputDebugString(L"WM_IME_CONTROL\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_CONTROL, wParam, lParam);
		return true;


	case WM_IME_NOTIFY:
		OutputDebugString(L"WM_IME_NOTIFY\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_NOTIFY, wParam, lParam);
		return true;
		//return HandleImeNotify(wParam, lParam);

	case WM_IME_REQUEST:
		OutputDebugString(L"WM_IME_REQUEST\n");
		*pResult = DefWindowProc(m_hWnd, WM_IME_REQUEST, wParam, lParam);
		return true;
	case WM_INPUTLANGCHANGE:
		*pResult = OnInputLanChange(wParam, lParam);
		return true;

	case TXM_PRINT:
		*pResult = OnPrint((HDC)wParam, (int)lParam);
		return true;

		//
	case TXM_OPENFILE:
		*pResult = OpenFile((TCHAR *)lParam);
		return true;


	case TXM_SAVEFILE:
		*pResult = SaveFile((TCHAR *)lParam);
		return true;

	case TXM_IMPORTFILE:
		*pResult = ImportFile((TCHAR *)lParam, (int)wParam);
		return true;

	case TXM_EXPORTFILE:
	{
		int convertype = LOWORD(wParam);
		int utf_type = HIWORD(wParam);
		*pResult = ExportFile((TCHAR *)lParam, convertype, utf_type);
		return true;
	}

	case TXM_CLEAR:
		*pResult = ClearFile();
		return true;

	case TXM_GETFORMAT:
		*pResult = m_pTextDoc->getformat();
		return true;

	case TXM_SETFORMAT:
		*pResult = m_pTextDoc->setformat((int)wParam);
		return true;

	case TXM_GETSELSIZE:
		*pResult = SelectionSize();
		return true;

	case TXM_SETSELALL:
		*pResult = SelectAll();
		return true;

	case TXM_GETCURPOS:
		*pResult = m_CurrentCharPos.get();
		return true;

	case TXM_GETCURLINE_D:
		*pResult = m_nCurrentLine_D;
		return true;

	case TXM_GETCURLINE_V:
		*pResult = OnGetCurLineV();
		return true;

	case TXM_GETCURCOL:
		*pResult = OnGetCurCol();
		return true;

	case TXM_GETEDITMODE:
		*pResult = m_nEditMode;
		return true;

	case TXM_SETEDITMODE:
		lParam = m_nEditMode;
		m_nEditMode = wParam;
		*pResult = lParam;
		return true;
	case TXM_FIND_INIT:
		FindInitial((WCHAR*)lParam);
		*pResult = 0;
		return true;
	case TXM_FIND:
	{
		BOOL m = (BOOL)LOWORD(wParam);
		BOOL b = (BOOL)HIWORD(wParam);
		//FindText()
		if (b)
			*pResult = FindBackward(m, NULL);
		else
			*pResult = FindForward(m, NULL);
		return true;
	}
	case TXM_FIND_TEXT:
	{
		FIND_OPTION* fp = (FIND_OPTION*)(lParam);
		*pResult = Find_Text(fp->text, lstrlen(fp->text), fp->fBackward, fp->fMachCase, fp->fWarp);
		return true;
	}
	case TXM_REPLACE_TEXT:
	{
		*pResult = Replace_Text((REPLACE_OPTION*)(lParam));
		return true;
	}
	case TXM_SETRESMODULE:
	{
		*pResult = OnSetResModule((HMODULE)lParam);
		return true;
	}
	case WM_GETTEXTLENGTH:
	case TXM_GETTEXTLEN:
	{
		*pResult = OnGetTextLen();
		return true;
	}
	case TXM_REPLACE:
	{
		BOOL ra = (BOOL)LOWORD(wParam);
		WORD mb = (WORD)HIWORD(wParam);
		BOOL m = (BOOL)LOBYTE(mb);
		BOOL b = (BOOL)HIBYTE(mb);
		if (b)
			*pResult = FindBackward(m, (WCHAR*)lParam, ra);
		else
			*pResult = FindForward(m, (WCHAR*)lParam, ra);
		return true;
	}
	case TXM_FIND_GETTEXTLENGTH:
		*pResult = m_pFndIterator->find_text_length();
		return true;
	case TXM_GETSELSTART:
		*pResult = m_nSelectionStart;
		return true;
	case TXM_GETSELEND:
		*pResult = m_nSelectionEnd;
		return true;
	case TXM_GETSELTEXT:
		*pResult = OnGetSelText((WCHAR*)wParam, ULONG(lParam));
		return true;
	case TXM_SETTESTERMODE:
		OnTesterMode((bool)wParam);
		*pResult = 0;
		return true;
	case TXM_SETCONTEXTMENU:
		m_hUserMenu = (HMENU)wParam;
		*pResult = 0;
		return true;
	case TXM_STATISTIC:
		*pResult = OnDoStatistic((STATISTIC*)(lParam));
		return true;
	case TXM_GETCONVERTTYPES:
		*pResult = OnGetConvertTypes((convert_type*)(lParam));
		return true;
	case EM_GETSEL:
		*pResult = OnMsg_EM_GETSEL((ULONG*)wParam, (ULONG*)lParam);
		return true;
	case EM_SETSEL:
		*pResult = OnMsg_EM_SETSEL((LONG)wParam, (LONG)lParam);
		return true;
	default:
		return false;
	}
}
Пример #15
0
void IWnd_stc::OnKeyEvent(wxKeyEvent& evt)
{
	int kc = evt.GetRawKeyCode();

	if(kc==wxSTC_KEY_TAB)
	{
		if(evt.ShiftDown())
		{
			CmdKeyExecute (wxSTC_CMD_BACKTAB);
		}
		else
		{
			CmdKeyExecute (wxSTC_CMD_TAB);
		}
		return;
	}

	if(evt.ControlDown())
	{
		switch(kc)
		{
		case 'C':
			{
				Copy();
			}
			return;
		case 'X':
			{
				Cut();
			}
			return;
		case 'V':
			{
				Paste();
			}
			return;
		case 'A':
			{
				SelectAll();
			}
			return;
		case 'Z':
			{
				Undo();
			}
			return;
		case 'R':
			{
				Redo();
			}
			return;
		case 'D':
			{
				this->Clear();
			}
			return;
		//case 'F':
		//	if(style.get(STYLE_CAN_FIND))
		//	{
		//		WndManager::current().evtmgr["Find"].CmdExecuteEx(-1);
		//		evt.Skip();
		//		return;
		//	}
		//	break;
		//case 'H':
		//	if(style.get(STYLE_CAN_REPLACE))
		//	{
		//		WndManager::current().evtmgr["Replace"].CmdExecuteEx(-1);
		//		evt.Skip();
		//		return;
		//	}
		//	break;
		};
	}

	evt.Skip();
}
Пример #16
0
//
//	Process keyboard-navigation keys
//
LONG TextViewBase::OnKeyDown(UINT nKeyCode, UINT nFlags)
{
	bool fCtrlDown	= IsKeyPressed(VK_CONTROL);
	bool fShiftDown	= IsKeyPressed(VK_SHIFT);
	BOOL fAdvancing = FALSE;
	long oldCursorOffset = m_nSelectionEnd;
	//
	//	Process the key-press. Cursor movement is different depending
	//	on if <ctrl> is held down or not, so act accordingly
	//
	switch(nKeyCode)
	{
	case VK_SHIFT: case VK_CONTROL:
		return 0;

	case 'a': case 'A':
		
		{
			if(fCtrlDown)
				SelectAll();
		}
		return 0;
	// CTRL+Z undo
	case 'z': case 'Z':
		
		if(fCtrlDown && Undo())
			/*NotifyParent(TVN_CHANGED);*/

		return 0;

	// CTRL+Y redo
	case 'y': case 'Y':
		
		if(fCtrlDown && Redo()) 
			//NotifyParent(TVN_CHANGED);

		return 0;
	// CTRL+C copy
	case 'c': case 'C':
	{
		//if(fCtrlDown && Redo()) 
		//	NotifyParent(TVN_CHANGED);
		if(fCtrlDown)
			return OnCopy();
		else
			break;
	}

	case 'x': case 'X':
		{
		if(fCtrlDown)
			return OnCut();
		else
			break;
		}
	case 'v': case 'V':
		{
		if(fCtrlDown)
			return OnPaste();
		else
			break;
		}

	
	// Change insert mode / clipboard copy&paste
	case VK_INSERT:

		if(fCtrlDown)
		{
			OnCopy();
			NotifyParent(TVN_CHANGED);
		}
		else if(fShiftDown)
		{
			OnPaste();
			NotifyParent(TVN_CHANGED);
		}
		else
		{
			if(m_nEditMode == MODE_INSERT)
				m_nEditMode = MODE_OVERWRITE;

			else if(m_nEditMode == MODE_OVERWRITE)
				m_nEditMode = MODE_INSERT;

			NotifyParent(TVN_EDITMODE_CHANGE);
		}

		return 0;

	case VK_DELETE:

		if(m_nEditMode != MODE_READONLY)
		{
			if(fShiftDown)
				OnCut();
			else
				ForwardDelete();

			NotifyParent(TVN_CHANGED);
		}
		return 0;

	case VK_BACK:

		if(m_nEditMode != MODE_READONLY)
		{
			BackDelete();
			fAdvancing = FALSE;

			NotifyParent(TVN_CHANGED);
		}
		return 0;

	case VK_LEFT:

		if(fCtrlDown)	MoveWordPrev();
		else			MoveCharPrev();

		fAdvancing = FALSE;
		break;

	case VK_RIGHT:
		
		if(fCtrlDown)	MoveWordNext();
		else			MoveCharNext();
			
		fAdvancing = TRUE;
		break;

	case VK_UP:
		if(fCtrlDown)	Scroll(0, -1);
		else			MoveLineUp(1);
		break;

	case VK_DOWN:
		if(fCtrlDown)	Scroll(0, 1);
		else			MoveLineDown(1);
		break;

	case VK_PRIOR:
		if(!fCtrlDown)	MovePageUp();
		break;

	case VK_NEXT:
		if(!fCtrlDown)	MovePageDown();
		break;

	case VK_HOME:
		if(fCtrlDown)	MoveFileStart();
		else			MoveLineStart(m_nCurrentLine);
		break;

	case VK_END:
		if(fCtrlDown)	MoveFileEnd();
		else			MoveLineEnd(m_nCurrentLine);
		break;

	default:
		return 0;
	}

	// Extend selection if <shift> is down
	if(fShiftDown)
	{		
		InvalidateRange(m_nSelectionEnd, oldCursorOffset);
		//m_nSelectionEnd	= m_nCursorOffset;
	}
	// Otherwise clear the selection
	else
	{
		if(m_nSelectionStart != m_nSelectionEnd)
			InvalidateRange(m_nSelectionStart, m_nSelectionEnd);

		//m_nSelectionEnd		= m_nCursorOffset;
		m_nSelectionStart = m_nSelectionEnd;
	}

	// update caret-location (xpos, line#) from the offset
	//UpdateCaretOffset(m_nCursorOffset, fAdvancing, &m_nCaretPosX, &m_nCurrentLine);
	CHAR_POS cp;
	FilePosToCharPos(m_nSelectionEnd, &cp);
	m_nCurrentLine_D = cp.logLine;
	
	// maintain the caret 'anchor' position *except* for up/down actions
	if(nKeyCode != VK_UP && nKeyCode != VK_DOWN)
	{
		//m_nAnchorPosX = m_nCaretPosX;

		// scroll as necessary to keep caret within viewport
		//ScrollToPosition(m_nCaretPosX, m_nCurrentLine);
	}
	else
	{
		// scroll as necessary to keep caret within viewport
		if(!fCtrlDown);
			//ScrollToPosition(m_nCaretPosX, m_nCurrentLine);
	}

	NotifyParent(TVN_CURSOR_CHANGE);

	return 0;
}
Пример #17
0
void TextControl::OnCommandSelectAll(wxCommandEvent& WXUNUSED(event))
{
    SelectAll();
}
void
KeepAliveRPC::SetValue(int v)
{
    value = v;
    SelectAll();
}
Пример #19
0
void CChildView::OnLButtonDown(UINT nFlags, CPoint point) 
{
  int i;
  CPoint pt;
  CContentObjects& objs = theApp.m_map.Content.Objects;
  CContentObj *o2;
  BOOL ShiftPressed = nFlags & MK_SHIFT;

  if (theApp.m_map.IsEmpty() || m_InPopup) goto mend;

  SetFocus();

  i = m_NewObjectType;
  m_NewObjectType = 0;
  if (i)
    SelectAll(FALSE);
  switch (i) {
  case otTextLabel:
    SetArrowCursor();
    CTextProps *tp;
    tp = new CTextProps(this);
    if (tp->DoModal() == IDOK) {
      CContentText *ct = new CContentText(theApp.m_map.Content);
      ct->StyleIdx = m_DefStyleIdx;
      ct->SetText(tp->m_EditText);
      pt = ScreenToMap(point);
//      ct->SetPosition(pt.x, pt.y);
      ct->SetPosition(pt.x - ct->BoundsRect.Width()/2, pt.y - ct->BoundsRect.Height()/2);
      ct->Plane = theApp.m_map.m_iLevel;
      ct->Selected = TRUE;
      m_ObjSelCount++;
      theApp.m_map.Content.Objects.Add(ct);
      InvalidateObj(ct);
      theApp.m_map.Content.Modified = TRUE;
    }
    return;
  case otMark:
    SetArrowCursor();
    CNewMarkDlg dlg(this);
    if (dlg.DoModal() == IDOK) {
      CContentMark *cm = new CContentMark(theApp.m_map.Content);
      cm->Category = dlg.m_CategoryIdx;
      cm->ShortText = dlg.m_ShortText;
      cm->LongText = dlg.m_LongText;
      pt = ScreenToMap(point);
      cm->SetPosition(pt.x - cm->BoundsRect.Width()/2, pt.y - cm->BoundsRect.Height()/2);
      cm->Plane = theApp.m_map.m_iLevel;
      cm->Selected = TRUE;
      m_ObjSelCount++;
      theApp.m_map.Content.Objects.Add(cm);
      InvalidateObj(cm);
      theApp.m_map.Content.Modified = TRUE;
    }
    return;
  }

  pt = ScreenToMap(point);
  o2 = theApp.m_map.Content.GetObjectAt(pt, theApp.m_map.m_iLevel);

  if (!m_EditorMode) {
    if (ShiftPressed) {
      i = g_pMainFrame->m_cbZoom.GetCurSel();
      if (nFlags & MK_CONTROL) {
        m_LastZoomIdx = i;
        i = 1;
        keybd_event('~', 0, 0, 0);  // Disables kbd layout switching by Ctrl+Shift
      }
      else 
        m_LastZoomIdx = -1;
      if (i > 0) {
        ChangeZoom(point, i - 1);
      }
    }
    else {
      if (o2 && o2->GetType() == otMark && !(theApp.m_map.Content.DrawOptions & cdoHideAll)) {
        BYTE dm = ((CContentMark*)o2)->DisplayMode;
        HideMarkDescriptions();
        if (dm != dmExpanded) {
          ((CContentMark*)o2)->DisplayMode = dmExpanded;
          o2->Selected = FALSE;
          InvalidateObj(o2);
        }
      }
      else {
        m_Moving = FALSE;
        m_ptClick = point;
        SetViewCursor(m_DragHand2Cur);
        SetCapture();
      }
    }
  }
  else {
    SelClick(point); 
    m_ptClick = point;
    SetCapture();
    m_Moving = FALSE;
    if (!o2) {
      m_Selection.left = m_Selection.right = point.x;
      m_Selection.top = m_Selection.bottom = point.y;
    }
    else 
      m_Selection.SetRectEmpty();
  }
mend:  
	CWnd ::OnLButtonDown(nFlags, point);
}
Пример #20
0
/// <summary>
/// Handles window messages.
/// </summary>
LRESULT WINAPI TileGroup::HandleMessage(HWND window, UINT message, WPARAM wParam, LPARAM lParam, LPVOID) {
  if (message == mChangeNotifyMsg) {
    return HandleChangeNotify(HANDLE(wParam), DWORD(lParam));
  }

  if (mContextMenu3) {
    LRESULT result;
    if (SUCCEEDED(mContextMenu3->HandleMenuMsg2(message, wParam, lParam, &result))) {
      return result;
    }
  }

  if (mContextMenu2) {
    if (SUCCEEDED(mContextMenu2->HandleMenuMsg(message, wParam, lParam))) {
      return 0;
    }
  }

  switch (message) {
  case WM_KEYDOWN:
    switch (wParam) {
    case 'A':
      if (GetKeyState(VK_CONTROL) < 0) {
        SelectAll();
      }
      break;

    case 'C':
      if (GetKeyState(VK_CONTROL) < 0) {
        DoCopy(false);
      }
      break;

    case 'V':
      if (GetKeyState(VK_CONTROL) < 0) {
        DoPaste();
      }
      break;

    case 'X':
      if (GetKeyState(VK_CONTROL) < 0) {
        DoCopy(true);
      }
      break;

    case 'Z':
      if (GetKeyState(VK_CONTROL) < 0) {
        DoUndo();
      }
      break;

    case VK_DELETE:
      DeleteSelectedFiles();
      break;

    case VK_RETURN:
      OpenSelectedFiles();
      break;

    case VK_F2:
      RenameSelectedFiles();
      break;

    case VK_F5:
      UpdateAllIcons();
      break;

    case VK_UP:
    case VK_DOWN:
    case VK_LEFT:
    case VK_RIGHT:
      break;
    }
    break;

  case WM_LBUTTONDOWN:
  case WM_RBUTTONDOWN:
    if (!mInRectangleSelection) {
      StartRectangleSelection(D2D1::Point2U(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
    } else {
      EndRectangleSelection(D2D1::Point2U(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
    }
    break;

  case WM_MOUSEMOVE:
    if (mInRectangleSelection) {
      MoveRectangleSelection(D2D1::Point2U(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
    }
    break;

  case WM_LBUTTONUP:
  case WM_RBUTTONUP:
    if (mInRectangleSelection) {
      EndRectangleSelection(D2D1::Point2U(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
    } else if (GetKeyState(VK_CONTROL) >= 0) {
      DeselectAll();
    }
    break;

  case Window::WM_TOPPARENTLOST:
    mChangeNotifyMsg = 0;
    if (mChangeNotifyUID != 0) {
      SHChangeNotifyDeregister(mChangeNotifyUID);
      mChangeNotifyUID = 0;
    }
    break;

  case Window::WM_NEWTOPPARENT:
    {
      // TODO(Erik): This is unacceptable. We have to pick up change notifications while we don't
      // have a top parent.
      IPersistFolder2 *ipsf2;
      LPITEMIDLIST curFolder;
      HRESULT hr;

      mChangeNotifyMsg = mWindow->RegisterUserMessage(this);

      if (SUCCEEDED(hr = mWorkingFolder->QueryInterface(IID_IPersistFolder2, (LPVOID*)&ipsf2))) {
        if (SUCCEEDED(hr = ipsf2->GetCurFolder(&curFolder))) {
          // (Re)Register for change notifications
          SHChangeNotifyEntry watchEntries[] = { curFolder, FALSE };
          mChangeNotifyUID = SHChangeNotifyRegister(
            window,
            CHANGE_SOURCES,
            CHANGE_EVENTS,
            mChangeNotifyMsg,
            1,
            watchEntries);

          // Let go fo the PIDLists
          CoTaskMemFree(curFolder);
        }
        ipsf2->Release();
      }
    }
    break;
  }

  mEventHandler->HandleMessage(window, message, wParam, lParam);
  return DefWindowProc(window, message, wParam, lParam);
}
Пример #21
0
bool LineEdit::Key(dword key, int count) {
	NextUndo();
	switch(key) {
	case K_CTRL_UP:
		ScrollUp();
		return true;
	case K_CTRL_DOWN:
		ScrollDown();
		return true;
	case K_INSERT:
		OverWriteMode(!IsOverWriteMode());
		break;
	}
	bool sel = key & K_SHIFT;
	dorectsel = key & K_ALT;
	dword k = key & ~K_SHIFT;
	if((key & (K_SHIFT|K_ALT)) == (K_SHIFT|K_ALT))
		k &= ~K_ALT;
	switch(k) {
	case K_CTRL_LEFT:
		{
			PlaceCaret(GetPrevWord(cursor), sel);
			break;
		}
	case K_CTRL_RIGHT:
		{
			PlaceCaret(GetNextWord(cursor), sel);
			break;
		}
	case K_LEFT:
		MoveLeft(sel);
		break;
	case K_RIGHT:
		MoveRight(sel);
		break;
	case K_HOME:
		MoveHome(sel);
		break;
	case K_END:
		MoveEnd(sel);
		break;
	case K_UP:
		MoveUp(sel);
		break;
	case K_DOWN:
		MoveDown(sel);
		break;
	case K_PAGEUP:
		MovePageUp(sel);
		break;
	case K_PAGEDOWN:
		MovePageDown(sel);
		break;
	case K_CTRL_PAGEUP:
	case K_CTRL_HOME:
		MoveTextBegin(sel);
		break;
	case K_CTRL_PAGEDOWN:
	case K_CTRL_END:
		MoveTextEnd(sel);
		break;
	case K_CTRL_C:
	case K_CTRL_INSERT:
		Copy();
		break;
	case K_CTRL_A:
		SelectAll();
		break;
	default:
		dorectsel = false;
		if(IsReadOnly())
			return MenuBar::Scan(WhenBar, key);
		switch(key) {
		case K_DELETE:
			DeleteChar();
			break;
		case K_BACKSPACE:
		case K_SHIFT|K_BACKSPACE:
			Backspace();
			break;
		case K_SHIFT_TAB:
			AlignChar();
			break;
		case K_CTRL_Y:
		case K_CTRL_L:
			if(cutline) {
				CutLine();
				break;
			}
		default:
			if(InsertChar(key, count, true))
				return true;
			return MenuBar::Scan(WhenBar, key);
		}
		return true;
	}
	dorectsel = false;
	Sync();
	return true;
}