Example #1
0
void
HEventList::SelectionChanged()
{
	BColumnListView::SelectionChanged();

	HEventRow* row = (HEventRow*)CurrentSelection();
	if (row != NULL) {
		entry_ref ref;
		BMediaFiles().GetRefFor(fType, row->Name(), &ref);

		BPath path(&ref);
		if (path.InitCheck() == B_OK || ref.name == NULL
			|| strcmp(ref.name, "") == 0) {
			row->SetPath(path.Path());
			UpdateRow(row);
		} else {
			printf("name %s\n", ref.name);
			BMediaFiles().RemoveRefFor(fType, row->Name(), ref);
			BAlert* alert = new BAlert("alert",
				B_TRANSLATE("No such file or directory"), B_TRANSLATE("OK"));
			alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
			alert->Go();
			return;
		}
		BMessage msg(M_EVENT_CHANGED);
		msg.AddString("name", row->Name());
		msg.AddString("path", row->Path());
		Window()->PostMessage(&msg);
	}
}
Example #2
0
void CEx29aView::ChangeSelectionToRow(int nRow)
{
    if ((nRow >= 0) && (nRow < min(GetRowCount(), LastViewableRow() - 1))) {
        m_nSelectedRow = nRow;
    }
    UpdateRow(m_nSelectedRow);
}
Example #3
0
//------------------------------------------------------------
// Overrides of CView and CBrView
void CBMRegEditView::OnUpdate(CView*, LPARAM lHint, CObject* pHint)
{ if (pHint!=NULL && theApp.m_nActiveFrame!=KBVIEW) return;
 if ( pHint != NULL && pHint->IsKindOf(RUNTIME_CLASS(CScriptDoc))) return;
 else if ( pHint != NULL && pHint->IsKindOf(RUNTIME_CLASS(CSBlock))) {
        int nReg = LOWORD(lHint)-1;
        if (theApp.m_nActiveFrame==KBVIEW) {
          UpdateRow(nReg);
        }
      }
 else { UpdateScrollSizes(); Invalidate(); }
}
Example #4
0
void CEx29aView::ChangeSelectionNextRow(BOOL bNext)
{
    if (bNext && (m_nSelectedRow < min(GetRowCount() - 1,
                                       LastViewableRow() - 2))) {
        m_nSelectedRow++;
    }
    if (!bNext && m_nSelectedRow) {
        m_nSelectedRow--;
    }
    UpdateRow(m_nSelectedRow);
}
void
HEventList::SetPath(const char* path)
{
	HEventRow* row = (HEventRow*)CurrentSelection();
	if (row != NULL) {
		entry_ref ref;
		BEntry entry(path);
		entry.GetRef(&ref);
		BMediaFiles().SetRefFor(fType, row->Name(), ref);

		row->SetPath(path);
		UpdateRow(row);
	}
}
Example #6
0
void
TreeTable::TableNodesChanged(TreeTableModel* model, const TreeTablePath& path,
	int32 childIndex, int32 count)
{
	TreeTableNode* node = _NodeForPath(path);
	if (node == NULL)
		return;

	int32 endIndex = childIndex + count;
	for (int32 i = childIndex; i < endIndex; i++) {
		if (TreeTableNode* child = node->ChildAt(i))
			UpdateRow(child->Row());
	}
}
Example #7
0
// Given a bookmark it updates the row in the dialog.  First it finds the
// row or appends a row if the bookmark is not found then calls UpdateRow
void CBookmarkDlg::UpdateBookmark(int index, BOOL select /*=FALSE*/)
{
	// First find the bookmark in the list
	int row;
	int col = COL_NAME + grid_.GetFixedColumnCount();
	for (row = grid_.GetFixedRowCount(); row < grid_.GetRowCount(); ++row)
	{
		if (grid_.GetItemData(row, col) == index)
			break;
	}
	if (row == grid_.GetRowCount())
	{
		// Not found so append a row and update that
		grid_.SetRowCount(row + 1);
	}

	UpdateRow(index, row, select);
}
Example #8
0
status_t _EndpointList::MidiUnregistered(int32 id, AmEndpointType type)
{
	BMidiEndpoint*	endpoint = BMidiRoster::FindEndpoint(id);
	if (!endpoint) {
		ArpASSERT(false);
		return B_ERROR;
	}
	BString			name = endpoint->Name();
	_EndpointRow*	p = ParentNamed(name, type);
	if (!p) return B_ERROR;
	if (!p->HasChanges() ) {
		DeleteRow(p);
	} else {
		p->SetIsValid(false);
		UpdateRow(p);
	}
	return B_OK;
}
Example #9
0
void _OwqList::MessageDropped(BMessage* msg, BPoint point)
{
	inherited::MessageDropped(msg, point);
	entry_ref		ref;
	if( msg->FindRef( "refs", &ref ) == B_OK ) {
		_OwqRow*	row = dynamic_cast<_OwqRow*>( RowAt(point) );
		if( !row ) {
			BMessage	prefs;
			prefs.AddBool( "on", true );
			prefs.AddRef( "ref", &ref );
			row = new _OwqRow( &prefs, view_font_height(this) );
			if( row )  AddRow( row );
		} else {
			row->SetRef( ref );
			UpdateRow(row);
		}
	}
}
Example #10
0
void _OwqList::Add(BMessage* msg)
{
	if( !msg ) return;
	BMessage	newItem, oldItem;
	if( msg->FindMessage( "new item", &newItem ) != B_OK ) return;
	if( msg->FindMessage( "old item", &oldItem ) == B_OK ) {
		_OwqRow*	row;
		for( int32 k = 0; (row = dynamic_cast<_OwqRow*>( RowAt(k) )); k++ ) {
			if( row->Matches( oldItem ) ) {
				row->SetPreferences( &newItem );
				UpdateRow( row );
				return;
			}
		}
	}

	_OwqRow*	row = new _OwqRow( &newItem, view_font_height(this) );
	if( row )  AddRow( row );
}
Example #11
0
void CMembersView::OnEdit()
{
	// Ignore if no selection.
	if (!m_lvGrid.IsSelection())
		return;

	// Get the current selection.
	int   iLVItem = m_lvGrid.Selection();
	CRow& oRow    = Row(iLVItem);

	CMemberDlg Dlg(m_oDB, oRow, true);

	if (Dlg.RunModal(*this) == IDOK)
	{
		// Update the list view.
		UpdateRow(iLVItem, true);

		App.m_AppCmds.UpdateUI();
	}
}
Example #12
0
BOOL CIniFileProcessor::OnInitDialog() 
{
	CDialog::OnInitDialog();

	for (int iData = 0; iData < 4; iData++)
		m_cListCtrl.InsertColumn(iData,m_szFieldNames[iData],
		LVCFMT_LEFT,
		m_cListCtrl.GetStringWidth(m_szFieldNames[iData])+100);

	{
		bool ColumnRWMap[4] = {false, true, false, false};
		m_cListCtrl.SetROColumns((bool*)ColumnRWMap);

	}

	m_cListCtrl.ModifyStyle(0, LVS_NOLABELWRAP | LVS_SINGLESEL | LVS_SHOWSELALWAYS);

	CString cTemp;
	int iNewItem = 0;
	for (int iData = 0; iData < ININAMECOUNT; iData++)
	{
		UpdateRow(true, iNewItem, iData);
		iNewItem++;
	}

	m_cListCtrl.SetExtendedStyle(m_cListCtrl.GetExtendedStyle()|LVS_EX_HEADERDRAGDROP | LVS_EX_FULLROWSELECT);
	// Win2k/XP only?
	//m_cListCtrl.SetExtendedStyle(m_cListCtrl.GetExtendedStyle()|LVS_EX_TRACKSELECT |LVS_EX_ONECLICKACTIVATE );
	GetDlgItem(IDOK)->EnableWindow(false);

	GetClientRect(&m_OldRect);
/*	CRect initRect;
	initRect.left = m_OldRect.right - GetSystemMetrics(SM_CXHSCROLL);
	initRect.top = m_OldRect.bottom - GetSystemMetrics(SM_CYVSCROLL);
	m_Grip.Create(WS_CHILD | SBS_SIZEBOX | SBS_SIZEBOXBOTTOMRIGHTALIGN | 
		SBS_SIZEGRIP | WS_VISIBLE, initRect, this, AFX_IDW_SIZE_BOX);
*/
	m_bInitialized = TRUE;
	return TRUE; 
}
Example #13
0
void CBookmarkDlg::OnAdd() 
{
	int index;                          // bookmark index of an existing bookmark of same name (or -1)
	CHexEditView *pview = GetView();
	ASSERT(pview != NULL);
	if (pview == NULL) return;

	CBookmarkList *pbl = theApp.GetBookmarkList();

	ASSERT(GetDlgItem(IDC_BOOKMARK_NAME) != NULL);
	CString name;
	GetDlgItem(IDC_BOOKMARK_NAME)->GetWindowText(name);
	if (name.GetLength() == 0) return;

	if (name[0] == '_')
	{
		AfxMessageBox("Names beginning with an underscore\r"
					  "are reserved for internal use.");
		return;
	}

	if (name.FindOneOf("|") != -1)
	{
		AfxMessageBox("Illegal characters in bookmark name");
		return;
	}

	CString file_name = pview->GetDocument()->pfile1_->GetFilePath();

	if ((index = pbl->GetIndex(name, file_name)) != -1)
	{
		CString ss;
		ss.Format("Bookmark \"%s\" already exists\r"
				  "in \"%s\".\r"
				  "Do you want to move it?", name, file_name);
		if (AfxMessageBox(ss, MB_YESNO) != IDYES)
			return;

#if 0 // moved to CBookmark
		// Remove overwritten bookmark from doc where it currently is
		CDocument *pdoc2;
		if (theApp.m_pDocTemplate->MatchDocType(pbl->file_[index], pdoc2) == 
			CDocTemplate::yesAlreadyOpen)
		{
			((CHexEditDoc *)pdoc2)->RemoveBookmark(index);
		}
#endif
	}

	// Add the bookmark to the list (overwrites existing bookmark of same name)
	int ii = pbl->AddBookmark(name, file_name,
							  pview->GetPos(), NULL, pview->GetDocument());

	theApp.SaveToMacro(km_bookmarks_add, name);

	// Find the new/replaced bookmark and select 
	int row, col = COL_NAME + grid_.GetFixedColumnCount();
	for (row = grid_.GetFixedRowCount(); row < grid_.GetRowCount(); ++row)
	{
		if (grid_.GetItemData(row, col) == ii)
			break;
	}
	ASSERT(row < grid_.GetRowCount());  // We should have found it

	grid_.SetSelectedRange(row, grid_.GetFixedColumnCount(), row, grid_.GetColumnCount()-1);
	grid_.EnsureVisible(row, 0);

	pbl->GoTo(ii);

#if 0 // moved to CBookmark::Add (now calls CBookmarkDlg::UpdateBookmark)
	// Save sort col (lost when we modify the grid) so we can re-sort later
//	int sort_col = grid_.GetSortColumn();
	int row;

	if (index == -1)
	{
		// Add a new row
		row = grid_.GetRowCount();
		grid_.SetRowCount(row + 1);
	}
	else
	{
		// Find the overwritten bookmark
		int col = COL_NAME + grid_.GetFixedColumnCount();
		for (row = grid_.GetFixedRowCount(); row < grid_.GetRowCount(); ++row)
		{
			if (grid_.GetItemData(row, col) == index)
				break;
		}
		ASSERT(row < grid_.GetRowCount());  // We should have found it
	}

	// Add bookmark to doc
	pview->GetDocument()->AddBookmark(ii, pos);

	// Update the row found or added and select it
	UpdateRow(ii, row);
	grid_.SetSelectedRange(row, grid_.GetFixedColumnCount(), row, grid_.GetColumnCount()-1);
	grid_.EnsureVisible(row, 0);

	// Re-sort the grid on the current sort column
//	if (sort_col != -1)
//		grid_.SortItems(sort_col, grid_.GetSortAscending());

//	// Close dialog
//	CDialog::OnOK();
#endif
}
Example #14
0
void CMembersView::RefreshRows(const CMembers::RowList& aoRows)
{
	// For all data rows, update grid row.
	for (size_t i = 0; i != aoRows.size(); i++)
		UpdateRow(FindRow(*aoRows[i]), false);
}
Example #15
0
void
TeamsListView::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_SELECTED_INTERFACE_CHANGED:
		{
			TargetHostInterface* interface;
			if (message->FindPointer("interface", reinterpret_cast<void**>(
					&interface)) == B_OK) {
				_SetInterface(interface);
			}
			break;
		}

		case MSG_TEAM_ADDED:
		{
			TeamInfo* info;
			team_id team;
			if (message->FindInt32("team", &team) != B_OK)
				break;

			TargetHost* host = fInterface->GetTargetHost();
			AutoLocker<TargetHost> hostLocker(host);
			info = host->TeamInfoByID(team);
			if (info == NULL)
				break;

			TeamRow* row = new TeamRow(info);
			AddRow(row);
			break;
		}

		case MSG_TEAM_REMOVED:
		{
			team_id team;
			if (message->FindInt32("team", &team) != B_OK)
				break;

			TeamRow* row = FindTeamRow(team);
			if (row != NULL) {
				RemoveRow(row);
				delete row;
			}
			break;
		}

		case MSG_TEAM_RENAMED:
		{
			TeamInfo* info;
			team_id team;
			if (message->FindInt32("team", &team) != B_OK)
				break;

			TargetHost* host = fInterface->GetTargetHost();
			AutoLocker<TargetHost> hostLocker(host);
			info = host->TeamInfoByID(team);
			if (info == NULL)
				break;

			TeamRow* row = FindTeamRow(info->TeamID());
			if (row != NULL && row->NeedsUpdate(info))
				UpdateRow(row);

			break;
		}

		default:
			Inherited::MessageReceived(message);
	}
}
Example #16
0
void CBookmarkDlg::OnValidate() 
{
	int move_count = 0;      // Number of bookmarks moved due to being past EOF

	CWaitCursor wc;
	CBookmarkList *pbl = theApp.GetBookmarkList();
	int fcc = grid_.GetFixedColumnCount();
	range_set<int> tt;                  // the grid rows to be removed

	for (int row = grid_.GetFixedRowCount(); row < grid_.GetRowCount(); ++row)
	{
		int index = grid_.GetItemData(row, fcc + COL_NAME);
		CDocument *pdoc;
		ASSERT(index > -1 && index < int(pbl->file_.size()));

		if (theApp.m_pDocTemplate->MatchDocType(pbl->file_[index], pdoc) == 
			CDocTemplate::yesAlreadyOpen)
		{
			// Bookmarks are checked when we open the document so we don't need to validate again here
			// (Ie this bookmark was checked when the file was opened.)
#if 0
			// The file is open so we need to check that the bookmark is <= the
			// in-memory file length which may be different to the on-disk length.
			if (pbl->filepos_[index] > ((CHexEditDoc *)pdoc)->length())
			{
				TRACE2("Validate: removing %s, file %s (loaded) is too short\n", pbl->name_[index], pbl->file_[index]);
				pbl->Remove(index);
				tt.insert(row);
			}
#endif
		}
		else if (_access(pbl->file_[index], 0) != -1)
		{
			// File found but make sure the bookmark is <= file length
			CFileStatus fs;                 // Used to get file size

			if (CFile64::GetStatus(pbl->file_[index], fs) &&
				pbl->filepos_[index] > __int64(fs.m_size))
			{
				TRACE2("Validate: moving %s, file %s is too short\n", pbl->name_[index], pbl->file_[index]);
				pbl->filepos_[index] = fs.m_size;
				UpdateRow(index, row);
				++move_count;
				// pbl->RemoveBookmark(index);
				// tt.insert(row);
			}
		}
		else
		{
			ASSERT(pbl->file_[index].Mid(1, 2) == ":\\"); // GetDriveType expects "D:\" under win9x

			// File not found so remove bookmark from the list
			// (unless it's a network/removeable file and net_retain_ is on)
			bool net_retain = ((CButton *)GetDlgItem(IDC_NET_RETAIN))->GetCheck() == BST_CHECKED;
			if (!net_retain || ::GetDriveType(pbl->file_[index].Left(3)) == DRIVE_FIXED)
			{
				TRACE2("Validate: removing bookmark %s, file %s not found\n", pbl->name_[index], pbl->file_[index]);
				pbl->RemoveBookmark(index);
				tt.insert(row);
			}
		}
	}

	// Now remove the rows from the display starting from the end
	range_set<int>::const_iterator pp;

	// Remove elements starting at end so that we don't muck up the row order
	for (pp = tt.end(); pp != tt.begin(); )
		grid_.DeleteRow(*(--pp));
	grid_.Refresh();

	if (move_count > 0 || tt.size() > 0)
	{
		CString mess;

		mess.Format("%ld bookmarks were deleted (files missing)\n"
					"%ld bookmarks were moved (past EOF)",
					long(tt.size()), long(move_count));
		AfxMessageBox(mess);
	}
	else
		AfxMessageBox("No bookmarks were deleted or moved.");
}
Example #17
0
void
ResView::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
		case M_NEW_FILE: {
			BRect r(100, 100, 400, 400);
			if (Window())
				r = Window()->Frame().OffsetByCopy(10, 10);
			ResWindow *win = new ResWindow(r);
			win->Show();
			break;
		}
		case M_OPEN_FILE: {
			be_app->PostMessage(M_SHOW_OPEN_PANEL);
			break;
		}
		case B_CANCEL: {
			if (fSaveStatus == FILE_QUIT_AFTER_SAVE)
				SetSaveStatus(FILE_DIRTY);
			break;
		}
		case B_SAVE_REQUESTED: {
			entry_ref saveDir;
			BString name;
			if (msg->FindRef("directory",&saveDir) == B_OK &&
				msg->FindString("name",&name) == B_OK) {
				SetTo(saveDir,name);
				SaveFile();
			}
			break;
		}
		case M_SAVE_FILE: {
			if (!fRef)
				fSavePanel->Show();
			else
				SaveFile();
			break;
		}
		case M_SHOW_SAVE_PANEL: {
			fSavePanel->Show();
			break;
		}
		case M_QUIT: {
			be_app->PostMessage(B_QUIT_REQUESTED);
			break;
		}
		case B_REFS_RECEIVED: {
			int32 i = 0;
			entry_ref ref;
			while (msg->FindRef("refs", i++, &ref) == B_OK)
				AddResource(ref);
			break;
		}
		case M_SELECT_FILE: {
			fOpenPanel->Show();
			break;
		}
		case M_DELETE_RESOURCE: {
			DeleteSelectedResources();
			break;
		}
		case M_EDIT_RESOURCE: {
			BRow *row = fListView->CurrentSelection();
			TypeCodeField *field = (TypeCodeField*)row->GetField(1);
			gResRoster.SpawnEditor(field->GetResourceData(), this);
			break;
		}
		case M_UPDATE_RESOURCE: {
			ResourceData *item;
			if (msg->FindPointer("item", (void **)&item) != B_OK)
				break;
			
			for (int32 i = 0; i < fListView->CountRows(); i++) {
				BRow *row = fListView->RowAt(i);
				TypeCodeField *field = (TypeCodeField*)row->GetField(1);
				if (!field || field->GetResourceData() != item)
					continue;
				
				UpdateRow(row);
				break;
			}
			break;
		}
		default:
			BView::MessageReceived(msg);
	}
}