Renamed View.* to PathView.* and Application.* to LPBApp.*.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@504 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
80a604c999
commit
8002202d9d
|
@ -2,11 +2,11 @@ SubDir OBOS_TOP src tests add-ons print pdf linepathbuilder ;
|
|||
|
||||
SubDirHdrs $(OBOS_TOP) src add-ons print drivers pdf source ;
|
||||
|
||||
AddResources LinePathBuilder : <$(SOURCE_GRIST)>Application.rsrc ;
|
||||
AddResources LinePathBuilder : LinePathBuilder.rsrc ;
|
||||
|
||||
local sources =
|
||||
Application.cpp
|
||||
View.cpp
|
||||
LPBApp.cpp
|
||||
PathView.cpp
|
||||
SubPath.cpp
|
||||
LinePathBuilder.cpp
|
||||
;
|
||||
|
@ -20,9 +20,4 @@ SimpleTest LinePathBuilder
|
|||
SEARCH on [ FGristFiles LinePathBuilder.cpp SubPath.cpp ]
|
||||
= [ FDirName $(OBOS_TOP) src add-ons print drivers pdf source ] ;
|
||||
|
||||
# Ugly hack: Prepend the dirs containing Be's Application.h/View.h to the list
|
||||
# of include search dirs. Otherwise they won't be found.
|
||||
# It is certainly a good idea to rename the local files.
|
||||
PrependObjectHdrs $(sources)
|
||||
: /boot/develop/headers/be/app /boot/develop/headers/be/interface ;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "Application.h"
|
||||
#include "LPBApp.h"
|
||||
|
||||
BMessage* NewMessage(uint32 what, uint32 data)
|
||||
{
|
||||
|
@ -43,10 +43,10 @@ AppWindow::AppWindow(BRect aRect)
|
|||
menubar->AddItem(menu);
|
||||
|
||||
AddChild(menubar);
|
||||
// add view
|
||||
// add path view
|
||||
aRect.Set(0, menubar->Bounds().Height()+1, aRect.Width(), aRect.Height());
|
||||
view = NULL;
|
||||
AddChild(view = new View(aRect));
|
||||
AddChild(view = new PathView(aRect));
|
||||
// make window visible
|
||||
Show();
|
||||
}
|
|
@ -3,16 +3,16 @@
|
|||
|
||||
#include <AppKit.h>
|
||||
#include <InterfaceKit.h>
|
||||
#include "View.h"
|
||||
#include "PathView.h"
|
||||
#include "MsgConsts.h"
|
||||
|
||||
#define APPLICATION "Application"
|
||||
#define APPLICATION "LinePathBuilder"
|
||||
#define VERSION "1.0"
|
||||
|
||||
class AppWindow : public BWindow {
|
||||
public:
|
||||
BMenuBar *menubar;
|
||||
View *view;
|
||||
PathView *view;
|
||||
AppWindow(BRect);
|
||||
bool QuitRequested();
|
||||
void AboutRequested();
|
Binary file not shown.
|
@ -1,124 +0,0 @@
|
|||
#include "View.h"
|
||||
#include "LinePathBuilder.h"
|
||||
#include <InterfaceKit.h>
|
||||
|
||||
class ShapeLPB : public LinePathBuilder
|
||||
{
|
||||
BShape fShape;
|
||||
|
||||
protected:
|
||||
virtual void MoveTo(BPoint p);
|
||||
virtual void LineTo(BPoint p);
|
||||
virtual void BezierTo(BPoint* p);
|
||||
virtual void ClosePath(void);
|
||||
|
||||
public:
|
||||
ShapeLPB(SubPath *subPath, float penSize, cap_mode capMode, join_mode joinMode, float miterLimit);
|
||||
BShape *Shape() { return &fShape; }
|
||||
};
|
||||
|
||||
ShapeLPB::ShapeLPB(SubPath *subPath, float penSize, cap_mode capMode, join_mode joinMode, float miterLimit)
|
||||
: LinePathBuilder(subPath, penSize, capMode, joinMode, miterLimit)
|
||||
{
|
||||
}
|
||||
|
||||
void ShapeLPB::MoveTo(BPoint p)
|
||||
{
|
||||
fShape.MoveTo(p);
|
||||
}
|
||||
|
||||
void ShapeLPB::LineTo(BPoint p)
|
||||
{
|
||||
fShape.LineTo(p);
|
||||
}
|
||||
|
||||
void ShapeLPB::BezierTo(BPoint p[3])
|
||||
{
|
||||
fShape.BezierTo(p);
|
||||
}
|
||||
|
||||
void ShapeLPB::ClosePath(void)
|
||||
{
|
||||
fShape.Close();
|
||||
}
|
||||
|
||||
View::View(BRect rect)
|
||||
: BView(rect, NULL, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_SUBPIXEL_PRECISE) {
|
||||
//SetViewColor(B_TRANSPARENT_COLOR);
|
||||
fMode = kStroke;
|
||||
fCurPoint = -1;
|
||||
fWidth = 16;
|
||||
}
|
||||
|
||||
void View::Draw(BRect updateRect) {
|
||||
if (fMode == kDrawOutline) {
|
||||
|
||||
} else if (fMode == kStroke) {
|
||||
const int n = fPath.CountPoints();
|
||||
BShape shape;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (i == 0)
|
||||
shape.MoveTo(fPath.PointAt(i));
|
||||
else
|
||||
shape.LineTo(fPath.PointAt(i));
|
||||
}
|
||||
if (fPath.IsClosed()) shape.Close();
|
||||
SetPenSize(fWidth);
|
||||
StrokeShape(&shape);
|
||||
|
||||
ShapeLPB path(&fPath, fWidth, LineCapMode(), LineJoinMode(), LineMiterLimit());
|
||||
path.CreateLinePath();
|
||||
SetPenSize(1);
|
||||
|
||||
BPicture picture;
|
||||
BeginPicture(&picture);
|
||||
FillShape(path.Shape());
|
||||
EndPicture();
|
||||
|
||||
PushState();
|
||||
ClipToPicture(&picture);
|
||||
SetHighColor(0, 255, 0);
|
||||
FillRect(Bounds());
|
||||
PopState();
|
||||
|
||||
SetOrigin(200, 0);
|
||||
SetHighColor(255, 0, 0);
|
||||
StrokeShape(path.Shape());
|
||||
Flush();
|
||||
}
|
||||
}
|
||||
|
||||
void View::MouseDown(BPoint point) {
|
||||
uint32 buttons;
|
||||
GetMouse(&point, &buttons, false);
|
||||
|
||||
if (buttons == B_SECONDARY_MOUSE_BUTTON) {
|
||||
fCurPoint = fPath.CountPoints();
|
||||
fPath.AddPoint(point);
|
||||
} else {
|
||||
float d = 100000000000.0;
|
||||
for (int i = 0; i < fPath.CountPoints(); i++) {
|
||||
BPoint p = point - fPath.PointAt(i);
|
||||
float e = p.x*p.x + p.y*p.y;
|
||||
if (e < d) { fCurPoint = i; d = e; }
|
||||
}
|
||||
fPath.AtPut(fCurPoint, point);
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void View::MouseMoved(BPoint point, uint32 transit, const BMessage *message) {
|
||||
if (fCurPoint != -1) {
|
||||
fPath.AtPut(fCurPoint, point);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void View::MouseUp(BPoint point) {
|
||||
fCurPoint = -1;
|
||||
}
|
||||
|
||||
void View::SetClose(bool close) {
|
||||
if (close) fPath.Close();
|
||||
else fPath.Open();
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef VIEW_H
|
||||
#define VIEW_H
|
||||
|
||||
#include "SubPath.h"
|
||||
#include <View.h>
|
||||
|
||||
class View : public BView {
|
||||
SubPath fPath;
|
||||
enum {
|
||||
kDrawOutline,
|
||||
kStroke
|
||||
} fMode;
|
||||
int fCurPoint;
|
||||
float fWidth;
|
||||
|
||||
public:
|
||||
View(BRect rect);
|
||||
void Draw(BRect updateRect);
|
||||
void MouseDown(BPoint point);
|
||||
void MouseUp(BPoint point);
|
||||
void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
|
||||
void SetClose(bool close);
|
||||
};
|
||||
#endif
|
Loading…
Reference in New Issue