示例#1
0
void SearchForText( short prev )
{
	char searchText[64];
	GetWindowText( GetDlgItem( hDlg, IDC_LANGTOKEN_FINDTEXT), searchText, 64 );
	if ( searchText[0] == 0 )
		return;
	int nonRealTokenOffset = 0;
	char lineStr1[LANG_LINE_SIZE];
	char lineStr2[LANG_LINE_SIZE];

	int top = ListView_GetTopIndex( hWndLangBuilderListView ) + 1;
	int listviewsize = ListView_GetCountPerPage( hWndLangBuilderListView );
	int bottom = top + listviewsize;
	int scrollOffset = 0;
	int item;
	/*if ( currItemSel+1 < top || currItemSel > bottom ) // Selected item is out of the list view (off the screen)
	{
		if ( currItemSel < top ) // Selected item is above the view
			scrollOffset = currItemSel - top - (listviewsize/2); // We can't see the selected item, so use the top of the view as the starting point for the search
		else // if ( currItemSel > bottom )
			scrollOffset = currItemSel - top - (listviewsize/2); // 
	}
	else*/
	scrollOffset = currItemSel - top - (listviewsize/2);

	if ( prev )
	{
		short i;
		item = currItemSel-1;
		// Since we can see the selected item in the list view, we start seaching right after it...
		for ( i = END_OF_STRINGS; i > SUMM_BEGIN; i-- )
		{
			if ( CheckLangStringForTextPrev( searchText, lineStr1, lineStr2, i, scrollOffset, nonRealTokenOffset, item ) )
				break;
		}
		if ( i == SUMM_BEGIN )
		{
			sprintf( lineStr1, "The string '%s' is not in the language list", searchText );                
			MessageBox( GetFocus(), lineStr1, "String not found", MB_OK );
		}
	}
	else
	{
		short i;
		item = currItemSel+1;
		// Since we can see the selected item in the list view, we start seaching right after it...
		for ( i = SUMM_BEGIN; i < END_OF_STRINGS; i++ )
		{
			if ( CheckLangStringForText( searchText, lineStr1, lineStr2, i, scrollOffset, nonRealTokenOffset, item ) )
				break;
		}
		if ( i == END_OF_STRINGS )
		{
			sprintf( lineStr1, "The string '%s' is not in the language list", searchText );                
			MessageBox( GetFocus(), lineStr1, "String not found", MB_OK );
		}
	}
}
void Update_RAM_Watch()
{
	BOOL watchChanged[MAX_WATCH_COUNT] = {0};

	if(WatchCount)
	{
		// update cached values and detect changes to displayed listview items

		EnterCriticalSection(&g_processMemCS);
		for(int i = 0; i < WatchCount; i++)
		{
			RSVal prevCurValue = rswatches[i].CurValue;
			RSVal newCurValue = GetCurrentValue(rswatches[i]);
			if(!prevCurValue.CheckBinaryEquality(newCurValue))
			{
				rswatches[i].CurValue = newCurValue;
				watchChanged[i] = TRUE;
			}
		}
		LeaveCriticalSection(&g_processMemCS);
	}

	// refresh any visible parts of the listview box that changed
	HWND lv = GetDlgItem(RamWatchHWnd,IDC_WATCHLIST);
	int top = ListView_GetTopIndex(lv);
	int bottom = top + ListView_GetCountPerPage(lv) + 1; // +1 is so we will update a partially-displayed last item
	if(top < 0) top = 0;
	if(bottom > WatchCount) bottom = WatchCount;
	int start = -1;
	for(int i = top; i <= bottom; i++)
	{
		if(start == -1)
		{
			if(i != bottom && watchChanged[i])
			{
				start = i;
				//somethingChanged = true;
			}
		}
		else
		{
			if(i == bottom || !watchChanged[i])
			{
				ListView_RedrawItems(lv, start, i-1);
				start = -1;
			}
		}
	}
}
示例#3
0
extern "C" void Update_RAM_Watch()
{
	if (!RamWatchHWnd) return;
	
	HWND lv;
	int top;
	int bottom;
	int start;
	int i;
	// update cached values and detect changes to displayed listview items
	int watchChanged[MAX_WATCH_COUNT] = {0};
	for(i = 0; i < WatchCount; i++)
	{
		unsigned int prevCurValue = rswatches[i].CurValue;
		unsigned int newCurValue = GetCurrentValue(&rswatches[i]);
		if(prevCurValue != newCurValue)
		{
			rswatches[i].CurValue = newCurValue;
			watchChanged[i] = 1;
		}
	}

	// refresh any visible parts of the listview box that changed
	lv = GetDlgItem(RamWatchHWnd,IDC_WATCHLIST);
	top = ListView_GetTopIndex(lv);
	bottom = top + ListView_GetCountPerPage(lv) + 1; // +1 is so we will update a partially-displayed last item
	if(top < 0) top = 0;
	if(bottom > WatchCount) bottom = WatchCount;
	start = -1;
	for(i = top; i <= bottom; i++)
	{
		if(start == -1)
		{
			if(i != bottom && watchChanged[i])
			{
				start = i;
				//somethingChanged = 1;
			}
		}
		else
		{
			if(i == bottom || !watchChanged[i])
			{
				ListView_RedrawItems(lv, start, i-1);
				start = -1;
			}
		}
	}
}
示例#4
0
void PaintAlternatingRows (HWND hWnd)
//    re-draw rows with the appropriate background colour
{
    int i;
    RECT    rectUpd,        	//    rectangle to update
            rectDestin,        	//    temporary storage
            rect;            	//    row rectangle
    POINT    pt;
    int     iItems,
            iTop;
    COLORREF    c;            	//    temporary storage

//    get the rectangle to be updated
    GetUpdateRect (hWnd, &rectUpd, FALSE);
//    allow default processing first
    CallWindowProc (old_lv_proc, hWnd, WM_PAINT, 0, 0);
//    set the row horizontal dimensions
    SetRect (&rect, rectUpd.left, 0, rectUpd.right, 0);
//    number of displayed rows
    iItems = ListView_GetCountPerPage (hWnd);
//    first visible row
    iTop = ListView_GetTopIndex (hWnd);

    ListView_GetItemPosition (hWnd, iTop, &pt);
    for (i=iTop ; i<=iTop+iItems ; i++) {
//        set row vertical dimensions
        rect.top = pt.y;
        ListView_GetItemPosition (hWnd, i+1, &pt);
        rect.bottom = pt.y;
//        if row rectangle intersects update rectangle then it requires
//        re-drawing
        if (IntersectRect (&rectDestin, &rectUpd, &rect)) {
//            change text background colour accordingly
            c = get_row_color(hWnd, i);
            ListView_SetTextBkColor (hWnd, c);
//            invalidate the row rectangle then...
            InvalidateRect (hWnd, &rect, FALSE);
//            ...force default processing
            CallWindowProc (old_lv_proc, hWnd, WM_PAINT, 0, 0);
        }
    }
}
示例#5
0
// Function to redraw the database list
void CDBListView::Update(int StartItem)
{
	// Update number of items
	ListView_SetItemCountEx(m_hList, m_entDB.size(), LVSICF_NOINVALIDATEALL | LVSICF_NOSCROLL);

	// Will not be drawn with the selected state and will become zero. Redraw properly
	if (m_entDB.empty())
	{
		ListView_Update(m_hList, 0);
	}
	else
	{
		int nCountPerPage = ListView_GetCountPerPage(m_hList);
		int nVisibleLast = StartItem + nCountPerPage;

		// Redraw the listview (which is to redraw the selected state. This is a fairly aggressive technique)
		for (int i = StartItem; i <= nVisibleLast; i++)
			ListView_SetItemState(m_hList, i, LVIS_SELECTED, LVIS_SELECTED);

		ListView_SetItemState(m_hList, -1, 0, LVIS_SELECTED);
	}
}
示例#6
0
void EraseAlternatingRowBkgnds (HWND hWnd, HDC hDC)
//    re-draw row backgrounds with the appropriate background colour
{
    int i;
    RECT    rect;        //    row rectangle
    POINT    pt;
    int     iItems,
            iTop;
    HBRUSH    brushes[MAX_LV_COLOR_NUM];

//    create coloured brushes
    brushes[0]=CreateSolidBrush(lv_row_color[0]);
    brushes[1]=CreateSolidBrush(lv_row_color[1]);
    brushes[2]=CreateSolidBrush(lv_row_color[2]);
    brushes[3]=CreateSolidBrush(lv_row_color[3]);

//    get horizontal dimensions of row
    GetClientRect (hWnd, &rect);
//    number of displayed rows
    iItems = ListView_GetCountPerPage (hWnd);
//    first visible row
    iTop = ListView_GetTopIndex (hWnd);
    ListView_GetItemPosition (hWnd, iTop, &pt);

    for (i=iTop ; i<=iTop+iItems ; i++) {
//        set row vertical dimensions
        rect.top = pt.y;
        ListView_GetItemPosition (hWnd, i+1, &pt);
        rect.bottom = pt.y;
//        fill row with appropriate colour
        FillRect (hDC, &rect, brushes[get_row_color_idx(hWnd, i)]);
    }
    
//    cleanup
    DeleteObject (brushes[0]);
    DeleteObject (brushes[1]);
    DeleteObject (brushes[2]);
    DeleteObject (brushes[3]);
}  
HRESULT CAddTracksDialog::UpdateInfo()
{
    LONG cx     = 0,
         cxItem = 0;
    int  i      = 0;

    CPlaylistMgr * pManager = CPlaylistMgr::GetInstance();

    if (NULL == pManager)
    {
        return E_FAIL;
    }

    // loop through the current playlist and print out all media clips
    ListView_DeleteAllItems(m_hwndTrackList);

    pManager->UpdateLocalContent();
    m_pPlaylist = pManager->LocalContent();
    if (NULL == m_pPlaylist)
    {
        return S_OK;
    }

    CPlaylist::playlist_t * pListItem = m_pPlaylist->GetFirst();

    while (pListItem)
    {
        cxItem = UpdateItem(i, pListItem->pClip);

        if (cxItem > cx)
        {
            cx = cxItem;
        }

        pListItem = pListItem->pNext;
        i++;
    }

    //
    // Resize the list view if needed
    //
    RECT rc;

    GetWindowRect(m_hwndTrackList, &rc);

    if (cx < rc.right - rc.left)
    {
        cx = rc.right - rc.left;
    }

    if (ListView_GetCountPerPage(m_hwndTrackList) < ListView_GetItemCount(m_hwndTrackList))
    { 
        cx -= GetSystemMetrics(SM_CXVSCROLL);
    }

    ListView_SetColumnWidth(m_hwndTrackList, 0, cx);

    SendMessage(m_hwndTrackList, WM_SETREDRAW, TRUE, 0);

    InvalidateRect(m_hwndTrackList, NULL, TRUE);

    return S_OK;
}
示例#8
0
文件: mhmenu.c 项目: yzh/yzhack
BOOL onListChar(HWND hWnd, HWND hwndList, WORD ch)
{
	int i = 0;
	PNHMenuWindow data;
	int curIndex, topIndex, pageSize;
	boolean is_accelerator = FALSE;

	data = (PNHMenuWindow)GetWindowLong(hWnd, GWL_USERDATA);

	switch( ch ) {
	case MENU_FIRST_PAGE:
		i = 0;
		ListView_SetItemState(hwndList, i, LVIS_FOCUSED, LVIS_FOCUSED);
		ListView_EnsureVisible(hwndList, i, FALSE);
	return -2;

	case MENU_LAST_PAGE:
		i = max(0, data->menu.size-1);
		ListView_SetItemState(hwndList, i, LVIS_FOCUSED, LVIS_FOCUSED);
		ListView_EnsureVisible(hwndList, i, FALSE);
	return -2;

	case MENU_NEXT_PAGE:
		topIndex = ListView_GetTopIndex( hwndList );
		pageSize = ListView_GetCountPerPage( hwndList );
        curIndex = ListView_GetNextItem(hwndList, -1,	LVNI_FOCUSED);
        /* Focus down one page */
		i = min(curIndex+pageSize, data->menu.size-1);
		ListView_SetItemState(hwndList, i, LVIS_FOCUSED, LVIS_FOCUSED);
        /* Scrollpos down one page */
        i = min(topIndex+(2*pageSize - 1), data->menu.size-1);
		ListView_EnsureVisible(hwndList, i, FALSE);
	return -2;

	case MENU_PREVIOUS_PAGE:
		topIndex = ListView_GetTopIndex( hwndList );
		pageSize = ListView_GetCountPerPage( hwndList );
        curIndex = ListView_GetNextItem(hwndList, -1,	LVNI_FOCUSED);
        /* Focus up one page */
		i = max(curIndex-pageSize, 0);
		ListView_SetItemState(hwndList, i, LVIS_FOCUSED, LVIS_FOCUSED);
        /* Scrollpos up one page */
		i = max(topIndex-pageSize, 0);
		ListView_EnsureVisible(hwndList, i, FALSE);
	break;

	case MENU_SELECT_ALL:
		if( data->how == PICK_ANY ) {
			reset_menu_count(hwndList, data);
			for(i=0; i<data->menu.size; i++ ) {
				SelectMenuItem(hwndList, data, i, -1);
			}
			return -2;
		}
	break;

	case MENU_UNSELECT_ALL:
		if( data->how == PICK_ANY ) {
			reset_menu_count(hwndList, data);
			for(i=0; i<data->menu.size; i++ ) {
				SelectMenuItem(hwndList, data, i, 0);
			}
			return -2;
		}
	break;

	case MENU_INVERT_ALL:
		if( data->how == PICK_ANY ) {
			reset_menu_count(hwndList, data);
			for(i=0; i<data->menu.size; i++ ) {
				SelectMenuItem(
					hwndList, 
					data, 
					i, 
					NHMENU_IS_SELECTED(data->menu.items[i])? 0 : -1
				);
			}
			return -2;
		}
	break;

	case MENU_SELECT_PAGE:
		if( data->how == PICK_ANY ) {
			int from, to;
			reset_menu_count(hwndList, data);
			topIndex = ListView_GetTopIndex( hwndList );
			pageSize = ListView_GetCountPerPage( hwndList );
			from = max(0, topIndex);
			to = min(data->menu.size, from+pageSize);
			for(i=from; i<to; i++ ) {
				SelectMenuItem(hwndList, data, i, -1);
			}
			return -2;
		}
	break;

	case MENU_UNSELECT_PAGE:
		if( data->how == PICK_ANY ) {
			int from, to;
			reset_menu_count(hwndList, data);
			topIndex = ListView_GetTopIndex( hwndList );
			pageSize = ListView_GetCountPerPage( hwndList );
			from = max(0, topIndex);
			to = min(data->menu.size, from+pageSize);
			for(i=from; i<to; i++ ) {
				SelectMenuItem(hwndList, data, i, 0);
			}
			return -2;
		}
	break;

	case MENU_INVERT_PAGE:
		if( data->how == PICK_ANY ) {
			int from, to;
			reset_menu_count(hwndList, data);
			topIndex = ListView_GetTopIndex( hwndList );
			pageSize = ListView_GetCountPerPage( hwndList );
			from = max(0, topIndex);
			to = min(data->menu.size, from+pageSize);
			for(i=from; i<to; i++ ) {
				SelectMenuItem(
					hwndList, 
					data, 
					i, 
					NHMENU_IS_SELECTED(data->menu.items[i])? 0 : -1
				);
			}
			return -2;
		}
	break;

	case MENU_SEARCH:
	    if( data->how==PICK_ANY || data->how==PICK_ONE ) {
			char buf[BUFSZ];
			int  selected_item;
			
			reset_menu_count(hwndList, data);
			mswin_getlin("Search for:", buf);
			if (!*buf || *buf == '\033') return -2;
			selected_item = -1;
			for(i=0; i<data->menu.size; i++ ) {
				if( NHMENU_IS_SELECTABLE(data->menu.items[i])
					&& strstr(data->menu.items[i].str, buf) ) {
					if (data->how == PICK_ANY) {
						SelectMenuItem(
							hwndList, 
							data, 
							i, 
							NHMENU_IS_SELECTED(data->menu.items[i])? 0 : -1
						);
						/* save the first item - we will move focus to it */
						if( selected_item == -1 ) selected_item = i;
					} else if( data->how == PICK_ONE ) {
						SelectMenuItem(
							hwndList, 
							data, 
							i, 
							-1
						);
						selected_item = i;
						break;
					}
				}
			} 

			if( selected_item>0 ) {
				ListView_SetItemState(hwndList, selected_item, LVIS_FOCUSED, LVIS_FOCUSED);
				ListView_EnsureVisible(hwndList, selected_item, FALSE);
			}
		} else {
			mswin_nhbell();
	    }
	return -2;

	case ' ':
		/* ends menu for PICK_ONE/PICK_NONE
		   select item for PICK_ANY */
		if( data->how==PICK_ONE || data->how==PICK_NONE ) {
			data->done = 1;
			data->result = 0;
			return -2;
		} else if( data->how==PICK_ANY ) {
			i = ListView_GetNextItem(hwndList, -1,	LVNI_FOCUSED);
			if( i>=0 ) {
				SelectMenuItem(
					hwndList, 
					data, 
					i, 
					NHMENU_IS_SELECTED(data->menu.items[i])? 0 : -1
				);
			}
			return -2;
		}
	break;

	default:
		if( strchr(data->menu.gacc, ch) &&
			!(ch=='0' && data->menu.counting) ) {
			/* matched a group accelerator */
			if (data->how == PICK_ANY || data->how == PICK_ONE) {
				reset_menu_count(hwndList, data);
				for(i=0; i<data->menu.size; i++ ) {
					if( NHMENU_IS_SELECTABLE(data->menu.items[i]) &&
						data->menu.items[i].group_accel == ch ) {
						if( data->how == PICK_ANY ) {
							SelectMenuItem(
								hwndList, 
								data, 
								i, 
								NHMENU_IS_SELECTED(data->menu.items[i])? 0 : -1
							);
						} else if( data->how == PICK_ONE ) {
							SelectMenuItem(
								hwndList, 
								data, 
								i, 
								-1
							);
							data->result = 0;
							data->done = 1;
							return -2;
						}
					}
				}
				return -2;
			} else {
				mswin_nhbell();
				return -2;
			}
		}

		if (isdigit(ch)) {
			int count;
			i = ListView_GetNextItem(hwndList, -1,	LVNI_FOCUSED);
			if( i>=0 ) {
				count = data->menu.items[i].count;
				if( count==-1 ) count=0;
				count *= 10L;
				count += (int)(ch - '0');
				if (count != 0)	/* ignore leading zeros */ {
					data->menu.counting = TRUE;
					data->menu.items[i].count = min(100000, count);
					ListView_RedrawItems( hwndList, i, i ); /* update count mark */
				}
			}
			return -2;
		}

		is_accelerator = FALSE;
		for(i=0; i<data->menu.size; i++) {
			if( data->menu.items[i].accelerator == ch ) {
				is_accelerator = TRUE;
				break;
			}
		}

		if( (ch>='a' && ch<='z') ||
			(ch>='A' && ch<='Z') || is_accelerator) {
			if (data->how == PICK_ANY || data->how == PICK_ONE) {
				for(i=0; i<data->menu.size; i++ ) {
					if( data->menu.items[i].accelerator == ch ) {
						if( data->how == PICK_ANY ) {
							SelectMenuItem(
								hwndList, 
								data, 
								i, 
								NHMENU_IS_SELECTED(data->menu.items[i])? 0 : -1
							);
							ListView_SetItemState(hwndList, i, LVIS_FOCUSED, LVIS_FOCUSED);
							ListView_EnsureVisible(hwndList, i, FALSE);
							return -2;
						} else if( data->how == PICK_ONE ) {
							SelectMenuItem(
								hwndList, 
								data, 
								i, 
								-1
							);
							data->result = 0;
							data->done = 1;
							return -2;
						}
					}
				}
			}
		}
	break;
	}

	reset_menu_count(hwndList, data);
	return -1;
}