Exemple #1
0
bool CRecentImp<T, S>::AppendItem( ReceiveType pItemData )
{
	int		i;

	if( !IsAvailable() ) return false;
	if( !pItemData ) return false;
	if( false == ValidateReceiveType(pItemData) ) return false;

	//登録済みか調べる。
	int	nIndex = FindItem( pItemData );
	if( nIndex >= 0 )
	{
		CopyItem( GetItemPointer(nIndex), pItemData );

		//先頭に持ってくる。
		MoveItem( nIndex, 0 );
		goto reconfigure;
	}

	//いっぱいのときは最古の通常アイテムを削除する。
	if( m_nArrayCount <= *m_pnUserItemCount )
	{
		nIndex = GetOldestItem( *m_pnUserItemCount - 1, false );
		if( -1 == nIndex )
		{
			return false;
		}

		DeleteItem( nIndex );
	}

	for( i = *m_pnUserItemCount; i > 0; i-- )
	{
		CopyItem( i - 1, i );
	}

	CopyItem( GetItemPointer(0), pItemData );

	//(void)SetFavorite( 0, true );
	//内部処理しないとだめ。
	if( m_pbUserItemFavorite ) m_pbUserItemFavorite[0] = false;

	*m_pnUserItemCount += 1;


reconfigure:
	//お気に入りを表示内に移動する。
	if( m_pnUserViewCount )
	{
		ChangeViewCount( *m_pnUserViewCount );
	}
	return true;
}
void CFavoriteOrganizeDlg::OnUpBnClicked()
{
    POSITION pos = m_list.GetFirstSelectedItemPosition();

    while (pos) {
        int nItem = m_list.GetNextSelectedItem(pos);
        if (nItem <= 0 || nItem >= m_list.GetItemCount()) {
            return;
        }

        MoveItem(nItem, -1);
    }
}
void FieldSelectionPanel::OnRemoveSome( wxCommandEvent& /* evt */ )
{
  wxArrayInt aSelected;
  if (m_lbSelected->GetSelections(aSelected)) {
    aSelected.Sort(pless);
    for (size_t idx = 0, nRemoved = 0; idx < aSelected.GetCount(); ++idx) {
      const int listIndex = aSelected[idx] - nRemoved;
      if (!ItemIsMandatory(listIndex)) {
        MoveItem(listIndex, m_lbSelected, m_lbAvailable);
        nRemoved++;
      }
    }
  }
}
Exemple #4
0
enum ActionMenu StageMain(int *stageState, char *mapName)
{
    static int bgm = - 1;
    static char name[MAX_PATH];
    
    switch (*stageState) {
    case 0:
        map = ReadMap(mapName);
#if !MAP_EDIT_MODE
        GetBgmName(name, mapName);
        bgm = LoadSound(name);
#endif        
        *stageState = 1;
        break;

    case 1:
        {
            InitMap(map);
            CreateObject(map);
            DrawMain = StageDraw;
            LoopSound(bgm);
            *stageState = 2;
        }
        break;

    case 2:
            MoveMap(map);
            MoveEnemy(map);
            MoveItem(map);
            MoveBomb(map);
            MoveEnemy(map);
            MovePlayer(map);
            if (IsPlayerDie()) {
                SoundPlay(res.sound_die);
                life--;
                if (life < 0) {
                    FreeStage(map, stageState, bgm);
                    return MENU_GAMEOVER;
                }
                *stageState = 1;
            }
            if (IsPlayerClear()) {
                FreeStage(map, stageState, bgm);
                return MENU_CLEAR;
            }
            break;
    }
    return MENU_STAGE;
}
void MailEwsSubscriptionCallback:: CopyItem(const char * oldParentFolderId,
                                            const char * parentFolderId,
                                            const char * oldItemId,
                                            const char * itemId){
    mailews_logger << "Copy Item:"
              << oldParentFolderId
              << "," << parentFolderId
              << "," << oldItemId
              << "," << itemId
              << std::endl;

    MoveItem(oldParentFolderId,
             parentFolderId,
             oldItemId,
             itemId);
}
Exemple #6
0
//把一段有父子关系的Tree移动到新父亲结点的末尾
void MoveItemToLast(HTREEITEM m_startItem, HTREEITEM pItem)
{
	HTREEITEM tempItem,nItem;
	CMainFrame * pFWnd = (CMainFrame *)AfxGetMainWnd();
	CModelTree * pTreeView = (CModelTree *)pFWnd->m_wndSplitter1.GetPane(0,2);
	CTreeCtrl& m_ctlTree = pTreeView->GetTreeCtrl();

	nItem=m_ctlTree.GetChildItem(pItem);//得到第一个子节点
	tempItem=nItem;
	while(nItem!=NULL)//如果存在子节点
	{
		nItem=tempItem;
		tempItem=m_ctlTree.GetNextSiblingItem(nItem);//得到下一个兄弟节点
	}
	MoveItem(m_startItem, pItem, nItem);
}
Exemple #7
0
/**
 * @brief Move selected items one position up or down.
 * @param [in] bUp If TRUE items are moved up,
 *  if FALSE items are moved down.
 */
void CDirColsDlg::MoveSelectedItems(bool bUp)
{
	int firstInd = -1;
	POSITION pos = m_listColumns.GetFirstSelectedItemPosition();

	while (pos)
	{
		int ind = m_listColumns.GetNextSelectedItem(pos);
		int newInd = bUp ? ind - 1: ind + 1;
		
		// Remember first item
		if (firstInd == -1)
			firstInd = newInd;
		MoveItem(ind, newInd);
	}
	m_listColumns.EnsureVisible(firstInd, FALSE);
}
void CFavoriteOrganizeDlg::OnDownBnClicked()
{
    CArray<int> selectedItems;
    POSITION pos = m_list.GetFirstSelectedItemPosition();

    while (pos) {
        int nItem = m_list.GetNextSelectedItem(pos);
        if (nItem < 0 || nItem >= m_list.GetItemCount() - 1) {
            return;
        }

        selectedItems.Add(nItem);
    }

    for (INT_PTR i = selectedItems.GetSize() - 1; i >= 0; i--) {
        MoveItem(selectedItems[i], +1);
    }
}
SCH_SHEET_PIN* SCH_EDIT_FRAME::ImportSheetPin( SCH_SHEET* aSheet, wxDC* aDC )
{
    EDA_ITEM*      item;
    SCH_SHEET_PIN* sheetPin;
    SCH_HIERLABEL* label = NULL;

    if( !aSheet->GetScreen() )
        return NULL;

    item = aSheet->GetScreen()->GetDrawItems();

    for( ; item != NULL; item = item->Next() )
    {
        if( item->Type() != SCH_HIERARCHICAL_LABEL_T )
            continue;

        label = (SCH_HIERLABEL*) item;

        /* A global label has been found: check if there a corresponding sheet label. */
        if( !aSheet->HasPin( label->GetText() ) )
            break;

        label = NULL;
    }

    if( label == NULL )
    {
        DisplayInfoMessage( this, _( "No new hierarchical labels found." ) );
        return NULL;
    }

    sheetPin = new SCH_SHEET_PIN( aSheet, wxPoint( 0, 0 ), label->GetText() );
    sheetPin->SetFlags( IS_NEW );
    sheetPin->SetSize( m_lastSheetPinTextSize );
    m_lastSheetPinType = label->GetShape();
    sheetPin->SetShape( label->GetShape() );
    sheetPin->SetPosition( GetCrossHairPosition() );

    sheetPin->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode );
    MoveItem( (SCH_ITEM*) sheetPin, aDC );

    return sheetPin;
}
void SCH_EDIT_FRAME::RepeatDrawItem( wxDC* DC )
{
    SCH_ITEM*   repeater = GetRepeatItem();

    if( !repeater )
        return;

    //D( repeater>Show( 0, std::cout ); )

    // clone the repeater, move it, insert into display list, then save a copy
    // via SetRepeatItem();

    SCH_ITEM* my_clone = (SCH_ITEM*) repeater->Clone();

    // If cloning a component then put into 'move' mode.
    if( my_clone->Type() == SCH_COMPONENT_T )
    {
        wxPoint pos = GetCrossHairPosition() -
                      ( (SCH_COMPONENT*) my_clone )->GetPosition();

        my_clone->SetFlags( IS_NEW );
        ( (SCH_COMPONENT*) my_clone )->SetTimeStamp( GetNewTimeStamp() );
        my_clone->Move( pos );
        my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), g_XorMode );
        MoveItem( my_clone, DC );
    }
    else
    {
        my_clone->Move( wxPoint( g_RepeatStep.GetWidth(), g_RepeatStep.GetHeight() ) );

        if( my_clone->CanIncrementLabel() )
            ( (SCH_TEXT*) my_clone )->IncrementLabel();

        GetScreen()->Append( my_clone );
        GetScreen()->TestDanglingEnds();
        my_clone->Draw( m_canvas, DC, wxPoint( 0, 0 ), GR_DEFAULT_DRAWMODE );
        SaveCopyInUndoList( my_clone, UR_NEW );
        my_clone->ClearFlags();
    }

    // clone my_clone, now that it has been moved, thus saving new position.
    SetRepeatItem( my_clone );
}
Exemple #11
0
/**
 * @brief Move hidden columns as last items in the list.
 */
void CDirColsDlg::SanitizeOrder()
{
	// Find last visible column.
	int i = m_listColumns.GetItemCount() - 1;
	for ( ; i >= 0; i--)
	{
		if (m_listColumns.GetCheck(i))
			break;
	}

	// Move all hidden columns below last visible column.
	for (int j = i; j >= 0; j--)
	{
		if (!m_listColumns.GetCheck(j))
		{
			MoveItem(j, i);
			i--;
		}
	}
}
Exemple #12
0
bool CRecentImp<T, S>::ChangeViewCount( int nViewCount )
{
	int	i;
	int	nIndex;

	//範囲外ならエラー
	if( ! IsAvailable() ) return false;
	if( nViewCount < 0 || nViewCount > m_nArrayCount ) return false;

	//表示個数を更新する。
	if( m_pnUserViewCount )
	{
		*m_pnUserViewCount = nViewCount;
	}

	//範囲内にすべて収まっているので何もしなくてよい。
	if( nViewCount >= *m_pnUserItemCount ) return true;

	//最も古いお気に入りを探す。
	i = GetOldestItem( *m_pnUserItemCount - 1, true );
	if( -1 == i ) return true;	//ないので何もしないで終了

	//表示外アイテムを表示内に移動する。
	for( ; i >= nViewCount; i-- )
	{
		if( IsFavorite( i ) )
		{
			//カレント位置から上に通常アイテムを探す
			nIndex = GetOldestItem( i - 1, false );
			if( -1 == nIndex ) break;	//もう1個もない

			//見つかったアイテムをカレント位置に移動する
			MoveItem( nIndex, i );
		}
	}

	return true;
}
/* Handles the selection of tools, menu, and popup menu commands.
 */
void PL_EDITOR_FRAME::Process_Special_Functions( wxCommandEvent& event )
{
    int id = event.GetId();
    int idx;
    wxString msg;
    WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
    WORKSHEET_DATAITEM* item = NULL;
    wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
    cmd.SetEventObject( this );

    switch( id )
    {
    case ID_NO_TOOL_SELECTED:
        SetNoToolSelected();
        break;

    case ID_MENU_ZOOM_SELECTION:
    case ID_ZOOM_SELECTION:
        // This tool is located on the main toolbar: switch it on or off on click
        if( GetToolId() != ID_ZOOM_SELECTION )
            SetToolID( ID_ZOOM_SELECTION, wxCURSOR_MAGNIFIER, _( "Zoom to selection" ) );
        else
            SetNoToolSelected();
        break;

    case ID_SELECT_PAGE_NUMBER:
        m_canvas->Refresh();
        break;

    case ID_SHEET_SET:
        {
        DIALOG_PAGES_SETTINGS dlg( this );
        dlg.SetWksFileName( GetCurrFileName() );
        dlg.EnableWksFileNamePicker( false );
        dlg.ShowModal();

        cmd.SetId( ID_ZOOM_PAGE );
        wxPostEvent( this, cmd );
        }
        break;

    case ID_POPUP_CANCEL_CURRENT_COMMAND:
        if( m_canvas->IsMouseCaptured() )
        {
            m_canvas->EndMouseCapture();
            SetToolID( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString );
        }
        else
        {
            SetNoToolSelected();
        }
        break;

    case ID_POPUP_DESIGN_TREE_ITEM_DELETE:
    case ID_POPUP_ITEM_DELETE:
    case wxID_CUT:
        // Delete item, and select the previous item
        item = m_treePagelayout->GetPageLayoutSelectedItem();

        if( item == NULL )
            break;

        SaveCopyInUndoList();
        idx = pglayout.GetItemIndex( item );
        pglayout.Remove( item );
        RebuildDesignTree();

        if( id == ID_POPUP_DESIGN_TREE_ITEM_DELETE )
        {
            item = pglayout.GetItem( (unsigned) (idx-1) );

            if( item )
                m_treePagelayout->SelectCell( item );
        }

        item = NULL;
        OnModify();
        m_canvas->Refresh();
        break;

    case ID_POPUP_ITEM_ADD_LINE:
        SaveCopyInUndoList();
        idx =  m_treePagelayout->GetSelectedItemIndex();
        item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_SEGMENT, idx );

        if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
        {
            RemoveLastCommandInUndoList();
            pglayout.Remove( item );
            RebuildDesignTree();
            item = NULL;
        }
        else
        {
            // Put the new item in move mode, after putting the cursor
            // on the start point:
            wxPoint position = item->GetStartPosUi();
            SetCrossHairPosition( position, false );
            position = GetCrossHairPosition();

            if( m_canvas->IsPointOnDisplay( position ) )
                m_canvas->MoveCursorToCrossHair();
            else
                RedrawScreen( position, true );

            item->SetFlags( NEW_ITEM );
            MoveItem( item );
        }
        break;

    case ID_POPUP_ITEM_ADD_RECT:
        SaveCopyInUndoList();
        idx =  m_treePagelayout->GetSelectedItemIndex();
        item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_RECT, idx );

        if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
        {
            RemoveLastCommandInUndoList();
            pglayout.Remove( item );
            RebuildDesignTree();
            item = NULL;
        }
        else
        {
            // Put the new item in move mode, after putting the cursor
            // on the start point:
            wxPoint position = item->GetStartPosUi();
            SetCrossHairPosition( position, false );
            position = GetCrossHairPosition();

            if( m_canvas->IsPointOnDisplay( position ) )
                m_canvas->MoveCursorToCrossHair();
            else
                RedrawScreen( position, true );

            item->SetFlags( NEW_ITEM );
            MoveItem( item );
        }
        break;

    case ID_POPUP_ITEM_ADD_TEXT:
        SaveCopyInUndoList();
        idx =  m_treePagelayout->GetSelectedItemIndex();
        item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_TEXT, idx );
        if( InvokeDialogNewItem( this, item ) == wxID_CANCEL )
        {
            RemoveLastCommandInUndoList();
            pglayout.Remove( item );
            RebuildDesignTree();
            item = NULL;
        }
        else
        {
            // Put the new text in move mode:
            item->SetFlags( NEW_ITEM | LOCATE_STARTPOINT );
            MoveItem( item );
        }
        break;

    case ID_POPUP_ITEM_ADD_BITMAP:
        SaveCopyInUndoList();
        idx =  m_treePagelayout->GetSelectedItemIndex();
        item = AddPageLayoutItem( WORKSHEET_DATAITEM::WS_BITMAP, idx );
        if( item && InvokeDialogNewItem( this, item ) == wxID_CANCEL )
        {
            RemoveLastCommandInUndoList();
            pglayout.Remove( item );
            RebuildDesignTree();
            item = NULL;
        }
        if( item )
        {
            // Put the new text in move mode:
            item->SetFlags( NEW_ITEM | LOCATE_STARTPOINT );
            MoveItem( item );
        }
        break;

    case ID_POPUP_ITEM_APPEND_PAGE_LAYOUT:
        cmd.SetId( ID_APPEND_DESCR_FILE );
        wxPostEvent( this, cmd );
        break;

    case ID_POPUP_ITEM_PLACE:
        item = GetScreen()->GetCurItem();
        PlaceItem( item );
        break;

    case ID_POPUP_ITEM_PLACE_CANCEL:
        if(  m_canvas->IsMouseCaptured() )
             m_canvas->EndMouseCapture();
        break;

    case ID_POPUP_ITEM_MOVE_START_POINT:
        item = m_treePagelayout->GetPageLayoutSelectedItem();
        // Ensure flags are properly set
        item->ClearFlags( LOCATE_ENDPOINT );
        item->SetFlags( LOCATE_STARTPOINT );
        MoveItem( item );
        break;

    case ID_POPUP_ITEM_MOVE_END_POINT:
        item = m_treePagelayout->GetPageLayoutSelectedItem();
        // Ensure flags are properly set
        item->ClearFlags( LOCATE_STARTPOINT );
        item->SetFlags( LOCATE_ENDPOINT );
        MoveItem( item );
        break;

    case ID_POPUP_ITEM_MOVE:
        item = m_treePagelayout->GetPageLayoutSelectedItem();
        item->ClearFlags( LOCATE_ENDPOINT|LOCATE_STARTPOINT );
        MoveItem( item );
        break;

    default:
        wxMessageBox( wxT( "PL_EDITOR_FRAME::Process_Special_Functions error" ) );
        break;
    }

    if( item )
    {
        OnModify();
        m_propertiesPagelayout->CopyPrmsFromItemToPanel( item );
        m_treePagelayout->SelectCell( item );
    }

}
void SCH_EDIT_FRAME::OnMoveItem( wxCommandEvent& aEvent )
{
    SCH_SCREEN* screen = GetScreen();
    SCH_ITEM*   item = screen->GetCurItem();

    if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
    {
        // trying to move an item when there is a block at the same time is not acceptable
        return;
    }

    if( item == NULL )
    {
        // If we didn't get here by a hot key, then something has gone wrong.
        if( aEvent.GetInt() == 0 )
            return;

        EDA_HOTKEY_CLIENT_DATA* data = (EDA_HOTKEY_CLIENT_DATA*) aEvent.GetClientObject();

        wxCHECK_RET( data != NULL, wxT( "Invalid hot key client object." ) );

        item = LocateAndShowItem( data->GetPosition(), SCH_COLLECTOR::MovableItems,
                                  aEvent.GetInt() );

        // Exit if no item found at the current location or the item is already being edited.
        if( (item == NULL) || (item->GetFlags() != 0) )
            return;
    }

    INSTALL_UNBUFFERED_DC( dc, m_canvas );

    switch( item->Type() )
    {
    case SCH_LINE_T:
        break;

    case SCH_JUNCTION_T:
    case SCH_NO_CONNECT_T:
    case SCH_BUS_BUS_ENTRY_T:
    case SCH_BUS_WIRE_ENTRY_T:
    case SCH_LABEL_T:
    case SCH_GLOBAL_LABEL_T:
    case SCH_HIERARCHICAL_LABEL_T:
    case SCH_TEXT_T:
    case SCH_COMPONENT_T:
    case SCH_SHEET_PIN_T:
    case SCH_FIELD_T:
        MoveItem( item, &dc );
        break;

    case SCH_BITMAP_T:
        MoveImage( (SCH_BITMAP*) item, &dc );
        break;

    case SCH_SHEET_T:
        StartMoveSheet( (SCH_SHEET*) item, &dc );
        break;

    case SCH_MARKER_T:
    default:
        wxFAIL_MSG( wxString::Format( wxT( "Cannot move item type %s" ),
                                      GetChars( item->GetClass() ) ) );
        break;
    }

    if( GetToolId() == ID_NO_TOOL_SELECTED )
        SetRepeatItem( NULL );
}
BOOL CDlgExpEditorDM::OnInitDialog()
{
	// TODO:  在此添加额外的初始化

	Json::Reader jR;
	if(!jR.parse(std::string(m_strExp), m_Jv))
	{//解析失败
		EndDialog(0);
		return TRUE;
	}

	Json::Value& jStr = m_Jv["ShowRootFlag"];
	m_IsShowRoot = TRUE;
	std::string str = jStr.asString();
	if(str.empty() || str == "false")
	{
		m_IsShowRoot = FALSE;
	}

	//20140526,lc,修改为左侧树不初始化,影响加载效率,因为后期设计中已无左侧树
	m_IsInitTree = FALSE;

	m_strExp = m_Jv["OldExp"].asString().c_str();

	CDlgExpEditor::OnInitDialog();

	GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_HIDE);
	GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
	GetDlgItem(IDC_BUTTON3)->ShowWindow(SW_HIDE);
	GetDlgItem(IDC_BUTTON4)->ShowWindow(SW_HIDE);
	GetDlgItem(IDC_BUTTON5)->ShowWindow(SW_HIDE);
	GetDlgItem(IDC_BUTTON6)->ShowWindow(SW_HIDE);

	GetDlgItem(IDC_BUTTON13)->ShowWindow(SW_HIDE);
	GetDlgItem(IDC_BUTTON14)->ShowWindow(SW_HIDE);
	GetDlgItem(IDC_BUTTON15)->ShowWindow(SW_HIDE);
	GetDlgItem(IDC_BUTTON16)->ShowWindow(SW_HIDE);
	GetDlgItem(IDC_BUTTON17)->ShowWindow(SW_HIDE);

	int d = 20;
	MoveItemUp(GetDlgItem(IDC_BUTTON7), GetDlgItem(IDC_EDIT_EXP), d);
	MoveItemUp(GetDlgItem(IDC_BUTTON8), GetDlgItem(IDC_EDIT_EXP), d);
	MoveItemUp(GetDlgItem(IDC_BUTTON9), GetDlgItem(IDC_EDIT_EXP), d);
	MoveItemUp(GetDlgItem(IDC_BUTTON10), GetDlgItem(IDC_EDIT_EXP), d);
	MoveItemUp(GetDlgItem(IDC_BUTTON11), GetDlgItem(IDC_EDIT_EXP), d);
	MoveItemUp(GetDlgItem(IDC_BUTTON12), GetDlgItem(IDC_EDIT_EXP), d);

	MoveItemUp(GetDlgItem(IDOK), GetDlgItem(IDC_BUTTON7), d);
	int nD= MoveItemUp(GetDlgItem(IDCANCEL), GetDlgItem(IDC_BUTTON7), d);

	CRect rect;
	GetDlgItem(IDC_STATIC_TREE)->GetWindowRect(rect);
	rect.DeflateRect(0, 0, 0, nD);
	ScreenToClient(rect);
	GetDlgItem(IDC_STATIC_TREE)->MoveWindow(rect);

	GetWindowRect(rect);
	rect.DeflateRect(0, 0, 0, nD);
	MoveWindow(rect);


	if(true)
	{//隐藏树
		CWnd& m_wndTreeLocation = *GetDlgItem(IDC_STATIC_TREE);
		m_wndGridTree.ShowWindow(SW_HIDE);
		m_wndTreeLocation.ShowWindow(SW_HIDE);
		CRect rect;
		m_wndTreeLocation.GetWindowRect(rect);
		int d = rect.Width() + 10;

		MoveItem(GetDlgItem(IDC_BUTTON7), LEFT, d);
		MoveItem(GetDlgItem(IDC_BUTTON8), LEFT, d);
		MoveItem(GetDlgItem(IDC_BUTTON9), LEFT, d);
		MoveItem(GetDlgItem(IDC_BUTTON10), LEFT, d);
		MoveItem(GetDlgItem(IDC_BUTTON11), LEFT, d);
		MoveItem(GetDlgItem(IDC_BUTTON12), LEFT, d);

		MoveItem(GetDlgItem(IDOK), LEFT, d);
		MoveItem(GetDlgItem(IDCANCEL), LEFT, d);

		MoveItem(GetDlgItem(IDC_EDIT_EXP), LEFT, d);

		GetWindowRect(rect);
		rect.DeflateRect(0, 0, d, 0);
		MoveWindow(rect);
	}

	return FALSE;
}
Exemple #16
0
/**
 * name:	MoveItem()
 * class:	CPsTree
 * desc:	moves a treeitem and its children to a new position
 * param:	pPs					- datastructure of the propertysheetpage
 *			hItem				- the HTREEITEM to move
 *			hInsertAfter		- the HTREEITEM to insert hItem after
 *			bAsChild			- tells, whether to try to add hItem as child of hInsertAfter or not
 * return:	handle to new (moved) treeitem if successful or NULL otherwise
 **/
HTREEITEM CPsTree::MoveItem(HTREEITEM hItem, HTREEITEM hInsertAfter, BYTE bAsChild)
{
	TVINSERTSTRUCT tvis;
	HTREEITEM hParent, hChild, hNewItem;
	int iItemIndex;

	if (!hItem || !hInsertAfter)
		return NULL;
	if (hItem == hInsertAfter)
		return hItem;
	
	switch ((ULONG_PTR)hInsertAfter) {
		case TVI_ROOT:
		case TVI_FIRST:
		case TVI_LAST:
			hParent = NULL;
			bAsChild = FALSE;
			break;
		default:
			hParent = TreeView_GetParent(_hWndTree, hInsertAfter);
			break;
	}
	// do not move a parent next to its own children!
	if (hItem == hParent)
		return hItem;
	// get detailed information about the item to move
	if (FAILED(iItemIndex = FindItemIndexByHandle(hItem)))
		return hItem;
	
	// item should be inserted as the first child of an existing root item
	if (bAsChild) { 
		tvis.hParent = hInsertAfter;
		tvis.hInsertAfter = (_dwFlags & PSTVF_SORTTREE) ? TVI_SORT : ((bAsChild == 2) ? TVI_LAST : TVI_FIRST);
	}
	// item should be inserted after an existing item
	else {
		tvis.hParent = hParent;
		tvis.hInsertAfter = hInsertAfter;
	}

	// don't move subitems of a protocol to root as this would mean them not to be unique anymore
	if (!_pPs->hContact && (_pItems[iItemIndex]->Flags() & PSPF_PROTOPREPENDED) && !tvis.hParent)
		return hItem;
	
	// prepare the insert structure
	tvis.itemex.mask = TVIF_PARAM|TVIF_TEXT;
	tvis.itemex.state = TVIS_EXPANDED;
	tvis.itemex.stateMask = TVIS_EXPANDED;
	tvis.itemex.pszText = _pItems[iItemIndex]->Label();
	tvis.itemex.lParam = (LPARAM)iItemIndex;
	if ((tvis.itemex.iImage = tvis.itemex.iSelectedImage = _pItems[iItemIndex]->Image()) >= 0)
		tvis.itemex.mask |= TVIF_IMAGE|TVIF_SELECTEDIMAGE;

	// insert the item
	if (!(hNewItem = TreeView_InsertItem(_hWndTree, &tvis)))
		return hItem;
	// update handle pointer in the page structure
	_pItems[iItemIndex]->Hti(hNewItem);
	// get the index of the parent
	_pItems[iItemIndex]->Parent(FindItemIndexByHandle(tvis.hParent));
	// move children
	hInsertAfter = hNewItem;
	while (hChild = TreeView_GetChild(_hWndTree, hItem)) {
		MoveItem(hChild, hInsertAfter, 2);
	}
	// delete old tree
	TreeView_DeleteItem(_hWndTree, hItem);
	_dwFlags |= PSTVF_POS_CHANGED;

	TreeView_SelectItem(_hWndTree, hNewItem);
	TreeView_Expand(_hWndTree, hNewItem, TVE_EXPAND);
	return hNewItem;
}
Exemple #17
0
void WcDependencies::GetDependencies(void)
{
	HRESOURCE hRes = OpenClusterResource(thePreSetup.m_hCluster, CT2CW(thePreSetup.m_ResourceName.GetBuffer()));
	if (hRes == NULL)
		return;

    DWORD dwResult = ERROR_SUCCESS;         // Captures return values
    DWORD dwIndex  = 0;                     // Enumeration index
    DWORD dwType   = CLUSTER_RESOURCE_ENUM_DEPENDS; // Type of object to enumerate 
    DWORD cbNameAlloc =                     // Allocated size of the name buffer
		MAXIMUM_NAMELENGTH * sizeof( WCHAR );
    DWORD cchName = 0;        // Size of the resulting name as a count of wchars

    LPWSTR lpszName =                       // Buffer to hold enumerated names
		(LPWSTR) LocalAlloc( LPTR, cbNameAlloc );
    if (lpszName == NULL)
    {
        dwResult = GetLastError();
        goto endf;
    }

	// Open enumeration handle.
    HRESENUM hResEnum = ClusterResourceOpenEnum( hRes, dwType );
    if (hResEnum == NULL)
    {
        dwResult = GetLastError();
        goto endf;
    }

    while(dwResult == ERROR_SUCCESS)
    {
        cchName = cbNameAlloc / sizeof( WCHAR );

        dwResult = ClusterResourceEnum(
			hResEnum,
			dwIndex,
			&dwType,
			lpszName,
			&cchName);

    	// Reallocate the name buffer if not big enough.
		if (dwResult == ERROR_MORE_DATA)
        {
            cchName++;   // Leave room for terminating NULL.
            cbNameAlloc = cchName / sizeof( WCHAR );
            LocalFree( lpszName );
            lpszName = (LPWSTR) LocalAlloc( LPTR, 
                                            cbNameAlloc );
            if ( lpszName == NULL )
            {
                dwResult = GetLastError();
                goto endf;
            }

            dwResult = ClusterResourceEnum( 
				hResEnum, 
				dwIndex,
				&dwType,
				lpszName,
				&cchName );
        }

        if( dwResult == ERROR_SUCCESS ) 
        {
			int nItem = FindDependency(lpszName, m_ResourceListCtrl);
			if (nItem >= 0)
				MoveItem(nItem, /*from*/m_ResourceListCtrl, /*to*/m_DependencyListCtrl);
        }
        else if( dwResult == ERROR_NO_MORE_ITEMS )
        {
			break;
        }
        else // enum failed for another reason
        {
            dwResult = GetLastError();
            goto endf;
        }
      
        dwIndex++;
    } //  End while.

endf:
	CloseClusterResource(hRes);
}
//**********************************************************************
void CBCGPRibbonCustomizeRibbonPage::OnDown() 
{
	MoveItem (FALSE);
	m_wndDown.SetFocus();
}
Exemple #19
0
 wxTreeItemId HierTreeCtrl::MoveItem(wxTreeItemId& source, wxTreeItemId& destination)
 {
     wxTreeItemId parent = GetItemParent(destination);
     return MoveItem(source, destination, parent);
 }
//**********************************************************************
void CBCGPRibbonCustomizeQATPage::OnUp() 
{
	MoveItem (TRUE);
}
//**********************************************************************
void CBCGPRibbonCustomizeRibbonPage::OnUp() 
{
	MoveItem (TRUE);
	m_wndUp.SetFocus();
}
//**********************************************************************
void CBCGPRibbonCustomizeQATPage::OnDown() 
{
	MoveItem (FALSE);
}
Exemple #23
0
void MainWidget::upData()
{
  MoveItem(alsa_config_list,alsa_system_list);
}
Exemple #24
0
///////////////////////////////////
//From UserInfoEx by DeathAxe
//
void MoveItem( HTREEITEM hItem, HTREEITEM hInsertAfter, BOOLEAN bAsChild )
{
	TVINSERTSTRUCT tvis;
	//TCHAR strbuf[128];
	HTREEITEM hParent, hChild, hNewItem;

	if ( !hItem || !hInsertAfter )
		return;
	if ( hItem == hInsertAfter )
		return;

	switch( ( ULONG_PTR )hInsertAfter ) {
	case TVI_ROOT:
	case TVI_FIRST:
	case TVI_LAST:
		hParent = NULL;
		bAsChild = FALSE;
		break;
	default:
		hParent = TreeView_GetParent( hMenuTree, hInsertAfter );
		break;
	}
	// do not move a parent next to its own children!
	if ( hItem == hParent )
		return;

	// prepare the insert structure
	{
		TCHAR strbuf[128];
		tvis.item.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT;

		tvis.item.pszText=strbuf;
		tvis.item.cchTextMax=_countof(strbuf);
		tvis.item.hItem=hItem;
		TreeView_GetItem(hMenuTree,&tvis.item);				
	}

	// item should be inserted as the first child of an existing root item
	if ( bAsChild ) { 
		tvis.hParent = hInsertAfter;
		tvis.hInsertAfter =   ( bAsChild == 2 ) ? TVI_LAST : TVI_FIRST ;
	}
	// item should be inserted after an existing item
	else {
		tvis.hParent = hParent;
		tvis.hInsertAfter = hInsertAfter;
	}
	// insert the item
	if ( !( hNewItem = TreeView_InsertItem( hMenuTree, &tvis )) )
		return;

	// move children
	hInsertAfter = hNewItem;
	while( hChild = TreeView_GetChild( hMenuTree, hItem )) {
		MoveItem( hChild, hInsertAfter, 2 );
	}
	// delete old tree
	TreeView_DeleteItem( hMenuTree, hItem );

	TreeView_SelectItem( hMenuTree, hNewItem );
	//TreeView_Expand( hMenuTree, hNewItem, TVE_EXPAND );
}
Exemple #25
0
INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam)
{	
	switch(msg){
	case WM_INITDIALOG:{
		DWORD style;
		g_opHdlg=hdlg;
		bOptionsInit=TRUE;
		TranslateDialogDefault(hdlg); 
		if(g_iButtonsCount!=db_get_b(NULL, PLGNAME,"ButtonsCount", 0))
		{
			LOGFONT logFont;
			HFONT hFont;
			bNeedRestart=TRUE;
			EnableWindow(GetDlgItem(hdlg,IDC_BUTTONSLIST),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_BLISTADD),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_BLISTREMOVE),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_MENUTREE),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_MTREEADD),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_MTREEREMOVE),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_RCLICKVALUE),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_BUTTONNAME),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
			EnableWindow(GetDlgItem(hdlg,IDC_MENUNAME),FALSE);	
			ShowWindow(GetDlgItem(hdlg,IDC_WARNING),SW_SHOW);

			hFont = (HFONT)SendDlgItemMessage(hdlg, IDC_WARNING, WM_GETFONT, 0, 0);
			GetObject(hFont, sizeof(logFont), &logFont);
			logFont.lfWeight = FW_BOLD;
			hFont = CreateFontIndirect(&logFont);
			SendDlgItemMessage(hdlg, IDC_WARNING, WM_SETFONT, (WPARAM)hFont, 0);
			break;
		}

		g_iOPButtonsCount=g_iButtonsCount;

		hButtonsList=GetDlgItem(hdlg,IDC_BUTTONSLIST);
		hMenuTree=GetDlgItem(hdlg,IDC_MENUTREE);

		style = GetWindowLongPtr(hButtonsList,GWL_STYLE);
		style |=TVS_NOHSCROLL;
		SetWindowLongPtr(hButtonsList,GWL_STYLE, style);

		style = GetWindowLongPtr(hMenuTree,GWL_STYLE);
		style |=TVS_NOHSCROLL;			
		SetWindowLongPtr(hMenuTree,GWL_STYLE, style);
		BuildButtonsList(hButtonsList);

		if (!TreeView_GetCount(hButtonsList))
			EnableWindow(GetDlgItem(hdlg,IDC_RCLICKVALUE),FALSE);

		mir_subclassWindow( GetDlgItem(hdlg,IDC_BUTTONNAME), EditSubclassProc);
		mir_subclassWindow( GetDlgItem(hdlg,IDC_MENUNAME),   EditSubclassProc);

		EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
		EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
		EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
		CheckDlgButton(hdlg,IDC_RAUTOSEND,(g_bRClickAuto=db_get_b(NULL,PLGNAME,"RClickAuto",0)) ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hdlg,IDC_LAUTOSEND,(g_bLClickAuto=db_get_b(NULL,PLGNAME,"LClickAuto",0)) ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hdlg,IDC_ENABLEQUICKMENU,(g_bQuickMenu=db_get_b(NULL, PLGNAME,"QuickMenu", 1)) ? BST_CHECKED : BST_UNCHECKED);

		bOptionsInit=FALSE;
							 }break;

	case WM_LBUTTONUP:
		if(drag) {
			TVHITTESTINFO hti; 
			HTREEITEM htiAfter=NULL;
			ButtonData* bd=NULL;
			TVITEM tvi;
			RECT rc;
			BYTE height;
			BOOLEAN bAsChild = FALSE;

			TreeView_SetInsertMark(hMenuTree, NULL, 0 );
			ReleaseCapture();
			SetCursor( LoadCursor( NULL, IDC_ARROW ));

			hti.pt.x = ( SHORT )LOWORD( lparam );
			hti.pt.y = ( SHORT )HIWORD( lparam );
			ClientToScreen(hdlg,&hti.pt);
			ScreenToClient(hMenuTree,&hti.pt);
			TreeView_HitTest( hMenuTree, &hti );

			if(TreeView_GetParent(hMenuTree,hti.hItem)&&TreeView_GetChild(hMenuTree,hDragItem))
				break;

			if(TreeView_GetChild(hMenuTree,hti.hItem)&&TreeView_GetChild(hMenuTree,hDragItem))
				break;


			if ( hti.flags & TVHT_ABOVE ) {
				htiAfter = TVI_FIRST;
			}
			else
				if ( hti.flags & ( TVHT_NOWHERE|TVHT_BELOW )) {
					htiAfter = TVI_LAST;
				}
				else
					if ( hti.flags & ( TVHT_ONITEM|TVHT_ONITEMRIGHT )) {
						// check where over the item, the pointer is
						if ( !TreeView_GetItemRect( hMenuTree, hti.hItem, &rc, FALSE )) {
							drag=0;
							break;
						}
						height = ( BYTE )( rc.bottom - rc.top );

						if ( hti.pt.y - ( height / 3 ) < rc.top ) {
							HTREEITEM hItem = hti.hItem;

							if ( !( hti.hItem = TreeView_GetPrevSibling( hMenuTree, hItem )) ) {
								if ( !( hti.hItem = TreeView_GetParent(hMenuTree, hItem )))
									htiAfter = TVI_FIRST;
								else
									bAsChild = TRUE;
							}
						}
						else 
							if ( hti.pt.y + ( height / 3 ) <= rc.bottom ) {
								bAsChild = TRUE;
							}
					}	


					if(TreeView_GetChild(hMenuTree,hDragItem)&&bAsChild)
						break;


					if(hti.hItem){
						tvi.hItem=hti.hItem;
						tvi.mask=TVIF_PARAM |TVIF_HANDLE;
						TreeView_GetItem(hMenuTree,&tvi);
						if ((bd=(ButtonData*)tvi.lParam)&&(bd->fEntryOpType&QMF_EX_SEPARATOR))
							bAsChild = FALSE;
					}

					if(TreeView_GetParent(hMenuTree,hti.hItem))
						bAsChild = FALSE;


					MoveItem( hDragItem, htiAfter?htiAfter:hti.hItem, bAsChild );
					SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
					drag=0;

		}
		break; 

		///////////////////////////////////
		//From UserInfoEx by DeathAxe
		//
	case WM_MOUSEMOVE:
		{
			if (!drag) break;
			{
				TVHITTESTINFO hti;

				hti.pt.x=(short)LOWORD(lparam);
				hti.pt.y=(short)HIWORD(lparam);
				ClientToScreen(hdlg,&hti.pt);
				ScreenToClient(hMenuTree,&hti.pt);
				TreeView_HitTest(hMenuTree,&hti);
				if ( hti.flags & ( TVHT_ONITEM|TVHT_ONITEMRIGHT )) {
					RECT rc;
					BYTE height;

					if ( TreeView_GetItemRect(hMenuTree, hti.hItem, &rc, FALSE )) {
						height = ( BYTE )( rc.bottom - rc.top );

						if ( hti.pt.y - ( height / 3 ) < rc.top ) {
							SetCursor( LoadCursor( NULL, IDC_ARROW ));
							TreeView_SetInsertMark( hMenuTree, hti.hItem, 0 );
						}
						else
							if ( hti.pt.y + ( height / 3 ) > rc.bottom ) {
								SetCursor( LoadCursor( NULL, IDC_ARROW ));
								TreeView_SetInsertMark( hMenuTree, hti.hItem, 1 );
							}
							else {
								TreeView_SetInsertMark( hMenuTree, NULL, 0 );
								SetCursor( LoadCursor( GetModuleHandle(NULL), MAKEINTRESOURCE( 183 )) );
							}
					}
				}
				else {
					if ( hti.flags & TVHT_ABOVE ) SendMessage( hMenuTree, WM_VSCROLL, MAKEWPARAM( SB_LINEUP, 0 ), 0 );
					if ( hti.flags & TVHT_BELOW ) SendMessage( hMenuTree, WM_VSCROLL, MAKEWPARAM( SB_LINEDOWN, 0 ), 0 );
					TreeView_SetInsertMark( hMenuTree, NULL, 0 );
				}
			}
		}break;
		/////////////
	case WM_DESTROY:
		if (g_varhelpDlg)
			DestroyWindow(g_varhelpDlg);
		g_varhelpDlg=NULL;
		break;

	case WM_NOTIFY:
		switch(((LPNMHDR)lparam)->idFrom)	{
		case 0:
			if (((LPNMHDR)lparam)->code == PSN_APPLY ) {
				if (!bNeedRestart){
					SetMenuEntryProperties(hdlg);
					SaveMenuTree(hdlg); 
				}
				db_set_b(NULL,PLGNAME,"RClickAuto",(BYTE)(g_bRClickAuto=IsDlgButtonChecked(hdlg,IDC_RAUTOSEND)));
				db_set_b(NULL,PLGNAME,"LClickAuto",(BYTE)(g_bLClickAuto=IsDlgButtonChecked(hdlg,IDC_LAUTOSEND)));
				db_set_b(NULL,PLGNAME,"QuickMenu",(BYTE)(g_bQuickMenu=IsDlgButtonChecked(hdlg,IDC_ENABLEQUICKMENU)));
				return 1;
			}
			else if (((LPNMHDR)lparam)->code == PSN_RESET ) {
				if (!bNeedRestart)
					RestoreModuleData(hdlg);
				return 1;
			}
			break; 

		case IDC_MENUTREE:
			switch (((LPNMHDR)lparam)->code){
			case TVN_KEYDOWN:{
				TV_KEYDOWN* pTVKeyDown = (TV_KEYDOWN*) ((LPNMHDR)lparam);
				if ( pTVKeyDown->wVKey == VK_F2 )
					TreeView_EditLabel(hMenuTree,TreeView_GetSelection(hMenuTree));
				else if ( pTVKeyDown->wVKey == VK_DELETE )
					SendMessage(hdlg,WM_COMMAND,IDC_MTREEREMOVE,0);
								  }break;

			case TVN_BEGINLABELEDIT:
				hwndEdit=TreeView_GetEditControl(hMenuTree);
				mir_subclassWindow(hwndEdit, LabelEditSubclassProc);
				break;

			case TVN_ENDLABELEDIT:
				{
					TVITEM tvi;
					ButtonData* bd=NULL;
					TCHAR strbuf[256];
					TCHAR szLabel[256];

					tvi.pszText = strbuf;
					tvi.cchTextMax = _countof(strbuf);
					tvi.mask=TVIF_TEXT |TVIF_HANDLE|TVIF_PARAM;
					tvi.hItem=TreeView_GetSelection(hMenuTree);
					TreeView_GetItem(hMenuTree,&tvi);

					GetWindowText(hwndEdit, szLabel, _countof(szLabel));
					hwndEdit=NULL;
					if (!mir_tstrlen(szLabel)) break;
					if (bd = (ButtonData*)tvi.lParam){
						if (!mir_tstrcmp(szLabel,_T("---"))) {
							if(TreeView_GetChild(hMenuTree,tvi.hItem))
								break;
							else{
								bd->fEntryOpType=QMF_EX_SEPARATOR;
								EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
								EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
								SetDlgItemText(hdlg, IDC_MENUVALUE, _T(""));
							}
						}
						else {
							bd->fEntryOpType&=~QMF_EX_SEPARATOR;
							EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),TRUE);
							EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),TRUE);
							SetDlgItemText(hdlg, IDC_MENUVALUE, bd->pszOpValue/*?bd->pszOpValue:bd->pszValue*/);
						}

						bd->pszOpName=mir_tstrdup(szLabel);

						tvi.pszText=szLabel;
						TreeView_SetItem(hMenuTree, &tvi);
						SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
					}
				}
				break;

			case NM_KILLFOCUS:
				TreeView_EndEditLabelNow(hButtonsList, 1);
				break;

			case TVN_BEGINDRAG:
				SetCapture(hdlg);
				drag=1;
				hDragItem=((LPNMTREEVIEW)lparam)->itemNew.hItem;
				TreeView_SelectItem(hMenuTree,hDragItem);
				break;

			case TVN_SELCHANGING:
				{
					HTREEITEM hti = TreeView_GetSelection(hMenuTree);
					if (hti==NULL)
						break;

					TVITEM tvi;
					tvi.hItem=hti;
					tvi.mask=TVIF_HANDLE|TVIF_PARAM;
					TreeView_GetItem(hMenuTree,&tvi);
					if (tvi.lParam == 0)
						break;

					ButtonData *bd = ( ButtonData* )tvi.lParam;
					if (bd) {
						TCHAR szValue[256];
						GetDlgItemText(hdlg, IDC_MENUVALUE, szValue, _countof(szValue));
						if(mir_tstrlen(szValue))
						{
							if(bd->pszOpValue&&(bd->pszOpValue!=bd->pszValue))
								mir_free(bd->pszOpValue);
							bd->pszOpValue=mir_tstrdup(szValue);
						}
						bd->bOpInQMenu=IsDlgButtonChecked(hdlg,IDC_INQMENU);
						bd->bIsOpServName=IsDlgButtonChecked(hdlg,IDC_ISSERVNAME);
					}
				}
				break;

			case TVN_SELCHANGED:
				{
					HTREEITEM hti = TreeView_GetSelection(hMenuTree);
					if (hti == NULL)
						break;

					TVITEM tvi;
					tvi.mask=TVIF_HANDLE|TVIF_PARAM;
					tvi.hItem=hti;
					TreeView_GetItem(hMenuTree,&tvi);

					ButtonData *bd = ( ButtonData* )tvi.lParam;
					if (bd) {
						if (!TreeView_GetChild(hMenuTree, tvi.hItem)&&!(bd->fEntryOpType&QMF_EX_SEPARATOR))
						{
							EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),TRUE);
							EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),TRUE);
							EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),TRUE);
							SetDlgItemText(hdlg, IDC_MENUVALUE, bd->pszOpValue/*?bd->pszOpValue:bd->pszValue*/);
						}
						else
						{
							EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
							EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
							if (!(bd->fEntryOpType&QMF_EX_SEPARATOR))
								EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
							SetDlgItemText(hdlg, IDC_MENUVALUE, _T(""));
						}
						CheckDlgButton(hdlg,IDC_INQMENU,bd->bOpInQMenu ? BST_CHECKED : BST_UNCHECKED);
						CheckDlgButton(hdlg,IDC_ISSERVNAME,bd->bIsOpServName ? BST_CHECKED : BST_UNCHECKED);
					}
				}
			}
			break;

		case IDC_BUTTONSLIST:
			switch (((LPNMHDR)lparam)->code) {
			case TVN_KEYDOWN:{
				TV_KEYDOWN* pTVKeyDown = (TV_KEYDOWN*) ((LPNMHDR)lparam);
				if ( pTVKeyDown->wVKey == VK_F2 )
					TreeView_EditLabel(hButtonsList,TreeView_GetSelection(hButtonsList));
				else if ( pTVKeyDown->wVKey == VK_DELETE )
					SendMessage(hdlg,WM_COMMAND,IDC_BLISTREMOVE,0);
								  }break;

			case TVN_BEGINLABELEDIT:
				hwndEdit = TreeView_GetEditControl(hButtonsList);
				mir_subclassWindow(hwndEdit, LabelEditSubclassProc);
				break;

			case TVN_ENDLABELEDIT:
				{
					TVITEM tvi;
					TCHAR strbuf[128];
					TCHAR szLabel[128];

					tvi.pszText = strbuf;
					tvi.cchTextMax = _countof(strbuf);
					tvi.mask=TVIF_TEXT |TVIF_HANDLE|TVIF_PARAM;
					tvi.hItem=TreeView_GetSelection(hButtonsList);
					TreeView_GetItem(hButtonsList,&tvi);

					GetWindowText(hwndEdit, szLabel, _countof(szLabel));
					hwndEdit=NULL;
					if (!mir_tstrlen(szLabel)) break;

					tvi.pszText=szLabel;
					((ListData*)tvi.lParam)->dwOPFlags|=QMF_RENAMED;	

					TreeView_SetItem(hButtonsList, &tvi);
					SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
				}
				break;

			case TVN_SELCHANGING:
				SetMenuEntryProperties(hdlg);
				break;

			case TVN_SELCHANGED:
				{
					HTREEITEM hti = TreeView_GetSelection(hButtonsList);
					if(hti==NULL||!TreeView_GetCount(hButtonsList)) {
						EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
						EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
						EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
						EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME2),FALSE);
						SetDlgItemText(hdlg, IDC_MENUVALUE, _T(""));
						break;
					}

					TVITEM tvi;
					tvi.mask=TVIF_HANDLE|TVIF_PARAM;
					tvi.hItem=hti;
					TreeView_GetItem(hButtonsList,&tvi);

					if(tvi.lParam==0) break;

					BuildMenuTree(hMenuTree,(SortedList *)((ListData*)tvi.lParam)->sl);

					SetDlgItemText(hdlg, IDC_MENUVALUE, _T(""));
					EnableWindow(GetDlgItem(hdlg,IDC_RCLICKVALUE),TRUE);
					EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME2),TRUE);
					CheckDlgButton(hdlg,IDC_ISSERVNAME2,((ListData*)tvi.lParam)->bIsOpServName ? BST_CHECKED : BST_UNCHECKED);

					if (((ListData*)tvi.lParam)->ptszOPQValue) 
						SetDlgItemText(hdlg, IDC_RCLICKVALUE, ((ListData*)tvi.lParam)->ptszOPQValue);
					else
						SetDlgItemText(hdlg, IDC_RCLICKVALUE, _T(""));
				}
				break;
			}
			break;
		}
		break;

	case WM_COMMAND:
		switch(LOWORD(wparam)) {
		case IDC_VARHELP:
			if (!g_varhelpDlg)
				g_varhelpDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_HELPDIALOG), 0, HelpDlgProc);
			else
				//ShowWindow(g_varhelpDlg,SW_SHOWDEFAULT);
				SetWindowPos(g_varhelpDlg,0,0,0,0,0,SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE);
			break;
		case IDC_BLISTADD:
			{
				TVINSERTSTRUCT tvis;
				ListData* ld=NULL;
				TCHAR namebuff[MAX_PATH]={'\0'};
				int count=TreeView_GetCount(hButtonsList);
				if (count>10) break;
				if(g_iOPButtonsCount==99){
					MessageBox(NULL, TranslateT("Congratulation!\r\nYou have clicked this button 100 times!\r\nThere was access violation at this point...\r\nAnd now function for freeing resources must be called...\r\nBut no! there's only break :D"), TranslateT("You win!"),MB_OK);
					break;
				}

				ld = (ListData *)mir_alloc(sizeof(ListData));
				ButtonsList[g_iOPButtonsCount++]=ld;

				ld->sl=List_Create(0,1);
				ld->dwOPFlags=QMF_NEW;
				ld->bIsOpServName=0;
				ld->ptszButtonName=NULL;
				ld->ptszOPQValue=NULL;
				ld->ptszQValue=NULL;
				tvis.hParent = NULL;
				tvis.hInsertAfter = TVI_LAST;

				GetDlgItemText(hdlg, IDC_BUTTONNAME, namebuff, _countof(namebuff));

				tvis.item.mask=TVIF_PARAM|TVIF_TEXT;
				tvis.item.pszText=(mir_tstrlen(namebuff))?namebuff:TranslateT("New Button");
				tvis.item.lParam=(LPARAM)ld;
				TreeView_SelectItem(hButtonsList,TreeView_InsertItem(hButtonsList,&tvis));
			}break;

		case IDC_BLISTREMOVE:
			{ 
				TVITEM tvi;
				ListData* ld;

				if (!(tvi.hItem=TreeView_GetSelection(hButtonsList)))
					break;

				tvi.mask=TVIF_HANDLE|TVIF_PARAM;
				TreeView_GetItem(hButtonsList,&tvi);

				ld= (ListData*)tvi.lParam;

				ld->dwOPFlags|=QMF_DELETNEEDED;	

				TreeView_DeleteItem(hButtonsList,tvi.hItem);
				if (!TreeView_GetCount(hButtonsList)) {
					TreeView_DeleteAllItems(hMenuTree);
					EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
					EnableWindow(GetDlgItem(hdlg,IDC_RCLICKVALUE),FALSE);
					EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
					EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
					EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME2),FALSE);
					SetDlgItemText(hdlg, IDC_MENUVALUE, _T(""));
					SetDlgItemText(hdlg, IDC_RCLICKVALUE, _T(""));
				}
			}break;

		case IDC_MTREEADD:
			{
				TVINSERTSTRUCT tvis;
				TVITEM tvi;
				ButtonData *bd=NULL;
				SortedList *sl=NULL;
				TCHAR namebuff[MAX_PATH]={'\0'};

				if (!TreeView_GetCount(hButtonsList)) break;
				if (!(tvi.hItem=TreeView_GetSelection(hButtonsList))) break;

				bd = (ButtonData *)mir_alloc(sizeof(ButtonData));
				memset(bd,0,sizeof(ButtonData));

				GetDlgItemText(hdlg, IDC_MENUNAME, namebuff, _countof(namebuff));

				bd->dwOPPos=TreeView_GetCount(hMenuTree)-1;
				bd->pszOpName=mir_tstrlen(namebuff)?mir_tstrdup(namebuff):mir_tstrdup(TranslateT("New Menu Entry"));
				bd->pszOpValue=mir_tstrdup(bd->pszOpName);
				bd->fEntryOpType=!mir_tstrcmp(namebuff,_T("---"))?QMF_EX_SEPARATOR:0;
				bd->dwOPFlags=QMF_NEW;
				bd->pszName=NULL;
				bd->pszValue=NULL;


				tvi.mask=TVIF_HANDLE|TVIF_PARAM;

				TreeView_GetItem(hButtonsList,&tvi);

				sl=((ListData*)tvi.lParam)->sl;

				List_InsertPtr(sl,bd);

				tvis.hParent = NULL;
				tvis.hInsertAfter = TVI_LAST;
				tvis.item.mask=TVIF_PARAM|TVIF_TEXT;
				tvis.item.pszText=bd->pszOpName;
				tvis.item.lParam=(LPARAM)bd;
				TreeView_SelectItem(hMenuTree,TreeView_InsertItem(hMenuTree,&tvis));
			}break;

		case IDC_MTREEREMOVE:
			{
				TVITEM tvi;
				TVINSERTSTRUCT tvis;
				HTREEITEM hti=NULL;
				ButtonData *bd=NULL;
				tvi.mask=TVIF_HANDLE|TVIF_PARAM;
				if (!(tvi.hItem=TreeView_GetSelection(hMenuTree)))
					break;
				TreeView_GetItem(hMenuTree,&tvi);
				hti=tvi.hItem;

				bd= (ButtonData*)tvi.lParam;
				bd->dwOPFlags|=QMF_DELETNEEDED;			

				if(tvi.hItem=TreeView_GetChild(hMenuTree,tvi.hItem)) {
					TCHAR strbuf[128];
					while(tvi.hItem){
						tvis.hInsertAfter=hti;
						tvi.pszText = strbuf;
						tvi.cchTextMax = _countof(strbuf);
						tvi.mask=TVIF_HANDLE|TVIF_PARAM|TVIF_TEXT;

						TreeView_GetItem(hMenuTree,&tvi); 
						tvis.hParent=NULL;
						tvis.item=tvi;
						TreeView_InsertItem(hMenuTree,&tvis);
						tvi.hItem=TreeView_GetNextSibling(hMenuTree,tvi.hItem);
					}
				}

				TreeView_DeleteItem(hMenuTree,hti);
				if (!TreeView_GetCount(hMenuTree)) {
					EnableWindow(GetDlgItem(hdlg,IDC_MENUVALUE),FALSE);
					EnableWindow(GetDlgItem(hdlg,IDC_ISSERVNAME),FALSE);
					EnableWindow(GetDlgItem(hdlg,IDC_INQMENU),FALSE);
					SetDlgItemText(hdlg, IDC_MENUVALUE, _T(""));
				}
			}break;
		}
		break;

	case WM_CLOSE:
		EndDialog(hdlg,0);
		return 0;
	}
	if (HIWORD(wparam)==BN_CLICKED && GetFocus()==(HWND)lparam)
		SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
	else if ((HIWORD(wparam) == EN_CHANGE)&&(GetFocus()==(HWND)lparam))
		if (!bOptionsInit)	SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);

	return 0;
}
Exemple #26
0
void FieldSelectionPanel::OnSelectAll( wxCommandEvent& /* evt */ )
{
  while (m_lbAvailable->GetCount()) {
    MoveItem(0, m_lbAvailable, m_lbSelected);
  }
}