Example #1
0
void
THeaderView::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
		case B_SIMPLE_DATA:
		{
			BTextView *textView = dynamic_cast<BTextView *>(Window()->CurrentFocus());
			if (dynamic_cast<TTextControl *>(textView->Parent()) != NULL)
				textView->Parent()->MessageReceived(msg);
			else {
				BMessage message(*msg);
				message.what = REFS_RECEIVED;
				Window()->PostMessage(&message, Window());
			}
			break;
		}

		case kMsgFrom:
		{
			BMenuItem *item;
			if (msg->FindPointer("source", (void **)&item) >= B_OK)
				item->SetMarked(true);

			int32 account;
			if (msg->FindInt32("id",(int32 *)&account) >= B_OK)
				fAccountID = account;
			
			BMessage message(FIELD_CHANGED);
			// field doesn't matter; no special processing for this field
			// it's just to turn on the save button
			message.AddInt32("bitmask", 0);
			Window()->PostMessage(&message, Window());
			
			break;
		}

		case kMsgEncoding:
		{
			BMessage message(*msg);
			int32 charSet;

			if (msg->FindInt32("charset", &charSet) == B_OK)
				fCharacterSetUserSees = charSet;

			message.what = CHARSET_CHOICE_MADE;
			message.AddInt32 ("charset", fCharacterSetUserSees);
			Window()->PostMessage (&message, Window());
			
			BMessage message2(FIELD_CHANGED);
			// field doesn't matter; no special processing for this field
			// it's just to turn on the save button
			message2.AddInt32("bitmask", 0);
			Window()->PostMessage(&message2, Window());
			
			break;
		}
	}
}
Example #2
0
void
THeaderView::MessageReceived(BMessage *msg)
{
	switch (msg->what) {
		case B_SIMPLE_DATA:
		{
			BTextView *textView = dynamic_cast<BTextView *>(Window()->CurrentFocus());
			if (dynamic_cast<TTextControl *>(textView->Parent()) != NULL)
				textView->Parent()->MessageReceived(msg);
			else {
				BMessage message(*msg);
				message.what = REFS_RECEIVED;
				Window()->PostMessage(&message, Window());
			}
			break;
		}

		case kMsgFrom:
		{
			BMenuItem *item;
			if (msg->FindPointer("source", (void **)&item) >= B_OK)
				item->SetMarked(true);

			uint32 chain;
			if (msg->FindInt32("id",(int32 *)&chain) >= B_OK)
				fChain = chain;
			break;
		}

		case kMsgEncoding:
		{
			BMessage message(*msg);
			int32 charSet;

			if (msg->FindInt32("charset", &charSet) == B_OK)
				fCharacterSetUserSees = charSet;

			message.what = CHARSET_CHOICE_MADE;
			message.AddInt32 ("charset", fCharacterSetUserSees);
			Window()->PostMessage (&message, Window());
			break;
		}
	}
}
Example #3
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;
}