Пример #1
0
filter_result
AutoTextControlFilter::Filter(BMessage* msg, BHandler** target)
{
	int32 rawchar, mod;
	msg->FindInt32("raw_char", &rawchar);
	msg->FindInt32("modifiers", &mod);

	BView* view = dynamic_cast<BView*>(*target);
	if (view != NULL || view->Name() != NULL && strcmp("_input_", view->Name()))
		return B_DISPATCH_MESSAGE;
	
	AutoTextControl* text = dynamic_cast<AutoTextControl*>(view->Parent());
	if (!text || text != fBox)
		return B_DISPATCH_MESSAGE;

	fCurrentMessage = msg;
	filter_result result = KeyFilter(rawchar, mod);
	fCurrentMessage = NULL;

	if (fBox->fCharLimit && result == B_DISPATCH_MESSAGE) {
		// See to it that we still allow shortcut keys
		if (mod & B_COMMAND_KEY)
			return B_DISPATCH_MESSAGE;

		// We don't use strlen() because it is not UTF-8 aware, which can
		// affect how many characters can be typed.
		if (isprint(rawchar) && 
				(uint32)BString(text->Text()).CountChars() == text->fCharLimit)
			return B_SKIP_MESSAGE;
	}

	return result;
}
Пример #2
0
int32 ToolTip::Tool_Thread(){
   BPoint loc;
   BPoint oldloc;
   ulong button;
   int32 count = 0;
   BView *v = NULL;
   
   // Wait until the BApplication becomes valid, in case
   // someone creates this as a global variable.
   while(!be_app_messenger.IsValid()){
      snooze(200000);
   }
   
   // while the app is valid, run. This is a 
   // easy way to let the thread natually die
	while(be_app_messenger.IsValid()){
		if(ttWin->Lock()){
			ttWin->ChildAt(0)->GetMouse(&loc, &button);
			ttWin->ConvertToScreen(&loc);
			if((loc == oldloc) && !button){
				if(count == 5){
					if(ttWin->IsHidden()){
						BPoint tr = loc;
						v = FindView(tr);
						const char *tip = NULL;
						while(v && (tip = GetTip(v)) == NULL){
							v = v->Parent();
						}
						if(tip){
							if(tip && strcmp(tip,"")){
								ttWin->Tip(loc,tip);
							}else{
								//ttWin->Tip(loc,"whats up with the No tip haven tool?");
							}
						}
					}
				}else{
					count++;
				}
			}else{
				count = 0;
				if(!(ttWin->IsHidden())){
					ttWin->Bye();
				}
			}
			oldloc = loc;
			ttWin->Unlock();
			//snooze(250000);
			snooze(150000);
		}else{
			snooze(1000000);
		}
	}
	return B_OK;
}
filter_result
BStatusMouseFilter::Filter(BMessage* message, BHandler** target)
{
	// If the target is the status bar, make sure the message goes to the
	// parent view instead.
	if ((*target)->Name() != NULL
		&& strcmp((*target)->Name(), "StatusBar") == 0) {
		BView* view = dynamic_cast<BView*>(*target);
		if (view != NULL)
			view = view->Parent();
		if (view != NULL)
			*target = view;
	}

	return B_DISPATCH_MESSAGE;
}
Пример #4
0
void
BGLView::FrameResized(float width, float height)
{
	fBounds = Bounds();
	for (BView *v = this; v; v = v->Parent())
		v->ConvertToParent(&fBounds);

	if (fRenderer) {
		LockGL();
		_LockDraw();
		fRenderer->FrameResized(width, height);
		_UnlockDraw();
		UnlockGL();
	}

   	BView::FrameResized(width, height);
}
Пример #5
0
void
BGLView::AttachedToWindow()
{
	BView::AttachedToWindow();

	fBounds = Bounds();
	for (BView *view = this; view != NULL; view = view->Parent())
		view->ConvertToParent(&fBounds);

	fRenderer = fRoster->GetRenderer();
	if (fRenderer != NULL) {
		// Jackburton: The following code was commented because it doesn't look
		// good in "direct" mode:
		// when the window is moved, the app_server doesn't paint the view's
		// background, and the stuff behind the window itself shows up. 
		// Setting the view color to black, instead, looks a bit more elegant.
#if 0
		// Don't paint white window background when resized
		SetViewColor(B_TRANSPARENT_32_BIT);
#else
		SetViewColor(0, 0, 0);
#endif
		// Set default OpenGL viewport:
		glViewport(0, 0, Bounds().IntegerWidth(), Bounds().IntegerHeight());
		fRenderer->FrameResized(Bounds().IntegerWidth(), Bounds().IntegerHeight());

		if (fClipInfo) {
			fRenderer->DirectConnected(
				((glview_direct_info *)fClipInfo)->direct_info);
			fRenderer->EnableDirectMode(
				((glview_direct_info *)fClipInfo)->enable_direct_mode);
		}

		return;
	}
	
	fprintf(stderr, "no renderer found! \n");

	// No Renderer, no rendering. Setup a minimal "No Renderer" string drawing
	// context
	SetFont(be_bold_font);
	// SetFontSize(16);
}
Пример #6
0
// Buttons are enabled or not depending on the selection in the list
// so each time you click in the list, this method is called to update the buttons
void NetListView::SelectionChanged(void)
{
	int32 index = CurrentSelection();

	BView *parent = Parent();
	
	if (index >= 0) {
		
		// There are 2 lists that are instances of this class, so we have to see in which list you are clicking
		if (strcmp(parent->Name(),"Interfaces_Scroller") == 0) {												  
			
			BButton *settings = dynamic_cast <BButton *> ((parent->Parent())->FindView("Settings"));
			BButton *clear 	  = dynamic_cast <BButton *> ((parent->Parent())->FindView("Clear"));
			
			settings->SetEnabled(true);
			clear->SetEnabled(true);
		}
		else if (strcmp(parent->Name(),"Configurations_Scroller") == 0) {
			
			BButton *restore = dynamic_cast <BButton *> ((parent->Parent())->FindView("Restore"));
			BButton *remove	 = dynamic_cast <BButton *> ((parent->Parent())->FindView("Delete"));
			
			restore ->SetEnabled(true);
			remove  ->SetEnabled(true);
		}
	}
	else {
		
		// There are 2 lists that are instances of this class, so we have to see in which list you are clicking
		if (strcmp(parent->Name(),"Interfaces_Scroller") == 0) {												  
		
			BButton *settings=dynamic_cast <BButton *> ((parent->Parent())->FindView("Settings"));
			BButton *clear=dynamic_cast <BButton *> ((parent->Parent())->FindView("Clear"));
			
			settings->SetEnabled(false);
			clear->SetEnabled(false);
		}
		else if (strcmp(parent->Name(),"Configurations_Scroller") == 0) {
		
			BButton *restore=dynamic_cast <BButton *> ((parent->Parent())->FindView("Restore"));
			BButton *remove=dynamic_cast <BButton *> ((parent->Parent())->FindView("Delete"));
			
			restore->SetEnabled(false);
			remove->SetEnabled(false);
		}
	}			
				
}
Пример #7
0
void
AgentDockHeaderString::MouseUp (BPoint where)
{
	SetViewColor (tint_color (ui_color (B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
	Parent()->SetViewColor (tint_color (ui_color (B_MENU_BACKGROUND_COLOR), B_DARKEN_1_TINT));
	Invalidate();
	Parent()->Invalidate();
	
	// check if this header string belongs to notify list and send resize message if so
	BView *notifyList (Parent());
	if (notifyList && dynamic_cast<AgentDockHeader *>(notifyList) != NULL)
	{
		notifyList = notifyList->Parent();
		if (notifyList && dynamic_cast<AgentDockNotifyList *>(notifyList) != NULL)
		{
			BMessenger msgr (((AgentDockNotifyList *)notifyList)->pNotifyList());
			if (msgr.IsValid())
				msgr.SendMessage (M_NOTIFYLIST_RESIZE);
		}
	}

	BStringView::MouseUp (where);
}
Пример #8
0
filter_result
SpinnerMsgFilter::Filter(BMessage *msg, BHandler **target)
{
	int32 c;
	msg->FindInt32("raw_char",&c);
	switch (c) {
		case B_ENTER: {
			BTextView *text = dynamic_cast<BTextView*>(*target);
			if (text && text->IsFocus()) {
				BView *view = text->Parent();
				while (view) {					
					Spinner *spin = dynamic_cast<Spinner*>(view);
					if (spin) {
						BString string(text->Text());
						int32 newvalue = 0;
						
						sscanf(string.String(),"%ld",&newvalue);
						if (newvalue != spin->Value()) {
							spin->SetValue(newvalue);
							spin->Invoke();
						}
						return B_SKIP_MESSAGE;
					}
					view = view->Parent();
				}
			}
			return B_DISPATCH_MESSAGE;
		}
		case B_TAB: {
			// Cause Tab characters to perform keybaord navigation
			BHandler *h = *target;
			BView *v = NULL;
			
			h = h->NextHandler();
			while (h) {
				v = dynamic_cast<BView*>(h);
				if (v) {
					*target = v->Window();
					return B_DISPATCH_MESSAGE;
				}
				h = h->NextHandler();
			}
			return B_SKIP_MESSAGE;
		}
		case B_UP_ARROW:
		case B_DOWN_ARROW: {
			BTextView *text = dynamic_cast<BTextView*>(*target);
			if (text && text->IsFocus()) {
				// We have a text view. See if it currently has the focus and belongs
				// to a Spinner control. If so, change the value of the spinner
				
				// TextViews are complicated beasts which are actually multiple views.
				// Travel up the hierarchy to see if any of the target's ancestors are
				// a Spinner.
				
				BView *view = text->Parent();
				while (view) {					
					Spinner *spin = dynamic_cast<Spinner*>(view);
					if (spin) {
						int32 step = spin->GetSteps();
						if (c == B_DOWN_ARROW)
							step = 0 - step;
						
						spin->SetValue(spin->Value() + step);
						spin->Invoke();
						return B_SKIP_MESSAGE;
					}
					view = view->Parent();
				}
			}
			
			return B_DISPATCH_MESSAGE;
		}
		default:
			return B_DISPATCH_MESSAGE;
	}
	
	// shut the stupid compiler up
	return B_SKIP_MESSAGE;
}
Пример #9
0
void CPrefsDialog::PostInit()
{
	BAutolock lock(this);

	strcpy(fNewFontFamily, gPrefs->GetPrefString("defdoc font family", NULL));
	fNewFontSize = gPrefs->GetPrefDouble("defdoc font size", 0.0);
	strcpy(fNewBFontFamily, gPrefs->GetPrefString("border font family", NULL));
	fNewBFontSize = gPrefs->GetPrefDouble("border font size", 0.0);

	CellStyle cs;
	font_style style;

	fOwner->GetCellView()->GetContainer()->GetDefaultCellStyle(cs);
	try {
		gFontSizeTable.GetFontInfo(cs.fFont, &fDocFontFamily, &style, &fDocFontSize);
		gFontSizeTable.GetFontInfo(fOwner->GetCellView()->BorderFontID(),
			&fDocBFontFamily, &style, &fDocBFontSize);
	}
	catch (CErr& e) {
		e.DoError();
	}

	BMenuField *mf = dynamic_cast<BMenuField*>(FindView("docfont"));
	fDocFont = mf->Menu();
	if (fDocFont) 
	{
		for (long i = 0; i < count_font_families(); i++)
		{
			font_family ff;
			get_font_family(i, &ff);
			fDocFont->AddItem(new BMenuItem(ff, new BMessage(msg_Changed)));
		}
		fDocFont->SetRadioMode(TRUE);
	}

	mf = dynamic_cast<BMenuField*>(FindView("borderfont"));
	fBorderFont = mf->Menu();
	for (long i = 0; i < count_font_families(); i++)
	{
		font_family ff;
		get_font_family(i, &ff);
		fBorderFont->AddItem(new BMenuItem(ff, new BMessage(msg_Changed)));
	}
	fBorderFont->SetRadioMode(TRUE);

	mf = dynamic_cast<BMenuField*>(FindView("dateorder"));
	fDMY = mf->Menu();
	fDMY->AddItem(new BMenuItem("dmy", new BMessage(msg_Changed)));
	fDMY->AddItem(new BMenuItem("dym", new BMessage(msg_Changed)));
	fDMY->AddItem(new BMenuItem("mdy", new BMessage(msg_Changed)));
	fDMY->AddItem(new BMenuItem("myd", new BMessage(msg_Changed)));
	fDMY->AddItem(new BMenuItem("ydm", new BMessage(msg_Changed)));
	fDMY->AddItem(new BMenuItem("ymd", new BMessage(msg_Changed)));

	mf = dynamic_cast<BMenuField*>(FindView("neworcur"));
	if (mf)
	{
		fNewOrCur = mf->Menu();
		fNewOrCur->AddItem(new BMenuItem("New Documents", new BMessage(msg_ChangeTarget)));
		if (fOwner)
		{
			char s[32];
			fDocFont->FindItem(fDocFontFamily)->SetMarked(true);
			ftoa(fDocFontSize, s);
			SetText("docsize", s);
			fBorderFont->FindItem(fDocBFontFamily)->SetMarked(true);
			ftoa(fDocBFontSize, s);
			SetText("bordersize", s);

			fNewOrCur->AddItem(new BMenuItem(fOwner->Title(), new BMessage(msg_ChangeTarget)));
			fNewOrCur->ItemAt(1)->SetMarked(true);
		}
		else
			fNewOrCur->ItemAt(0)->SetMarked(true);
		mf->SetDivider(be_plain_font->StringWidth(mf->Label()) + 4);
	}

	BBox *b;
	BView *v;
	v = FindView("prgrid");
	b = dynamic_cast<BBox*>(v->Parent());
	if (b)
	{
		char t[256];
		sprintf(t, b->Label(), fOwner->Title());
		b->SetLabel(t);
	}
	
	fAutoRecalc = fOwner->GetCellView()->DoesAutoRecalc();
	fDisplayZero = fOwner->GetCellView()->DoesDisplayZero();
	fPrGrid = fOwner->GetCellView()->PrintsGrid();
	fPrBorders = fOwner->GetCellView()->PrintsBorders();
	fShGrid = fOwner->GetCellView()->ShowsGrid();
	fShBorders = fOwner->GetCellView()->ShowsBorders();

	CancelClicked();

	Show();
} /* CPrefsDialog::PostInit */
Пример #10
0
void BubbleHelper::Helper()
{
	// Wait until the BApplication becomes valid, in case
	// someone creates this as a global variable.
	while (!be_app_messenger.IsValid()) snooze(200000);
	// wait a little longer, until the BApplication is really up to speed
	while (be_app->IsLaunching()) snooze(200000);

	textwin = new BWindow(BRect(-100, -100, -50, -50), "", B_BORDERED_WINDOW_LOOK,
						  B_FLOATING_ALL_WINDOW_FEEL, B_NOT_MOVABLE | B_AVOID_FOCUS);

	textview = new BTextView(BRect(0, 0, 50, 50), "", BRect(1, 1, 49, 49), B_FOLLOW_ALL_SIDES,
							 B_WILL_DRAW);
	textview->MakeEditable(false);
	textview->MakeSelectable(false);
	textview->SetWordWrap(false);
	textview->SetLowColor(255, 255, 190);
	textview->SetViewColor(255, 255, 190);
	textview->SetHighColor(0, 0, 0);
	textwin->AddChild(textview);
	textwin->Run();
	textwin->Lock();
	textwin->Activate(false);
	rename_thread(textwin->Thread(), "bubble");
	textwin->Unlock();

	ulong delaycounter = 0;
	BPoint lastwhere;

	while (be_app_messenger.IsValid()) {
		BPoint where;
		uint32 buttons;
		if (enabled) {
			if (textwin->Lock()) {
				textview->GetMouse(&where, &buttons);
				textview->ConvertToScreen(&where);
				if (lastwhere != where || buttons) {
					delaycounter = 0;
				} else {
					// mouse didn't move
					if (delaycounter++ > 5) {
						delaycounter = 0;
						// mouse didn't move for a while
						BView* view = FindView(where);
						char* text = NULL;
						while (view && (text = GetHelp(view)) == NULL) view = view->Parent();
						if (text) {
							DisplayHelp(text, where);
							// wait until mouse moves out of view, or wait
							// for timeout
							long displaycounter = 0;
							BPoint where2;
							long displaytime = max_c(20, strlen(text));
							do {
								textwin->Unlock();
								snooze(100000);
								if (!textwin->Lock()) goto end; // window is apparently gone
								textview->GetMouse(&where2, &buttons);
								textview->ConvertToScreen(&where2);
							} while (!buttons && where2 == where &&
									 (displaycounter++ < displaytime));

							HideBubble();
							do {
								textwin->Unlock();
								snooze(100000);
								if (!textwin->Lock()) goto end; // window is apparently gone
								textview->GetMouse(&where2, &buttons);
								textview->ConvertToScreen(&where2);
							} while (where2 == where);
						}
					}
				}
				lastwhere = where;
				textwin->Unlock();
			}
		}
	end:
		snooze(100000);
	}
	// (this thread normally gets killed by the destructor before arriving here)
}