本文整理汇总了C++中BRect类的典型用法代码示例。如果您正苦于以下问题:C++ BRect类的具体用法?C++ BRect怎么用?C++ BRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BWindow
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entry)
: BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position),
"Application Type", B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS),
fChangedProperties(0)
{
// add the menu
BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL);
AddChild(menuBar);
BMenu* menu = new BMenu("File");
fSaveMenuItem = new BMenuItem("Save", new BMessage(kMsgSave), 'S');
fSaveMenuItem->SetEnabled(false);
menu->AddItem(fSaveMenuItem);
BMenuItem* item;
menu->AddItem(item = new BMenuItem("Save into resource file" B_UTF8_ELLIPSIS,
NULL));
item->SetEnabled(false);
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED),
'W', B_COMMAND_KEY));
menuBar->AddItem(menu);
// Top view and signature
BRect rect = Bounds();
rect.top = menuBar->Bounds().Height() + 1.0f;
BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(topView);
rect = topView->Bounds().InsetByCopy(8.0f, 8.0f);
fSignatureControl = new BTextControl(rect, "signature", "Signature:", NULL,
new BMessage(kMsgSignatureChanged), B_FOLLOW_LEFT_RIGHT);
fSignatureControl->SetModificationMessage(
new BMessage(kMsgSignatureChanged));
fSignatureControl->SetDivider(fSignatureControl->StringWidth(
fSignatureControl->Label()) + 4.0f);
float width, height;
fSignatureControl->GetPreferredSize(&width, &height);
fSignatureControl->ResizeTo(rect.Width(), height);
topView->AddChild(fSignatureControl);
// filter out invalid characters that can't be part of a MIME type name
BTextView* textView = fSignatureControl->TextView();
textView->SetMaxBytes(B_MIME_TYPE_LENGTH);
const char* disallowedCharacters = "<>@,;:\"()[]?=";
for (int32 i = 0; disallowedCharacters[i]; i++) {
textView->DisallowChar(disallowedCharacters[i]);
}
// "Application Flags" group
BFont font(be_bold_font);
font_height fontHeight;
font.GetHeight(&fontHeight);
width = font.StringWidth("Icon") + 16.0f;
if (width < B_LARGE_ICON + 16.0f)
width = B_LARGE_ICON + 16.0f;
rect.top = fSignatureControl->Frame().bottom + 4.0f;
rect.bottom = rect.top + 100.0f;
rect.right -= width + 8.0f;
BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
topView->AddChild(box);
fFlagsCheckBox = new BCheckBox(rect, "flags", "Application flags",
new BMessage(kMsgToggleAppFlags));
fFlagsCheckBox->SetValue(B_CONTROL_ON);
fFlagsCheckBox->ResizeToPreferred();
box->SetLabel(fFlagsCheckBox);
rect.top = fFlagsCheckBox->Bounds().Height() + 4.0f;
fSingleLaunchButton = new BRadioButton(rect, "single", "Single launch",
new BMessage(kMsgAppFlagsChanged));
fSingleLaunchButton->ResizeToPreferred();
box->AddChild(fSingleLaunchButton);
rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f);
fMultipleLaunchButton = new BRadioButton(rect, "multiple",
"Multiple launch", new BMessage(kMsgAppFlagsChanged));
fMultipleLaunchButton->ResizeToPreferred();
box->AddChild(fMultipleLaunchButton);
rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f);
fExclusiveLaunchButton = new BRadioButton(rect, "exclusive",
"Exclusive launch", new BMessage(kMsgAppFlagsChanged));
fExclusiveLaunchButton->ResizeToPreferred();
box->AddChild(fExclusiveLaunchButton);
rect.top = fSingleLaunchButton->Frame().top;
rect.left = fExclusiveLaunchButton->Frame().right + 4.0f;
fArgsOnlyCheckBox = new BCheckBox(rect, "args only", "Args only",
new BMessage(kMsgAppFlagsChanged));
fArgsOnlyCheckBox->ResizeToPreferred();
box->AddChild(fArgsOnlyCheckBox);
//.........这里部分代码省略.........
示例2: ui_color
void
KeyboardLayoutView::_DrawKey(BView* view, BRect updateRect, const Key* key,
BRect rect, bool pressed)
{
rgb_color base = key->dark ? kDarkColor : kBrightColor;
rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
key_kind keyKind = kNormalKey;
int32 deadKey = 0;
bool secondDeadKey = false;
bool isDeadKeyEnabled = true;
char text[32];
if (fKeymap != NULL) {
_GetKeyLabel(key, text, sizeof(text), keyKind);
deadKey = fKeymap->DeadKey(key->code, fModifiers, &isDeadKeyEnabled);
secondDeadKey = fKeymap->IsDeadSecondKey(key->code, fModifiers,
fDeadKey);
} else {
// Show the key code if there is no keymap
snprintf(text, sizeof(text), "%02" B_PRIx32, key->code);
}
_SetFontSize(view, keyKind);
if (secondDeadKey)
base = kSecondDeadKeyColor;
else if (deadKey > 0 && isDeadKeyEnabled)
base = kDeadKeyColor;
if (key->shape == kRectangleKeyShape) {
_DrawKeyButton(view, rect, updateRect, base, background, pressed);
rect.InsetBy(1, 1);
_GetAbbreviatedKeyLabelIfNeeded(view, rect, key, text, sizeof(text));
be_control_look->DrawLabel(view, text, rect, updateRect,
base, 0, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
} else if (key->shape == kEnterKeyShape) {
BRect topLeft = rect;
BRect topRight = rect;
BRect bottomLeft = rect;
BRect bottomRight = rect;
// TODO: for some reason, this does not always equal the bottom of
// the other keys...
bottomLeft.top = floorf(rect.top
+ fLayout->DefaultKeySize().height * fFactor - fGap - 1);
bottomLeft.right = floorf(rect.left
+ (key->frame.Width() - key->second_row) * fFactor - fGap - 2);
topLeft.bottom = bottomLeft.top;
topLeft.right = bottomLeft.right + 1;
// add one to make the borders meet
topRight.bottom = topLeft.bottom;
topRight.left = topLeft.right;
bottomRight.top = bottomLeft.top;
bottomRight.left = bottomLeft.right;
// draw top left corner
be_control_look->DrawButtonFrame(view, topLeft, updateRect,
4.0f, 0.0f, 4.0f, 0.0f, base, background,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
| BControlLook::B_BOTTOM_BORDER);
be_control_look->DrawButtonBackground(view, topLeft, updateRect,
4.0f, 0.0f, 4.0f, 0.0f, base,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_LEFT_BORDER | BControlLook::B_TOP_BORDER
| BControlLook::B_BOTTOM_BORDER);
// draw top right corner
be_control_look->DrawButtonFrame(view, topRight, updateRect,
0.0f, 4.0f, 0.0f, 0.0f, base, background,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER);
be_control_look->DrawButtonBackground(view, topRight, updateRect,
0.0f, 4.0f, 0.0f, 0.0f, base,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_TOP_BORDER | BControlLook::B_RIGHT_BORDER);
// draw bottom right corner
be_control_look->DrawButtonFrame(view, bottomRight, updateRect,
0.0f, 0.0f, 4.0f, 4.0f, base, background,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER
| BControlLook::B_BOTTOM_BORDER);
be_control_look->DrawButtonBackground(view, bottomRight, updateRect,
0.0f, 0.0f, 4.0f, 4.0f, base,
pressed ? BControlLook::B_ACTIVATED : 0,
BControlLook::B_LEFT_BORDER | BControlLook::B_RIGHT_BORDER
| BControlLook::B_BOTTOM_BORDER);
// clip out the bottom left corner
bottomLeft.right += 1;
bottomLeft.top -= 2;
BRegion region(rect);
region.Exclude(bottomLeft);
view->ConstrainClippingRegion(®ion);
//.........这里部分代码省略.........
示例3: Window
void
SLoadingModulesView::ReGetBitmap()
{
BWindow *window = Window();
if(!window) return;
bool is_hidden = window->IsHidden();
if(!is_hidden) window->Hide();
BScreen screen(window);
BBitmap *screen_bitmap = NULL;
BRect rect = screen.Frame().OffsetToCopy(B_ORIGIN);
if(screen.GetBitmap(&screen_bitmap, false, &rect) == B_OK)
{
if(screen_bitmap)
{
if(bitmap) delete bitmap;
rect = ConvertToScreen(Bounds());
bitmap = new BBitmap(rect.OffsetToCopy(B_ORIGIN), B_BITMAP_ACCEPTS_VIEWS, B_RGB32);
if(bitmap)
{
SAutolock<BBitmap> autolock(bitmap);
BView *bitmap_view = new BView(bitmap->Bounds(), NULL, B_FOLLOW_NONE, B_WILL_DRAW);
bitmap->AddChild(bitmap_view);
bitmap_view->PushState();
bitmap_view->SetDrawingMode(B_OP_COPY);
bitmap_view->DrawBitmap(screen_bitmap, rect, rect.OffsetToCopy(B_ORIGIN));
bitmap_view->SetDrawingMode(B_OP_ALPHA);
BPoint circle_center;
float circle_radius = bitmap->Bounds().Height() / 2;
circle_center.x = bitmap->Bounds().left + circle_radius;
circle_center.y = bitmap->Bounds().top + circle_radius;
bitmap_view->SetHighColor(ViewColor());
bitmap_view->FillArc(circle_center, circle_radius, circle_radius, 0, 360);
bitmap_view->SetHighColor(220, 220, 220, 150);
bitmap_view->StrokeArc(circle_center, circle_radius, circle_radius, 45, 180);
bitmap_view->SetHighColor(20, 20, 20, 150);
bitmap_view->StrokeArc(circle_center, circle_radius, circle_radius, 225, 180);
BRect rect = bitmap->Bounds();
rect.left = circle_center.x;
rect.InsetBy(0, 5);
bitmap_view->SetHighColor(ViewColor());
bitmap_view->FillRoundRect(rect, 3, 3);
bitmap_view->SetHighColor(220, 220, 220, 150);
bitmap_view->StrokeRoundRect(rect, 3, 3);
bitmap_view->SetHighColor(20, 20, 20, 150);
rect.left += 1; rect.top += 1;
bitmap_view->StrokeRoundRect(rect, 3, 3);
rect.right -= 1; rect.bottom -= 1;
bitmap_view->SetHighColor(ViewColor());
bitmap_view->FillArc(circle_center, circle_radius - 1, circle_radius - 1, 0, 360);
bitmap_view->FillRoundRect(rect, 3, 3);
bitmap_view->PopState();
bitmap_view->Sync();
}
delete screen_bitmap;
}
}
if(!is_hidden) window->Show();
}
示例4: PRINT
void
Model::TrackIconSource(icon_size size)
{
PRINT(("tracking %s icon\n", size == B_LARGE_ICON ? "large" : "small"));
BRect rect;
if (size == B_MINI_ICON)
rect.Set(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1);
else
rect.Set(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1);
BBitmap bitmap(rect, B_CMAP8);
BModelOpener opener(this);
if (Node() == NULL) {
PRINT(("track icon error - no node\n"));
return;
}
if (IsSymLink()) {
PRINT(("tracking symlink icon\n"));
if (fLinkTo) {
fLinkTo->TrackIconSource(size);
return;
}
}
if (fBaseType == kVolumeNode) {
BVolume volume(NodeRef()->device);
status_t result = volume.GetIcon(&bitmap, size);
PRINT(("getting icon from volume %s\n", strerror(result)));
} else {
BNodeInfo nodeInfo(Node());
status_t err = nodeInfo.GetIcon(&bitmap, size);
if (err == B_OK) {
// file knew which icon to use, we are done
PRINT(("track icon - got icon from file\n"));
return;
}
char preferredApp[B_MIME_TYPE_LENGTH];
err = nodeInfo.GetPreferredApp(preferredApp);
if (err == B_OK && preferredApp[0]) {
BMimeType preferredAppType(preferredApp);
err = preferredAppType.GetIconForType(MimeType(), &bitmap, size);
if (err == B_OK) {
PRINT(("track icon - got icon for type %s from preferred app %s for file\n",
MimeType(), preferredApp));
return;
}
}
BMimeType mimeType(MimeType());
err = mimeType.GetIcon(&bitmap, size);
if (err == B_OK) {
// the system knew what icon to use for the type, we are done
PRINT(("track icon - signature %s, got icon from system\n",
MimeType()));
return;
}
err = mimeType.GetPreferredApp(preferredApp);
if (err != B_OK) {
// no preferred App for document, give up
PRINT(("track icon - signature %s, no prefered app, error %s\n",
MimeType(), strerror(err)));
return;
}
BMimeType preferredAppType(preferredApp);
err = preferredAppType.GetIconForType(MimeType(), &bitmap, size);
if (err == B_OK) {
// the preferred app knew icon to use for the type, we are done
PRINT(("track icon - signature %s, got icon from preferred app %s\n",
MimeType(), preferredApp));
return;
}
PRINT(("track icon - signature %s, preferred app %s, no icon, error %s\n",
MimeType(), preferredApp, strerror(err)));
}
}
示例5: m_seqGlobal
// c'tor
TempoView::TempoView(SeqGlobal& seqGlobal, BRect frame) :
m_seqGlobal(seqGlobal),
BView(frame, "tempo-view", B_FOLLOW_TOP|B_FOLLOW_LEFT,
B_WILL_DRAW) {
// create sliders
BRect sliderRect = Bounds();
sliderRect.bottom = 40;
// (leave room for the border)
sliderRect.InsetBy(2,2);
//---------------------------------------//
// coarse-tempo slider:
// measured in 10ths
//---------------------------------------//
m_pCoarseSlider = new TempoSlider(sliderRect,
"coarse-bpm-slider", NULL,
new BMessage(TEMPO_SET_BPM),
10, 3000); // min & max values (x10)
// set to init value
int32 nBPMT = m_seqGlobal.getTempo(); // returns in 1000ths of a BPM
m_pCoarseSlider->SetValue(nBPMT/100);
// set min/max labels
m_pCoarseSlider->SetLimitLabels("1.0", "300.0");
// set hash marks
m_pCoarseSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
m_pCoarseSlider->SetHashMarkCount(10);
// add
AddChild(m_pCoarseSlider);
#if 0
//---------------------------------------//
// fine-tempo slider (+/- 1 BPM)
// measured in 1000ths
//---------------------------------------//
sliderRect.OffsetBy(0, 40);
m_pFineSlider = new TempoSlider(sliderRect,
"fine-bpm-slider", NULL,
new BMessage(TEMPO_SET_BPM_FINE),
-1000, 1000); // min & max in BPM/1000
// set to init (center) value
m_pFineSlider->SetValue(0);
// set labels
updateFineSliderLabels(nBPMT);
// set hash marks
m_pFineSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
m_pFineSlider->SetHashMarkCount(3);
m_pFineSlider->SetSnoozeAmount(10000);
// add
AddChild(m_pFineSlider);
#endif /* 0 */
// prepare for drawing; set color:
rgb_color bgGray = {219,219,219,255};
SetViewColor(bgGray);
}
示例6: CloseDatabase
void BeAccessibleWindow::OpenDatabase(BPath path)
{
//If a database is already open, close it before opening a new one.
if (GlobalSQLMgr->IsOpen())
CloseDatabase();
//Open the given database
bool databaseOpened = GlobalSQLMgr->Open(path.Path());
if (databaseOpened)
{
//Add database to list of recently opened files
BeAccessibleApp* myApp = static_cast<BeAccessibleApp*>(be_app);
myApp->AddToRecentFiles(new BString(path.Path()));
//Create the beaccessible_master table if it's not there
if (!GlobalSQLMgr->TableExists("beaccessible_master"))
{
BString sql = "create table beaccessible_master (name Text, type Text, "
"value Text, primary key (name, type));";
GlobalSQLMgr->Execute(sql.String());
}
}
Lock();
//Change title of window to include database name
BString newTitle("BeAccessible : ");
newTitle += path.Leaf();
SetTitle(newTitle.String());
//Create tab for Tables (hopefully someday Queries, too!)
BRect frame = Bounds();
BRect menuHeight = fMenuBar->Bounds();
frame.top += menuHeight.Height() + 1;
frame.InsetBy(10.0, 10.0);
const char* tabNames[1] = {"Tables"};
fTabView = new TabView(frame, NULL, tabNames, 1, B_FOLLOW_ALL_SIDES);
fTabView->SetViewColor(216,216,216,0);
BRect ContentRect = fTabView->GetContentArea();
ContentRect.InsetBy(5,5);
fTableTab = new DBTabView(ContentRect, "Table");
BView* tabs[1];
tabs[0] = (BView*)fTableTab;
fTabView->AddViews(tabs);
fMainView->AddChild(fTabView);
//Select the first table as default
fTableTab->fListView->Select(0);
//Enable certain menu items since there is now a database open
EnableMenuItems();
Unlock();
// Save the database's full path to a string
fPath->SetTo(path.Path());
}
示例7: autoConfigRect
void
ConfigWindow::MessageReceived(BMessage *msg)
{
float fontFactor = be_plain_font->Size() / 12.0f;
BRect autoConfigRect(0, 0, 400 * fontFactor, 300 * fontFactor);
BRect frame;
AutoConfigWindow *autoConfigWindow = NULL;
switch (msg->what) {
case B_COLORS_UPDATED:
{
rgb_color textColor;
if (msg->FindColor(ui_color_name(B_PANEL_TEXT_COLOR), &textColor)
== B_OK) {
BFont font;
fHowToTextView->SetFontAndColor(&font, 0, &textColor);
}
break;
}
case kMsgAccountsRightClicked:
{
BPoint point;
msg->FindPoint("point", &point);
int32 index = msg->FindInt32("index");
AccountItem* clickedItem = dynamic_cast<AccountItem*>(
fAccountsListView->ItemAt(index));
if (clickedItem == NULL || clickedItem->Type() != ACCOUNT_ITEM)
break;
BPopUpMenu rightClickMenu("accounts", false, false);
BMenuItem* inMenuItem = new BMenuItem(B_TRANSLATE("Incoming"),
NULL);
BMenuItem* outMenuItem = new BMenuItem(B_TRANSLATE("Outgoing"),
NULL);
rightClickMenu.AddItem(inMenuItem);
rightClickMenu.AddItem(outMenuItem);
BMailAccountSettings* settings = clickedItem->Account();
if (settings->IsInboundEnabled())
inMenuItem->SetMarked(true);
if (settings->IsOutboundEnabled())
outMenuItem->SetMarked(true);
BMenuItem* selectedItem = rightClickMenu.Go(point);
if (selectedItem == NULL)
break;
if (selectedItem == inMenuItem) {
AccountItem* item = dynamic_cast<AccountItem*>(
fAccountsListView->ItemAt(index + 1));
if (item == NULL)
break;
if (settings->IsInboundEnabled()) {
settings->SetInboundEnabled(false);
item->SetEnabled(false);
} else {
settings->SetInboundEnabled(true);
item->SetEnabled(true);
}
} else {
AccountItem* item = dynamic_cast<AccountItem*>(
fAccountsListView->ItemAt(index + 2));
if (item == NULL)
break;
if (settings->IsOutboundEnabled()) {
settings->SetOutboundEnabled(false);
item->SetEnabled(false);
} else {
settings->SetOutboundEnabled(true);
item->SetEnabled(true);
}
}
}
case kMsgAccountSelected:
{
int32 index;
if (msg->FindInt32("index", &index) != B_OK || index < 0) {
// deselect current item
_ReplaceConfigView(_BuildHowToView());
break;
}
AccountItem* item = (AccountItem*)fAccountsListView->ItemAt(index);
if (item != NULL)
_AccountSelected(item);
break;
}
case kMsgAddAccount:
{
frame = Frame();
autoConfigRect.OffsetTo(
frame.left + (frame.Width() - autoConfigRect.Width()) / 2,
frame.top + (frame.Width() - autoConfigRect.Height()) / 2);
autoConfigWindow = new AutoConfigWindow(autoConfigRect, this);
autoConfigWindow->Show();
break;
}
//.........这里部分代码省略.........
示例8: DrawMonth
void MonthWindowView::DrawMonth()
{
Bmp->Lock();
float y=yearStringView->Frame().bottom+h_cell;
float x=0;
if(NewMonth)
{
BmpView->SetHighColor(VIEW_COLOR);
BmpView->FillRect(BRect(0,y+1,
BmpView->Bounds().right,todayStringView->Frame().top-6));
BmpView->SetHighColor(0,0,0,0);
NewMonth=false;
}
int byear=cyear; // base year
if(tyear<byear) byear=tyear;
int day1=0, m=0, k=byear;
while(k<cyear)
{
day1++;
if(k%4==0) // leap year?
if((k%100!=0) || (k%400==0)) day1++; // yes
k++;
}
while(++m<cmonth)
{
day1+=(monthDays[m-1]-28);
if(m==2) if((cyear%4)==0) if((cyear%100!=0) || (cyear%400==0)) day1++;
}
day1++; // day1 is number of 1st day of chosen month in chosen year
day1=day1%7;
int day2=0;
m=0;
k=byear;
while(k<tyear)
{
day2++;
if((k%4)==0) if((k%100!=0) || (k%400==0)) day2++;
k++;
}
while(++m<tmonth)
{
day2+=(monthDays[m-1]-28);
if(m==2) if((tyear%4)==0) if((tyear%100!=0) || (tyear%400==0)) day2++;
}
day2+=tday; // day2 - number of today's day in today's year
day2=day2%7;
k=(twday==0) ? 6 : twday-1;
k=k-day2+day1;
while(k<0) k+=7;
k=k%7;
cwday1=k;
x=w_cell*k+1;
y+=h_cell;
int qu_days=monthDays[cmonth-1]; // quantity of days in month
if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
BString s;
int t=0;
while(t<qu_days)
{
t++;
s<<t;
if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(200,0,0,0);
BmpView->DrawString(s.String(),BPoint(x+(w_cell-StringWidth(s.String()))/2,y));
if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(0,0,0,0);
if(t==cday)
{
cwday=k;
if(which_focused==2) BmpView->SetHighColor(ACTIVE_COLOR);
else BmpView->SetHighColor(NOACTIVE_COLOR);
cursor.Set(x,y-h_cell+5,x+w_cell-1,y+4);
BmpView->StrokeRect(cursor);
BmpView->SetHighColor(0,0,0,0);
}
x+=w_cell;
k++;
s.SetTo("");
if(k==7)
{
k=0;
y+=h_cell;
x=1;
//.........这里部分代码省略.........
示例9: MaximizeEmptyArea
bool
InsertionIntoEmptyArea::FindOptimalAreaFor(const BPoint& point, BRect dragFrame,
BSize target, BSize minSize, area_ref& ref, area_ref& maximalArea,
Area* movedArea)
{
if (!fView->FindEmptyArea(point, maximalArea, movedArea))
return false;
BRect currentFrame;
if (movedArea != NULL)
currentFrame = movedArea->Frame();
MaximizeEmptyArea(maximalArea, dragFrame, currentFrame);
ref = maximalArea;
const float kSnapDistance = 10;
// first reduce the area again if we are close to tab
BRect emptyFrame = ref.Frame();
float interestingWidth = dragFrame.Width();
if (target.width >= 0 && emptyFrame.Width() > interestingWidth
&& dragFrame.right + kSnapDistance < emptyFrame.right
&& dragFrame.left - kSnapDistance > emptyFrame.left) {
XTab* betterLeft = fView->GetXTabNearPoint(dragFrame.LeftTop(),
kSnapDistance);
if (betterLeft != NULL && (movedArea == NULL
|| (betterLeft != movedArea->Left()
&& betterLeft != movedArea->Right()))) {
if (emptyFrame.right - betterLeft->Value() >= interestingWidth)
ref.left = betterLeft;
} else {
XTab* betterRight = fView->GetXTabNearPoint(dragFrame.RightTop(),
kSnapDistance);
if (betterRight != NULL && (movedArea == NULL
|| (betterRight != movedArea->Left()
&& betterRight != movedArea->Right()))) {
if (betterRight->Value() - emptyFrame.left >= interestingWidth)
ref.right = betterRight;
}
}
}
float interestingHeight = dragFrame.Height();
if (target.height >= 0 && emptyFrame.Height() > interestingHeight
&& dragFrame.bottom + kSnapDistance < emptyFrame.bottom
&& dragFrame.top - kSnapDistance > emptyFrame.top) {
YTab* betterTop = fView->GetYTabNearPoint(dragFrame.LeftTop(),
kSnapDistance);
if (betterTop != NULL && (movedArea == NULL
|| (betterTop != movedArea->Top()
&& betterTop != movedArea->Bottom()))) {
if (emptyFrame.bottom - betterTop->Value() >= interestingHeight)
ref.top = betterTop;
} else {
YTab* betterBottom = fView->GetYTabNearPoint(dragFrame.RightBottom(),
kSnapDistance);
if (betterBottom != NULL && (movedArea == NULL
|| (betterBottom != movedArea->Top()
&& betterBottom != movedArea->Bottom()))) {
if (betterBottom->Value() - emptyFrame.top >= interestingHeight)
ref.bottom = betterBottom;
}
}
}
bool xSnapped = true;
bool ySnapped = true;
const float kNewTabSnapDistance = 15;
// snap to area border
emptyFrame = ref.Frame();
InnerAreaTabs innerAreaTabs(fView->fOverlapManager.GetTabConnections());
if (target.width >= 0
&& emptyFrame.Width() - target.width > kNewTabSnapDistance) {
if (dragFrame.left - emptyFrame.left < kNewTabSnapDistance) {
ref.right = innerAreaTabs.FindHorizontalInnerTab(
emptyFrame.left + target.width, kNewTabSnapDistance,
maximalArea);
if (ref.right != NULL && ref.right->Value() <= ref.left->Value())
ref.right = NULL;
} else if (emptyFrame.right - dragFrame.right < kNewTabSnapDistance) {
ref.left = innerAreaTabs.FindHorizontalInnerTab(
emptyFrame.right - target.width, kNewTabSnapDistance,
maximalArea);
if (ref.left != NULL && ref.right->Value() <= ref.left->Value())
ref.left = NULL;
} else
xSnapped = false;
}
if (target.height >= 0
&& emptyFrame.Height() - target.height > kNewTabSnapDistance) {
if (dragFrame.top - emptyFrame.top < kNewTabSnapDistance) {
ref.bottom = innerAreaTabs.FindVerticalInnerTab(
emptyFrame.top + target.height, kNewTabSnapDistance,
maximalArea);
if (ref.bottom != NULL && ref.bottom->Value() <= ref.top->Value())
ref.bottom = NULL;
} else if (emptyFrame.bottom - dragFrame.bottom < kNewTabSnapDistance) {
ref.top = innerAreaTabs.FindVerticalInnerTab(
emptyFrame.bottom - target.height, kNewTabSnapDistance,
//.........这里部分代码省略.........
示例10: areaInfo
void
InsertionIntoEmptyArea::MaximizeEmptyArea(area_ref& ref, BRect target, BRect ignore)
{
BALMLayout* layout = fView->Layout();
BRegion takenSpace = fView->fTakenSpace;
takenSpace.Exclude(ignore);
area_info areaInfo(ref, layout);
// try to match the target
XTab* left = ref.left;
while (left->Value() > target.left) {
left = layout->XTabAt(areaInfo.left - 1, true);
if (left == NULL)
break;
area_ref newRef = ref;
newRef.left = left;
BRect frame = newRef.Frame();
frame.InsetBy(1, 1);
if (takenSpace.Intersects(frame))
break;
areaInfo.left -= 1;
ref.left = left;
}
XTab* right = ref.right;
while (right->Value() < target.right) {
right = layout->XTabAt(areaInfo.right + 1, true);
if (right == NULL)
break;
area_ref newRef = ref;
newRef.right = right;
BRect frame = newRef.Frame();
frame.InsetBy(1, 1);
if (takenSpace.Intersects(frame))
break;
areaInfo.right += 1;
ref.right = right;
}
YTab* top = ref.top;
while (top->Value() > target.top) {
top = layout->YTabAt(areaInfo.top - 1, true);
if (top == NULL)
break;
area_ref newRef = ref;
newRef.top = top;
BRect frame = newRef.Frame();
frame.InsetBy(1, 1);
if (takenSpace.Intersects(frame))
break;
areaInfo.top -= 1;
ref.top = top;
}
YTab* bottom = ref.bottom;
while (bottom->Value() < target.bottom) {
bottom = layout->YTabAt(areaInfo.bottom + 1, true);
if (bottom == NULL)
break;
area_ref newRef = ref;
newRef.bottom = bottom;
BRect frame = newRef.Frame();
frame.InsetBy(1, 1);
if (takenSpace.Intersects(frame))
break;
areaInfo.bottom += 1;
ref.bottom = bottom;
}
// maximize further
while (true) {
BRect previousFrame = ref.Frame();
left = layout->XTabAt(areaInfo.left - 1, true);
right = layout->XTabAt(areaInfo.right + 1, true);
top = layout->YTabAt(areaInfo.top - 1, true);
bottom = layout->YTabAt(areaInfo.bottom + 1, true);
float leftDelta = -1;
if (left != NULL) {
BRect newFrame(previousFrame);
newFrame.left = left->Value();
newFrame.InsetBy(1, 1);
if (!takenSpace.Intersects(newFrame)) {
leftDelta = previousFrame.Height()
* (previousFrame.left - left->Value());
}
}
float rightDelta = -1;
if (right != NULL) {
BRect newFrame(previousFrame);
newFrame.right = right->Value();
newFrame.InsetBy(1, 1);
if (!takenSpace.Intersects(newFrame)) {
rightDelta = previousFrame.Height()
* (right->Value() - previousFrame.right);
}
}
float topDelta = -1;
if (top != NULL) {
BRect newFrame(previousFrame);
newFrame.top = top->Value();
newFrame.InsetBy(1, 1);
//.........这里部分代码省略.........
示例11: BWindow
CharacterWindow::CharacterWindow()
:
BWindow(BRect(100, 100, 700, 550), B_TRANSLATE_SYSTEM_NAME("CharacterMap"),
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE
| B_AUTO_UPDATE_SIZE_LIMITS)
{
BMessage settings;
_LoadSettings(settings);
BRect frame;
if (settings.FindRect("window frame", &frame) == B_OK) {
MoveTo(frame.LeftTop());
ResizeTo(frame.Width(), frame.Height());
} else {
float scaling = be_plain_font->Size() / 12.0f;
ResizeTo(Frame().Width() * scaling, Frame().Height() * scaling);
CenterOnScreen();
}
// create GUI
BMenuBar* menuBar = new BMenuBar("menu");
fFilterControl = new BTextControl(B_TRANSLATE("Filter:"), NULL, NULL);
fFilterControl->SetModificationMessage(new BMessage(kMsgFilterChanged));
BButton* clearButton = new BButton("clear", B_TRANSLATE("Clear"),
new BMessage(kMsgClearFilter));
fUnicodeBlockView = new UnicodeBlockView("unicodeBlocks");
fUnicodeBlockView->SetSelectionMessage(
new BMessage(kMsgUnicodeBlockSelected));
BScrollView* unicodeScroller = new BScrollView("unicodeScroller",
fUnicodeBlockView, 0, false, true);
fCharacterView = new CharacterView("characters");
fCharacterView->SetTarget(this, kMsgCharacterChanged);
fGlyphView = new BStringView("glyph", "");
fGlyphView->SetExplicitMaxSize(BSize(B_SIZE_UNSET,
fGlyphView->PreferredSize().Height()));
// TODO: have a context object shared by CharacterView/UnicodeBlockView
bool show;
if (settings.FindBool("show private blocks", &show) == B_OK) {
fCharacterView->ShowPrivateBlocks(show);
fUnicodeBlockView->ShowPrivateBlocks(show);
}
if (settings.FindBool("show contained blocks only", &show) == B_OK) {
fCharacterView->ShowContainedBlocksOnly(show);
fUnicodeBlockView->ShowPrivateBlocks(show);
}
const char* family;
const char* style;
BString displayName;
if (settings.FindString("font family", &family) == B_OK
&& settings.FindString("font style", &style) == B_OK) {
_SetFont(family, style);
displayName << family << " " << style;
} else {
font_family currentFontFamily;
font_style currentFontStyle;
fCharacterView->CharacterFont().GetFamilyAndStyle(¤tFontFamily,
¤tFontStyle);
displayName << currentFontFamily << " " << currentFontStyle;
}
int32 fontSize;
if (settings.FindInt32("font size", &fontSize) == B_OK) {
BFont font = fCharacterView->CharacterFont();
if (fontSize < kMinFontSize)
fontSize = kMinFontSize;
else if (fontSize > kMaxFontSize)
fontSize = kMaxFontSize;
font.SetSize(fontSize);
fCharacterView->SetCharacterFont(font);
} else
fontSize = (int32)fCharacterView->CharacterFont().Size();
BScrollView* characterScroller = new BScrollView("characterScroller",
fCharacterView, 0, false, true);
fFontSizeSlider = new FontSizeSlider("fontSizeSlider",
displayName,
new BMessage(kMsgFontSizeChanged), kMinFontSize, kMaxFontSize);
fFontSizeSlider->SetValue(fontSize);
fCodeView = new BStringView("code", "-");
fCodeView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
fCodeView->PreferredSize().Height()));
// Set minimum width for character pane to prevent UI
// from jumping when longer code strings are displayed.
// use 'w' character for sizing as it's likely the widest
// character for a Latin font. 40 characters is a little
// wider than needed so hopefully this covers other
// non-Latin fonts that may be wider.
//.........这里部分代码省略.........
示例12: PushState
void
ColorSwatch::Draw (BRect)
{
PushState();
SetDrawingMode (B_OP_COPY);
rgb_color high (HighColor());
BRect colorPad (Bounds());
SetHighColor (ValueAsColor());
FillRect (colorPad);
rgb_color light (ShiftColor (ValueAsColor(), 0.4));
rgb_color dark (ShiftColor (ValueAsColor(), 1.2));
BeginLineArray (10);
AddLine (
colorPad.LeftTop(),
colorPad.RightTop() - BPoint (1, 0),
light);
AddLine (
colorPad.LeftTop(),
colorPad.LeftBottom() - BPoint (0, 1),
light);
AddLine (
colorPad.RightTop() + BPoint (0, 1),
colorPad.RightBottom(),
dark);
AddLine (
colorPad.RightBottom(),
colorPad.LeftBottom() + BPoint (1, 0),
dark);
light = ShiftColor (ViewColor(), 0.1);
dark = ShiftColor (ViewColor(), 1.4);
colorPad.InsetBy (-1, -1);
BPoint hless (-1, 0);
BPoint hmore (1, 0);
BPoint vless (0, -1);
BPoint vmore (0, 1);
if (IsFocus() && Window()->IsActive())
{
light = general_info.mark_color;
dark = general_info.mark_color;
hless = hmore = vless = vmore = BPoint (0, 0);
}
else
{
// A little blue residue clean up
AddLine (
colorPad.RightTop(),
colorPad.RightTop(),
ViewColor());
AddLine (
colorPad.LeftBottom(),
colorPad.LeftBottom(),
ViewColor());
}
AddLine (
colorPad.LeftTop(),
colorPad.RightTop() + hless,
dark);
AddLine (
colorPad.LeftTop(),
colorPad.LeftBottom() + vless,
dark);
AddLine (
colorPad.RightTop() + vmore,
colorPad.RightBottom(),
light);
AddLine (
colorPad.RightBottom(),
colorPad.LeftBottom() + hmore,
light);
EndLineArray();
PopState();
}
示例13: IsEnabled
void
BTextControl::Draw(BRect updateRect)
{
bool enabled = IsEnabled();
bool active = fText->IsFocus() && Window()->IsActive();
BRect rect = fText->Frame();
rect.InsetBy(-2, -2);
if (be_control_look != NULL) {
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
uint32 flags = 0;
if (!enabled)
flags |= BControlLook::B_DISABLED;
if (active)
flags |= BControlLook::B_FOCUSED;
be_control_look->DrawTextControlBorder(this, rect, updateRect, base,
flags);
rect = Bounds();
rect.right = fDivider - kLabelInputSpacing;
// rect.right = fText->Frame().left - 2;
// rect.right -= 3;//be_control_look->DefaultLabelSpacing();
be_control_look->DrawLabel(this, Label(), rect, updateRect,
base, flags, BAlignment(fLabelAlign, B_ALIGN_MIDDLE));
return;
}
// outer bevel
rgb_color noTint = ui_color(B_PANEL_BACKGROUND_COLOR);
rgb_color lighten1 = tint_color(noTint, B_LIGHTEN_1_TINT);
rgb_color lighten2 = tint_color(noTint, B_LIGHTEN_2_TINT);
rgb_color lightenMax = tint_color(noTint, B_LIGHTEN_MAX_TINT);
rgb_color darken1 = tint_color(noTint, B_DARKEN_1_TINT);
rgb_color darken2 = tint_color(noTint, B_DARKEN_2_TINT);
rgb_color darken4 = tint_color(noTint, B_DARKEN_4_TINT);
rgb_color navigationColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
if (enabled)
SetHighColor(darken1);
else
SetHighColor(noTint);
StrokeLine(rect.LeftBottom(), rect.LeftTop());
StrokeLine(rect.RightTop());
if (enabled)
SetHighColor(lighten2);
else
SetHighColor(lighten1);
StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom());
StrokeLine(BPoint(rect.right, rect.top + 1.0f), rect.RightBottom());
// inner bevel
rect.InsetBy(1.0f, 1.0f);
if (active) {
SetHighColor(navigationColor);
StrokeRect(rect);
} else {
if (enabled)
SetHighColor(darken4);
else
SetHighColor(darken2);
StrokeLine(rect.LeftTop(), rect.LeftBottom());
StrokeLine(rect.LeftTop(), rect.RightTop());
SetHighColor(noTint);
StrokeLine(BPoint(rect.left + 1.0f, rect.bottom), rect.RightBottom());
StrokeLine(BPoint(rect.right, rect.top + 1.0f));
}
// label
if (Label()) {
_ValidateLayoutData();
font_height& fontHeight = fLayoutData->font_info;
float y = Bounds().top + (Bounds().Height() + 1 - fontHeight.ascent
- fontHeight.descent) / 2 + fontHeight.ascent;
float x;
float labelWidth = StringWidth(Label());
switch (fLabelAlign) {
case B_ALIGN_RIGHT:
x = fDivider - labelWidth - kLabelInputSpacing;
break;
case B_ALIGN_CENTER:
x = fDivider - labelWidth / 2.0;
break;
default:
x = 0.0;
break;
//.........这里部分代码省略.........
示例14: make_window_visible
void
make_window_visible(BWindow* window, bool mayResize)
{
uint32 flags = window->Flags();
BRect screen = BScreen(window).Frame();
BRect frame = window->Frame();
screen.InsetBy(4, 8);
screen.OffsetBy(0, 8);
if (mayResize) {
float width = frame.Width();
float height = frame.Height();
if (screen.Width() < width && !(flags & B_NOT_H_RESIZABLE))
width = screen.Width();
if (screen.Height() < height && !(flags & B_NOT_V_RESIZABLE))
height = screen.Height();
if (width != frame.Width() || height != frame.Height()) {
window->ResizeTo(width, height);
frame.right = frame.left + width;
frame.bottom = frame.top + height;
}
}
if (frame.right > screen.right)
window->MoveBy(screen.right-frame.right, 0);
if (frame.bottom > screen.bottom)
window->MoveBy(0, screen.bottom-frame.bottom);
if (frame.left < screen.left)
window->MoveTo(screen.left, frame.top);
if (frame.top < screen.top)
window->MoveBy(0, screen.top-frame.top);
}
示例15: Bounds
void
ObjectView::AttachedToWindow()
{
float position[] = {0.0, 3.0, 3.0, 0.0};
float position1[] = {-3.0, -3.0, 3.0, 0.0};
float position2[] = {3.0, 0.0, 0.0, 0.0};
float local_view[] = {0.0, 0.0};
// float ambient[] = {0.1745, 0.03175, 0.03175};
// float diffuse[] = {0.61424, 0.10136, 0.10136};
// float specular[] = {0.727811, 0.626959, 0.626959};
// rgb_color black = {0, 0, 0, 255};
BRect bounds = Bounds();
BGLView::AttachedToWindow();
Window()->SetPulseRate(100000);
LockGL();
glEnable(GL_DITHER);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glDepthFunc(GL_LESS);
glShadeModel(GL_SMOOTH);
glLightfv(GL_LIGHT0, GL_POSITION, position);
glLightfv(GL_LIGHT0 + 1, GL_POSITION, position1);
glLightfv(GL_LIGHT0 + 2, GL_POSITION, position2);
glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, local_view);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_SPECULAR, lights[lightWhite].specular);
glLightfv(GL_LIGHT0, GL_DIFFUSE,lights[lightWhite].diffuse);
glLightfv(GL_LIGHT0, GL_AMBIENT,lights[lightWhite].ambient);
glEnable(GL_LIGHT1);
glLightfv(GL_LIGHT1, GL_SPECULAR, lights[lightBlue].specular);
glLightfv(GL_LIGHT1, GL_DIFFUSE,lights[lightBlue].diffuse);
glLightfv(GL_LIGHT1, GL_AMBIENT,lights[lightBlue].ambient);
glFrontFace(GL_CW);
glEnable(GL_LIGHTING);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glMaterialf(GL_FRONT, GL_SHININESS, 0.6 * 128.0);
glClearColor(bgColor[0], bgColor[1], bgColor[2], 1.0);
glColor3f(1.0, 1.0, 1.0);
glViewport(0, 0, (GLint)bounds.IntegerWidth() + 1,
(GLint)bounds.IntegerHeight() + 1);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
float scale = displayScale;
glOrtho(-scale, scale, -scale, scale, -scale * depthOfView,
scale * depthOfView);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
UnlockGL();
fDrawThread = spawn_thread(simonThread, "Simon", B_NORMAL_PRIORITY, this);
resume_thread(fDrawThread);
fForceRedraw = true;
setEvent(drawEvent);
}