Exemplo n.º 1
0
/**
 * @brief 		dispalys a listbox
 * @retval		None
 * displays the listbox based on its state
 */
void jddex_listbox::Show()
{
	JC_RECT stAbsRect, stTextRect, stIconRect;
	JC_INT32 iBorderColor ;
	JC_UINT32 uiVisibleRows = 0;
	JC_UINT32 uiWidth = 0, uiHeight = 0 ;
	JDDEX_LIST_ITEM	  * pstListItems = *m_stJddexListBox.pstListItems;

	GetAbsRect(&stAbsRect);
	if(m_stListBox.uiVisibleRows == 0)
		uiVisibleRows = m_stListBox.uiNumberItems;
	else
		uiVisibleRows = m_stListBox.uiVisibleRows;


	if(m_bIsFocussed)
	{
		iBorderColor = JDDEX_DEFAULT_BLUE;
	}
	else
	{
		iBorderColor = JDDEX_DEFAULT_BLACK ;
	}
	jddex_DrawFormattedRect(&stAbsRect,iBorderColor, JDDEX_DEFAULT_WHITE, 
				JDDEX_DEFAULT_LISTBOX_BORDER_WIDTH);

	jddex_GetListBoxIConDimensions(&uiWidth, &uiHeight);

	stTextRect = stAbsRect;
	stTextRect.uiWidth -= uiWidth;

	 if(m_stListBox.uiNumberItems > 0)
    {
		//display the first selcted if any or dispaly the 1st list item
		jddex_FormattedDrawTextEx(pstListItems[GetFirstSelection()].psText, stTextRect, m_stControlStyle, 
										E_JDDEX_LEFT_ALLIGN|E_JDDEX_MIDDLE_ALLIGN);
	}

	stIconRect.uiWidth  = uiWidth; // width of the icon
	stIconRect.uiHeight = uiHeight; // height of the icon
	stIconRect.iLeft = stAbsRect.iLeft + stAbsRect.uiWidth - uiWidth;
    stIconRect.iTop = stAbsRect.iTop;

	//draw the icon at the end of the box
	jddex_DrawFormattedListBoxIcon(&stIconRect);
}
GenesisCopyWindow::GenesisCopyWindow(CustomListView *list, PanelView *destpanel, const char *destination, BLooper* looper, BWindow *mainwindow) :
	BWindow(BRect(0,0,320,140), "Copy...", B_TITLED_WINDOW , B_WILL_DRAW)
////////////////////////////////////////////////////////////////////////
{
	BRect rect;

	m_CustomListView = list;
	m_DestPanel = destpanel;
	m_DestPath.SetTo(destination);
	m_Looper = looper;
	m_Window = mainwindow;

	m_SingleCopy = false;
	m_Paused = false;
	m_SkipAllCopyError = false;
	m_OverwriteAll = false;
	m_SkipSymLinkCreationError = false;

	// After the delete process we have to select an item if no item selected...
	m_Selection = GetFirstSelection();

	// First we have to remove the parent selection if selected...
//	RemoveParentSelection();

	m_FileCount = m_CustomListView->CountSelectedEntries(CT_WITHOUTPARENT);			

	if (m_FileCount == 1)
		m_SingleCopy = true;

	SetType(B_FLOATING_WINDOW);
	SetFeel(B_MODAL_SUBSET_WINDOW_FEEL);
	SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE);

	AddToSubset(mainwindow);

	m_View = new BView(Bounds(), "copyview", B_FOLLOW_ALL, B_WILL_DRAW);
	m_View->SetViewColor(216, 216, 216, 0);
	AddChild(m_View);

	// Bottom View	
	rect = Bounds();
	rect.top = rect.bottom-44;
	BView *BottomView = new BView(rect, "infobottomview", B_FOLLOW_BOTTOM, B_WILL_DRAW);
	BottomView->SetViewColor(180, 190, 200, 0);
	m_View->AddChild(BottomView);	
/*
	// More checkbox
	rect = BottomView->Bounds();
	rect.top = rect.bottom-30;
	rect.bottom = rect.bottom-14;
	rect.left = 20;
	rect.right = rect.left+40;	
	m_MoreCB = new BCheckBox(rect,"more","Show more",new BMessage(COPY_MORE), B_FOLLOW_BOTTOM, B_WILL_DRAW);
	m_MoreCB->ResizeToPreferred();
	BottomView->AddChild(m_MoreCB);
*/	
	// OK Button	
	rect = BottomView->Bounds();
	rect.top = rect.bottom-34;
	rect.bottom = rect.bottom-14;
	rect.left = rect.right-80;
	rect.right = rect.right-20;	
	m_CopyButton = new BButton(rect,"copy","Copy",new BMessage(BUTTON_MSG_COPY),B_FOLLOW_BOTTOM,B_WILL_DRAW);
	BottomView->AddChild(m_CopyButton);

	//Cancel Button
	rect = BottomView->Bounds();
	rect.top = rect.bottom-34;
	rect.bottom = rect.bottom-14;
	rect.left = rect.right-160;
	rect.right = rect.right-100;	
	m_CancelButton = new BButton(rect,"cancel","Cancel",new BMessage(BUTTON_MSG_CANCELCOPY),B_FOLLOW_BOTTOM,B_WILL_DRAW);
	BottomView->AddChild(m_CancelButton);

	SetDefaultButton(m_CopyButton);

	// Info string
	rect = Bounds();
	rect.left += 24;
	rect.right -= 24;
	if (m_SingleCopy)
		rect.top += 8;
	else
		rect.top += 16;
	rect.bottom = rect.top+20;
	m_Label = new BStringView(rect,"filename","Copy");
	m_Label->SetAlignment(B_ALIGN_CENTER);
	m_Label->SetViewColor(216,216,216);
	m_Label->SetLowColor(216,216,216);
	m_Label->SetHighColor(0,0,0);
	AddChild(m_Label);

	// Edit field
	rect = BottomView->Bounds();
	if (m_SingleCopy)
		rect.top = rect.top+36;
	else
		rect.top = rect.top+56;
	rect.bottom = rect.top+32;
	rect.left += 20;
	rect.right -= 20;
	m_DirName = new BTextControl( rect, "destname", "to", "", NULL );
	m_DirName->SetDivider(m_View->StringWidth("to")+4);
	m_DirName->SetModificationMessage(new BMessage(COPYNAME_CHANGED));
	m_DirName->SetText(m_DestPath.String());
	m_View->AddChild(m_DirName);

	// "as" field
	if (m_SingleCopy)
	{
		rect = BottomView->Bounds();
		rect.top = rect.top+64;
		rect.bottom = rect.top+32;
		rect.left += 20;
		rect.right -= 20;

		m_FileAsName = new BTextControl( rect, "destfilename", "as", "", NULL );
		m_FileAsName->SetDivider(m_View->StringWidth("to")+4);
		m_FileAsName->SetModificationMessage(new BMessage(COPYNAME_CHANGED));

		if (((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_Type == FT_PARENT)
			m_FileAsName->SetText( ((CustomListItem *)m_CustomListView->GetSelectedEntry(1))->m_FileName.String() );
		else
			m_FileAsName->SetText( ((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_FileName.String() );
		
		m_View->AddChild(m_FileAsName);
	}

	m_DirName->MakeFocus(true);	
	
	// Ctrl + Q closes the window...
	AddShortcut('Q', 0, new BMessage(BUTTON_MSG_CANCELCOPY));

	// Set copy label...
	if (m_SingleCopy)
	{
		BString text;
		text.SetTo("Copy '");
		if (((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_Type == FT_PARENT)
			text << ((CustomListItem *)m_CustomListView->GetSelectedEntry(1))->m_FileName;
		else
			text << ((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_FileName;
		text << "'";
	
		m_Label->SetText(text.String());
	}
	else
	{
		BString text;
		text.SetTo("Copy ");
		text << m_FileCount << " files";
		
		m_Label->SetText(text.String());
	}
	
	AddCommonFilter(new EscapeFilter(this, new BMessage(BUTTON_MSG_CANCELCOPY)));
	
	// If there is a given window, let's align our window to its center...
	if (mainwindow)
	{
		BRect myrect = Bounds();
		
		rect = mainwindow->Frame();
		float w = rect.right - rect.left;
		float h = rect.bottom - rect.top;
		MoveTo(rect.left + w/2 - (myrect.right-myrect.left)/2, rect.top + h/2 - (myrect.bottom-myrect.top)/2);
	}
}