void
Window::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case kMsgShowAlert:
		{
			int32 count = fCountSlider->Value();

			BAlert* alert = new BAlert("Test title", "Lorem ipsum dolor sit "
				"amet, consectetur adipiscing elit. Suspendisse vel iaculis "
				"quam. Donec faucibus erat nunc, ac ullamcorper justo sodales.",
				"short 1", count > 1 ? "a bit longer 2" : NULL,
				count > 2 ? "very very long button 3" : NULL,
				_ButtonWidth(), _ButtonSpacing(), _AlertType());
			alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
			int result = alert->Go();
			if (result < 0) {
				fLastStringView->SetText("Canceled alert");
			} else {
				fLastStringView->SetText(BString().SetToFormat(
					"Pressed button %d", result + 1).String());
			}
			break;
		}
		default:
			BWindow::MessageReceived(message);
	}
}
Example #2
0
status_t
AboutView::SetVersion(const char* version)
{
	fVersionView->SetText(version);

	return B_OK;
}
Example #3
0
status_t
AboutView::SetName(const char* name)
{
	fNameView->SetText(name);

	return B_OK;
}
Example #4
0
	void Display()
	{
		BString count;

		FormatCountString(&count, totalFiles_, totalDirs_, totalBytes_);
		mTotalCount_->SetText(count.String());

		if (markedDirs_ > 0 || markedFiles_ > 0) {
			FormatCountString(&count, markedFiles_, markedDirs_, markedBytes_);
			count << " Marked";
		} else {
			count.SetTo("");
		}
		mMarkedCount_->SetText(count.String());

		Invalidate();
	}
Example #5
0
void
TeamDescriptionView::SetItem(TeamListItem* item)
{
	fItem = item;

	if (item == NULL) {
		int32 styleStart = 0;
		int32 styleEnd = 0;
		BString text;

		text.SetToFormat(fInfoString, fSeconds);
		fInfoTextView->SetText(text);
		if (fRebootRunner != NULL && fSeconds < 4) {
			styleStart = text.FindLast('\n');
			styleEnd = text.Length();
		}

		if (styleStart != styleEnd && fInfoTextView != NULL) {
			BFont font;
			fInfoTextView->GetFont(&font);
			font.SetFace(B_BOLD_FACE);
			fInfoTextView->SetStylable(true);
			fInfoTextView->SetFontAndColor(styleStart, styleEnd, &font);
		}
	} else {
		fTeamName->SetText(item->Path()->Path());

		if (item->IsSystemServer()) {
			if (fSysComponent->IsHidden(fSysComponent))
				fSysComponent->Show();
		} else {
			if (!fSysComponent->IsHidden(fSysComponent))
				fSysComponent->Hide();
		}

		if (item->IsRefusingToQuit()) {
			if (fQuitOverdue->IsHidden(fQuitOverdue))
				fQuitOverdue->Show();
		} else {
			if (!fQuitOverdue->IsHidden(fQuitOverdue))
				fQuitOverdue->Hide();
		}

		fIconView->SetIcon(item->Path()->Path());
	}

	if (fLayout == NULL)
		return;

	if (item == NULL)
		fLayout->SetVisibleItem((int32)0);
	else
		fLayout->SetVisibleItem((int32)1);

	Invalidate();
}
Example #6
0
status_t
PLabel::SetProperty(const char *name, PValue *value, const int32 &index)
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	if (FlagsForProperty(prop) & PROPERTY_READ_ONLY)
		return B_READ_ONLY;
	
	BStringView *backend = (BStringView*)fView;
	
	BoolValue boolval;
	CharValue charval;
	ColorValue colorval;
	FloatValue floatval;
	IntValue intval;
	PointValue pointval;
	RectValue rectval;
	StringValue stringval;
	
	status_t status = prop->SetValue(value);
	if (status != B_OK)
		return status;

	if (backend->Window())
		backend->Window()->Lock();

	if (str.ICompare("Alignment") == 0)
	{
		prop->GetValue(&intval);
		backend->SetAlignment((alignment)*intval.value);
	}
	else if (str.ICompare("Text") == 0)
	{
		prop->GetValue(&stringval);
		backend->SetText(*stringval.value);
	}
	else
	{
		if (backend->Window())
			backend->Window()->Unlock();

		return PView::SetProperty(name, value, index);
	}

	if (backend->Window())
		backend->Window()->Unlock();

	return prop->GetValue(value);
}
Example #7
0
void
AboutView::Pulse()
{
	char string[255];
	system_info info;
	get_system_info(&info);
	fUptimeView->SetText(UptimeToString(string, sizeof(string)));
	fMemView->SetText(MemUsageToString(string, sizeof(string), &info));

	if (fScrollRunner == NULL
		&& system_time() > fLastActionTime + 10000000) {
		BMessage message(SCROLL_CREDITS_VIEW);
		//fScrollRunner = new BMessageRunner(this, &message, 25000, -1);
	}
}
Example #8
0
status_t CharismaWindow::pulsehits()
{
	int hits0,hits1;
	char s[40];

	hits1=-1;
	for(;;){
		snooze(100000);

		hits0=hitcount;
		if(hits0!=hits1){
			sprintf(s,"Hits: %d",hitcount);
			Lock();
			hits->SetText(s);
			Unlock();
		}
		hits1=hits0;
	}
	
	return 0;
}
Example #9
0
File: Box.cpp Project: D-os/BeFree
void
BBox::SetLabel(const char *label)
{
	if (!(label == NULL || *label == 0)) {
		BStringView *strView = cast_as(fLabelView, BStringView);
		if (strView != NULL) {
			strView->SetText(label);
			strView->ResizeToPreferred();
			ReAdjustLabel();
			return;
		}

		if ((strView = new BStringView(BRect(0, 0, 1, 1), NULL, label, B_FOLLOW_NONE)) == NULL) return;
		strView->SetFont(be_bold_font);
		strView->ResizeToPreferred();
		if (SetLabel(strView) != B_OK) delete strView;
	} else if (fLabelView != NULL) {
		BView *view = fLabelView;
		fLabelView = NULL;

		view->RemoveSelf();
		delete view;
	}
}
Example #10
0
LibraryWindow::LibraryWindow(BRect frame, const BMessenger &parent, Project *project)
	:	DWindow(frame,NULL,B_TITLED_WINDOW,B_ASYNCHRONOUS_CONTROLS |
											B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE),
		fParent(parent),
		fProject(project)
{
	if (project)
	{
		BString title(TR("Libraries: "));
		title << project->GetName();
		SetTitle(title.String());
	}
	
	BView *top = GetBackgroundView();
	
	BRect r(10,10,11,11);
	BStringView *label = new BStringView(r,"label",TR("Choose the system libraries "
													"for your project."));
	label->ResizeToPreferred();
	top->AddChild(label);
	label->SetText(TR("Scanning libraries…"));
	
	r = Bounds().InsetByCopy(10,10);
	r.top = label->Frame().top + 20;
	r.right -= B_V_SCROLL_BAR_WIDTH;
	fCheckList = new BView(r,"checklist",B_FOLLOW_ALL,B_WILL_DRAW);
	
	BScrollView *scrollView = new BScrollView("scrollView",fCheckList,
											B_FOLLOW_ALL, 0,false,true);
	top->AddChild(scrollView);
	
	fScanThread = spawn_thread(ScanThread,"libscanthread",B_NORMAL_PRIORITY,this);
	resume_thread(fScanThread);
	
	fCheckList->MakeFocus(true);
}
Example #11
0
void MonthWindowView::MessageReceived(BMessage *msg)
{
 switch(msg->what)
 {
  case 'YEA0': // year before
  {
   if(cyear<=first_year) break;
   cyear--;
   NewMonth=true;
   BString s("");
   if(cyear<10) s.Append("000");
   else if(cyear<100) s.Append("00");
   else if(cyear<1000) s.Append("0");
   s<<cyear;
   yearStringView->SetText(s.String());
   
   if(cmonth==2) if(cday==29) // one can do simplier: if cday==29, then make
                              // cday=28, because two leap years one after other can't be
   {
    if(cyear%4!=0) cday=28;
    else if(cyear%100==0 && cyear%400!=0) cday=28;
   }
   
   DrawMonth();
   break;
  }
  case 'YEA1': // year after
  {
   if(cyear>=last_year) break;
   cyear++;
   NewMonth=true;
   BString s("");
   if(cyear<10) s.Append("000");
   else if(cyear<100) s.Append("00");
   else if(cyear<1000) s.Append("0");
   s<<cyear;
   yearStringView->SetText(s.String());
   
   if(cmonth==2) if(cday==29)
   {
    if(cyear%4!=0) cday=28;
    else if(cyear%100==0 && cyear%400!=0) cday=28;
   }
   
   DrawMonth();
   break;
  }
  case 'MON0': // month before
  {
   if(cmonth>1) cmonth--;
   else if(cyear>first_year)
   {
    cmonth=12;
    cyear--;
    
    BString s("");
    if(cyear<10) s.Append("000");
    else if(cyear<100) s.Append("00");
    else if(cyear<1000) s.Append("0");
    s<<cyear;
    yearStringView->SetText(s.String());
   }
   else break; // nothing is changed
   
   NewMonth=true;
   monthStringView->SetText(monthNames[cmonth-1]);
   
   if(cmonth==2)
   {
    int tmpday=28;
    if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) tmpday=29;
    if(cday>tmpday) cday=tmpday;
   }
   else if(cday>monthDays[cmonth-1]) cday=monthDays[cmonth-1];
   
   DrawMonth();
   break;
  }
  case 'MON1': // month after
  {
   if(cmonth<12) cmonth++;
   else if(cyear<last_year)
   {
    cmonth=1;
    cyear++;
    
    BString s("");
    if(cyear<10) s.Append("000");
    else if(cyear<100) s.Append("00");
    else if(cyear<1000) s.Append("0");
    s<<cyear;
    yearStringView->SetText(s.String());
   }
   else break; // nothing is changed
   
   NewMonth=true;
   monthStringView->SetText(monthNames[cmonth-1]);
   
   if(cmonth==2)
   {
    int tmpday=28;
    if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) tmpday=29;
    if(cday>tmpday) cday=tmpday;
   }
   else if(cday>monthDays[cmonth-1]) cday=monthDays[cmonth-1];
   
   DrawMonth();
   break;
  }
  case 'TODA': // to place to today's date
  {
   if(tyear<first_year || tyear>last_year) break;
   
   NewMonth=true;
   
   cyear=tyear;
   cmonth=tmonth;
   cday=tday;
   
   BString s("");
   if(cyear<10) s.Append("000");
   else if(cyear<100) s.Append("00");
   else if(cyear<1000) s.Append("0");
   s<<cyear;
   yearStringView->SetText(s.String());
   monthStringView->SetText(monthNames[cmonth-1]);
   
   DrawMonth();
   break;
  }
  default:
   BView::MessageReceived(msg);
 }
}
Example #12
0
void MonthWindowView::AttachedToWindow(void)
{
 SetFont(be_plain_font);
 
 SetViewColor(VIEW_COLOR);
 
 // Calculate size of cell needed for number of day of month
 font_height h;
 be_plain_font->GetHeight(&h);
 h_cell=(int)(h.ascent+h.descent+h.leading+6);
 w_cell=StringWidth("4")*4;
 
 

#ifdef __LANG_RUSSIAN
 
 BString s("");
 s<<tday;
 s.Append(" ");
 switch(tmonth)
 {
  case 1:
  {
   s.Append("января ");
   break;
  }
  case 2:
  {
   s.Append("февраля ");
   break;
  }
  case 3:
  {
   s.Append("марта ");
   break;
  }
  case 4:
  {
   s.Append("апреля ");
   break;
  }
  case 5:
  {
   s.Append("мая ");
   break;
  }
  case 6:
  {
   s.Append("июня ");
   break;
  }
  case 7:
  {
   s.Append("июля ");
   break;
  }
  case 8:
  {
   s.Append("августа ");
   break;
  }
  case 9:
  {
   s.Append("сентября ");
   break;
  }
  case 10:
  {
   s.Append("октября ");
   break;
  }
  case 11:
  {
   s.Append("ноября ");
   break;
  }
  case 12:
  {
   s.Append("декабря ");
   break;
  }
 }
 s<<tyear;
 s.Append(" г.");

#else // localized, english and french
 
 BString s("");
 s<<tday;
 s.Append(" ");
 s.Append(monthNames[tmonth-1]);
 s.Append(" ");
 s<<tyear;

#endif
 
 msng=new BMessenger(this);
 todayStringView=new MouseSenseStringView(new BMessage('TODA'), msng,
                                          BRect(10,10,100,100),"todayMStringViewAViX",
                                          s.String());
 AddChild(todayStringView);
 todayStringView->ResizeToPreferred();
 todayStringView->SetViewColor(VIEW_COLOR);
 
 monthStringView=new BStringView(BRect(10,10,100,100),"monthStringViewAViX",
                                 monthNames[8]);
 monthStringView->SetAlignment(B_ALIGN_CENTER);
 AddChild(monthStringView);
 monthStringView->ResizeToPreferred();
 monthStringView->SetText(monthNames[cmonth-1]);
 monthStringView->SetViewColor(VIEW_COLOR);
 
 s.SetTo("");
 if(cyear<10) s.Append("000");
 else if(cyear<100) s.Append("00");
 else if(cyear<1000) s.Append("0");
 s<<cyear;
 
 yearStringView=new BStringView(BRect(10,10,100,100),"yearStringViewAViX",
                                "0000");
 AddChild(yearStringView);
 yearStringView->ResizeToPreferred();
 yearStringView->SetText(s.String());
 yearStringView->SetViewColor(VIEW_COLOR);
 
 ResizeTo(w_cell*7+1,h_cell*7+3+16+yearStringView->Bounds().bottom+todayStringView->Bounds().bottom);
 Window()->ResizeTo(Bounds().right, Bounds().bottom);
 
 yearMStringView[0]=new MouseSenseStringView(new BMessage('YEA0'),msng,
                                             BRect(10,10,100,100),
                                             "yearMStringViewAViX0",
                                             "<<");
 AddChild(yearMStringView[0]);
 yearMStringView[0]->ResizeToPreferred();
 yearMStringView[0]->SetViewColor(VIEW_COLOR);
 
 yearMStringView[1]=new MouseSenseStringView(new BMessage('YEA1'),msng,
                                             BRect(10,10,100,100),
                                             "yearMStringViewAViX1",
                                             ">>");
 AddChild(yearMStringView[1]);
 yearMStringView[1]->ResizeToPreferred();
 yearMStringView[1]->SetViewColor(VIEW_COLOR);
 
 monthMStringView[0]=new MouseSenseStringView(new BMessage('MON0'),msng,
                                              BRect(10,10,100,100),
                                              "monthMStringViewAViX0",
                                              "<<");
 AddChild(monthMStringView[0]);
 monthMStringView[0]->ResizeToPreferred();
 monthMStringView[0]->SetViewColor(VIEW_COLOR);
 
 monthMStringView[1]=new MouseSenseStringView(new BMessage('MON1'),msng,
                                              BRect(10,10,100,100),
                                              "monthMStringViewAViX1",
                                              ">>");
 AddChild(monthMStringView[1]);
 monthMStringView[1]->ResizeToPreferred();
 monthMStringView[1]->SetViewColor(VIEW_COLOR);
 
 todayStringView->MoveTo((Bounds().right-todayStringView->Bounds().right)/2,
                         Bounds().bottom-todayStringView->Bounds().bottom-2);
 if(tyear<first_year || tyear>last_year) todayStringView->SetHighColor(NOACTIVE_COLOR);
  
 yearMStringView[1]->MoveTo(Bounds().right-yearMStringView[1]->Bounds().right,5);
 yearStringView->MoveTo(yearMStringView[1]->Frame().left-yearStringView->Bounds().right,5);
 yearMStringView[0]->MoveTo(yearStringView->Frame().left-yearMStringView[0]->Bounds().right,5);
 
 
 monthStringView->MoveTo((yearMStringView[0]->Frame().left-monthStringView->Bounds().right)/2,5);
 monthMStringView[0]->MoveTo(monthStringView->Frame().left-monthMStringView[0]->Bounds().right,5);
 monthMStringView[1]->MoveTo(monthStringView->Frame().right,5);
 
 which_focused=2; // days of month
 
 
 Bmp=new BBitmap(BRect(Frame()),B_RGB32,true);
 BmpView=new BView(Bmp->Bounds(),"BV",0,B_WILL_DRAW);
 Bmp->AddChild(BmpView);
 
 Bmp->Lock();
 BmpView->SetHighColor(VIEW_COLOR);
 BmpView->FillRect(BmpView->Frame());
 
 BmpView->SetHighColor(LINE_COLOR);
 BmpView->StrokeLine(BPoint(3,todayStringView->Frame().top-5),
                     BPoint(Bounds().right-3,todayStringView->Frame().top-5));
 BmpView->StrokeLine(BPoint(3,yearStringView->Frame().bottom+2),
                     BPoint(Bounds().right-3,yearStringView->Frame().bottom+2));
 BmpView->SetHighColor(0,0,0,0);
 
 float y=yearStringView->Frame().bottom+h_cell;
 float x=0;
 for(int i=0;i<7;i++)
 {
  BmpView->DrawString(weekdayNames[i],BPoint(x+(w_cell-StringWidth(weekdayNames[i]))/2,y));
  x+=w_cell;
 }
 
 BmpView->Sync();
 Bmp->Unlock();
 DrawMonth();
}
Example #13
0
void
ImageView::_UpdateImage()
{
	// ToDo: add scroller if necessary?!

	BAutolock locker(fEditor);

	// we need all the data...

	size_t viewSize = fEditor.ViewSize();
	// that may need some more memory...
	if ((off_t)viewSize < fEditor.FileSize())
		fEditor.SetViewSize(fEditor.FileSize());

	const char *data;
	if (fEditor.GetViewBuffer((const uint8 **)&data) != B_OK) {
		fEditor.SetViewSize(viewSize);
		return;
	}

	if (fBitmap != NULL && (fEditor.Type() == B_MINI_ICON_TYPE
			|| fEditor.Type() == B_LARGE_ICON_TYPE)) {
		// optimize icon update...
		fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
		fEditor.SetViewSize(viewSize);
		return;
	}
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
	if (fBitmap != NULL && fEditor.Type() == B_VECTOR_ICON_TYPE
		&& fScaleSlider->Value() * 8 - 1 == fBitmap->Bounds().Width()) {
		if (BIconUtils::GetVectorIcon((const uint8 *)data,
				(size_t)fEditor.FileSize(), fBitmap) == B_OK) {
			fEditor.SetViewSize(viewSize);
			return;
		}
	}
#endif

	delete fBitmap;
	fBitmap = NULL;

	switch (fEditor.Type()) {
		case B_MINI_ICON_TYPE:
			fBitmap = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
			if (fBitmap->InitCheck() == B_OK)
				fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
			break;
		case B_LARGE_ICON_TYPE:
			fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8);
			if (fBitmap->InitCheck() == B_OK)
				fBitmap->SetBits(data, fEditor.FileSize(), 0, B_CMAP8);
			break;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
		case B_VECTOR_ICON_TYPE:
			fBitmap = new BBitmap(BRect(0, 0, fScaleSlider->Value() * 8 - 1,
				fScaleSlider->Value() * 8 - 1), B_RGB32);
			if (fBitmap->InitCheck() != B_OK
				|| BIconUtils::GetVectorIcon((const uint8 *)data,
					(size_t)fEditor.FileSize(), fBitmap) != B_OK) {
				delete fBitmap;
				fBitmap = NULL;
			}
			break;
#endif
		case B_PNG_FORMAT:
		{
			BMemoryIO stream(data, fEditor.FileSize());
			fBitmap = BTranslationUtils::GetBitmap(&stream);
			break;
		}
		case B_MESSAGE_TYPE:
		{
			BMessage message;
			// ToDo: this could be problematic if the data is not large
			//		enough to contain the message...
			if (message.Unflatten(data) == B_OK)
				fBitmap = new BBitmap(&message);
			break;
		}
	}

	// Update the bitmap description. If no image can be displayed,
	// we will show our "unsupported" message

	if (fBitmap != NULL && fBitmap->InitCheck() != B_OK) {
		delete fBitmap;
		fBitmap = NULL;
	}

	if (fBitmap != NULL) {
		char buffer[256];
		const char *type = B_TRANSLATE("Unknown type");
		switch (fEditor.Type()) {
			case B_MINI_ICON_TYPE:
			case B_LARGE_ICON_TYPE:
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
			case B_VECTOR_ICON_TYPE:
#endif
				type = B_TRANSLATE("Icon");
				break;
			case B_PNG_FORMAT:
				type = B_TRANSLATE("PNG format");
				break;
			case B_MESSAGE_TYPE:
				type = B_TRANSLATE("Flattened bitmap");
				break;
			default:
				break;
		}
		const char *colorSpace;
		switch (fBitmap->ColorSpace()) {
			case B_GRAY1:
			case B_GRAY8:
				colorSpace = B_TRANSLATE("Grayscale");
				break;
			case B_CMAP8:
				colorSpace = B_TRANSLATE("8 bit palette");
				break;
			case B_RGB32:
			case B_RGBA32:
			case B_RGB32_BIG:
			case B_RGBA32_BIG:
				colorSpace = B_TRANSLATE("32 bit");
				break;
			case B_RGB15:
			case B_RGBA15:
			case B_RGB15_BIG:
			case B_RGBA15_BIG:
				colorSpace = B_TRANSLATE("15 bit");
				break;
			case B_RGB16:
			case B_RGB16_BIG:
				colorSpace = B_TRANSLATE("16 bit");
				break;
			default:
				colorSpace = B_TRANSLATE("Unknown format");
				break;
		}
		snprintf(buffer, sizeof(buffer), "%s, %g x %g, %s", type,
			fBitmap->Bounds().Width() + 1, fBitmap->Bounds().Height() + 1, 
			colorSpace);
		fDescriptionView->SetText(buffer);
	} else
		fDescriptionView->SetText(B_TRANSLATE_COMMENT("Could not read image", 
			"Image means here a picture file, not a disk image."));

	// Update the view size to match the image and its description

	float width, height;
	fDescriptionView->GetPreferredSize(&width, &height);
	fDescriptionView->ResizeTo(width, height);

	BRect rect = fDescriptionView->Bounds();
	if (fBitmap != NULL) {
		BRect bounds = fBitmap->Bounds();
		rect.bottom += bounds.Height() + 5;

		if (fScaleSlider != NULL && rect.Width() < fScaleSlider->Bounds().Width())
			rect.right = fScaleSlider->Bounds().right;
		if (bounds.Width() > rect.Width())
			rect.right = bounds.right;

		// center description below the bitmap
		fDescriptionView->MoveTo((rect.Width() - fDescriptionView->Bounds().Width()) / 2,
			bounds.Height() + 5);

		if (fScaleSlider != NULL) {
			// center slider below description
			rect.bottom += fScaleSlider->Bounds().Height() + 5;
			fScaleSlider->MoveTo((rect.Width() - fScaleSlider->Bounds().Width()) / 2,
				fDescriptionView->Frame().bottom + 5);

			if (fScaleSlider->IsHidden())
				fScaleSlider->Show();
		}
	} else if (fScaleSlider != NULL && !fScaleSlider->IsHidden())
		fScaleSlider->Hide();

	ResizeTo(rect.Width(), rect.Height());
	if (Parent()) {
		// center within parent view
		BRect parentBounds = Parent()->Bounds();
		MoveTo((parentBounds.Width() - rect.Width()) / 2,
			(parentBounds.Height() - rect.Height()) / 2);
	}

	Invalidate();

	// restore old view size
	fEditor.SetViewSize(viewSize);
}
Example #14
0
int32
LibraryWindow::ScanThread(void *data)
{
	LibraryWindow *win = (LibraryWindow *)data;

	float maxwidth;
	BRect r(5,5,105,20);
	
	BView *systemheader = win->AddHeader(r.LeftTop(),TR("System Libraries:"));
	
	win->Lock();
	r = systemheader->Frame();
	win->Unlock();
	maxwidth = r.right;
	
	r.OffsetBy(0,r.Height() + 10);
	
	DPath sysPath = GetSystemPath(B_USER_DEVELOP_DIRECTORY);
	sysPath << "lib/x86";
	BRect out = win->ScanFolder(r.LeftTop(),sysPath.GetFullPath(),&maxwidth);
	if (out != BRect(0,0,-1,-1))
	{
		r = out;
		r.OffsetBy(0,10);
	}
	
	if (gPlatform == PLATFORM_HAIKU || gPlatform == PLATFORM_HAIKU_GCC4)
	{
		BView *commonheader = win->AddHeader(r.LeftTop(),TR("Common Libraries:"));
		win->Lock();
		r = commonheader->Frame();
		win->Unlock();
		maxwidth = MAX(r.right,maxwidth);
		
		r.OffsetBy(0,r.Height() + 10);
		
		out = win->ScanFolder(r.LeftTop(),GetSystemPath(B_USER_LIB_DIRECTORY).GetFullPath(),
							&maxwidth);
		if (out != BRect(0,0,-1,-1))
		{
			r = out;
			r.OffsetBy(0,10);
		}
	}
	
	BView *userheader = win->AddHeader(r.LeftTop(),TR("User Libraries:"));
	win->Lock();
	r = userheader->Frame();
	win->Unlock();
	maxwidth = MAX(r.right,maxwidth);
	
	r.OffsetBy(0,r.Height() + 10);
	
	out = win->ScanFolder(r.LeftTop(),GetSystemPath(B_USER_LIB_DIRECTORY).GetFullPath(),
						&maxwidth);
	if (out.IsValid())
	{
		r = out;
		r.OffsetBy(0,10);
	}
	
	win->Lock();
	BView *top = win->GetBackgroundView();
	BScrollView *scrollView = (BScrollView*)top->FindView("scrollView");
	
	BScrollBar *vbar = scrollView->ScrollBar(B_VERTICAL);
	vbar->SetRange(0, r.bottom - scrollView->Bounds().Height());
	vbar->SetSteps(r.Height() * 2.0,r.Height() * 8.0);
	gSettings.Lock();
	BRect savedframe;
	if (gSettings.FindRect("libwin_frame",&savedframe) == B_OK)
		win->ResizeTo(savedframe.Width(),savedframe.Height());
	gSettings.Unlock();
	
	BStringView *label = (BStringView*)top->FindView("label");
	label->SetText(TR("Choose the system libraries for your project."));
	float minw = label->Frame().right + 10;
	win->SetSizeLimits(minw,30000,200,30000);
	if (win->Bounds().Width() < minw)
		win->ResizeTo(minw,win->Bounds().Height());
	win->fScanThread = -1;
	win->Unlock();
	
	return 0;
}
Example #15
0
void CharismaWindow::MessageReceived(BMessage *message)
{
	char buf[B_PATH_NAME_LENGTH+1024];
	BWindow *w;
	entry_ref ref;
	BEntry entry;
	BPath path;

	switch (message->what){
	
	case kMsg_About:
		about();
		break;

	case kMsg_SelectDirectory:
		w=selectdirpanel->Window();
		w->Lock();
		sprintf(buf,"Current: %s",g_webdir);
		currentdir->SetText(buf);
		w->Unlock();
		selectdirpanel->Show();
		break;
		
	case kMsg_DirSelected:
		if(message->FindRef("refs", 0, &ref)) break;
		entry.SetTo(&ref);
		entry.GetPath(&path);
		sprintf(g_webdir,"%s/",path.Path());
		sprintf(buf,
			"The new Web directory is: %s\n"
			"If you wish to use previously acquired data, you should move or copy them here.\n"
			"This modification will take effect for Stamina when Stamina is re-launched.",
			g_webdir);
		message->FindRef("refs",&ref);
		(new BAlert("Charisma message",buf,"OK"))->Go();
		saveprefs();
		break;

	case kMsg_ExternalControl:
		extcontrol_item->SetMarked(!extcontrol_item->IsMarked());
		update_proxy_settings();
		break;

	case kMsg_NetposAutosettings:
		netposautoset_item->SetMarked(!netposautoset_item->IsMarked());
		setnetpos();
		break;
		
	case kMsg_ClearHits:
		hitcount=0;
		break;
		
	case kMsg_ProxySettings:
		update_proxy_settings();
		setnetpos();
		break;
		
	default:
		BWindow::MessageReceived(message);
		break;
	}
}