Skip to content

Commit

Permalink
Merge pull request #8 from lorglas/master
Browse files Browse the repository at this point in the history
yab 1.7.6 from lorglas
  • Loading branch information
bbjimmy authored Dec 17, 2018
2 parents ac58bad + a476af5 commit d1acdf4
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 24 deletions.
84 changes: 67 additions & 17 deletions src/YabInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,9 @@ void YabInterface::DrawText(BPoint coordinates, const char* text, const char* wi
if(bview)
{
b->Lock();
bview->DrawString(text, coordinates);
bview->SetDrawingMode(B_OP_ALPHA);
bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
bview->DrawString(text, coordinates);
bview->Sync();
b->Unlock();
return;
Expand All @@ -1640,6 +1642,8 @@ void YabInterface::DrawText(BPoint coordinates, const char* text, const char* wi
BBitmap *b = myView->GetBitmap();
BView *bView = myView->GetBitmapView();
b->Lock();
bView->SetDrawingMode(B_OP_ALPHA);
bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
bView->DrawString(text, coordinates);
bView->Sync();
b->Unlock();
Expand Down Expand Up @@ -1697,9 +1701,11 @@ void YabInterface::DrawRect(BRect frame, const char* window)
if(bview)
{
b->Lock();
if(drawStroking)
bview->SetDrawingMode(B_OP_ALPHA);
bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
if(drawStroking)
bview->StrokeRect(frame, yabPattern);
else
else
bview->FillRect(frame, yabPattern);
bview->Sync();
b->Unlock();
Expand All @@ -1718,6 +1724,8 @@ void YabInterface::DrawRect(BRect frame, const char* window)
BBitmap *b = myView->GetBitmap();
BView *bView = myView->GetBitmapView();
b->Lock();
// bView->SetDrawingMode(B_OP_ALPHA);
//bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
if(drawStroking)
bView->StrokeRect(frame, yabPattern);
else
Expand Down Expand Up @@ -1812,6 +1820,8 @@ void YabInterface::DrawDot(double x, double y, const char* window)
if(bview)
{
b->Lock();
bview->SetDrawingMode(B_OP_ALPHA);
bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
bview->StrokeLine(BPoint(x,y), BPoint(x,y), yabPattern);
bview->Sync();
b->Unlock();
Expand All @@ -1830,6 +1840,8 @@ void YabInterface::DrawDot(double x, double y, const char* window)
BBitmap *b = myView->GetBitmap();
BView *bView = myView->GetBitmapView();
b->Lock();
// bView->SetDrawingMode(B_OP_ALPHA);
// bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
bView->StrokeLine(BPoint(x,y), BPoint(x,y), yabPattern);
bView->Sync();
b->Unlock();
Expand Down Expand Up @@ -1878,6 +1890,8 @@ void YabInterface::DrawLine(double x1, double y1, double x2, double y2, const ch
if(bview)
{
b->Lock();
bview->SetDrawingMode(B_OP_ALPHA);
bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
bview->StrokeLine(BPoint(x1,y1), BPoint(x2,y2), yabPattern);
bview->Sync();
b->Unlock();
Expand All @@ -1896,6 +1910,8 @@ void YabInterface::DrawLine(double x1, double y1, double x2, double y2, const ch
BBitmap *b = myView->GetBitmap();
BView *bView = myView->GetBitmapView();
b->Lock();
//bView->SetDrawingMode(B_OP_ALPHA);
//bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
bView->StrokeLine(BPoint(x1,y1), BPoint(x2,y2), yabPattern);
bView->Sync();
b->Unlock();
Expand Down Expand Up @@ -1948,6 +1964,10 @@ void YabInterface::DrawCircle(double x, double y, double r, const char* window)
if(bview)
{
b->Lock();

bview->SetDrawingMode(B_OP_ALPHA);
bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);

if(drawStroking)
bview->StrokeEllipse(BPoint(x,y), r, r, yabPattern);
else
Expand All @@ -1968,7 +1988,11 @@ void YabInterface::DrawCircle(double x, double y, double r, const char* window)
w->Lock();
BBitmap *b = myView->GetBitmap();
BView *bView = myView->GetBitmapView();

b->Lock();
// bView->SetDrawingMode(B_OP_ALPHA);
// bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
// bView->SetDrawingMode(B_OP_OVER);
if(drawStroking)
bView->StrokeEllipse(BPoint(x,y), r, r, yabPattern);
else
Expand Down Expand Up @@ -2021,6 +2045,8 @@ void YabInterface::DrawEllipse(double x, double y, double r1, double r2, const c
if(bview)
{
b->Lock();
bview->SetDrawingMode(B_OP_ALPHA);
bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
if(drawStroking)
bview->StrokeEllipse(BPoint(x,y), r1, r2, yabPattern);
else
Expand All @@ -2042,6 +2068,8 @@ void YabInterface::DrawEllipse(double x, double y, double r1, double r2, const c
BBitmap *b = myView->GetBitmap();
BView *bView = myView->GetBitmapView();
b->Lock();
// bView->SetDrawingMode(B_OP_ALPHA);
// bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
if(drawStroking)
bView->StrokeEllipse(BPoint(x,y), r1, r2, yabPattern);
else
Expand Down Expand Up @@ -2101,6 +2129,8 @@ void YabInterface::DrawCurve(double x1, double y1, double x2, double y2, double
if(bview)
{
b->Lock();
bview->SetDrawingMode(B_OP_ALPHA);
bview->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
BPoint p[4];
p[0].Set(x1,y1);
p[1].Set(x2,y2);
Expand Down Expand Up @@ -2132,6 +2162,8 @@ void YabInterface::DrawCurve(double x1, double y1, double x2, double y2, double
BBitmap *b = myView->GetBitmap();
BView *bView = myView->GetBitmapView();
b->Lock();
// bView->SetDrawingMode(B_OP_ALPHA);
// bView->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
BPoint p[4];
p[0].Set(x1,y1);
p[1].Set(x2,y2);
Expand All @@ -2148,7 +2180,7 @@ void YabInterface::DrawCurve(double x1, double y1, double x2, double y2, double
bView->FillBezier(p, yabPattern);
bView->Sync();
b->Unlock();

myView->Draw(BRect(invx1,invy1,invx2,invy2));
w->Unlock();
return;
Expand Down Expand Up @@ -4485,7 +4517,7 @@ void YabInterface::TreeBox2(const char* id, const char* item)
}
Error(id, "TREEBOX");
}

//Correction of Subitem by Stephan Aßmus on BeGeistert 2018
void YabInterface::TreeBox3(const char* id, const char* head, const char* item, int isExpanded)
{
YabView *myView = NULL;
Expand All @@ -4507,10 +4539,17 @@ void YabInterface::TreeBox3(const char* id, const char* head, const char* item,
BStringItem *stritem = (BStringItem*)myTree->FullListItemAt(i);
if(!strcmp(stritem->Text(), head))
{
BStringItem *tmp = new BStringItem(item);
myTree->AddUnder(tmp,stritem);
int32 level = stritem->OutlineLevel() + 1;
BStringItem *tmp = new BStringItem(item, level);
//myTree->AddUnder(tmp,stritem);
int32 fullSubItemCount = myTree->CountItemsUnder(stritem, false);
//printf("found item '%s' at %ld with level %ld, number of sub-items: %ld\n",
// head, i, level - 1, fullSubItemCount);
myTree->AddItem(tmp, i + fullSubItemCount + 1);

if(isExpanded<1)
myTree->Collapse(stritem);

w->Unlock();
return;
}
Expand Down Expand Up @@ -4804,7 +4843,7 @@ const char* YabInterface::TreeboxGet(const char* treebox, int pos)
pos--;
YabView *myView = NULL;
BOutlineListView *myTree = NULL;
for(int i=0; i<viewList->CountItems(); i++)
for(int i=0; i<viewList->CountItems(); i++) //CountItems()
{
myView = cast_as((BView*)viewList->ItemAt(i), YabView);
if(myView)
Expand All @@ -4820,6 +4859,7 @@ const char* YabInterface::TreeboxGet(const char* treebox, int pos)
if(t)
{
const char* txt = t->Text();
//printf(txt);
w->Unlock();
return txt;
}
Expand Down Expand Up @@ -8149,19 +8189,24 @@ int YabInterface::ThreadGet(const char* option, const char* appname)

return ret;
}

//Correction of Subitem by Stephan Aßmus on BeGeistert 2018
void YabInterface::Bitmap(double w, double h, const char* id)
{
char *t;
BBitmap *b = new BBitmap(BRect(0,0,w-1,h-1), B_RGBA32, true);
BView *bview = new BView(BRect(0,0,w-1,h-1), id, B_FOLLOW_NONE, 0);

//bview->SetDrawingMode(B_OP_ALPHA);
//bview->SetViewColor(255,255,255,255);
b->AddChild(bview);
t = (char*)b->Bits();
for(int i=0; i<w*h*4; i = i + 4)
{
t[i] = t[i+1] = t[i+2] = 255;
t[i+3] = 0;
}

memset(b->Bits(), 0, b->BitsLength());
// t = (char*)b->Bits();
// for(int i=0; i<w*h*4; i = i + 4)
// {
// t[i] = t[i+1] = t[i+2] = 255;
// t[i+3] = 0;
// }
yabbitmaps->AddItem(b);
}

Expand Down Expand Up @@ -8420,11 +8465,15 @@ void YabInterface::BitmapGet(BRect frame, const char* id, const char* bitmap)
{
BBitmap *b = (BBitmap*)yabbitmaps->ItemAt(i);
BView *bview = b->FindView(bitmap);


if(bview)
{
char *oldbits, *newbits;
BBitmap *newbmp = new BBitmap(BRect(0,0, frame.Width(), frame.Height()), B_RGBA32, true);

BBitmap *newbmp = new BBitmap(BRect(0,0, frame.Width(), frame.Height()), B_RGBA32, true);
BView *newbview = new BView(BRect(0,0, frame.Width(), frame.Height()), id, B_FOLLOW_NONE, 0);

newbmp->AddChild(newbview);
newbits = (char*)newbmp->Bits();
for(int i=0; i<frame.Width()*frame.Height()*4; i = i + 4)
Expand Down Expand Up @@ -8794,7 +8843,8 @@ int YabInterface::Sound(const char* filename)
{
entry_ref ref;
BEntry entry(filename, true);

//printf("file '%s' \n", &filename);

if (entry.InitCheck() == B_OK)
if (entry.GetRef(&ref) == B_OK)
return play_sound(&ref, true, false, true);
Expand Down
9 changes: 5 additions & 4 deletions src/YabView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ void YabView::Draw(BRect updateRect)
{
SetFont(be_plain_font);
updateRect = Bounds();
SetDrawingMode(B_OP_OVER);
for(int i=0; i<drawList->CountItems(); i++)
{
YabDrawing *e = (YabDrawing*)drawList->ItemAt(i);
Expand All @@ -129,15 +130,15 @@ void YabView::Draw(BRect updateRect)
break;
case 6: {
if(e->alpha == 255)
SetDrawingMode(B_OP_COPY);
SetDrawingMode(B_OP_OVER);
else
SetDrawingMode(B_OP_ALPHA);
SetHighColor(e->r,e->g,e->b,e->alpha);
}
break;
case 7: {
if(e->alpha == 255)
SetDrawingMode(B_OP_COPY);
SetDrawingMode(B_OP_OVER);
else
SetDrawingMode(B_OP_ALPHA);
SetLowColor(e->r,e->g,e->b,e->alpha);
Expand Down Expand Up @@ -168,7 +169,7 @@ void YabView::Draw(BRect updateRect)
case 10: {
drawing_mode mode = DrawingMode();
if(IsPrinting())
SetDrawingMode(B_OP_COPY);
SetDrawingMode(B_OP_OVER);
else
SetDrawingMode(B_OP_ALPHA);
DrawBitmap(e->bitmap, BPoint(e->x1, e->y1));
Expand All @@ -178,7 +179,7 @@ void YabView::Draw(BRect updateRect)
case 11: {
drawing_mode mode = DrawingMode();
if(IsPrinting())
SetDrawingMode(B_OP_COPY);
SetDrawingMode(B_OP_OVER);
else
SetDrawingMode(B_OP_ALPHA);
DrawBitmap(e->bitmap, BRect(e->x1, e->y1, e->x2, e->y2));
Expand Down
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// #define LIBBSVG
#define BUILD_TIME __DATE__
/* Version number of package */
#define VERSION "1.7.5.6"
#define VERSION "1.7.6.0"
/* architecture of build machine */
#define UNIX_ARCHITECTURE "BePC-Haiku"

Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ can be found at www.yabasic.de
/* ------------- defines ---------------- */

#define DONE {current=current->next;break;} /* reduces type-work */
#define COPYRIGHT " Original yabasic Copyright 1995-2006 by Marc-Oliver Ihm\n\tyab improvements Copyright 2006-2014 by Jan Bungeroth\n\tyab improvements Copyright 2013-2018 by Jim Saxton\n"
#define COPYRIGHT " Original yabasic Copyright 1995-2006 by Marc-Oliver Ihm\n\tyab improvements Copyright 2006-2014 by Jan Bungeroth\n\tyab improvements Copyright 2013-2018 by Jim Saxton\n\tyab improvements Copyright 2018 by BeSly Software Solutions (Thanks to Stephan Aßmus for Correction of Code)\n"
#define BANNER \
"\n yab is yabasic, a BASIC programming language for Haiku.\n This is version " VERSION ",\n built on "\
"\n yab is yabasic, a BASIC programming language for Haiku.\n This is version " VERSION ", built on "\
ARCHITECTURE " on " BUILD_TIME "\n\n " COPYRIGHT "\n\n"
#define BANNER_VERSION \
"yab " VERSION ", built on " ARCHITECTURE "\n" COPYRIGHT
Expand Down

0 comments on commit d1acdf4

Please sign in to comment.