// // The author of this software is abiSoft. Inc. // Copyright (c) 1998 abiSoft. Inc. // Permission to use, copy, modify, and distribute this software for any // purpose without fee is hereby granted, provided that this entire notice // is included in all copies of any software which is or includes a copy // or modification of this software and in all copies of the supporting // documentation for such software. // THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED // WARRANTY. IN PARTICULAR, THE AUTHOR DOES NOT MAKE ANY // REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY // OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. // #pragma once on #include "abisoftButtonBox.h" abisoftButtonBox::abisoftButtonBox(BRect arect, char *name, uint32 Position, ButtonStruct *buttonArray, int32 Nel, orientation orient) :BView (arect, "MyButtonButtonBox", Position, B_NAVIGABLE ) { BRect rect = arect; rect.OffsetTo(B_ORIGIN); BView *box = new BView (rect, "buttonBox", Position, B_NAVIGABLE); float buttonWidth = rect.Width(); float buttonHeight = rect.Height(); if (orient == B_HORIZONTAL) buttonWidth /= Nel; else buttonHeight /= Nel; BRect arrowBox(0.0, 0.0, buttonWidth, buttonHeight); nelButtons = Nel; char buf[128]; arrowButton = new abisoftButton * [Nel]; for (int32 i = 0; i < Nel; i++) { sprintf(buf, "%s%d", name, i); arrowButton[i] = new abisoftButton(arrowBox, buf, buttonArray[i].what, buttonArray[i].type, buttonArray[i].argc, buttonArray[i].labels, buttonArray[i].pictureName, buttonArray[i].argc2, buttonArray[i].togglelabels, buttonArray[i].picture2Name); if (buttonArray[i].type == A_TWO_STRING) { box->AddChild(arrowButton[i]->toggleButton); arrowButton[i]->toggleButton->Hide(); } box->AddChild(arrowButton[i]); if (orient == B_HORIZONTAL) arrowBox.OffsetBy(buttonWidth, 0); else arrowBox.OffsetBy(0, buttonHeight); } AddChild(box); } abisoftButtonBox::~abisoftButtonBox() { for (int32 i = 0; i < nelButtons; i++) delete arrowButton[i]; delete [] arrowButton; } void abisoftButtonBox::SetLabelFonts(BFont *fontarray) { for (int32 i = 0; i < nelButtons; i++) arrowButton[i]->SetLabelFont(fontarray[i]); } void abisoftButtonBox::SetALabelFont(int32 buttonNo, BFont& font) { if (buttonNo < nelButtons) arrowButton[buttonNo]->SetLabelFont(font); } void abisoftButtonBox::SetAFontSize(int32 arrowNo, float newfSize) { if (arrowNo < nelButtons && arrowNo > -1) { arrowButton[arrowNo]->SetLabelFontSize(newfSize); } } void abisoftButtonBox::SetFontSizes(float newfSizeArray[]) { for (int32 i = 0; i < nelButtons; i++) arrowButton[i]->SetLabelFontSize(newfSizeArray[i]); } void abisoftButtonBox::SetBackgroundColor(int32 arrowNo, rgb_color color) { if (arrowNo < nelButtons + 1 && arrowNo > 0) arrowButton[arrowNo -1]->SetBackgroundColor(color); } void abisoftButtonBox::GetBackgroundColors(rgb_color colorArray[]) { for (int32 i = 0; i < nelButtons; i++) arrowButton[i]->GetBackgroundColor(&colorArray[i]); } void abisoftButtonBox::SetBackgroundColors(const char *array[]) { for (int32 i = 0; i < nelButtons; i++) arrowButton[i]->SetBackgroundColor(BeRgbColorFromName(array[i])); } void abisoftButtonBox::SetABackgroundColor(rgb_color nColor, int32 buttonNo) { if (buttonNo < nelButtons) arrowButton[buttonNo]->SetBackgroundColor(nColor); } void abisoftButtonBox::SetBackgroundColors(rgb_color colorArray[]) { for (int32 i = 0; i < nelButtons; i++) { arrowButton[i]->SetBackgroundColor(colorArray[i]); } }