/* * Make inside state picture. */ BPicture* HToolbarButton::MakeInsidePicture(BBitmap *in) { HToolbar *toolbar = cast_as(Parent(),HToolbar); BRect buttonRect = toolbar->ButtonRect(); BView *view = new BView(BRect(0,0,buttonRect.Width(),buttonRect.Height()) ,"offview",0,0); BBitmap *bitmap = new BBitmap(view->Bounds(), in->ColorSpace(), true); BPicture *pict; bitmap->AddChild(view); bitmap->Lock(); view->SetDrawingMode(B_OP_ALPHA); view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); view->BeginPicture(new BPicture); DrawBitmap(view,in); DrawString(view,fName.String()); //view->SetHighColor(White); //view->FillRect(BRect(0,0,0,22)); //view->FillRect(BRect(0,0,22,0)); //view->SetHighColor(BeShadow); //view->FillRect(BRect(21,0,21,21)); //view->FillRect(BRect(0,21,21,21)); BRect rect(Bounds()); view->SetDrawingMode(B_OP_OVER); rect.InsetBy(1,1); view->BeginLineArray(5); view->AddLine(rect.LeftTop(), rect.LeftBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT)); view->AddLine(rect.LeftTop(), rect.RightTop(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_MAX_TINT)); view->AddLine(rect.LeftBottom(), rect.RightBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT)); rect.bottom--; view->AddLine(rect.LeftBottom(), rect.RightBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); view->AddLine(rect.RightTop(), rect.RightBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT)); view->EndLineArray(); view->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT)); view->StrokeRect(Bounds()); pict = view->EndPicture(); bitmap->Unlock(); delete bitmap; return pict; }
void ActivityView::_DrawHistory(bool drawBackground) { _UpdateOffscreenBitmap(); BView* view = this; if (fOffscreen != NULL) { fOffscreen->Lock(); view = _OffscreenView(); } BRect frame = _HistoryFrame(); BRect outerFrame = frame.InsetByCopy(-2, -2); // draw the outer frame uint32 flags = 0; if (!drawBackground) flags |= BControlLook::B_BLEND_FRAME; be_control_look->DrawTextControlBorder(this, outerFrame, outerFrame, fLegendBackgroundColor, flags); // convert to offscreen view if necessary if (view != this) frame.OffsetTo(B_ORIGIN); view->SetLowColor(fHistoryBackgroundColor); view->FillRect(frame, B_SOLID_LOW); uint32 step = 2; uint32 resolution = fDrawResolution; if (fDrawResolution > 1) { step = 1; resolution--; } // We would get a negative number of steps which isn't a good idea. if (frame.IntegerWidth() <= 10) return; uint32 width = frame.IntegerWidth() - 10; uint32 steps = width / step; bigtime_t timeStep = RefreshInterval() * resolution; bigtime_t now = system_time(); // Draw scale // TODO: add second markers? view->SetPenSize(1); rgb_color scaleColor = view->LowColor(); uint32 average = (scaleColor.red + scaleColor.green + scaleColor.blue) / 3; if (average < 96) scaleColor = tint_color(scaleColor, B_LIGHTEN_2_TINT); else scaleColor = tint_color(scaleColor, B_DARKEN_2_TINT); view->SetHighColor(scaleColor); view->StrokeLine(BPoint(frame.left, frame.top + frame.Height() / 2), BPoint(frame.right, frame.top + frame.Height() / 2)); // Draw values view->SetPenSize(1.5); BAutolock _(fSourcesLock); for (uint32 i = fSources.CountItems(); i-- > 0;) { ViewHistory* viewValues = fViewValues.ItemAt(i); DataSource* source = fSources.ItemAt(i); DataHistory* values = fValues.ItemAt(i); viewValues->Update(values, steps, fDrawResolution, now, timeStep, RefreshInterval()); if (viewValues->Start() >= (int32)steps - 1) continue; uint32 x = viewValues->Start() * step; bool first = true; view->SetHighColor(source->Color()); view->SetLineMode(B_BUTT_CAP, B_ROUND_JOIN); view->MovePenTo(B_ORIGIN); try { view->BeginLineArray(steps - viewValues->Start() - 1); BPoint prev; for (uint32 j = viewValues->Start(); j < steps; x += step, j++) { float y = _PositionForValue(source, values, viewValues->ValueAt(j)); if (first) { first = false; } else view->AddLine(prev, BPoint(x, y), source->Color()); prev.Set(x, y); } } catch (std::bad_alloc) { // Not enough memory to allocate the line array. // TODO we could try to draw using the slower but less memory // consuming solution using StrokeLine. } view->EndLineArray(); } // TODO: add marks when an app started or quit view->Sync(); if (fOffscreen != NULL) { fOffscreen->Unlock(); DrawBitmap(fOffscreen, outerFrame.LeftTop()); } }
// _UpdateThread status_t ColorSlider::_UpdateThread(void* data) { // initializing ColorSlider* colorSlider = (ColorSlider*)data; bool looperLocked = colorSlider->LockLooper(); port_id port = colorSlider->fUpdatePort; orientation orient = colorSlider->fOrientation; if (looperLocked) colorSlider->UnlockLooper(); float h, s, v, r, g, b; int R, G, B; // drawing int32 msg_code; char msg_buffer; while (true) { port_info info; do { read_port(port, &msg_code, &msg_buffer, sizeof(msg_buffer)); get_port_info(port, &info); } while (info.queue_count); if (colorSlider->LockLooper()) { uint colormode = colorSlider->fMode; float fixedvalue1 = colorSlider->fFixedValue1; float fixedvalue2 = colorSlider->fFixedValue2; BBitmap* bitmap = colorSlider->fBgBitmap; BView* view = colorSlider->fBgView; bitmap->Lock(); colorSlider->UnlockLooper(); view->BeginLineArray(256); switch (colormode) { case R_SELECTED: { G = round(fixedvalue1 * 255); B = round(fixedvalue2 * 255); for (int R = 0; R < 256; ++R) { _DrawColorLineY( view, R, R, G, B ); } }; break; case G_SELECTED: { R = round(fixedvalue1 * 255); B = round(fixedvalue2 * 255); for (int G = 0; G < 256; ++G) { _DrawColorLineY( view, G, R, G, B ); } }; break; case B_SELECTED: { R = round(fixedvalue1 * 255); G = round(fixedvalue2 * 255); for (int B = 0; B < 256; ++B) { _DrawColorLineY( view, B, R, G, B ); } }; break; case H_SELECTED: { s = 1.0;//fixedvalue1; v = 1.0;//fixedvalue2; if (orient == B_VERTICAL) { for (int y = 0; y < 256; ++y) { HSV_to_RGB( (float)y*6.0/255.0, s, v, r, g, b ); _DrawColorLineY( view, y, r*255, g*255, b*255 ); } } else { for (int x = 0; x < 256; ++x) { HSV_to_RGB( (float)x*6.0/255.0, s, v, r, g, b ); _DrawColorLineX( view, x, r*255, g*255, b*255 ); } } }; break; case S_SELECTED: { h = fixedvalue1; v = 1.0;//fixedvalue2; for (int y = 0; y < 256; ++y) { HSV_to_RGB( h, (float)y/255, v, r, g, b ); _DrawColorLineY( view, y, r*255, g*255, b*255 ); } }; break; case V_SELECTED: { h = fixedvalue1; s = 1.0;//fixedvalue2; for (int y = 0; y < 256; ++y) { HSV_to_RGB( h, s, (float)y/255, r, g, b ); _DrawColorLineY( view, y, r*255, g*255, b*255 ); } }; break; } view->EndLineArray(); view->Sync(); bitmap->Unlock(); if (colorSlider->LockLooper()) { colorSlider->Update(1); colorSlider->UnlockLooper(); } } } return B_OK; }
void BTitleView::Draw(BRect /*updateRect*/, bool useOffscreen, bool updateOnly, const BColumnTitle *pressedColumn, void (*trackRectBlitter)(BView *, BRect), BRect passThru) { BRect bounds(Bounds()); BView *view; if (useOffscreen) { ASSERT(sOffscreen); BRect frame(bounds); frame.right += frame.left; // this is kind of messy way of avoiding being clipped by the ammount the // title is scrolled to the left // ToDo: fix this view = sOffscreen->BeginUsing(frame); view->SetOrigin(-bounds.left, 0); view->SetLowColor(LowColor()); view->SetHighColor(HighColor()); BFont font(be_plain_font); font.SetSize(9); view->SetFont(&font); } else view = this; if (be_control_look != NULL) { rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); view->SetHighColor(tint_color(base, B_DARKEN_2_TINT)); view->StrokeLine(bounds.LeftBottom(), bounds.RightBottom()); bounds.bottom--; be_control_look->DrawButtonBackground(view, bounds, bounds, base, 0, BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER); } else { // fill background with light gray background if (!updateOnly) view->FillRect(bounds, B_SOLID_LOW); view->BeginLineArray(4); view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShadowColor); view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), sShadowColor); // draw lighter gray and white inset lines bounds.InsetBy(0, 1); view->AddLine(bounds.LeftBottom(), bounds.RightBottom(), sLightShadowColor); view->AddLine(bounds.LeftTop(), bounds.RightTop(), sShineColor); view->EndLineArray(); } int32 count = fTitleList.CountItems(); float minx = bounds.right; float maxx = bounds.left; for (int32 index = 0; index < count; index++) { BColumnTitle *title = fTitleList.ItemAt(index); title->Draw(view, title == pressedColumn); BRect titleBounds(title->Bounds()); if (titleBounds.left < minx) minx = titleBounds.left; if (titleBounds.right > maxx) maxx = titleBounds.right; } if (be_control_look != NULL) { bounds = Bounds(); minx--; view->SetHighColor(sLightShadowColor); view->StrokeLine(BPoint(minx, bounds.top), BPoint(minx, bounds.bottom - 1)); } else { // first and last shades before and after first column maxx++; minx--; view->BeginLineArray(2); view->AddLine(BPoint(minx, bounds.top), BPoint(minx, bounds.bottom), sShadowColor); view->AddLine(BPoint(maxx, bounds.top), BPoint(maxx, bounds.bottom), sShineColor); view->EndLineArray(); } #if !(APP_SERVER_CLEARS_BACKGROUND) FillRect(BRect(bounds.left, bounds.top + 1, minx - 1, bounds.bottom - 1), B_SOLID_LOW); FillRect(BRect(maxx + 1, bounds.top + 1, bounds.right, bounds.bottom - 1), B_SOLID_LOW); #endif if (useOffscreen) { if (trackRectBlitter) (trackRectBlitter)(view, passThru); view->Sync(); DrawBitmap(sOffscreen->Bitmap()); sOffscreen->DoneUsing(); } else if (trackRectBlitter) (trackRectBlitter)(view, passThru); }
int32 ColorField::_UpdateThread(void *data) { // initialization ColorField *colorField = (ColorField *)data; BLooper *looper = colorField->Looper(); if (looper) looper->Lock(); BBitmap* bitmap = colorField->fBgBitmap[0]; BView* view = colorField->fBgView[0]; port_id port = colorField->fUpdatePort; if (looper) looper->Unlock(); // draw float h, s, v, r, g, b; int R, G, B; int32 msg_code; char msg_buffer; while (true) { port_info info; do { read_port(port, &msg_code, &msg_buffer, sizeof(msg_buffer)); get_port_info(port, &info); } while (info.queue_count); if (looper) looper->Lock(); uint colormode = colorField->fColorMode; float fixedvalue = colorField->fFixedValue; if (looper) looper->Unlock(); bitmap->Lock(); view->BeginLineArray(256 * 256); switch (colormode) { case R_SELECTED: { R = round(fixedvalue * 255); for (int G = 0; G < 256; ++G) for (int B = 0; B < 256; ++B) DrawColorPoint(BPoint(G, 255.0 - B), R, G, B); break; } case G_SELECTED: { G = round(fixedvalue * 255); for (int R = 0; R < 256; ++R) for (int B = 0; B < 256; ++B) DrawColorPoint(BPoint(R, 255.0 - B), R, G, B); break; } case B_SELECTED: { B = round(fixedvalue * 255); for (int R = 0; R < 256; ++R) for (int G = 0; G < 256; ++G) DrawColorPoint(BPoint(R, 255.0 - G), R, G, B); break; } case H_SELECTED: { h = fixedvalue; for (int x = 0; x < 256; ++x) { s = (float)x / 255.0; for (int y = 0; y < 256; ++y) { v = (float)y / 255.0; HSV_to_RGB(h, s, v, r, g, b); DrawColorPoint(BPoint(x, 255.0 - y), round(r * 255.0), round(g * 255.0), round(b * 255.0)); } } break; } case S_SELECTED: { s = fixedvalue; for (int x = 0; x < 256; ++x) { h = 6.0 / 255 * x; for (int y = 0; y<256; ++y) { v = (float)y / 255.0; HSV_to_RGB(h, s, v, r, g, b); DrawColorPoint(BPoint(x, 255.0 - y), round(r * 255.0), round(g * 255.0), round(b * 255.0)); } } break; } case V_SELECTED: { v = fixedvalue; for (int x = 0; x < 256; ++x) { h = 6.0 / 255 * x; for (int y = 0; y < 256; ++y) { s = (float)y / 255.0; HSV_to_RGB(h, s, v, r, g, b); DrawColorPoint(BPoint(x, 255.0 - y), round(r * 255.0), round(g * 255.0), round(b * 255.0)); } } break; } } view->EndLineArray(); view->Sync(); bitmap->Unlock(); looper = colorField->Looper(); if (looper && looper->Lock()) { colorField->Update(2); looper->Unlock(); } } return 0; }
void RemoteView::_DrawThread() { RemoteMessage reply(NULL, fSendBuffer); RemoteMessage message(fReceiveBuffer, NULL); // cursor BPoint cursorHotSpot(0, 0); while (!fStopThread) { uint16 code; status_t status = message.NextMessage(code); if (status != B_OK) { TRACE_ERROR("failed to read message from receiver\n"); break; } TRACE("code %u with %ld bytes data\n", code, message.DataLeft()); BAutolock locker(this->Looper()); if (!locker.IsLocked()) break; // handle stuff that doesn't go to a specicifc engine switch (code) { case RP_INIT_CONNECTION: { uint16 port; status_t result = message.Read(port); if (result != B_OK) { TRACE_ERROR("failed to read remote port\n"); continue; } BNetEndpoint *endpoint = fReceiver->Endpoint(); if (endpoint == NULL) { TRACE_ERROR("receiver not connected anymore\n"); continue; } in_addr remoteHost; char hostName[MAXHOSTNAMELEN + 1]; BNetAddress address(endpoint->RemoteAddr()); address.GetAddr(remoteHost); address.GetAddr(hostName, NULL); address.SetTo(remoteHost, port); TRACE("connecting to host \"%s\" port %u\n", hostName, port); result = fSendEndpoint->Connect(address); if (result != B_OK) { TRACE_ERROR("failed to connect to host \"%s\" port %u\n", hostName, port); continue; } BRect bounds = fOffscreenBitmap->Bounds(); reply.Start(RP_UPDATE_DISPLAY_MODE); reply.Add(bounds.IntegerWidth() + 1); reply.Add(bounds.IntegerHeight() + 1); if (reply.Flush() == B_OK) fIsConnected = true; continue; } case RP_CLOSE_CONNECTION: { be_app->PostMessage(B_QUIT_REQUESTED); continue; } case RP_CREATE_STATE: case RP_DELETE_STATE: { uint32 token; message.Read(token); if (code == RP_CREATE_STATE) _CreateState(token); else _DeleteState(token); continue; } case RP_SET_CURSOR: { BBitmap *bitmap; BPoint oldHotSpot = cursorHotSpot; message.Read(cursorHotSpot); if (message.ReadBitmap(&bitmap) != B_OK) continue; delete fCursorBitmap; fCursorBitmap = bitmap; Invalidate(fCursorFrame); BRect bounds = fCursorBitmap->Bounds(); fCursorFrame.right = fCursorFrame.left + bounds.IntegerWidth() + 1; fCursorFrame.bottom = fCursorFrame.bottom + bounds.IntegerHeight() + 1; fCursorFrame.OffsetBy(oldHotSpot - cursorHotSpot); Invalidate(fCursorFrame); continue; } case RP_SET_CURSOR_VISIBLE: { bool wasVisible = fCursorVisible; message.Read(fCursorVisible); if (wasVisible != fCursorVisible) Invalidate(fCursorFrame); continue; } case RP_MOVE_CURSOR_TO: { BPoint position; message.Read(position); if (fCursorVisible) Invalidate(fCursorFrame); fCursorFrame.OffsetTo(position - cursorHotSpot); Invalidate(fCursorFrame); continue; } case RP_INVALIDATE_RECT: { BRect rect; if (message.Read(rect) != B_OK) continue; Invalidate(rect); continue; } case RP_INVALIDATE_REGION: { BRegion region; if (message.ReadRegion(region) != B_OK) continue; Invalidate(®ion); continue; } case RP_FILL_REGION_COLOR_NO_CLIPPING: { BRegion region; rgb_color color; message.ReadRegion(region); if (message.Read(color) != B_OK) continue; fOffscreen->LockLooper(); fOffscreen->SetHighColor(color); fOffscreen->FillRegion(®ion); fOffscreen->UnlockLooper(); Invalidate(®ion); continue; } case RP_COPY_RECT_NO_CLIPPING: { int32 xOffset, yOffset; BRect rect; message.Read(xOffset); message.Read(yOffset); if (message.Read(rect) != B_OK) continue; BRect dest = rect.OffsetByCopy(xOffset, yOffset); fOffscreen->LockLooper(); fOffscreen->CopyBits(rect, dest); fOffscreen->UnlockLooper(); continue; } } uint32 token; message.Read(token); engine_state *state = _FindState(token); if (state == NULL) { TRACE_ERROR("didn't find state for token %lu\n", token); continue; } BView *offscreen = state->view; ::pattern &pattern = state->pattern; BRegion &clippingRegion = state->clipping_region; float &penSize = state->pen_size; bool &syncDrawing = state->sync_drawing; BRegion invalidRegion; BAutolock offscreenLocker(offscreen->Looper()); if (!offscreenLocker.IsLocked()) break; switch (code) { case RP_ENABLE_SYNC_DRAWING: syncDrawing = true; continue; case RP_DISABLE_SYNC_DRAWING: syncDrawing = false; continue; case RP_SET_OFFSETS: { int32 xOffset, yOffset; message.Read(xOffset); if (message.Read(yOffset) != B_OK) continue; offscreen->MovePenTo(xOffset, yOffset); break; } case RP_SET_HIGH_COLOR: case RP_SET_LOW_COLOR: { rgb_color color; if (message.Read(color) != B_OK) continue; if (code == RP_SET_HIGH_COLOR) offscreen->SetHighColor(color); else offscreen->SetLowColor(color); break; } case RP_SET_PEN_SIZE: { float newPenSize; if (message.Read(newPenSize) != B_OK) continue; offscreen->SetPenSize(newPenSize); penSize = newPenSize / 2; break; } case RP_SET_STROKE_MODE: { cap_mode capMode; join_mode joinMode; float miterLimit; message.Read(capMode); message.Read(joinMode); if (message.Read(miterLimit) != B_OK) continue; offscreen->SetLineMode(capMode, joinMode, miterLimit); break; } case RP_SET_BLENDING_MODE: { source_alpha sourceAlpha; alpha_function alphaFunction; message.Read(sourceAlpha); if (message.Read(alphaFunction) != B_OK) continue; offscreen->SetBlendingMode(sourceAlpha, alphaFunction); break; } case RP_SET_PATTERN: { if (message.Read(pattern) != B_OK) continue; break; } case RP_SET_DRAWING_MODE: { drawing_mode drawingMode; if (message.Read(drawingMode) != B_OK) continue; offscreen->SetDrawingMode(drawingMode); break; } case RP_SET_FONT: { BFont font; if (message.ReadFontState(font) != B_OK) continue; offscreen->SetFont(&font); break; } case RP_CONSTRAIN_CLIPPING_REGION: { if (message.ReadRegion(clippingRegion) != B_OK) continue; offscreen->ConstrainClippingRegion(&clippingRegion); break; } case RP_INVERT_RECT: { BRect rect; if (message.Read(rect) != B_OK) continue; offscreen->InvertRect(rect); invalidRegion.Include(rect); break; } case RP_DRAW_BITMAP: { BBitmap *bitmap; BRect bitmapRect, viewRect; uint32 options; message.Read(bitmapRect); message.Read(viewRect); message.Read(options); if (message.ReadBitmap(&bitmap) != B_OK || bitmap == NULL) continue; offscreen->DrawBitmap(bitmap, bitmapRect, viewRect, options); invalidRegion.Include(viewRect); delete bitmap; break; } case RP_DRAW_BITMAP_RECTS: { color_space colorSpace; int32 rectCount; uint32 flags, options; message.Read(options); message.Read(colorSpace); message.Read(flags); message.Read(rectCount); for (int32 i = 0; i < rectCount; i++) { BBitmap *bitmap; BRect viewRect; message.Read(viewRect); if (message.ReadBitmap(&bitmap, true, colorSpace, flags) != B_OK || bitmap == NULL) { continue; } offscreen->DrawBitmap(bitmap, bitmap->Bounds(), viewRect, options); invalidRegion.Include(viewRect); delete bitmap; } break; } case RP_STROKE_ARC: case RP_FILL_ARC: case RP_FILL_ARC_GRADIENT: { BRect rect; float angle, span; message.Read(rect); message.Read(angle); if (message.Read(span) != B_OK) continue; if (code == RP_STROKE_ARC) { offscreen->StrokeArc(rect, angle, span, pattern); rect.InsetBy(-penSize, -penSize); } else if (code == RP_FILL_ARC) offscreen->FillArc(rect, angle, span, pattern); else { BGradient *gradient; if (message.ReadGradient(&gradient) != B_OK) continue; offscreen->FillArc(rect, angle, span, *gradient); delete gradient; } invalidRegion.Include(rect); break; } case RP_STROKE_BEZIER: case RP_FILL_BEZIER: case RP_FILL_BEZIER_GRADIENT: { BPoint points[4]; if (message.ReadList(points, 4) != B_OK) continue; BRect bounds = _BuildInvalidateRect(points, 4); if (code == RP_STROKE_BEZIER) { offscreen->StrokeBezier(points, pattern); bounds.InsetBy(-penSize, -penSize); } else if (code == RP_FILL_BEZIER) offscreen->FillBezier(points, pattern); else { BGradient *gradient; if (message.ReadGradient(&gradient) != B_OK) continue; offscreen->FillBezier(points, *gradient); delete gradient; } invalidRegion.Include(bounds); break; } case RP_STROKE_ELLIPSE: case RP_FILL_ELLIPSE: case RP_FILL_ELLIPSE_GRADIENT: { BRect rect; if (message.Read(rect) != B_OK) continue; if (code == RP_STROKE_ELLIPSE) { offscreen->StrokeEllipse(rect, pattern); rect.InsetBy(-penSize, -penSize); } else if (code == RP_FILL_ELLIPSE) offscreen->FillEllipse(rect, pattern); else { BGradient *gradient; if (message.ReadGradient(&gradient) != B_OK) continue; offscreen->FillEllipse(rect, *gradient); delete gradient; } invalidRegion.Include(rect); break; } case RP_STROKE_POLYGON: case RP_FILL_POLYGON: case RP_FILL_POLYGON_GRADIENT: { BRect bounds; bool closed; int32 numPoints; message.Read(bounds); message.Read(closed); if (message.Read(numPoints) != B_OK) continue; BPoint points[numPoints]; for (int32 i = 0; i < numPoints; i++) message.Read(points[i]); if (code == RP_STROKE_POLYGON) { offscreen->StrokePolygon(points, numPoints, bounds, closed, pattern); bounds.InsetBy(-penSize, -penSize); } else if (code == RP_FILL_POLYGON) offscreen->FillPolygon(points, numPoints, bounds, pattern); else { BGradient *gradient; if (message.ReadGradient(&gradient) != B_OK) continue; offscreen->FillPolygon(points, numPoints, bounds, *gradient); delete gradient; } invalidRegion.Include(bounds); break; } case RP_STROKE_RECT: case RP_FILL_RECT: case RP_FILL_RECT_GRADIENT: { BRect rect; if (message.Read(rect) != B_OK) continue; if (code == RP_STROKE_RECT) { offscreen->StrokeRect(rect, pattern); rect.InsetBy(-penSize, -penSize); } else if (code == RP_FILL_RECT) offscreen->FillRect(rect, pattern); else { BGradient *gradient; if (message.ReadGradient(&gradient) != B_OK) continue; offscreen->FillRect(rect, *gradient); delete gradient; } invalidRegion.Include(rect); break; } case RP_STROKE_ROUND_RECT: case RP_FILL_ROUND_RECT: case RP_FILL_ROUND_RECT_GRADIENT: { BRect rect; float xRadius, yRadius; message.Read(rect); message.Read(xRadius); if (message.Read(yRadius) != B_OK) continue; if (code == RP_STROKE_ROUND_RECT) { offscreen->StrokeRoundRect(rect, xRadius, yRadius, pattern); rect.InsetBy(-penSize, -penSize); } else if (code == RP_FILL_ROUND_RECT) offscreen->FillRoundRect(rect, xRadius, yRadius, pattern); else { BGradient *gradient; if (message.ReadGradient(&gradient) != B_OK) continue; offscreen->FillRoundRect(rect, xRadius, yRadius, *gradient); delete gradient; } invalidRegion.Include(rect); break; } case RP_STROKE_SHAPE: case RP_FILL_SHAPE: case RP_FILL_SHAPE_GRADIENT: { BRect bounds; int32 opCount, pointCount; message.Read(bounds); if (message.Read(opCount) != B_OK) continue; BMessage archive; for (int32 i = 0; i < opCount; i++) { int32 op; message.Read(op); archive.AddInt32("ops", op); } if (message.Read(pointCount) != B_OK) continue; for (int32 i = 0; i < pointCount; i++) { BPoint point; message.Read(point); archive.AddPoint("pts", point); } BPoint offset; message.Read(offset); float scale; if (message.Read(scale) != B_OK) continue; offscreen->PushState(); offscreen->MovePenTo(offset); offscreen->SetScale(scale); BShape shape(&archive); if (code == RP_STROKE_SHAPE) { offscreen->StrokeShape(&shape, pattern); bounds.InsetBy(-penSize, -penSize); } else if (code == RP_FILL_SHAPE) offscreen->FillShape(&shape, pattern); else { BGradient *gradient; if (message.ReadGradient(&gradient) != B_OK) { offscreen->PopState(); continue; } offscreen->FillShape(&shape, *gradient); delete gradient; } offscreen->PopState(); invalidRegion.Include(bounds); break; } case RP_STROKE_TRIANGLE: case RP_FILL_TRIANGLE: case RP_FILL_TRIANGLE_GRADIENT: { BRect bounds; BPoint points[3]; message.ReadList(points, 3); if (message.Read(bounds) != B_OK) continue; if (code == RP_STROKE_TRIANGLE) { offscreen->StrokeTriangle(points[0], points[1], points[2], bounds, pattern); bounds.InsetBy(-penSize, -penSize); } else if (code == RP_FILL_TRIANGLE) { offscreen->FillTriangle(points[0], points[1], points[2], bounds, pattern); } else { BGradient *gradient; if (message.ReadGradient(&gradient) != B_OK) continue; offscreen->FillTriangle(points[0], points[1], points[2], bounds, *gradient); delete gradient; } invalidRegion.Include(bounds); break; } case RP_STROKE_LINE: { BPoint points[2]; if (message.ReadList(points, 2) != B_OK) continue; offscreen->StrokeLine(points[0], points[1], pattern); BRect bounds = _BuildInvalidateRect(points, 2); invalidRegion.Include(bounds.InsetBySelf(-penSize, -penSize)); break; } case RP_STROKE_LINE_ARRAY: { int32 numLines; if (message.Read(numLines) != B_OK) continue; BRect bounds; offscreen->BeginLineArray(numLines); for (int32 i = 0; i < numLines; i++) { rgb_color color; BPoint start, end; message.ReadArrayLine(start, end, color); offscreen->AddLine(start, end, color); bounds.left = min_c(bounds.left, min_c(start.x, end.x)); bounds.top = min_c(bounds.top, min_c(start.y, end.y)); bounds.right = max_c(bounds.right, max_c(start.x, end.x)); bounds.bottom = max_c(bounds.bottom, max_c(start.y, end.y)); } offscreen->EndLineArray(); invalidRegion.Include(bounds); break; } case RP_FILL_REGION: case RP_FILL_REGION_GRADIENT: { BRegion region; if (message.ReadRegion(region) != B_OK) continue; if (code == RP_FILL_REGION) offscreen->FillRegion(®ion, pattern); else { BGradient *gradient; if (message.ReadGradient(&gradient) != B_OK) continue; offscreen->FillRegion(®ion, *gradient); delete gradient; } invalidRegion.Include(®ion); break; } case RP_STROKE_POINT_COLOR: { BPoint point; rgb_color color; message.Read(point); if (message.Read(color) != B_OK) continue; rgb_color oldColor = offscreen->HighColor(); offscreen->SetHighColor(color); offscreen->StrokeLine(point, point); offscreen->SetHighColor(oldColor); invalidRegion.Include( BRect(point, point).InsetBySelf(-penSize, -penSize)); break; } case RP_STROKE_LINE_1PX_COLOR: { BPoint points[2]; rgb_color color; message.ReadList(points, 2); if (message.Read(color) != B_OK) continue; float oldSize = offscreen->PenSize(); rgb_color oldColor = offscreen->HighColor(); drawing_mode oldMode = offscreen->DrawingMode(); offscreen->SetPenSize(1); offscreen->SetHighColor(color); offscreen->SetDrawingMode(B_OP_OVER); offscreen->StrokeLine(points[0], points[1]); offscreen->SetDrawingMode(oldMode); offscreen->SetHighColor(oldColor); offscreen->SetPenSize(oldSize); invalidRegion.Include(_BuildInvalidateRect(points, 2)); break; } case RP_STROKE_RECT_1PX_COLOR: case RP_FILL_RECT_COLOR: { BRect rect; rgb_color color; message.Read(rect); if (message.Read(color) != B_OK) continue; rgb_color oldColor = offscreen->HighColor(); offscreen->SetHighColor(color); if (code == RP_STROKE_RECT_1PX_COLOR) { float oldSize = PenSize(); offscreen->SetPenSize(1); offscreen->StrokeRect(rect); offscreen->SetPenSize(oldSize); } else offscreen->FillRect(rect); offscreen->SetHighColor(oldColor); invalidRegion.Include(rect); break; } case RP_DRAW_STRING: { BPoint point; size_t length; char *string; bool hasDelta; message.Read(point); message.ReadString(&string, length); if (message.Read(hasDelta) != B_OK) { free(string); continue; } if (hasDelta) { escapement_delta delta[length]; message.ReadList(delta, length); offscreen->DrawString(string, point, delta); } else offscreen->DrawString(string, point); free(string); reply.Start(RP_DRAW_STRING_RESULT); reply.Add(token); reply.Add(offscreen->PenLocation()); reply.Flush(); font_height height; offscreen->GetFontHeight(&height); BRect bounds(point, offscreen->PenLocation()); bounds.top -= height.ascent; bounds.bottom += height.descent; invalidRegion.Include(bounds); break; } case RP_DRAW_STRING_WITH_OFFSETS: { size_t length; char *string; message.ReadString(&string, length); int32 count = UTF8CountChars(string, length); BPoint offsets[count]; if (message.ReadList(offsets, count) != B_OK) { free(string); continue; } offscreen->DrawString(string, offsets, count); free(string); reply.Start(RP_DRAW_STRING_RESULT); reply.Add(token); reply.Add(offscreen->PenLocation()); reply.Flush(); BFont font; offscreen->GetFont(&font); BRect boxes[count]; font.GetBoundingBoxesAsGlyphs(string, count, B_SCREEN_METRIC, boxes); font_height height; offscreen->GetFontHeight(&height); for (int32 i = 0; i < count; i++) { // TODO: validate boxes[i].OffsetBy(offsets[i] + BPoint(0, -height.ascent)); invalidRegion.Include(boxes[i]); } break; } case RP_READ_BITMAP: { BRect bounds; bool drawCursor; message.Read(bounds); if (message.Read(drawCursor) != B_OK) continue; // TODO: support the drawCursor flag BBitmap bitmap(bounds, B_BITMAP_NO_SERVER_LINK, B_RGB32); bitmap.ImportBits(fOffscreenBitmap, bounds.LeftTop(), BPoint(0, 0), bounds.IntegerWidth() + 1, bounds.IntegerHeight() + 1); reply.Start(RP_READ_BITMAP_RESULT); reply.Add(token); reply.AddBitmap(&bitmap); reply.Flush(); break; } default: TRACE_ERROR("unknown protocol code: %u\n", code); break; } if (syncDrawing) { offscreen->Sync(); Invalidate(&invalidRegion); } } }
void BSlider::DrawHashMarks() { if (fHashMarks == B_HASH_MARKS_NONE) return; BRect frame = HashMarksFrame(); BView* view = OffscreenView(); if (be_control_look) { rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); uint32 flags = be_control_look->Flags(this); be_control_look->DrawSliderHashMarks(view, frame, frame, base, fHashMarkCount, fHashMarks, flags, fOrientation); return; } rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR); rgb_color lightenmax; rgb_color darken2; if (IsEnabled()) { lightenmax = tint_color(no_tint, B_LIGHTEN_MAX_TINT); darken2 = tint_color(no_tint, B_DARKEN_2_TINT); } else { lightenmax = tint_color(no_tint, B_LIGHTEN_2_TINT); darken2 = tint_color(no_tint, B_DARKEN_1_TINT); } float pos = _MinPosition(); int32 hashMarkCount = max_c(fHashMarkCount, 2); // draw at least two hashmarks at min/max if // fHashMarks != B_HASH_MARKS_NONE float factor = (_MaxPosition() - pos) / (hashMarkCount - 1); if (fHashMarks & B_HASH_MARKS_TOP) { view->BeginLineArray(hashMarkCount * 2); if (fOrientation == B_HORIZONTAL) { for (int32 i = 0; i < hashMarkCount; i++) { view->AddLine(BPoint(pos, frame.top), BPoint(pos, frame.top + 5), darken2); view->AddLine(BPoint(pos + 1, frame.top), BPoint(pos + 1, frame.top + 5), lightenmax); pos += factor; } } else { for (int32 i = 0; i < hashMarkCount; i++) { view->AddLine(BPoint(frame.left, pos), BPoint(frame.left + 5, pos), darken2); view->AddLine(BPoint(frame.left, pos + 1), BPoint(frame.left + 5, pos + 1), lightenmax); pos += factor; } } view->EndLineArray(); } pos = _MinPosition(); if (fHashMarks & B_HASH_MARKS_BOTTOM) { view->BeginLineArray(hashMarkCount * 2); if (fOrientation == B_HORIZONTAL) { for (int32 i = 0; i < hashMarkCount; i++) { view->AddLine(BPoint(pos, frame.bottom - 5), BPoint(pos, frame.bottom), darken2); view->AddLine(BPoint(pos + 1, frame.bottom - 5), BPoint(pos + 1, frame.bottom), lightenmax); pos += factor; } } else { for (int32 i = 0; i < hashMarkCount; i++) { view->AddLine(BPoint(frame.right - 5, pos), BPoint(frame.right, pos), darken2); view->AddLine(BPoint(frame.right - 5, pos + 1), BPoint(frame.right, pos + 1), lightenmax); pos += factor; } } view->EndLineArray(); } }
/*------------------------------------------------------------------------------*\ ( ) - \*------------------------------------------------------------------------------*/ BPicture* BmToolbarButton::CreatePicture( int32 mode, float width, float height) { const char* label = mLabel.String(); BmBitmapHandle* imageHandle = TheResources->IconByName(BmString("Button_")<<mResourceName); BBitmap* image = imageHandle ? imageHandle->bitmap : NULL; // Calc icon/label positions BFont font( be_plain_font); bool showIcons = ThePrefs->GetBool( "ShowToolbarIcons", true); BmString labelMode = ThePrefs->GetString( "ShowToolbarLabel", "Bottom"); float labelWidth = (label && labelMode != "Hide") ? font.StringWidth( label) : 0; float labelHeight = (label && labelMode != "Hide") ? TheResources->FontLineHeight( &font) : 0; float iconWidth = (showIcons && image) ? image->Bounds().Width() : 0; float iconHeight = (showIcons && image) ? image->Bounds().Height() : 0; BPoint posIcon( 0,0), posLabel( 0,0); if (showIcons && (labelMode == "Left")) { // Icon + Label/Left float d = (width-(mNeedsLatch ? DIVLATCHW : 0)-DIVW-labelWidth-iconWidth)/2; posLabel = BPoint( d,(height-labelHeight)/2); posIcon = BPoint( d+DIVW+labelWidth+(mNeedsLatch ? DIVLATCHW : 0), (height-iconHeight)/2-1); } else if (showIcons && (labelMode == "Right")) { // Icon + Label/Right float d = (width-(mNeedsLatch ? DIVLATCHW : 0)-DIVW-labelWidth-iconWidth)/2; posLabel = BPoint( d+DIVW+iconWidth,(height-labelHeight)/2); posIcon = BPoint( d,(height-iconHeight)/2-1); } else if (showIcons && (labelMode == "Top")) { // Icon + Label/top float d = (height-DIVH-labelHeight-iconHeight)/2-2; posLabel = BPoint( (width-labelWidth-(mNeedsLatch ? DIVLATCHW : 0))/2, d); posIcon = BPoint( (width-iconWidth)/2-1,d+DIVH+labelHeight); } else if (showIcons && (labelMode == "Bottom")) { // Icon + Label/bottom float d = (height-DIVH-labelHeight-iconHeight)/2; posLabel = BPoint( (width-labelWidth-(mNeedsLatch ? DIVLATCHW : 0))/2, d+DIVH+iconHeight); posIcon = BPoint( (width-iconWidth)/2-1,d); } else if (!showIcons && labelMode != "Hide") { // Label only posLabel = BPoint( (width-labelWidth-(mNeedsLatch ? DIVLATCHW : 0))/2, (height-labelHeight)/2); } else if (showIcons && labelMode == "Hide") { // Icon only posIcon = BPoint( (width-iconWidth-(mNeedsLatch ? DIVLATCHW : 0))/2, (height-iconHeight)/2); } if (mNeedsLatch) { if (labelMode == "Hide") mLatchRect.Set( posIcon.x+iconWidth+2, posIcon.y+iconHeight/2-LATCHSZ/2, width, height); else mLatchRect.Set( posLabel.x+labelWidth+2, posLabel.y+labelHeight/2-LATCHSZ/2, width, height); } else mLatchRect.Set( -1, -1, -1, -1); // Draw BRect rect(0,0,width-1,height-1); BView* view = new BView( rect, NULL, B_FOLLOW_NONE, 0); BBitmap* drawImage = new BBitmap( rect, B_RGBA32, true); drawImage->AddChild( view); drawImage->Lock(); BPicture* picture = new BPicture(); view->BeginPicture( picture); view->SetHighColor( ui_color( B_PANEL_TEXT_COLOR)); view->SetViewColor( B_TRANSPARENT_COLOR); view->SetLowColor( ui_color( B_PANEL_BACKGROUND_COLOR)); #ifndef __HAIKU__ BmToolbar* toolbar = dynamic_cast<BmToolbar*>(Parent()->Parent()); BBitmap* toolbarBackground = NULL; if (toolbar) { toolbarBackground = toolbar->BackgroundBitmap(); if (toolbarBackground) view->DrawBitmap( toolbarBackground, Frame(), rect); } if (mode == STATE_ON) { rect.InsetBy( 1, 1); view->BeginLineArray(4); view->AddLine( rect.LeftBottom(), rect.LeftTop(), BmWeakenColor(B_SHADOW_COLOR, BeShadowMod)); view->AddLine( rect.LeftTop(), rect.RightTop(), BmWeakenColor(B_SHADOW_COLOR, BeShadowMod)); view->AddLine( rect.LeftBottom(), rect.RightBottom(), ui_color( B_SHINE_COLOR)); view->AddLine( rect.RightBottom(), rect.RightTop(), ui_color( B_SHINE_COLOR)); view->EndLineArray(); } #endif // Draw Icon if (showIcons && image) { view->SetDrawingMode( B_OP_ALPHA); view->SetBlendingMode( B_PIXEL_ALPHA, B_ALPHA_OVERLAY); #ifdef __HAIKU__ BBitmap disabledImage(image); if (mode == STATE_DISABLED) { image = &disabledImage; uint8* bits = (uint8*)image->Bits(); uint32 width = image->Bounds().IntegerWidth() + 1; uint32 height = image->Bounds().IntegerWidth() + 1; uint32 bpr = image->BytesPerRow(); for (uint32 y = 0; y < height; y++) { uint8* b = bits; for (uint32 x = 0; x < width; x++) { b[3] = (uint8)(((int)b[3] * 100) >> 8); b += 4; } bits += bpr; } }
//Build up GUI eg MenuBar void ImmersiveVideoWindow::_InitWindow(void) { BRect r; BMenu *menu; BMenuItem *item; //++++MenuBar++++ r = Bounds(); menubar = new BMenuBar(r, "menu_bar"); // Add File menu to menu bar menu = new BMenu("File"); // menu->AddItem(new BMenuItem("New", new BMessage(MENU_FILE_NEW), 'N')); menu->AddItem(item=new BMenuItem("Open" B_UTF8_ELLIPSIS,new BMessage(MENU_FILE_OPEN), 'O')); item->SetTarget(be_app); menu->AddItem(item=new BMenuItem("Close", new BMessage(MENU_FILE_CLOSE), 'W')); item->SetTarget(be_app); menu->AddSeparatorItem(); menu->AddItem(saveitem=new BMenuItem("Save", new BMessage(MENU_FILE_SAVE), 'S')); // saveitem->SetEnabled(false); //saveitem->SetTarget(be_app); //menu->AddItem(item=new BMenuItem("Save as" B_UTF8_ELLIPSIS,new BMessage(MENU_FILE_SAVEAS))); //item->SetTarget(be_app); menu->AddSeparatorItem(); menu->AddItem(item=new BMenuItem("Export" B_UTF8_ELLIPSIS,new BMessage(MENU_FILE_EXPORT))); item->SetTarget(be_app); menu->AddSeparatorItem(); menu->AddItem(item=new BMenuItem("Page Setup" B_UTF8_ELLIPSIS,new BMessage(MENU_FILE_PAGESETUP))); item->SetEnabled(false); item->SetTarget(be_app); menu->AddItem(item=new BMenuItem("Print" B_UTF8_ELLIPSIS,new BMessage(MENU_FILE_PRINT), 'P')); item->SetTarget(be_app); item->SetEnabled(false); menu->AddSeparatorItem(); menu->AddItem(item=new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); item->SetTarget(be_app); menubar->AddItem(menu); // Add the Edit menu to the menu bar edit = new BMenu("Edit"); edit->AddItem(item=new BMenuItem("Undo", new BMessage(B_UNDO), 'Z')); // edit->AddItem(item=new BMenuItem("Redo", new BMessage(B_REDO), 'Z')); edit->AddSeparatorItem(); edit->AddItem(item=new BMenuItem("Cut", new BMessage(B_CUT), 'X')); edit->AddItem(item=new BMenuItem("Copy", new BMessage(B_COPY), 'C')); edit->AddItem(item=new BMenuItem("Paste", new BMessage(B_PASTE), 'V')); edit->AddSeparatorItem(); edit->AddItem(item=new BMenuItem("Preferences", new BMessage(MENU_EDIT_PREFERENCES), 'A')); menubar->AddItem(edit); // Attach the menu bar to he window AddChild(menubar); //----MenuBar---- //++++GUI++++ //+++BackView+++ BRect background= Bounds(); background.top = menubar->Bounds().bottom + 1.0; BView *backView=new BView(background,"hintergrund",B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_PULSE_NEEDED); AddChild(backView); backView->SetViewColor(216,216,216); //---BackView--- //+++PluginListe+++ BRect pluginListFrame = background; pluginListFrame.right -= B_V_SCROLL_BAR_WIDTH; pluginListFrame.bottom -= 180; //**nur notwendig wenn wir unten ein Scrollbar einführen wollen // pluginListFrame.bottom -= B_V_SCROLL_BAR_WIDTH; pluginListFrame.InsetBy(2,2); listView = new BListView(pluginListFrame, "plugin_view", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_PULSE_NEEDED); scrollView = new BScrollView("scroll_view", listView, B_FOLLOW_ALL_SIDES, B_SUBPIXEL_PRECISE, false, true); backView->AddChild(scrollView); listView->MakeFocus(true); listView->SetSelectionMessage(new BMessage(PLUGINLIST_SELECTION_CHANGED)); //---PluginListe--- //+++Originalgrößen View+++ BRect pictureSize = background; pictureSize.top=(pluginListFrame.bottom+5); pictureSize.bottom -=115; BBox *pictureSizeView=new BBox(pictureSize,"pictureView1",B_FOLLOW_BOTTOM|B_FOLLOW_LEFT_RIGHT); backView->AddChild(pictureSizeView); pictureSizeView->SetLabel(new BStringView(BRect(10,0,50,20),"Label","Originalgröße:")); BStringView *label1=new BStringView(BRect(5,20,45,35),"Label1","Width:", B_FOLLOW_BOTTOM|B_FOLLOW_LEFT , B_WILL_DRAW|B_PULSE_NEEDED); BStringView *unit1=new BStringView(BRect(pictureSize.Width()-75,20,pictureSize.Width()-60,35),"Unit1","px", B_FOLLOW_BOTTOM|B_FOLLOW_RIGHT , B_WILL_DRAW|B_PULSE_NEEDED); inputWidth=new BStringView(BRect(65,20,pictureSize.Width()-80,35),"iWidth","",B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_PULSE_NEEDED); BStringView *label2=new BStringView(BRect(5,40,45,55),"Label2","Height:", B_FOLLOW_BOTTOM|B_FOLLOW_LEFT, B_WILL_DRAW|B_PULSE_NEEDED); BStringView *unit2=new BStringView(BRect(pictureSize.Width()-75,40,pictureSize.Width()-60,55),"Unit2","px", B_FOLLOW_BOTTOM|B_FOLLOW_RIGHT , B_WILL_DRAW|B_PULSE_NEEDED); inputHeight=new BStringView(BRect(65,40,pictureSize.Width()-80,55),"iHeight","",B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_PULSE_NEEDED); pictureSizeView->AddChild(label1); pictureSizeView->AddChild(inputHeight); pictureSizeView->AddChild(unit1); inputHeight->SetViewColor(200,200,200,255); inputHeight->SetDrawingMode(B_OP_OVER); // (inputHeight->TextView())->MakeEditable(false); pictureSizeView->AddChild(label2); pictureSizeView->AddChild(inputWidth); pictureSizeView->AddChild(unit2); inputWidth->SetViewColor(200,200,200,255); inputWidth->SetDrawingMode(B_OP_OVER); // (inputWidth->TextView())->MakeEditable(false); //---Originalgrößen View--- //+++Neue Größe View+++ BRect newPictureSize = background; newPictureSize.top=(pictureSize.bottom+3); newPictureSize.bottom -=50; BBox *newPictureSizeView=new BBox(newPictureSize,"pictureView2",B_FOLLOW_BOTTOM|B_FOLLOW_LEFT_RIGHT); newPictureSizeView->SetLabel(new BStringView(BRect(10,0,50,20),"Label","Neue Größe:")); outputWidth=new BTextControl(BRect(5,15,newPictureSize.Width()-80,20),"oWidth","Width:","",new BMessage(OUTPUT_WIDTH_CHANGED),B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_PULSE_NEEDED); outputHeight=new BTextControl(BRect(5,35,newPictureSize.Width()-80,20),"oHeight","Height:","",new BMessage(OUTPUT_HEIGHT_CHANGED),B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_PULSE_NEEDED); //Die Maseinheiten auswahl... BMenu *messureMenu=new BMenu("px",B_ITEMS_IN_COLUMN); messureMenu->SetRadioMode(true); messureMenu->SetLabelFromMarked(true); messureMenu->AddItem(item=new BMenuItem("px",new BMessage(MESSURE_MENU_PIXEL))); item->SetMarked(true); messureMenu->AddItem(item=new BMenuItem("%",new BMessage(MESSURE_MENU_PERCENT))); BMenuField *messureKind=new BMenuField(BRect(newPictureSize.Width()-40,25,newPictureSize.Width()-5,40),"messureKind",NULL,messureMenu,B_FOLLOW_BOTTOM|B_FOLLOW_RIGHT); BRect rect=BRect(newPictureSize.Width()-75,20,newPictureSize.Width()-45,50); BView *tmpView = new BView(rect, "temp", B_FOLLOW_NONE, B_WILL_DRAW ); // der Verknüpfungsknop AddChild(tmpView); //create on picture rgb_color back=backView->ViewColor(); //back.alpha=255; BPicture *on; tmpView->BeginPicture(new BPicture); tmpView->SetHighColor(back); tmpView->FillRect(tmpView->Bounds()); tmpView->BeginLineArray(7); tmpView->AddLine(BPoint(0,3),BPoint(15,3),black); tmpView->AddLine(BPoint(0,3),BPoint(5,0),black); tmpView->AddLine(BPoint(0,3),BPoint(5,6),black); tmpView->AddLine(BPoint(15,3),BPoint(15,27),black); tmpView->AddLine(BPoint(0,27),BPoint(15,27),black); tmpView->AddLine(BPoint(0,27),BPoint(5,24),black); tmpView->AddLine(BPoint(0,27),BPoint(5,30),black); tmpView->EndLineArray(); on = tmpView->EndPicture(); //create off picture BPicture *off; tmpView->BeginPicture(new BPicture); tmpView->SetHighColor(back); tmpView->FillRect(tmpView->Bounds()); tmpView->BeginLineArray(8); tmpView->AddLine(BPoint(0,3),BPoint(15,3),black); tmpView->AddLine(BPoint(0,3),BPoint(5,0),black); tmpView->AddLine(BPoint(0,3),BPoint(5,6),black); tmpView->AddLine(BPoint(15,3),BPoint(15,10),black); tmpView->AddLine(BPoint(15,20),BPoint(15,27),black); tmpView->AddLine(BPoint(0,27),BPoint(15,27),black); tmpView->AddLine(BPoint(0,27),BPoint(5,24),black); tmpView->AddLine(BPoint(0,27),BPoint(5,30),black); tmpView->EndLineArray(); tmpView->SetPenSize(1.5); tmpView->SetHighColor(red); tmpView->StrokeArc(BPoint(15,7),4,2,180,180); tmpView->StrokeArc(BPoint(15,23),4,2,0,180); off = tmpView->EndPicture(); //get rid of tmpView RemoveChild(tmpView); delete tmpView; depent = new BPictureButton(rect,"concate", on, off, NULL,B_TWO_STATE_BUTTON,B_FOLLOW_BOTTOM|B_FOLLOW_RIGHT); newPictureSizeView->AddChild(outputHeight); newPictureSizeView->AddChild(outputWidth); newPictureSizeView->AddChild(depent); newPictureSizeView->AddChild(messureKind); backView->AddChild(newPictureSizeView); // BButton *testButton=new BButton(BRect(10,Bounds().Height()-45,70,Bounds().Height()-25),"TestButton","Test",new BMessage(TEST_REQUEST),B_FOLLOW_BOTTOM); BButton *testButton=new BButton(BRect(Bounds().Width()-60,Bounds().Height()-45,Bounds().Width()-7,Bounds().Height()-25),"TestButton","Berechnen",new BMessage(TEST_REQUEST),B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM); // BButton *speichernButton=new BButton(BRect(Bounds().Width()-70,Bounds().Height()-45,Bounds().Width()-10,Bounds().Height()-25),"SaveButton","Save",new BMessage(TEST_REQUEST),B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM); backView->AddChild(testButton); // backView->AddChild(speichernButton); //---Neue Größe View--- pluginWindow=NULL; LoadPlugins(); }