diff --git a/src/Makefile b/src/Makefile index 0a601f3..3df82e9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -53,7 +53,7 @@ OPT = -O ## ## set libtrary name ## -YABLIBRARY := libyab.so +YABLIBRARY := libyab1.so ## # @@ -69,7 +69,7 @@ GPP_OPT = $(DBG) $(OPT) -I. -DHAVE_CONFIG -DUNIX $(HAIKUOPT) ## find out if we need to change the library to libyab_x86.so and use gcc instead of ld ifeq ($(USEDARCH), x86) LD = gcc - YABLIBRARY:=libyab_x86.so + YABLIBRARY:=libyab1_x86.so else LD = ld endif @@ -87,7 +87,7 @@ LD_OPT = -shared LIBPATHS = $(shell findpaths -a `getarch` B_FIND_PATH_LIB_DIRECTORY;findpaths -a `getarch` B_FIND_PATH_DEVELOP_LIB_DIRECTORY) . LIBPATH=$(addprefix -L,$(LIBPATHS)) ##LIBPATH = -L`finddir B_SYSTEM_LIB_DIRECTORY` ##/boot/system/lib -LIB = -lbe -lroot -ltranslation -ltracker -lmedia -llocalestub +LIB = -lbe -lroot -ltranslation -ltracker -lmedia -llocalestub -lgame ## flags for flex (-d for debugging) FLEXFLAGS = -i -I -L -s diff --git a/src/MediaPlay.h b/src/MediaPlay.h new file mode 100644 index 0000000..7ed0c46 --- /dev/null +++ b/src/MediaPlay.h @@ -0,0 +1,11 @@ +/* + * Copyright 2017, Dario Casalinuovo. All rights reserved. + * Distributed under the terms of the MIT License. + */ + +#ifndef _MEDIA_CLIENT_PLAY +#define _MEDIA_CLIENT_PLAY + +int media_play(const char* uri); + +#endif diff --git a/src/Spinner.cpp b/src/Spinner.cpp index 2cdeb68..6b6429c 100644 --- a/src/Spinner.cpp +++ b/src/Spinner.cpp @@ -15,7 +15,7 @@ #include #include #include "global.h" - +#include enum { M_UP='mmup', @@ -130,24 +130,37 @@ Spinner::Spinner(BRect frame, const char *name, const char *label, int32 min, in BFont f(be_plain_font); float width1 = f.StringWidth(t.String())+2; float width2 = f.StringWidth(label); - ResizeTo(width1+width2+18+14, 14*2-2); - r = Bounds(); - r.right-=14+3; + ResizeTo(width1+width2+30, textheight+6); //14*2-2); //+18+14 length of textcontrol - r.bottom=r.top+textheight+8; + + r = Bounds(); + r.right -= 14+3; //Distance between textcontrol and spinnerbutton + + r.bottom=r.top+textheight+8; //+10; //Changed from 8 to 10, because the spinnerbutton look nicer r.OffsetTo(0, ( (Bounds().Height()-r.Height())/2) ); fTextControl=new BTextControl(r,"textcontrol",label,"0",new BMessage(M_TEXT_CHANGED), B_FOLLOW_ALL,B_WILL_DRAW|B_NAVIGABLE); - AddChild(fTextControl); - BTextView *tview=fTextControl->TextView(); - tview->SetAlignment(B_ALIGN_LEFT); - tview->SetWordWrap(false); - fTextControl->SetDivider(width2+5); - + AddChild(fTextControl); + + BTextView *tview=fTextControl->TextView(); + + tview->SetAlignment(B_ALIGN_RIGHT); //change from left to right not completed + tview->SetWordWrap(false); + + if (strcmp(label, "") == 0) //check if Label was set + { + fTextControl->SetDivider(width2); + } + else if (strcmp(label,"") != 0) + { + fTextControl->SetDivider(width2+4); + } + //fTextControl->SetDivider(width2+5); + //fTextControl->SetAlignment(B_ALIGN_RIGHT,B_ALIGN_RIGHT); BString string("QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,/qwertyuiop{}| " - "asdfghjkl:\"zxcvbnm<>?!@#$%^&*()-_=+`~\r"); + "asdfghjkl:\"zxcvbnm<>?!@#$%^&*()-_=+`~\r"); for(int32 i=0; iSetText(string); + } void Spinner::SetViewColor(rgb_color color) @@ -224,10 +239,12 @@ void Spinner::SetLabel(const char *text) void Spinner::ValueChanged(int32 value) { + } void Spinner::MessageReceived(BMessage *msg) { + if(msg->what==M_TEXT_CHANGED) { BString string(fTextControl->Text()); @@ -241,6 +258,7 @@ void Spinner::MessageReceived(BMessage *msg) Invoke(); Draw(Bounds()); ValueChanged(Value()); + } else { @@ -252,6 +270,7 @@ void Spinner::MessageReceived(BMessage *msg) Invoke(); Draw(Bounds()); ValueChanged(Value()); + } else if(newvalue>GetMax() && Value()!=GetMax()) @@ -260,17 +279,23 @@ void Spinner::MessageReceived(BMessage *msg) Invoke(); Draw(Bounds()); ValueChanged(Value()); + + } else { char string[100]; sprintf(string,"%ld",Value()); fTextControl->SetText(string); + } } + } + else BControl::MessageReceived(msg); + } void Spinner::SetSteps(int32 stepsize) diff --git a/src/URLView.cpp b/src/URLView.cpp index 5ea7ddd..73403ee 100644 --- a/src/URLView.cpp +++ b/src/URLView.cpp @@ -46,7 +46,7 @@ URLView::URLView( BRect frame, const char *name, const char *label, // Set the default values for the other definable instance variables. this->color = blue; - this->clickColor = red; + this->clickColor = dark_green; this->hoverColor = dark_blue; this->disabledColor = gray; this->hoverEnabled = true; @@ -120,6 +120,7 @@ void URLView::AttachedToWindow() { void URLView::Draw( BRect updateRect ) { + BRect rect = Frame(); rect.OffsetTo( B_ORIGIN ); @@ -157,17 +158,27 @@ void URLView::Draw( BRect updateRect ) { // Note: DrawString() draws the text at one pixel above the pen's // current y coordinate. DrawString( Text() ); + } -void URLView::MessageReceived( BMessage *message ) { +void URLView::MessageReceived( BMessage *message ) +{ + entry_ref ref; + switch (message->what) + { + + case 'DDCP': + { + // Is this a message from Tracker in response to our drag-and-drop? - if( message->what == 'DDCP' ) { + //if( message->what == 'DDCP' ) { // Tracker will send back the name and path of the created file. // We need to read this information. entry_ref ref; message->FindRef( "directory", &ref ); + BEntry entry( &ref ); BPath path( &entry ); BString *fullName = new BString( path.Path() ); @@ -183,11 +194,17 @@ void URLView::MessageReceived( BMessage *message ) { delete fullName; delete title; + + } + break; + default: + + BView::MessageReceived(message); + break; } + } - - void URLView::MouseDown( BPoint point ) { // If the link isn't enabled, don't do anything. if( !IsEnabled() ) @@ -201,8 +218,7 @@ void URLView::MouseDown( BPoint point ) { // if the user clicks on the link text itself and not just // anywhere in the view. if( GetTextRect().Contains( point ) ) { - SetHighColor( clickColor ); - Redraw(); + SetHighColor( clickColor ); // Set the link as selected and track the mouse. selected = true; @@ -223,13 +239,14 @@ void URLView::MouseDown( BPoint point ) { // Pop up the context menu? if( buttons == B_SECONDARY_MOUSE_BUTTON ) inPopup = true; } + //Redraw(); } void URLView::MouseMoved( BPoint point, uint32 transit, const BMessage *message ) { - + // If the link isn't enabled, don't do anything. if( !IsEnabled() ) return; @@ -242,9 +259,10 @@ void URLView::MouseMoved( BPoint point, uint32 transit, // Is the user currently dragging the link? (i.e. is a mouse button // currently down?) bool alreadyDragging = (buttons != 0); - + switch( transit ) { case( B_ENTERED_VIEW ): + // Should we set the cursor to the link cursor? if( GetTextRect().Contains( point ) && !draggedOut ) { if( !alreadyDragging ) be_app->SetCursor( linkCursor ); @@ -254,13 +272,13 @@ void URLView::MouseMoved( BPoint point, uint32 transit, // the link. if( selected ) { SetHighColor( clickColor ); - Redraw(); + //Redraw(); } // Should we hover-highlight the link? else if( hoverEnabled && !alreadyDragging ) { if( buttons == 0 ) { SetHighColor( hoverColor ); - Redraw(); + //Redraw(); hovering = true; } } @@ -274,11 +292,11 @@ void URLView::MouseMoved( BPoint point, uint32 transit, if( selected && !draggedOut ) { be_app->SetCursor( B_HAND_CURSOR ); SetHighColor( color ); - Redraw(); + //Redraw(); // Is the user drag-and-dropping a bookmark or person? if( draggable ) { - draggedOut = true; + // = true; if( IsEmailLink() ) DoPersonDrag(); else DoBookmarkDrag(); } @@ -288,20 +306,23 @@ void URLView::MouseMoved( BPoint point, uint32 transit, else if( hovering && !alreadyDragging ) { be_app->SetCursor( B_HAND_CURSOR ); SetHighColor( color ); - Redraw(); + //Redraw(); hovering = false; } // Change the cursor back to the hand. else { be_app->SetCursor( B_HAND_CURSOR ); } + break; case( B_INSIDE_VIEW ): // The user could either be moving out of the view or // back into it here, so we must handle both cases. // In the first case, the cursor is now over the link. + if( GetTextRect().Contains( point ) && !draggedOut ) { + // We only want to change the cursor if not dragging. if( !alreadyDragging ) be_app->SetCursor( linkCursor ); if( selected ) { @@ -317,7 +338,7 @@ void URLView::MouseMoved( BPoint point, uint32 transit, if( IsEmailLink() ) DoPersonDrag(); else DoBookmarkDrag(); SetHighColor( color ); - Redraw(); + //Redraw(); } } else { @@ -326,14 +347,14 @@ void URLView::MouseMoved( BPoint point, uint32 transit, // has the mouse cursor over it (like a standard // button). SetHighColor( clickColor ); - Redraw(); + //Redraw(); } } // The link isn't currently selected? If hover-highlighting // is enabled, highlight the link. else if( hoverEnabled && !alreadyDragging ) { SetHighColor( hoverColor ); - Redraw(); + //Redraw(); hovering = true; } } @@ -343,7 +364,7 @@ void URLView::MouseMoved( BPoint point, uint32 transit, be_app->SetCursor( B_HAND_CURSOR ); if( selected ) { SetHighColor( color ); - Redraw(); + // Is the user dragging the link? if( draggable ) { @@ -355,9 +376,10 @@ void URLView::MouseMoved( BPoint point, uint32 transit, // Is the mouse cursor hovering over the link? else if( hovering ) { SetHighColor( color ); - Redraw(); + //Redraw(); hovering = false; } + } break; } @@ -396,7 +418,7 @@ void URLView::MouseUp( BPoint point ) { // If not, restore the normal link color. else { SetHighColor( color ); - Redraw(); + } } @@ -416,8 +438,11 @@ void URLView::MouseUp( BPoint point ) { !inPopup && hoverEnabled ) { SetHighColor( hoverColor ); } - else if( !hovering ) SetHighColor( color ); - Redraw(); + else if( !hovering ) + { + SetHighColor( color ); + } + } @@ -429,7 +454,7 @@ void URLView::WindowActivated( bool active ) { if( !active ) { if( IsEnabled() ) { SetHighColor( color ); - Redraw(); + //Redraw(); } } } @@ -681,7 +706,7 @@ BPopUpMenu * URLView::CreatePopupMenu() { returnMe->SetAsyncAutoDestruct( true ); entry_ref app; - + // Set the text of the first item according to the link type. if( IsEmailLink() ) { // Find the name of the default e-mail client. @@ -950,9 +975,8 @@ BString URLView::GetImportantURL() { return returnMe; } - - BRect URLView::GetTextRect() { + // This function will return a BRect that contains only the text // and the underline, so the mouse can change and the link will // be activated only when the mouse is over the text itself, not @@ -1007,6 +1031,7 @@ BRect URLView::GetTextRect() { BRect URLView::GetURLRect() { + //Redraw(); // This function will return a BRect that contains only the URL // and the underline, so we can draw it when the user drags. // We'll use GetFontHeight() instead of bounding boxes here @@ -1055,8 +1080,6 @@ bool URLView::IsHTMLLink() { (url->FindFirst( "https://" ) == 0 ) ); } - - void URLView::LaunchURL() { // Is the URL a mail link or HTTP? if( IsEmailLink() ) { @@ -1108,16 +1131,13 @@ void URLView::LaunchURL() { // We don't know how to handle anything else. } - - void URLView::Redraw() { // Redraw the link without flicker. BRect frame = Frame(); - frame.OffsetTo( B_ORIGIN ); + frame.OffsetTo(0,0 ); Draw( frame ); } - void URLView::WriteAttributes( int fd ) { // Write the developer-defined attributes to the newly-created file. KeyPair *item; diff --git a/src/URLView.h b/src/URLView.h index 08bec86..9d39c6e 100644 --- a/src/URLView.h +++ b/src/URLView.h @@ -52,7 +52,7 @@ const uint8 url_cursor[] = { 16, 1, 1, 2, // The default link color, blue. const rgb_color blue = { 0, 0, 255 }; // The default clicked-link color, red. -const rgb_color red = { 255, 0, 0 }; +const rgb_color dark_green = { 107, 142, 035 }; // The default link hover color, dark blue. const rgb_color dark_blue = { 0, 0, 120 }; // The default disabled color, gray. @@ -92,7 +92,16 @@ class URLView : public BStringView { virtual void SetIconSize( icon_size iconSize ); virtual void SetUnderlineThickness( int thickness ); virtual void SetURL( const char *url ); - + //virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message); + // virtual void MouseUp(BPoint point); + // virtual void MouseDown(BPoint point); + int mouseStateInfo; + int mouseMovedInfo; + int mouseX; + int mouseY; + uint mouseLButton; + uint mouseMButton; + uint mouseRButton; private: void CopyToClipboard(); @@ -130,6 +139,8 @@ class URLView : public BStringView { BPoint dragOffset; BList *attributes; + + int prevMouseStateInfo; typedef struct kp { BString *key; BString *value; diff --git a/src/YabInterface.cpp b/src/YabInterface.cpp index fd0bad8..e2ba054 100644 --- a/src/YabInterface.cpp +++ b/src/YabInterface.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -40,6 +40,18 @@ #include #include #include +//#include +//#include +//#include "GameSoundDevice.h" +#include +#include +#include +#include +#include +#include +//#include + +#include #include #include #include @@ -56,7 +68,7 @@ #include "URLView.h" #include "Spinner.h" #include "YabTabView.h" - +#include "TabView.h" #ifdef LIBBSVG #include #endif @@ -78,6 +90,11 @@ #include "column/ColumnListView.h" +BMediaTrack* playTrack; +media_format playFormat; +BSoundPlayer* player = 0; + + const uint32 YABBUTTON = 'YBbu'; const uint32 YABMENU = 'YBme'; const uint32 YABSUBMENU = 'YBsu'; @@ -94,7 +111,6 @@ const uint32 YABTREEBOXINVOKE = 'YBti'; const uint32 YABFILEBOXSELECT = 'YBfs'; const uint32 YABFILEBOXINVOKE = 'YBfi'; const uint32 YABSHORTCUT = 'YBsh'; - const uint32 TYPE_YABVIEW = 1; char * refsRec=(char*)""; @@ -113,7 +129,6 @@ const char* _L(const char* text) return yabCatalog->GetString(text, NULL); //B_TRANSLATE_CONTEXT); return text; } - /** * Start the interpreter thread */ @@ -207,6 +222,7 @@ YabInterface::~YabInterface() delete viewList; // delete Roster; delete myProps; + delete fPlayer; if(yabCatalog) delete yabCatalog; while(yabbitmaps->CountItems()>0) @@ -605,9 +621,10 @@ void YabInterface::Tab(BRect frame, const char* id, const char* mode, const char myTabView->SetTabSide(side); myTabView->SetTabWidth(B_WIDTH_FROM_LABEL); - + //myTabView->SetTabWidth(B_WIDTH_AS_USUAL); + myView->AddChild(myTabView); - + w->Unlock(); } else @@ -620,8 +637,49 @@ void YabInterface::Tab(BRect frame, const char* id, const char* mode, const char void YabInterface::TabAdd(const char* id, const char* tabname) { YabView *myView = NULL; - YabTabView *myTabView = NULL; - + YabTabView *myTabView = NULL; + + + for(int i=0; iCountItems(); i++) + { + myView = cast_as((BView*)viewList->ItemAt(i), YabView); + if(myView) + { + //viewList->PrintOut(); + //fprintf(stderr, "Viewlist %d\n",viewList->ItemAt(i)); + YabWindow *w = cast_as(myView->Window(), YabWindow); + if(w) + { + w->Lock(); + myTabView = cast_as(myView->FindView(id), YabTabView); + + //myTabView->FindTabName(tabname); + if(myTabView) + { + BString t(id); + t << myTabView->CountTabs()+1; + BRect contentFrame = myTabView->Bounds(); + YabView *newView = new YabView(contentFrame, t.String(), B_FOLLOW_ALL_SIDES,B_WILL_DRAW|B_NAVIGABLE_JUMP); + viewList->AddView(t.String(), newView, TYPE_YABVIEW); + myTabView->AddTab(newView, tabname); + w->Unlock(); + return; + } + + w->Unlock(); + + } + } + + } + Error(id, "TABVIEW"); +} +void YabInterface::TabDel(const char* id, int num) //Reactivating Lorenz Glaser (aka lorglas) 20200801 +{ + YabView *myView = NULL; + YabTabView *myTabView=NULL; + + for(int i=0; iCountItems(); i++) { myView = cast_as((BView*)viewList->ItemAt(i), YabView); @@ -633,29 +691,45 @@ void YabInterface::TabAdd(const char* id, const char* tabname) w->Lock(); myTabView = cast_as(myView->FindView(id), YabTabView); if(myTabView) - { - BString t(id); - t << myTabView->CountTabs()+1; - - BRect contentFrame = myTabView->Bounds(); - - YabView *newView = new YabView(contentFrame, t.String(), B_FOLLOW_ALL_SIDES,B_WILL_DRAW|B_NAVIGABLE_JUMP); - viewList->AddView(t.String(), newView, TYPE_YABVIEW); - - myTabView->AddTab(newView, tabname); + { + if(num>=0 && num<=myTabView->CountTabs() && num != myTabView->Selection()) + { + if (num<=0) { + num=1; //If you deleted Tab Zero you must reselect Tab Zero + } + + myTabView->Select(num-1); //Selection of tab before + YabTabView* tabView = static_cast(myTabView); + YabView *t = static_cast(tabView->TabAt(num)->View()); + RemoveView(t); + //viewList->DelView(t->NameForTabView()); + myTabView->RemoveTab(num); //Remove Tab + + //viewList->PrintOut(); + } w->Unlock(); - return; + //viewList->PrintOut(); + return ; } - w->Unlock(); + //w->Unlock(); } } } Error(id, "TABVIEW"); } - +/* +void YabInterface::TabADD2(const char* id, int num) //Reactivating Lorenz Glaser (aka lorglas) 20200801 +{ + myTabView->AddTab(id, tabname); + myTabView->AddTab(num); + + } + Error(id, "TABVIEW"); +} +/* void YabInterface::TabDel(const char* id, int num) { -/* + YabView *myView = NULL; #ifdef BUILD_HAIKUTAB YabTabView *myTabView = NULL; @@ -669,6 +743,7 @@ void YabInterface::TabDel(const char* id, int num) if(myView) { YabWindow *w = cast_as(myView->Window(), YabWindow); + if(w) { w->Lock(); @@ -734,19 +809,32 @@ void YabInterface::TabDel(const char* id, int num) BBox *box = cast_as(myView->Parent(), BBox); myView->RemoveSelf(); delete myView; - viewList->DelView(window); + //viewList->DelView(w); + //viewList->DelView(window); + //viewList->DelView(id); + viewList->PrintOut(); if(box) { box->RemoveSelf(); delete box; } + viewList->PrintOut(); #ifdef BUILD_HAIKUTAB WindowClear(myTabView->ItemAt(num-1)->Name()); RemoveView(myTabView->ItemAt(num-1)); + //#endif #else - WindowClear((myTabView->TabAt(num-1)).GetTargetView().Name()); + + + //WindowClear((myTabView->Selection())); + //WindowClear(myTabView->TabAt(num-1)->Name()); + + //WindowClear(myTabView->ItemAt(num-1)->Name()); + //RemoveView(myTabView->ItemAt(num-1)); + #endif - myTabView->RemoveTab(num-1); + myTabView->RemoveTab(num); + w->Unlock(); return; } @@ -755,13 +843,7 @@ void YabInterface::TabDel(const char* id, int num) } } Error(id, "TABVIEW"); -*/ -} - - - - - +}*/ void YabInterface::TabSet(const char* id, int num) { @@ -1239,6 +1321,7 @@ void YabInterface::StatusBarSet(const char* id, int r, int g, int b) { YabView *myView = NULL; BStatusBar *myBar = NULL; + for(int i=0; iCountItems(); i++) { myView = cast_as((BView*)viewList->ItemAt(i), YabView); @@ -1321,7 +1404,9 @@ void YabInterface::CreateMenu(const char* menuhead, const char* menuitem, const void YabInterface::CreateTextControl(BRect frame, const char* id, const char* label, const char* text, const char* window) { + YabView *myView = cast_as((BView*)viewList->GetView(window), YabView); + //viewList->PrintOut(); if(myView) { YabWindow *w = cast_as(myView->Window(), YabWindow); @@ -1329,8 +1414,15 @@ void YabInterface::CreateTextControl(BRect frame, const char* id, const char* la { w->Lock(); BTextControl *textControl = new BTextControl(frame, id ,label, text, new BMessage(YABTEXTCONTROL)); - textControl->SetDivider(textControl->StringWidth(label)+5.0); - + //If the label is not set, a space of 5 pixels was still reserved to the left of the field. This place is now fully used + if (strcmp(label, "") == 0) //check if Label was set + { + textControl->SetDivider(textControl->StringWidth(label)); //+5.0); + } + else if (strcmp(label,"") != 0) + { + textControl->SetDivider(textControl->StringWidth(label)+5.0); + } if(w) { if(w->layout == -1) @@ -1464,7 +1556,17 @@ void YabInterface::CreateDropBox(BRect frame, const char* title, const char* lab w->Lock(); BPopUpMenu *dropmenu = new BPopUpMenu(""); BMenuField *drop = new BMenuField(frame,title,label, dropmenu, true); - drop->SetDivider(drop->StringWidth(label)+5.0); + drop->ResizeToPreferred(); + //If the label is not set, a space of 5 pixels was still reserved to the left of the field. This place is now fully used + if (strcmp(label, "") == 0) //check if label was set + { + drop->SetDivider(drop->StringWidth(label)); + } + else if (strcmp(label,"") != 0) + { + drop->SetDivider(drop->StringWidth(label)+5.0); + } + //drop->SetDivider(drop->StringWidth(label)+5.0); if(w->layout == -1) drop->SetResizingMode(B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM); else @@ -2745,6 +2847,7 @@ void YabInterface::TextControl(const char* id, int mode) for(int i=0; iCountItems(); i++) { myView = cast_as((BView*)viewList->ItemAt(i), YabView); + if(myView) { YabWindow *w = cast_as(myView->Window(), YabWindow); @@ -2789,11 +2892,13 @@ void YabInterface::TextControl(const char* id, const char* option, const char* v if(myView) { YabWindow *w = cast_as(myView->Window(), YabWindow); + if(w) { w->Lock(); int32 x=0; myTControl = cast_as(myView->FindView(id), BTextControl); + if(myTControl) { @@ -2826,17 +2931,28 @@ void YabInterface::TextControl(const char* id, const char* option, const char* v { if(tmpValue.IFindFirst("number")!=B_ERROR) { - for (x=0;x<48; x++) - { + + //Changing from for to String Method because it was possible to enter äöü and so on + //20.02.2019 Lorent Glaser + /*for (x=0;x<48; x++) + { myTView->DisallowChar(x); - } + } for (x=58;x<128; x++) - { - myTView->DisallowChar(x); - } + { + myTView->DisallowChar(x); + } x=46; - myTView-> AllowChar(x); + myTView-> AllowChar(x);*/ + BString string("QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,/qwertyuiop{}| " + "asdfghjkl:\"zxcvbnm<>?!@#$%^&*()-_=+`´°~\röäüÖÄÜß"); + for(int32 i=0; iDisallowChar(c); + } } + if(tmpValue.IFindFirst("alphanumeric")!=B_ERROR) { for (x=0;x<128; x++) @@ -3626,8 +3742,9 @@ void YabInterface::TextSet(const char* title, const char* option) myText->SelectAll(); else if(tmp.IFindFirst("Undo")!=B_ERROR) myText->Undo(be_clipboard); - // else if(tmp.IFindFirst("Redo")!=B_ERROR) - // ; // myText->Redo(be_clipboard); + else if(tmp.IFindFirst("Redo")!=B_ERROR) + // myText->Redo(be_clipboard); + ; else ErrorGen("Unknown option"); w->Unlock(); @@ -5232,16 +5349,70 @@ void YabInterface::ToolTips(const char* view, const char* text) Error(view, "VIEW"); } +void YabInterface::ToolTipsNew(const char* view, const char* text, const char* color, int r, int g, int b) +{ + printf("View %s",view); + printf("View %s",text); + printf("View %s",color); + printf("View %d",r); + printf("View %d",g); + printf("View %d",b); + + //SetViewColor(b1); + //SetLowColor(b1); + //SetHighColor(b2); + YabView *myView = NULL; + BView *theView = NULL; + for(int i=0; iCountItems(); i++) + { + myView = cast_as((BView*)viewList->ItemAt(i), YabView); + if(myView) + { + YabWindow *w = cast_as(myView->Window(), YabWindow); + if(w) + { + w->Lock(); + theView = w->FindView(view); + if(theView) + { + if(theView->Name()) + { + if(!strcmp(theView->Name(), view)) + { + if(text[0] == '\0') + // tooltip->SetHelp(theView, NULL); + ; + else + theView->SetLowColor(r,g,b,255); + theView->SetToolTip(text); + + w->Unlock(); + return; + } + } + } + w->Unlock(); + } + } + } + Error(view, "VIEW"); +} void YabInterface::ToolTipsColor(const char* color, int r, int g, int b) { -/* + /* BString tmp(color); rgb_color rgb = {r,g,b}; if(tmp.IFindFirst("BGColor")!=B_ERROR) - tooltip->SetColor(rgb); + { + //tooltip->SetColor(rgb); + + } else if(tmp.IFindFirst("TextColor")!=B_ERROR) - tooltip->SetTextColor(rgb); -*/ + { + //tooltip->SetTextColor(rgb); + + } + */ } void YabInterface::TreeSort(const char* view) @@ -6100,6 +6271,10 @@ int YabInterface::DesktopParam(bool isWidth) if(isWidth) return t.virtual_width; return t.virtual_height; } +/*int YabInterface::WorkspaceGet(bool isID) +{ + +}*/ int YabInterface::WindowGet(const char* view, const char* option) { @@ -7137,7 +7312,7 @@ void YabInterface::DrawSet3(const char* option, int transparency) if(yabAlpha>255) yabAlpha = 255; } } - +//Texturl modified by Lorenz Glaser (aka lorglas) 03.10.2019 void YabInterface::TextURL(double x, double y, const char* id, const char* text, const char* url, const char* view) { YabView *myView = cast_as((BView*)viewList->GetView(view), YabView); @@ -7148,9 +7323,11 @@ void YabInterface::TextURL(double x, double y, const char* id, const char* text, { w->Lock(); double h,b; + b = be_plain_font->StringWidth(text)+1; - h = be_plain_font->Size() + 1; - URLView *s = new URLView(BRect(x,y,x+b,y+h), id, text, url); + h = be_plain_font->Size(); + + URLView *s = new URLView(BRect(x,y,x+b,y+h+3), id, text, url); //Correction of Height +3 added,because text wasn't fully displayed. Lorglas s->SetHoverEnabled(true); if(w->layout == -1) s->SetResizingMode(B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM); @@ -7607,7 +7784,7 @@ void YabInterface::SpinControl(double x, double y, const char* id, const char* l if(w) { w->Lock(); - Spinner *mySpin = new Spinner(BRect(x,y,x+10,y+10), id, label, min, max, step, NULL); + Spinner *mySpin = new Spinner(BRect(x,y,x+10,y+10), id, label, min, max, step, NULL); if(w->layout == -1) mySpin->SetResizingMode(B_FOLLOW_RIGHT|B_FOLLOW_BOTTOM); else @@ -8265,10 +8442,12 @@ void YabInterface::BitmapDraw(double x, double y, const char* bitmap, const char if(w) { BBitmap *newb = new BBitmap(b->Bounds(), B_RGBA32); + char* newbits = (char*)newb->Bits(); char* oldbits = (char*)b->Bits(); for(int j=0; jBitsLength(); j++) newbits[j] = oldbits[j]; + w->Lock(); YabDrawing *t = new YabDrawing(); t->command = 10; @@ -8277,7 +8456,7 @@ void YabInterface::BitmapDraw(double x, double y, const char* bitmap, const char myView->drawList->AddItem(t); myView->Invalidate(); w->Unlock(); - return; + return; } else ErrorGen("Unable to lock window"); @@ -8458,25 +8637,25 @@ void YabInterface::BitmapDraw(BRect frame, const char* bitmap, const char* mode, } Error(bitmap, "BITMAP"); } - +//Correction added of Width and Height and transparency Pixel of the right and bottom side void YabInterface::BitmapGet(BRect frame, const char* id, const char* bitmap) { + for(int i=0; iCountItems(); i++) { 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); - BView *newbview = new BView(BRect(0,0, frame.Width(), frame.Height()), id, B_FOLLOW_NONE, 0); + BBitmap *newbmp = new BBitmap(BRect(0,0, frame.Width()-1, frame.Height()-1), B_RGBA32, true); //-1 Added, because correction of right and height limit + BView *newbview = new BView(BRect(0,0, frame.Width()-1, frame.Height()-1), id, B_FOLLOW_NONE, 0);//-1 Added, because correction of right and height limit newbmp->AddChild(newbview); newbits = (char*)newbmp->Bits(); - for(int i=0; iLock(); BRect tframe = bview->Bounds(); b->Unlock(); - if(frame.top>tframe.bottom || frame.left>tframe.right || frame.bottom>tframe.bottom || frame.right>tframe.right || frame.top<0 || frame.left<0 || frame.right<0 || frame.bottom<0) + if(frame.top>tframe.bottom || frame.left>tframe.right || (frame.bottom-1)>tframe.bottom || (frame.right-1)>tframe.right || frame.top<0 || frame.left<0 || frame.right<0 || frame.bottom<0) ErrorGen("Out of bounds"); for(int32 j = 0; jBytesPerRow()+k*4+l] = oldbits[(int32)((j+frame.top)*b->BytesPerRow()+(k+frame.left)*4+l)]; + newbits[j*newbmp->BytesPerRow()+k*4+l] = oldbits[(int32)((j+frame.top)*b->BytesPerRow()+(k+frame.left)*4+l)]; yabbitmaps->AddItem(newbmp); return; } @@ -8498,6 +8677,7 @@ void YabInterface::BitmapGet(BRect frame, const char* id, const char* bitmap) for(int i=0; iCountItems(); i++) { YabBitmapView *myView = (YabBitmapView*)yabcanvas->ItemAt(i); + if(!strcmp(myView->Name(), bitmap)) { YabWindow *w = cast_as(myView->Window(), YabWindow); @@ -8506,18 +8686,19 @@ void YabInterface::BitmapGet(BRect frame, const char* id, const char* bitmap) w->Lock(); BBitmap *b = myView->GetBitmap(); char *oldbits, *newbits; - 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); + BBitmap *newbmp = new BBitmap(BRect(0,0, frame.Width()-1, frame.Height()-1), B_RGBA32, true);//-1 Added, because correction of right and height limit + BView *newbview = new BView(BRect(0,0, frame.Width()-1, frame.Height()-1), id, B_FOLLOW_NONE, 0);//-1 Added, because correction of right and height limit newbmp->AddChild(newbview); newbits = (char*)newbmp->Bits(); - for(int i=0; iBits(); BRect tframe = myView->Bounds(); - if(frame.top>tframe.bottom || frame.left>tframe.right || frame.bottom>tframe.bottom || frame.right>tframe.right || frame.top<0 || frame.left<0 || frame.right<0 || frame.bottom<0) + if(frame.top>tframe.bottom || frame.left>tframe.right || (frame.bottom-1)>tframe.bottom || (frame.right-1)>tframe.right || frame.top<0 || frame.left<0 || frame.right<0 || frame.bottom<0) ErrorGen("Out of bounds"); for(int32 j = 0; jAddChild(bview); - + + + //memset(fBitmap->Bits(), 0, fBitmap->BitsLength()); char *b; b = (char*)fBitmap->Bits(); for(int i=0; iAddChild(bview); char *b; + //memset(fBitmap->Bits(), 0, fBitmap->BitsLength()); b = (char*)fBitmap->Bits(); for(int i=0; iAddChild(bview); char *b; + memset(fBitmap->Bits(), 0, fBitmap->BitsLength()); b = (char*)fBitmap->Bits(); for(int i=0; iAddChild(bview); - + //memset(fBitmap->Bits(), 0, fBitmap->BitsLength()); t = (char*)fBitmap->Bits(); for(int i=0; iBounds(); if(isWidth) - return r.IntegerWidth()+1; + return r.IntegerWidth(); //+1; else - return r.IntegerHeight()+1; + return r.IntegerHeight(); //+1; } } Error(id, "BITMAP"); @@ -8838,29 +9024,124 @@ void YabInterface::Canvas(BRect frame, const char* id, const char* view) } Error(view, "VIEW"); } - -int YabInterface::Sound(const char* filename) +int YabInterface::Sound(const char* filename) //Reactivate Sound Lorglas 2020.01.02 { + int soundplayer; entry_ref ref; BEntry entry(filename, true); - //printf("file '%s' \n", &filename); - + //Check, if filename is ok if (entry.InitCheck() == B_OK) if (entry.GetRef(&ref) == B_OK) - return play_sound(&ref, true, false, true); - return -1; + //delete playing fplayer, because we get no ID back from fplayer. So if we didn't deleting fplayer, a second sound will be played and the first one can't be stopped + delete fPlayer; + fPlayer = new BFileGameSound(&ref, false); + fPlayer->StartPlaying(); + soundplayer=1; + return soundplayer; } -void YabInterface::SoundStop(int32 id) +int YabInterface::SoundStop(int32 soundplayer) //Reactivate Sound Lorglas 2020.01.02 { - stop_sound(id); + //Check, if fplayer is NULL, then do nothing + if (fPlayer == NULL) { + } + //Check, if fplayer is Playing, then stop playing and delete fplayer + if (fPlayer->IsPlaying()) { + fPlayer->StopPlaying(); + delete fPlayer; + fPlayer = NULL; + soundplayer=0; + //printf("%d\n",finished); + return soundplayer; + } } -void YabInterface::SoundWait(int32 id) +int YabInterface::SoundWait(int32 soundplayer) //Reactivate Sound Lorglas 2020.01.03 +{ + //Check, if fplayr is in Paused modus, if so Setpaused to false, so play again, if true fplayer paused + if (fPlayer->IsPaused()) { + fPlayer->SetPaused(false, 2); + } + else { + fPlayer->SetPaused(true, 0); + } + soundplayer=2; + return soundplayer; +} +void play_buffer(void *cookie, void * buffer, size_t size, const media_raw_audio_format & format) { - wait_for_sound(id); -} + int64 frames = 0; + playTrack->ReadFrames(buffer, &frames); + + if (frames <=0) { + player->SetHasData(false); + + } +} +int YabInterface::MediaSound(const char* filename) //Implementation MediaSound Lorglas 2020.01.02 code used and modified from media_client +{ + BUrl url; + entry_ref ref; + BMediaFile* playFile; + int finished; + if (get_ref_for_path(filename, &ref) != B_OK) + { + url.SetUrlString(filename); + if (url.IsValid()) + { + playFile = new BMediaFile(url); + } + else + { + return 2; + } + } + else + { + playFile = new BMediaFile(&ref); + } + if (playFile->InitCheck() != B_OK) + { + delete playFile; + return 2; + } + + for (int i = 0; i < playFile->CountTracks(); i++) + { + BMediaTrack* track = playFile->TrackAt(i); + if (track != NULL) + { + playFormat.type = B_MEDIA_RAW_AUDIO; + if ((track->DecodedFormat(&playFormat) == B_OK) && (playFormat.type == B_MEDIA_RAW_AUDIO)) + { + playTrack = track; + break; + } + playFile->ReleaseTrack(track); + } + } + + player = new BSoundPlayer(&playFormat.u.raw_audio, "playFile", play_buffer); + player->SetVolume(1.0f); + player->SetHasData(true); + player->Start(); + finished=1; + //printf(" %s is playing \n",filename); + return finished; + +} +int YabInterface::MediaSoundStop(int32 finished) //New Version Sound Lorglas 2020.01.02 +{ + //Check, if fplayer is NULL, then do nothing + if (finished==1) { + player->Stop(); + delete player; + finished=0; + //printf("%d\n",finished); + return finished; + } +} void YabInterface::SetOption(const char* id, const char* option, double x, double y) { BString tmp(option); @@ -9557,6 +9838,7 @@ const char* YabInterface::GetMessageString() } } } + if(tmp.Length()>32766) tmp.Remove(32767, tmp.Length()-32766); strcpy(messagebuffer, tmp.String()); @@ -10166,6 +10448,11 @@ void yi_ToolTip(const char* view, const char* text, YabInterface *yab) yab->ToolTips(view,_L(text)); } +void yi_ToolTipNew(const char* view, const char* text,const char* color, int r, int g, int b, YabInterface *yab) +{ + yab->ToolTipsNew(view, _L(text), color, r, g, b); +} + void yi_ToolTipColor(const char* color, int r, int g, int b, YabInterface *yab) { yab->ToolTipsColor(color,r,g,b); @@ -10667,21 +10954,36 @@ void yi_Canvas(double x1, double y1, double x2, double y2, const char* id, const yab->Canvas(BRect(x1,y1,x2,y2), id,view); } -int yi_Sound(const char* filename, YabInterface* yab) +int yi_Sound(const char* filename, YabInterface* yab) //Reactivate Sound Lorglas 2020.01.02 { return yab->Sound(filename); } -void yi_SoundStop(int id, YabInterface* yab) +int yi_SoundStop(int id, YabInterface* yab) //Reactivate Sound Lorglas 2020.01.02 { - yab->SoundStop(id); + return yab->SoundStop(id); } -void yi_SoundWait(int id, YabInterface* yab) +int yi_SoundWait(int id, YabInterface* yab) //Reactivate Sound Lorglas 2020.01.03 { - yab->SoundWait(id); + return yab->SoundWait(id); } +int yi_MediaSound(const char* filename, YabInterface* yab) +{ + return yab->MediaSound(filename); +} + +int yi_MediaSoundStop(int id,YabInterface* yab) +{ + return yab->MediaSoundStop(id); +} +/* +void yi_MediaSoundWait(int id, YabInterface* yab) +{ + yab->MediaSoundWait(id); +} +*/ void yi_ShortCut(const char* view, const char* key, const char* msg, YabInterface *yab) { yab->ShortCut(view,key,msg); diff --git a/src/YabInterface.h b/src/YabInterface.h index 8c6dbd5..073706a 100644 --- a/src/YabInterface.h +++ b/src/YabInterface.h @@ -13,7 +13,7 @@ #include "YabList.h" #include "global.h" #include "config.h" - + #include class YabInterface : public BApplication { public: @@ -122,6 +122,7 @@ void CheckboxSet(const char* id, int isActivated); void RadioSet(const char* id, int isActivated); void ToolTips(const char* view, const char* text); + void ToolTipsNew(const char* view, const char* text, const char* color, int r, int g, int b); void ToolTipsColor(const char* color, int r, int g, int b); void TreeSort(const char* view); void ListSort(const char* view); @@ -215,8 +216,10 @@ int BitmapSave(const char* id, const char* filename, const char* type); void Canvas(BRect frame, const char* id, const char* view); int Sound(const char* filename); - void SoundStop(int32 id); - void SoundWait(int32 id); + int SoundStop(int32 id); + int SoundWait(int32 id); + int MediaSound(const char* filename); + int MediaSoundStop(int32 finished); int IsComputerOn(); void ShortCut(const char* view, const char* key, const char* msg); void DrawSet(const char* option, const char* color,const char* view); @@ -242,8 +245,10 @@ void StatusBarSet(BRect frame, const char* id, const char* view); void StatusBarSet(const char* id, int r, int g, int b); void RefsReceived(BMessage *message); - + private: + BFileGameSound* fPlayer; + int status; void RemoveView(BView* myView); void GetMMsgInfo(BString &t, int mouseStateInfo, int mouseLButton, int mouseMButton, int mouseRButton, int x, int y, const char* name); BBitmap* loadImage(const char* name); @@ -276,6 +281,7 @@ BList *yabbitmaps; BList *yabcanvas; BString lastMouseMsg; + }; #else typedef @@ -389,6 +395,7 @@ extern void yi_CheckboxSet(const char* id, int isActivated, YabInterface* yab); extern void yi_RadioSet(const char* id, int isActivated, YabInterface* yab); extern const char* yi_TextControlGet(const char* id, YabInterface* yab); extern void yi_ToolTip(const char* view, const char* text, YabInterface *yab); +extern void yi_ToolTipNew(const char* view, const char* text, const char* color, int r, int g, int b, YabInterface *yab); extern void yi_ToolTipColor(const char* color, int r, int g, int b, YabInterface *yab); extern void yi_TreeSort(const char* view, YabInterface *yab); extern void yi_ListSort(const char* view, YabInterface *yab); @@ -489,8 +496,10 @@ extern void yi_Screenshot(double x1, double y1, double x2, double y2, const char extern int yi_BitmapSave(const char* id, const char* filename, const char* type, YabInterface* yab); extern void yi_Canvas(double x1, double y1, double x2, double y2, const char* id, const char* view, YabInterface *yab); extern int yi_Sound(const char* filename, YabInterface* yab); -extern void yi_SoundStop(int id, YabInterface* yab); -extern void yi_SoundWait(int id, YabInterface* yab); +extern int yi_SoundStop(int id, YabInterface* yab); +extern int yi_SoundWait(int id, YabInterface* yab); +extern int yi_MediaSound(const char* filename, YabInterface* yab); +extern int yi_MediaSoundStop(int id, YabInterface* yab); extern int yi_IsComputerOn(YabInterface* yab); extern void yi_ShortCut(const char* view, const char* key, const char* msg, YabInterface* yab); extern void yi_DrawSet4(const char* option, const char* color,const char* view, YabInterface* yab); diff --git a/src/YabList.cpp b/src/YabList.cpp index 72b31fa..4216175 100644 --- a/src/YabList.cpp +++ b/src/YabList.cpp @@ -87,6 +87,6 @@ void YabList::PrintOut() { printf("\n"); for(int i=0; iCountItems(); i++) - printf("\t%s\n", ((BString*)(idList->ItemAt(i)))->String() ); + printf("\t View %s and the id %d %d \n", ((BString*)(idList->ItemAt(i)))->String() , idList->ItemAt(i), viewList->ItemAt(i)); printf("\n"); } diff --git a/src/YabList.h b/src/YabList.h index e2c1740..e56cf76 100644 --- a/src/YabList.h +++ b/src/YabList.h @@ -17,6 +17,7 @@ public: const int CountItems(); const void* ItemAt(int i); void PrintOut(); + private: int ViewNum(const char* id); BList* idList; diff --git a/src/YabTabView.cpp b/src/YabTabView.cpp index bb8db3c..06a5a0d 100644 --- a/src/YabTabView.cpp +++ b/src/YabTabView.cpp @@ -35,6 +35,7 @@ #include #include "YabTabView.h" + YabTabView::YabTabView(BRect frame, const char* name, button_width width, uint32 resizingMode, uint32 flags) : BTabView(frame, name, width, resizingMode, flags) { @@ -68,6 +69,7 @@ void YabTabView::AddTab(BView *tabView, const char* label) tabView->Hide(); fTabNames->AddItem(new BString(label)); + } } @@ -111,6 +113,60 @@ void YabTabView::SetFocusTab(int32 tab, bool focused) BTabView::SetFocusTab(tab, focused); } +void YabTabView::RemovingTab(int32 index) +{ + BTabView::RemoveTab(index); +} +/* +void YabTabView::RemovingTab(int32 index, bool focused) +{ + int oldindex=index; + int index_a; + int tab; + if (index < 0 || index >= CountTabs()) + return NULL; + BTab* tab = (BTab*)fTabNames->RemoveItem(index); + if (tab==NULL) + return NULL; + + tab->Deselect(); + BTab::Private(tab).SetTabView(Null); + if (fContainerView->GetLayout()) + fContainerView->GetLayout()->RemoveItem(index); + if (CountTabs()==0) + fFocus = -1; + else if (index <= fSelection) + Select (fSelection-1); + if (fFocus >=0) { + if(fFocus == CountTabs() -1 || CountTabs() == 0) + BTabView::Select(f.Focus, false); + else + BTabView::Select(f.Focus, true); + } + return tab; + BTabView::RemoveTab(oldindex); + BTabView::Select(1); + + + BTab* tab = TabAt(index); + if (tab) + { + FocusChanged = index; + } + + int32 prevSelected = 1; //Selection(); + RemoveChild(tab->View()); + tab->View()->Show(); + BTabView::Select(index); + if(prevSelected > -1) { + BTab* prevTab = TabAt(prevSelected); //prevSelected); + prevTab->View()->Hide(); + AddChild(prevTab->View()); + } +} + */ + + const char* YabTabView::GetTabName(int32 index) const { if(index < 0 || index >= CountTabs()) @@ -118,3 +174,46 @@ const char* YabTabView::GetTabName(int32 index) const return ((BString*)fTabNames->ItemAt(index))->String(); } +void YabTabView::PrintOut() +{ + //printf("\n %d",fTabNames->CountItems()); + if (fTabNames->CountItems()==0) + { + } + else if(fTabNames->CountItems()>0) + { + printf("\n"); + for(int i=0; iCountItems(); i++) + printf("\t View %s and the id %d\n", ((BString*)(fTabNames->ItemAt(i)))->String() , fTabNames->ItemAt(i)); + printf("\n"); + } +} +void YabTabView::FindTabName(const char* tabname ) +{ + BString test = NULL; + //printf("\n %d",fTabNames->CountItems()); + if (fTabNames->CountItems()<=0) + { + //return NULL; + } + else if(fTabNames->CountItems()>0) + { + //printf("%s \n", tabname); + for(int i=0; iCountItems(); i++) + { + printf("%s\n", ((BString*)(fTabNames->ItemAt(i)))->String()); + test=((BString*)(fTabNames->ItemAt(i)))->String(); + + if (test == tabname) + { + //printf("stimmt"); + printf("%s %d",test,i ); + printf("\n"); + //return tabname; + //return true; + } + } + //printf("\n"); + } +} + diff --git a/src/YabTabView.h b/src/YabTabView.h index ff49be0..89cfe58 100644 --- a/src/YabTabView.h +++ b/src/YabTabView.h @@ -46,19 +46,27 @@ public: B_FRAME_EVENTS | B_NAVIGABLE); ~YabTabView(); -virtual const char* GetTabName(int32 index) const; +virtual const char* GetTabName(int32 index) const; virtual void AddTab(BView *target, const char* tabname); - -virtual void Select(int32 index); -virtual void MakeFocus(bool focused = true); -virtual void SetFocusTab(int32 tab, bool focused); - +virtual void Select(int32 index); +virtual void MakeFocus(bool focused = true); +virtual void RemovingTab(int32 index); +virtual void SetFocusTab(int32 tab, bool focused); + void PrintOut(); + void FindTabName(const char* tabname); int32 FocusChanged; int32 OldTabView; +//void MoveTab(int32 index, int32 newIndex); private: BList *fTabNames; + + int32 fSelection; + int32 fInitialSelection; + int32 fFocus; + + }; //------------------------------------------------------------------------------ diff --git a/src/YabWindow.cpp b/src/YabWindow.cpp index e23873c..8e839be 100644 --- a/src/YabWindow.cpp +++ b/src/YabWindow.cpp @@ -36,6 +36,7 @@ const uint32 YABFILEBOXINVOKE = 'YBfi'; const uint32 YABSPINCONTROL = 'YBsp'; const uint32 YABSHORTCUT = 'YBsh'; + YabWindow::YabWindow(BRect frame, const char* title, const char* id, window_look winlook, window_feel winfeel, uint32 flags) : BWindow (frame, title, winlook, winfeel, flags) { diff --git a/src/config.h b/src/config.h index b914423..19c3c09 100644 --- a/src/config.h +++ b/src/config.h @@ -5,7 +5,7 @@ // #define LIBBSVG #define BUILD_TIME __DATE__ /* Version number of package */ -#define VERSION "1.7.6.0" +#define VERSION "1.7.8" /* architecture of build machine */ #define UNIX_ARCHITECTURE "BePC-Haiku" diff --git a/src/function.c b/src/function.c index cfcf6b6..8b341d5 100644 --- a/src/function.c +++ b/src/function.c @@ -1005,6 +1005,11 @@ void function(struct command *current,YabInterface* yab) /* performs a function value = sound(str, yab, linenum, current->lib->s); result = stNUMBER; break; + case fMEDIASOUND: + str=a1->pointer; + value = mediasound(str, yab, linenum, current->lib->s); + result = stNUMBER; + break; case fTREEBOXGETOPT: str=a1->pointer; str2=a2->pointer; diff --git a/src/graphic.c b/src/graphic.c index 82f508a..70c9215 100644 --- a/src/graphic.c +++ b/src/graphic.c @@ -1341,7 +1341,24 @@ void tooltip(struct command *cmd, YabInterface *yab) yi_SetCurrentLineNumber(cmd->line, (const char*)cmd->lib->s, yab); yi_ToolTip(view,text,yab); } - +void tooltipnew(struct command *cmd, YabInterface *yab) +{ + char *view, *text, *color; + int r,g,b; + + b = pop(stNUMBER)->value; + g = pop(stNUMBER)->value; + r = pop(stNUMBER)->value; + + color = pop(stSTRING)->pointer; + text = pop(stSTRING)->pointer; + view = pop(stSTRING)->pointer; + + + + yi_SetCurrentLineNumber(cmd->line, (const char*)cmd->lib->s, yab); + yi_ToolTipNew(view,text,color,r,g,b,yab); +} void tooltipcolor(struct command *cmd, YabInterface *yab) { char *color; @@ -2431,6 +2448,21 @@ void soundwait(struct command *cmd, YabInterface *yab) yi_SoundWait(id, yab); } +int mediasound(const char* filename, YabInterface *yab, int line, const char* libname) +{ + yi_SetCurrentLineNumber(line, libname, yab); + return yi_MediaSound(filename, yab); +} + +void mediasoundstop(struct command *cmd, YabInterface *yab) +{ + int id; + + id = pop(stNUMBER)->value; + + yi_SetCurrentLineNumber(cmd->line, (const char*)cmd->lib->s, yab); + yi_MediaSoundStop(id, yab); +} int iscomputeron(YabInterface *yab, int line, const char* libname) { yi_SetCurrentLineNumber(line, libname, yab); diff --git a/src/libyab1.so b/src/libyab1.so new file mode 100755 index 0000000..7539119 Binary files /dev/null and b/src/libyab1.so differ diff --git a/src/main.c b/src/main.c index 658ec1b..0d54a7f 100644 --- a/src/main.c +++ b/src/main.c @@ -26,7 +26,7 @@ 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\tyab improvements Copyright 2018 by BeSly Software Solutions (Thanks to Stephan Aßmus for Correction of Code)\n" +#define COPYRIGHT " Original yabasic Copyright 1995-2006 by Marc-Oliver Ihm\n\tyab Copyright 2006-2014 by Jan Bungeroth\n\tyab improvements Copyright 2013-2020 by Jim Saxton\n\tyab improvements Copyright 2018-2020 by BeSly Software Solutions\n\t\t(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 ", built on "\ ARCHITECTURE " on " BUILD_TIME "\n\n " COPYRIGHT "\n\n" @@ -1499,6 +1499,8 @@ static void run_it(YabInterface* yab) radioset(current, yab); DONE; case cTOOLTIP: tooltip(current, yab); DONE; + case cTOOLTIPNEW: + tooltipnew(current, yab); DONE; case cTOOLTIPCOLOR: tooltipcolor(current, yab); DONE; case cFILEBOX: @@ -1563,6 +1565,8 @@ static void run_it(YabInterface* yab) soundstop(current, yab); DONE; case cSOUNDWAIT: soundwait(current, yab); DONE; + case cMEDIASOUNDSTOP: + mediasoundstop(current, yab); DONE; case cSHORTCUT: shortcut(current, yab); DONE; case cTREEBOX13: diff --git a/src/yabasic.bison b/src/yabasic.bison index ea8f827..d19f24c 100644 --- a/src/yabasic.bison +++ b/src/yabasic.bison @@ -113,9 +113,9 @@ void report_missing(int severity,char *text) { %token tBUTTON tALERT tMENU tCHECKBOX tRADIOBUTTON tTEXTCONTROL %token tLISTBOX tDROPBOX tADD tREMOVE tLOCALIZE tFILEPANEL tSLIDER tSTATUSBAR %token tLAYOUT tSET tTEXTEDIT tCOUNT tVIEW tBOXVIEW tTABVIEW tTEXTURL tBITMAP tCANVAS -%token tOPTION tDROPZONE tCOLORCONTROL tTREEBOX tCOLUMNBOX tCOLUMN tSORT tTOOLTIP tCALENDAR +%token tOPTION tDROPZONE tCOLORCONTROL tTREEBOX tCOLUMNBOX tCOLUMN tSORT tTOOLTIP tTOOLTIPNEW tCALENDAR %token tCLIPBOARD tCOPY tSUBMENU tSELECT tSCROLLBAR tEXPAND tCOLLAPSE tSPLITVIEW tSTACKVIEW -%token tPOPUPMENU tSPINCONTROL tMSEND tNUMMESSAGE tTHREAD tSOUND tPLAY tSTOP tSHORTCUT tISCOMPUTERON +%token tPOPUPMENU tSPINCONTROL tMSEND tNUMMESSAGE tTHREAD tSOUND tPLAY tSTOP tMEDIASOUND tSHORTCUT tISCOMPUTERON %token tDRAW tTEXT tFLUSH tELLIPSE tSAVE %token tRECT tGETCHAR tPUTCHAR tNEW tCURVE tLAUNCH tATTRIBUTE @@ -326,6 +326,7 @@ statement: /* empty */ | tCHECKBOX tSET string_expression ',' expression {add_command(cCHECKBOXSET,NULL);} | tRADIOBUTTON tSET string_expression ',' expression {add_command(cRADIOSET,NULL);} | tTOOLTIP string_expression ',' string_expression {add_command(cTOOLTIP,NULL);} + | tTOOLTIPNEW string_expression ',' string_expression ',' string_expression ',' expression ',' expression ',' expression {add_command(cTOOLTIPNEW,NULL);} | tTOOLTIP tCOLOUR string_expression ',' expression ',' expression ',' expression {add_command(cTOOLTIPCOLOR,NULL);} | tLISTBOX tSORT string_expression {add_command(cLISTSORT,NULL);} | tTREEBOX tSORT string_expression {add_command(cTREESORT,NULL);} @@ -359,7 +360,9 @@ statement: /* empty */ | tSOUND tSTOP expression {add_command(cSOUNDSTOP,NULL);} | tSOUND tSTOP '(' expression ')' {add_command(cSOUNDSTOP,NULL);} | tSOUND tWAIT expression {add_command(cSOUNDWAIT,NULL);} - | tSOUND tWAIT '(' expression ')' {add_command(cSOUNDWAIT,NULL);} + | tSOUND tWAIT '(' expression ')' {add_command(cSOUNDWAIT,NULL);} + | tMEDIASOUND tSTOP expression {add_command(cMEDIASOUNDSTOP,NULL);} + | tMEDIASOUND tSTOP '(' expression ')' {add_command(cMEDIASOUNDSTOP,NULL);} | tSPLITVIEW coordinates to coordinates ',' string_expression ',' expression ',' expression ',' string_expression {add_command(cSPLITVIEW1,NULL);} | tSPLITVIEW tSET string_expression ',' string_expression ',' expression {add_command(cSPLITVIEW2,NULL);} | tSPLITVIEW tSET string_expression ',' string_expression ',' expression ',' expression {add_command(cSPLITVIEW3,NULL);} @@ -628,6 +631,7 @@ function: tSIN '(' expression ')' {create_function(fSIN);} | tTHREAD tGETNUM string_expression ',' string_expression {create_function(fTHREADGET);} | tPRINTER string_expression ',' string_expression ',' string_expression {create_function(fPRINTER);} | tSOUND tPLAY string_expression {create_function(fSOUND);} + | tMEDIASOUND tPLAY string_expression {create_function(fMEDIASOUND);} | tISCOMPUTERON {create_function(fISCOMPUTERON);} | tLISTBOX tGETNUM string_expression {create_function(fLISTBOXGETNUM);} | tDROPBOX tGETNUM string_expression {create_function(fDROPBOXGETNUM);} diff --git a/src/yabasic.flex b/src/yabasic.flex index 83bcf50..e74b317 100644 --- a/src/yabasic.flex +++ b/src/yabasic.flex @@ -223,6 +223,7 @@ COLORCONTROL return tCOLORCONTROL; TREEBOX return tTREEBOX; SORT return tSORT; TOOLTIP return tTOOLTIP; +TOOLTIPNEW return tTOOLTIPNEW; COLUMNBOX return tCOLUMNBOX; COLUMN return tCOLUMN; CLIPBOARD return tCLIPBOARD; @@ -235,6 +236,7 @@ SCROLLBAR return tSCROLLBAR; COLLAPSE return tCOLLAPSE; EXPAND return tEXPAND; SOUND return tSOUND; +MEDIASOUND return tMEDIASOUND; PLAY return tPLAY; STOP return tSTOP; SPLITVIEW return tSPLITVIEW; diff --git a/src/yabasic.h b/src/yabasic.h index eeed614..471529e 100644 --- a/src/yabasic.h +++ b/src/yabasic.h @@ -300,7 +300,7 @@ enum functions { /* functions in yabasic (sorted by number of arguments) */ fLTRIM,fRTRIM,fTRIM,fCHR,fTRANSLATE,fMENUTRANSLATE,fMOUSE, fISMOUSEIN,fTEXTCONTROLGET, fKEYBOARD,fCOLUMNBOXCOUNT, fCALENDAR, fLISTBOXCOUNT, fTREEBOXCOUNT, fSTACKVIEWGET, fSPINCONTROLGET, fDROPBOXCOUNT, fSLIDERGET, fTEXTGET, fDRAWGET3, fTABVIEWGET, - fLISTBOXGETNUM, fDROPBOXGETNUM, fCOLUMNBOXGETNUM, fTREEBOXGETNUM, fSOUND, + fLISTBOXGETNUM, fDROPBOXGETNUM, fCOLUMNBOXGETNUM, fTREEBOXGETNUM, fSOUND, fMEDIASOUND, fONEARGS, fDEC2,fATAN2,fLEFT,fAND,fOR,fEOR,fLOG2, fRIGHT,fINSTR,fRINSTR,fSTR2,fMOD,fMIN,fMAX,fPEEK3,fMID2,fWINDOWGET, fVIEWGET /* vasper */, @@ -378,7 +378,7 @@ enum cmd_type { /* type of command */ cVIEW, cBOXVIEW, cBOXVIEWSET, cTAB, cSLIDER1, cSLIDER2, cSLIDER3, cSLIDER4, cSLIDER5, cSLIDER6, cOPTION1, cOPTION2, cOPTION3, cDROPZONE, cTEXTCONTROL2, cTEXTCONTROL3, cTEXTCONTROL4, cTEXTCONTROL5, cCOLORCONTROL1, cCOLORCONTROL2, cTREEBOX1, cTREEBOX2, cTREEBOX3, cTREEBOX4, cTREEBOX5, - cBUTTONIMAGE, cCHECKBOXIMAGE, cCHECKBOXSET, cRADIOSET, cTOOLTIP, cTOOLTIPCOLOR, cTREESORT, + cBUTTONIMAGE, cCHECKBOXIMAGE, cCHECKBOXSET, cRADIOSET, cTOOLTIP, cTOOLTIPNEW, cTOOLTIPCOLOR, cTREESORT, cLISTSORT, cFILEBOX, cFILEBOXADD2, cFILEBOXCLEAR, cCOLUMNBOXREMOVE, cCOLUMNBOXSELECT, cCOLUMNBOXADD, cDROPBOXSELECT, cMENU2, cSUBMENU1, cSUBMENU2, cCLIPBOARDCOPY, cCOLUMNBOXCOLOR, cPRINTERCONFIG, cCALENDAR, cLISTBOXSELECT, cLISTBOXADD1, cLISTBOXADD2, @@ -389,7 +389,7 @@ enum cmd_type { /* type of command */ cDOT, cLINE, cCIRCLE, cDRAWTEXT, cDRAWRECT, cTREEBOX12, cOPTION4, cOPTION5, cDRAWCLEAR, cDRAWSET1, cDRAWSET2, cELLIPSE, cCURVE, /* Drawing */ cBITMAP, cBITMAPDRAW, cBITMAPDRAW2, cBITMAPGET, cBITMAPGET2, cBITMAPGETICON, cBITMAPDRAG, cBITMAPREMOVE, cCANVAS, /* Bitmaps */ - cSOUNDSTOP, cSOUNDWAIT, /* Sound */ + cSOUNDSTOP, cSOUNDWAIT, cMEDIASOUNDSTOP, /* Sound */ cTREEBOX13, cDRAWSET4, cSHORTCUT, cMOUSESET, cSCREENSHOT, cSTATUSBAR, cSTATUSBARSET, cSTATUSBARSET2, cSTATUSBARSET3, cLAUNCH, cRESTORE2, cRESTORE3, cATTRIBUTE1, cATTRIBUTE2, cATTRIBUTECLEAR, @@ -657,6 +657,7 @@ void checkboximage(struct command *, YabInterface *yab); void checkboxset(struct command *, YabInterface *yab); void radioset(struct command *, YabInterface *yab); void tooltip(struct command *, YabInterface *yab); +void tooltipnew(struct command *, YabInterface *yab); void tooltipcolor(struct command *, YabInterface *yab); void listsort(struct command *, YabInterface *yab); void treesort(struct command *, YabInterface *yab); @@ -758,6 +759,8 @@ void drawset4(struct command *, YabInterface *yab); int sound(const char*, YabInterface *yab, int line, const char* libname); void soundstop(struct command *, YabInterface *yab); void soundwait(struct command *, YabInterface *yab); +int mediasound(const char*, YabInterface *yab, int line, const char* libname); +void mediasoundstop(struct command *, YabInterface *yab); void shortcut(struct command *, YabInterface *yab); int iscomputeron(YabInterface *yab, int line, const char* libname); void mouseset(struct command *, YabInterface *yab); diff --git a/yab-IDE/BuildFactory/AutoHeader.mak b/yab-IDE/BuildFactory/AutoHeader.mak index 77a9877..007ac53 100644 --- a/yab-IDE/BuildFactory/AutoHeader.mak +++ b/yab-IDE/BuildFactory/AutoHeader.mak @@ -36,5 +36,5 @@ OPT = -O LIBPATHS = $(shell findpaths B_FIND_PATH_DEVELOP_LIB_DIRECTORY) LIBPATH=$(addprefix -L,$(LIBPATHS)) -LIB = -lyab -lbe -lroot -ltranslation -ltracker -lmedia -lz +LIB = -lyab1 -lbe -lroot -ltranslation -ltracker -lmedia -lz