Ejemplo n.º 1
0
void BComboBox::ChoiceListView::Draw(BRect update)
{
	float h = LineHeight();
	BRect rect(Bounds());
	int32 index;
	int32 choices = fParent->fChoiceList->CountChoices();
	int32 selected = (fTrackingMouseDown) ? fSelIndex : fParent->CurrentSelection();

	// draw each visible item
	for (index = (int32)floor(update.top / h); index < choices; index++)
	{
		rect.top = index * h;
		rect.bottom = rect.top + h;
		SetLowColor((index == selected) ? fSelCol : fBackCol);
		FillRect(rect, B_SOLID_LOW);
		DrawString(fParent->fChoiceList->ChoiceAt(index), BPoint(rect.left + 2,
			rect.bottom - fFontHeight.descent - 1));
	}

	// draw empty area on bottom
	if (rect.bottom < update.bottom)
	{
		update.top = rect.bottom;
		SetLowColor(fBackCol);
		FillRect(update, B_SOLID_LOW);
	}
}
Ejemplo n.º 2
0
BRect BComboBox::ChoiceListView::ItemFrame(int32 index)
{
	BRect rect(Bounds());
	float h = LineHeight();
	rect.top = index * h;
	rect.bottom = rect.top + h;
	return rect;
}
Ejemplo n.º 3
0
BSize
URLInputGroup::URLTextView::MinSize()
{
	BSize min;
	min.height = ceilf(LineHeight(0) + kHorizontalTextRectInset);
		// we always add at least one pixel vertical inset top/bottom for
		// the text rect.
	min.width = min.height * 3;
	return BLayoutUtils::ComposeSize(ExplicitMinSize(), min);
}
Ejemplo n.º 4
0
static void CenterString (RectPtr rptr, CharPtr text, FonT fnt, Int2 inc)

{
  if (fnt != NULL) {
    SelectFont (fnt);
  }
  rptr->bottom = rptr->top + LineHeight ();
  DrawString (rptr, text, 'c', FALSE);
  rptr->top = rptr->bottom + inc;
}
Ejemplo n.º 5
0
BSize
_BTextInput_::MinSize()
{
	BSize min;
	min.height = ceilf(LineHeight(0) + 2.0);
	// we always add at least one pixel vertical inset top/bottom for
	// the text rect.
	min.width = min.height * 3;
	return BLayoutUtils::ComposeSize(ExplicitMinSize(), min);
}
Ejemplo n.º 6
0
void
URLInputGroup::URLTextView::_AlignTextRect()
{
	// Layout the text rect to be in the middle, normally this means there
	// is one pixel spacing on each side.
	BRect textRect(Bounds());
	textRect.left = 0.0;
	float vInset = max_c(1,
		floorf((textRect.Height() - LineHeight(0)) / 2.0 + 0.5));
	float hInset = kHorizontalTextRectInset;

	if (be_control_look)
		hInset = be_control_look->DefaultLabelSpacing();

	textRect.InsetBy(hInset, vInset);
	SetTextRect(textRect);
}
Ejemplo n.º 7
0
void BComboBox::ChoiceListView::AdjustScrollBar()
{
	BScrollBar *sb = ScrollBar(B_VERTICAL);
	if (sb) {
		float h = LineHeight();
		float max = h * fParent->fChoiceList->CountChoices();
		BRect frame(Frame());
		float diff = max - frame.Height();
		float prop = frame.Height() / max;
		if (diff < 0) {
			diff = 0.0;
			prop = 1.0;
		}
		sb->SetSteps(h, h * (frame.IntegerHeight() / h));
		sb->SetRange(0.0, diff);
		sb->SetProportion(prop);
	}	
}
Ejemplo n.º 8
0
void BComboBox::ChoiceListView::MouseMoved(BPoint where, uint32 /*transit*/,
	const BMessage */*dragMessage*/)
{
	if (fTrackingMouseDown)
	{
		float h = LineHeight();
		int32 oldIndex = fSelIndex;
		fSelIndex = (int32)floor(where.y / h);
		int32 choices = fParent->fChoiceList->CountChoices();
		if (fSelIndex < 0 || fSelIndex >= choices)
			fSelIndex = -1;

		if (oldIndex != fSelIndex)
		{
			InvalidateItem(oldIndex);
			InvalidateItem(fSelIndex);
		}
	}
}
Ejemplo n.º 9
0
void
_BTextInput_::AlignTextRect()
{
	// the label font could require the control to be higher than
	// necessary for the text view, we compensate this by layouting
	// the text rect to be in the middle, normally this means there
	// is one pixel spacing on each side
	BRect textRect(Bounds());
	float vInset = max_c(1,
			floorf((textRect.Height() - LineHeight(0)) / 2.0));
	float hInset = 2;
	float textFontWidth = TextRect().right;

	if (be_control_look != NULL)  {
		switch (Alignment()) {
			case B_ALIGN_LEFT:
				hInset = be_control_look->DefaultLabelSpacing();
				break;

			case B_ALIGN_RIGHT:
				hInset  = textRect.right - textFontWidth;
				hInset -= be_control_look->DefaultLabelSpacing();
				break;

			case B_ALIGN_CENTER:
				hInset = (textRect.right - textFontWidth) / 2.0;
				break;

			default:
				break;
		}
	}

	textRect.InsetBy(hInset, vInset);
	SetTextRect(textRect);
}
Ejemplo n.º 10
0
void BComboBox::ChoiceListView::MouseDown(BPoint where)
{
	BRect rect(Window()->Frame());
	ConvertFromScreen(&rect);
	if (!rect.Contains(where))
	{
		// hide the popup window when the user clicks outside of it
		if (fParent->Window()->Lock())
		{
			fParent->HidePopupWindow();
			fParent->Window()->Unlock();
		}

		// HACK: the window is locked and unlocked so that it will get
		// activated before we potentially send the mouse down event in the
		// code below.  Is there a way to wait until the window is activated
		// before sending the mouse down? Should we call
		// fParent->Window()->MakeActive(true) here?
		
		if (fParent->Window()->Lock())
		{
			// resend the mouse event to the textinput, if necessary
			BTextView *text = fParent->TextView();
			BPoint screenWhere(ConvertToScreen(where));
			rect = text->Window()->ConvertToScreen(text->Frame());
			if (rect.Contains(screenWhere))
			{
				//printf("  resending mouse down to textinput\n");
				BMessage *msg = new BMessage(*Window()->CurrentMessage());
				msg->RemoveName("be:view_where");
				text->ConvertFromScreen(&screenWhere);
				msg->AddPoint("be:view_where", screenWhere);
				text->Window()->PostMessage(msg, text);
				delete msg;
			}
			fParent->Window()->Unlock();
		}
		
		return;
	}

	rect = Bounds();
	if (!rect.Contains(where))
		return;
	
	fTrackingMouseDown = true;
	// check for double click
	bigtime_t now = system_time();
	bigtime_t clickSpeed;
	get_click_speed(&clickSpeed);
	if ((now - fClickTime < clickSpeed)
		&& ((abs((int)(fClickLoc.x - where.x)) < 3)
		&& (abs((int)(fClickLoc.y - where.y)) < 3)))
	{
		// this is a double click
		// XXX: what to do here?
		printf("BComboBox::ChoiceListView::MouseDown() -- unhandled double click\n");
	}
	fClickTime = now;
	fClickLoc = where;

	float h = LineHeight();
	int32 oldIndex = fSelIndex;
	fSelIndex = (int32)floor(where.y / h);
	int32 choices = fParent->fChoiceList->CountChoices();
	if (fSelIndex < 0 || fSelIndex >= choices)
		fSelIndex = -1;

	if (oldIndex != fSelIndex)
	{
		InvalidateItem(oldIndex);
		InvalidateItem(fSelIndex);
	}
	// XXX: this probably isn't necessary since we are doing a SetEventMask
	// whenever the popup window becomes visible which routes all mouse events
	// to this view
//	SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
}
Ejemplo n.º 11
0
extern DialoG CreateBadgesDialog (
  GrouP prnt,
  SscTablesPtr stp
)

{
  GrouP       cts, tbl, g0, g1, g2, p;
  FonT        fnt;
  Int2        i, hgt, max, wid;
  SscBadgPtr  sbp;

  sbp = (SscBadgPtr) MemNew (sizeof (SscBadg));
  if (sbp == NULL) return NULL;

  p = HiddenGroup (prnt, -1, 0, NULL);
  SetGroupSpacing (p, 10, 10);

  SetObjectExtra (p, sbp, StdCleanupExtraProc);
  sbp->dialog = (DialoG) p;
  sbp->todialog = AwardDataPtrToAdjPage;
  sbp->fromdialog = AdjPageToAwardDataPtr;

  sbp->tables = stp;

  SelectFont (systemFont);
  hgt = LineHeight ();
  badgColFmt [0].pixWidth = 25 * StringWidth ("X") + 5;
  max = StringWidth ("Diamond Distance ");
  badgColFmt [1].pixWidth = max + 5;
  SelectFont (systemFont);

  wid = 0;
  for (i = 0; i < 2; i++) {
    wid += badgColFmt [i].pixWidth;
  }

  tbl = HiddenGroup (p, -1, 0, NULL);
  SetGroupSpacing (tbl, 10, 5);
  SetGroupMargins (tbl, 5, 5);

  g0 = HiddenGroup (tbl, 15, 0, NULL);
  SetGroupSpacing (g0, 0, 3);
#ifdef WIN_MSWIN
  fnt = systemFont;
#else
  fnt = programFont;
#endif
  StaticPrompt (g0, "Name", badgColFmt [0].pixWidth, 0, fnt, 'c');
  StaticPrompt (g0, "Award", badgColFmt [1].pixWidth, 0, fnt, 'c');

  sbp->badglog = DocumentPanel (tbl, wid + 2, NUM_BADGE_LINES * hgt + 2);
  SetObjectExtra (sbp->badglog, sbp, NULL);
  SetDocCache (sbp->badglog, NULL, NULL, NULL);
  SetDocNotify (sbp->badglog, ChangeBadgTableSelect);
  sbp->numBadgs = 0;

  for (i = 0; i < NUM_BADGE_LINES; i++) {
    AppendItem (sbp->badglog, PrintBadgTable, sbp, FALSE, 1,
                &badgParFmt, badgColFmt, systemFont);
  }

  cts = HiddenGroup (p, -1, 0, NULL);
  SetGroupSpacing (cts, 10, 10);
  SetGroupMargins (cts, 5, 5);

  g1 = HiddenGroup (cts, -10, 0, NULL);
  SetGroupSpacing (g1, 10, 5);

  StaticPrompt (g1, "Name", 0, popupMenuHeight, programFont, 'l');
  sbp->name = CreateEnumPopupDialog (g1, TRUE, ChangeName, stp->payers.alist, (UIEnum) 0, sbp);

  StaticPrompt (g1, "Award", 0, popupMenuHeight, programFont, 'l');
  sbp->reason = CreateEnumPopupDialog (g1, TRUE, ChangeReason, reason_alist, (UIEnum) 0, sbp);
  SetObjectExtra (sbp->reason, sbp, NULL);

  g2 = HiddenGroup (cts, -10, 0, NULL);
  SetGroupSpacing (g2, 10, 5);

  StaticPrompt (g2, "Comment", 0, dialogTextHeight, programFont, 'l');
  sbp->comment = DialogText (g2, "", 20, ChangeComment);
  SetObjectExtra (sbp->comment, sbp, NULL);

  AlignObjects (ALIGN_CENTER, (HANDLE) tbl, (HANDLE) cts, NULL);

  sbp->numBadgs = 0;
  sbp->currItem = 1;

  return (DialoG) p;
}