Exemplo n.º 1
0
void
ICSTXTControl::AddTxt(BString const& str)
{
    float min, max;
    AutoLocker<BLocker> autolocker(fLocker);
    fScrollBar->GetRange(&min, &max);

    if (fScrollBar->Value() == max) {
        fTxtView->Insert(fTxtView->TextLength(), str.String(), str.Length());
        fScrollBar->GetRange(&min, &max);
        fScrollBar->SetValue(max);
    }
    else {
        fTxtView->Insert(fTxtView->TextLength(), str.String(), str.Length());
    }
}
Exemplo n.º 2
0
void
ICSTXTControl::MessageReceived(BMessage* message)
{
    switch (message->what) {
		case M_SEND_BUTTON:
        {
            AutoLocker<BLocker> autolocker(fLocker);

            BString str(fTxtControl->Text());

            if (str.Length() < 1)
                return;

            BString command = str;
            SendICS(command.Prepend("1000 "), Window());

            str.Prepend("\n").Append("\n");
            fTxtView->Insert(fTxtView->TextLength(), str, str.Length());
            float min, max;
            fScrollBar->GetRange(&min, &max);
            fScrollBar->SetValue(max);
            fTxtControl->SetText("");
            fTxtControl->MakeFocus();
			break;
        }

        case ICS_USER_CMD_RESPONSE:
        {
            BString str = "";
            message->FindString("info", &str);
            AddTxt(str);
            break;
        }

		default:
            BGroupView::MessageReceived(message);
			break;
	}
}
void GenesisCopyWindow::PrepareCopy(void)
////////////////////////////////////////////////////////////////////////
{
	BRect rect;
	
	rgb_color BarColor;
	BarColor.red = 180;
	BarColor.green = 190;
	BarColor.blue = 200;	

	m_DestPath.SetTo(m_DirName->Text());
	
	if (m_SingleCopy)
		m_DestFileName.SetTo(m_FileAsName->Text());

	if (IsDirReadOnly(m_DestPath.String()))
	{
		BAlert *myAlert = new BAlert("Copy", "Cannot copy to a write protected volume.", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
		myAlert->SetShortcut(0, B_ESCAPE);
		myAlert->Go();
		return;
	}

	BEntry dest(m_DestPath.String());
	
	if (dest.InitCheck()!=B_OK)
	{
		BAlert *myAlert = new BAlert("Copy","Cannot initialize destination entry.","OK", NULL, NULL,B_WIDTH_AS_USUAL,B_OFFSET_SPACING,B_WARNING_ALERT);
		myAlert->Go();
		return;
	}
	
	if (!dest.Exists())
	{
		BAlert *myAlert = new BAlert("Copy","Destination path does not exist.","OK", NULL, NULL,B_WIDTH_AS_USUAL,B_OFFSET_SPACING,B_WARNING_ALERT);
		myAlert->Go();
		return;
	}
	
	if (!dest.IsDirectory())
	{
		BAlert *myAlert = new BAlert("Copy","Destination path is not a folder.","OK", NULL, NULL,B_WIDTH_AS_USUAL,B_OFFSET_SPACING,B_WARNING_ALERT);
		myAlert->Go();
		return;
	}

	BAutolock autolocker(this);
	
	m_AbortButton = m_CopyButton;
	m_AbortButton->SetMessage(new BMessage(BUTTON_MSG_ABORTCOPY));
	m_PauseButton = m_CancelButton;
	m_PauseButton->SetMessage(new BMessage(BUTTON_MSG_PAUSECOPY));
	
	m_DirName->RemoveSelf();
	m_Label->RemoveSelf();				//	m_Label->MoveBy(0,40);
	
	if (m_SingleCopy)
		m_FileAsName->RemoveSelf();
	
	SetTitle("Copy in progress...");
	
	// Add ProgressBar
	if (!m_SingleCopy)
	{
		rect = Bounds();
		rect.left += 24;
		rect.right -= 24;
		rect.top += 8;
		rect.bottom = rect.top+40;
		m_ProgressBar = new BStatusBar(rect,"progressbar","0%","100%");
		m_ProgressBar->SetViewColor(216,216,216);
		m_ProgressBar->SetLowColor(216,216,216);
		m_ProgressBar->SetHighColor(0,0,0);
		m_ProgressBar->SetBarColor(BarColor);
		m_ProgressBar->SetMaxValue(m_FileCount);
		m_View->AddChild(m_ProgressBar);
	}
	
	// Add File Bar
	rect = Bounds();
	rect.left += 24;
	rect.right -= 24;
	if (m_SingleCopy)
		rect.top += 32;
	else
		rect.top += 48;
	rect.bottom = rect.top+40;
	m_FileBar = new BStatusBar(rect,"filebar","","");
	m_FileBar->SetViewColor(216,216,216);
	m_FileBar->SetLowColor(216,216,216);
	m_FileBar->SetHighColor(0,0,0);
	m_FileBar->SetBarColor(BarColor);
	m_View->AddChild(m_FileBar);

	m_AbortButton->SetLabel("Abort");
	m_PauseButton->SetLabel("Pause");

	RemoveParentSelection();

	if (m_SingleCopy)
		m_CopyThread = spawn_thread(SingleCopyThreadFunc, "CopyThread", B_NORMAL_PRIORITY, (void *)this);
	else
		m_CopyThread = spawn_thread(MultiCopyThreadFunc, "CopyThread", B_NORMAL_PRIORITY, (void *)this);
	resume_thread(m_CopyThread);
}