예제 #1
0
void MyListCtrl::OnSize(UINT nType, int cx, int cy) 
{
	CListCtrl::OnSize(nType, cx, cy);

	if (nType == SIZE_MAXHIDE || nType == SIZE_MAXSHOW)
		return;		// arrangement not needed



	/*
	CHeaderCtrl* pHeader=GetHeaderCtrl();
	if(pHeader)
	iNumberOfColums=pHeader->GetItemCount();

	double normalColumnWidth=500.0;
	int iColumnWidth=0;
	int newColumnWidth=0;
	double fratio=0.0;
	for(int i=0;i<iNumberOfColums;i++)
	{
	iColumnWidth=GetColumnWidth(i);
	fratio=(float)iColumnWidth/normalColumnWidth;
	newColumnWidth=(int)(fratio*(float)cx);
	SetColumnWidth(i,newColumnWidth);
	}

	*/

	ResizeColumns(cx);
}
예제 #2
0
void CGitProgressList::Init()
{
	SetExtendedStyle (LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);

	DeleteAllItems();
	int c = ((CHeaderCtrl*)(GetDlgItem(0)))->GetItemCount()-1;
	while (c>=0)
		DeleteColumn(c--);

	CString temp;
	temp.LoadString(IDS_PROGRS_ACTION);
	InsertColumn(0, temp);
	temp.LoadString(IDS_PROGRS_PATH);
	InsertColumn(1, temp);

	m_pThread = AfxBeginThread(ProgressThreadEntry, this, THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);
	if (m_pThread==NULL)
	{
		ReportError(CString(MAKEINTRESOURCE(IDS_ERR_THREADSTARTFAILED)));
	}
	else
	{
		m_pThread->m_bAutoDelete = FALSE;
		m_pThread->ResumeThread();
	}

	// Call this early so that the column headings aren't hidden before any
	// text gets added.
	ResizeColumns();

	SetTimer(VISIBLETIMER, 300, NULL);
}
예제 #3
0
void CGitProgressList::AddItemToList()
{
	int totalcount = GetItemCount();

	SetItemCountEx(totalcount+1, LVSICF_NOSCROLL|LVSICF_NOINVALIDATEALL);
	// make columns width fit
	if (iFirstResized < 30)
	{
		// only resize the columns for the first 30 or so entries.
		// after that, don't resize them anymore because that's an
		// expensive function call and the columns will be sized
		// close enough already.
		ResizeColumns();
		++iFirstResized;
	}

	// Make sure the item is *entirely* visible even if the horizontal
	// scroll bar is visible.
	int count = GetCountPerPage();
	if (totalcount <= (GetTopIndex() + count + nEnsureVisibleCount + 2))
	{
		++nEnsureVisibleCount;
		m_bLastVisible = true;
	}
	else
	{
		nEnsureVisibleCount = 0;
		if (IsIconic() == 0)
			m_bLastVisible = false;
	}
}
예제 #4
0
BOOL MyListCtrl::init()
{
	//Create Image list. 
	
	m_ImageListThumb.DeleteImageList();
	m_IconWidth=2;
	m_IconHeight=27;
	m_ImageListThumb.Create(m_IconWidth, m_IconHeight, ILC_COLOR24, 0, 1);
	SetImageList(&m_ImageListThumb, LVSIL_SMALL);
	m_ShowIcons=FALSE;
	Arrange(LVSCW_AUTOSIZE);
	//LVSCW_AUTOSIZE
	FreeListItems();
	
	// For the resize problem...... 
	m_iNumberOfColumns=2;
	m_iColumnWidthArray[0]=60;
	m_iColumnWidthArray[1]=40;
	m_iColumnWidthArray[2]=110;
	m_iColumnWidthArray[3]=100;
	
	
	
	InsertColumn(0,"Name",LVCFMT_LEFT,m_iColumnWidthArray[0]);
	InsertColumn(1,"Address",LVCFMT_LEFT,m_iColumnWidthArray[1]);
	// nice flat list-  	
	SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FLATSB |
		LVS_EX_FULLROWSELECT );
	
	
	//
	// Setting the header INFO
	//
	
	// Loading header images.. 
	m_HeaderImages.DeleteImageList();
	m_HeaderImages.Create(IDB_HEADER, 9*2, 1, RGB(255,255,255));
	
	CHeaderCtrl* pHeader=GetHeaderCtrl();
	if(pHeader)
	{
		
		pHeader->SetImageList(&m_HeaderImages);
		
		for (int i=0; i < pHeader->GetItemCount(); i++)
		{
			SetHeaderIcon(i,-1);
		}
		
		SetBkColor(RGB(255,255,255));
		SetTextBkColor(RGB(255,255,255));
		SetTextColor(RGB(0,0,0));
		SetHeaderIcon(0,0);
		m_iCurrentSortColumn=0;
    }
	
	ResizeColumns();
	
	return TRUE;
}
예제 #5
0
void MyListCtrl::OnSize(UINT nType, int cx, int cy) 
{
	CListCtrl::OnSize(nType, cx, cy);
	
	if (nType == SIZE_MAXHIDE || nType == SIZE_MAXSHOW)
		return;		// arrangement not needed
	ResizeColumns(cx);
}
/// <summary>
/// Handle the WM_RESIZE message to adjust the width of each column automatically
/// </summary>
void SensorListControl::OnResize(LONG totalWidth)
{
    UINT widthValues[Columns];

    widthValues[DetailColumnIndex] = max(totalWidth - SensorListImageWidth, 0);
    widthValues[ImageColumnIndex] = min(totalWidth, SensorListImageWidth);

    ResizeColumns(widthValues, Columns);
}
/// <summary>
/// Handle the WM_RESIZE message to adjust the width of each column automatically
/// </summary>
void StatusLogListControl::OnResize(LONG totalWidth)
{
    UINT widthValues[Columns];

    widthValues[InstanceIdCellIndex] = max(totalWidth - StatusLogListStatusWidth - StatusLogListTimeWidth, 0);
    widthValues[SensorStatusCellIndex] = min(totalWidth, StatusLogListStatusWidth);
    widthValues[LogTimeCellIndex] = totalWidth - widthValues[0] - widthValues[1] - GetSystemMetrics(SM_CXVSCROLL);

    ResizeColumns(widthValues, Columns);
}
예제 #8
0
void MenuView::Init(bool _readonly) {
  model = new MenuModel();
  setModel(model);
  setSelectionBehavior(QAbstractItemView::SelectRows);
  AllowSelection(!_readonly);

  /*Дичайший костыль, исправить при первой возможности*/
  QTimer* timer = new QTimer(this);
  timer->setInterval(200);
  timer->start();
  connect(timer, SIGNAL(timeout()), this, SLOT(ResizeColumns()));
}
예제 #9
0
void PixelInfoListCtrl::OnDrag( wxListEvent& event )
{
  event.Skip();
  ResizeColumns();
}
예제 #10
0
void PixelInfoListCtrl::OnSize( wxSizeEvent& event )
{
  event.Skip();
  ResizeColumns();
}
예제 #11
0
UINT CGitProgressList::ProgressThread()
{
	// The SetParams function should have loaded something for us

	CString temp;
	CString sWindowTitle;
	bool bSuccess = false;

	if(m_pPostWnd)
		m_pPostWnd->PostMessage(WM_PROG_CMD_START, (WPARAM)m_Command);

	if(m_pProgressLabelCtrl)
	{
		m_pProgressLabelCtrl->ShowWindow(SW_SHOW);
		m_pProgressLabelCtrl->SetWindowText(_T(""));
	}

//	SetAndClearProgressInfo(m_hWnd);
	m_itemCount = m_itemCountTotal;

	InterlockedExchange(&m_bThreadRunning, TRUE);
	iFirstResized = 0;
	bSecondResized = FALSE;
	m_bFinishedItemAdded = false;
	DWORD startTime = GetCurrentTime();

	if (m_pTaskbarList && m_pPostWnd)
		m_pTaskbarList->SetProgressState(m_pPostWnd->GetSafeHwnd(), TBPF_INDETERMINATE);

	m_TotalBytesTransferred = 0;
	if (m_Command)
		bSuccess = m_Command->Run(this, sWindowTitle, m_itemCountTotal, m_itemCount);
	else
		bSuccess = false;

	if (!bSuccess)
		temp.LoadString(IDS_PROGRS_TITLEFAILED);
	else
		temp.LoadString(IDS_PROGRS_TITLEFIN);
	sWindowTitle = sWindowTitle + _T(" ") + temp;
	if (m_bSetTitle && m_pPostWnd)
		::SetWindowText(m_pPostWnd->GetSafeHwnd(), sWindowTitle);

	KillTimer(TRANSFERTIMER);
	KillTimer(VISIBLETIMER);

	if (m_pTaskbarList && m_pPostWnd)
	{
		if (DidErrorsOccur())
		{
			m_pTaskbarList->SetProgressState(m_pPostWnd->GetSafeHwnd(), TBPF_ERROR);
			m_pTaskbarList->SetProgressValue(m_pPostWnd->GetSafeHwnd(), 100, 100);
		}
		else
			m_pTaskbarList->SetProgressState(m_pPostWnd->GetSafeHwnd(), TBPF_NOPROGRESS);
	}

	if (m_pInfoCtrl)
	{
		CString info;
		if (!bSuccess)
			info.LoadString(IDS_PROGRS_INFOFAILED);
		else // this implies that command is not nullptr
			info = BuildInfoString();
		m_pInfoCtrl->SetWindowText(info);
	}

	ResizeColumns();

	DWORD time = GetCurrentTime() - startTime;

	CString sFinalInfo;
	if (!m_sTotalBytesTransferred.IsEmpty())
	{
		temp.Format(IDS_PROGRS_TIME, (time / 1000) / 60, (time / 1000) % 60);
		sFinalInfo.Format(IDS_PROGRS_FINALINFO, m_sTotalBytesTransferred, (LPCTSTR)temp);
		if (m_pProgressLabelCtrl)
			m_pProgressLabelCtrl->SetWindowText(sFinalInfo);
	}
	else
	{
		if (m_pProgressLabelCtrl)
			m_pProgressLabelCtrl->ShowWindow(SW_HIDE);
	}

	if (m_pProgControl)
		m_pProgControl->ShowWindow(SW_HIDE);

	if (!m_bFinishedItemAdded)
	{
		CString log, str;
		if (bSuccess)
			str.LoadString(IDS_SUCCESS);
		else
			str.LoadString(IDS_FAIL);
		log.Format(_T("%s (%lu ms @ %s)"), str, time,  CLoglistUtils::FormatDateAndTime(CTime::GetCurrentTime(), DATE_SHORTDATE, true, false));

		// there's no "finished: xxx" line at the end. We add one here to make
		// sure the user sees that the command is actually finished.
		ReportString(log, CString(MAKEINTRESOURCE(IDS_PROGRS_FINISHED)), bSuccess? RGB(0,0,255) : RGB(255,0,0));
	}

	int count = GetItemCount();
	if ((count > 0)&&(m_bLastVisible))
		EnsureVisible(count-1, FALSE);

	CLogFile logfile(g_Git.m_CurrentDir);
	if (logfile.Open())
	{
		logfile.AddTimeLine();
		for (size_t i = 0; i < m_arData.size(); ++i)
		{
			NotificationData * data = m_arData[i];
			temp.Format(_T("%-20s : %s"), (LPCTSTR)data->sActionColumnText, (LPCTSTR)data->sPathColumnText);
			logfile.AddLine(temp);
		}
		if (!sFinalInfo.IsEmpty())
			logfile.AddLine(sFinalInfo);
		logfile.Close();
	}

	m_bCancelled = TRUE;
	InterlockedExchange(&m_bThreadRunning, FALSE);

	if (m_pPostWnd)
		m_pPostWnd->PostMessage(WM_PROG_CMD_FINISH, (WPARAM)m_Command, 0L);

	//Don't do anything here which might cause messages to be sent to the window
	//The window thread is probably now blocked in OnOK if we've done an auto close
	return 0;
}
예제 #12
0
static INT_PTR CALLBACK BackgroundDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);
		{	LVCOLUMN lvc;
			RECT rc;
			GetClientRect(GetDlgItem(hwndDlg, IDC_PAST), &rc);
			rc.right-=GetSystemMetrics(SM_CXVSCROLL);
			lvc.mask = LVCF_WIDTH;
			lvc.cx = rc.right/3;
			ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PAST), 0, &lvc);
			ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_INTERESTS), 0, &lvc);
			lvc.cx = rc.right-rc.right/3;
			ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PAST), 1, &lvc);
			ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_INTERESTS), 1, &lvc);
		}
		ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_PAST), LVS_EX_LABELTIP, LVS_EX_LABELTIP);
		ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_INTERESTS), LVS_EX_LABELTIP, LVS_EX_LABELTIP);
		break;

	case WM_NOTIFY:
		switch (((LPNMHDR)lParam)->idFrom) {
		case 0:
			if (((LPNMHDR)lParam)->code == PSN_INFOCHANGED)
			{	LVITEM lvi;
				int i;
				char idstr[33];
				DBVARIANT dbv, dbvText;
				HANDLE hContact = (HANDLE)((LPPSHNOTIFY)lParam)->lParam;

				if (hContact != NULL) {
					char *szProto = GetContactProto(hContact);
					if (szProto == NULL) break;
					bool proto_service = (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC) == PF4_INFOSETTINGSVC;
					SetValue(hwndDlg, IDC_WEBPAGE, hContact, szProto, "Homepage", SVS_ZEROISUNSPEC);

					//past
					ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PAST));
					lvi.mask = LVIF_TEXT;
					lvi.iSubItem = 0;
					lvi.iItem = 0;
					for (i=0;;i++) {
						mir_snprintf(idstr, SIZEOF(idstr), "Past%d", i);
						if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) ||
							( !proto_service && db_get_ts(hContact, szProto, idstr, &dbv)))
							break;
						mir_snprintf(idstr, SIZEOF(idstr), "Past%dText", i);
						if (db_get_ts(hContact, szProto, idstr, &dbvText))
						{if (proto_service) Proto_FreeInfoVariant(&dbv); else db_free(&dbv); break;}
						lvi.pszText = dbv.ptszVal;
						ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PAST), &lvi);
						ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PAST), lvi.iItem, 1, dbvText.ptszVal);
						db_free(&dbvText);
						if (proto_service)
							Proto_FreeInfoVariant(&dbv);
						else
							db_free(&dbv);
						lvi.iItem++;
					}

					for (i=0;;i++) {
						mir_snprintf(idstr, SIZEOF(idstr), "Affiliation%d", i);
						if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) ||
							( !proto_service && db_get_ts(hContact, szProto, idstr, &dbv)))
							break;
						mir_snprintf(idstr, SIZEOF(idstr), "Affiliation%dText", i);
						if (db_get_ts(hContact, szProto, idstr, &dbvText))
						{if (proto_service) Proto_FreeInfoVariant(&dbv); else db_free(&dbv); break;}
						lvi.pszText = dbv.ptszVal;
						ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PAST), &lvi);
						ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PAST), lvi.iItem, 1, dbvText.ptszVal);
						db_free(&dbvText);
						if (proto_service)
							Proto_FreeInfoVariant(&dbv);
						else
							db_free(&dbv);
						lvi.iItem++;
					}

					ResizeColumns(GetDlgItem(hwndDlg, IDC_PAST));

					//interests
					ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_INTERESTS));
					lvi.mask = LVIF_TEXT;
					lvi.iSubItem = 0;
					lvi.iItem = 0;
					for (i=0;;i++) {
						mir_snprintf(idstr, SIZEOF(idstr), "Interest%dCat", i);
						if ((proto_service && Proto_GetContactInfoSetting(hContact, szProto, szProto, idstr, &dbv, DBVT_TCHAR)) ||
							( !proto_service && db_get_ts(hContact, szProto, idstr, &dbv)))
							break;
						mir_snprintf(idstr, SIZEOF(idstr), "Interest%dText", i);
						if (db_get_ts(hContact, szProto, idstr, &dbvText))
						{if (proto_service) Proto_FreeInfoVariant(&dbv); else db_free(&dbv); break;}
						lvi.pszText = dbv.ptszVal;
						ListView_InsertItem(GetDlgItem(hwndDlg, IDC_INTERESTS), &lvi);
						ListView_SetItemText(GetDlgItem(hwndDlg, IDC_INTERESTS), lvi.iItem, 1, dbvText.ptszVal);
						db_free(&dbvText);
						if (proto_service)
							Proto_FreeInfoVariant(&dbv);
						else
							db_free(&dbv);
						lvi.iItem++;
					}
					ResizeColumns(GetDlgItem(hwndDlg, IDC_INTERESTS));
			}	}
			break;
		}
		break;

	case WM_COMMAND:
		switch(LOWORD(wParam)) {
		case IDCANCEL:
			SendMessage(GetParent(hwndDlg), msg, wParam, lParam);
			break;
		case IDC_WEBPAGE:
			if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_WEBPAGE))) {
				char szPage[256];
				GetDlgItemTextA(hwndDlg, IDC_WEBPAGE, szPage, SIZEOF(szPage));
				CallService(MS_UTILS_OPENURL, 1, (LPARAM)szPage);
			}
			break;
		}
		break;
	}
	return FALSE;
}
예제 #13
0
MenuView::MenuView(bool _readonly, QWidget *parent) :
    QTableView(parent)
{
  Init(_readonly);
  connect(this, SIGNAL(activated(QModelIndex)), SLOT(ResizeColumns()));
}