diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..986367c --- /dev/null +++ b/.clang-format @@ -0,0 +1,237 @@ +--- +Language: Cpp + # BasedOnStyle: LLVM +AccessModifierOffset: -2 +AlignAfterOpenBracket: BlockIndent +AlignArrayOfStructures: None +AlignConsecutiveAssignments: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: true +AlignConsecutiveBitFields: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveDeclarations: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveMacros: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCompound: false + PadOperators: false +AlignConsecutiveShortCaseStatements: + Enabled: false + AcrossEmptyLines: false + AcrossComments: false + AlignCaseColons: false +AlignEscapedNewlines: Right +AlignOperands: Align +AlignTrailingComments: + Kind: Always + OverEmptyLines: 0 +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: TopLevel +AlwaysBreakAfterReturnType: TopLevel +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +AttributeMacros: + - __capability +BinPackArguments: true +BinPackParameters: true +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterExternBlock: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAfterAttributes: Always +BreakAfterJavaFieldAnnotations: false +BreakArrays: true +BreakBeforeBinaryOperators: None +BreakBeforeConceptDeclarations: Always +BreakBeforeBraces: Mozilla +BreakBeforeInlineASMColon: OnlyMultiline +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +ColumnLimit: 100 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: LogicalBlock +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: false +IndentExternBlock: AfterExternBlock +IndentGotoLabels: true +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertBraces: false +InsertNewlineAtEOF: false +InsertTrailingCommas: None +IntegerLiteralSeparator: + Binary: 0 + BinaryMinDigits: 0 + Decimal: 0 + DecimalMinDigits: 0 + Hex: 0 + HexMinDigits: 0 +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +KeepEmptyLinesAtEOF: false +LambdaBodyIndentation: Signature +LineEnding: DeriveLF +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PackConstructorInitializers: BinPack +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakOpenParenthesis: 0 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyIndentedWhitespace: 0 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +PPIndentWidth: -1 +QualifierAlignment: Leave +ReferenceAlignment: Pointer +ReflowComments: true +RemoveBracesLLVM: false +RemoveParentheses: Leave +RemoveSemicolon: false +RequiresClausePosition: OwnLine +RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Always +ShortNamespaceLines: 1 +SortIncludes: false +SortJavaStaticImport: Before +SortUsingDeclarations: LexicographicNumeric +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeJsonColon: false +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + AfterRequiresInClause: false + AfterRequiresInExpression: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: Never +SpacesInContainerLiterals: true +SpacesInLineCommentPrefix: + Minimum: 1 + Maximum: -1 +SpacesInParens: Never +SpacesInParensOptions: + InCStyleCasts: false + InConditionalStatements: false + InEmptyParentheses: false + Other: false +SpacesInSquareBrackets: false +Standard: Latest +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 4 +UseTab: Always +VerilogBreakBetweenInstancePorts: true +WhitespaceSensitiveMacros: + - BOOST_PP_STRINGIZE + - CF_SWIFT_NAME + - NS_SWIFT_NAME + - PP_STRINGIZE + - STRINGIZE +... + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..af31adc --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +*.o + +Becasso +source/add-ons/AutoContrast/AutoContrast +source/add-ons/Blur/Blur +source/add-ons/Brightness/Brightness +source/add-ons/BumpMap/BumpMap +source/add-ons/CaptureTest/CaptureTest +source/add-ons/Chromakey/Chromakey +source/add-ons/ColorCurves/ColorCurves +source/add-ons/Diffuse/Diffuse +source/add-ons/Gaussian/Gaussian +source/add-ons/Gradient/Gradient +source/add-ons/Mandelbrot/Mandelbrot +source/add-ons/MotionBlur/MotionBlur +source/add-ons/Negate/Negate +source/add-ons/Noise/Noise +source/add-ons/OilPaint/OilPaint +source/add-ons/Quantize/Quantize +source/add-ons/Ripple/Ripple +source/add-ons/Scale/Scale +source/add-ons/Sepia/Sepia +source/add-ons/Solarize/Solarize +source/add-ons/Tile/Tile +source/add-ons/VideoGrabber/VideoGrabber +source/add-ons/Wave/Wave +source/add-ons/WinGrab/WinGrab + diff --git a/source/AboutView.cpp b/source/AboutView.cpp index 0da560a..fc46309 100644 --- a/source/AboutView.cpp +++ b/source/AboutView.cpp @@ -5,93 +5,92 @@ #include #include "Settings.h" -SAboutView::SAboutView (BRect rect, BBitmap *becasso, BBitmap *sum, bool startup) -: BView (rect, "SAboutView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) +SAboutView::SAboutView(BRect rect, BBitmap* becasso, BBitmap* sum, bool startup) + : BView(rect, "SAboutView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) { fBecasso = becasso; fSum = sum; - SetViewColor (Grey28); + SetViewColor(Grey28); fStartup = startup; fAddOnString[0] = 0; url = NULL; doc = NULL; - if (!startup) - { - url = new BButton (BRect (126, 178, 196, 196), "url", lstring (1, "URL"), new BMessage ('aURL')); - doc = new BButton (BRect (204, 178, 274, 196), "doc", lstring (2, "Manual"), new BMessage ('aDOC')); - url->SetTarget (be_app); - doc->SetTarget (be_app); - AddChild (url); - AddChild (doc); + if (!startup) { + url = + new BButton(BRect(126, 178, 196, 196), "url", lstring(1, "URL"), new BMessage('aURL')); + doc = new BButton( + BRect(204, 178, 274, 196), "doc", lstring(2, "Manual"), new BMessage('aDOC') + ); + url->SetTarget(be_app); + doc->SetTarget(be_app); + AddChild(url); + AddChild(doc); } } -SAboutView::~SAboutView () +SAboutView::~SAboutView() { delete fBecasso; delete fSum; } -void SAboutView::Draw (BRect updateRect) +void +SAboutView::Draw(BRect updateRect) { - if (updateRect != BRect (85, 170, 250, 195)) - { + if (updateRect != BRect(85, 170, 250, 195)) { if (fBecasso) - DrawBitmap (fBecasso, BPoint (25, 10)); + DrawBitmap(fBecasso, BPoint(25, 10)); if (fSum) - DrawBitmap (fSum, BPoint (10, 115)); - SetLowColor (Grey28); - SetHighColor (Grey8); + DrawBitmap(fSum, BPoint(10, 115)); + SetLowColor(Grey28); + SetHighColor(Grey8); char verstring[80]; - extern const char *Version; + extern const char* Version; extern int gGlobalAlpha; extern char gAlphaMask[128]; - SetFontSize (13); - sprintf (verstring, lstring (3, "Version %s, built %s"), Version, __DATE__); - // sprintf (verstring, "MacWorld Demo Version"); - DrawString (verstring, BPoint (85, 124)); - SetFontSize (11); - DrawString ("© 1997-2001 ∑ Sum Software", BPoint (85, 138)); - if (!gGlobalAlpha) - { - SetHighColor (Red); - SetFontSize (13); - DrawString (lstring (4, "Unregistered Version"), BPoint (85, 155)); + SetFontSize(13); + sprintf(verstring, lstring(3, "Version %s, built %s"), Version, __DATE__); + // sprintf (verstring, "MacWorld Demo Version"); + DrawString(verstring, BPoint(85, 124)); + SetFontSize(11); + DrawString("© 1997-2001 ∑ Sum Software", BPoint(85, 138)); + if (!gGlobalAlpha) { + SetHighColor(Red); + SetFontSize(13); + DrawString(lstring(4, "Unregistered Version"), BPoint(85, 155)); + } else { + SetHighColor(Grey8); +#if defined(__HAIKU__) + DrawString("Released under the MIT license", BPoint(85, 152)); +#else + DrawString(lstring(7, "Registered to"), BPoint(85, 152)); + SetHighColor(Black); + SetFontSize(12); + DrawString(gAlphaMask, BPoint(85, 168)); +#endif } - else - { - SetHighColor (Grey8); - #if defined(__HAIKU__) - DrawString ("Released under the MIT license", BPoint (85, 152)); - #else - DrawString (lstring (7, "Registered to"), BPoint (85, 152)); - SetHighColor (Black); - SetFontSize (12); - DrawString (gAlphaMask, BPoint (85, 168)); - #endif - } - // DrawString ("Add-On developers beta version", BPoint (85, 158)); - // DrawString ("This is a ", BPoint (85, 158)); - // SetHighColor (Red); - // DrawString ("time limited"); - // SetHighColor (Grey8); - // DrawString (" demo that will"); - // DrawString ("stop working on January 1st, 1998", BPoint (85, 172)); + // DrawString ("Add-On developers beta version", BPoint (85, 158)); + // DrawString ("This is a ", BPoint (85, 158)); + // SetHighColor (Red); + // DrawString ("time limited"); + // SetHighColor (Grey8); + // DrawString (" demo that will"); + // DrawString ("stop working on January 1st, 1998", BPoint (85, 172)); } - if (fStartup) - { - SetLowColor (Grey28); - SetHighColor (Grey8); - SetFontSize (12); - DrawString (lstring (5, "Initializing Add-Ons:"), BPoint (85, 182)); - SetFontSize (11); - DrawString (fAddOnString, BPoint (85, 194)); + if (fStartup) { + SetLowColor(Grey28); + SetHighColor(Grey8); + SetFontSize(12); + DrawString(lstring(5, "Initializing Add-Ons:"), BPoint(85, 182)); + SetFontSize(11); + DrawString(fAddOnString, BPoint(85, 194)); } } -void SAboutView::SetInitString (const char *s) +void +SAboutView::SetInitString(const char* s) { - strcpy (fAddOnString, s); -// printf ("Set to %s\n", s); - Invalidate (BRect (85, 170, 250, 195)); + strcpy(fAddOnString, s); + // printf ("Set to %s\n", s); + Invalidate(BRect(85, 170, 250, 195)); } diff --git a/source/AboutView.h b/source/AboutView.h index a081761..02df68a 100644 --- a/source/AboutView.h +++ b/source/AboutView.h @@ -7,19 +7,19 @@ class SAboutView : public BView { -public: - SAboutView (BRect rect, BBitmap *becasso, BBitmap *sum, bool startup = false); -virtual ~SAboutView (); -virtual void Draw (BRect updateRect); -virtual void SetInitString (const char *s); + public: + SAboutView(BRect rect, BBitmap* becasso, BBitmap* sum, bool startup = false); + virtual ~SAboutView(); + virtual void Draw(BRect updateRect); + virtual void SetInitString(const char* s); -private: -typedef BView inherited; -BBitmap *fBecasso; -BBitmap *fSum; -bool fStartup; -BButton *url, *doc; -char fAddOnString[256]; + private: + typedef BView inherited; + BBitmap* fBecasso; + BBitmap* fSum; + bool fStartup; + BButton *url, *doc; + char fAddOnString[256]; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AboutWindow.cpp b/source/AboutWindow.cpp index 12e63af..4e2e09f 100644 --- a/source/AboutWindow.cpp +++ b/source/AboutWindow.cpp @@ -2,23 +2,21 @@ #include "Becasso.h" #include "Settings.h" -AboutWindow::AboutWindow (BRect rect) -: BWindow (rect, lstring (0, "About Becasso"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) +AboutWindow::AboutWindow(BRect rect) + : BWindow(rect, lstring(0, "About Becasso"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) { } -AboutWindow::~AboutWindow () -{ -} +AboutWindow::~AboutWindow() {} -void AboutWindow::MessageReceived (BMessage *msg) +void +AboutWindow::MessageReceived(BMessage* msg) { -// printf ("Huh?!\n"); - switch (msg->what) - { + // printf ("Huh?!\n"); + switch (msg->what) { default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AboutWindow.h b/source/AboutWindow.h index 34f69cd..3653b50 100644 --- a/source/AboutWindow.h +++ b/source/AboutWindow.h @@ -5,12 +5,13 @@ class AboutWindow : public BWindow { -public: - AboutWindow (BRect rect); -virtual ~AboutWindow (); -virtual void MessageReceived (BMessage *msg); -private: -typedef BWindow inherited; + public: + AboutWindow(BRect rect); + virtual ~AboutWindow(); + virtual void MessageReceived(BMessage* msg); + + private: + typedef BWindow inherited; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AddOn.cpp b/source/AddOn.cpp index 9be666b..1ec1a74 100644 --- a/source/AddOn.cpp +++ b/source/AddOn.cpp @@ -6,253 +6,258 @@ #include #include -static AddOnWindow *currentAddOnWindow = 0; -static AddOn *currentAddOn = 0; +static AddOnWindow* currentAddOnWindow = 0; +static AddOn* currentAddOn = 0; -AddOn::AddOn (BEntry entry) +AddOn::AddOn(BEntry entry) { extern bool VerbAddOns; BPath path; - entry.GetPath (&path); - fAddOnID = load_add_on (path.Path()); + entry.GetPath(&path); + fAddOnID = load_add_on(path.Path()); addon_open = 0; addon_make_config = 0; process = 0; - if (fAddOnID < 0) - { + if (fAddOnID < 0) { if (VerbAddOns) - fprintf (stderr, "Problems loading add-on %s\n", path.Path()); - throw (0); + fprintf(stderr, "Problems loading add-on %s\n", path.Path()); + throw(0); } - if (get_image_symbol (fAddOnID, "addon_init", B_SYMBOL_TYPE_TEXT, (void **) &addon_init)) - { + if (get_image_symbol(fAddOnID, "addon_init", B_SYMBOL_TYPE_TEXT, (void**)&addon_init)) { if (VerbAddOns) - fprintf (stderr, "Problems finding addon_init routine in %s\n", path.Path()); - throw (1); + fprintf(stderr, "Problems finding addon_init routine in %s\n", path.Path()); + throw(1); } - if (get_image_symbol (fAddOnID, "addon_exit", B_SYMBOL_TYPE_TEXT, (void **) &addon_exit)) - { + if (get_image_symbol(fAddOnID, "addon_exit", B_SYMBOL_TYPE_TEXT, (void**)&addon_exit)) { if (VerbAddOns) - fprintf (stderr, "Problems finding addon_exit routine in %s\n", path.Path()); - throw (1); + fprintf(stderr, "Problems finding addon_exit routine in %s\n", path.Path()); + throw(1); } - if (get_image_symbol (fAddOnID, "process", B_SYMBOL_TYPE_TEXT, (void **) &process)) - { + if (get_image_symbol(fAddOnID, "process", B_SYMBOL_TYPE_TEXT, (void**)&process)) { // Maybe it's a capture add-on: - if (get_image_symbol (fAddOnID, "bitmap", B_SYMBOL_TYPE_TEXT, (void **) &bitmap)) - { + if (get_image_symbol(fAddOnID, "bitmap", B_SYMBOL_TYPE_TEXT, (void**)&bitmap)) { if (VerbAddOns) - fprintf (stderr, "Problems finding process/bitmap routine in %s\n", path.Path()); - throw (1); + fprintf(stderr, "Problems finding process/bitmap routine in %s\n", path.Path()); + throw(1); } - if (get_image_symbol (fAddOnID, "addon_open", B_SYMBOL_TYPE_TEXT, (void **) &addon_open)) - { + if (get_image_symbol(fAddOnID, "addon_open", B_SYMBOL_TYPE_TEXT, (void**)&addon_open)) { if (VerbAddOns) - fprintf (stderr, "Problems finding addon_open routine in %s\n", path.Path()); - throw (1); + fprintf(stderr, "Problems finding addon_open routine in %s\n", path.Path()); + throw(1); } - } - else if (get_image_symbol (fAddOnID, "addon_make_config", B_SYMBOL_TYPE_TEXT, (void **) &addon_make_config)) - { + } else if (get_image_symbol( + fAddOnID, "addon_make_config", B_SYMBOL_TYPE_TEXT, (void**)&addon_make_config + )) { if (VerbAddOns) - fprintf (stderr, "Problems finding addon_make_config routine in %s\n", path.Path()); - throw (1); + fprintf(stderr, "Problems finding addon_make_config routine in %s\n", path.Path()); + throw(1); } - if (process && get_image_symbol (fAddOnID, "addon_close", B_SYMBOL_TYPE_TEXT, (void **) &addon_close)) - { + if (process && + get_image_symbol(fAddOnID, "addon_close", B_SYMBOL_TYPE_TEXT, (void**)&addon_close)) { if (VerbAddOns) - fprintf (stderr, "Problems finding addon_close routine in %s\n", path.Path()); - throw (1); + fprintf(stderr, "Problems finding addon_close routine in %s\n", path.Path()); + throw(1); } - + // optional hooks - if (get_image_symbol (fAddOnID, "addon_mode_changed", B_SYMBOL_TYPE_TEXT, (void **) &addon_mode_changed)) + if (get_image_symbol( + fAddOnID, "addon_mode_changed", B_SYMBOL_TYPE_TEXT, (void**)&addon_mode_changed + )) addon_mode_changed = 0; else if (VerbAddOns) - fprintf (stderr, "Found addon_mode_changed() hook in %s\n", path.Path()); - - if (get_image_symbol (fAddOnID, "addon_color_changed", B_SYMBOL_TYPE_TEXT, (void **) &addon_color_changed)) + fprintf(stderr, "Found addon_mode_changed() hook in %s\n", path.Path()); + + if (get_image_symbol( + fAddOnID, "addon_color_changed", B_SYMBOL_TYPE_TEXT, (void**)&addon_color_changed + )) addon_color_changed = 0; else if (VerbAddOns) - fprintf (stderr, "Found addon_color_changed() hook in %s\n", path.Path()); - + fprintf(stderr, "Found addon_color_changed() hook in %s\n", path.Path()); + if (VerbAddOns) - fprintf (stderr, "Loaded %s\n", path.Path()); - + fprintf(stderr, "Loaded %s\n", path.Path()); } -AddOn::~AddOn () +AddOn::~AddOn() { - if ((*addon_exit)()) - { - fprintf (stderr, "Warning: Add-on returned an error from addon_exit.\n"); + if ((*addon_exit)()) { + fprintf(stderr, "Warning: Add-on returned an error from addon_exit.\n"); } // unload_add_on (fAddOnID); // Crashes on exit... Hmm! } -status_t AddOn::Init (uint32 index) +status_t +AddOn::Init(uint32 index) { - extern const char *Version; + extern const char* Version; extern bool VerbAddOns; int res = (*addon_init)(index, &fInfo); if (res) return (res); - if (fInfo.becasso_version > atoi (Version)) - { - fprintf (stderr, "%s expects a newer Becasso version (%i)\n", fInfo.name, fInfo.becasso_version); + if (fInfo.becasso_version > atoi(Version)) { + fprintf( + stderr, "%s expects a newer Becasso version (%i)\n", fInfo.name, fInfo.becasso_version + ); return (1); } if (VerbAddOns) - fprintf (stderr, "%s version %i.%i successfully initialized.\n", fInfo.name, fInfo.version, fInfo.release); + fprintf( + stderr, "%s version %i.%i successfully initialized.\n", fInfo.name, fInfo.version, + fInfo.release + ); return 0; } -void AddOn::ColorChanged () +void +AddOn::ColorChanged() { if (addon_color_changed) (*addon_color_changed)(); addon_preview(); } -void AddOn::ModeChanged () +void +AddOn::ModeChanged() { if (addon_mode_changed) (*addon_mode_changed)(); addon_preview(); } -status_t AddOn::Open (BWindow *client, const char */*name*/) +status_t +AddOn::Open(BWindow* client, const char* /*name*/) { -// printf ("AddOn::Open() [%s]\n", fInfo.name); - + // printf ("AddOn::Open() [%s]\n", fInfo.name); + currentAddOn = this; - if (addon_open) // this is a capture add-on + if (addon_open) // this is a capture add-on { return (*addon_open)(); } - - BView *configView = 0; - BRect frame (0, 0, 190, 1); - MakeConfig (&configView, frame); + + BView* configView = 0; + BRect frame(0, 0, 190, 1); + MakeConfig(&configView, frame); if (configView) frame = configView->Bounds(); if (frame.right < 188) frame.right = 188; frame.bottom += 64; - frame.OffsetBy (100, 100); // FIXME: make a setting or at least memorize + frame.OffsetBy(100, 100); // FIXME: make a setting or at least memorize // note: see AddOnWindow - ADDON_RESIZED - + if (!currentAddOnWindow) - currentAddOnWindow = new AddOnWindow (frame); + currentAddOnWindow = new AddOnWindow(frame); else - currentAddOnWindow->ResizeTo (frame.Width(), frame.Height()); + currentAddOnWindow->ResizeTo(frame.Width(), frame.Height()); currentAddOnWindow->Lock(); - BView *old_config = currentAddOnWindow->FindView ("config view"); + BView* old_config = currentAddOnWindow->FindView("config view"); if (old_config) - currentAddOnWindow->Background()->RemoveChild (old_config); - if (configView) - { - configView->SetViewColor (LightGrey); - configView->SetName ("config view"); - currentAddOnWindow->Background()->AddChild (configView); - SetTargetOfControlsRecurse (configView, configView); + currentAddOnWindow->Background()->RemoveChild(old_config); + if (configView) { + configView->SetViewColor(LightGrey); + configView->SetName("config view"); + currentAddOnWindow->Background()->AddChild(configView); + SetTargetOfControlsRecurse(configView, configView); configView->AttachedToWindow(); } currentAddOnWindow->Unlock(); - - currentAddOnWindow->SetAddOn (&fInfo); - currentAddOnWindow->SetClient (client); + + currentAddOnWindow->SetAddOn(&fInfo); + currentAddOnWindow->SetClient(client); currentAddOnWindow->Lock(); if (currentAddOnWindow->IsHidden()) currentAddOnWindow->Show(); currentAddOnWindow->Unlock(); - + return B_OK; } -void AddOn::SetTargetOfControlsRecurse (BView *target, BView *view) +void +AddOn::SetTargetOfControlsRecurse(BView* target, BView* view) { extern int DebugLevel; - BControl *control = dynamic_cast (view); - if (control) - { - if (control->Target() == currentAddOnWindow) - { + BControl* control = dynamic_cast(view); + if (control) { + if (control->Target() == currentAddOnWindow) { if (DebugLevel > 2) - printf ("setting target of control %s\n", control->Name()); - control->SetTarget (target); - } - else if (DebugLevel > 2) - printf ("skipping target for control %s\n", control->Name()); + printf("setting target of control %s\n", control->Name()); + control->SetTarget(target); + } else if (DebugLevel > 2) + printf("skipping target for control %s\n", control->Name()); return; } - BMenuField *mf = dynamic_cast (view); - if (mf) - { + BMenuField* mf = dynamic_cast(view); + if (mf) { if (DebugLevel > 2) - printf ("setting target for popup %s\n", mf->Name()); - BMenu *menu = mf->Menu(); - for (int i = 0; i < menu->CountItems(); i++) - { - BMenuItem *item = menu->ItemAt (i); - if (item) - item->SetTarget (target); - } + printf("setting target for popup %s\n", mf->Name()); + BMenu* menu = mf->Menu(); + for (int i = 0; i < menu->CountItems(); i++) { + BMenuItem* item = menu->ItemAt(i); + if (item) + item->SetTarget(target); + } } - - for (int i = 0; i < view->CountChildren(); i++) - { - SetTargetOfControlsRecurse (target, view->ChildAt(i)); + + for (int i = 0; i < view->CountChildren(); i++) { + SetTargetOfControlsRecurse(target, view->ChildAt(i)); } } -status_t AddOn::MakeConfig (BView **view, BRect rect) +status_t +AddOn::MakeConfig(BView** view, BRect rect) { return ((*addon_make_config)(view, rect)); } -status_t AddOn::Close (bool client_quits) +status_t +AddOn::Close(bool client_quits) { -// printf ("AddOn::Close() [%s]\n", fInfo.name); - - if (currentAddOn != this) - { - fprintf (stderr, "Warning: add-on %s closes but wasn't the current?\n", fInfo.name); + // printf ("AddOn::Close() [%s]\n", fInfo.name); + + if (currentAddOn != this) { + fprintf(stderr, "Warning: add-on %s closes but wasn't the current?\n", fInfo.name); } currentAddOn = 0; - if (addon_close) - { + if (addon_close) { status_t err = (*addon_close)(); if (err) - fprintf (stderr, "Warning: add-on %s returned 0x%lx from addon_close()\n", fInfo.name, err); + fprintf( + stderr, "Warning: add-on %s returned 0x%lx from addon_close()\n", fInfo.name, err + ); } - + if (client_quits) - currentAddOnWindow->SetClient (NULL); + currentAddOnWindow->SetClient(NULL); currentAddOnWindow->Hide(); return B_OK; } -status_t AddOn::Process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect *frame, bool final, BPoint point, uint32 buttons) +status_t +AddOn::Process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* frame, bool final, BPoint point, uint32 buttons +) { - return ((*process)(inLayer, inSelection, outLayer, outSelection, mode, frame, final, point, buttons)); + return ( + (*process)(inLayer, inSelection, outLayer, outSelection, mode, frame, final, point, buttons) + ); } -BBitmap *AddOn::Bitmap (char *title) +BBitmap* +AddOn::Bitmap(char* title) { return ((*bitmap)(title)); } -void addon_start (void) +void +addon_start(void) { - if (!currentAddOnWindow) - { - fprintf (stderr, "addon_start: No currentAddOnWindow\n"); + if (!currentAddOnWindow) { + fprintf(stderr, "addon_start: No currentAddOnWindow\n"); return; } currentAddOnWindow->Lock(); @@ -260,24 +265,24 @@ void addon_start (void) currentAddOnWindow->Unlock(); } -bool addon_stop (void) +bool +addon_stop(void) { - if (!currentAddOnWindow) - { - fprintf (stderr, "addon_stop: No currentAddOnWindow\n"); + if (!currentAddOnWindow) { + fprintf(stderr, "addon_stop: No currentAddOnWindow\n"); return true; } -// currentAddOnWindow->Lock(); + // currentAddOnWindow->Lock(); bool val = currentAddOnWindow->Stop(); -// currentAddOnWindow->Unlock(); + // currentAddOnWindow->Unlock(); return val; } -void addon_done (void) +void +addon_done(void) { - if (!currentAddOnWindow) - { - fprintf (stderr, "addon_stopped: No currentAddOnWindow\n"); + if (!currentAddOnWindow) { + fprintf(stderr, "addon_stopped: No currentAddOnWindow\n"); return; } currentAddOnWindow->Lock(); @@ -285,35 +290,35 @@ void addon_done (void) currentAddOnWindow->Unlock(); } -void addon_update_statusbar (float delta, const char *text, const char *trailingText) +void +addon_update_statusbar(float delta, const char* text, const char* trailingText) { - if (!currentAddOnWindow) - { - fprintf (stderr, "addon_update_statusbar: No currentAddOnWindow\n"); + if (!currentAddOnWindow) { + fprintf(stderr, "addon_update_statusbar: No currentAddOnWindow\n"); return; } currentAddOnWindow->Lock(); - currentAddOnWindow->UpdateStatusBar (delta, text, trailingText); + currentAddOnWindow->UpdateStatusBar(delta, text, trailingText); currentAddOnWindow->Unlock(); } -void addon_reset_statusbar (const char *label, const char *trailingText) +void +addon_reset_statusbar(const char* label, const char* trailingText) { - if (!currentAddOnWindow) - { - fprintf (stderr, "addon_reset_statusbar: No currentAddOnWindow\n"); + if (!currentAddOnWindow) { + fprintf(stderr, "addon_reset_statusbar: No currentAddOnWindow\n"); return; } currentAddOnWindow->Lock(); - currentAddOnWindow->ResetStatusBar (label, trailingText); + currentAddOnWindow->ResetStatusBar(label, trailingText); currentAddOnWindow->Unlock(); } -void addon_preview (void) +void +addon_preview(void) { - if (!currentAddOnWindow) - { - fprintf (stderr, "addon_preview: No currentAddOnWindow\n"); + if (!currentAddOnWindow) { + fprintf(stderr, "addon_preview: No currentAddOnWindow\n"); return; } currentAddOnWindow->Lock(); @@ -321,21 +326,20 @@ void addon_preview (void) currentAddOnWindow->Unlock(); } -void addon_refresh_config (void) +void +addon_refresh_config(void) { - if (!currentAddOnWindow) - { - fprintf (stderr, "addon_refresh_config: No currentAddOnWindow\n"); + if (!currentAddOnWindow) { + fprintf(stderr, "addon_refresh_config: No currentAddOnWindow\n"); return; } - if (!currentAddOn) - { - fprintf (stderr, "addon_refresh_config: No currentAddOn\n"); + if (!currentAddOn) { + fprintf(stderr, "addon_refresh_config: No currentAddOn\n"); return; } - BView *configView = 0; - BRect frame (0, 0, 190, 1); - currentAddOn->MakeConfig (&configView, frame); + BView* configView = 0; + BRect frame(0, 0, 190, 1); + currentAddOn->MakeConfig(&configView, frame); if (configView) frame = configView->Bounds(); if (frame.right < 188) @@ -343,16 +347,15 @@ void addon_refresh_config (void) frame.bottom += 64; currentAddOnWindow->Lock(); - currentAddOnWindow->ResizeTo (frame.Width(), frame.Height()); - BView *old_config = currentAddOnWindow->FindView ("config view"); + currentAddOnWindow->ResizeTo(frame.Width(), frame.Height()); + BView* old_config = currentAddOnWindow->FindView("config view"); if (old_config) - currentAddOnWindow->Background()->RemoveChild (old_config); - if (configView) - { - configView->SetViewColor (LightGrey); - configView->SetName ("config view"); - currentAddOnWindow->Background()->AddChild (configView); - currentAddOn->SetTargetOfControlsRecurse (configView, configView); + currentAddOnWindow->Background()->RemoveChild(old_config); + if (configView) { + configView->SetViewColor(LightGrey); + configView->SetName("config view"); + currentAddOnWindow->Background()->AddChild(configView); + currentAddOn->SetTargetOfControlsRecurse(configView, configView); } currentAddOnWindow->Unlock(); } \ No newline at end of file diff --git a/source/AddOn.h b/source/AddOn.h index 45796b5..ea5e8d6 100644 --- a/source/AddOn.h +++ b/source/AddOn.h @@ -10,42 +10,47 @@ class AddOn { -public: - AddOn (BEntry entry); - ~AddOn (); -status_t Init (uint32 index); -status_t Open (BWindow *client, const char *name); -status_t MakeConfig (BView **view, BRect rect); -status_t Close (bool client_quits = false); -status_t Process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode = M_DRAW, - BRect *frame = NULL, bool final = true, - BPoint point = BPoint (-1, -1), uint32 buttons = 0); -BBitmap *Bitmap (char *title); -const int Type () { return (fInfo.type); }; -const char *Name () { return (fInfo.name); }; -const uint8 DoesPreview () { return (fInfo.does_preview); }; -void ColorChanged (); -void ModeChanged (); - -void SetTargetOfControlsRecurse (BView *target, BView *view); - -private: - -status_t (*addon_init)(uint32 index, becasso_addon_info *info); -status_t (*addon_exit)(void); -status_t (*addon_close)(void); -status_t (*addon_make_config)(BView **view, BRect rect); -status_t (*process)(Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect *frame, bool final, BPoint point, uint32 buttons); -status_t (*addon_open)(void); // capture add-ons only -BBitmap * (*bitmap)(char *title); // capture add-ons only -void (*addon_color_changed)(void); // optional -void (*addon_mode_changed)(void); // optional - -image_id fAddOnID; -becasso_addon_info fInfo; + public: + AddOn(BEntry entry); + ~AddOn(); + status_t Init(uint32 index); + status_t Open(BWindow* client, const char* name); + status_t MakeConfig(BView** view, BRect rect); + status_t Close(bool client_quits = false); + status_t Process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, + int32 mode = M_DRAW, BRect* frame = NULL, bool final = true, BPoint point = BPoint(-1, -1), + uint32 buttons = 0 + ); + BBitmap* Bitmap(char* title); + + const int Type() { return (fInfo.type); }; + + const char* Name() { return (fInfo.name); }; + + const uint8 DoesPreview() { return (fInfo.does_preview); }; + + void ColorChanged(); + void ModeChanged(); + + void SetTargetOfControlsRecurse(BView* target, BView* view); + + private: + status_t (*addon_init)(uint32 index, becasso_addon_info* info); + status_t (*addon_exit)(void); + status_t (*addon_close)(void); + status_t (*addon_make_config)(BView** view, BRect rect); + status_t (*process)( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, + int32 mode, BRect* frame, bool final, BPoint point, uint32 buttons + ); + status_t (*addon_open)(void); // capture add-ons only + BBitmap* (*bitmap)(char* title); // capture add-ons only + void (*addon_color_changed)(void); // optional + void (*addon_mode_changed)(void); // optional + + image_id fAddOnID; + becasso_addon_info fInfo; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AddOnSupport.cpp b/source/AddOnSupport.cpp index b2f203f..9d9fca9 100644 --- a/source/AddOnSupport.cpp +++ b/source/AddOnSupport.cpp @@ -4,189 +4,225 @@ #include "PicMenuButton.h" #include "hsv.h" -bgra_pixel average4 (bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d) +bgra_pixel +average4(bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d) { -// This is valid for both IA and PPC + // This is valid for both IA and PPC bgra_pixel r = ((a >> 24) + (b >> 24) + (c >> 24) + (d >> 24)) << 22; - r += ((a & 0x00FF0000) + (b & 0x00FF0000) + (c & 0x00FF0000) + (d & 0x00FF0000))/4; - r += ((a & 0x0000FF00) + (b & 0x0000FF00) + (c & 0x0000FF00) + (d & 0x0000FF00))/4; - r += ((a & 0x000000FF) + (b & 0x000000FF) + (c & 0x000000FF) + (d & 0x000000FF))/4; + r += ((a & 0x00FF0000) + (b & 0x00FF0000) + (c & 0x00FF0000) + (d & 0x00FF0000)) / 4; + r += ((a & 0x0000FF00) + (b & 0x0000FF00) + (c & 0x0000FF00) + (d & 0x0000FF00)) / 4; + r += ((a & 0x000000FF) + (b & 0x000000FF) + (c & 0x000000FF) + (d & 0x000000FF)) / 4; return (r); } -bgra_pixel average6 (bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d, bgra_pixel e, bgra_pixel f) +bgra_pixel +average6(bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d, bgra_pixel e, bgra_pixel f) { -// This is valid for both IA and PPC - bgra_pixel r = (((a >> 24) + (b >> 24) + (c >> 24) + (d >> 24) + (e >> 24) + (f >> 24))/6) << 24; - r += ((a & 0x00FF0000) + (b & 0x00FF0000) + (c & 0x00FF0000) + (d & 0x00FF0000) + (e & 0x00FF0000) + (f & 0x00FF0000))/6; + // This is valid for both IA and PPC + bgra_pixel r = (((a >> 24) + (b >> 24) + (c >> 24) + (d >> 24) + (e >> 24) + (f >> 24)) / 6) + << 24; + r += ((a & 0x00FF0000) + (b & 0x00FF0000) + (c & 0x00FF0000) + (d & 0x00FF0000) + + (e & 0x00FF0000) + (f & 0x00FF0000)) / + 6; r &= 0xFFFF0000; - r += ((a & 0x0000FF00) + (b & 0x0000FF00) + (c & 0x0000FF00) + (d & 0x0000FF00) + (e & 0x0000FF00) + (f & 0x0000FF00))/6; + r += ((a & 0x0000FF00) + (b & 0x0000FF00) + (c & 0x0000FF00) + (d & 0x0000FF00) + + (e & 0x0000FF00) + (f & 0x0000FF00)) / + 6; r &= 0xFFFFFF00; - r += ((a & 0x000000FF) + (b & 0x000000FF) + (c & 0x000000FF) + (d & 0x000000FF) + (e & 0x000000FF) + (f & 0x000000FF))/6; + r += ((a & 0x000000FF) + (b & 0x000000FF) + (c & 0x000000FF) + (d & 0x000000FF) + + (e & 0x000000FF) + (f & 0x000000FF)) / + 6; return (r); } -bgra_pixel average9 (bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d, bgra_pixel e, bgra_pixel f, bgra_pixel g, bgra_pixel h, bgra_pixel i) -{ -// This is valid for both IA and PPC - bgra_pixel r = (((a >> 24) + (b >> 24) + (c >> 24) + (d >> 24) + (e >> 24) + (f >> 24) + (g >> 24) + (h >> 24) + (i >> 24))/9) << 24; - r += ((a & 0x00FF0000) + (b & 0x00FF0000) + (c & 0x00FF0000) + (d & 0x00FF0000) + (e & 0x00FF0000) + (f & 0x00FF0000) + (g & 0x00FF0000) + (h & 0x00FF0000) + (i & 0x00FF0000))/9; +bgra_pixel +average9( + bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d, bgra_pixel e, bgra_pixel f, + bgra_pixel g, bgra_pixel h, bgra_pixel i +) +{ + // This is valid for both IA and PPC + bgra_pixel r = (((a >> 24) + (b >> 24) + (c >> 24) + (d >> 24) + (e >> 24) + (f >> 24) + + (g >> 24) + (h >> 24) + (i >> 24)) / + 9) + << 24; + r += ((a & 0x00FF0000) + (b & 0x00FF0000) + (c & 0x00FF0000) + (d & 0x00FF0000) + + (e & 0x00FF0000) + (f & 0x00FF0000) + (g & 0x00FF0000) + (h & 0x00FF0000) + + (i & 0x00FF0000)) / + 9; r &= 0xFFFF0000; - r += ((a & 0x0000FF00) + (b & 0x0000FF00) + (c & 0x0000FF00) + (d & 0x0000FF00) + (e & 0x0000FF00) + (f & 0x0000FF00) + (g & 0x0000FF00) + (h & 0x0000FF00) + (i & 0x0000FF00))/9; + r += ((a & 0x0000FF00) + (b & 0x0000FF00) + (c & 0x0000FF00) + (d & 0x0000FF00) + + (e & 0x0000FF00) + (f & 0x0000FF00) + (g & 0x0000FF00) + (h & 0x0000FF00) + + (i & 0x0000FF00)) / + 9; r &= 0xFFFFFF00; - r += ((a & 0x000000FF) + (b & 0x000000FF) + (c & 0x000000FF) + (d & 0x000000FF) + (e & 0x000000FF) + (f & 0x000000FF) + (g & 0x000000FF) + (h & 0x000000FF) + (i & 0x000000FF))/9; + r += ((a & 0x000000FF) + (b & 0x000000FF) + (c & 0x000000FF) + (d & 0x000000FF) + + (e & 0x000000FF) + (f & 0x000000FF) + (g & 0x000000FF) + (h & 0x000000FF) + + (i & 0x000000FF)) / + 9; return (r); } -bgra_pixel pixelblend (bgra_pixel d, bgra_pixel s) +bgra_pixel +pixelblend(bgra_pixel d, bgra_pixel s) { bgra_pixel res; -#if defined (__POWERPC__) +#if defined(__POWERPC__) int sa = s & 0xFF; int da = 255 - sa; int ta = 255; - if (sa == 255 || !(d & 0xFF)) // Fully opaque + if (sa == 255 || !(d & 0xFF)) // Fully opaque { res = s; - } - else if (sa == 0) // Fully transparent + } else if (sa == 0) // Fully transparent { res = d; - } - else - { - res = ((((d & 0xFF000000)/ta)*da + ((s & 0xFF000000)/ta)*sa) & 0xFF000000) | - ((((d & 0x00FF0000)/ta)*da + ((s & 0x00FF0000)/ta)*sa) & 0x00FF0000) | - ((((d & 0x0000FF00)*da + (s & 0x0000FF00)*sa)/ta) & 0x0000FF00) | -// res = (((((d >> 24)*da + (s >> 24)*sa)/ta) << 24) & 0xFF000000) | -// ((((((d >> 16) & 0xFF)*da + (s >> 16) & 0xFF)*sa) << 16) & 0x00FF0000) | -// ((((((d >> 8) & 0xFF)*da + (s >> 8) & 0xFF)*sa) << 8) & 0x0000FF00) | - clipchar (sa + int (d & 0xFF)); + } else { + res = + ((((d & 0xFF000000) / ta) * da + ((s & 0xFF000000) / ta) * sa) & 0xFF000000) | + ((((d & 0x00FF0000) / ta) * da + ((s & 0x00FF0000) / ta) * sa) & 0x00FF0000) | + ((((d & 0x0000FF00) * da + (s & 0x0000FF00) * sa) / ta) & 0x0000FF00) | + // res = (((((d >> 24)*da + (s >> 24)*sa)/ta) << 24) & 0xFF000000) | + // ((((((d >> 16) & 0xFF)*da + (s >> 16) & 0xFF)*sa) << 16) & 0x00FF0000) | + // ((((((d >> 8) & 0xFF)*da + (s >> 8) & 0xFF)*sa) << 8) & 0x0000FF00) | + clipchar(sa + int(d & 0xFF)); } #else int sa = s >> 24; int da = 255 - sa; int ta = 255; - if (sa == 255 || !(d >> 24)) // Fully opaque + if (sa == 255 || !(d >> 24)) // Fully opaque { res = s; - } - else if (sa == 0) // Fully transparent + } else if (sa == 0) // Fully transparent { res = d; - } - else - { - res = ((((d & 0x00FF0000)*da + (s & 0x00FF0000)*sa)/ta) & 0x00FF0000) | - ((((d & 0x0000FF00)*da + (s & 0x0000FF00)*sa)/ta) & 0x0000FF00) | - ((((d & 0x000000FF)*da + (s & 0x000000FF)*sa)/ta) & 0x000000FF) | - (clipchar (sa + int (d >> 24)) << 24); + } else { + res = ((((d & 0x00FF0000) * da + (s & 0x00FF0000) * sa) / ta) & 0x00FF0000) | + ((((d & 0x0000FF00) * da + (s & 0x0000FF00) * sa) / ta) & 0x0000FF00) | + ((((d & 0x000000FF) * da + (s & 0x000000FF) * sa) / ta) & 0x000000FF) | + (clipchar(sa + int(d >> 24)) << 24); } #endif return res; } -uint8 clip8 (int32 c) +uint8 +clip8(int32 c) { return ((c < 0) ? 0 : (c > 255) ? 255 : c); } -rgb_color highcolor (void) +rgb_color +highcolor(void) { - extern ColorMenuButton *hicolor; + extern ColorMenuButton* hicolor; return hicolor->color(); } -rgb_color lowcolor (void) +rgb_color +lowcolor(void) { - extern ColorMenuButton *locolor; + extern ColorMenuButton* locolor; return locolor->color(); } -int32 currentmode (void) +int32 +currentmode(void) { - extern PicMenuButton *mode; + extern PicMenuButton* mode; return mode->selected(); } -pattern currentpattern (void) +pattern +currentpattern(void) { - extern PatternMenuButton *pat; + extern PatternMenuButton* pat; return pat->pat(); } -rgb_color *highpalette (void) +rgb_color* +highpalette(void) { - extern ColorMenuButton *hicolor; + extern ColorMenuButton* hicolor; return hicolor->palette(); } -rgb_color *lowpalette (void) +rgb_color* +lowpalette(void) { - extern ColorMenuButton *locolor; + extern ColorMenuButton* locolor; return locolor->palette(); } -int highpalettesize (void) +int +highpalettesize(void) { - extern ColorMenuButton *hicolor; + extern ColorMenuButton* hicolor; return hicolor->numColors(); } -int lowpalettesize (void) +int +lowpalettesize(void) { - extern ColorMenuButton *locolor; + extern ColorMenuButton* locolor; return locolor->numColors(); } -rgb_color closesthigh (rgb_color a) +rgb_color +closesthigh(rgb_color a) { - extern ColorMenuButton *hicolor; - return hicolor->getClosest (a); + extern ColorMenuButton* hicolor; + return hicolor->getClosest(a); } -rgb_color closestlow (rgb_color a) +rgb_color +closestlow(rgb_color a) { - extern ColorMenuButton *locolor; - return locolor->getClosest (a); + extern ColorMenuButton* locolor; + return locolor->getClosest(a); } -rgb_color contrastingcolor (rgb_color a, rgb_color b) +rgb_color +contrastingcolor(rgb_color a, rgb_color b) { - if ((a.red > a.green + 100 && a.red > a.blue + 100) - || (b.red > b.green + 100 && b.red > b.blue + 100)) // "one is sort of red" + if ((a.red > a.green + 100 && a.red > a.blue + 100) || + (b.red > b.green + 100 && b.red > b.blue + 100)) // "one is sort of red" { - if (a.red + a.green + a.blue + b.red + b.green + b.blue > 768) // light colors + if (a.red + a.green + a.blue + b.red + b.green + b.blue > 768) // light colors return (Black); else return (White); - } - else + } else return (Red); } -bgra_pixel weighted_average (bgra_pixel a, uint8 wa, bgra_pixel b, uint8 wb) +bgra_pixel +weighted_average(bgra_pixel a, uint8 wa, bgra_pixel b, uint8 wb) { -// This is valid for both IA and PPC + // This is valid for both IA and PPC uint32 t = wa + wb; -// return ((((((a & 0xFF000000)/t)*wa + (b & 0xFF000000)/t)*wb) & 0xFF000000) | -// (((((a & 0x00FF0000)/t)*wa + (b & 0x00FF0000)/t)*wb) & 0x00FF0000) | -// ((((a & 0x0000FF00)*wa + (b & 0x0000FF00)*wb)/t) & 0x0000FF00) | -// ((((a & 0x000000FF)*wa + (b & 0x000000FF)*wb)/t) & 0x000000FF)); - return ((((((a >> 24)*wa + (b >> 24)*wb)/t) << 24) & 0xFF000000) | - ((((((a >> 16) & 0xFF)*wa + ((b >> 16) & 0xFF)*wb)/t) << 16) & 0x00FF0000) | - ((((((a >> 8) & 0xFF)*wa + ((b >> 8) & 0xFF)*wb)/t) << 8) & 0x0000FF00) | - (((a & 0xFF)*wa + (b & 0xFF)*wb)/t & 0x000000FF)); -} - -bgra_pixel weighted_average_rgb (rgb_color ca, uint8 wa, rgb_color cb, uint8 wb) -{ -#if defined (__POWERPC__) + // return ((((((a & 0xFF000000)/t)*wa + (b & 0xFF000000)/t)*wb) & 0xFF000000) | + // (((((a & 0x00FF0000)/t)*wa + (b & 0x00FF0000)/t)*wb) & 0x00FF0000) | + // ((((a & 0x0000FF00)*wa + (b & 0x0000FF00)*wb)/t) & 0x0000FF00) | + // ((((a & 0x000000FF)*wa + (b & 0x000000FF)*wb)/t) & 0x000000FF)); + return ( + (((((a >> 24) * wa + (b >> 24) * wb) / t) << 24) & 0xFF000000) | + ((((((a >> 16) & 0xFF) * wa + ((b >> 16) & 0xFF) * wb) / t) << 16) & 0x00FF0000) | + ((((((a >> 8) & 0xFF) * wa + ((b >> 8) & 0xFF) * wb) / t) << 8) & 0x0000FF00) | + (((a & 0xFF) * wa + (b & 0xFF) * wb) / t & 0x000000FF) + ); +} + +bgra_pixel +weighted_average_rgb(rgb_color ca, uint8 wa, rgb_color cb, uint8 wb) +{ +#if defined(__POWERPC__) bgra_pixel a = ca.blue << 24 | ca.green << 16 | ca.red << 8; bgra_pixel b = cb.blue << 24 | cb.green << 16 | cb.red << 8; #else bgra_pixel a = ca.red << 16 | ca.green << 8 | ca.blue; bgra_pixel b = cb.red << 16 | cb.green << 8 | cb.blue; #endif - return (weighted_average (a, wa, b, wb)); + return (weighted_average(a, wa, b, wb)); } diff --git a/source/AddOnSupport.h b/source/AddOnSupport.h index 47f9b03..ec94e63 100644 --- a/source/AddOnSupport.h +++ b/source/AddOnSupport.h @@ -11,53 +11,96 @@ typedef uint32 bgra_pixel; typedef uint32 cmyk_pixel; -typedef uint8 grey_pixel; +typedef uint8 grey_pixel; + typedef struct { - float hue; // [0,360> - float saturation; // [0,1] - float value; // [0,1] - uint8 alpha; // [0,255] + float hue; // [0,360> + float saturation; // [0,1] + float value; // [0,1] + uint8 alpha; // [0,255] } hsv_color; -extern "C" IMPEXP bgra_pixel average4 (bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d); -extern "C" IMPEXP bgra_pixel average6 (bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d, bgra_pixel e, bgra_pixel f); -extern "C" IMPEXP bgra_pixel average9 (bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d, bgra_pixel e, bgra_pixel f, bgra_pixel g, bgra_pixel h, bgra_pixel i); -extern "C" IMPEXP bgra_pixel pixelblend (bgra_pixel d, bgra_pixel s); -extern "C" IMPEXP uint8 clip8 (int32 c); -extern "C" IMPEXP rgb_color highcolor (void); -extern "C" IMPEXP rgb_color lowcolor (void); -extern "C" IMPEXP int32 currentmode (void); -extern "C" IMPEXP rgb_color contrastingcolor (rgb_color a, rgb_color b); -extern "C" IMPEXP rgb_color *highpalette (void); -extern "C" IMPEXP int highpalettesize (void); -extern "C" IMPEXP rgb_color closesthigh (rgb_color a); -extern "C" IMPEXP rgb_color *lowpalette (void); -extern "C" IMPEXP int lowpalettesize (void); -extern "C" IMPEXP rgb_color closestlow (rgb_color a); -extern "C" IMPEXP pattern currentpattern (void); -extern "C" IMPEXP bgra_pixel weighted_average (bgra_pixel a, uint8 wa, bgra_pixel b, uint8 wb); -extern "C" IMPEXP bgra_pixel weighted_average_rgb (rgb_color a, uint8 wa, rgb_color b, uint8 wb); -extern "C" IMPEXP int Scale (BBitmap *src, BBitmap *srcmap, BBitmap *dest, BBitmap *destmap); -extern "C" IMPEXP void AddWithAlpha (BBitmap *src, BBitmap *dest, long x, long y, int strength = 255); -extern "C" IMPEXP void BlendWithAlpha (BBitmap *src, BBitmap *dest, long x, long y, int strength = 255); -extern "C" IMPEXP void CutOrCopy (BBitmap *src, BBitmap *dest, BBitmap *selection, long offx, long offy, bool cut); -extern "C" IMPEXP BBitmap *entry2bitmap (BEntry entry, bool silent = false); -extern "C" IMPEXP rgb_color hsv2rgb (hsv_color c); -extern "C" IMPEXP rgb_color bgra2rgb (bgra_pixel c); -extern "C" IMPEXP rgb_color cmyk2rgb (cmyk_pixel c); -extern "C" IMPEXP hsv_color rgb2hsv (rgb_color c); -extern "C" IMPEXP hsv_color bgra2hsv (bgra_pixel c); -extern "C" IMPEXP hsv_color cmyk2hsv (cmyk_pixel c); -extern "C" IMPEXP bgra_pixel cmyk2bgra (cmyk_pixel c); -extern "C" IMPEXP bgra_pixel rgb2bgra (rgb_color c); -extern "C" IMPEXP bgra_pixel hsv2bgra (hsv_color c); -extern "C" IMPEXP cmyk_pixel bgra2cmyk (bgra_pixel c); -extern "C" IMPEXP cmyk_pixel rgb2cmyk (rgb_color c); -extern "C" IMPEXP cmyk_pixel hsv2cmyk (hsv_color c); -extern "C" IMPEXP float diff (rgb_color a, rgb_color b); -extern "C" IMPEXP uchar clipchar (float x); -extern "C" IMPEXP float clipone (float x); -extern "C" IMPEXP float clipdegr (float x); +extern "C" IMPEXP bgra_pixel +average4(bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d); +extern "C" IMPEXP bgra_pixel +average6(bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d, bgra_pixel e, bgra_pixel f); +extern "C" IMPEXP bgra_pixel +average9( + bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d, bgra_pixel e, bgra_pixel f, + bgra_pixel g, bgra_pixel h, bgra_pixel i +); +extern "C" IMPEXP bgra_pixel +pixelblend(bgra_pixel d, bgra_pixel s); +extern "C" IMPEXP uint8 +clip8(int32 c); +extern "C" IMPEXP rgb_color +highcolor(void); +extern "C" IMPEXP rgb_color +lowcolor(void); +extern "C" IMPEXP int32 +currentmode(void); +extern "C" IMPEXP rgb_color +contrastingcolor(rgb_color a, rgb_color b); +extern "C" IMPEXP rgb_color* +highpalette(void); +extern "C" IMPEXP int +highpalettesize(void); +extern "C" IMPEXP rgb_color +closesthigh(rgb_color a); +extern "C" IMPEXP rgb_color* +lowpalette(void); +extern "C" IMPEXP int +lowpalettesize(void); +extern "C" IMPEXP rgb_color +closestlow(rgb_color a); +extern "C" IMPEXP pattern +currentpattern(void); +extern "C" IMPEXP bgra_pixel +weighted_average(bgra_pixel a, uint8 wa, bgra_pixel b, uint8 wb); +extern "C" IMPEXP bgra_pixel +weighted_average_rgb(rgb_color a, uint8 wa, rgb_color b, uint8 wb); +extern "C" IMPEXP int +Scale(BBitmap* src, BBitmap* srcmap, BBitmap* dest, BBitmap* destmap); +extern "C" IMPEXP void +AddWithAlpha(BBitmap* src, BBitmap* dest, long x, long y, int strength = 255); +extern "C" IMPEXP void +BlendWithAlpha(BBitmap* src, BBitmap* dest, long x, long y, int strength = 255); +extern "C" IMPEXP void +CutOrCopy(BBitmap* src, BBitmap* dest, BBitmap* selection, long offx, long offy, bool cut); +extern "C" IMPEXP BBitmap* +entry2bitmap(BEntry entry, bool silent = false); +extern "C" IMPEXP rgb_color +hsv2rgb(hsv_color c); +extern "C" IMPEXP rgb_color +bgra2rgb(bgra_pixel c); +extern "C" IMPEXP rgb_color +cmyk2rgb(cmyk_pixel c); +extern "C" IMPEXP hsv_color +rgb2hsv(rgb_color c); +extern "C" IMPEXP hsv_color +bgra2hsv(bgra_pixel c); +extern "C" IMPEXP hsv_color +cmyk2hsv(cmyk_pixel c); +extern "C" IMPEXP bgra_pixel +cmyk2bgra(cmyk_pixel c); +extern "C" IMPEXP bgra_pixel +rgb2bgra(rgb_color c); +extern "C" IMPEXP bgra_pixel +hsv2bgra(hsv_color c); +extern "C" IMPEXP cmyk_pixel +bgra2cmyk(bgra_pixel c); +extern "C" IMPEXP cmyk_pixel +rgb2cmyk(rgb_color c); +extern "C" IMPEXP cmyk_pixel +hsv2cmyk(hsv_color c); +extern "C" IMPEXP float +diff(rgb_color a, rgb_color b); +extern "C" IMPEXP uchar +clipchar(float x); +extern "C" IMPEXP float +clipone(float x); +extern "C" IMPEXP float +clipdegr(float x); #endif diff --git a/source/AddOnWindow.cpp b/source/AddOnWindow.cpp index 49b18fe..11b9a12 100644 --- a/source/AddOnWindow.cpp +++ b/source/AddOnWindow.cpp @@ -6,188 +6,203 @@ #include "Settings.h" #include "AddOn.h" -AddOnWindow::AddOnWindow (BRect frame) -: BWindow (frame, "Unopened", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK) +AddOnWindow::AddOnWindow(BRect frame) + : BWindow( + frame, "Unopened", B_TITLED_WINDOW, + B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK + ) { BRect mybounds = Bounds(); - bg = new BView (mybounds, "addonbg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); - bg->SetViewColor (LightGrey); - AddChild (bg); - fStatusBar = new BStatusBar (BRect (mybounds.left + 8, mybounds.bottom - 68, mybounds.right - 8, mybounds.bottom - 60), "AddonStatusBar"); - fStatusBar->SetResizingMode (B_FOLLOW_BOTTOM); - bg->AddChild (fStatusBar); - fStatusBar->SetBarHeight (8); - fStop = new BButton (BRect (mybounds.right - 180, mybounds.bottom - 32, mybounds.right - 128, mybounds.bottom - 8), "AddonStop", lstring (370, "Stop"), new BMessage ('ao_s'), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT); - fStop->SetEnabled (false); - bg->AddChild (fStop); - fInfo = new BButton (BRect (mybounds.right - 120, mybounds.bottom - 32, mybounds.right - 68, mybounds.bottom - 8), "AddonInfo", lstring (371, "Info"), new BMessage ('ao_i'), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT); - bg->AddChild (fInfo); - fApply = new BButton (BRect (mybounds.right - 60, mybounds.bottom - 32, mybounds.right - 8, mybounds.bottom - 8), "AddonApply", lstring (373, "Apply"), 0, B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT); - bg->AddChild (fApply); - fApply->MakeDefault (true); + bg = new BView(mybounds, "addonbg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); + bg->SetViewColor(LightGrey); + AddChild(bg); + fStatusBar = new BStatusBar( + BRect(mybounds.left + 8, mybounds.bottom - 68, mybounds.right - 8, mybounds.bottom - 60), + "AddonStatusBar" + ); + fStatusBar->SetResizingMode(B_FOLLOW_BOTTOM); + bg->AddChild(fStatusBar); + fStatusBar->SetBarHeight(8); + fStop = new BButton( + BRect( + mybounds.right - 180, mybounds.bottom - 32, mybounds.right - 128, mybounds.bottom - 8 + ), + "AddonStop", lstring(370, "Stop"), new BMessage('ao_s'), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT + ); + fStop->SetEnabled(false); + bg->AddChild(fStop); + fInfo = new BButton( + BRect(mybounds.right - 120, mybounds.bottom - 32, mybounds.right - 68, mybounds.bottom - 8), + "AddonInfo", lstring(371, "Info"), new BMessage('ao_i'), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT + ); + bg->AddChild(fInfo); + fApply = new BButton( + BRect(mybounds.right - 60, mybounds.bottom - 32, mybounds.right - 8, mybounds.bottom - 8), + "AddonApply", lstring(373, "Apply"), 0, B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT + ); + bg->AddChild(fApply); + fApply->MakeDefault(true); fClient = 0; } -void AddOnWindow::SetAddOn (becasso_addon_info *info) +void +AddOnWindow::SetAddOn(becasso_addon_info* info) { - SetName (info->name); - BMessage *msg = NULL; - switch (info->type) - { + SetName(info->name); + BMessage* msg = NULL; + switch (info->type) { case BECASSO_FILTER: - msg = new BMessage (ADDON_FILTER); + msg = new BMessage(ADDON_FILTER); break; case BECASSO_TRANSFORMER: - msg = new BMessage (ADDON_TRANSFORMER); + msg = new BMessage(ADDON_TRANSFORMER); break; case BECASSO_GENERATOR: - msg = new BMessage (ADDON_GENERATOR); + msg = new BMessage(ADDON_GENERATOR); break; default: - fprintf (stderr, "AddOnWindow: Unknown Add-On Type!\n"); - throw (0); + fprintf(stderr, "AddOnWindow: Unknown Add-On Type!\n"); + throw(0); } - msg->AddInt32 ("index", info->index); - fApply->SetMessage (msg); - memcpy (&fInfoStruct, info, sizeof (becasso_addon_info)); + msg->AddInt32("index", info->index); + fApply->SetMessage(msg); + memcpy(&fInfoStruct, info, sizeof(becasso_addon_info)); stop = false; } -AddOnWindow::~AddOnWindow () -{ -} +AddOnWindow::~AddOnWindow() {} -bool AddOnWindow::QuitRequested () +bool +AddOnWindow::QuitRequested() { -// printf ("AddOnWindow::QuitRequested ()\n"); - SetClient (NULL); // This sends a message to the previous client; - // that'll notify the AddOn. + // printf ("AddOnWindow::QuitRequested ()\n"); + SetClient(NULL); // This sends a message to the previous client; + // that'll notify the AddOn. return false; } -void AddOnWindow::Start () +void +AddOnWindow::Start() { ResetStatusBar(); - fStop->SetEnabled (true); + fStop->SetEnabled(true); } -void AddOnWindow::Stopped () +void +AddOnWindow::Stopped() { ResetStatusBar(); - fStop->SetEnabled (false); + fStop->SetEnabled(false); stop = false; } -void AddOnWindow::UpdateStatusBar (float delta, const char *text, const char *trailingText) +void +AddOnWindow::UpdateStatusBar(float delta, const char* text, const char* trailingText) { - fStatusBar->Update (delta, text, trailingText); + fStatusBar->Update(delta, text, trailingText); UpdateIfNeeded(); } -void AddOnWindow::ResetStatusBar (const char *label, const char *trailingLabel) +void +AddOnWindow::ResetStatusBar(const char* label, const char* trailingLabel) { - fStatusBar->Reset (label, trailingLabel); + fStatusBar->Reset(label, trailingLabel); UpdateIfNeeded(); } -void AddOnWindow::aPreview () +void +AddOnWindow::aPreview() { - BMessage *msg = new BMessage (ADDON_PREVIEW); - msg->AddInt32 ("type", fInfoStruct.type); - msg->AddInt32 ("index", fInfoStruct.index); + BMessage* msg = new BMessage(ADDON_PREVIEW); + msg->AddInt32("type", fInfoStruct.type); + msg->AddInt32("index", fInfoStruct.index); fClient->Lock(); - fClient->PostMessage (msg); + fClient->PostMessage(msg); fClient->Unlock(); delete msg; } -void AddOnWindow::SetClient (BWindow *client) +void +AddOnWindow::SetClient(BWindow* client) { -// printf ("AddOnWindow::SetClient\n"); - CanvasWindow *old_win = dynamic_cast (fClient); + // printf ("AddOnWindow::SetClient\n"); + CanvasWindow* old_win = dynamic_cast(fClient); - if (old_win && old_win != client && !(old_win->IsQuitting())) - { -// printf ("Sending Bye message...\n"); - BMessenger tmpmessenger (fClient); - BMessage *bye = new BMessage ('adcl'); + if (old_win && old_win != client && !(old_win->IsQuitting())) { + // printf ("Sending Bye message...\n"); + BMessenger tmpmessenger(fClient); + BMessage* bye = new BMessage('adcl'); BMessage reply; - bye->AddInt32 ("index", fInfoStruct.index); - tmpmessenger.SendMessage (bye, &reply, 100000, 100000); + bye->AddInt32("index", fInfoStruct.index); + tmpmessenger.SendMessage(bye, &reply, 100000, 100000); delete bye; } fClient = client; - - CanvasWindow *new_win = dynamic_cast (fClient); -// printf ("client = %p, old_win = %p, new_win = %p\n", client, old_win, new_win); - - if (new_win) - { + + CanvasWindow* new_win = dynamic_cast(fClient); + // printf ("client = %p, old_win = %p, new_win = %p\n", client, old_win, new_win); + + if (new_win) { char name[256]; - sprintf (name, "%s %s", fInfoStruct.name, new_win->CanvasName()); - SetTitle (name); + sprintf(name, "%s %s", fInfoStruct.name, new_win->CanvasName()); + SetTitle(name); } - fApply->SetTarget (client); + fApply->SetTarget(client); } -void AddOnWindow::MessageReceived (BMessage *msg) +void +AddOnWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case 'ao_i': - { + switch (msg->what) { + case 'ao_i': { char infostring[1024]; - sprintf (infostring, "%s ", fInfoStruct.name); - switch (fInfoStruct.type) - { + sprintf(infostring, "%s ", fInfoStruct.name); + switch (fInfoStruct.type) { case BECASSO_FILTER: - strcat (infostring, "Filter "); + strcat(infostring, "Filter "); break; case BECASSO_TRANSFORMER: - strcat (infostring, "Transformer "); + strcat(infostring, "Transformer "); break; case BECASSO_GENERATOR: - strcat (infostring, "Generator "); + strcat(infostring, "Generator "); break; default: - fprintf (stderr, "AddOnWindow: Unknown Add-On Type!\n"); + fprintf(stderr, "AddOnWindow: Unknown Add-On Type!\n"); } char version[16]; - sprintf (version, "v%i.%i\n", fInfoStruct.version, fInfoStruct.release); - strcat (infostring, version); - strcat (infostring, fInfoStruct.author); - strcat (infostring, "\n"); - strcat (infostring, fInfoStruct.copyright); - strcat (infostring, "\n"); - strcat (infostring, fInfoStruct.description); - BAlert *infoBox = new BAlert ("", infostring, "OK"); + sprintf(version, "v%i.%i\n", fInfoStruct.version, fInfoStruct.release); + strcat(infostring, version); + strcat(infostring, fInfoStruct.author); + strcat(infostring, "\n"); + strcat(infostring, fInfoStruct.copyright); + strcat(infostring, "\n"); + strcat(infostring, fInfoStruct.description); + BAlert* infoBox = new BAlert("", infostring, "OK"); infoBox->Go(); break; } case 'ao_s': stop = true; break; - case 'cack': // Closing is acknowledged by the client. - printf ("cack\n"); + case 'cack': // Closing is acknowledged by the client. + printf("cack\n"); break; - case ADDON_RESIZED: - { + case ADDON_RESIZED: { // Note: see AddOn::Open() - BView *config = FindView ("config view"); - if (config) - { + BView* config = FindView("config view"); + if (config) { BRect bounds = config->Bounds(); if (bounds.right < 188) bounds.right = 188; bounds.bottom += 64; - ResizeTo (bounds.Width(), bounds.Height()); - } - else - fprintf (stderr, "AddOnWindow: ADDON_RESIZED but couldn't find config view\n"); + ResizeTo(bounds.Width(), bounds.Height()); + } else + fprintf(stderr, "AddOnWindow: ADDON_RESIZED but couldn't find config view\n"); break; } default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } diff --git a/source/AddOnWindow.h b/source/AddOnWindow.h index efc19bd..9ff306d 100644 --- a/source/AddOnWindow.h +++ b/source/AddOnWindow.h @@ -12,32 +12,34 @@ class AddOnWindow : public BWindow { -public: - AddOnWindow (BRect frame); -virtual ~AddOnWindow (); - void SetAddOn (becasso_addon_info *info); - void SetClient (BWindow *client); - - void aPreview (); - -virtual void MessageReceived (BMessage *msg); -virtual bool QuitRequested (); - -bool Stop () { return stop; }; -void Stopped (); -void Start (); -void UpdateStatusBar (float delta, const char *text = NULL, const char *trailingText = NULL); -void ResetStatusBar (const char *label = NULL, const char *trailingLabel = NULL); -BView *Background () { return bg; }; - -private: -typedef BWindow inherited; -bool stop; -BWindow *fClient; -BView *bg; -BButton *fStop, *fInfo, *fApply; -BStatusBar *fStatusBar; -becasso_addon_info fInfoStruct; + public: + AddOnWindow(BRect frame); + virtual ~AddOnWindow(); + void SetAddOn(becasso_addon_info* info); + void SetClient(BWindow* client); + + void aPreview(); + + virtual void MessageReceived(BMessage* msg); + virtual bool QuitRequested(); + + bool Stop() { return stop; }; + + void Stopped(); + void Start(); + void UpdateStatusBar(float delta, const char* text = NULL, const char* trailingText = NULL); + void ResetStatusBar(const char* label = NULL, const char* trailingLabel = NULL); + + BView* Background() { return bg; }; + + private: + typedef BWindow inherited; + bool stop; + BWindow* fClient; + BView* bg; + BButton *fStop, *fInfo, *fApply; + BStatusBar* fStatusBar; + becasso_addon_info fInfoStruct; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribBrush.cpp b/source/AttribBrush.cpp index 959f0be..494e48e 100644 --- a/source/AttribBrush.cpp +++ b/source/AttribBrush.cpp @@ -18,10 +18,9 @@ static property_info prop_list[] = { 0 }; -AttribBrush::AttribBrush () -: AttribView (BRect (0, 0, 160, 280), lstring (22, "Brush")) +AttribBrush::AttribBrush() : AttribView(BRect(0, 0, 160, 280), lstring(22, "Brush")) { - SetViewColor (LightGrey); + SetViewColor(LightGrey); fSpacing = 1; fAngle = 0; fX = 5; @@ -29,303 +28,302 @@ AttribBrush::AttribBrush () fHardness = 1; fStrength = 128; fBrush = NULL; - bv = new BitmapView (BRect (4, 4, 154, 154), "BrushBitmapView"); - AddChild (bv); + bv = new BitmapView(BRect(4, 4, 154, 154), "BrushBitmapView"); + AddChild(bv); ConstructBrush(); - xSlid = new Slider (BRect (4, 160, 154, 176), 60, lstring (300, "X-size"), 1, 40, 1, new BMessage ('ABxc'), B_HORIZONTAL, 26); - ySlid = new Slider (BRect (4, 180, 154, 196), 60, lstring (301, "Y-size"), 1, 40, 1, new BMessage ('AByc'), B_HORIZONTAL, 26); - aSlid = new Slider (BRect (4, 200, 154, 216), 60, lstring (302, "Angle"), 0, 45, 1, new BMessage ('ABac'), B_HORIZONTAL, 26); - sSlid = new Slider (BRect (4, 220, 154, 236), 60, lstring (303, "Strength"), 0, 255, 1, new BMessage ('ABsc'), B_HORIZONTAL, 26); - hSlid = new Slider (BRect (4, 240, 154, 256), 60, lstring (305, "Hardness"), 1, 100, 1, new BMessage ('ABph'), B_HORIZONTAL, 26); - pSlid = new Slider (BRect (4, 260, 154, 276), 60, lstring (304, "Spacing"), 1, 64, 1, new BMessage ('ABpc'), B_HORIZONTAL, 26); - AddChild (xSlid); - AddChild (ySlid); - AddChild (aSlid); - AddChild (sSlid); - AddChild (hSlid); - AddChild (pSlid); - xSlid->SetValue (fX); - ySlid->SetValue (fY); - sSlid->SetValue (fStrength); - hSlid->SetValue (fHardness); + xSlid = new Slider( + BRect(4, 160, 154, 176), 60, lstring(300, "X-size"), 1, 40, 1, new BMessage('ABxc'), + B_HORIZONTAL, 26 + ); + ySlid = new Slider( + BRect(4, 180, 154, 196), 60, lstring(301, "Y-size"), 1, 40, 1, new BMessage('AByc'), + B_HORIZONTAL, 26 + ); + aSlid = new Slider( + BRect(4, 200, 154, 216), 60, lstring(302, "Angle"), 0, 45, 1, new BMessage('ABac'), + B_HORIZONTAL, 26 + ); + sSlid = new Slider( + BRect(4, 220, 154, 236), 60, lstring(303, "Strength"), 0, 255, 1, new BMessage('ABsc'), + B_HORIZONTAL, 26 + ); + hSlid = new Slider( + BRect(4, 240, 154, 256), 60, lstring(305, "Hardness"), 1, 100, 1, new BMessage('ABph'), + B_HORIZONTAL, 26 + ); + pSlid = new Slider( + BRect(4, 260, 154, 276), 60, lstring(304, "Spacing"), 1, 64, 1, new BMessage('ABpc'), + B_HORIZONTAL, 26 + ); + AddChild(xSlid); + AddChild(ySlid); + AddChild(aSlid); + AddChild(sSlid); + AddChild(hSlid); + AddChild(pSlid); + xSlid->SetValue(fX); + ySlid->SetValue(fY); + sSlid->SetValue(fStrength); + hSlid->SetValue(fHardness); fCurrentProperty = 0; } -AttribBrush::~AttribBrush () +AttribBrush::~AttribBrush() { -// RemoveChild (bv); -// delete bv; + // RemoveChild (bv); + // delete bv; delete fBrush; } -void AttribBrush::ConstructBrush () +void +AttribBrush::ConstructBrush() { delete fBrush; - float rangle = -fAngle/180*M_PI; - int ssx = 2*fX + 1; - int ssy = 2*fY + 1; - int sx = max_c (abs (int (ssx*cos (rangle))), abs (int ((ssy*sin (rangle))*(1.0 + sin (-rangle)/4)))); - int sy = max_c (abs (int (ssy*cos (rangle))), abs (int ((ssx*sin (rangle))*(1.0 + sin (-rangle)/4)))); + float rangle = -fAngle / 180 * M_PI; + int ssx = 2 * fX + 1; + int ssy = 2 * fY + 1; + int sx = max_c( + abs(int(ssx * cos(rangle))), abs(int((ssy * sin(rangle)) * (1.0 + sin(-rangle) / 4))) + ); + int sy = max_c( + abs(int(ssy * cos(rangle))), abs(int((ssx * sin(rangle)) * (1.0 + sin(-rangle) / 4))) + ); // printf ("Width: %d, Height: %d\n", sx, sy); - fBrush = new Brush (sy*1.1, sx*1.1, fSpacing); - mkGaussianBrush (fBrush, fX, fY, fAngle, fStrength, fHardness/10 + 1); - bv->SetBitmap (fBrush->ToBitmap (Black, White)); -// printf ("bv = %p, fBrush = %p\n", bv, fBrush); + fBrush = new Brush(sy * 1.1, sx * 1.1, fSpacing); + mkGaussianBrush(fBrush, fX, fY, fAngle, fStrength, fHardness / 10 + 1); + bv->SetBitmap(fBrush->ToBitmap(Black, White)); + // printf ("bv = %p, fBrush = %p\n", bv, fBrush); } -inline float sgn (float f) +inline float +sgn(float f) { return (f < 0 ? -1 : (f == 0 ? 0 : 1)); } -inline float hfunc (float r, float s) +inline float +hfunc(float r, float s) { - return (pow (r, s)); + return (pow(r, s)); } -void AttribBrush::mkGaussianBrush (Brush *b, float sigmaxsq, float sigmaysq, float angle, int cval, float hardness) +void +AttribBrush::mkGaussianBrush( + Brush* b, float sigmaxsq, float sigmaysq, float angle, int cval, float hardness +) { - int hw = b->Width()/2; - int hh = b->Height()/2; - float rangle = -angle/180*M_PI; - for (float x = -hw; x <= hw; x++) - { - for (float y = -hh; y <= hh; y++) - { - register float rx = (x*cos (rangle) + y*sin (rangle))/sigmaxsq*2; - register float ry = (x*sin (rangle) - y*cos (rangle))/sigmaysq*2; - register float r = rx*rx + ry*ry; - b->Set (hw + x, hh + y, cval*exp (-(hfunc (r, hardness)))); + int hw = b->Width() / 2; + int hh = b->Height() / 2; + float rangle = -angle / 180 * M_PI; + for (float x = -hw; x <= hw; x++) { + for (float y = -hh; y <= hh; y++) { + register float rx = (x * cos(rangle) + y * sin(rangle)) / sigmaxsq * 2; + register float ry = (x * sin(rangle) - y * cos(rangle)) / sigmaysq * 2; + register float r = rx * rx + ry * ry; + b->Set(hw + x, hh + y, cval * exp(-(hfunc(r, hardness)))); } } } -void AttribBrush::mkDiagonalBrush (Brush *b, int dir) +void +AttribBrush::mkDiagonalBrush(Brush* b, int dir) { - int d = min_c (b->Height(), b->Width()) - 1; - if (dir > 0) // forward slash + int d = min_c(b->Height(), b->Width()) - 1; + if (dir > 0) // forward slash { - for (int i = 1; i < d; i++) - { - b->Set (i, d - i, 255); - b->Set (i - 1, d - i, 128); - b->Set (i, d - i + 1, 128); + for (int i = 1; i < d; i++) { + b->Set(i, d - i, 255); + b->Set(i - 1, d - i, 128); + b->Set(i, d - i + 1, 128); } - b->Set (0, d, 64); - b->Set (d, 0, 64); - b->Set (d, 1, 128); - b->Set (d - 1, 0, 128); - } - else // backward slash + b->Set(0, d, 64); + b->Set(d, 0, 64); + b->Set(d, 1, 128); + b->Set(d - 1, 0, 128); + } else // backward slash { - for (int i = 1; i < d; i++) - { - b->Set (i, i, 255); - b->Set (i, i - 1, 128); - b->Set (i - 1, i, 128); + for (int i = 1; i < d; i++) { + b->Set(i, i, 255); + b->Set(i, i - 1, 128); + b->Set(i - 1, i, 128); } - b->Set (0, 0, 64); - b->Set (d, d, 64); - b->Set (d, d - 1, 128); - b->Set (d - 1, d, 128); + b->Set(0, 0, 64); + b->Set(d, d, 64); + b->Set(d, d - 1, 128); + b->Set(d - 1, d, 128); } } -status_t AttribBrush::GetSupportedSuites (BMessage *message) +status_t +AttribBrush::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso-Brush"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso-Brush"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -BHandler *AttribBrush::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribBrush::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { -// printf ("\nmessage:\n"); -// message->PrintToStream(); -// printf ("specifier:\n"); -// specifier->PrintToStream(); -// printf ("Property: %s\n", property); - - if (!strcasecmp (property, "Spacing")) - { + // printf ("\nmessage:\n"); + // message->PrintToStream(); + // printf ("specifier:\n"); + // specifier->PrintToStream(); + // printf ("Property: %s\n", property); + + if (!strcasecmp(property, "Spacing")) { fCurrentProperty = PROP_SPACING; return this; } - if (!strcasecmp (property, "Strength")) - { + if (!strcasecmp(property, "Strength")) { fCurrentProperty = PROP_STRENGTH; return this; } - if (!strcasecmp (property, "Angle")) - { + if (!strcasecmp(property, "Angle")) { fCurrentProperty = PROP_ANGLE; return this; } - if (!strcasecmp (property, "Width") || !strcasecmp (property, "XSize")) - { + if (!strcasecmp(property, "Width") || !strcasecmp(property, "XSize")) { fCurrentProperty = PROP_X; return this; } - if (!strcasecmp (property, "Height") || !strcasecmp (property, "YSize")) - { + if (!strcasecmp(property, "Height") || !strcasecmp(property, "YSize")) { fCurrentProperty = PROP_Y; return this; } - if (!strcasecmp (property, "Hardness")) - { + if (!strcasecmp(property, "Hardness")) { fCurrentProperty = PROP_HARDNESS; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } - -void AttribBrush::MessageReceived (BMessage *msg) +void +AttribBrush::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_SPACING: // float, 1 .. 64 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_SPACING: // float, 1 .. 64 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 1 && value <= 40) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 1 && value <= 40) { fSpacing = value; - pSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + pSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } ConstructBrush(); } } break; } - case PROP_STRENGTH: // int, 0 .. 255 + case PROP_STRENGTH: // int, 0 .. 255 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) - { - if (value >= 0 && value <= 255) - { + if (msg->FindInt32("data", &value) == B_OK) { + if (value >= 0 && value <= 255) { fStrength = value; - sSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + sSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } ConstructBrush(); } } break; } - case PROP_HARDNESS: // int, 0 .. 100 + case PROP_HARDNESS: // int, 0 .. 100 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) - { - if (value >= 1 && value <= 100) - { + if (msg->FindInt32("data", &value) == B_OK) { + if (value >= 1 && value <= 100) { fHardness = value; - hSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + hSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } ConstructBrush(); } } break; } - case PROP_ANGLE: // float, 0 .. 45 + case PROP_ANGLE: // float, 0 .. 45 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 45) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 45) { fAngle = value; - aSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + aSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } ConstructBrush(); } } break; } - case PROP_X: // int, 1 .. 40 + case PROP_X: // int, 1 .. 40 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) - { - if (value >= 1 && value <= 40) - { + if (msg->FindInt32("data", &value) == B_OK) { + if (value >= 1 && value <= 40) { fX = value; - xSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + xSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } ConstructBrush(); } } break; } - case PROP_Y: // int, 1 .. 40 + case PROP_Y: // int, 1 .. 40 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) - { - if (value >= 1 && value <= 40) - { + if (msg->FindInt32("data", &value) == B_OK) { + if (value >= 1 && value <= 40) { fY = value; - ySlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + ySlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } ConstructBrush(); } @@ -334,40 +332,40 @@ void AttribBrush::MessageReceived (BMessage *msg) } } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'ABxc': - fX = int (msg->FindFloat ("value")); + fX = int(msg->FindFloat("value")); ConstructBrush(); - fSpacing = sqrt (fX + fY); - pSlid->SetValue (fSpacing); + fSpacing = sqrt(fX + fY); + pSlid->SetValue(fSpacing); break; case 'AByc': - fY = int (msg->FindFloat ("value")); - fSpacing = sqrt (fX + fY); - pSlid->SetValue (fSpacing); + fY = int(msg->FindFloat("value")); + fSpacing = sqrt(fX + fY); + pSlid->SetValue(fSpacing); ConstructBrush(); break; case 'ABsc': - fStrength = int (msg->FindFloat ("value")); + fStrength = int(msg->FindFloat("value")); ConstructBrush(); break; case 'ABac': - fAngle = msg->FindFloat ("value"); + fAngle = msg->FindFloat("value"); ConstructBrush(); break; case 'ABph': - fHardness = msg->FindFloat ("value"); + fHardness = msg->FindFloat("value"); ConstructBrush(); break; case 'ABpc': - fSpacing = msg->FindFloat ("value"); + fSpacing = msg->FindFloat("value"); ConstructBrush(); break; default: - //msg->PrintToStream(); - inherited::MessageReceived (msg); + // msg->PrintToStream(); + inherited::MessageReceived(msg); } bv->Invalidate(); } diff --git a/source/AttribBrush.h b/source/AttribBrush.h index 3dce9d3..4c880d9 100644 --- a/source/AttribBrush.h +++ b/source/AttribBrush.h @@ -7,42 +7,49 @@ #include "Brush.h" #include "Slider.h" -#define PROP_SPACING 1 -#define PROP_STRENGTH 2 -#define PROP_ANGLE 3 -#define PROP_X 4 -#define PROP_Y 5 -#define PROP_HARDNESS 6 +#define PROP_SPACING 1 +#define PROP_STRENGTH 2 +#define PROP_ANGLE 3 +#define PROP_X 4 +#define PROP_Y 5 +#define PROP_HARDNESS 6 class AttribBrush : public AttribView { -public: - AttribBrush (); -virtual ~AttribBrush (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -float getSpacing () { return fSpacing; }; -int getStrength () { return fStrength; }; -Brush *getBrush () { return fBrush; }; - -private: -typedef AttribView inherited; -void ConstructBrush (); -void mkGaussianBrush (Brush *b, float sigmaxsq, float sigmaysq, float angle, int cval, float hardness); -void mkDiagonalBrush (Brush *b, int dir); - -float fSpacing; -int fStrength; -float fAngle; -int fX; -int fY; -float fHardness; -Brush *fBrush; -BitmapView *bv; -int fCurrentProperty; - -Slider *pSlid, *xSlid, *ySlid, *aSlid, *sSlid, *hSlid; + public: + AttribBrush(); + virtual ~AttribBrush(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + + float getSpacing() { return fSpacing; }; + + int getStrength() { return fStrength; }; + + Brush* getBrush() { return fBrush; }; + + private: + typedef AttribView inherited; + void ConstructBrush(); + void mkGaussianBrush( + Brush* b, float sigmaxsq, float sigmaysq, float angle, int cval, float hardness + ); + void mkDiagonalBrush(Brush* b, int dir); + + float fSpacing; + int fStrength; + float fAngle; + int fX; + int fY; + float fHardness; + Brush* fBrush; + BitmapView* bv; + int fCurrentProperty; + + Slider *pSlid, *xSlid, *ySlid, *aSlid, *sSlid, *hSlid; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribCircle.cpp b/source/AttribCircle.cpp index 914d331..053a194 100644 --- a/source/AttribCircle.cpp +++ b/source/AttribCircle.cpp @@ -13,338 +13,323 @@ static property_info prop_list[] = { 0 }; - -AttribCircle::AttribCircle () -: AttribView (BRect (0, 0, 148, 148), lstring (33, "Circles")) +AttribCircle::AttribCircle() : AttribView(BRect(0, 0, 148, 148), lstring(33, "Circles")) { - SetViewColor (LightGrey); - lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc')); - AddChild (lSlid); + SetViewColor(LightGrey); + lSlid = new Slider( + BRect(8, 8, 140, 26), 60, lstring(310, "Pen Size"), 1, 50, 1, new BMessage('ALpc') + ); + AddChild(lSlid); fType = CIRCLE_OUTFILL; fFirst = FIXES_CENTER; fPenSize = 1; - BBox *type = new BBox (BRect (18, 32, 130, 82), "type"); - type->SetLabel (lstring (311, "Type")); - AddChild (type); - BBox *first = new BBox (BRect (18, 90, 130, 140), "first"); - first->SetLabel (lstring (312, "First Click")); - AddChild (first); - - BRect shape = BRect (4, 4, 26, 26); - BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL)); - BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL)); - picWindow->AddChild (bg); + BBox* type = new BBox(BRect(18, 32, 130, 82), "type"); + type->SetLabel(lstring(311, "Type")); + AddChild(type); + BBox* first = new BBox(BRect(18, 90, 130, 140), "first"); + first->SetLabel(lstring(312, "First Click")); + AddChild(first); + + BRect shape = BRect(4, 4, 26, 26); + BWindow* picWindow = new BWindow( + BRect(0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32(NULL), uint32(NULL) + ); + BView* bg = new BView(BRect(0, 0, 100, 100), "Temp Pic View", uint32(NULL), uint32(NULL)); + picWindow->AddChild(bg); - BPicture *p10; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetLowColor (White); - bg->FillEllipse (shape, B_SOLID_LOW); - bg->StrokeEllipse (shape); + BPicture* p10; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetLowColor(White); + bg->FillEllipse(shape, B_SOLID_LOW); + bg->StrokeEllipse(shape); p10 = bg->EndPicture(); - - BPicture *p20; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillEllipse (shape, B_SOLID_LOW); + + BPicture* p20; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillEllipse(shape, B_SOLID_LOW); p20 = bg->EndPicture(); - - BPicture *p30; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->StrokeEllipse (shape); + + BPicture* p30; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->StrokeEllipse(shape); p30 = bg->EndPicture(); - BPicture *p11; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillEllipse (shape, B_SOLID_LOW); - bg->StrokeEllipse (shape); + BPicture* p11; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillEllipse(shape, B_SOLID_LOW); + bg->StrokeEllipse(shape); p11 = bg->EndPicture(); - - BPicture *p21; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillEllipse (shape, B_SOLID_LOW); + + BPicture* p21; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillEllipse(shape, B_SOLID_LOW); p21 = bg->EndPicture(); - - BPicture *p31; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->StrokeEllipse (shape); + + BPicture* p31; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->StrokeEllipse(shape); p31 = bg->EndPicture(); - - BPicture *p40; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->StrokeEllipse (shape); - bg->SetHighColor (Red); - bg->StrokeLine (BPoint (12, 15), BPoint (18, 15)); - bg->StrokeLine (BPoint (15, 12), BPoint (15, 18)); + + BPicture* p40; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->StrokeEllipse(shape); + bg->SetHighColor(Red); + bg->StrokeLine(BPoint(12, 15), BPoint(18, 15)); + bg->StrokeLine(BPoint(15, 12), BPoint(15, 18)); p40 = bg->EndPicture(); - - BPicture *p41; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->StrokeEllipse (shape); - bg->SetHighColor (Red); - bg->StrokeLine (BPoint (12, 15), BPoint (18, 15)); - bg->StrokeLine (BPoint (15, 12), BPoint (15, 18)); + + BPicture* p41; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->StrokeEllipse(shape); + bg->SetHighColor(Red); + bg->StrokeLine(BPoint(12, 15), BPoint(18, 15)); + bg->StrokeLine(BPoint(15, 12), BPoint(15, 18)); p41 = bg->EndPicture(); - - BPicture *p50; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->StrokeEllipse (shape); - bg->SetHighColor (Red); - bg->StrokeLine (BPoint (5, 7), BPoint (11, 7)); - bg->StrokeLine (BPoint (8, 4), BPoint (8, 10)); + + BPicture* p50; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->StrokeEllipse(shape); + bg->SetHighColor(Red); + bg->StrokeLine(BPoint(5, 7), BPoint(11, 7)); + bg->StrokeLine(BPoint(8, 4), BPoint(8, 10)); p50 = bg->EndPicture(); - BPicture *p51; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->StrokeEllipse (shape); - bg->SetHighColor (Red); - bg->StrokeLine (BPoint (5, 7), BPoint (11, 7)); - bg->StrokeLine (BPoint (8, 4), BPoint (8, 10)); + BPicture* p51; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->StrokeEllipse(shape); + bg->SetHighColor(Red); + bg->StrokeLine(BPoint(5, 7), BPoint(11, 7)); + bg->StrokeLine(BPoint(8, 4), BPoint(8, 10)); p51 = bg->EndPicture(); - + delete picWindow; - - pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON); - pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON); - pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON); - pF1 = new BPictureButton (BRect (22, 15, 52, 45), "ACVt1", p40, p41, new BMessage ('pvF1'), B_TWO_STATE_BUTTON); - pF2 = new BPictureButton (BRect (58, 15, 88, 45), "ACTt2", p50, p51, new BMessage ('pvF2'), B_TWO_STATE_BUTTON); - type->AddChild (pT1); - type->AddChild (pT2); - type->AddChild (pT3); - first->AddChild (pF1); - first->AddChild (pF2); - pT1->SetValue (B_CONTROL_ON); - pF1->SetValue (B_CONTROL_ON); - - fCurrentProperty = 0; -} + pT1 = new BPictureButton( + BRect(4, 15, 34, 45), "APVt1", p10, p11, new BMessage('pvT1'), B_TWO_STATE_BUTTON + ); + pT2 = new BPictureButton( + BRect(40, 15, 70, 45), "APVt2", p20, p21, new BMessage('pvT2'), B_TWO_STATE_BUTTON + ); + pT3 = new BPictureButton( + BRect(76, 15, 106, 45), "APVt3", p30, p31, new BMessage('pvT3'), B_TWO_STATE_BUTTON + ); + pF1 = new BPictureButton( + BRect(22, 15, 52, 45), "ACVt1", p40, p41, new BMessage('pvF1'), B_TWO_STATE_BUTTON + ); + pF2 = new BPictureButton( + BRect(58, 15, 88, 45), "ACTt2", p50, p51, new BMessage('pvF2'), B_TWO_STATE_BUTTON + ); + type->AddChild(pT1); + type->AddChild(pT2); + type->AddChild(pT3); + first->AddChild(pF1); + first->AddChild(pF2); + pT1->SetValue(B_CONTROL_ON); + pF1->SetValue(B_CONTROL_ON); -AttribCircle::~AttribCircle () -{ + fCurrentProperty = 0; } -status_t AttribCircle::GetSupportedSuites (BMessage *message) +AttribCircle::~AttribCircle() {} + +status_t +AttribCircle::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso-Circle"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso-Circle"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -BHandler *AttribCircle::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribCircle::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - if (!strcasecmp (property, "PenSize")) - { + if (!strcasecmp(property, "PenSize")) { fCurrentProperty = PROP_PENSIZE; return this; } - if (!strcasecmp (property, "ShapeType") || !strcasecmp (property, "Type")) - { + if (!strcasecmp(property, "ShapeType") || !strcasecmp(property, "Type")) { fCurrentProperty = PROP_TYPE; return this; } - if (!strcasecmp (property, "FixPoint") || !strcasecmp (property, "FirstClick")) - { + if (!strcasecmp(property, "FixPoint") || !strcasecmp(property, "FirstClick")) { fCurrentProperty = PROP_FIXPOINT; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribCircle::MessageReceived (BMessage *msg) +void +AttribCircle::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_PENSIZE: // float, 0 .. 50 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_PENSIZE: // float, 0 .. 50 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 50) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 50) { fPenSize = value; - lSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + lSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_TYPE: // FilledOutline, Filled, Outline + case PROP_TYPE: // FilledOutline, Filled, Outline { - const char *name; + const char* name; int value = 0; - if (msg->FindString ("data", &name) == B_OK) - { - if (!strcasecmp (name, "FilledOutline")) - { - pT1->SetValue (B_CONTROL_ON); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_OFF); + if (msg->FindString("data", &name) == B_OK) { + if (!strcasecmp(name, "FilledOutline")) { + pT1->SetValue(B_CONTROL_ON); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_OFF); value = CIRCLE_OUTFILL; - } - else if (!strcasecmp (name, "Filled")) - { - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_ON); - pT3->SetValue (B_CONTROL_OFF); + } else if (!strcasecmp(name, "Filled")) { + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_ON); + pT3->SetValue(B_CONTROL_OFF); value = CIRCLE_FILL; - } - else if (!strcasecmp (name, "Outline")) - { - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_ON); + } else if (!strcasecmp(name, "Outline")) { + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_ON); value = CIRCLE_OUTLINE; } - if (value) - { + if (value) { fType = value; - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } - } - else - { + } else { // Error report... } } break; } - case PROP_FIXPOINT: // Center, Perimeter + case PROP_FIXPOINT: // Center, Perimeter { - const char *name; + const char* name; int value = 0; - if (msg->FindString ("data", &name) == B_OK) - { - if (!strcasecmp (name, "Center")) - { - pF1->SetValue (B_CONTROL_ON); - pF2->SetValue (B_CONTROL_OFF); + if (msg->FindString("data", &name) == B_OK) { + if (!strcasecmp(name, "Center")) { + pF1->SetValue(B_CONTROL_ON); + pF2->SetValue(B_CONTROL_OFF); value = FIXES_CENTER; - } - else if (!strcasecmp (name, "Perimeter")) - { - pF1->SetValue (B_CONTROL_OFF); - pF2->SetValue (B_CONTROL_ON); + } else if (!strcasecmp(name, "Perimeter")) { + pF1->SetValue(B_CONTROL_OFF); + pF2->SetValue(B_CONTROL_ON); value = FIXES_PERIMETER; } - if (value) - { + if (value) { fFirst = value; - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } - } - else - { + } else { // Error report... } } } - fCurrentProperty = 0; - break; + fCurrentProperty = 0; + break; } - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'ALpc': - fPenSize = msg->FindFloat ("value"); + fPenSize = msg->FindFloat("value"); break; case 'pvT1': fType = CIRCLE_OUTFILL; - pT1->SetValue (B_CONTROL_ON); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_OFF); + pT1->SetValue(B_CONTROL_ON); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_OFF); break; case 'pvT2': fType = CIRCLE_FILL; - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_ON); - pT3->SetValue (B_CONTROL_OFF); + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_ON); + pT3->SetValue(B_CONTROL_OFF); break; case 'pvT3': fType = CIRCLE_OUTLINE; - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_ON); + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_ON); break; case 'pvF1': fFirst = FIXES_CENTER; - pF1->SetValue (B_CONTROL_ON); - pF2->SetValue (B_CONTROL_OFF); + pF1->SetValue(B_CONTROL_ON); + pF2->SetValue(B_CONTROL_OFF); break; case 'pvF2': fFirst = FIXES_PERIMETER; - pF1->SetValue (B_CONTROL_OFF); - pF2->SetValue (B_CONTROL_ON); + pF1->SetValue(B_CONTROL_OFF); + pF2->SetValue(B_CONTROL_ON); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AttribCircle.h b/source/AttribCircle.h index 0c305d5..02c08cd 100644 --- a/source/AttribCircle.h +++ b/source/AttribCircle.h @@ -7,36 +7,41 @@ #include "Slider.h" #define CIRCLE_OUTLINE 1 -#define CIRCLE_FILL 2 +#define CIRCLE_FILL 2 #define CIRCLE_OUTFILL 3 -#define FIXES_CENTER 1 +#define FIXES_CENTER 1 #define FIXES_PERIMETER 2 -#define PROP_PENSIZE 1 -#define PROP_TYPE 2 -#define PROP_FIXPOINT 3 +#define PROP_PENSIZE 1 +#define PROP_TYPE 2 +#define PROP_FIXPOINT 3 class AttribCircle : public AttribView { -public: - AttribCircle (); -virtual ~AttribCircle (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -float getPenSize () { return fPenSize; }; -int getType () { return fType; }; -int getFirst () { return fFirst; }; - -private: -typedef AttribView inherited; -float fPenSize; -int fType; -int fFirst; -BPictureButton *pT1, *pT2, *pT3, *pF1, *pF2; -Slider *lSlid; -int fCurrentProperty; + public: + AttribCircle(); + virtual ~AttribCircle(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + + float getPenSize() { return fPenSize; }; + + int getType() { return fType; }; + + int getFirst() { return fFirst; }; + + private: + typedef AttribView inherited; + float fPenSize; + int fType; + int fFirst; + BPictureButton *pT1, *pT2, *pT3, *pF1, *pF2; + Slider* lSlid; + int fCurrentProperty; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribClone.cpp b/source/AttribClone.cpp index 7781371..9574261 100644 --- a/source/AttribClone.cpp +++ b/source/AttribClone.cpp @@ -18,10 +18,9 @@ static property_info prop_list[] = { 0 }; -AttribClone::AttribClone () -: AttribView (BRect (0, 0, 160, 280), lstring (35, "Clone")) +AttribClone::AttribClone() : AttribView(BRect(0, 0, 160, 280), lstring(35, "Clone")) { - SetViewColor (LightGrey); + SetViewColor(LightGrey); fSpacing = 1; fAngle = 0; fX = 5; @@ -29,303 +28,302 @@ AttribClone::AttribClone () fHardness = 1; fStrength = 128; fBrush = NULL; - bv = new BitmapView (BRect (4, 4, 154, 154), "BrushBitmapView"); - AddChild (bv); + bv = new BitmapView(BRect(4, 4, 154, 154), "BrushBitmapView"); + AddChild(bv); ConstructBrush(); - xSlid = new Slider (BRect (4, 160, 154, 176), 60, lstring (300, "X-size"), 1, 40, 1, new BMessage ('ABxc'), B_HORIZONTAL, 26); - ySlid = new Slider (BRect (4, 180, 154, 196), 60, lstring (301, "Y-size"), 1, 40, 1, new BMessage ('AByc'), B_HORIZONTAL, 26); - aSlid = new Slider (BRect (4, 200, 154, 216), 60, lstring (302, "Angle"), 0, 45, 1, new BMessage ('ABac'), B_HORIZONTAL, 26); - sSlid = new Slider (BRect (4, 220, 154, 236), 60, lstring (303, "Strength"), 0, 255, 1, new BMessage ('ABsc'), B_HORIZONTAL, 26); - hSlid = new Slider (BRect (4, 240, 154, 256), 60, lstring (305, "Hardness"), 1, 100, 1, new BMessage ('ABph'), B_HORIZONTAL, 26); - pSlid = new Slider (BRect (4, 260, 154, 276), 60, lstring (304, "Spacing"), 1, 64, 1, new BMessage ('ABpc'), B_HORIZONTAL, 26); - AddChild (xSlid); - AddChild (ySlid); - AddChild (aSlid); - AddChild (sSlid); - AddChild (hSlid); - AddChild (pSlid); - xSlid->SetValue (fX); - ySlid->SetValue (fY); - sSlid->SetValue (fStrength); - hSlid->SetValue (fHardness); + xSlid = new Slider( + BRect(4, 160, 154, 176), 60, lstring(300, "X-size"), 1, 40, 1, new BMessage('ABxc'), + B_HORIZONTAL, 26 + ); + ySlid = new Slider( + BRect(4, 180, 154, 196), 60, lstring(301, "Y-size"), 1, 40, 1, new BMessage('AByc'), + B_HORIZONTAL, 26 + ); + aSlid = new Slider( + BRect(4, 200, 154, 216), 60, lstring(302, "Angle"), 0, 45, 1, new BMessage('ABac'), + B_HORIZONTAL, 26 + ); + sSlid = new Slider( + BRect(4, 220, 154, 236), 60, lstring(303, "Strength"), 0, 255, 1, new BMessage('ABsc'), + B_HORIZONTAL, 26 + ); + hSlid = new Slider( + BRect(4, 240, 154, 256), 60, lstring(305, "Hardness"), 1, 100, 1, new BMessage('ABph'), + B_HORIZONTAL, 26 + ); + pSlid = new Slider( + BRect(4, 260, 154, 276), 60, lstring(304, "Spacing"), 1, 64, 1, new BMessage('ABpc'), + B_HORIZONTAL, 26 + ); + AddChild(xSlid); + AddChild(ySlid); + AddChild(aSlid); + AddChild(sSlid); + AddChild(hSlid); + AddChild(pSlid); + xSlid->SetValue(fX); + ySlid->SetValue(fY); + sSlid->SetValue(fStrength); + hSlid->SetValue(fHardness); fCurrentProperty = 0; } -AttribClone::~AttribClone () +AttribClone::~AttribClone() { -// RemoveChild (bv); -// delete bv; + // RemoveChild (bv); + // delete bv; delete fBrush; } -void AttribClone::ConstructBrush () +void +AttribClone::ConstructBrush() { delete fBrush; - float rangle = -fAngle/180*M_PI; - int ssx = 2*fX + 1; - int ssy = 2*fY + 1; - int sx = max_c (abs (int (ssx*cos (rangle))), abs (int ((ssy*sin (rangle))*(1.0 + sin (-rangle)/4)))); - int sy = max_c (abs (int (ssy*cos (rangle))), abs (int ((ssx*sin (rangle))*(1.0 + sin (-rangle)/4)))); + float rangle = -fAngle / 180 * M_PI; + int ssx = 2 * fX + 1; + int ssy = 2 * fY + 1; + int sx = max_c( + abs(int(ssx * cos(rangle))), abs(int((ssy * sin(rangle)) * (1.0 + sin(-rangle) / 4))) + ); + int sy = max_c( + abs(int(ssy * cos(rangle))), abs(int((ssx * sin(rangle)) * (1.0 + sin(-rangle) / 4))) + ); // printf ("Width: %d, Height: %d\n", sx, sy); - fBrush = new Brush (sy*1.1, sx*1.1, fSpacing); - mkGaussianBrush (fBrush, fX, fY, fAngle, fStrength, fHardness/10 + 1); - bv->SetBitmap (fBrush->ToBitmap (Black, White)); -// printf ("bv = %p, fBrush = %p\n", bv, fBrush); + fBrush = new Brush(sy * 1.1, sx * 1.1, fSpacing); + mkGaussianBrush(fBrush, fX, fY, fAngle, fStrength, fHardness / 10 + 1); + bv->SetBitmap(fBrush->ToBitmap(Black, White)); + // printf ("bv = %p, fBrush = %p\n", bv, fBrush); } -inline float sgn (float f) +inline float +sgn(float f) { return (f < 0 ? -1 : (f == 0 ? 0 : 1)); } -inline float hfunc (float r, float s) +inline float +hfunc(float r, float s) { - return (pow (r, s)); + return (pow(r, s)); } -void AttribClone::mkGaussianBrush (Brush *b, float sigmaxsq, float sigmaysq, float angle, int cval, float hardness) +void +AttribClone::mkGaussianBrush( + Brush* b, float sigmaxsq, float sigmaysq, float angle, int cval, float hardness +) { - int hw = b->Width()/2; - int hh = b->Height()/2; - float rangle = -angle/180*M_PI; - for (float x = -hw; x <= hw; x++) - { - for (float y = -hh; y <= hh; y++) - { - register float rx = (x*cos (rangle) + y*sin (rangle))/sigmaxsq*2; - register float ry = (x*sin (rangle) - y*cos (rangle))/sigmaysq*2; - register float r = rx*rx + ry*ry; - b->Set (hw + x, hh + y, cval*exp (-(hfunc (r, hardness)))); + int hw = b->Width() / 2; + int hh = b->Height() / 2; + float rangle = -angle / 180 * M_PI; + for (float x = -hw; x <= hw; x++) { + for (float y = -hh; y <= hh; y++) { + register float rx = (x * cos(rangle) + y * sin(rangle)) / sigmaxsq * 2; + register float ry = (x * sin(rangle) - y * cos(rangle)) / sigmaysq * 2; + register float r = rx * rx + ry * ry; + b->Set(hw + x, hh + y, cval * exp(-(hfunc(r, hardness)))); } } } -void AttribClone::mkDiagonalBrush (Brush *b, int dir) +void +AttribClone::mkDiagonalBrush(Brush* b, int dir) { - int d = min_c (b->Height(), b->Width()) - 1; - if (dir > 0) // forward slash + int d = min_c(b->Height(), b->Width()) - 1; + if (dir > 0) // forward slash { - for (int i = 1; i < d; i++) - { - b->Set (i, d - i, 255); - b->Set (i - 1, d - i, 128); - b->Set (i, d - i + 1, 128); + for (int i = 1; i < d; i++) { + b->Set(i, d - i, 255); + b->Set(i - 1, d - i, 128); + b->Set(i, d - i + 1, 128); } - b->Set (0, d, 64); - b->Set (d, 0, 64); - b->Set (d, 1, 128); - b->Set (d - 1, 0, 128); - } - else // backward slash + b->Set(0, d, 64); + b->Set(d, 0, 64); + b->Set(d, 1, 128); + b->Set(d - 1, 0, 128); + } else // backward slash { - for (int i = 1; i < d; i++) - { - b->Set (i, i, 255); - b->Set (i, i - 1, 128); - b->Set (i - 1, i, 128); + for (int i = 1; i < d; i++) { + b->Set(i, i, 255); + b->Set(i, i - 1, 128); + b->Set(i - 1, i, 128); } - b->Set (0, 0, 64); - b->Set (d, d, 64); - b->Set (d, d - 1, 128); - b->Set (d - 1, d, 128); + b->Set(0, 0, 64); + b->Set(d, d, 64); + b->Set(d, d - 1, 128); + b->Set(d - 1, d, 128); } } -status_t AttribClone::GetSupportedSuites (BMessage *message) +status_t +AttribClone::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso-Clone"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso-Clone"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -BHandler *AttribClone::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribClone::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { -// printf ("\nmessage:\n"); -// message->PrintToStream(); -// printf ("specifier:\n"); -// specifier->PrintToStream(); -// printf ("Property: %s\n", property); - - if (!strcasecmp (property, "Spacing")) - { + // printf ("\nmessage:\n"); + // message->PrintToStream(); + // printf ("specifier:\n"); + // specifier->PrintToStream(); + // printf ("Property: %s\n", property); + + if (!strcasecmp(property, "Spacing")) { fCurrentProperty = PROP_SPACING; return this; } - if (!strcasecmp (property, "Strength")) - { + if (!strcasecmp(property, "Strength")) { fCurrentProperty = PROP_STRENGTH; return this; } - if (!strcasecmp (property, "Angle")) - { + if (!strcasecmp(property, "Angle")) { fCurrentProperty = PROP_ANGLE; return this; } - if (!strcasecmp (property, "Width") || !strcasecmp (property, "XSize")) - { + if (!strcasecmp(property, "Width") || !strcasecmp(property, "XSize")) { fCurrentProperty = PROP_X; return this; } - if (!strcasecmp (property, "Height") || !strcasecmp (property, "YSize")) - { + if (!strcasecmp(property, "Height") || !strcasecmp(property, "YSize")) { fCurrentProperty = PROP_Y; return this; } - if (!strcasecmp (property, "Hardness")) - { + if (!strcasecmp(property, "Hardness")) { fCurrentProperty = PROP_HARDNESS; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } - -void AttribClone::MessageReceived (BMessage *msg) +void +AttribClone::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_SPACING: // float, 1 .. 64 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_SPACING: // float, 1 .. 64 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 1 && value <= 40) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 1 && value <= 40) { fSpacing = value; - pSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + pSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } ConstructBrush(); } } break; } - case PROP_STRENGTH: // int, 0 .. 255 + case PROP_STRENGTH: // int, 0 .. 255 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) - { - if (value >= 0 && value <= 255) - { + if (msg->FindInt32("data", &value) == B_OK) { + if (value >= 0 && value <= 255) { fStrength = value; - sSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + sSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } ConstructBrush(); } } break; } - case PROP_HARDNESS: // int, 0 .. 100 + case PROP_HARDNESS: // int, 0 .. 100 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) - { - if (value >= 1 && value <= 100) - { + if (msg->FindInt32("data", &value) == B_OK) { + if (value >= 1 && value <= 100) { fHardness = value; - hSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + hSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } ConstructBrush(); } } break; } - case PROP_ANGLE: // float, 0 .. 45 + case PROP_ANGLE: // float, 0 .. 45 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 45) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 45) { fAngle = value; - aSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + aSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } ConstructBrush(); } } break; } - case PROP_X: // int, 1 .. 40 + case PROP_X: // int, 1 .. 40 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) - { - if (value >= 1 && value <= 40) - { + if (msg->FindInt32("data", &value) == B_OK) { + if (value >= 1 && value <= 40) { fX = value; - xSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + xSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } ConstructBrush(); } } break; } - case PROP_Y: // int, 1 .. 40 + case PROP_Y: // int, 1 .. 40 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) - { - if (value >= 1 && value <= 40) - { + if (msg->FindInt32("data", &value) == B_OK) { + if (value >= 1 && value <= 40) { fY = value; - ySlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + ySlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } ConstructBrush(); } @@ -334,40 +332,40 @@ void AttribClone::MessageReceived (BMessage *msg) } } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'ABxc': - fX = int (msg->FindFloat ("value")); + fX = int(msg->FindFloat("value")); ConstructBrush(); - fSpacing = sqrt (fX + fY); - pSlid->SetValue (fSpacing); + fSpacing = sqrt(fX + fY); + pSlid->SetValue(fSpacing); break; case 'AByc': - fY = int (msg->FindFloat ("value")); - fSpacing = sqrt (fX + fY); - pSlid->SetValue (fSpacing); + fY = int(msg->FindFloat("value")); + fSpacing = sqrt(fX + fY); + pSlid->SetValue(fSpacing); ConstructBrush(); break; case 'ABsc': - fStrength = int (msg->FindFloat ("value")); + fStrength = int(msg->FindFloat("value")); ConstructBrush(); break; case 'ABac': - fAngle = msg->FindFloat ("value"); + fAngle = msg->FindFloat("value"); ConstructBrush(); break; case 'ABph': - fHardness = msg->FindFloat ("value"); + fHardness = msg->FindFloat("value"); ConstructBrush(); break; case 'ABpc': - fSpacing = msg->FindFloat ("value"); + fSpacing = msg->FindFloat("value"); ConstructBrush(); break; default: - //msg->PrintToStream(); - inherited::MessageReceived (msg); + // msg->PrintToStream(); + inherited::MessageReceived(msg); } bv->Invalidate(); } diff --git a/source/AttribClone.h b/source/AttribClone.h index 7c3c40a..2717a73 100644 --- a/source/AttribClone.h +++ b/source/AttribClone.h @@ -7,42 +7,49 @@ #include "Brush.h" #include "Slider.h" -#define PROP_SPACING 1 -#define PROP_STRENGTH 2 -#define PROP_ANGLE 3 -#define PROP_X 4 -#define PROP_Y 5 -#define PROP_HARDNESS 6 +#define PROP_SPACING 1 +#define PROP_STRENGTH 2 +#define PROP_ANGLE 3 +#define PROP_X 4 +#define PROP_Y 5 +#define PROP_HARDNESS 6 class AttribClone : public AttribView { -public: - AttribClone (); -virtual ~AttribClone (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -float getSpacing () { return fSpacing; }; -int getStrength () { return fStrength; }; -Brush *getBrush () { return fBrush; }; - -private: -typedef AttribView inherited; -void ConstructBrush (); -void mkGaussianBrush (Brush *b, float sigmaxsq, float sigmaysq, float angle, int cval, float hardness); -void mkDiagonalBrush (Brush *b, int dir); - -float fSpacing; -int fStrength; -float fAngle; -int fX; -int fY; -float fHardness; -Brush *fBrush; -BitmapView *bv; -int fCurrentProperty; - -Slider *pSlid, *xSlid, *ySlid, *aSlid, *sSlid, *hSlid; + public: + AttribClone(); + virtual ~AttribClone(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + + float getSpacing() { return fSpacing; }; + + int getStrength() { return fStrength; }; + + Brush* getBrush() { return fBrush; }; + + private: + typedef AttribView inherited; + void ConstructBrush(); + void mkGaussianBrush( + Brush* b, float sigmaxsq, float sigmaysq, float angle, int cval, float hardness + ); + void mkDiagonalBrush(Brush* b, int dir); + + float fSpacing; + int fStrength; + float fAngle; + int fX; + int fY; + float fHardness; + Brush* fBrush; + BitmapView* bv; + int fCurrentProperty; + + Slider *pSlid, *xSlid, *ySlid, *aSlid, *sSlid, *hSlid; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribDraw.cpp b/source/AttribDraw.cpp index ef10617..0ea33e8 100644 --- a/source/AttribDraw.cpp +++ b/source/AttribDraw.cpp @@ -9,29 +9,27 @@ #include #include "Settings.h" -static property_info prop_list[] = { - 0 -}; +static property_info prop_list[] = {0}; -AttribDraw::AttribDraw () -: AttribView (BRect (0, 0, 164, 58), lstring (20, "Draw")) +AttribDraw::AttribDraw() : AttribView(BRect(0, 0, 164, 58), lstring(20, "Draw")) { extern bool BuiltInTablet; - SetViewColor (LightGrey); - fModePU = new BPopUpMenu (""); - BMenuItem *item = new BMenuItem (lstring (320, "Copy"), NULL); - item->SetMarked (true); - fModePU->AddItem (item); - fModePU->AddItem (new BMenuItem (lstring (321, "Over"), NULL)); - fModePU->AddItem (new BMenuItem (lstring (322, "Erase"), NULL)); - fModePU->AddItem (new BMenuItem (lstring (323, "Min"), NULL)); - fModePU->AddItem (new BMenuItem (lstring (324, "Max"), NULL)); - fModePU->AddItem (new BMenuItem (lstring (325, "Invert"), NULL)); - fModePU->AddItem (new BMenuItem (lstring (326, "Add"), NULL)); - fModePU->AddItem (new BMenuItem (lstring (327, "Subtract"), NULL)); - fModePU->AddItem (new BMenuItem (lstring (328, "Blend"), NULL)); - BMenuField *dMode = new BMenuField (BRect (8, 6, 156, 24), "dMode", lstring (329, "Drawing Mode:"), fModePU); - dMode->SetDivider (82); + SetViewColor(LightGrey); + fModePU = new BPopUpMenu(""); + BMenuItem* item = new BMenuItem(lstring(320, "Copy"), NULL); + item->SetMarked(true); + fModePU->AddItem(item); + fModePU->AddItem(new BMenuItem(lstring(321, "Over"), NULL)); + fModePU->AddItem(new BMenuItem(lstring(322, "Erase"), NULL)); + fModePU->AddItem(new BMenuItem(lstring(323, "Min"), NULL)); + fModePU->AddItem(new BMenuItem(lstring(324, "Max"), NULL)); + fModePU->AddItem(new BMenuItem(lstring(325, "Invert"), NULL)); + fModePU->AddItem(new BMenuItem(lstring(326, "Add"), NULL)); + fModePU->AddItem(new BMenuItem(lstring(327, "Subtract"), NULL)); + fModePU->AddItem(new BMenuItem(lstring(328, "Blend"), NULL)); + BMenuField* dMode = + new BMenuField(BRect(8, 6, 156, 24), "dMode", lstring(329, "Drawing Mode:"), fModePU); + dMode->SetDivider(82); drawmode[0] = B_OP_COPY; drawmode[1] = B_OP_OVER; drawmode[2] = B_OP_ERASE; @@ -41,78 +39,78 @@ AttribDraw::AttribDraw () drawmode[6] = B_OP_ADD; drawmode[7] = B_OP_SUBTRACT; drawmode[8] = B_OP_BLEND; - AddChild (dMode); - if (BuiltInTablet) - { - fTabletPU = new BPopUpMenu (""); - fTabletPU->AddItem (new BMenuItem ("Serial 1", new BMessage ('TBL1'))); - fTabletPU->AddItem (new BMenuItem ("Serial 2", new BMessage ('TBL2'))); - item = new BMenuItem ("Serial 3", new BMessage ('TBL3')); - item->SetMarked (true); - fTabletPU->AddItem (item); - fTabletPU->AddItem (new BMenuItem ("Serial 4", new BMessage ('TBL4'))); - BMenuField *dTablet = new BMenuField (BRect (8, 30, 156, 48), "dTablet", lstring (330, "Tablet: "), fTabletPU); - dTablet->SetDivider (82); - AddChild (dTablet); + AddChild(dMode); + if (BuiltInTablet) { + fTabletPU = new BPopUpMenu(""); + fTabletPU->AddItem(new BMenuItem("Serial 1", new BMessage('TBL1'))); + fTabletPU->AddItem(new BMenuItem("Serial 2", new BMessage('TBL2'))); + item = new BMenuItem("Serial 3", new BMessage('TBL3')); + item->SetMarked(true); + fTabletPU->AddItem(item); + fTabletPU->AddItem(new BMenuItem("Serial 4", new BMessage('TBL4'))); + BMenuField* dTablet = + new BMenuField(BRect(8, 30, 156, 48), "dTablet", lstring(330, "Tablet: "), fTabletPU); + dTablet->SetDivider(82); + AddChild(dTablet); } } -AttribDraw::~AttribDraw () +AttribDraw::~AttribDraw() { // printf ("Deleting Draw Window\n"); } -status_t AttribDraw::GetSupportedSuites (BMessage *message) +status_t +AttribDraw::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso-Draw"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso-Draw"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -BHandler *AttribDraw::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribDraw::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribDraw::MessageReceived (BMessage *msg) +void +AttribDraw::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case 'TBL1': - { - extern Tablet *wacom; + switch (msg->what) { + case 'TBL1': { + extern Tablet* wacom; delete wacom; - wacom = new Tablet ("serial1"); + wacom = new Tablet("serial1"); wacom->Init(); break; } - case 'TBL2': - { - extern Tablet *wacom; + case 'TBL2': { + extern Tablet* wacom; delete wacom; - wacom = new Tablet ("serial2"); + wacom = new Tablet("serial2"); wacom->Init(); break; } - case 'TBL3': - { - extern Tablet *wacom; + case 'TBL3': { + extern Tablet* wacom; delete wacom; - wacom = new Tablet ("serial3"); + wacom = new Tablet("serial3"); wacom->Init(); break; } - case 'TBL4': - { - extern Tablet *wacom; + case 'TBL4': { + extern Tablet* wacom; delete wacom; - wacom = new Tablet ("serial4"); + wacom = new Tablet("serial4"); wacom->Init(); break; } default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AttribDraw.h b/source/AttribDraw.h index 3d03b5c..b2d1132 100644 --- a/source/AttribDraw.h +++ b/source/AttribDraw.h @@ -9,19 +9,22 @@ class AttribDraw : public AttribView { -public: - AttribDraw (); -virtual ~AttribDraw (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -drawing_mode getDrawingMode () { return drawmode [fModePU->IndexOf (fModePU->FindMarked())]; }; + public: + AttribDraw(); + virtual ~AttribDraw(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); -private: -typedef AttribView inherited; -BPopUpMenu *fModePU; -BPopUpMenu *fTabletPU; -drawing_mode drawmode[9]; + drawing_mode getDrawingMode() { return drawmode[fModePU->IndexOf(fModePU->FindMarked())]; }; + + private: + typedef AttribView inherited; + BPopUpMenu* fModePU; + BPopUpMenu* fTabletPU; + drawing_mode drawmode[9]; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribEllipse.cpp b/source/AttribEllipse.cpp index e8009bc..312d951 100644 --- a/source/AttribEllipse.cpp +++ b/source/AttribEllipse.cpp @@ -12,234 +12,225 @@ static property_info prop_list[] = { 0 }; -AttribEllipse::AttribEllipse () -: AttribView (BRect (0, 0, 148, 90), lstring (34, "Ellipses")) +AttribEllipse::AttribEllipse() : AttribView(BRect(0, 0, 148, 90), lstring(34, "Ellipses")) { - SetViewColor (LightGrey); - lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc')); - AddChild (lSlid); + SetViewColor(LightGrey); + lSlid = new Slider( + BRect(8, 8, 140, 26), 60, lstring(310, "Pen Size"), 1, 50, 1, new BMessage('ALpc') + ); + AddChild(lSlid); fType = ELLIPSE_OUTFILL; fPenSize = 1; - BBox *type = new BBox (BRect (18, 32, 130, 82), "type"); - type->SetLabel (lstring (311, "Type")); - AddChild (type); - - BRect shape = BRect (3, 7, 27, 23); - BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL)); - BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL)); - picWindow->AddChild (bg); - - BPicture *p10; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetLowColor (White); - bg->FillEllipse (shape, B_SOLID_LOW); - bg->StrokeEllipse (shape); + BBox* type = new BBox(BRect(18, 32, 130, 82), "type"); + type->SetLabel(lstring(311, "Type")); + AddChild(type); + + BRect shape = BRect(3, 7, 27, 23); + BWindow* picWindow = new BWindow( + BRect(0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32(NULL), uint32(NULL) + ); + BView* bg = new BView(BRect(0, 0, 100, 100), "Temp Pic View", uint32(NULL), uint32(NULL)); + picWindow->AddChild(bg); + + BPicture* p10; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetLowColor(White); + bg->FillEllipse(shape, B_SOLID_LOW); + bg->StrokeEllipse(shape); p10 = bg->EndPicture(); - - BPicture *p20; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillEllipse (shape, B_SOLID_LOW); + + BPicture* p20; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillEllipse(shape, B_SOLID_LOW); p20 = bg->EndPicture(); - - BPicture *p30; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->StrokeEllipse (shape); + + BPicture* p30; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->StrokeEllipse(shape); p30 = bg->EndPicture(); - BPicture *p11; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillEllipse (shape, B_SOLID_LOW); - bg->StrokeEllipse (shape); + BPicture* p11; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillEllipse(shape, B_SOLID_LOW); + bg->StrokeEllipse(shape); p11 = bg->EndPicture(); - - BPicture *p21; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillEllipse (shape, B_SOLID_LOW); + + BPicture* p21; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillEllipse(shape, B_SOLID_LOW); p21 = bg->EndPicture(); - - BPicture *p31; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->StrokeEllipse (shape); + + BPicture* p31; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->StrokeEllipse(shape); p31 = bg->EndPicture(); - - SetViewColor (LightGrey); + + SetViewColor(LightGrey); delete picWindow; - - pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON); - pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON); - pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON); - type->AddChild (pT1); - type->AddChild (pT2); - type->AddChild (pT3); - pT1->SetValue (B_CONTROL_ON); + + pT1 = new BPictureButton( + BRect(4, 15, 34, 45), "APVt1", p10, p11, new BMessage('pvT1'), B_TWO_STATE_BUTTON + ); + pT2 = new BPictureButton( + BRect(40, 15, 70, 45), "APVt2", p20, p21, new BMessage('pvT2'), B_TWO_STATE_BUTTON + ); + pT3 = new BPictureButton( + BRect(76, 15, 106, 45), "APVt3", p30, p31, new BMessage('pvT3'), B_TWO_STATE_BUTTON + ); + type->AddChild(pT1); + type->AddChild(pT2); + type->AddChild(pT3); + pT1->SetValue(B_CONTROL_ON); fCurrentProperty = 0; } +AttribEllipse::~AttribEllipse() {} -AttribEllipse::~AttribEllipse () -{ -} - -status_t AttribEllipse::GetSupportedSuites (BMessage *message) +status_t +AttribEllipse::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso-Ellipses"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso-Ellipses"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -BHandler *AttribEllipse::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribEllipse::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - if (!strcasecmp (property, "PenSize")) - { + if (!strcasecmp(property, "PenSize")) { fCurrentProperty = PROP_PENSIZE; return this; } - if (!strcasecmp (property, "ShapeType") || !strcasecmp (property, "Type")) - { + if (!strcasecmp(property, "ShapeType") || !strcasecmp(property, "Type")) { fCurrentProperty = PROP_TYPE; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribEllipse::MessageReceived (BMessage *msg) +void +AttribEllipse::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_PENSIZE: // float, 1 .. 50 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_PENSIZE: // float, 1 .. 50 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 1 && value <= 50) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 1 && value <= 50) { fPenSize = value; - lSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + lSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_TYPE: // FilledOutline, Filled, Outline + case PROP_TYPE: // FilledOutline, Filled, Outline { - const char *name; + const char* name; int value = 0; - if (msg->FindString ("data", &name) == B_OK) - { - if (!strcasecmp (name, "FilledOutline")) - { - pT1->SetValue (B_CONTROL_ON); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_OFF); + if (msg->FindString("data", &name) == B_OK) { + if (!strcasecmp(name, "FilledOutline")) { + pT1->SetValue(B_CONTROL_ON); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_OFF); value = ELLIPSE_OUTFILL; - } - else if (!strcasecmp (name, "Filled")) - { - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_ON); - pT3->SetValue (B_CONTROL_OFF); + } else if (!strcasecmp(name, "Filled")) { + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_ON); + pT3->SetValue(B_CONTROL_OFF); value = ELLIPSE_FILL; - } - else if (!strcasecmp (name, "Outline")) - { - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_ON); + } else if (!strcasecmp(name, "Outline")) { + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_ON); value = ELLIPSE_OUTLINE; } - if (value) - { + if (value) { fType = value; - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } - } - else - { + } else { // Error report... } } } - fCurrentProperty = 0; - break; + fCurrentProperty = 0; + break; } - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'ALpc': - fPenSize = msg->FindFloat ("value"); + fPenSize = msg->FindFloat("value"); break; case 'pvT1': fType = ELLIPSE_OUTFILL; - pT1->SetValue (B_CONTROL_ON); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_OFF); + pT1->SetValue(B_CONTROL_ON); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_OFF); break; case 'pvT2': fType = ELLIPSE_FILL; - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_ON); - pT3->SetValue (B_CONTROL_OFF); + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_ON); + pT3->SetValue(B_CONTROL_OFF); break; case 'pvT3': fType = ELLIPSE_OUTLINE; - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_ON); + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_ON); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AttribEllipse.h b/source/AttribEllipse.h index f7b08f0..c8b8c11 100644 --- a/source/AttribEllipse.h +++ b/source/AttribEllipse.h @@ -7,30 +7,34 @@ #include "Slider.h" #define ELLIPSE_OUTLINE 1 -#define ELLIPSE_FILL 2 +#define ELLIPSE_FILL 2 #define ELLIPSE_OUTFILL 3 -#define PROP_PENSIZE 1 -#define PROP_TYPE 2 +#define PROP_PENSIZE 1 +#define PROP_TYPE 2 class AttribEllipse : public AttribView { -public: - AttribEllipse (); -virtual ~AttribEllipse (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -float getPenSize () { return fPenSize; }; -int getType () { return fType; }; - -private: -typedef AttribView inherited; -float fPenSize; -int fType; -BPictureButton *pT1, *pT2, *pT3; -Slider *lSlid; -int fCurrentProperty; + public: + AttribEllipse(); + virtual ~AttribEllipse(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + + float getPenSize() { return fPenSize; }; + + int getType() { return fType; }; + + private: + typedef AttribView inherited; + float fPenSize; + int fType; + BPictureButton *pT1, *pT2, *pT3; + Slider* lSlid; + int fCurrentProperty; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribEraser.cpp b/source/AttribEraser.cpp index 85d367c..32a1eb7 100644 --- a/source/AttribEraser.cpp +++ b/source/AttribEraser.cpp @@ -14,240 +14,229 @@ static property_info prop_list[] = { 0 }; -AttribEraser::AttribEraser () -: AttribView (BRect (0, 0, 126, 102), lstring (23, "Eraser")) +AttribEraser::AttribEraser() : AttribView(BRect(0, 0, 126, 102), lstring(23, "Eraser")) { - SetViewColor (LightGrey); - BBox *type = new BBox (BRect (8, 8, 119, 58), "type"); - type->SetLabel (lstring (333, "Shape")); - AddChild (type); - xSlid = new Slider (BRect (8, 62, 119, 78), 45, lstring (334, "H Size"), 1, 50, 1, new BMessage ('AEhs')); - ySlid = new Slider (BRect (8, 82, 119, 98), 45, lstring (335, "V Size"), 1, 50, 1, new BMessage ('AEvs')); - xSlid->SetValue (16); - ySlid->SetValue (16); + SetViewColor(LightGrey); + BBox* type = new BBox(BRect(8, 8, 119, 58), "type"); + type->SetLabel(lstring(333, "Shape")); + AddChild(type); + xSlid = new Slider( + BRect(8, 62, 119, 78), 45, lstring(334, "H Size"), 1, 50, 1, new BMessage('AEhs') + ); + ySlid = new Slider( + BRect(8, 82, 119, 98), 45, lstring(335, "V Size"), 1, 50, 1, new BMessage('AEvs') + ); + xSlid->SetValue(16); + ySlid->SetValue(16); fXSize = 16; fYSize = 16; - AddChild (xSlid); - AddChild (ySlid); + AddChild(xSlid); + AddChild(ySlid); - BRect shape = BRect (3, 7, 27, 23); + BRect shape = BRect(3, 7, 27, 23); - BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL)); - BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL)); - picWindow->AddChild (bg); - - BPicture *p10; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillRect (shape, B_SOLID_LOW); - bg->StrokeRect (shape); + BWindow* picWindow = new BWindow( + BRect(0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32(NULL), uint32(NULL) + ); + BView* bg = new BView(BRect(0, 0, 100, 100), "Temp Pic View", uint32(NULL), uint32(NULL)); + picWindow->AddChild(bg); + + BPicture* p10; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillRect(shape, B_SOLID_LOW); + bg->StrokeRect(shape); p10 = bg->EndPicture(); - - BPicture *p20; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillEllipse (shape, B_SOLID_LOW); - bg->StrokeEllipse (shape); + + BPicture* p20; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillEllipse(shape, B_SOLID_LOW); + bg->StrokeEllipse(shape); p20 = bg->EndPicture(); - BPicture *p11; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillRect (shape, B_SOLID_LOW); - bg->StrokeRect (shape); + BPicture* p11; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillRect(shape, B_SOLID_LOW); + bg->StrokeRect(shape); p11 = bg->EndPicture(); - - BPicture *p21; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillEllipse (shape, B_SOLID_LOW); - bg->StrokeEllipse (shape); + + BPicture* p21; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillEllipse(shape, B_SOLID_LOW); + bg->StrokeEllipse(shape); p21 = bg->EndPicture(); - + delete picWindow; - - eT1 = new BPictureButton (BRect (22, 15, 52, 45), "eT1", p10, p11, new BMessage ('peT1')); - eT2 = new BPictureButton (BRect (58, 15, 88, 45), "eT2", p20, p21, new BMessage ('peT2')); - type->AddChild (eT1); - type->AddChild (eT2); - eT1->SetValue (B_CONTROL_ON); + + eT1 = new BPictureButton(BRect(22, 15, 52, 45), "eT1", p10, p11, new BMessage('peT1')); + eT2 = new BPictureButton(BRect(58, 15, 88, 45), "eT2", p20, p21, new BMessage('peT2')); + type->AddChild(eT1); + type->AddChild(eT2); + eT1->SetValue(B_CONTROL_ON); fType = ERASER_RECT; fCurrentProperty = 0; } - -AttribEraser::~AttribEraser () +AttribEraser::~AttribEraser() { -// printf ("~AttribEraser\n"); + // printf ("~AttribEraser\n"); } -status_t AttribEraser::GetSupportedSuites (BMessage *message) +status_t +AttribEraser::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso-Eraser"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso-Eraser"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -BHandler *AttribEraser::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribEraser::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - if (!strcasecmp (property, "XSize") || !strcasecmp (property, "Width") || !strcasecmp (property, "HSize")) - { + if (!strcasecmp(property, "XSize") || !strcasecmp(property, "Width") || + !strcasecmp(property, "HSize")) { fCurrentProperty = PROP_XSIZE; return this; } - if (!strcasecmp (property, "YSize") || !strcasecmp (property, "Height") || !strcasecmp (property, "VSize")) - { + if (!strcasecmp(property, "YSize") || !strcasecmp(property, "Height") || + !strcasecmp(property, "VSize")) { fCurrentProperty = PROP_YSIZE; return this; } - if (!strcasecmp (property, "Shape") || !strcasecmp (property, "Type")) - { + if (!strcasecmp(property, "Shape") || !strcasecmp(property, "Type")) { fCurrentProperty = PROP_TYPE; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribEraser::MessageReceived (BMessage *msg) +void +AttribEraser::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_XSIZE: // float, 1 .. 50 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_XSIZE: // float, 1 .. 50 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 1 && value <= 50) - { - xSlid->SetValue (value); + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 1 && value <= 50) { + xSlid->SetValue(value); fXSize = value; - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_YSIZE: // float, 1 .. 50 + case PROP_YSIZE: // float, 1 .. 50 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 1 && value <= 50) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 1 && value <= 50) { fYSize = value; - ySlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + ySlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_TYPE: // Ellipse, Rectangle + case PROP_TYPE: // Ellipse, Rectangle { - const char *name; + const char* name; int value = 0; - if (msg->FindString ("data", &name) == B_OK) - { - if (!strcasecmp (name, "Ellipse")) - { - eT1->SetValue (B_CONTROL_OFF); - eT2->SetValue (B_CONTROL_ON); + if (msg->FindString("data", &name) == B_OK) { + if (!strcasecmp(name, "Ellipse")) { + eT1->SetValue(B_CONTROL_OFF); + eT2->SetValue(B_CONTROL_ON); value = ERASER_ELLIPSE; - } - else if (!strcasecmp (name, "Rectangle")) - { - eT1->SetValue (B_CONTROL_ON); - eT2->SetValue (B_CONTROL_OFF); + } else if (!strcasecmp(name, "Rectangle")) { + eT1->SetValue(B_CONTROL_ON); + eT2->SetValue(B_CONTROL_OFF); value = ERASER_RECT; } - if (value) - { + if (value) { fType = value; - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } - } - else - { + } else { // Error report... } } } - fCurrentProperty = 0; - break; + fCurrentProperty = 0; + break; } - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'AEhs': - fXSize = msg->FindFloat ("value"); + fXSize = msg->FindFloat("value"); break; case 'AEvs': - fYSize = msg->FindFloat ("value"); + fYSize = msg->FindFloat("value"); break; case 'peT1': - eT1->SetValue (B_CONTROL_ON); - eT2->SetValue (B_CONTROL_OFF); + eT1->SetValue(B_CONTROL_ON); + eT2->SetValue(B_CONTROL_OFF); fType = ERASER_RECT; break; case 'peT2': - eT1->SetValue (B_CONTROL_OFF); - eT2->SetValue (B_CONTROL_ON); + eT1->SetValue(B_CONTROL_OFF); + eT2->SetValue(B_CONTROL_ON); fType = ERASER_ELLIPSE; break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AttribEraser.h b/source/AttribEraser.h index af47194..7bbb3f3 100644 --- a/source/AttribEraser.h +++ b/source/AttribEraser.h @@ -6,33 +6,38 @@ #include #include "Slider.h" -#define ERASER_RECT 1 -#define ERASER_ELLIPSE 2 +#define ERASER_RECT 1 +#define ERASER_ELLIPSE 2 -#define PROP_TYPE 2 -#define PROP_XSIZE 1 -#define PROP_YSIZE 3 +#define PROP_TYPE 2 +#define PROP_XSIZE 1 +#define PROP_YSIZE 3 class AttribEraser : public AttribView { -public: - AttribEraser (); -virtual ~AttribEraser (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -float getXSize () { return fXSize; }; -float getYSize () { return fYSize; }; -int getType () { return fType; }; - -private: -typedef AttribView inherited; -float fXSize; -float fYSize; -int fType; -BPictureButton *eT1, *eT2; -Slider *xSlid, *ySlid; -int fCurrentProperty; + public: + AttribEraser(); + virtual ~AttribEraser(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + + float getXSize() { return fXSize; }; + + float getYSize() { return fYSize; }; + + int getType() { return fType; }; + + private: + typedef AttribView inherited; + float fXSize; + float fYSize; + int fType; + BPictureButton *eT1, *eT2; + Slider *xSlid, *ySlid; + int fCurrentProperty; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribFill.cpp b/source/AttribFill.cpp index baa85ea..7aedc4b 100644 --- a/source/AttribFill.cpp +++ b/source/AttribFill.cpp @@ -17,40 +17,51 @@ static property_info prop_list[] = { 0 }; -AttribFill::AttribFill () -: AttribView (BRect (0, 0, 146, 146), lstring (24, "Fill")) +AttribFill::AttribFill() : AttribView(BRect(0, 0, 146, 146), lstring(24, "Fill")) { - SetViewColor (LightGrey); - BBox *tolSets = new BBox (BRect (4, 4, 142, 142), "tol"); - tolSets->SetLabel (lstring (338, "Tolerance")); - AddChild (tolSets); - tol = new BRadioButton (BRect (8, 13, 124, 30), "tol", lstring (339, "Visual Distance"), new BMessage ('AFtV')); - rgb = new BRadioButton (BRect (8, 30, 124, 46), "rgb", lstring (340, "Absolute RGB"), new BMessage ('AFtS')); - tol->SetValue (B_CONTROL_ON); - tolSets->AddChild (tol); - tolSets->AddChild (rgb); - TabView *bgTab = new TabView (BRect (4, 50, 132, 134), "AttribFill Tab"); - tolSets->AddChild (bgTab); - BView *tolTab = new BView (BRect (2, TAB_HEIGHT + 4, 126, TAB_HEIGHT + 63), "tol View", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); - BView *rgbTab = new BView (BRect (2, TAB_HEIGHT + 4, 126, TAB_HEIGHT + 63), "rgb View", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); - tolTab->SetViewColor (LightGrey); - rgbTab->SetViewColor (LightGrey); - bgTab->AddView (tolTab, lstring (341, "Visual")); - bgTab->AddView (rgbTab, lstring (342, "RGB")); - BStringView *explD = new BStringView (BRect (2, 8, 122, 20), "explD", lstring (343, "Visual Factors:")); - BStringView *facD = new BStringView (BRect (2, 20, 122, 32), "facD", lstring (344, "R: 0.213 G: 0.715 B: 0.072")); - explD->SetFontSize (10); - facD->SetFontSize (10); - sT = new Slider (BRect (4, 42, 122, 58), 10, "D", 0, 255, 1, new BMessage ('AFcT')); - sR = new Slider (BRect (4, 2, 122, 18), 10, "R", 0, 255, 1, new BMessage ('AFcR')); - sG = new Slider (BRect (4, 22, 122, 38), 10, "G", 0, 255, 1, new BMessage ('AFcG')); - sB = new Slider (BRect (4, 42, 122, 58), 10, "B", 0, 255, 1, new BMessage ('AFcB')); - tolTab->AddChild (sT); - tolTab->AddChild (explD); - tolTab->AddChild (facD); - rgbTab->AddChild (sR); - rgbTab->AddChild (sG); - rgbTab->AddChild (sB); + SetViewColor(LightGrey); + BBox* tolSets = new BBox(BRect(4, 4, 142, 142), "tol"); + tolSets->SetLabel(lstring(338, "Tolerance")); + AddChild(tolSets); + tol = new BRadioButton( + BRect(8, 13, 124, 30), "tol", lstring(339, "Visual Distance"), new BMessage('AFtV') + ); + rgb = new BRadioButton( + BRect(8, 30, 124, 46), "rgb", lstring(340, "Absolute RGB"), new BMessage('AFtS') + ); + tol->SetValue(B_CONTROL_ON); + tolSets->AddChild(tol); + tolSets->AddChild(rgb); + TabView* bgTab = new TabView(BRect(4, 50, 132, 134), "AttribFill Tab"); + tolSets->AddChild(bgTab); + BView* tolTab = new BView( + BRect(2, TAB_HEIGHT + 4, 126, TAB_HEIGHT + 63), "tol View", B_FOLLOW_LEFT | B_FOLLOW_TOP, + B_WILL_DRAW + ); + BView* rgbTab = new BView( + BRect(2, TAB_HEIGHT + 4, 126, TAB_HEIGHT + 63), "rgb View", B_FOLLOW_LEFT | B_FOLLOW_TOP, + B_WILL_DRAW + ); + tolTab->SetViewColor(LightGrey); + rgbTab->SetViewColor(LightGrey); + bgTab->AddView(tolTab, lstring(341, "Visual")); + bgTab->AddView(rgbTab, lstring(342, "RGB")); + BStringView* explD = + new BStringView(BRect(2, 8, 122, 20), "explD", lstring(343, "Visual Factors:")); + BStringView* facD = + new BStringView(BRect(2, 20, 122, 32), "facD", lstring(344, "R: 0.213 G: 0.715 B: 0.072")); + explD->SetFontSize(10); + facD->SetFontSize(10); + sT = new Slider(BRect(4, 42, 122, 58), 10, "D", 0, 255, 1, new BMessage('AFcT')); + sR = new Slider(BRect(4, 2, 122, 18), 10, "R", 0, 255, 1, new BMessage('AFcR')); + sG = new Slider(BRect(4, 22, 122, 38), 10, "G", 0, 255, 1, new BMessage('AFcG')); + sB = new Slider(BRect(4, 42, 122, 58), 10, "B", 0, 255, 1, new BMessage('AFcB')); + tolTab->AddChild(sT); + tolTab->AddChild(explD); + tolTab->AddChild(facD); + rgbTab->AddChild(sR); + rgbTab->AddChild(sG); + rgbTab->AddChild(sB); fTolMode = FILLTOL_TOL; fTolerance = 0; fToleranceRGB.red = 0; @@ -59,185 +70,157 @@ AttribFill::AttribFill () fCurrentProperty = 0; } +AttribFill::~AttribFill() {} -AttribFill::~AttribFill () +status_t +AttribFill::GetSupportedSuites(BMessage* message) { + message->AddString("suites", "suite/x-sum-becasso-Fill"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -status_t AttribFill::GetSupportedSuites (BMessage *message) +BHandler* +AttribFill::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - message->AddString ("suites", "suite/x-sum-becasso-Fill"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); -} - -BHandler *AttribFill::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) -{ - if (!strcasecmp (property, "ToleranceType") || !strcasecmp (property, "Type")) - { + if (!strcasecmp(property, "ToleranceType") || !strcasecmp(property, "Type")) { fCurrentProperty = PROP_TOLTYPE; return this; } - if (!strcasecmp (property, "Tolerance") || !strcasecmp (property, "Visual")) - { + if (!strcasecmp(property, "Tolerance") || !strcasecmp(property, "Visual")) { fCurrentProperty = PROP_VISUAL; return this; } - if (!strcasecmp (property, "Red")) - { + if (!strcasecmp(property, "Red")) { fCurrentProperty = PROP_DRED; return this; } - if (!strcasecmp (property, "Green")) - { + if (!strcasecmp(property, "Green")) { fCurrentProperty = PROP_DGREEN; return this; } - if (!strcasecmp (property, "Blue")) - { + if (!strcasecmp(property, "Blue")) { fCurrentProperty = PROP_DBLUE; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribFill::MessageReceived (BMessage *msg) +void +AttribFill::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_VISUAL: // float, 0 .. 255 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_VISUAL: // float, 0 .. 255 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 255) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 255) { fTolerance = value; - sT->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + sT->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_DRED: // int, 0 .. 255 + case PROP_DRED: // int, 0 .. 255 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) - { - if (value >= 0 && value <= 255) - { + if (msg->FindInt32("data", &value) == B_OK) { + if (value >= 0 && value <= 255) { fToleranceRGB.red = value; - sR->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + sR->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_DGREEN: // int, 0 .. 255 + case PROP_DGREEN: // int, 0 .. 255 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) - { - if (value >= 0 && value <= 255) - { + if (msg->FindInt32("data", &value) == B_OK) { + if (value >= 0 && value <= 255) { fToleranceRGB.green = value; - sG->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + sG->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_DBLUE: // int, 0 .. 255 + case PROP_DBLUE: // int, 0 .. 255 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) - { - if (value >= 0 && value <= 255) - { + if (msg->FindInt32("data", &value) == B_OK) { + if (value >= 0 && value <= 255) { fToleranceRGB.blue = value; - sB->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + sB->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_TOLTYPE: // Visual, RGB|Absolute + case PROP_TOLTYPE: // Visual, RGB|Absolute { - const char *name; + const char* name; int value = 0; - if (msg->FindString ("data", &name) == B_OK) - { - if (!strcasecmp (name, "Visual")) - { - tol->SetValue (B_CONTROL_ON); + if (msg->FindString("data", &name) == B_OK) { + if (!strcasecmp(name, "Visual")) { + tol->SetValue(B_CONTROL_ON); value = FILLTOL_TOL; - } - else if (!strcasecmp (name, "RGB") || !strcasecmp (name, "Absolute")) - { - rgb->SetValue (B_CONTROL_ON); + } else if (!strcasecmp(name, "RGB") || !strcasecmp(name, "Absolute")) { + rgb->SetValue(B_CONTROL_ON); value = FILLTOL_RGB; } - if (value) - { + if (value) { fTolMode = value; - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } - } - else - { + } else { // Error report... } } } - fCurrentProperty = 0; - break; + fCurrentProperty = 0; + break; } - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'AFtV': @@ -247,19 +230,19 @@ void AttribFill::MessageReceived (BMessage *msg) fTolMode = FILLTOL_RGB; break; case 'AFcT': - fTolerance = msg->FindFloat ("value"); + fTolerance = msg->FindFloat("value"); break; case 'AFcR': - fToleranceRGB.red = uint8 (msg->FindFloat ("value")); + fToleranceRGB.red = uint8(msg->FindFloat("value")); break; case 'AFcG': - fToleranceRGB.green = uint8 (msg->FindFloat ("value")); + fToleranceRGB.green = uint8(msg->FindFloat("value")); break; case 'AFcB': - fToleranceRGB.blue = uint8 (msg->FindFloat ("value")); + fToleranceRGB.blue = uint8(msg->FindFloat("value")); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AttribFill.h b/source/AttribFill.h index 8475317..b2ac6c8 100644 --- a/source/AttribFill.h +++ b/source/AttribFill.h @@ -6,35 +6,40 @@ #include #include "Slider.h" -#define FILLTOL_TOL 0 -#define FILLTOL_RGB 1 +#define FILLTOL_TOL 0 +#define FILLTOL_RGB 1 -#define PROP_TOLTYPE 0 -#define PROP_VISUAL 1 -#define PROP_DRED 2 -#define PROP_DGREEN 3 -#define PROP_DBLUE 4 +#define PROP_TOLTYPE 0 +#define PROP_VISUAL 1 +#define PROP_DRED 2 +#define PROP_DGREEN 3 +#define PROP_DBLUE 4 class AttribFill : public AttribView { -public: - AttribFill (); -virtual ~AttribFill (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -int getTolMode () { return fTolMode; }; -float getTolerance () { return fTolerance; }; -rgb_color getToleranceRGB () { return fToleranceRGB; }; - -private: -typedef AttribView inherited; -int fTolMode; -float fTolerance; -rgb_color fToleranceRGB; -BRadioButton *tol, *rgb; -Slider *sT, *sR, *sG, *sB; -int fCurrentProperty; + public: + AttribFill(); + virtual ~AttribFill(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + + int getTolMode() { return fTolMode; }; + + float getTolerance() { return fTolerance; }; + + rgb_color getToleranceRGB() { return fToleranceRGB; }; + + private: + typedef AttribView inherited; + int fTolMode; + float fTolerance; + rgb_color fToleranceRGB; + BRadioButton *tol, *rgb; + Slider *sT, *sR, *sG, *sB; + int fCurrentProperty; }; #endif diff --git a/source/AttribFreehand.cpp b/source/AttribFreehand.cpp index 4b6d719..afe4dc8 100644 --- a/source/AttribFreehand.cpp +++ b/source/AttribFreehand.cpp @@ -3,97 +3,88 @@ #include #include "Settings.h" -static property_info prop_list[] = { - {"PenSize", SET, DIRECT, "float: 0 .. 50"}, - 0 -}; +static property_info prop_list[] = {{"PenSize", SET, DIRECT, "float: 0 .. 50"}, 0}; -AttribFreehand::AttribFreehand () -: AttribView (BRect (0, 0, 148, 40), lstring (27, "Freehand")) +AttribFreehand::AttribFreehand() : AttribView(BRect(0, 0, 148, 40), lstring(27, "Freehand")) { - SetViewColor (LightGrey); - pSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('AFpc')); - AddChild (pSlid); + SetViewColor(LightGrey); + pSlid = new Slider( + BRect(8, 8, 140, 26), 60, lstring(310, "Pen Size"), 1, 50, 1, new BMessage('AFpc') + ); + AddChild(pSlid); fPenSize = 1; fCurrentProperty = 0; } +AttribFreehand::~AttribFreehand() {} -AttribFreehand::~AttribFreehand () +status_t +AttribFreehand::GetSupportedSuites(BMessage* message) { + message->AddString("suites", "suite/x-sum-becasso-Freehand"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -status_t AttribFreehand::GetSupportedSuites (BMessage *message) +BHandler* +AttribFreehand::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - message->AddString ("suites", "suite/x-sum-becasso-Freehand"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); -} - -BHandler *AttribFreehand::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) -{ - if (!strcasecmp (property, "PenSize")) - { + if (!strcasecmp(property, "PenSize")) { fCurrentProperty = PROP_PENSIZE; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribFreehand::MessageReceived (BMessage *msg) +void +AttribFreehand::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_PENSIZE: // float, 0 .. 50 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_PENSIZE: // float, 0 .. 50 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 50) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 50) { fPenSize = value; - pSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + pSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } } - fCurrentProperty = 0; - break; + fCurrentProperty = 0; + break; } - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'AFpc': - fPenSize = msg->FindFloat ("value"); + fPenSize = msg->FindFloat("value"); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AttribFreehand.h b/source/AttribFreehand.h index 3180a06..6259a3b 100644 --- a/source/AttribFreehand.h +++ b/source/AttribFreehand.h @@ -5,23 +5,26 @@ #include #include "Slider.h" -#define PROP_PENSIZE 1 +#define PROP_PENSIZE 1 class AttribFreehand : public AttribView { -public: - AttribFreehand (); -virtual ~AttribFreehand (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -float getPenSize () { return fPenSize; }; + public: + AttribFreehand(); + virtual ~AttribFreehand(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); -private: -typedef AttribView inherited; -float fPenSize; -Slider *pSlid; -int fCurrentProperty; + float getPenSize() { return fPenSize; }; + + private: + typedef AttribView inherited; + float fPenSize; + Slider* pSlid; + int fCurrentProperty; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribLines.cpp b/source/AttribLines.cpp index 118ff97..02bd857 100644 --- a/source/AttribLines.cpp +++ b/source/AttribLines.cpp @@ -10,114 +10,108 @@ static property_info prop_list[] = { 0 }; -AttribLines::AttribLines () -: AttribView (BRect (0, 0, 148, 54), lstring (28, "Lines")) +AttribLines::AttribLines() : AttribView(BRect(0, 0, 148, 54), lstring(28, "Lines")) { - SetViewColor (LightGrey); - lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc')); - AddChild (lSlid); + SetViewColor(LightGrey); + lSlid = new Slider( + BRect(8, 8, 140, 26), 60, lstring(310, "Pen Size"), 1, 50, 1, new BMessage('ALpc') + ); + AddChild(lSlid); fPenSize = 1; - lFC = new BCheckBox (BRect (8, 30, 120, 48), "lFC", lstring (348, "Fill Corners"), new BMessage ('ALfc')); - lFC->SetValue (1); + lFC = new BCheckBox( + BRect(8, 30, 120, 48), "lFC", lstring(348, "Fill Corners"), new BMessage('ALfc') + ); + lFC->SetValue(1); fFillCorners = true; - AddChild (lFC); + AddChild(lFC); fCurrentProperty = 0; } +AttribLines::~AttribLines() {} -AttribLines::~AttribLines () +status_t +AttribLines::GetSupportedSuites(BMessage* message) { + message->AddString("suites", "suite/x-sum-becasso-Lines"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -status_t AttribLines::GetSupportedSuites (BMessage *message) +BHandler* +AttribLines::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - message->AddString ("suites", "suite/x-sum-becasso-Lines"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); -} - -BHandler *AttribLines::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) -{ - if (!strcasecmp (property, "PenSize")) - { + if (!strcasecmp(property, "PenSize")) { fCurrentProperty = PROP_PENSIZE; return this; } - if (!strcasecmp (property, "Corners") || !strcasecmp (property, "FillCorners")) - { + if (!strcasecmp(property, "Corners") || !strcasecmp(property, "FillCorners")) { fCurrentProperty = PROP_FILLCORNERS; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribLines::MessageReceived (BMessage *msg) +void +AttribLines::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_PENSIZE: // float, 0 .. 50 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_PENSIZE: // float, 0 .. 50 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 50) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 50) { fPenSize = value; - lSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + lSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_FILLCORNERS: // boolean + case PROP_FILLCORNERS: // boolean { bool value; - if (msg->FindBool ("data", &value) == B_OK) - { + if (msg->FindBool("data", &value) == B_OK) { fFillCorners = value; - lFC->SetValue (value); + lFC->SetValue(value); } } - fCurrentProperty = 0; - break; + fCurrentProperty = 0; + break; } - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'ALpc': - fPenSize = msg->FindFloat ("value"); + fPenSize = msg->FindFloat("value"); break; case 'ALfc': fFillCorners = lFC->Value(); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AttribLines.h b/source/AttribLines.h index cbe5045..88bf4cf 100644 --- a/source/AttribLines.h +++ b/source/AttribLines.h @@ -6,27 +6,31 @@ #include #include "Slider.h" -#define PROP_PENSIZE 1 -#define PROP_FILLCORNERS 2 +#define PROP_PENSIZE 1 +#define PROP_FILLCORNERS 2 class AttribLines : public AttribView { -public: - AttribLines (); -virtual ~AttribLines (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -float getPenSize () { return fPenSize; }; -bool fillCorners () { return fFillCorners; }; + public: + AttribLines(); + virtual ~AttribLines(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); -private: -typedef AttribView inherited; -BCheckBox *lFC; -float fPenSize; -bool fFillCorners; -Slider *lSlid; -int fCurrentProperty; + float getPenSize() { return fPenSize; }; + + bool fillCorners() { return fFillCorners; }; + + private: + typedef AttribView inherited; + BCheckBox* lFC; + float fPenSize; + bool fFillCorners; + Slider* lSlid; + int fCurrentProperty; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribPolyblob.cpp b/source/AttribPolyblob.cpp index 6191ab5..958a93a 100644 --- a/source/AttribPolyblob.cpp +++ b/source/AttribPolyblob.cpp @@ -1,5 +1,5 @@ #include "AttribPolyblob.h" -#include "Colors.h" +#include "Colors.h" #include #include #include @@ -12,260 +12,234 @@ static property_info prop_list[] = { 0 }; -AttribPolyblob::AttribPolyblob () -: AttribView (BRect (0, 0, 148, 90), lstring (29, "Free Shapes")) +AttribPolyblob::AttribPolyblob() : AttribView(BRect(0, 0, 148, 90), lstring(29, "Free Shapes")) { - SetViewColor (LightGrey); - lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc')); - AddChild (lSlid); + SetViewColor(LightGrey); + lSlid = new Slider( + BRect(8, 8, 140, 26), 60, lstring(310, "Pen Size"), 1, 50, 1, new BMessage('ALpc') + ); + AddChild(lSlid); fPenSize = 1; fType = POLYBLOB_OUTFILL; - BBox *type = new BBox (BRect (18, 32, 130, 82), "type"); - type->SetLabel (lstring (311, "Type")); - AddChild (type); - - BPoint pointArray[] = { - BPoint ( 2, 8), - BPoint ( 3, 4), - BPoint ( 6, 3), - BPoint ( 9, 2), - BPoint (12, 3), - BPoint (20, 5), - BPoint (23, 7), - BPoint (27, 12), - BPoint (26, 15), - BPoint (24, 20), - BPoint (22, 23), - BPoint (19, 28), - BPoint (18, 28), - BPoint (16, 23), - BPoint (15, 20), - BPoint (13, 21), - BPoint (11, 23), - BPoint ( 6, 22), - BPoint ( 4, 15), - BPoint ( 3, 10) - }; - BPolygon *poly = new BPolygon(); + BBox* type = new BBox(BRect(18, 32, 130, 82), "type"); + type->SetLabel(lstring(311, "Type")); + AddChild(type); + + BPoint pointArray[] = {BPoint(2, 8), BPoint(3, 4), BPoint(6, 3), BPoint(9, 2), + BPoint(12, 3), BPoint(20, 5), BPoint(23, 7), BPoint(27, 12), + BPoint(26, 15), BPoint(24, 20), BPoint(22, 23), BPoint(19, 28), + BPoint(18, 28), BPoint(16, 23), BPoint(15, 20), BPoint(13, 21), + BPoint(11, 23), BPoint(6, 22), BPoint(4, 15), BPoint(3, 10)}; + BPolygon* poly = new BPolygon(); poly->AddPoints(pointArray, 20); - BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL)); - BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL)); - picWindow->AddChild (bg); - - BPicture *p10; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetLowColor (White); - bg->FillPolygon (poly, B_SOLID_LOW); - bg->StrokePolygon (poly); + BWindow* picWindow = new BWindow( + BRect(0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32(NULL), uint32(NULL) + ); + BView* bg = new BView(BRect(0, 0, 100, 100), "Temp Pic View", uint32(NULL), uint32(NULL)); + picWindow->AddChild(bg); + + BPicture* p10; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetLowColor(White); + bg->FillPolygon(poly, B_SOLID_LOW); + bg->StrokePolygon(poly); p10 = bg->EndPicture(); - - BPicture *p20; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillPolygon (poly, B_SOLID_LOW); + + BPicture* p20; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillPolygon(poly, B_SOLID_LOW); p20 = bg->EndPicture(); - - BPicture *p30; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->StrokePolygon (poly); + + BPicture* p30; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->StrokePolygon(poly); p30 = bg->EndPicture(); - BPicture *p11; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillPolygon (poly, B_SOLID_LOW); - bg->StrokePolygon (poly); + BPicture* p11; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillPolygon(poly, B_SOLID_LOW); + bg->StrokePolygon(poly); p11 = bg->EndPicture(); - - BPicture *p21; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillPolygon (poly, B_SOLID_LOW); + + BPicture* p21; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillPolygon(poly, B_SOLID_LOW); p21 = bg->EndPicture(); - - BPicture *p31; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->StrokePolygon (poly); + + BPicture* p31; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->StrokePolygon(poly); p31 = bg->EndPicture(); - + delete poly; delete picWindow; - - SetViewColor (LightGrey); - - pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON); - pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON); - pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON); - type->AddChild (pT1); - type->AddChild (pT2); - type->AddChild (pT3); - pT1->SetValue (B_CONTROL_ON); - fCurrentProperty = 0; -} + SetViewColor(LightGrey); -AttribPolyblob::~AttribPolyblob () -{ + pT1 = new BPictureButton( + BRect(4, 15, 34, 45), "APVt1", p10, p11, new BMessage('pvT1'), B_TWO_STATE_BUTTON + ); + pT2 = new BPictureButton( + BRect(40, 15, 70, 45), "APVt2", p20, p21, new BMessage('pvT2'), B_TWO_STATE_BUTTON + ); + pT3 = new BPictureButton( + BRect(76, 15, 106, 45), "APVt3", p30, p31, new BMessage('pvT3'), B_TWO_STATE_BUTTON + ); + type->AddChild(pT1); + type->AddChild(pT2); + type->AddChild(pT3); + pT1->SetValue(B_CONTROL_ON); + fCurrentProperty = 0; } -status_t AttribPolyblob::GetSupportedSuites (BMessage *message) +AttribPolyblob::~AttribPolyblob() {} + +status_t +AttribPolyblob::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso-Free Shape"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso-Free Shape"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -BHandler *AttribPolyblob::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribPolyblob::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - if (!strcasecmp (property, "PenSize")) - { + if (!strcasecmp(property, "PenSize")) { fCurrentProperty = PROP_PENSIZE; return this; } - if (!strcasecmp (property, "ShapeType") || !strcasecmp (property, "Type")) - { + if (!strcasecmp(property, "ShapeType") || !strcasecmp(property, "Type")) { fCurrentProperty = PROP_TYPE; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribPolyblob::MessageReceived (BMessage *msg) +void +AttribPolyblob::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_PENSIZE: // float, 0 .. 50 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_PENSIZE: // float, 0 .. 50 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 50) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 50) { fPenSize = value; - lSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + lSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_TYPE: // FilledOutline, Filled, Outline + case PROP_TYPE: // FilledOutline, Filled, Outline { - const char *name; + const char* name; int value = 0; - if (msg->FindString ("data", &name) == B_OK) - { - if (!strcasecmp (name, "FilledOutline")) - { - pT1->SetValue (B_CONTROL_ON); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_OFF); + if (msg->FindString("data", &name) == B_OK) { + if (!strcasecmp(name, "FilledOutline")) { + pT1->SetValue(B_CONTROL_ON); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_OFF); value = POLYBLOB_OUTFILL; - } - else if (!strcasecmp (name, "Filled")) - { - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_ON); - pT3->SetValue (B_CONTROL_OFF); + } else if (!strcasecmp(name, "Filled")) { + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_ON); + pT3->SetValue(B_CONTROL_OFF); value = POLYBLOB_FILL; - } - else if (!strcasecmp (name, "Outline")) - { - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_ON); + } else if (!strcasecmp(name, "Outline")) { + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_ON); value = POLYBLOB_OUTLINE; } - if (value) - { + if (value) { fType = value; - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } - } - else - { + } else { // Error report... } } } - fCurrentProperty = 0; - break; + fCurrentProperty = 0; + break; } - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'ALpc': - fPenSize = msg->FindFloat ("value"); + fPenSize = msg->FindFloat("value"); break; case 'pvT1': fType = POLYBLOB_OUTFILL; - pT1->SetValue (B_CONTROL_ON); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_OFF); + pT1->SetValue(B_CONTROL_ON); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_OFF); break; case 'pvT2': fType = POLYBLOB_FILL; - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_ON); - pT3->SetValue (B_CONTROL_OFF); + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_ON); + pT3->SetValue(B_CONTROL_OFF); break; case 'pvT3': fType = POLYBLOB_OUTLINE; - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_ON); + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_ON); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } diff --git a/source/AttribPolyblob.h b/source/AttribPolyblob.h index e731c51..da40eff 100644 --- a/source/AttribPolyblob.h +++ b/source/AttribPolyblob.h @@ -7,30 +7,34 @@ #include "Slider.h" #define POLYBLOB_OUTLINE 1 -#define POLYBLOB_FILL 2 +#define POLYBLOB_FILL 2 #define POLYBLOB_OUTFILL 3 -#define PROP_PENSIZE 1 -#define PROP_TYPE 2 +#define PROP_PENSIZE 1 +#define PROP_TYPE 2 class AttribPolyblob : public AttribView { -public: - AttribPolyblob (); -virtual ~AttribPolyblob (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -float getPenSize () { return fPenSize; }; -int getType () { return fType; }; - -private: -typedef AttribView inherited; -float fPenSize; -int fType; -BPictureButton *pT1, *pT2, *pT3; -Slider *lSlid; -int fCurrentProperty; + public: + AttribPolyblob(); + virtual ~AttribPolyblob(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + + float getPenSize() { return fPenSize; }; + + int getType() { return fType; }; + + private: + typedef AttribView inherited; + float fPenSize; + int fType; + BPictureButton *pT1, *pT2, *pT3; + Slider* lSlid; + int fCurrentProperty; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribPolygon.cpp b/source/AttribPolygon.cpp index 2a20937..2262160 100644 --- a/source/AttribPolygon.cpp +++ b/source/AttribPolygon.cpp @@ -15,246 +15,231 @@ static property_info prop_list[] = { 0 }; -AttribPolygon::AttribPolygon () -: AttribView (BRect (0, 0, 148, 90), lstring (30, "Polygons")) +AttribPolygon::AttribPolygon() : AttribView(BRect(0, 0, 148, 90), lstring(30, "Polygons")) { - SetViewColor (LightGrey); - lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc')); - AddChild (lSlid); + SetViewColor(LightGrey); + lSlid = new Slider( + BRect(8, 8, 140, 26), 60, lstring(310, "Pen Size"), 1, 50, 1, new BMessage('ALpc') + ); + AddChild(lSlid); fPenSize = 1; fType = POLYGON_OUTFILL; - BBox *type = new BBox (BRect (18, 32, 130, 82), "type"); - type->SetLabel (lstring (311, "Type")); - AddChild (type); + BBox* type = new BBox(BRect(18, 32, 130, 82), "type"); + type->SetLabel(lstring(311, "Type")); + AddChild(type); - BPoint pointArray[] = { - BPoint ( 2, 8), - BPoint ( 9, 2), - BPoint (27, 12), - BPoint (19, 28), - BPoint (14, 20), - BPoint ( 9, 26) - }; - BPolygon *poly = new BPolygon(); + BPoint pointArray[] = {BPoint(2, 8), BPoint(9, 2), BPoint(27, 12), + BPoint(19, 28), BPoint(14, 20), BPoint(9, 26)}; + BPolygon* poly = new BPolygon(); poly->AddPoints(pointArray, 6); - BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL)); - BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL)); - picWindow->AddChild (bg); - - BPicture *p10; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetLowColor (White); - bg->FillPolygon (poly, B_SOLID_LOW); - bg->StrokePolygon (poly); + BWindow* picWindow = new BWindow( + BRect(0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32(NULL), uint32(NULL) + ); + BView* bg = new BView(BRect(0, 0, 100, 100), "Temp Pic View", uint32(NULL), uint32(NULL)); + picWindow->AddChild(bg); + + BPicture* p10; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetLowColor(White); + bg->FillPolygon(poly, B_SOLID_LOW); + bg->StrokePolygon(poly); p10 = bg->EndPicture(); - - BPicture *p20; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillPolygon (poly, B_SOLID_LOW); + + BPicture* p20; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillPolygon(poly, B_SOLID_LOW); p20 = bg->EndPicture(); - - BPicture *p30; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->StrokePolygon (poly); + + BPicture* p30; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->StrokePolygon(poly); p30 = bg->EndPicture(); - BPicture *p11; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillPolygon (poly, B_SOLID_LOW); - bg->StrokePolygon (poly); + BPicture* p11; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillPolygon(poly, B_SOLID_LOW); + bg->StrokePolygon(poly); p11 = bg->EndPicture(); - - BPicture *p21; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillPolygon (poly, B_SOLID_LOW); + + BPicture* p21; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillPolygon(poly, B_SOLID_LOW); p21 = bg->EndPicture(); - - BPicture *p31; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->StrokePolygon (poly); + + BPicture* p31; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->StrokePolygon(poly); p31 = bg->EndPicture(); - + delete poly; delete picWindow; - - SetViewColor (LightGrey); - - pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON); - pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON); - pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON); - type->AddChild (pT1); - type->AddChild (pT2); - type->AddChild (pT3); - pT1->SetValue (B_CONTROL_ON); - fCurrentProperty = 0; -} + SetViewColor(LightGrey); -AttribPolygon::~AttribPolygon () -{ + pT1 = new BPictureButton( + BRect(4, 15, 34, 45), "APVt1", p10, p11, new BMessage('pvT1'), B_TWO_STATE_BUTTON + ); + pT2 = new BPictureButton( + BRect(40, 15, 70, 45), "APVt2", p20, p21, new BMessage('pvT2'), B_TWO_STATE_BUTTON + ); + pT3 = new BPictureButton( + BRect(76, 15, 106, 45), "APVt3", p30, p31, new BMessage('pvT3'), B_TWO_STATE_BUTTON + ); + type->AddChild(pT1); + type->AddChild(pT2); + type->AddChild(pT3); + pT1->SetValue(B_CONTROL_ON); + fCurrentProperty = 0; } -status_t AttribPolygon::GetSupportedSuites (BMessage *message) +AttribPolygon::~AttribPolygon() {} + +status_t +AttribPolygon::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso-Polygons"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso-Polygons"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -BHandler *AttribPolygon::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribPolygon::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - if (!strcasecmp (property, "PenSize")) - { + if (!strcasecmp(property, "PenSize")) { fCurrentProperty = PROP_PENSIZE; return this; } - if (!strcasecmp (property, "ShapeType") || !strcasecmp (property, "Type")) - { + if (!strcasecmp(property, "ShapeType") || !strcasecmp(property, "Type")) { fCurrentProperty = PROP_TYPE; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribPolygon::MessageReceived (BMessage *msg) +void +AttribPolygon::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_PENSIZE: // float, 0 .. 50 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_PENSIZE: // float, 0 .. 50 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 50) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 50) { fPenSize = value; - lSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + lSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_TYPE: // FilledOutline, Filled, Outline + case PROP_TYPE: // FilledOutline, Filled, Outline { - const char *name; + const char* name; int value = 0; - if (msg->FindString ("data", &name) == B_OK) - { - if (!strcasecmp (name, "FilledOutline")) - { - pT1->SetValue (B_CONTROL_ON); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_OFF); + if (msg->FindString("data", &name) == B_OK) { + if (!strcasecmp(name, "FilledOutline")) { + pT1->SetValue(B_CONTROL_ON); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_OFF); value = POLYGON_OUTFILL; - } - else if (!strcasecmp (name, "Filled")) - { - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_ON); - pT3->SetValue (B_CONTROL_OFF); + } else if (!strcasecmp(name, "Filled")) { + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_ON); + pT3->SetValue(B_CONTROL_OFF); value = POLYGON_FILL; - } - else if (!strcasecmp (name, "Outline")) - { - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_ON); + } else if (!strcasecmp(name, "Outline")) { + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_ON); value = POLYGON_OUTLINE; } - if (value) - { + if (value) { fType = value; - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } - } - else - { + } else { // Error report... } } } - fCurrentProperty = 0; - break; + fCurrentProperty = 0; + break; } - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'ALpc': - fPenSize = msg->FindFloat ("value"); + fPenSize = msg->FindFloat("value"); break; case 'pvT1': fType = POLYGON_OUTFILL; - pT1->SetValue (B_CONTROL_ON); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_OFF); + pT1->SetValue(B_CONTROL_ON); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_OFF); break; case 'pvT2': fType = POLYGON_FILL; - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_ON); - pT3->SetValue (B_CONTROL_OFF); + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_ON); + pT3->SetValue(B_CONTROL_OFF); break; case 'pvT3': fType = POLYGON_OUTLINE; - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_ON); + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_ON); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } diff --git a/source/AttribPolygon.h b/source/AttribPolygon.h index f1367f4..84cd357 100644 --- a/source/AttribPolygon.h +++ b/source/AttribPolygon.h @@ -7,30 +7,34 @@ #include "Slider.h" #define POLYGON_OUTLINE 1 -#define POLYGON_FILL 2 +#define POLYGON_FILL 2 #define POLYGON_OUTFILL 3 -#define PROP_PENSIZE 1 -#define PROP_TYPE 2 +#define PROP_PENSIZE 1 +#define PROP_TYPE 2 class AttribPolygon : public AttribView { -public: - AttribPolygon (); -virtual ~AttribPolygon (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -float getPenSize () { return fPenSize; }; -int getType () { return fType; }; - -private: -typedef AttribView inherited; -float fPenSize; -int fType; -BPictureButton *pT1, *pT2, *pT3; -Slider *lSlid; -int fCurrentProperty; + public: + AttribPolygon(); + virtual ~AttribPolygon(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + + float getPenSize() { return fPenSize; }; + + int getType() { return fType; }; + + private: + typedef AttribView inherited; + float fPenSize; + int fType; + BPictureButton *pT1, *pT2, *pT3; + Slider* lSlid; + int fCurrentProperty; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribRect.cpp b/source/AttribRect.cpp index 9877c8c..15e751e 100644 --- a/source/AttribRect.cpp +++ b/source/AttribRect.cpp @@ -12,233 +12,225 @@ static property_info prop_list[] = { 0 }; -AttribRect::AttribRect () -: AttribView (BRect (0, 0, 148, 90), lstring (31, "Rectangles")) +AttribRect::AttribRect() : AttribView(BRect(0, 0, 148, 90), lstring(31, "Rectangles")) { - SetViewColor (LightGrey); - lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc')); - AddChild (lSlid); + SetViewColor(LightGrey); + lSlid = new Slider( + BRect(8, 8, 140, 26), 60, lstring(310, "Pen Size"), 1, 50, 1, new BMessage('ALpc') + ); + AddChild(lSlid); fType = RECT_OUTFILL; fPenSize = 1; - BBox *type = new BBox (BRect (18, 32, 130, 82), "type"); - type->SetLabel (lstring (311, "Type")); - AddChild (type); - BRect shape = BRect (3, 5, 27, 25); - - BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL)); - BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL)); - picWindow->AddChild (bg); - - BPicture *p10; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetLowColor (White); - bg->FillRect (shape, B_SOLID_LOW); - bg->StrokeRect (shape); + BBox* type = new BBox(BRect(18, 32, 130, 82), "type"); + type->SetLabel(lstring(311, "Type")); + AddChild(type); + BRect shape = BRect(3, 5, 27, 25); + + BWindow* picWindow = new BWindow( + BRect(0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32(NULL), uint32(NULL) + ); + BView* bg = new BView(BRect(0, 0, 100, 100), "Temp Pic View", uint32(NULL), uint32(NULL)); + picWindow->AddChild(bg); + + BPicture* p10; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetLowColor(White); + bg->FillRect(shape, B_SOLID_LOW); + bg->StrokeRect(shape); p10 = bg->EndPicture(); - - BPicture *p20; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillRect (shape, B_SOLID_LOW); + + BPicture* p20; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillRect(shape, B_SOLID_LOW); p20 = bg->EndPicture(); - - BPicture *p30; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->StrokeRect (shape); + + BPicture* p30; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->StrokeRect(shape); p30 = bg->EndPicture(); - BPicture *p11; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillRect (shape, B_SOLID_LOW); - bg->StrokeRect (shape); + BPicture* p11; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillRect(shape, B_SOLID_LOW); + bg->StrokeRect(shape); p11 = bg->EndPicture(); - - BPicture *p21; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillRect (shape, B_SOLID_LOW); + + BPicture* p21; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillRect(shape, B_SOLID_LOW); p21 = bg->EndPicture(); - - BPicture *p31; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->StrokeRect (shape); + + BPicture* p31; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->StrokeRect(shape); p31 = bg->EndPicture(); - - SetViewColor (LightGrey); + + SetViewColor(LightGrey); delete picWindow; - - pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON); - pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON); - pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON); - type->AddChild (pT1); - type->AddChild (pT2); - type->AddChild (pT3); - pT1->SetValue (B_CONTROL_ON); + + pT1 = new BPictureButton( + BRect(4, 15, 34, 45), "APVt1", p10, p11, new BMessage('pvT1'), B_TWO_STATE_BUTTON + ); + pT2 = new BPictureButton( + BRect(40, 15, 70, 45), "APVt2", p20, p21, new BMessage('pvT2'), B_TWO_STATE_BUTTON + ); + pT3 = new BPictureButton( + BRect(76, 15, 106, 45), "APVt3", p30, p31, new BMessage('pvT3'), B_TWO_STATE_BUTTON + ); + type->AddChild(pT1); + type->AddChild(pT2); + type->AddChild(pT3); + pT1->SetValue(B_CONTROL_ON); fCurrentProperty = 0; } -AttribRect::~AttribRect () -{ -} +AttribRect::~AttribRect() {} -status_t AttribRect::GetSupportedSuites (BMessage *message) +status_t +AttribRect::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso-Rectangles"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso-Rectangles"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -BHandler *AttribRect::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribRect::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - if (!strcasecmp (property, "PenSize")) - { + if (!strcasecmp(property, "PenSize")) { fCurrentProperty = PROP_PENSIZE; return this; } - if (!strcasecmp (property, "ShapeType") || !strcasecmp (property, "Type")) - { + if (!strcasecmp(property, "ShapeType") || !strcasecmp(property, "Type")) { fCurrentProperty = PROP_TYPE; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribRect::MessageReceived (BMessage *msg) +void +AttribRect::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_PENSIZE: // float, 0 .. 50 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_PENSIZE: // float, 0 .. 50 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 50) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 50) { fPenSize = value; - lSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + lSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_TYPE: // FilledOutline, Filled, Outline + case PROP_TYPE: // FilledOutline, Filled, Outline { - const char *name; + const char* name; int value = 0; - if (msg->FindString ("data", &name) == B_OK) - { - if (!strcasecmp (name, "FilledOutline")) - { - pT1->SetValue (B_CONTROL_ON); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_OFF); + if (msg->FindString("data", &name) == B_OK) { + if (!strcasecmp(name, "FilledOutline")) { + pT1->SetValue(B_CONTROL_ON); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_OFF); value = RECT_OUTFILL; - } - else if (!strcasecmp (name, "Filled")) - { - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_ON); - pT3->SetValue (B_CONTROL_OFF); + } else if (!strcasecmp(name, "Filled")) { + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_ON); + pT3->SetValue(B_CONTROL_OFF); value = RECT_FILL; - } - else if (!strcasecmp (name, "Outline")) - { - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_ON); + } else if (!strcasecmp(name, "Outline")) { + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_ON); value = RECT_OUTLINE; } - if (value) - { + if (value) { fType = value; - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } - } - else - { + } else { // Error report... } } } - fCurrentProperty = 0; - break; + fCurrentProperty = 0; + break; } - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'ALpc': - fPenSize = msg->FindFloat ("value"); + fPenSize = msg->FindFloat("value"); break; case 'pvT1': fType = RECT_OUTFILL; - pT1->SetValue (B_CONTROL_ON); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_OFF); + pT1->SetValue(B_CONTROL_ON); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_OFF); break; case 'pvT2': fType = RECT_FILL; - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_ON); - pT3->SetValue (B_CONTROL_OFF); + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_ON); + pT3->SetValue(B_CONTROL_OFF); break; case 'pvT3': fType = RECT_OUTLINE; - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_ON); + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_ON); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AttribRect.h b/source/AttribRect.h index f820a85..f8e4ec0 100644 --- a/source/AttribRect.h +++ b/source/AttribRect.h @@ -7,30 +7,34 @@ #include "Slider.h" #define RECT_OUTLINE 1 -#define RECT_FILL 2 +#define RECT_FILL 2 #define RECT_OUTFILL 3 -#define PROP_PENSIZE 1 -#define PROP_TYPE 2 +#define PROP_PENSIZE 1 +#define PROP_TYPE 2 class AttribRect : public AttribView { -public: - AttribRect (); -virtual ~AttribRect (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -float getPenSize () { return fPenSize; }; -int getType () { return fType; }; - -private: -typedef AttribView inherited; -float fPenSize; -int fType; -BPictureButton *pT1, *pT2, *pT3; -Slider *lSlid; -int fCurrentProperty; + public: + AttribRect(); + virtual ~AttribRect(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + + float getPenSize() { return fPenSize; }; + + int getType() { return fType; }; + + private: + typedef AttribView inherited; + float fPenSize; + int fType; + BPictureButton *pT1, *pT2, *pT3; + Slider* lSlid; + int fCurrentProperty; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribRoundRect.cpp b/source/AttribRoundRect.cpp index 9846152..5204c9b 100644 --- a/source/AttribRoundRect.cpp +++ b/source/AttribRoundRect.cpp @@ -20,12 +20,13 @@ static property_info prop_list[] = { 0 }; -AttribRoundRect::AttribRoundRect () -: AttribView (BRect (0, 0, 148, 190), lstring (32, "Ovals")) +AttribRoundRect::AttribRoundRect() : AttribView(BRect(0, 0, 148, 190), lstring(32, "Ovals")) { - SetViewColor (LightGrey); - lSlid = new Slider (BRect (8, 8, 140, 26), 60, lstring (310, "Pen Size"), 1, 50, 1, new BMessage ('ALpc')); - AddChild (lSlid); + SetViewColor(LightGrey); + lSlid = new Slider( + BRect(8, 8, 140, 26), 60, lstring(310, "Pen Size"), 1, 50, 1, new BMessage('ALpc') + ); + AddChild(lSlid); fType = RRECT_OUTFILL; fPenSize = 1; fRadType = RRECT_RELATIVE; @@ -33,399 +34,380 @@ AttribRoundRect::AttribRoundRect () fRadYabs = 8; fRadXrel = 0.1; fRadYrel = 0.1; - - BBox *type = new BBox (BRect (18, 32, 130, 82), "type"); - type->SetLabel (lstring (311, "Type")); - AddChild (type); - - BRect shape = BRect (3, 5, 27, 25); - - BWindow *picWindow = new BWindow (BRect (0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32 (NULL), uint32 (NULL)); - BView *bg = new BView (BRect (0, 0, 100, 100), "Temp Pic View", uint32 (NULL), uint32 (NULL)); - picWindow->AddChild (bg); - - BPicture *p10; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetLowColor (White); - bg->FillRoundRect (shape, 8, 8, B_SOLID_LOW); - bg->StrokeRoundRect (shape, 8, 8); + + BBox* type = new BBox(BRect(18, 32, 130, 82), "type"); + type->SetLabel(lstring(311, "Type")); + AddChild(type); + + BRect shape = BRect(3, 5, 27, 25); + + BWindow* picWindow = new BWindow( + BRect(0, 0, 100, 100), "Temp Pic Window", B_BORDERED_WINDOW, uint32(NULL), uint32(NULL) + ); + BView* bg = new BView(BRect(0, 0, 100, 100), "Temp Pic View", uint32(NULL), uint32(NULL)); + picWindow->AddChild(bg); + + BPicture* p10; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetLowColor(White); + bg->FillRoundRect(shape, 8, 8, B_SOLID_LOW); + bg->StrokeRoundRect(shape, 8, 8); p10 = bg->EndPicture(); - - BPicture *p20; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillRoundRect (shape, 8, 8, B_SOLID_LOW); + + BPicture* p20; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillRoundRect(shape, 8, 8, B_SOLID_LOW); p20 = bg->EndPicture(); - - BPicture *p30; - bg->BeginPicture (new BPicture); - bg->SetLowColor (LightGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->StrokeRoundRect (shape, 8, 8); + + BPicture* p30; + bg->BeginPicture(new BPicture); + bg->SetLowColor(LightGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->StrokeRoundRect(shape, 8, 8); p30 = bg->EndPicture(); - BPicture *p11; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillRoundRect (shape, 8, 8, B_SOLID_LOW); - bg->StrokeRoundRect (shape, 8, 8); + BPicture* p11; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillRoundRect(shape, 8, 8, B_SOLID_LOW); + bg->StrokeRoundRect(shape, 8, 8); p11 = bg->EndPicture(); - - BPicture *p21; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->FillRoundRect (shape, 8, 8, B_SOLID_LOW); + + BPicture* p21; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->FillRoundRect(shape, 8, 8, B_SOLID_LOW); p21 = bg->EndPicture(); - - BPicture *p31; - bg->BeginPicture (new BPicture); - bg->SetLowColor (DarkGrey); - bg->FillRect (BRect (0, 0, 32, 32), B_SOLID_LOW); - bg->SetHighColor (Black); - bg->SetLowColor (White); - bg->StrokeRoundRect (shape, 8, 8); + + BPicture* p31; + bg->BeginPicture(new BPicture); + bg->SetLowColor(DarkGrey); + bg->FillRect(BRect(0, 0, 32, 32), B_SOLID_LOW); + bg->SetHighColor(Black); + bg->SetLowColor(White); + bg->StrokeRoundRect(shape, 8, 8); p31 = bg->EndPicture(); - - SetViewColor (LightGrey); + + SetViewColor(LightGrey); delete picWindow; - - pT1 = new BPictureButton (BRect (4, 15, 34, 45), "APVt1", p10, p11, new BMessage ('pvT1'), B_TWO_STATE_BUTTON); - pT2 = new BPictureButton (BRect (40, 15, 70, 45), "APVt2", p20, p21, new BMessage ('pvT2'), B_TWO_STATE_BUTTON); - pT3 = new BPictureButton (BRect (76, 15, 106, 45), "APVt3", p30, p31, new BMessage ('pvT3'), B_TWO_STATE_BUTTON); - type->AddChild (pT1); - type->AddChild (pT2); - type->AddChild (pT3); - pT1->SetValue (B_CONTROL_ON); - rel = new BRadioButton (BRect (8, 86, 144, 104), "rel", lstring (350, "Relative Corners"), new BMessage ('RRsr')); - abs = new BRadioButton (BRect (8, 107, 144, 125), "abs", lstring (351, "Absolute Corners"), new BMessage ('RRsa')); - rel->SetValue (B_CONTROL_ON); - AddChild (rel); - AddChild (abs); - - TabView *bgTab = new TabView (BRect (0, 128, 148, 191), "AttribRoundRect Tab"); - AddChild (bgTab); - BView *relTab = new BView (BRect (2, TAB_HEIGHT + 4, 126, TAB_HEIGHT + 44), "Rel View", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); - BView *absTab = new BView (BRect (2, TAB_HEIGHT + 4, 126, TAB_HEIGHT + 44), "Abs View", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); - relTab->SetViewColor (LightGrey); - absTab->SetViewColor (LightGrey); - bgTab->AddView (relTab, lstring (352, "Relative")); - bgTab->AddView (absTab, lstring (353, "Absolute")); - relx = new Slider (BRect (4, 2, 142, 18), 10, "x", 0, 0.5, 0.01, new BMessage ('RRRx'), B_HORIZONTAL, 0, "%1.2f"); - rely = new Slider (BRect (4, 22, 142, 38), 10, "y", 0, 0.5, 0.01, new BMessage ('RRRy'), B_HORIZONTAL, 0, "%1.2f"); - absx = new Slider (BRect (4, 2, 142, 18), 10, "x", 0, 200, 1, new BMessage ('RRAx')); - absy = new Slider (BRect (4, 22, 142, 38), 10, "y", 0, 200, 1, new BMessage ('RRAy')); - relx->SetValue (fRadXrel); - rely->SetValue (fRadYrel); - absx->SetValue (fRadXabs); - absy->SetValue (fRadYabs); - relTab->AddChild (relx); - relTab->AddChild (rely); - absTab->AddChild (absx); - absTab->AddChild (absy); + pT1 = new BPictureButton( + BRect(4, 15, 34, 45), "APVt1", p10, p11, new BMessage('pvT1'), B_TWO_STATE_BUTTON + ); + pT2 = new BPictureButton( + BRect(40, 15, 70, 45), "APVt2", p20, p21, new BMessage('pvT2'), B_TWO_STATE_BUTTON + ); + pT3 = new BPictureButton( + BRect(76, 15, 106, 45), "APVt3", p30, p31, new BMessage('pvT3'), B_TWO_STATE_BUTTON + ); + type->AddChild(pT1); + type->AddChild(pT2); + type->AddChild(pT3); + pT1->SetValue(B_CONTROL_ON); - fCurrentProperty = 0; -} + rel = new BRadioButton( + BRect(8, 86, 144, 104), "rel", lstring(350, "Relative Corners"), new BMessage('RRsr') + ); + abs = new BRadioButton( + BRect(8, 107, 144, 125), "abs", lstring(351, "Absolute Corners"), new BMessage('RRsa') + ); + rel->SetValue(B_CONTROL_ON); + AddChild(rel); + AddChild(abs); + TabView* bgTab = new TabView(BRect(0, 128, 148, 191), "AttribRoundRect Tab"); + AddChild(bgTab); + BView* relTab = new BView( + BRect(2, TAB_HEIGHT + 4, 126, TAB_HEIGHT + 44), "Rel View", B_FOLLOW_LEFT | B_FOLLOW_TOP, + B_WILL_DRAW + ); + BView* absTab = new BView( + BRect(2, TAB_HEIGHT + 4, 126, TAB_HEIGHT + 44), "Abs View", B_FOLLOW_LEFT | B_FOLLOW_TOP, + B_WILL_DRAW + ); + relTab->SetViewColor(LightGrey); + absTab->SetViewColor(LightGrey); + bgTab->AddView(relTab, lstring(352, "Relative")); + bgTab->AddView(absTab, lstring(353, "Absolute")); + relx = new Slider( + BRect(4, 2, 142, 18), 10, "x", 0, 0.5, 0.01, new BMessage('RRRx'), B_HORIZONTAL, 0, "%1.2f" + ); + rely = new Slider( + BRect(4, 22, 142, 38), 10, "y", 0, 0.5, 0.01, new BMessage('RRRy'), B_HORIZONTAL, 0, "%1.2f" + ); + absx = new Slider(BRect(4, 2, 142, 18), 10, "x", 0, 200, 1, new BMessage('RRAx')); + absy = new Slider(BRect(4, 22, 142, 38), 10, "y", 0, 200, 1, new BMessage('RRAy')); + relx->SetValue(fRadXrel); + rely->SetValue(fRadYrel); + absx->SetValue(fRadXabs); + absy->SetValue(fRadYabs); + relTab->AddChild(relx); + relTab->AddChild(rely); + absTab->AddChild(absx); + absTab->AddChild(absy); -AttribRoundRect::~AttribRoundRect () -{ + fCurrentProperty = 0; } -status_t AttribRoundRect::GetSupportedSuites (BMessage *message) +AttribRoundRect::~AttribRoundRect() {} + +status_t +AttribRoundRect::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso-Ovals"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso-Ovals"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -BHandler *AttribRoundRect::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribRoundRect::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - if (!strcasecmp (property, "PenSize")) - { + if (!strcasecmp(property, "PenSize")) { fCurrentProperty = PROP_PENSIZE; return this; } - if (!strcasecmp (property, "ShapeType") || !strcasecmp (property, "Type")) - { + if (!strcasecmp(property, "ShapeType") || !strcasecmp(property, "Type")) { fCurrentProperty = PROP_TYPE; return this; } - if (!strcasecmp (property, "RelativeWidth") || !strcasecmp (property, "RelX")) - { + if (!strcasecmp(property, "RelativeWidth") || !strcasecmp(property, "RelX")) { fCurrentProperty = PROP_RELX; return this; } - if (!strcasecmp (property, "RelativeHeight") || !strcasecmp (property, "RelY")) - { + if (!strcasecmp(property, "RelativeHeight") || !strcasecmp(property, "RelY")) { fCurrentProperty = PROP_RELY; return this; } - if (!strcasecmp (property, "AbsoluteWidth") || !strcasecmp (property, "AbsX")) - { + if (!strcasecmp(property, "AbsoluteWidth") || !strcasecmp(property, "AbsX")) { fCurrentProperty = PROP_ABSX; return this; } - if (!strcasecmp (property, "AbsoluteHeight") || !strcasecmp (property, "AbsY")) - { + if (!strcasecmp(property, "AbsoluteHeight") || !strcasecmp(property, "AbsY")) { fCurrentProperty = PROP_ABSY; return this; } - if (!strcasecmp (property, "Corners")) - { + if (!strcasecmp(property, "Corners")) { fCurrentProperty = PROP_CORNERS; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribRoundRect::MessageReceived (BMessage *msg) +void +AttribRoundRect::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_PENSIZE: // float, 0 .. 50 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_PENSIZE: // float, 0 .. 50 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 50) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 50) { fPenSize = value; - lSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + lSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_RELX: // float, 0 .. 0.5 + case PROP_RELX: // float, 0 .. 0.5 { float value; - if (msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 0.5) - { + if (msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 0.5) { fRadXrel = value; - relx->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + relx->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_RELY: // float, 0 .. 0.5 + case PROP_RELY: // float, 0 .. 0.5 { float value; - if (msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 0.5) - { + if (msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 0.5) { fRadYrel = value; - rely->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + rely->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_ABSX: // float, 0 .. 200 + case PROP_ABSX: // float, 0 .. 200 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &value) == B_OK) // OK, we'll take int32's too. { - if (value >= 0 && value <= 200) - { + if (value >= 0 && value <= 200) { fRadXabs = value; - absx->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + absx->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_ABSY: // float, 0 .. 200 + case PROP_ABSY: // float, 0 .. 200 { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &value) == B_OK) // OK, we'll take int32's too. { - if (value >= 0 && value <= 200) - { + if (value >= 0 && value <= 200) { fRadYabs = value; - absy->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + absy->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_TYPE: // FilledOutline, Filled, Outline + case PROP_TYPE: // FilledOutline, Filled, Outline { - const char *name; + const char* name; int value = 0; - if (msg->FindString ("data", &name) == B_OK) - { - if (!strcasecmp (name, "FilledOutline")) - { - pT1->SetValue (B_CONTROL_ON); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_OFF); + if (msg->FindString("data", &name) == B_OK) { + if (!strcasecmp(name, "FilledOutline")) { + pT1->SetValue(B_CONTROL_ON); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_OFF); value = RRECT_OUTFILL; - } - else if (!strcasecmp (name, "Filled")) - { - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_ON); - pT3->SetValue (B_CONTROL_OFF); + } else if (!strcasecmp(name, "Filled")) { + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_ON); + pT3->SetValue(B_CONTROL_OFF); value = RRECT_FILL; - } - else if (!strcasecmp (name, "Outline")) - { - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_ON); + } else if (!strcasecmp(name, "Outline")) { + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_ON); value = RRECT_OUTLINE; } - if (value) - { + if (value) { fType = value; - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } - } - else - { + } else { // Error report... } } break; } - case PROP_CORNERS: // Relative, Absolute + case PROP_CORNERS: // Relative, Absolute { - const char *name; + const char* name; int value = 0; - if (msg->FindString ("data", &name) == B_OK) - { - if (!strcasecmp (name, "Relative")) - { - rel->SetValue (B_CONTROL_ON); + if (msg->FindString("data", &name) == B_OK) { + if (!strcasecmp(name, "Relative")) { + rel->SetValue(B_CONTROL_ON); value = RRECT_RELATIVE; - } - else if (!strcasecmp (name, "Absolute")) - { - abs->SetValue (B_CONTROL_ON); + } else if (!strcasecmp(name, "Absolute")) { + abs->SetValue(B_CONTROL_ON); value = RRECT_ABSOLUTE; } - if (value) - { + if (value) { fType = value; - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } - } - else - { + } else { // Error report... } } } - fCurrentProperty = 0; - break; + fCurrentProperty = 0; + break; } - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'ALpc': - fPenSize = msg->FindFloat ("value"); + fPenSize = msg->FindFloat("value"); break; case 'pvT1': fType = RRECT_OUTFILL; - pT1->SetValue (B_CONTROL_ON); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_OFF); + pT1->SetValue(B_CONTROL_ON); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_OFF); break; case 'pvT2': fType = RRECT_FILL; - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_ON); - pT3->SetValue (B_CONTROL_OFF); + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_ON); + pT3->SetValue(B_CONTROL_OFF); break; case 'pvT3': fType = RRECT_OUTLINE; - pT1->SetValue (B_CONTROL_OFF); - pT2->SetValue (B_CONTROL_OFF); - pT3->SetValue (B_CONTROL_ON); + pT1->SetValue(B_CONTROL_OFF); + pT2->SetValue(B_CONTROL_OFF); + pT3->SetValue(B_CONTROL_ON); break; case 'RRRx': - fRadXrel = msg->FindFloat ("value"); + fRadXrel = msg->FindFloat("value"); break; case 'RRRy': - fRadYrel = msg->FindFloat ("value"); + fRadYrel = msg->FindFloat("value"); break; case 'RRAx': - fRadXabs = msg->FindFloat ("value"); + fRadXabs = msg->FindFloat("value"); break; case 'RRAy': - fRadYabs = msg->FindFloat ("value"); + fRadYabs = msg->FindFloat("value"); break; case 'RRsr': fRadType = RRECT_RELATIVE; @@ -434,7 +416,7 @@ void AttribRoundRect::MessageReceived (BMessage *msg) fRadType = RRECT_ABSOLUTE; break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AttribRoundRect.h b/source/AttribRoundRect.h index 5dd9a9b..bd59076 100644 --- a/source/AttribRoundRect.h +++ b/source/AttribRoundRect.h @@ -8,49 +8,58 @@ #include "Slider.h" #define RRECT_OUTLINE 1 -#define RRECT_FILL 2 +#define RRECT_FILL 2 #define RRECT_OUTFILL 3 #define RRECT_RELATIVE 1 #define RRECT_ABSOLUTE 2 -#define PROP_PENSIZE 1 -#define PROP_TYPE 2 -#define PROP_RELX 3 -#define PROP_RELY 4 -#define PROP_ABSX 5 -#define PROP_ABSY 6 -#define PROP_CORNERS 7 +#define PROP_PENSIZE 1 +#define PROP_TYPE 2 +#define PROP_RELX 3 +#define PROP_RELY 4 +#define PROP_ABSX 5 +#define PROP_ABSY 6 +#define PROP_CORNERS 7 class AttribRoundRect : public AttribView { -public: - AttribRoundRect (); -virtual ~AttribRoundRect (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -float getPenSize () { return fPenSize; }; -int getType () { return fType; }; -int getRadType () { return fRadType; }; -float getRadXabs () { return fRadXabs; }; -float getRadYabs () { return fRadYabs; }; -float getRadXrel () { return fRadXrel; }; -float getRadYrel () { return fRadYrel; }; - -private: -typedef AttribView inherited; -float fPenSize; -float fRadXabs; -float fRadYabs; -float fRadXrel; -float fRadYrel; -int fRadType; -int fType; -BPictureButton *pT1, *pT2, *pT3; -Slider *lSlid, *relx, *rely, *absx, *absy; -BRadioButton *rel, *abs; -int fCurrentProperty; + public: + AttribRoundRect(); + virtual ~AttribRoundRect(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + + float getPenSize() { return fPenSize; }; + + int getType() { return fType; }; + + int getRadType() { return fRadType; }; + + float getRadXabs() { return fRadXabs; }; + + float getRadYabs() { return fRadYabs; }; + + float getRadXrel() { return fRadXrel; }; + + float getRadYrel() { return fRadYrel; }; + + private: + typedef AttribView inherited; + float fPenSize; + float fRadXabs; + float fRadYabs; + float fRadXrel; + float fRadYrel; + int fRadType; + int fType; + BPictureButton *pT1, *pT2, *pT3; + Slider *lSlid, *relx, *rely, *absx, *absy; + BRadioButton *rel, *abs; + int fCurrentProperty; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribSelect.cpp b/source/AttribSelect.cpp index 47ec976..70a6fea 100644 --- a/source/AttribSelect.cpp +++ b/source/AttribSelect.cpp @@ -4,43 +4,43 @@ #include "Colors.h" #include "Settings.h" -static property_info prop_list[] = { - 0 -}; -AttribSelect::AttribSelect () -: AttribView (BRect (0, 0, 128, 40), lstring (21, "Select")) -{ - SetViewColor (LightGrey); - BStringView *sv = new BStringView (BRect (6, 6, 120, 26), "no controls", lstring (306, "No Parameters")); - AddChild (sv); -// Slider *pSlid = new Slider (BRect (8, 8, 120, 26), 46, "Pen Size", 0, 50, 1, new BMessage ('AFpc')); -// AddChild (pSlid); -} +static property_info prop_list[] = {0}; - -AttribSelect::~AttribSelect () +AttribSelect::AttribSelect() : AttribView(BRect(0, 0, 128, 40), lstring(21, "Select")) { + SetViewColor(LightGrey); + BStringView* sv = + new BStringView(BRect(6, 6, 120, 26), "no controls", lstring(306, "No Parameters")); + AddChild(sv); + // Slider *pSlid = new Slider (BRect (8, 8, 120, 26), 46, "Pen Size", 0, 50, 1, new BMessage + //('AFpc')); AddChild (pSlid); } -status_t AttribSelect::GetSupportedSuites (BMessage *message) +AttribSelect::~AttribSelect() {} + +status_t +AttribSelect::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso-Select"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso-Select"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -BHandler *AttribSelect::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribSelect::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribSelect::MessageReceived (BMessage *msg) +void +AttribSelect::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AttribSelect.h b/source/AttribSelect.h index 860a7f8..1274abf 100644 --- a/source/AttribSelect.h +++ b/source/AttribSelect.h @@ -6,15 +6,17 @@ class AttribSelect : public AttribView { -public: - AttribSelect (); -virtual ~AttribSelect (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); + public: + AttribSelect(); + virtual ~AttribSelect(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); -private: -typedef AttribView inherited; + private: + typedef AttribView inherited; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribSpraycan.cpp b/source/AttribSpraycan.cpp index dd9de81..71eb381 100644 --- a/source/AttribSpraycan.cpp +++ b/source/AttribSpraycan.cpp @@ -11,184 +11,174 @@ static property_info prop_list[] = { 0 }; -AttribSpraycan::AttribSpraycan () -: AttribView (BRect (0, 0, 164, 90), lstring (26, "Spraycan")) +AttribSpraycan::AttribSpraycan() : AttribView(BRect(0, 0, 164, 90), lstring(26, "Spraycan")) { - SetViewColor (LightGrey); - sSlid = new Slider (BRect (4, 4, 160, 22), 60, lstring (355, "Sigma"), 1, 25, 1, new BMessage ('ASsg')); - cSlid = new Slider (BRect (4, 26, 160, 44), 60, lstring (356, "Color Ratio"), 0, 1, 0.01, new BMessage ('AScr'), B_HORIZONTAL, 0, "%.2f"); - fSlid = new Slider (BRect (4, 48, 160, 64), 60, lstring (357, "Flow Rate"), 1, 20, 1, new BMessage ('ASfr')); - AddChild (sSlid); - AddChild (cSlid); - AddChild (fSlid); + SetViewColor(LightGrey); + sSlid = + new Slider(BRect(4, 4, 160, 22), 60, lstring(355, "Sigma"), 1, 25, 1, new BMessage('ASsg')); + cSlid = new Slider( + BRect(4, 26, 160, 44), 60, lstring(356, "Color Ratio"), 0, 1, 0.01, new BMessage('AScr'), + B_HORIZONTAL, 0, "%.2f" + ); + fSlid = new Slider( + BRect(4, 48, 160, 64), 60, lstring(357, "Flow Rate"), 1, 20, 1, new BMessage('ASfr') + ); + AddChild(sSlid); + AddChild(cSlid); + AddChild(fSlid); fSigma = 5; - sSlid->SetValue (5); - cSlid->SetValue (0); - fSlid->SetValue (10); - sL = new BCheckBox (BRect (4, 68, 162, 86), "sL", lstring (358, "Fade with Distance"), new BMessage ('ASfd')); - sL->SetValue (0); + sSlid->SetValue(5); + cSlid->SetValue(0); + fSlid->SetValue(10); + sL = new BCheckBox( + BRect(4, 68, 162, 86), "sL", lstring(358, "Fade with Distance"), new BMessage('ASfd') + ); + sL->SetValue(0); fLighten = false; - AddChild (sL); + AddChild(sL); fColorRatio = 0; fFlowRate = 5; fCurrentProperty = 0; } +AttribSpraycan::~AttribSpraycan() {} -AttribSpraycan::~AttribSpraycan () +status_t +AttribSpraycan::GetSupportedSuites(BMessage* message) { + message->AddString("suites", "suite/x-sum-becasso-Spray Can"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -status_t AttribSpraycan::GetSupportedSuites (BMessage *message) +BHandler* +AttribSpraycan::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - message->AddString ("suites", "suite/x-sum-becasso-Spray Can"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); -} - -BHandler *AttribSpraycan::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) -{ - if (!strcasecmp (property, "Sigma")) - { + if (!strcasecmp(property, "Sigma")) { fCurrentProperty = PROP_SIGMA; return this; } - if (!strcasecmp (property, "Ratio") || !strcasecmp (property, "ColorRatio")) - { + if (!strcasecmp(property, "Ratio") || !strcasecmp(property, "ColorRatio")) { fCurrentProperty = PROP_RATIO; return this; } - if (!strcasecmp (property, "Rate") || !strcasecmp (property, "FlowRate")) - { + if (!strcasecmp(property, "Rate") || !strcasecmp(property, "FlowRate")) { fCurrentProperty = PROP_RATE; return this; } - if (!strcasecmp (property, "Fade")) - { + if (!strcasecmp(property, "Fade")) { fCurrentProperty = PROP_FADE; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribSpraycan::MessageReceived (BMessage *msg) +void +AttribSpraycan::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_SIGMA: // float, 1 .. 25 + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_SIGMA: // float, 1 .. 25 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 1 && value <= 25) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 1 && value <= 25) { fSigma = value; - sSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + sSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_RATE: // float, 1 .. 20 + case PROP_RATE: // float, 1 .. 20 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 1 && value <= 20) - { + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 1 && value <= 20) { fFlowRate = value; - fSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + fSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_RATIO: // float, 0 .. 1 + case PROP_RATIO: // float, 0 .. 1 { float value; - if (msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 1) - { + if (msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 1) { fColorRatio = value; - cSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + cSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_FADE: // boolean + case PROP_FADE: // boolean { bool value; - if (msg->FindBool ("data", &value) == B_OK) - { + if (msg->FindBool("data", &value) == B_OK) { fLighten = value; - sL->SetValue (value); + sL->SetValue(value); } } - fCurrentProperty = 0; - break; + fCurrentProperty = 0; + break; } - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } case 'ASsg': - fSigma = msg->FindFloat ("value"); + fSigma = msg->FindFloat("value"); break; case 'AScr': - fColorRatio = msg->FindFloat ("value"); + fColorRatio = msg->FindFloat("value"); break; case 'ASfr': - fFlowRate = msg->FindFloat ("value"); + fFlowRate = msg->FindFloat("value"); break; case 'ASfd': fLighten = sL->Value(); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AttribSpraycan.h b/source/AttribSpraycan.h index b102a0d..983588d 100644 --- a/source/AttribSpraycan.h +++ b/source/AttribSpraycan.h @@ -6,35 +6,41 @@ #include #include "Slider.h" -#define frand() ((double) rand() / ((double) RAND_MAX + 1)) +#define frand() ((double)rand() / ((double)RAND_MAX + 1)) -#define PROP_SIGMA 0 -#define PROP_RATIO 1 -#define PROP_RATE 2 -#define PROP_FADE 3 +#define PROP_SIGMA 0 +#define PROP_RATIO 1 +#define PROP_RATE 2 +#define PROP_FADE 3 class AttribSpraycan : public AttribView { -public: - AttribSpraycan (); -virtual ~AttribSpraycan (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -float getSigma () { return fSigma; }; -bool getLighten () { return fLighten; }; -float getColorRatio () { return fColorRatio; }; -float getFlowRate () { return fFlowRate; }; - -private: -typedef AttribView inherited; -float fSigma; -bool fLighten; -float fColorRatio; -float fFlowRate; -BCheckBox *sL; -Slider *cSlid, *sSlid, *fSlid; -int fCurrentProperty; + public: + AttribSpraycan(); + virtual ~AttribSpraycan(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + + float getSigma() { return fSigma; }; + + bool getLighten() { return fLighten; }; + + float getColorRatio() { return fColorRatio; }; + + float getFlowRate() { return fFlowRate; }; + + private: + typedef AttribView inherited; + float fSigma; + bool fLighten; + float fColorRatio; + float fFlowRate; + BCheckBox* sL; + Slider *cSlid, *sSlid, *fSlid; + int fCurrentProperty; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribText.cpp b/source/AttribText.cpp index cca851b..1417d1d 100644 --- a/source/AttribText.cpp +++ b/source/AttribText.cpp @@ -8,426 +8,398 @@ #include #include "Settings.h" -static property_info prop_list[] = { - {"Family", SET, DIRECT, "string: family_name"}, - {"Style", SET, DIRECT, "string: style_name"}, - {"PtSize|Size", SET, DIRECT, "float: 4 .. 144"}, - {"Shear", SET, DIRECT, "float: 45 .. 135"}, - {"Rotation", SET, DIRECT, "float: 0 .. 360"}, - {"AntiAliasing", SET, DIRECT, "bool: true, false"}, - {"Text", SET, DIRECT, "string: text"}, - 0 -}; +static property_info prop_list[] = {{"Family", SET, DIRECT, "string: family_name"}, + {"Style", SET, DIRECT, "string: style_name"}, + {"PtSize|Size", SET, DIRECT, "float: 4 .. 144"}, + {"Shear", SET, DIRECT, "float: 45 .. 135"}, + {"Rotation", SET, DIRECT, "float: 0 .. 360"}, + {"AntiAliasing", SET, DIRECT, "bool: true, false"}, + {"Text", SET, DIRECT, "string: text"}, + 0}; -AttribText::AttribText () -: AttribView (BRect (0, 0, 224, 208), lstring (25, "Text")) +AttribText::AttribText() : AttribView(BRect(0, 0, 224, 208), lstring(25, "Text")) { - SetViewColor (LightGrey); - fFont = BFont (be_plain_font); + SetViewColor(LightGrey); + fFont = BFont(be_plain_font); numFamilies = count_font_families(); families = new font_family[numFamilies]; font_family family; font_style style; uint32 flags; - for (int32 i = 0; i < numFamilies; i++) - { - if (get_font_family (i, &family, &flags) == B_OK) - { - strcpy (families[i], family); + for (int32 i = 0; i < numFamilies; i++) { + if (get_font_family(i, &family, &flags) == B_OK) { + strcpy(families[i], family); } } - get_font_family (2, &family, &flags); - numStyles = count_font_styles (family); + get_font_family(2, &family, &flags); + numStyles = count_font_styles(family); styles = new font_style[numStyles]; - for (int32 j = 0; j < numStyles; j++) - { - if (get_font_style (family, j, &style, &flags) == B_OK) - { - strcpy (styles[j], style); + for (int32 j = 0; j < numStyles; j++) { + if (get_font_style(family, j, &style, &flags) == B_OK) { + strcpy(styles[j], style); } } - fFamilyPU = new BPopUpMenu (""); + fFamilyPU = new BPopUpMenu(""); for (int32 i = 0; i < numFamilies; i++) - fFamilyPU->AddItem (new BMenuItem (families[i], new BMessage ('font'))); - fFamilyPU->ItemAt(2)->SetMarked (true); - fFamilyPU->SetTargetForItems (this); - fStylePU = new BPopUpMenu (""); + fFamilyPU->AddItem(new BMenuItem(families[i], new BMessage('font'))); + fFamilyPU->ItemAt(2)->SetMarked(true); + fFamilyPU->SetTargetForItems(this); + fStylePU = new BPopUpMenu(""); for (int32 j = 0; j < numStyles; j++) - fStylePU->AddItem (new BMenuItem (styles[j], new BMessage ('fchg'))); - fStylePU->ItemAt(0)->SetMarked (true); - fStylePU->SetTargetForItems (this); - BMenuField *dFamily = new BMenuField (BRect (4, 2, 220, 20), "dFamily", lstring (360, "Family: "), fFamilyPU); - dFamily->SetDivider (50); - BMenuField *dStyle = new BMenuField (BRect (4, 24, 220, 40), "dStyle", lstring (361, "Style: "), fStylePU); - dStyle->SetDivider (50); - AddChild (dFamily); - AddChild (dStyle); - szSlid = new Slider (BRect (7, 50, 220, 66), 66, lstring (362, "Pt Size:"), 4, 144, 1, new BMessage ('fcSz')); - shSlid = new Slider (BRect (7, 70, 220, 86), 66, lstring (363, "Shear:"), 45, 135, 1, new BMessage ('fcSh')); - rtSlid = new Slider (BRect (7, 90, 220, 106), 66, lstring (364, "Rotation:"), 0, 360, 1, new BMessage ('fcRt')); - szSlid->SetValue (12); - shSlid->SetValue (90); - AddChild (szSlid); - AddChild (shSlid); - AddChild (rtSlid); - aaCheck = new BCheckBox (BRect (7, 109, 216, 127), "anti-aliasing", lstring (365, "Anti Aliasing"), new BMessage ('fcAA')); - aaCheck->SetValue (1); - AddChild (aaCheck); - fFont.SetFamilyAndStyle (families[2], styles[0]); - fFont.SetSize (12); - fFont.SetShear (90); - fFont.SetSpacing (B_BITMAP_SPACING); - fFont.SetRotation (0); -// demo = new BStringView (BRect (8, 132, 176, 182), "demo", DEMO_TEXT); -// demo->SetFont (&fFont); -// demo->SetText (DEMO_TEXT); -// demo->SetViewColor (White); -// demo->SetLowColor (White); - fText = new BTextView (BRect (8, 132, 216 - B_V_SCROLL_BAR_WIDTH, 202 - B_H_SCROLL_BAR_HEIGHT), "text", BRect (0, 0, 1024, 1), &fFont, 0, B_FOLLOW_NONE, B_WILL_DRAW); - fText->SetWordWrap (false); - fText->MakeResizable (false); - fText->SetStylable (true); - fText->SetText (DEMO_TEXT); - BScrollView *demoBox = new BScrollView ("demoBox", fText, B_FOLLOW_NONE, 0, true, true); - AddChild (demoBox); + fStylePU->AddItem(new BMenuItem(styles[j], new BMessage('fchg'))); + fStylePU->ItemAt(0)->SetMarked(true); + fStylePU->SetTargetForItems(this); + BMenuField* dFamily = + new BMenuField(BRect(4, 2, 220, 20), "dFamily", lstring(360, "Family: "), fFamilyPU); + dFamily->SetDivider(50); + BMenuField* dStyle = + new BMenuField(BRect(4, 24, 220, 40), "dStyle", lstring(361, "Style: "), fStylePU); + dStyle->SetDivider(50); + AddChild(dFamily); + AddChild(dStyle); + szSlid = new Slider( + BRect(7, 50, 220, 66), 66, lstring(362, "Pt Size:"), 4, 144, 1, new BMessage('fcSz') + ); + shSlid = new Slider( + BRect(7, 70, 220, 86), 66, lstring(363, "Shear:"), 45, 135, 1, new BMessage('fcSh') + ); + rtSlid = new Slider( + BRect(7, 90, 220, 106), 66, lstring(364, "Rotation:"), 0, 360, 1, new BMessage('fcRt') + ); + szSlid->SetValue(12); + shSlid->SetValue(90); + AddChild(szSlid); + AddChild(shSlid); + AddChild(rtSlid); + aaCheck = new BCheckBox( + BRect(7, 109, 216, 127), "anti-aliasing", lstring(365, "Anti Aliasing"), + new BMessage('fcAA') + ); + aaCheck->SetValue(1); + AddChild(aaCheck); + fFont.SetFamilyAndStyle(families[2], styles[0]); + fFont.SetSize(12); + fFont.SetShear(90); + fFont.SetSpacing(B_BITMAP_SPACING); + fFont.SetRotation(0); + // demo = new BStringView (BRect (8, 132, 176, 182), "demo", DEMO_TEXT); + // demo->SetFont (&fFont); + // demo->SetText (DEMO_TEXT); + // demo->SetViewColor (White); + // demo->SetLowColor (White); + fText = new BTextView( + BRect(8, 132, 216 - B_V_SCROLL_BAR_WIDTH, 202 - B_H_SCROLL_BAR_HEIGHT), "text", + BRect(0, 0, 1024, 1), &fFont, 0, B_FOLLOW_NONE, B_WILL_DRAW + ); + fText->SetWordWrap(false); + fText->MakeResizable(false); + fText->SetStylable(true); + fText->SetText(DEMO_TEXT); + BScrollView* demoBox = new BScrollView("demoBox", fText, B_FOLLOW_NONE, 0, true, true); + AddChild(demoBox); fCurrentProperty = 0; } -AttribText::~AttribText () +AttribText::~AttribText() { - delete [] families; - delete [] styles; + delete[] families; + delete[] styles; } -void AttribText::AttachedToWindow () +void +AttribText::AttachedToWindow() { inherited::AttachedToWindow(); } -status_t AttribText::GetSupportedSuites (BMessage *message) +status_t +AttribText::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso-Text"); - BPropertyInfo info (prop_list); - message->AddFlat ("messages", &info); - return AttribView::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso-Text"); + BPropertyInfo info(prop_list); + message->AddFlat("messages", &info); + return AttribView::GetSupportedSuites(message); } -BHandler *AttribText::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribText::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - if (!strcasecmp (property, "Family")) - { + if (!strcasecmp(property, "Family")) { fCurrentProperty = PROP_FAMILY; return this; } - if (!strcasecmp (property, "Style")) - { + if (!strcasecmp(property, "Style")) { fCurrentProperty = PROP_STYLE; return this; } - if (!strcasecmp (property, "PtSize") || !strcasecmp (property, "Size")) - { + if (!strcasecmp(property, "PtSize") || !strcasecmp(property, "Size")) { fCurrentProperty = PROP_SIZE; return this; } - if (!strcasecmp (property, "Shear")) - { + if (!strcasecmp(property, "Shear")) { fCurrentProperty = PROP_SHEAR; return this; } - if (!strcasecmp (property, "Rotation")) - { + if (!strcasecmp(property, "Rotation")) { fCurrentProperty = PROP_ROTATION; return this; } - if (!strcasecmp (property, "AntiAliasing")) - { + if (!strcasecmp(property, "AntiAliasing")) { fCurrentProperty = PROP_ANTIALIAS; return this; } - if (!strcasecmp (property, "Text")) - { + if (!strcasecmp(property, "Text")) { fCurrentProperty = PROP_TEXT; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribText::MessageReceived (BMessage *msg) +void +AttribText::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { } fCurrentProperty = 0; - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_FAMILY: - { - const char *name; - if (msg->FindString ("data", &name) == B_OK) - { - BMenuItem *item = fFamilyPU->FindItem (name); - if (!item) // Courtesy to the user: Do a partial match. + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_FAMILY: { + const char* name; + if (msg->FindString("data", &name) == B_OK) { + BMenuItem* item = fFamilyPU->FindItem(name); + if (!item) // Courtesy to the user: Do a partial match. { - for (int32 i = fFamilyPU->CountItems() - 1; i >= 0; i--) - { - BMenuItem *thisone = fFamilyPU->ItemAt (i); - if (!strncasecmp (thisone->Label(), name, strlen (name))) - { + for (int32 i = fFamilyPU->CountItems() - 1; i >= 0; i--) { + BMenuItem* thisone = fFamilyPU->ItemAt(i); + if (!strncasecmp(thisone->Label(), name, strlen(name))) { item = thisone; } } } - if (item) - { - item->SetMarked (true); - BMessage font = BMessage ('font'); - MessageReceived (&font); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (item) { + item->SetMarked(true); + BMessage font = BMessage('font'); + MessageReceived(&font); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_STYLE: - { - const char *name; - if (msg->FindString ("data", &name) == B_OK) - { - BMenuItem *item = fStylePU->FindItem (name); - if (!item) // Courtesy to the user: Do a partial match. + case PROP_STYLE: { + const char* name; + if (msg->FindString("data", &name) == B_OK) { + BMenuItem* item = fStylePU->FindItem(name); + if (!item) // Courtesy to the user: Do a partial match. { - for (int32 i = fStylePU->CountItems() - 1; i >= 0; i--) - { - BMenuItem *thisone = fStylePU->ItemAt (i); - if (!strncasecmp (thisone->Label(), name, strlen (name))) - { + for (int32 i = fStylePU->CountItems() - 1; i >= 0; i--) { + BMenuItem* thisone = fStylePU->ItemAt(i); + if (!strncasecmp(thisone->Label(), name, strlen(name))) { item = thisone; } } } - if (item) - { - item->SetMarked (true); - BMessage font = BMessage ('fchg'); - MessageReceived (&font); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (item) { + item->SetMarked(true); + BMessage font = BMessage('fchg'); + MessageReceived(&font); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_SIZE: // float, 4 .. 144 + case PROP_SIZE: // float, 4 .. 144 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 4 && value <= 144) - { - fFont.SetSize (value); - fText->SetStylable (false); - fText->SetFontAndColor (&fFont); - fText->SetStylable (true); - szSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 4 && value <= 144) { + fFont.SetSize(value); + fText->SetStylable(false); + fText->SetFontAndColor(&fFont); + fText->SetStylable(true); + szSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_SHEAR: // float, 45 .. 135 + case PROP_SHEAR: // float, 45 .. 135 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 45 && value <= 135) - { - fFont.SetShear (value); - fText->SetStylable (false); - fText->SetFontAndColor (&fFont); - fText->SetStylable (true); - shSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 45 && value <= 135) { + fFont.SetShear(value); + fText->SetStylable(false); + fText->SetFontAndColor(&fFont); + fText->SetStylable(true); + shSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_ROTATION: // float, 0 .. 360 + case PROP_ROTATION: // float, 0 .. 360 { float value; int32 ivalue; bool floatvalid = false; - if (msg->FindInt32 ("data", &ivalue) == B_OK) // OK, we'll take int32's too. + if (msg->FindInt32("data", &ivalue) == B_OK) // OK, we'll take int32's too. { value = ivalue; floatvalid = true; } - if (floatvalid || msg->FindFloat ("data", &value) == B_OK) - { - if (value >= 0 && value <= 360) - { - fFont.SetRotation (value); - fText->SetStylable (false); - fText->SetFontAndColor (&fFont); - fText->SetStylable (true); - rtSlid->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (floatvalid || msg->FindFloat("data", &value) == B_OK) { + if (value >= 0 && value <= 360) { + fFont.SetRotation(value); + fText->SetStylable(false); + fText->SetFontAndColor(&fFont); + fText->SetStylable(true); + rtSlid->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } break; } - case PROP_ANTIALIAS: // boolean + case PROP_ANTIALIAS: // boolean { bool value; - if (msg->FindBool ("data", &value) == B_OK) - { - fFont.SetFlags (value ? ~B_DISABLE_ANTIALIASING : B_DISABLE_ANTIALIASING); - fText->SetStylable (false); - fText->SetFontAndColor (&fFont); - fText->SetStylable (true); - aaCheck->SetValue (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->FindBool("data", &value) == B_OK) { + fFont.SetFlags(value ? ~B_DISABLE_ANTIALIASING : B_DISABLE_ANTIALIASING); + fText->SetStylable(false); + fText->SetFontAndColor(&fFont); + fText->SetStylable(true); + aaCheck->SetValue(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } break; } - case PROP_TEXT: // string + case PROP_TEXT: // string { - const char *value; - if (msg->FindString ("data", &value) == B_OK) - { - fText->SetText (value); - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + const char* value; + if (msg->FindString("data", &value) == B_OK) { + fText->SetText(value); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } - fCurrentProperty = 0; - break; + fCurrentProperty = 0; + break; } - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } - case 'font': - { + case 'font': { font_family family; - strcpy (family, families[fFamilyPU->IndexOf (fFamilyPU->FindMarked())]); + strcpy(family, families[fFamilyPU->IndexOf(fFamilyPU->FindMarked())]); for (int32 j = numStyles; j > 0; j--) - fStylePU->RemoveItem (j - 1); - - delete [] styles; - numStyles = count_font_styles (family); + fStylePU->RemoveItem(j - 1); + + delete[] styles; + numStyles = count_font_styles(family); styles = new font_style[numStyles]; uint32 flags; - for (int32 j = 0; j < numStyles; j++) - { + for (int32 j = 0; j < numStyles; j++) { font_style style; - if (get_font_style (family, j, &style, &flags) == B_OK) - { - strcpy (styles[j], style); - fStylePU->AddItem (new BMenuItem (style, new BMessage ('fchg'))); + if (get_font_style(family, j, &style, &flags) == B_OK) { + strcpy(styles[j], style); + fStylePU->AddItem(new BMenuItem(style, new BMessage('fchg'))); } } - fStylePU->ItemAt(0)->SetMarked (true); - fFont.SetFamilyAndStyle (family, styles[0]); - fText->SetStylable (false); - fText->SetFontAndColor (&fFont); - fText->SetStylable (true); + fStylePU->ItemAt(0)->SetMarked(true); + fFont.SetFamilyAndStyle(family, styles[0]); + fText->SetStylable(false); + fText->SetFontAndColor(&fFont); + fText->SetStylable(true); break; } - case 'fchg': - { - int f = fFamilyPU->IndexOf (fFamilyPU->FindMarked()); - int s = fStylePU->IndexOf (fStylePU->FindMarked()); + case 'fchg': { + int f = fFamilyPU->IndexOf(fFamilyPU->FindMarked()); + int s = fStylePU->IndexOf(fStylePU->FindMarked()); // printf ("families[%d] = %s, styles[%d] = %s\n", f, families[f], s, styles[s]); - fFont.SetFamilyAndStyle (families[f], styles[s]); - fText->SetStylable (false); - fText->SetFontAndColor (&fFont); - fText->SetStylable (true); + fFont.SetFamilyAndStyle(families[f], styles[s]); + fText->SetStylable(false); + fText->SetFontAndColor(&fFont); + fText->SetStylable(true); break; } case 'fcSz': - fFont.SetSize (msg->FindFloat ("value")); - fText->SetFontAndColor (&fFont); - fText->SetStylable (false); - fText->SetFontAndColor (&fFont); - fText->SetStylable (true); + fFont.SetSize(msg->FindFloat("value")); + fText->SetFontAndColor(&fFont); + fText->SetStylable(false); + fText->SetFontAndColor(&fFont); + fText->SetStylable(true); break; case 'fcSh': - fFont.SetShear (msg->FindFloat ("value")); - fText->SetFontAndColor (&fFont); - fText->SetStylable (false); - fText->SetFontAndColor (&fFont); - fText->SetStylable (true); + fFont.SetShear(msg->FindFloat("value")); + fText->SetFontAndColor(&fFont); + fText->SetStylable(false); + fText->SetFontAndColor(&fFont); + fText->SetStylable(true); break; case 'fcRt': - fFont.SetRotation (msg->FindFloat ("value")); - fText->SetFontAndColor (&fFont); - fText->SetStylable (false); - fText->SetFontAndColor (&fFont); - fText->SetStylable (true); + fFont.SetRotation(msg->FindFloat("value")); + fText->SetFontAndColor(&fFont); + fText->SetStylable(false); + fText->SetFontAndColor(&fFont); + fText->SetStylable(true); break; case 'fcAA': - fFont.SetFlags (aaCheck->Value() ? ~B_DISABLE_ANTIALIASING : B_DISABLE_ANTIALIASING); - fText->SetFontAndColor (&fFont); - fText->SetStylable (false); - fText->SetFontAndColor (&fFont); - fText->SetStylable (true); + fFont.SetFlags(aaCheck->Value() ? ~B_DISABLE_ANTIALIASING : B_DISABLE_ANTIALIASING); + fText->SetFontAndColor(&fFont); + fText->SetStylable(false); + fText->SetFontAndColor(&fFont); + fText->SetStylable(true); break; default: // msg->PrintToStream(); - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/AttribText.h b/source/AttribText.h index 7818ea2..370efcb 100644 --- a/source/AttribText.h +++ b/source/AttribText.h @@ -11,39 +11,43 @@ #define DEMO_TEXT "Becasso" -#define PROP_FAMILY 0 -#define PROP_STYLE 1 -#define PROP_SIZE 2 -#define PROP_SHEAR 3 -#define PROP_ROTATION 4 -#define PROP_ANTIALIAS 5 -#define PROP_TEXT 6 +#define PROP_FAMILY 0 +#define PROP_STYLE 1 +#define PROP_SIZE 2 +#define PROP_SHEAR 3 +#define PROP_ROTATION 4 +#define PROP_ANTIALIAS 5 +#define PROP_TEXT 6 class AttribText : public AttribView { -public: - AttribText (); -virtual ~AttribText (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); -virtual void AttachedToWindow (); -BFont getFont () { return fFont; }; -const char *getText () { return fText->Text(); }; - -private: -typedef AttribView inherited; -BFont fFont; -font_family *families; -font_style *styles; -BPopUpMenu *fFamilyPU; -BPopUpMenu *fStylePU; -BTextView *fText; -BCheckBox *aaCheck; -int32 numStyles; -int32 numFamilies; -Slider *szSlid, *shSlid, *rtSlid; -int fCurrentProperty; + public: + AttribText(); + virtual ~AttribText(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + virtual void AttachedToWindow(); + + BFont getFont() { return fFont; }; + + const char* getText() { return fText->Text(); }; + + private: + typedef AttribView inherited; + BFont fFont; + font_family* families; + font_style* styles; + BPopUpMenu* fFamilyPU; + BPopUpMenu* fStylePU; + BTextView* fText; + BCheckBox* aaCheck; + int32 numStyles; + int32 numFamilies; + Slider *szSlid, *shSlid, *rtSlid; + int fCurrentProperty; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribView.cpp b/source/AttribView.cpp index a049b03..63aa301 100644 --- a/source/AttribView.cpp +++ b/source/AttribView.cpp @@ -1,23 +1,25 @@ #include "AttribView.h" #include "AttribWindow.h" -AttribView::AttribView (BRect frame, const char *title) -: BView (frame, title, B_FOLLOW_NONE, B_WILL_DRAW | B_NAVIGABLE) +AttribView::AttribView(BRect frame, const char* title) + : BView(frame, title, B_FOLLOW_NONE, B_WILL_DRAW | B_NAVIGABLE) { } -AttribView::~AttribView () -{ -} +AttribView::~AttribView() {} -void AttribView::MessageReceived (BMessage *message) +void +AttribView::MessageReceived(BMessage* message) { bool passed = true; - message->AddBool ("passed", passed); - inherited::MessageReceived (message); + message->AddBool("passed", passed); + inherited::MessageReceived(message); } -BHandler *AttribView::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribView::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } diff --git a/source/AttribView.h b/source/AttribView.h index f6b1eeb..842dff2 100644 --- a/source/AttribView.h +++ b/source/AttribView.h @@ -5,22 +5,39 @@ #include #include -#define GET_AND_SET {B_GET_PROPERTY, B_SET_PROPERTY, 0} -#define SET {B_SET_PROPERTY, 0} -#define GET {B_GET_PROPERTY, 0} -#define DIRECT_AND_INDEX {B_DIRECT_SPECIFIER, B_INDEX_SPECIFIER, 0} -#define DIRECT {B_DIRECT_SPECIFIER, 0} +#define GET_AND_SET \ + { \ + B_GET_PROPERTY, B_SET_PROPERTY, 0 \ + } +#define SET \ + { \ + B_SET_PROPERTY, 0 \ + } +#define GET \ + { \ + B_GET_PROPERTY, 0 \ + } +#define DIRECT_AND_INDEX \ + { \ + B_DIRECT_SPECIFIER, B_INDEX_SPECIFIER, 0 \ + } +#define DIRECT \ + { \ + B_DIRECT_SPECIFIER, 0 \ + } class AttribView : public BView { -public: - AttribView (BRect frame, const char *title); -virtual ~AttribView (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); + public: + AttribView(BRect frame, const char* title); + virtual ~AttribView(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); -private: -typedef BView inherited; + private: + typedef BView inherited; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/AttribWindow.cpp b/source/AttribWindow.cpp index 829f09c..c9d4ced 100644 --- a/source/AttribWindow.cpp +++ b/source/AttribWindow.cpp @@ -5,173 +5,173 @@ #include "Colors.h" #include "Settings.h" -AttribWindow::AttribWindow (BRect frame, const char *title) -: BWindow (frame, title, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK) +AttribWindow::AttribWindow(BRect frame, const char* title) + : BWindow( + frame, title, B_TITLED_WINDOW, + B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK + ) { current = -1; numviews = 0; - strcpy (orig_title, title); + strcpy(orig_title, title); } -AttribWindow::~AttribWindow () +AttribWindow::~AttribWindow() { - if (current != -1) - { -// printf ("Removing view %d from Window %s... ", current, Name()); fflush (stdout); + if (current != -1) { + // printf ("Removing view %d from Window %s... ", current, Name()); fflush (stdout); view_n_icon c = views[current]; - RemoveChild (c.view); + RemoveChild(c.view); if (c.icon) - RemoveChild (c.icon); -// printf ("Removed.\n"); + RemoveChild(c.icon); + // printf ("Removed.\n"); } - for (int i = 0; i < numviews; i++) - { -// printf ("deleting view %d: %s... ", i, views[i]->Name()); fflush (stdout); -// snooze (20000); + for (int i = 0; i < numviews; i++) { + // printf ("deleting view %d: %s... ", i, views[i]->Name()); fflush (stdout); + // snooze (20000); view_n_icon c = views[i]; delete c.view; delete c.icon; -// printf ("Deleted.\n"); + // printf ("Deleted.\n"); } } -void AttribWindow::Quit () +void +AttribWindow::Quit() { BPoint origin = Frame().LeftTop(); - if (!strcmp (orig_title, "Mode")) - set_window_origin (numModeWindow, IsHidden() ? InvalidPoint : origin); - else if (!strcmp (orig_title, "Attribs")) - set_window_origin (numAttribWindow, IsHidden() ? InvalidPoint : origin); + if (!strcmp(orig_title, "Mode")) + set_window_origin(numModeWindow, IsHidden() ? InvalidPoint : origin); + else if (!strcmp(orig_title, "Attribs")) + set_window_origin(numAttribWindow, IsHidden() ? InvalidPoint : origin); inherited::Quit(); } -int AttribWindow::AddView (AttribView *view, BBitmap *icon) +int +AttribWindow::AddView(AttribView* view, BBitmap* icon) { view_n_icon entry; entry.view = view; entry.icon = 0; - if (icon) - { - view->MoveBy (40, 0); - BitmapView *iview = new BitmapView (BRect (0, 0, 39, view->Bounds().Height()), "icon", icon, B_OP_OVER, false); - iview->SetViewColor (DarkGrey); - iview->SetPosition (BPoint (4, 8)); + if (icon) { + view->MoveBy(40, 0); + BitmapView* iview = new BitmapView( + BRect(0, 0, 39, view->Bounds().Height()), "icon", icon, B_OP_OVER, false + ); + iview->SetViewColor(DarkGrey); + iview->SetPosition(BPoint(4, 8)); entry.icon = iview; } views[numviews] = entry; return (numviews++); } -void AttribWindow::RaiseView (int index) +void +AttribWindow::RaiseView(int index) { Lock(); - if (current != -1) - { - RemoveChild (views[current].view); + if (current != -1) { + RemoveChild(views[current].view); if (views[current].icon) - RemoveChild (views[current].icon); + RemoveChild(views[current].icon); } view_n_icon c = views[index]; - AddChild (c.view); + AddChild(c.view); if (c.icon) - AddChild (c.icon); + AddChild(c.icon); current = index; - ResizeTo (c.view->Bounds().Width() + (c.icon ? 40 : 0), views[index].view->Bounds().Height()); - SetTitle (c.view->Name()); + ResizeTo(c.view->Bounds().Width() + (c.icon ? 40 : 0), views[index].view->Bounds().Height()); + SetTitle(c.view->Name()); Unlock(); } -bool AttribWindow::QuitRequested () +bool +AttribWindow::QuitRequested() { Hide(); return false; } -void AttribWindow::Show () +void +AttribWindow::Show() { inherited::Show(); } -void AttribWindow::Hide () +void +AttribWindow::Hide() { inherited::Hide(); } -BHandler *AttribWindow::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +AttribWindow::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { -// printf ("\nAttribWindow::ResolveSpecifier(): message:\n"); -// message->PrintToStream(); -// printf ("specifier:\n"); -// specifier->PrintToStream(); - - const char *name; - if (!strcasecmp (property, "Tool") || !strcasecmp (property, "Mode")) - { - if (specifier->FindString ("name", &name) != B_OK) - { + // printf ("\nAttribWindow::ResolveSpecifier(): message:\n"); + // message->PrintToStream(); + // printf ("specifier:\n"); + // specifier->PrintToStream(); + + const char* name; + if (!strcasecmp(property, "Tool") || !strcasecmp(property, "Mode")) { + if (specifier->FindString("name", &name) != B_OK) { int32 index; - if (specifier->FindInt32 ("index", &index) == B_OK) - { - if (!strcasecmp (property, "Tool")) - { - // extern const int32 NumTools; - extern const char *ToolSpecifiers[]; - if (index >= 0 && index <= NumTools) - { + if (specifier->FindInt32("index", &index) == B_OK) { + if (!strcasecmp(property, "Tool")) { + // extern const int32 NumTools; + extern const char* ToolSpecifiers[]; + if (index >= 0 && index <= NumTools) { name = ToolSpecifiers[index]; - } - else - return inherited::ResolveSpecifier (message, index, specifier, command, property); - } - else if (!strcasecmp (property, "Mode")) - { - // extern const int32 NumModes; - extern const char *ModeSpecifiers[]; - if (index >= 0 && index <= NumModes) - { + } else + return inherited::ResolveSpecifier( + message, index, specifier, command, property + ); + } else if (!strcasecmp(property, "Mode")) { + // extern const int32 NumModes; + extern const char* ModeSpecifiers[]; + if (index >= 0 && index <= NumModes) { name = ModeSpecifiers[index]; - } - else - return inherited::ResolveSpecifier (message, index, specifier, command, property); + } else + return inherited::ResolveSpecifier( + message, index, specifier, command, property + ); } - } - else // Name nor index?! - return inherited::ResolveSpecifier (message, index, specifier, command, property); + } else // Name nor index?! + return inherited::ResolveSpecifier(message, index, specifier, command, property); } - } - else // This must be a "normal" Be scripting call - return inherited::ResolveSpecifier (message, index, specifier, command, property); - + } else // This must be a "normal" Be scripting call + return inherited::ResolveSpecifier(message, index, specifier, command, property); + message->PopSpecifier(); int32 i; -// printf ("name = %s\n", name); - for (i = 0; i < numviews; i++) - { -// printf ("views[%ld].view->Name() = %s\n", i, views[i].view->Name()); - if (!strcasecmp (views[i].view->Name(), name)) - { - RaiseView (i); + // printf ("name = %s\n", name); + for (i = 0; i < numviews; i++) { + // printf ("views[%ld].view->Name() = %s\n", i, views[i].view->Name()); + if (!strcasecmp(views[i].view->Name(), name)) { + RaiseView(i); return views[i].view; } } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void AttribWindow::MessageReceived (BMessage *msg) +void +AttribWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { default: - if (!msg->HasBool ("passed")) - views[current].view->MessageReceived (msg); + if (!msg->HasBool("passed")) + views[current].view->MessageReceived(msg); // Commenting this out fixes the TAB key bug... I'm expecting some // unwanted side effects but at least this doesn't crash anymore... // UPDATE: The unwanted side effects have been spotted: Popup menus // didn't work anymore. - + else - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } diff --git a/source/AttribWindow.h b/source/AttribWindow.h index bc45b9e..736268f 100644 --- a/source/AttribWindow.h +++ b/source/AttribWindow.h @@ -10,31 +10,35 @@ typedef struct { - AttribView *view; - BitmapView *icon; + AttribView* view; + BitmapView* icon; } view_n_icon; class AttribWindow : public BWindow { -public: - AttribWindow (BRect frame, const char *title); -virtual ~AttribWindow (); -virtual void MessageReceived (BMessage *msg); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual bool QuitRequested (); -virtual int AddView (AttribView *view, BBitmap *icon = 0); -virtual int Current () { return (current); }; -virtual void RaiseView (int index); -virtual void Show (); -virtual void Hide (); -virtual void Quit (); - -private: -typedef BWindow inherited; -view_n_icon views[MAX_VIEWS]; -int current; -int numviews; -char orig_title[16]; + public: + AttribWindow(BRect frame, const char* title); + virtual ~AttribWindow(); + virtual void MessageReceived(BMessage* msg); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual bool QuitRequested(); + virtual int AddView(AttribView* view, BBitmap* icon = 0); + + virtual int Current() { return (current); }; + + virtual void RaiseView(int index); + virtual void Show(); + virtual void Hide(); + virtual void Quit(); + + private: + typedef BWindow inherited; + view_n_icon views[MAX_VIEWS]; + int current; + int numviews; + char orig_title[16]; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/BBP.h b/source/BBP.h index cb0daae..19403e8 100644 --- a/source/BBP.h +++ b/source/BBP.h @@ -8,27 +8,27 @@ // reply message will contain the entry_ref to a saved graphic file. -const int32 BBP_OPEN_BBITMAP='BPob'; // External App -> BBitmap Editor App +const int32 BBP_OPEN_BBITMAP = 'BPob'; // External App -> BBitmap Editor App // B_MESSENGER_TYPE "target" (the target to send the reply to) // B_MESSAGE_TYPE "BBitmap" (BBitmap archive) *or* // B_REF_TYPE "ref" (entry_ref to the graphic file) // B_FLOAT_TYPE "zoom" (optional zooming factor e.g. 2.0f means 200%) // B_STRING_TYPE "name" (optional bitmap name, which can go in the window title ) -const int32 BBP_REPLACE_BBITMAP='BPpb'; // External App -> BBitmap Editor App +const int32 BBP_REPLACE_BBITMAP = 'BPpb'; // External App -> BBitmap Editor App // B_MESSAGE_TYPE "BBitmap" (BBitmap archive) // B_FLOAT_TYPE "zoom" (optional zooming factor e.g. 2.0f means 200%) // B_STRING_TYPE "name" (optional bitmap name, which can go in the window title ) -const int32 BBP_BBITMAP_OPENED='BPbo'; // BBitmap Editor App -> External Messenger +const int32 BBP_BBITMAP_OPENED = 'BPbo'; // BBitmap Editor App -> External Messenger // B_MESSENGER_TYPE "target" (the editor window messenger) -const int32 BBP_SEND_BBITMAP='BPsb'; // BBitmap Editor Window -> External Messenger +const int32 BBP_SEND_BBITMAP = 'BPsb'; // BBitmap Editor Window -> External Messenger // B_MESSAGE_TYPE "BBitmap" (edited BBitmap archive) *or* // B_REF_TYPE "ref" (edited graphic file). -const int32 BBP_BBITMAP_CLOSED='BPbc'; // BBitmap Editor Window -> External Messenger +const int32 BBP_BBITMAP_CLOSED = 'BPbc'; // BBitmap Editor Window -> External Messenger -const int32 BBP_REQUEST_BBITMAP='BPrb'; // External Messenger -> BBitmap Editor Window +const int32 BBP_REQUEST_BBITMAP = 'BPrb'; // External Messenger -> BBitmap Editor Window -const int32 BBP_NO_WINDOWS='BPnw'; // Becasso -> External Messenger \ No newline at end of file +const int32 BBP_NO_WINDOWS = 'BPnw'; // Becasso -> External Messenger \ No newline at end of file diff --git a/source/BGView.cpp b/source/BGView.cpp index 7aa0293..a52a1d2 100644 --- a/source/BGView.cpp +++ b/source/BGView.cpp @@ -3,83 +3,78 @@ #include #include -BGView::BGView (BRect frame, const char *name, uint32 resizeMask, uint32 flags) -: BView (frame, name, resizeMask, flags) +BGView::BGView(BRect frame, const char* name, uint32 resizeMask, uint32 flags) + : BView(frame, name, resizeMask, flags) { fFrame = frame; - fFrame.OffsetTo (0, 0); - SetViewColor (B_TRANSPARENT_32_BIT); + fFrame.OffsetTo(0, 0); + SetViewColor(B_TRANSPARENT_32_BIT); fScale = 1; } -BGView::~BGView () -{ -} +BGView::~BGView() {} -void BGView::Draw (BRect update) +void +BGView::Draw(BRect update) { - BView *canvas = FindView ("Canvas"); - if (canvas) - { + BView* canvas = FindView("Canvas"); + if (canvas) { BRect cFrame = canvas->Frame(); - BRegion upd (update); - upd.Exclude (cFrame); - SetHighColor (DarkGrey); - FillRegion (&upd); + BRegion upd(update); + upd.Exclude(cFrame); + SetHighColor(DarkGrey); + FillRegion(&upd); } - BView::Draw (update); + BView::Draw(update); } -void BGView::MouseMoved (BPoint point, uint32 transit, const BMessage *msg) +void +BGView::MouseMoved(BPoint point, uint32 transit, const BMessage* msg) { - BView *canvas = FindView ("Canvas"); - if (canvas) - { - BPoint mp = BPoint (point.x - canvas->Frame().left, - point.y - canvas->Frame().top); - canvas->MouseMoved (mp, B_OUTSIDE_VIEW, msg); + BView* canvas = FindView("Canvas"); + if (canvas) { + BPoint mp = BPoint(point.x - canvas->Frame().left, point.y - canvas->Frame().top); + canvas->MouseMoved(mp, B_OUTSIDE_VIEW, msg); } - BView::MouseMoved (point, transit, msg); + BView::MouseMoved(point, transit, msg); } -void BGView::MouseDown (BPoint point) +void +BGView::MouseDown(BPoint point) { - BView *canvas = FindView ("Canvas"); - if (canvas) - { - BPoint mp = BPoint (point.x - canvas->Frame().left, - point.y - canvas->Frame().top); - canvas->MouseDown (mp); + BView* canvas = FindView("Canvas"); + if (canvas) { + BPoint mp = BPoint(point.x - canvas->Frame().left, point.y - canvas->Frame().top); + canvas->MouseDown(mp); } - BView::MouseDown (point); + BView::MouseDown(point); } -void BGView::MouseUp (BPoint point) +void +BGView::MouseUp(BPoint point) { - BView *canvas = FindView ("Canvas"); - if (canvas) - { - BPoint mp = BPoint (point.x - canvas->Frame().left, - point.y - canvas->Frame().top); - canvas->MouseUp (mp); + BView* canvas = FindView("Canvas"); + if (canvas) { + BPoint mp = BPoint(point.x - canvas->Frame().left, point.y - canvas->Frame().top); + canvas->MouseUp(mp); } - BView::MouseUp (point); + BView::MouseUp(point); } -void BGView::ScrollTo (BPoint where) +void +BGView::ScrollTo(BPoint where) { float x = where.x; float y = where.y; float hmin, hmax, vmin, vmax; - BScrollBar *h = ScrollBar (B_HORIZONTAL); - BScrollBar *v = ScrollBar (B_VERTICAL); - if (!h || !v) - { - fprintf (stderr, "BGView::ScrollTo (x, y): no BScrollBars\n"); + BScrollBar* h = ScrollBar(B_HORIZONTAL); + BScrollBar* v = ScrollBar(B_VERTICAL); + if (!h || !v) { + fprintf(stderr, "BGView::ScrollTo (x, y): no BScrollBars\n"); return; } - h->GetRange (&hmin, &hmax); - v->GetRange (&vmin, &vmax); + h->GetRange(&hmin, &hmax); + v->GetRange(&vmin, &vmax); if (x < hmin) x = hmin; if (x > hmax) @@ -88,53 +83,55 @@ void BGView::ScrollTo (BPoint where) y = vmin; if (y > vmax) y = vmax; - BView::ScrollTo (BPoint (x, y)); + BView::ScrollTo(BPoint(x, y)); } -void BGView::FrameResized (float width, float height) +void +BGView::FrameResized(float width, float height) { - BView *canvas = FindView ("Canvas"); + BView* canvas = FindView("Canvas"); BRect cFrame; - if (canvas) - { + if (canvas) { cFrame = canvas->Frame(); float cw = canvas->Bounds().Width(); float ch = canvas->Bounds().Height(); if (cw < Bounds().Width() && ch < Bounds().Height()) - canvas->MoveTo ((width - cw)/2, (height - ch)/2); + canvas->MoveTo((width - cw) / 2, (height - ch) / 2); else if (cw < Bounds().Width()) - canvas->MoveTo ((width - cw)/2, min_c (0, cFrame.top)); + canvas->MoveTo((width - cw) / 2, min_c(0, cFrame.top)); else if (ch < Bounds().Height()) - canvas->MoveTo (min_c (0, cFrame.left), (height - ch)/2); + canvas->MoveTo(min_c(0, cFrame.left), (height - ch) / 2); else - canvas->MoveTo (min_c (0, cFrame.left), min_c (0, cFrame.top)); + canvas->MoveTo(min_c(0, cFrame.left), min_c(0, cFrame.top)); cFrame = canvas->Frame(); } float hmin, hmax, vmin, vmax; - BScrollBar *h = ScrollBar (B_HORIZONTAL); - BScrollBar *v = ScrollBar (B_VERTICAL); - h->GetRange (&hmin, &hmax); - v->GetRange (&vmin, &vmax); -// printf ("vrange = %f\n", fFrame.Height()*fScale - height); - h->SetRange (hmin, max_c (0, fFrame.Width()*fScale - width)); - v->SetRange (vmin, max_c (0, fFrame.Height()*fScale - height)); - h->SetProportion (min_c (1, width/fScale/fFrame.Width())); - v->SetProportion (min_c (1, height/fScale/fFrame.Height())); - h->SetSteps (1, Bounds().Width()); - v->SetSteps (1, Bounds().Height()); - h->SetValue (fFrame.left*fScale - cFrame.left); - v->SetValue (fFrame.top*fScale - cFrame.top); + BScrollBar* h = ScrollBar(B_HORIZONTAL); + BScrollBar* v = ScrollBar(B_VERTICAL); + h->GetRange(&hmin, &hmax); + v->GetRange(&vmin, &vmax); + // printf ("vrange = %f\n", fFrame.Height()*fScale - height); + h->SetRange(hmin, max_c(0, fFrame.Width() * fScale - width)); + v->SetRange(vmin, max_c(0, fFrame.Height() * fScale - height)); + h->SetProportion(min_c(1, width / fScale / fFrame.Width())); + v->SetProportion(min_c(1, height / fScale / fFrame.Height())); + h->SetSteps(1, Bounds().Width()); + v->SetSteps(1, Bounds().Height()); + h->SetValue(fFrame.left * fScale - cFrame.left); + v->SetValue(fFrame.top * fScale - cFrame.top); } -void BGView::setScale (float s) +void +BGView::setScale(float s) { fScale = s; - FrameResized (Bounds().Width(), Bounds().Height()); + FrameResized(Bounds().Width(), Bounds().Height()); Invalidate(); } -void BGView::setFrame (BRect frame) +void +BGView::setFrame(BRect frame) { fFrame = frame; - FrameResized (frame.Width(), frame.Height()); + FrameResized(frame.Width(), frame.Height()); } diff --git a/source/BGView.h b/source/BGView.h index b5da931..c6fe94d 100644 --- a/source/BGView.h +++ b/source/BGView.h @@ -6,24 +6,27 @@ class BGView : public BView { -public: - BGView (BRect frame, const char *name, uint32 resizeMask, uint32 flags); -virtual ~BGView (); -virtual void FrameResized (float width, float height); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *msg); -virtual void MouseDown (BPoint point); -virtual void MouseUp (BPoint point); -virtual void Draw (BRect update); -virtual void ScrollTo (BPoint where); -void setScale (float s); -float getScale () { return fScale; }; -void setFrame (BRect frame); -BRect getFrame () { return fFrame; }; + public: + BGView(BRect frame, const char* name, uint32 resizeMask, uint32 flags); + virtual ~BGView(); + virtual void FrameResized(float width, float height); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg); + virtual void MouseDown(BPoint point); + virtual void MouseUp(BPoint point); + virtual void Draw(BRect update); + virtual void ScrollTo(BPoint where); + void setScale(float s); -private: -typedef BView inherited; -float fScale; -BRect fFrame; + float getScale() { return fScale; }; + + void setFrame(BRect frame); + + BRect getFrame() { return fFrame; }; + + private: + typedef BView inherited; + float fScale; + BRect fFrame; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/BeDSC.h b/source/BeDSC.h index 2c17cf1..66c3ff0 100644 --- a/source/BeDSC.h +++ b/source/BeDSC.h @@ -3,59 +3,54 @@ /* dc1000 0.5 (2000-07-02) Copyright (C) Fredrik Roubert */ #ifndef BEDSC_H -# define BEDSC_H +#define BEDSC_H -# include "dsc.h" +#include "dsc.h" -# include -# include -# include +#include +#include +#include class BeDSC { -private: + private: + dsc_t* dsc; + dsc_error open_error; - dsc_t *dsc; - dsc_error open_error; - - -public: + public: BeDSC() { dsc = 0; open_error.lerror = 0; } - - inline status_t - Open(const char *pathname, data_rate speed) + inline status_t Open(const char* pathname, data_rate speed) { - speed_t termios_speed; - - switch (speed) - { - case B_9600_BPS: - termios_speed = B9600; - break; - - case B_19200_BPS: - termios_speed = B19200; - break; - - case B_38400_BPS: - termios_speed = B38400; - break; - - case B_57600_BPS: - termios_speed = B57600; - break; - - default: - open_error.lerror = EDSCBPSRNG; - /* bps out of range */ - return B_ERROR; + speed_t termios_speed; + + switch (speed) { + case B_9600_BPS: + termios_speed = B9600; + break; + + case B_19200_BPS: + termios_speed = B19200; + break; + + case B_38400_BPS: + termios_speed = B38400; + break; + + case B_57600_BPS: + termios_speed = B57600; + break; + + default: + open_error.lerror = EDSCBPSRNG; + /* bps out of range */ + return B_ERROR; } dsc = dsc_open(pathname, termios_speed, &open_error); @@ -63,9 +58,7 @@ class BeDSC return dsc == NULL ? B_ERROR : B_OK; } - - inline status_t - Close(void) + inline status_t Close(void) { if (dsc) return dsc_close(dsc) == -1 ? B_ERROR : B_OK; @@ -73,63 +66,27 @@ class BeDSC return B_OK; } + inline int GetIndex(dsc_quality_t* buf) { return dsc_getindex(dsc, buf); } - inline int - GetIndex(dsc_quality_t *buf) - { - return dsc_getindex(dsc, buf); - } - + inline status_t Preview(int index) { return dsc_preview(dsc, index) == -1 ? B_ERROR : B_OK; } - inline status_t - Preview(int index) - { - return dsc_preview(dsc, index) == -1 ? B_ERROR : B_OK; - } + inline status_t Delete(int index) { return dsc_delete(dsc, index) == -1 ? B_ERROR : B_OK; } + inline ssize_t RequestImage(int index) { return dsc_requestimage(dsc, index); } - inline status_t - Delete(int index) - { - return dsc_delete(dsc, index) == -1 ? B_ERROR : B_OK; - } - - - inline ssize_t - RequestImage(int index) - { - return dsc_requestimage(dsc, index); - } - - - inline ssize_t - ReadImageBlock(int block, void *buf) + inline ssize_t ReadImageBlock(int block, void* buf) { return dsc_readimageblock(dsc, block, buf); } - - inline const dsc_error * - Error(void) + inline const dsc_error* Error(void) { return open_error.lerror == 0 ? &dsc->lasterror : &open_error; } + inline const char* ErrorString(void) { return dsc_strerror(Error()); } - inline const char * - ErrorString(void) - { - return dsc_strerror(Error()); - } - - - inline static const char * - ErrorString(dsc_error *lasterror) - { - return dsc_strerror(lasterror); - } - + inline static const char* ErrorString(dsc_error* lasterror) { return dsc_strerror(lasterror); } }; #endif - diff --git a/source/Becasso.cpp b/source/Becasso.cpp index 1fb1a44..611fccc 100644 --- a/source/Becasso.cpp +++ b/source/Becasso.cpp @@ -1,6 +1,6 @@ #include -#if defined (DATATYPES) -# include +#if defined(DATATYPES) +#include #endif #include #include @@ -30,10 +30,10 @@ #include "DragWindow.h" #include "BBP.h" #include "Position.h" -#if defined (EASTER_EGG_SFX) -# include "sfx.h" +#if defined(EASTER_EGG_SFX) +#include "sfx.h" #endif -#include "PicMenuButton.h" // for the scripting +#include "PicMenuButton.h" // for the scripting #include "ColorMenuButton.h" #include "Properties.h" #include "debug.h" @@ -50,158 +50,143 @@ #define SHOW_EXTRA_COLOR_INFO 0 bool DataTypes; -MainWindow *mainWindow; -ThumbnailFilePanel *openPanel; +MainWindow* mainWindow; +ThumbnailFilePanel* openPanel; entry_ref gSaveRef; -BMessage *printSetup; +BMessage* printSetup; int newnum; -BBitmap *clip; +BBitmap* clip; long pasteX, pasteY; long fPasteX, fPasteY; bool inPaste, inDrag; -const char *Version = "2.0"; -unsigned char **RGBColors; +const char* Version = "2.0"; +unsigned char** RGBColors; int32 NumColors; -BList *AddOns; -Tablet *wacom; +BList* AddOns; +Tablet* wacom; port_id position_port; -BLocker *clipLock; -#if defined (EASTER_EGG_SFX) -EffectsPlayer *easterEgg; -SoundEffect8_11 *fxTear; +BLocker* clipLock; +#if defined(EASTER_EGG_SFX) +EffectsPlayer* easterEgg; +SoundEffect8_11* fxTear; #endif int32 def_out_type; translator_id def_out_translator; //__declspec (dllexport) const int32 NumTools = 13; //__declspec (dllexport) const int32 NumModes = 2; -const char *ModeSpecifiers[NumModes] = { "Draw", "Select" }; -const char *ToolSpecifiers[NumTools] = { "Brush", "Eraser", "Fill", "Text", "Spray Can", "Clone", "Freehand", "Lines", "Free Shape", "Polygons", "Rectangles", "Ovals", "Circles", "Ellipses" }; - -uchar cross[3][68] ={{ 16, // Size - 1, // Bit depth - 7, 7, // hot spot - 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, // Image - 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7C, 0x7C, - 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, - 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, // Mask - 0x03, 0x80, 0x03, 0x80, 0xFC, 0x7E, 0xFC, 0x7E, - 0xFC, 0x7E, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, - 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00 }, - { 16, - 1, - 7, 7, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x40, - 0x20, 0x40, 0x18, 0x80, 0x04, 0x00, 0x00, 0x00, - 0x00, 0x40, 0x02, 0x30, 0x04, 0x08, 0x04, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x70, 0x00, 0xF0, 0x70, 0xF0, - 0x7D, 0xE0, 0x7F, 0xE0, 0x3F, 0xC0, 0x0E, 0x70, - 0x07, 0xF8, 0x0F, 0xFc, 0x0F, 0x7C, 0x1E, 0x1C, - 0x1E, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00 }, - { 16, - 1, - 7, 7, - 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, - 0x04, 0x08, 0x02, 0x30, 0x00, 0x40, 0x00, 0x00, - 0x04, 0x00, 0x18, 0x00, 0x40, 0x80, 0x00, 0x40, - 0x00, 0x40, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x1C, 0x00, 0x1E, 0x00, 0x1E, 0x1C, - 0x0F, 0x7C, 0x0F, 0xFC, 0x07, 0xF8, 0x0E, 0xE0, - 0x3F, 0xC0, 0x7F, 0xE0, 0x7D, 0xE0, 0x70, 0xF0, - 0x00, 0xE0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00 } - }; - -uchar ccross[68] = { 16, // Size, - 1, // Bit depth, - 7, 7, // hot spot - 0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x09, 0x20, // Image - 0x11, 0x10, 0x01, 0x00, 0x20, 0x08, 0x7C, 0x7C, - 0x20, 0x08, 0x01, 0x00, 0x11, 0x10, 0x09, 0x20, - 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x1F, 0xF0, // Mask - 0x3B, 0xB8, 0x73, 0x9C, 0xFF, 0xFE, 0xFE, 0xFE, - 0xFF, 0xFE, 0x73, 0x9C, 0x3B, 0xB8, 0x1F, 0xF0, - 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x00, 0x00 }; - -uchar scross[68] = { 16, // Size - 1, // Bit depth - 7, 7, // hot spot - 0x00, 0x00, 0x03, 0x80, 0x02, 0x80, 0x02, 0x80, // Image - 0x02, 0x80, 0x01, 0x00, 0x78, 0x3C, 0x44, 0x44, - 0x78, 0x3C, 0x01, 0x00, 0x02, 0x80, 0x02, 0x80, - 0x02, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, // Mask - 0x07, 0xC0, 0xF8, 0x3E, 0xF8, 0x3E, 0xF8, 0x3E, - 0xF8, 0x3E, 0xF8, 0x3E, 0x07, 0xC0, 0x07, 0xC0, - 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, 0x00, 0x00 }; - -uchar hand[68] = { 16, // Size - 1, // Bit depth - 7, 7, // hot spot - 0x01, 0x80, 0x1A, 0x70, 0x26, 0x48, 0x26, 0x4A, // Image - 0x12, 0x4D, 0x12, 0x49, 0x68, 0x09, 0x98, 0x01, - 0x88, 0x02, 0x40, 0x02, 0x20, 0x02, 0x20, 0x04, - 0x10, 0x04, 0x08, 0x08, 0x04, 0x08, 0x04, 0x08, - 0x01, 0x80, 0x1B, 0xF0, 0x3F, 0xF8, 0x3F, 0xFA, // Mask - 0x1F, 0xFF, 0x1F, 0xFF, 0x6F, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFE, 0x7F, 0xFE, 0x3F, 0xFE, 0x3F, 0xFC, - 0x1F, 0xFC, 0x0F, 0xF8, 0x07, 0xF8, 0x07, 0xF8 }; - -uchar grab[68] = { 16, // Size - 1, // Bit depth - 7, 7, // hot spot - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Image - 0x0D, 0xB0, 0x12, 0x4C, 0x10, 0x0A, 0x08, 0x02, - 0x18, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x04, - 0x10, 0x04, 0x08, 0x08, 0x04, 0x08, 0x04, 0x08, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Mask - 0x0D, 0xB0, 0x1F, 0xFC, 0x1F, 0xFE, 0x0F, 0xFE, - 0x1F, 0xFE, 0x3F, 0xFE, 0x3F, 0xFE, 0x3F, 0xFC, - 0x1F, 0xFC, 0x0F, 0xF8, 0x07, 0xF8, 0x07, 0xF8 }; - -uchar picker[68] = { 16, // Size, - 1, // Bit depth, - 14, 1, // hot spot - 0x00, 0x00, 0x00, 0x0C, 0x00, 0x1E, 0x00, 0x2E, // Image - 0x01, 0xBC, 0x01, 0x38, 0x00, 0xE0, 0x01, 0x70, - 0x02, 0xB0, 0x05, 0x00, 0x0A, 0x00, 0x14, 0x00, - 0x28, 0x00, 0x50, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x00, 0x1E, 0x00, 0x3F, 0x00, 0x7F, 0x03, 0xFF, // Mask - 0x03, 0xFF, 0x03, 0xFE, 0x03, 0xFC, 0x07, 0xF8, - 0x0F, 0xF8, 0x1F, 0xF8, 0x3F, 0x80, 0x7F, 0x00, - 0xFE, 0x00, 0xFC, 0x00, 0xF8, 0x00, 0xF0, 0x00 }; - -uchar mover[68] = { 16, - 1, - 7, 7, - 0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x07, 0xC0, - 0x01, 0x00, 0x11, 0x10, 0x31, 0x18, 0x7F, 0xFC, - 0x31, 0x18, 0x11, 0x10, 0x01, 0x00, 0x07, 0xC0, - 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x80, 0x07, 0xC0, 0x07, 0xE0, 0x0F, 0xF0, - 0x3F, 0xF8, 0x7B, 0xBC, 0xFF, 0xFE, 0xFF, 0xFE, - 0xFF, 0xFE, 0x7B, 0xBC, 0x3F, 0xF8, 0x0F, 0xE0, - 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x00, 0x00 }; - -uchar rotator[68]= { 16, - 1, - 7, 7, - 0x00, 0x00, 0x03, 0x80, 0x0C, 0x60, 0x10, 0x10, - 0x20, 0x08, 0x20, 0x08, 0x41, 0x04, 0x42, 0x84, - 0x41, 0x04, 0x20, 0x00, 0x20, 0x00, 0x10, 0xF0, - 0x0C, 0x38, 0x03, 0xD0, 0x00, 0x10, 0x00, 0x00, - 0x07, 0xC0, 0x1F, 0xF0, 0x3F, 0xF8, 0x7E, 0xFC, - 0x78, 0x3C, 0xF3, 0x9E, 0xF7, 0xDE, 0xE7, 0xCE, - 0xF7, 0xCE, 0xF3, 0x8E, 0x79, 0xF8, 0x7F, 0xF8, - 0x3F, 0xF8, 0x1F, 0xF8, 0x07, 0xF8, 0x00, 0x38 }; - -#define GET_AND_SET {B_GET_PROPERTY, B_SET_PROPERTY, 0} -#define GET_SET_AND_PROP { B_GET_PROPERTY, B_SET_PROPERTY, B_GET_SUPPORTED_SUITES, 0 } -#define SET {B_SET_PROPERTY, 0} -#define DIRECT_AND_INDEX {B_DIRECT_SPECIFIER, B_INDEX_SPECIFIER, 0} -#define DIRECT {B_DIRECT_SPECIFIER, 0} +const char* ModeSpecifiers[NumModes] = {"Draw", "Select"}; +const char* ToolSpecifiers[NumTools] = {"Brush", "Eraser", "Fill", "Text", + "Spray Can", "Clone", "Freehand", "Lines", + "Free Shape", "Polygons", "Rectangles", "Ovals", + "Circles", "Ellipses"}; + +uchar cross[3][68] = { + {16, // Size + 1, // Bit depth + 7, 7, // hot spot + 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, // Image + 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7C, 0x7C, 0x00, 0x00, 0x01, 0x00, + 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, // Mask + 0x03, 0x80, 0x03, 0x80, 0xFC, 0x7E, 0xFC, 0x7E, 0xFC, 0x7E, 0x03, 0x80, + 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00}, + {16, 1, 7, 7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x40, 0x20, 0x40, + 0x18, 0x80, 0x04, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x30, 0x04, 0x08, 0x04, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0xF0, + 0x70, 0xF0, 0x7D, 0xE0, 0x7F, 0xE0, 0x3F, 0xC0, 0x0E, 0x70, 0x07, 0xF8, 0x0F, 0xFc, + 0x0F, 0x7C, 0x1E, 0x1C, 0x1E, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00}, + {16, 1, 7, 7, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x04, 0x08, + 0x02, 0x30, 0x00, 0x40, 0x00, 0x00, 0x04, 0x00, 0x18, 0x00, 0x40, 0x80, 0x00, 0x40, + 0x00, 0x40, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x1E, 0x00, + 0x1E, 0x1C, 0x0F, 0x7C, 0x0F, 0xFC, 0x07, 0xF8, 0x0E, 0xE0, 0x3F, 0xC0, 0x7F, 0xE0, + 0x7D, 0xE0, 0x70, 0xF0, 0x00, 0xE0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00} +}; + +uchar ccross[68] = {16, // Size, + 1, // Bit depth, + 7, 7, // hot spot + 0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x09, 0x20, // Image + 0x11, 0x10, 0x01, 0x00, 0x20, 0x08, 0x7C, 0x7C, 0x20, 0x08, 0x01, 0x00, + 0x11, 0x10, 0x09, 0x20, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x80, 0x07, 0xC0, 0x0F, 0xE0, 0x1F, 0xF0, // Mask + 0x3B, 0xB8, 0x73, 0x9C, 0xFF, 0xFE, 0xFE, 0xFE, 0xFF, 0xFE, 0x73, 0x9C, + 0x3B, 0xB8, 0x1F, 0xF0, 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x00, 0x00}; + +uchar scross[68] = {16, // Size + 1, // Bit depth + 7, 7, // hot spot + 0x00, 0x00, 0x03, 0x80, 0x02, 0x80, 0x02, 0x80, // Image + 0x02, 0x80, 0x01, 0x00, 0x78, 0x3C, 0x44, 0x44, 0x78, 0x3C, 0x01, 0x00, + 0x02, 0x80, 0x02, 0x80, 0x02, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, // Mask + 0x07, 0xC0, 0xF8, 0x3E, 0xF8, 0x3E, 0xF8, 0x3E, 0xF8, 0x3E, 0xF8, 0x3E, + 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, 0x07, 0xC0, 0x00, 0x00}; + +uchar hand[68] = {16, // Size + 1, // Bit depth + 7, 7, // hot spot + 0x01, 0x80, 0x1A, 0x70, 0x26, 0x48, 0x26, 0x4A, // Image + 0x12, 0x4D, 0x12, 0x49, 0x68, 0x09, 0x98, 0x01, 0x88, 0x02, 0x40, 0x02, + 0x20, 0x02, 0x20, 0x04, 0x10, 0x04, 0x08, 0x08, 0x04, 0x08, 0x04, 0x08, + 0x01, 0x80, 0x1B, 0xF0, 0x3F, 0xF8, 0x3F, 0xFA, // Mask + 0x1F, 0xFF, 0x1F, 0xFF, 0x6F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0x7F, 0xFE, + 0x3F, 0xFE, 0x3F, 0xFC, 0x1F, 0xFC, 0x0F, 0xF8, 0x07, 0xF8, 0x07, 0xF8}; + +uchar grab[68] = {16, // Size + 1, // Bit depth + 7, 7, // hot spot + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Image + 0x0D, 0xB0, 0x12, 0x4C, 0x10, 0x0A, 0x08, 0x02, 0x18, 0x02, 0x20, 0x02, + 0x20, 0x02, 0x20, 0x04, 0x10, 0x04, 0x08, 0x08, 0x04, 0x08, 0x04, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Mask + 0x0D, 0xB0, 0x1F, 0xFC, 0x1F, 0xFE, 0x0F, 0xFE, 0x1F, 0xFE, 0x3F, 0xFE, + 0x3F, 0xFE, 0x3F, 0xFC, 0x1F, 0xFC, 0x0F, 0xF8, 0x07, 0xF8, 0x07, 0xF8}; + +uchar picker[68] = {16, // Size, + 1, // Bit depth, + 14, 1, // hot spot + 0x00, 0x00, 0x00, 0x0C, 0x00, 0x1E, 0x00, 0x2E, // Image + 0x01, 0xBC, 0x01, 0x38, 0x00, 0xE0, 0x01, 0x70, 0x02, 0xB0, 0x05, 0x00, + 0x0A, 0x00, 0x14, 0x00, 0x28, 0x00, 0x50, 0x00, 0x60, 0x00, 0x00, 0x00, + 0x00, 0x1E, 0x00, 0x3F, 0x00, 0x7F, 0x03, 0xFF, // Mask + 0x03, 0xFF, 0x03, 0xFE, 0x03, 0xFC, 0x07, 0xF8, 0x0F, 0xF8, 0x1F, 0xF8, + 0x3F, 0x80, 0x7F, 0x00, 0xFE, 0x00, 0xFC, 0x00, 0xF8, 0x00, 0xF0, 0x00}; + +uchar mover[68] = {16, 1, 7, 7, 0x00, 0x00, 0x01, 0x00, 0x03, 0x80, 0x07, 0xC0, + 0x01, 0x00, 0x11, 0x10, 0x31, 0x18, 0x7F, 0xFC, 0x31, 0x18, 0x11, 0x10, + 0x01, 0x00, 0x07, 0xC0, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x80, 0x07, 0xC0, 0x07, 0xE0, 0x0F, 0xF0, 0x3F, 0xF8, 0x7B, 0xBC, + 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0x7B, 0xBC, 0x3F, 0xF8, 0x0F, 0xE0, + 0x0F, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x00, 0x00}; + +uchar rotator[68] = {16, 1, 7, 7, 0x00, 0x00, 0x03, 0x80, 0x0C, 0x60, 0x10, 0x10, + 0x20, 0x08, 0x20, 0x08, 0x41, 0x04, 0x42, 0x84, 0x41, 0x04, 0x20, 0x00, + 0x20, 0x00, 0x10, 0xF0, 0x0C, 0x38, 0x03, 0xD0, 0x00, 0x10, 0x00, 0x00, + 0x07, 0xC0, 0x1F, 0xF0, 0x3F, 0xF8, 0x7E, 0xFC, 0x78, 0x3C, 0xF3, 0x9E, + 0xF7, 0xDE, 0xE7, 0xCE, 0xF7, 0xCE, 0xF3, 0x8E, 0x79, 0xF8, 0x7F, 0xF8, + 0x3F, 0xF8, 0x1F, 0xF8, 0x07, 0xF8, 0x00, 0x38}; + +#define GET_AND_SET \ + { \ + B_GET_PROPERTY, B_SET_PROPERTY, 0 \ + } +#define GET_SET_AND_PROP \ + { \ + B_GET_PROPERTY, B_SET_PROPERTY, B_GET_SUPPORTED_SUITES, 0 \ + } +#define SET \ + { \ + B_SET_PROPERTY, 0 \ + } +#define DIRECT_AND_INDEX \ + { \ + B_DIRECT_SPECIFIER, B_INDEX_SPECIFIER, 0 \ + } +#define DIRECT \ + { \ + B_DIRECT_SPECIFIER, 0 \ + } static property_info prop_list[] = { {"Tool", GET_SET_AND_PROP, DIRECT_AND_INDEX, "Get or set current tool"}, @@ -221,146 +206,133 @@ static value_info value_list[] = { 0 }; -static property_info prop_list_BBP[] = { - {"", { 0 }, { 0 }, ""}, - 0 -}; +static property_info prop_list_BBP[] = {{"", {0}, {0}, ""}, 0}; -static value_info value_list_BBP[] = { - {"BBP_*_BBITMAP", 'BPxx', B_COMMAND_KIND, "See BBP.h"}, - 0 -}; +static value_info value_list_BBP[] = {{"BBP_*_BBITMAP", 'BPxx', B_COMMAND_KIND, "See BBP.h"}, 0}; -Becasso::Becasso () - : BApplication ("application/x-sum-becasso") +Becasso::Becasso() : BApplication("application/x-sum-becasso") { fBusy = 0; - SetPulseRate (100000); - + SetPulseRate(100000); + BPath path; - if (find_directory (B_USER_SETTINGS_DIRECTORY, &path) == B_OK) - { - BDirectory dir (path.Path()); + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { + BDirectory dir(path.Path()); BDirectory dummy; BEntry entry; -// dir.GetEntry (&entry); -// entry.GetPath (&path); -// printf ("Path now: %s\n", path.Path()); - dir.CreateDirectory ("Becasso", &dummy); // this won't clobber anyway -// dir.GetEntry (&entry); -// entry.GetPath (&path); -// printf ("Path now: %s\n", path.Path()); - path.Append ("Becasso"); - dir.SetTo (path.Path()); - + // dir.GetEntry (&entry); + // entry.GetPath (&path); + // printf ("Path now: %s\n", path.Path()); + dir.CreateDirectory("Becasso", &dummy); // this won't clobber anyway + // dir.GetEntry (&entry); + // entry.GetPath (&path); + // printf ("Path now: %s\n", path.Path()); + path.Append("Becasso"); + dir.SetTo(path.Path()); + // Do prefs loading here - -// dir.CreateDirectory ("Recent", &dummy); -// dir.GetEntry (&entry); -// entry.GetPath (&path); -// printf ("Path now: %s\n", path.Path()); + + // dir.CreateDirectory ("Recent", &dummy); + // dir.GetEntry (&entry); + // entry.GetPath (&path); + // printf ("Path now: %s\n", path.Path()); } - + app_info info; - GetAppInfo (&info); - BEntry appEntry = BEntry (&info.ref); + GetAppInfo(&info); + BEntry appEntry = BEntry(&info.ref); BEntry appDir; - appEntry.GetParent (&appDir); - BPath appDirPath (&appDir); + appEntry.GetParent(&appDir); + BPath appDirPath(&appDir); char dataFile[B_FILE_NAME_LENGTH]; - strcpy (dataFile, appDirPath.Path()); - strcat (dataFile, "/data/strings/"); + strcpy(dataFile, appDirPath.Path()); + strcat(dataFile, "/data/strings/"); extern BLocker g_settings_lock; extern becasso_settings g_settings; g_settings_lock.Lock(); - strcat (dataFile, g_settings.language); + strcat(dataFile, g_settings.language); g_settings_lock.Unlock(); - if (init_strings (dataFile) != B_OK) - fprintf (stderr, "Error initializing strings from %s\n", dataFile); + if (init_strings(dataFile) != B_OK) + fprintf(stderr, "Error initializing strings from %s\n", dataFile); -#if defined (DATATYPES) +#if defined(DATATYPES) if (DATAVersion) DataTypes = true; else DataTypes = false; if (DataTypes) - if (DATAInit ("application/x-sum-becasso")) + if (DATAInit("application/x-sum-becasso")) DataTypes = false; #else - DataTypes = true; // Called the Translation Kit here, but it's basically the same thing. + DataTypes = true; // Called the Translation Kit here, but it's basically the same thing. #endif def_out_type = 0; def_out_translator = 0; size_t bsize; size_t fxsize; - void *colordata = NULL; - void *teardata = NULL; + void* colordata = NULL; + void* teardata = NULL; NumColors = 0; - GetAppInfo (&info); - BFile file (&info.ref, O_RDONLY); - if (file.InitCheck()) - { - fprintf (stderr, "InitCheck() failed\n"); - } - else - { - BResources res (&file); - colordata = res.FindResource ('rgbx', 131, &bsize); - teardata = res.FindResource ('sfx1', 130, &fxsize); + GetAppInfo(&info); + BFile file(&info.ref, O_RDONLY); + if (file.InitCheck()) { + fprintf(stderr, "InitCheck() failed\n"); + } else { + BResources res(&file); + colordata = res.FindResource('rgbx', 131, &bsize); + teardata = res.FindResource('sfx1', 130, &fxsize); // printf ("bsize = %li\n", bsize); } - if (colordata) - { + if (colordata) { // RGB Color data resource is in the format: // offset data // 0 Max length of color name // 1,2 Number of entries (Big Endian) // 3.. [R][G][B]Name\0 - unsigned char *cdata = (unsigned char *) colordata; + unsigned char* cdata = (unsigned char*)colordata; extern bool ShowColors; int clen = cdata[0]; - NumColors = cdata[1] + 256*cdata[2]; - if (ShowColors && SHOW_EXTRA_COLOR_INFO) - { - printf ("Number of Color Names: %ld\n", NumColors); - printf ("Max length of color name: %d\n", clen); + NumColors = cdata[1] + 256 * cdata[2]; + if (ShowColors && SHOW_EXTRA_COLOR_INFO) { + printf("Number of Color Names: %ld\n", NumColors); + printf("Max length of color name: %d\n", clen); } cdata += 3; clen += 4; - RGBColors = new unsigned char* [NumColors]; - for (int i = 0; i < NumColors; i++) - { - RGBColors[i] = new unsigned char [clen]; + RGBColors = new unsigned char*[NumColors]; + for (int i = 0; i < NumColors; i++) { + RGBColors[i] = new unsigned char[clen]; RGBColors[i][0] = *cdata++; RGBColors[i][1] = *cdata++; RGBColors[i][2] = *cdata++; - unsigned char *ti = &(RGBColors[i][3]); + unsigned char* ti = &(RGBColors[i][3]); while (*cdata) *ti++ = *cdata++; *ti++ = *cdata++; if (ShowColors) - printf ("%3d %3d %3d %s\n", (int) RGBColors[i][0], (int) RGBColors[i][1], (int) RGBColors[i][2], &RGBColors[i][3]); + printf( + "%3d %3d %3d %s\n", (int)RGBColors[i][0], (int)RGBColors[i][1], + (int)RGBColors[i][2], &RGBColors[i][3] + ); } - } - else - fprintf (stderr, "Warning: Couldn't find RGB color resource\n"); + } else + fprintf(stderr, "Warning: Couldn't find RGB color resource\n"); -#if defined (EASTER_EGG_SFX) - if (teardata) - { - extern SoundEffect8_11 *fxTear; - fxTear = new SoundEffect8_11 (teardata, fxsize); - } - else - fprintf (stderr, "Warning: Couldn't find easter egg resource\n"); +#if defined(EASTER_EGG_SFX) + if (teardata) { + extern SoundEffect8_11* fxTear; + fxTear = new SoundEffect8_11(teardata, fxsize); + } else + fprintf(stderr, "Warning: Couldn't find easter egg resource\n"); #endif newnum = 1; refvalid = false; - openPanel = new ThumbnailFilePanel (B_OPEN_PANEL, new BMessenger (this), - NULL, B_FILE_NODE, false, new BMessage ('opnf'), NULL); - openPanel->GetPanelDirectory (&gSaveRef); + openPanel = new ThumbnailFilePanel( + B_OPEN_PANEL, new BMessenger(this), NULL, B_FILE_NODE, false, new BMessage('opnf'), NULL + ); + openPanel->GetPanelDirectory(&gSaveRef); clip = NULL; inDrag = false; inPaste = false; @@ -368,19 +340,19 @@ Becasso::Becasso () launchMessage = NULL; fCurrentScriptee = NULL; launching = true; - position_port = create_port (POSITION_QUEUE, "Position Port"); + position_port = create_port(POSITION_QUEUE, "Position Port"); extern bool BuiltInTablet; if (BuiltInTablet) - wacom = new Tablet ("serial3"); + wacom = new Tablet("serial3"); else - wacom = new Tablet (""); + wacom = new Tablet(""); wacom->Init(); - clipLock = new BLocker ("Clip Locker"); - -#if defined (EASTER_EGG_SFX) + clipLock = new BLocker("Clip Locker"); + +#if defined(EASTER_EGG_SFX) extern bool EasterEgg; if (EasterEgg && fxTear) - easterEgg = new EffectsPlayer (fxTear); + easterEgg = new EffectsPlayer(fxTear); else easterEgg = NULL; #endif @@ -391,196 +363,176 @@ Becasso::Becasso () // printf ("Becasso::ctor done\n"); } -Becasso::~Becasso () +Becasso::~Becasso() { -#if defined (EASTER_EGG_SFX) +#if defined(EASTER_EGG_SFX) delete easterEgg; #endif delete openPanel; if (clip) delete clip; -#if defined (DATATYPES) +#if defined(DATATYPES) if (DataTypes) DATAShutdown(); #endif - AddOn *addon; - for (long i = 0; addon = (AddOn *) AddOns->ItemAt (i), addon; i++) + AddOn* addon; + for (long i = 0; addon = (AddOn*)AddOns->ItemAt(i), addon; i++) delete addon; delete AddOns; } -void Becasso::LoadAddOns () +void +Becasso::LoadAddOns() { extern bool VerbAddOns, NoAddOns; - if (NoAddOns) - { + if (NoAddOns) { if (VerbAddOns) - fprintf (stderr, "Add-on loading skipped\n"); + fprintf(stderr, "Add-on loading skipped\n"); return; } app_info info; - GetAppInfo (&info); - BEntry appEntry = BEntry (&info.ref); + GetAppInfo(&info); + BEntry appEntry = BEntry(&info.ref); BEntry appDir; BPath appPath; BDirectory addonDir; - appEntry.GetParent (&appDir); - appDir.GetPath (&appPath); + appEntry.GetParent(&appDir); + appDir.GetPath(&appPath); char dirname[B_FILE_NAME_LENGTH]; - strcpy (dirname, appPath.Path()); - if (addonDir.SetTo (strcat (dirname, "/add-ons")) == B_OK) - { + strcpy(dirname, appPath.Path()); + if (addonDir.SetTo(strcat(dirname, "/add-ons")) == B_OK) { BEntry addon; - while (addonDir.GetNextEntry (&addon) != ENOENT) - { - AddOn *newaddon; - try - { - newaddon = new AddOn (addon); - } - catch (...) - { + while (addonDir.GetNextEntry(&addon) != ENOENT) { + AddOn* newaddon; + try { + newaddon = new AddOn(addon); + } catch (...) { BPath path; - addon.GetPath (&path); + addon.GetPath(&path); if (VerbAddOns) - fprintf (stderr, "Skipped %s\n", path.Path()); - // Don't delete newaddon here! + fprintf(stderr, "Skipped %s\n", path.Path()); + // Don't delete newaddon here! // Apparently it still points to the previously loaded addon... newaddon = NULL; } - if (newaddon) - { - if (!newaddon->Init (AddOns->CountItems())) - { - BMessage *spl = new BMessage ('Iaos'); - spl->AddString ("InitString", newaddon->Name()); + if (newaddon) { + if (!newaddon->Init(AddOns->CountItems())) { + BMessage* spl = new BMessage('Iaos'); + spl->AddString("InitString", newaddon->Name()); // printf ("Splash: %s\n", newaddon->Name()); - extern SplashWindow *splash; + extern SplashWindow* splash; splash->Lock(); - splash->PostMessage (spl); + splash->PostMessage(spl); splash->Unlock(); delete spl; - AddOns->AddItem (newaddon); - } - else - fprintf (stderr, "Warning: Add-On returned error from init\n"); + AddOns->AddItem(newaddon); + } else + fprintf(stderr, "Warning: Add-On returned error from init\n"); } } - } - else - { - fprintf (stderr, "Hmmm - I couldn't find the add-ons/ directory...\n"); + } else { + fprintf(stderr, "Hmmm - I couldn't find the add-ons/ directory...\n"); } } -bool Becasso::QuitRequested () +bool +Becasso::QuitRequested() { extern bool VerbQuit; - BWindow **kill_list = new BWindow* [CountWindows()]; + BWindow** kill_list = new BWindow*[CountWindows()]; int windex = 0; bool canQuit = true; - for (int i = 0; (i < CountWindows()) && canQuit; i++) - { + for (int i = 0; (i < CountWindows()) && canQuit; i++) { if (VerbQuit) - printf ("Checking window %i...\n", i); - BWindow *win = WindowAt(i); + printf("Checking window %i...\n", i); + BWindow* win = WindowAt(i); if (VerbQuit) - printf ("Class name: %s\n", class_name (win)); - if (is_kind_of (win, AttribWindow)) - { + printf("Class name: %s\n", class_name(win)); + if (is_kind_of(win, AttribWindow)) { if (VerbQuit) - printf (" AttribWindow\n"); + printf(" AttribWindow\n"); kill_list[windex++] = win; - continue; // These will have to be killed the hard way or they'll hide. + continue; // These will have to be killed the hard way or they'll hide. } - if (is_kind_of (win, LayerWindow)) - { + if (is_kind_of(win, LayerWindow)) { if (VerbQuit) - printf (" LayerWindow\n"); - continue; // These will go down with their associated CanvasWindow. + printf(" LayerWindow\n"); + continue; // These will go down with their associated CanvasWindow. } - if (is_kind_of (win, AddOnWindow)) - { + if (is_kind_of(win, AddOnWindow)) { if (VerbQuit) - printf (" AddOnWindow\n"); + printf(" AddOnWindow\n"); // These will be closed by the associated CanvasWindow. continue; } - if (is_instance_of (win, MagWindow)) - { + if (is_instance_of(win, MagWindow)) { if (VerbQuit) - printf (" MagWindow\n"); + printf(" MagWindow\n"); // These will be closed by the associated CanvasWindow. continue; } - if (is_instance_of (win, CanvasWindow)) - { + if (is_instance_of(win, CanvasWindow)) { if (VerbQuit) - printf (" CanvasWindow - QuitRequested...\n"); + printf(" CanvasWindow - QuitRequested...\n"); canQuit = win->QuitRequested(); if (canQuit) kill_list[windex++] = win; - if (VerbQuit) - { + if (VerbQuit) { if (canQuit) - printf (" Acknowledged.\n"); + printf(" Acknowledged.\n"); else - printf (" Refused!\n"); + printf(" Refused!\n"); } } - if (DragWindow *dw = dynamic_cast (win)) - { + if (DragWindow* dw = dynamic_cast(win)) { // This is a MenuWindow (dragged off PicMenuButton) if (VerbQuit) - printf (" DragWindow\n"); + printf(" DragWindow\n"); dw->SavePos(); - kill_list[windex++] = win; // Before the Main Window exits, killing the PicMenuButtons. + kill_list[windex++] = win; // Before the Main Window exits, killing the PicMenuButtons. } // The rest are probably File Panels and whatnot. // Just kill them. } - if (canQuit) - { -// // Kill the MouseChecking threads of the DragView. They might be -// // lingering around, and access their "parent" window after it's gone. -// // No harm done, but it generates an exception on closing. Better be -// // sure and kill them ourselves. -// -// NOTE: This is no longer needed because R3 offers floating windows by itself. -// -// thread_id mousethread; -// status_t exitvalue; -// while ((mousethread = find_thread ("BecassoDVMC")) != B_NAME_NOT_FOUND) -// { -// kill_thread (mousethread); -// wait_for_thread (mousethread, &exitvalue); -// } - for (int i = 0; i < windex; i++) - { + if (canQuit) { + // // Kill the MouseChecking threads of the DragView. They might be + // // lingering around, and access their "parent" window after it's gone. + // // No harm done, but it generates an exception on closing. Better be + // // sure and kill them ourselves. + // + // NOTE: This is no longer needed because R3 offers floating windows by itself. + // + // thread_id mousethread; + // status_t exitvalue; + // while ((mousethread = find_thread ("BecassoDVMC")) != B_NAME_NOT_FOUND) + // { + // kill_thread (mousethread); + // wait_for_thread (mousethread, &exitvalue); + // } + for (int i = 0; i < windex; i++) { if (VerbQuit) - printf ("Closing window %i: %s\n", i, class_name (kill_list[i])); + printf("Closing window %i: %s\n", i, class_name(kill_list[i])); kill_list[i]->Lock(); kill_list[i]->Quit(); // snooze (20000); } if (VerbQuit) - printf ("Closing Main Window\n"); + printf("Closing Main Window\n"); mainWindow->Lock(); - mainWindow->Quit(); // It'll take the openPanel with it. + mainWindow->Quit(); // It'll take the openPanel with it. } - delete [] kill_list; + delete[] kill_list; return (canQuit); } - -void Becasso::AboutRequested () +void +Becasso::AboutRequested() { -// char line[81]; -// sprintf (line, "Becasso v%s\n© 1997 ∑ Sum Software\nDemo version, expires 1 dec 1997\nhttp://www.sumware.demon.nl", Version); -// BAlert *about = new BAlert ("", line, "OK"); -// about->Go(); - if (about && about->Lock()) - { + // char line[81]; + // sprintf (line, "Becasso v%s\n© 1997 ∑ Sum Software\nDemo version, expires 1 dec + // 1997\nhttp://www.sumware.demon.nl", Version); BAlert *about = new BAlert ("", line, "OK"); + // about->Go(); + if (about && about->Lock()) { about->Activate(); about->Unlock(); return; @@ -588,2060 +540,1848 @@ void Becasso::AboutRequested () size_t bsize, ssize; void *becassodata, *sumdata; app_info info; - GetAppInfo (&info); - BFile file (&info.ref, O_RDONLY); - if (file.InitCheck()) - { - fprintf (stderr, "InitCheck() failed\n"); + GetAppInfo(&info); + BFile file(&info.ref, O_RDONLY); + if (file.InitCheck()) { + fprintf(stderr, "InitCheck() failed\n"); inherited::AboutRequested(); return; } - BResources res (&file); - becassodata = res.FindResource ('blog', 128, &bsize); - sumdata = res.FindResource ('slog', 129, &ssize); - if (!becassodata || !sumdata) - { - fprintf (stderr, "Bitmap data not found in resource\n"); + BResources res(&file); + becassodata = res.FindResource('blog', 128, &bsize); + sumdata = res.FindResource('slog', 129, &ssize); + if (!becassodata || !sumdata) { + fprintf(stderr, "Bitmap data not found in resource\n"); inherited::AboutRequested(); return; } - about = new AboutWindow (BRect (200, 200, 480, 410)); + about = new AboutWindow(BRect(200, 200, 480, 410)); color_space cs = B_RGB32; { BScreen screen; if (screen.ColorSpace() == B_COLOR_8_BIT) cs = B_COLOR_8_BIT; - } - BRect becassorect = BRect (0, 0, 231, 93); - BRect sumrect = BRect (0, 0, 63, 83); - BBitmap *becasso = new BBitmap (becassorect, cs); - BBitmap *sum = new BBitmap (sumrect, B_RGB32); - becasso->SetBits (becassodata, bsize, 0, B_RGB32); - sum->SetBits (sumdata, ssize, 0, B_RGB32); - SAboutView *aboutView = new SAboutView (about->Bounds(), becasso, sum); - about->AddChild (aboutView); + } + BRect becassorect = BRect(0, 0, 231, 93); + BRect sumrect = BRect(0, 0, 63, 83); + BBitmap* becasso = new BBitmap(becassorect, cs); + BBitmap* sum = new BBitmap(sumrect, B_RGB32); + becasso->SetBits(becassodata, bsize, 0, B_RGB32); + sum->SetBits(sumdata, ssize, 0, B_RGB32); + SAboutView* aboutView = new SAboutView(about->Bounds(), becasso, sum); + about->AddChild(aboutView); about->Show(); } -void Becasso::ReadyToRun() +void +Becasso::ReadyToRun() { - //printf ("ReadyToRun()...\n"); + // printf ("ReadyToRun()...\n"); BRect mainWindowFrame; - mainWindowFrame.Set (0, 0, 160, 50); - BPoint origin = get_window_origin (0); - mainWindow = new MainWindow (mainWindowFrame, "Becasso"); - mainWindow->MoveTo (origin); - + mainWindowFrame.Set(0, 0, 160, 50); + BPoint origin = get_window_origin(0); + mainWindow = new MainWindow(mainWindowFrame, "Becasso"); + mainWindow->MoveTo(origin); + extern int SilentOperation; - mainWindow->Minimize (SilentOperation >= 2); + mainWindow->Minimize(SilentOperation >= 2); mainWindow->Show(); - extern SplashWindow *splash; + extern SplashWindow* splash; splash->Lock(); splash->Quit(); launching = false; - if (launchMessage) - { - PostMessage (launchMessage); + if (launchMessage) { + PostMessage(launchMessage); delete launchMessage; - launchMessage = NULL; // Just to make sure. It won't be used anymore, though. + launchMessage = NULL; // Just to make sure. It won't be used anymore, though. } - //printf ("ReadyToRun() Done\n"); - + // printf ("ReadyToRun() Done\n"); + extern becasso_settings g_settings; extern BLocker g_settings_lock; g_settings_lock.Lock(); int32 totd = g_settings.totd; g_settings_lock.Unlock(); - - if (totd) - { - BRect totdRect (100, 200, 420, 320); - BPoint totdPoint = get_window_origin (numTOTDWindow); + + if (totd) { + BRect totdRect(100, 200, 420, 320); + BPoint totdPoint = get_window_origin(numTOTDWindow); if (totdPoint != InvalidPoint) - totdRect.OffsetTo (totdPoint); - TOTDWindow *totdwin = new TOTDWindow (totdRect, totd); + totdRect.OffsetTo(totdPoint); + TOTDWindow* totdwin = new TOTDWindow(totdRect, totd); totdwin->Show(); } } -void Becasso::RefsReceived (BMessage *message) +void +Becasso::RefsReceived(BMessage* message) { - //printf ("Becasso::RefsReceived\n"); + // printf ("Becasso::RefsReceived\n"); uint32 type; int32 count; - message->GetInfo ("refs", &type, &count); - for (long i = --count; i >= 0; i--) - { - if (message->FindRef ("refs", i, &fRef) == B_OK) - { + message->GetInfo("refs", &type, &count); + for (long i = --count; i >= 0; i--) { + if (message->FindRef("refs", i, &fRef) == B_OK) { refvalid = true; - BMessage *refmsg = new BMessage ('opnf'); - refmsg->AddRef ("refs", &fRef); + BMessage* refmsg = new BMessage('opnf'); + refmsg->AddRef("refs", &fRef); bool AskForAlpha = true; - const char *AskForAlphaString; + const char* AskForAlphaString; // message->PrintToStream(); - if (message->FindBool ("AskForAlpha", &AskForAlpha) == B_OK) - refmsg->AddBool ("AskForAlpha", AskForAlpha); - else if ((message->FindString ("AskForAlpha", &AskForAlphaString) == B_OK) - && (!strcasecmp (AskForAlphaString, "false"))) - refmsg->AddBool ("AskForAlpha", false); + if (message->FindBool("AskForAlpha", &AskForAlpha) == B_OK) + refmsg->AddBool("AskForAlpha", AskForAlpha); + else if ((message->FindString("AskForAlpha", &AskForAlphaString) == B_OK) && (!strcasecmp(AskForAlphaString, "false"))) + refmsg->AddBool("AskForAlpha", false); // refmsg->PrintToStream(); - PostMessage (refmsg); + PostMessage(refmsg); delete refmsg; - snooze (20000); + snooze(20000); } } } -void Becasso::ArgvReceived (int32 argc, char **argv) +void +Becasso::ArgvReceived(int32 argc, char** argv) { // printf ("Becasso::ArgvReceived (argc = %ld)\n", argc); - for (int i = 1; i < argc; i++) - { - if (argv[i][0] == '-') - { + for (int i = 1; i < argc; i++) { + if (argv[i][0] == '-') { // Command line option - these are handled in main(). - } - else - { + } else { // printf ("%s\n", argv[i]); entry_ref ref; - get_ref_for_path (argv[i], &ref); + get_ref_for_path(argv[i], &ref); refvalid = true; - BMessage *refmsg = new BMessage ('opnf'); - refmsg->AddRef ("refs", &ref); - PostMessage (refmsg); + BMessage* refmsg = new BMessage('opnf'); + refmsg->AddRef("refs", &ref); + PostMessage(refmsg); delete refmsg; - snooze (20000); + snooze(20000); } } } -status_t Becasso::GetSupportedSuites (BMessage *message) +status_t +Becasso::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-becasso"); - BPropertyInfo info (prop_list, value_list); - message->AddFlat ("messages", &info); - message->AddString ("suites", "suite/x-sum-BBP"); - BPropertyInfo infoBBP (prop_list_BBP, value_list_BBP); - message->AddFlat ("messages", &infoBBP); - return BApplication::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-becasso"); + BPropertyInfo info(prop_list, value_list); + message->AddFlat("messages", &info); + message->AddString("suites", "suite/x-sum-BBP"); + BPropertyInfo infoBBP(prop_list_BBP, value_list_BBP); + message->AddFlat("messages", &infoBBP); + return BApplication::GetSupportedSuites(message); } -BHandler *Becasso::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +Becasso::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { -// printf ("message:\n"); -// message->PrintToStream(); -// printf ("\nspecifier:\n"); -// specifier->PrintToStream(); -// printf ("command: %ld, property: ""%s""\n", command, property); + // printf ("message:\n"); + // message->PrintToStream(); + // printf ("\nspecifier:\n"); + // specifier->PrintToStream(); + // printf ("command: %ld, property: ""%s""\n", command, property); - if (!strcasecmp (property, "Tool")) - { - if (specifier->HasString ("name") - || specifier->HasInt32 ("index")) // Part of a specifier for Tool settings. + if (!strcasecmp(property, "Tool")) { + if (specifier->HasString("name") || + specifier->HasInt32("index")) // Part of a specifier for Tool settings. { // Note: Don't PopSpecifier() !! // We'll let the AttribWindow resolve the exact tool specifier first... - extern AttribWindow *tAttribWindow; - tAttribWindow->PostMessage (message); + extern AttribWindow* tAttribWindow; + tAttribWindow->PostMessage(message); return NULL; - } - else - { + } else { fCurrentProperty = PROP_TOOL; return this; } } - if (!strcasecmp (property, "Mode")) - { - if (specifier->HasString ("name") - || specifier->HasInt32 ("index")) // Part of a specifier for Mode settings. + if (!strcasecmp(property, "Mode")) { + if (specifier->HasString("name") || + specifier->HasInt32("index")) // Part of a specifier for Mode settings. { // Note: Don't PopSpecifier() !! // We'll let the AttribWindow resolve the exact mode specifier first... - extern AttribWindow *mAttribWindow; - mAttribWindow->PostMessage (message); + extern AttribWindow* mAttribWindow; + mAttribWindow->PostMessage(message); return NULL; - } - else - { + } else { fCurrentProperty = PROP_MODE; return this; } } - if (!strcasecmp (property, "Foreground")) - { + if (!strcasecmp(property, "Foreground")) { fCurrentProperty = PROP_FGCOLOR; return this; } - if (!strcasecmp (property, "Background")) - { + if (!strcasecmp(property, "Background")) { fCurrentProperty = PROP_BGCOLOR; return this; } - if (!strcasecmp (property, "TabletArea")) - { + if (!strcasecmp(property, "TabletArea")) { fCurrentProperty = PROP_TABLET; return this; } - if (!strcasecmp (property, "Size")) - { + if (!strcasecmp(property, "Size")) { fCurrentProperty = PROP_SIZE; return this; } - if (!strcasecmp (property, "Name")) - { + if (!strcasecmp(property, "Name")) { fCurrentProperty = PROP_NAME; return this; } - if (!strcasecmp (property, "ExportFormat")) - { + if (!strcasecmp(property, "ExportFormat")) { fCurrentProperty = PROP_EXPFMT; return this; } - if (!strcasecmp (property, "Scriptee")) - { + if (!strcasecmp(property, "Scriptee")) { fCurrentProperty = PROP_SCRIPTEE; return this; } - if (!strcasecmp (property, "Canvas")) - { + if (!strcasecmp(property, "Canvas")) { fCurrentProperty = PROP_CANVAS; - switch (specifier->what) - { + switch (specifier->what) { case B_DIRECT_SPECIFIER: return this; break; - case B_INDEX_SPECIFIER: - { + case B_INDEX_SPECIFIER: { int32 index; - if (specifier->FindInt32 ("index", &index) == B_OK) - { - canvas *current = (canvas *) canvases.ItemAt (index); - if (current) - { + if (specifier->FindInt32("index", &index) == B_OK) { + canvas* current = (canvas*)canvases.ItemAt(index); + if (current) { message->PopSpecifier(); - if (current->its_looper != Looper()) - { - current->its_looper->PostMessage (message); + if (current->its_looper != Looper()) { + current->its_looper->PostMessage(message); return NULL; } - } - else - { - char errstring[256]; - sprintf (errstring, "Index Out of Range: %ld", index); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + } else { + BString indexData, errorString; + fNumberFormat.Format(indexData, index); + errorString.SetToFormat("Index out of range: %s", indexData.String()); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errorString); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errorString); } } break; } - case B_NAME_SPECIFIER: - { - const char *name; - if (specifier->FindString ("name", &name) == B_OK) - { + case B_NAME_SPECIFIER: { + const char* name; + if (specifier->FindString("name", &name) == B_OK) { int32 m = canvases.CountItems(); int32 i; - for (i = 0; i < m; i++) - { - canvas *current = (canvas *) canvases.ItemAt (i); - if (!strcmp (name, current->name)) - { + for (i = 0; i < m; i++) { + canvas* current = (canvas*)canvases.ItemAt(i); + if (!strcmp(name, current->name)) { message->PopSpecifier(); - current->its_looper->PostMessage (message); + current->its_looper->PostMessage(message); return NULL; } } - if (i == m) - { + if (i == m) { char errstring[256]; - sprintf (errstring, "Unknown Canvas: '%s'", name); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + sprintf(errstring, "Unknown Canvas: '%s'", name); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); } } break; } default: - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void Becasso::PrintSetup () +void +Becasso::PrintSetup() { - extern BMessage *printSetup; - BPrintJob job ("Becasso"); + extern BMessage* printSetup; + BPrintJob job("Becasso"); if (printSetup) - job.SetSettings (new BMessage (*printSetup)); - if (job.ConfigPage() == B_OK) - { - delete printSetup; - printSetup = job.Settings(); + job.SetSettings(new BMessage(*printSetup)); + if (job.ConfigPage() == B_OK) { + delete printSetup; + printSetup = job.Settings(); } } -#if defined (__MWCC__) -# pragma optimization_level 1 +#if defined(__MWCC__) +#pragma optimization_level 1 #endif -void Becasso::MessageReceived (BMessage *message) +void +Becasso::MessageReceived(BMessage* message) { -// printf ("Becasso::MessageReceived\n"); -// message->PrintToStream(); - switch (message->what) - { - case 'creg': - { - // printf ("Registering canvas...\n"); - canvas *newcanvas = new canvas (); - const char *name; - if (message->FindString ("name", &name) == B_OK) - strcpy (newcanvas->name, name); - else - strcpy (newcanvas->name, ""); - newcanvas->index = canvas_index++; - BLooper *its_looper; - if (message->FindPointer ("looper", (void **) &its_looper) == B_OK) - newcanvas->its_looper = its_looper; - else - fprintf (stderr, "BIG error!!\n"); - - canvases.AddItem (newcanvas); - verbose (1, "Canvas '%s' registered...\n", newcanvas->name); - break; - } - case 'cdel': - { - BLooper *its_looper; - if (message->FindPointer ("looper", (void **) &its_looper) == B_OK) - { - int32 m = canvases.CountItems(); - int32 i; - for (i = 0; i < m; i++) - { - canvas *current = (canvas *) canvases.ItemAt (i); - if (its_looper == current->its_looper) - { - delete ((canvas *) canvases.RemoveItem (i)); - break; - } + // printf ("Becasso::MessageReceived\n"); + // message->PrintToStream(); + BString title, windowNumber; + + switch (message->what) { + case 'creg': { + // printf ("Registering canvas...\n"); + canvas* newcanvas = new canvas(); + const char* name; + if (message->FindString("name", &name) == B_OK) + strcpy(newcanvas->name, name); + else + strcpy(newcanvas->name, ""); + newcanvas->index = canvas_index++; + BLooper* its_looper; + if (message->FindPointer("looper", (void**)&its_looper) == B_OK) + newcanvas->its_looper = its_looper; + else + fprintf(stderr, "BIG error!!\n"); + + canvases.AddItem(newcanvas); + verbose(1, "Canvas '%s' registered...\n", newcanvas->name); + break; + } + case 'cdel': { + BLooper* its_looper; + if (message->FindPointer("looper", (void**)&its_looper) == B_OK) { + int32 m = canvases.CountItems(); + int32 i; + for (i = 0; i < m; i++) { + canvas* current = (canvas*)canvases.ItemAt(i); + if (its_looper == current->its_looper) { + delete ((canvas*)canvases.RemoveItem(i)); + break; } - if (i == m) - fprintf (stderr, "Unknown Canvas %p (?!)\n", its_looper); } - else - fprintf (stderr, "BIG error!!\n"); - break; + if (i == m) + fprintf(stderr, "Unknown Canvas %p (?!)\n", its_looper); + } else + fprintf(stderr, "BIG error!!\n"); + break; + } + case 'aURL': { + char* argv[1] = {"https://github.com/HaikuArchives/Becasso"}; + be_roster->Launch("text/html", 1, argv); + break; + } + case 'aDOC': { + app_info info; + GetAppInfo(&info); + BEntry appEntry = BEntry(&info.ref); + BEntry appDir; + BPath appPath; + BDirectory addonDir; + appEntry.GetParent(&appDir); + appDir.GetPath(&appPath); + char dirname[B_FILE_NAME_LENGTH]; + strcpy(dirname, appPath.Path()); + char* argv[1]; + argv[0] = new char[B_FILE_NAME_LENGTH]; + sprintf(argv[0], "file://%s/Documentation/Becasso.html", dirname); + be_roster->Launch("text/html", 1, argv); + break; + } + case B_SIMPLE_DATA: { + uint32 type; + int32 count; + message->GetInfo("refs", &type, &count); + for (long i = --count; i >= 0; i--) { + if (message->FindRef("refs", i, &fRef) == B_OK) { + refvalid = true; + BMessage* refmsg = new BMessage('opnf'); + refmsg->AddRef("refs", &fRef); + PostMessage(refmsg); + delete refmsg; + snooze(20000); + } } - case 'aURL': + break; + } + case 'expt': { + if (!fCurrentScriptee) + // There's no current "scriptee" window yet! { - char *argv[1] = { "https://github.com/HaikuArchives/Becasso" }; - be_roster->Launch ("text/html", 1, argv); + char errstring[256]; + sprintf( + errstring, "There is no current " + "scriptee" + " window yet" + ); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); break; } - case 'aDOC': - { - app_info info; - GetAppInfo (&info); - BEntry appEntry = BEntry (&info.ref); - BEntry appDir; - BPath appPath; - BDirectory addonDir; - appEntry.GetParent (&appDir); - appDir.GetPath (&appPath); - char dirname[B_FILE_NAME_LENGTH]; - strcpy (dirname, appPath.Path()); - char *argv[1]; - argv[0] = new char[B_FILE_NAME_LENGTH]; - sprintf (argv[0], "file://%s/Documentation/Becasso.html", dirname); - be_roster->Launch ("text/html", 1, argv); - break; + + BMessage exportMessage('expt'); + const char* namestring; + if (message->FindString("name", &namestring) == B_OK || + message->FindString("Name", &namestring) == B_OK || + message->FindString("filename", &namestring) == B_OK || + message->FindString("Filename", &namestring) == B_OK) { + exportMessage.AddString("filename", namestring); + // printf ("File name: %s\n", namestring); + } + + BMessage reply; + fCurrentScriptee->SendMessage(&exportMessage, &reply); + if (message->IsSourceWaiting()) { + message->SendReply(&reply); } - case B_SIMPLE_DATA: + break; + } + case 'Crop': { + if (!fCurrentScriptee) + // There's no current "scriptee" window yet! { - uint32 type; - int32 count; - message->GetInfo ("refs", &type, &count); - for (long i = --count; i >= 0; i--) - { - if (message->FindRef ("refs", i, &fRef) == B_OK) - { - refvalid = true; - BMessage *refmsg = new BMessage ('opnf'); - refmsg->AddRef ("refs", &fRef); - PostMessage (refmsg); - delete refmsg; - snooze (20000); - } - } + char errstring[256]; + sprintf( + errstring, "There is no current " + "scriptee" + " window yet" + ); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); break; } - case 'expt': - { - if (!fCurrentScriptee) - // There's no current "scriptee" window yet! - { - char errstring[256]; - sprintf (errstring, "There is no current ""scriptee"" window yet"); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + + BMessage cropMessage('Crop'); + BRect rect; + if (message->FindRect("data", &rect) == B_OK || message->FindRect("rect", &rect) == B_OK || + message->FindRect("croprect", &rect) == B_OK || + message->FindRect("CropRect", &rect) == B_OK) { + cropMessage.AddRect("data", rect); + } + + BMessage reply; + fCurrentScriptee->SendMessage(&cropMessage, &reply); + if (message->IsSourceWaiting()) { + message->SendReply(&reply); + } + break; + } + case 'newc': { + Unlock(); + static int32 newWidth = 256, newHeight = 256; + static int32 newColor = COLOR_BG; + SizeWindow* sizeWindow = new SizeWindow(newHeight, newWidth, newColor); + if (sizeWindow->Go()) { + fNumberFormat.Format(windowNumber, newnum++); + title.SetToFormat("%s %s", "Untitled", windowNumber.String()); + newWidth = sizeWindow->w(); + newHeight = sizeWindow->h(); + newColor = sizeWindow->color(); + BRect canvasWindowFrame; + canvasWindowFrame.Set( + 128 + newnum * 16, 128 + newnum * 16, 128 + newnum * 16 + newWidth - 1, + 128 + newnum * 16 + newHeight - 1 + ); + rgb_color color = White; + extern ColorMenuButton *hicolor, *locolor; + switch (newColor) { + case COLOR_FG: + color = hicolor->color(); + break; + case COLOR_BG: + color = locolor->color(); + break; + case COLOR_TR: + color.red = 255; + color.green = 255; + color.blue = 255; + color.alpha = 0; break; } - - BMessage exportMessage ('expt'); - const char *namestring; - if (message->FindString ("name", &namestring) == B_OK - || message->FindString ("Name", &namestring) == B_OK - || message->FindString ("filename", &namestring) == B_OK - || message->FindString ("Filename", &namestring) == B_OK) - { - exportMessage.AddString ("filename", namestring); - // printf ("File name: %s\n", namestring); - } - - BMessage reply; - fCurrentScriptee->SendMessage (&exportMessage, &reply); - if (message->IsSourceWaiting()) - { - message->SendReply (&reply); + CanvasWindow* canvasWindow = + new CanvasWindow(canvasWindowFrame, title, NULL, NULL, false, color); + delete fCurrentScriptee; + fCurrentScriptee = new BMessenger(canvasWindow); + canvasWindow->Show(); + } + Lock(); + sizeWindow->Lock(); + sizeWindow->Quit(); + break; + } + case 'cnew': // Deprecated!!! + { + // message->PrintToStream(); + fNumberFormat.Format(windowNumber, newnum++); + title.SetToFormat("Untitled %s", windowNumber.String()); + BRect canvasWindowFrame; + canvasWindowFrame.Set( + 128 + newnum * 16, 128 + newnum * 16, 128 + newnum * 16 + 255, 128 + newnum * 16 + 255 + ); + + BMessage specifier; + int32 index; + while (message->GetCurrentSpecifier(&index, &specifier) == B_OK) { + // printf ("Found a specifier:\n"); + // specifier.PrintToStream(); + const char* property; + if (specifier.FindString("property", &property) == B_OK) { + // printf ("Found property: %s\n", property); + if (!strcasecmp(property, "Size")) { + char* sizestring; + if (specifier.FindString("name", (const char**)&sizestring) == B_OK) { + if (!strncmp(sizestring, "BRect", 5)) + sizestring += 6; + + canvasWindowFrame.left = atof(strtok(sizestring, " ,")); + canvasWindowFrame.top = atof(strtok(NULL, " ,")); + canvasWindowFrame.right = atof(strtok(NULL, " ,")); + canvasWindowFrame.bottom = atof(strtok(NULL, " ,")); + } + } else if (!strcasecmp(property, "Name")) { + const char* namestring; + if (specifier.FindString("name", &namestring) == B_OK) { + title.SetTo(namestring); + } + } } - break; + message->PopSpecifier(); } - case 'Crop': - { - if (!fCurrentScriptee) - // There's no current "scriptee" window yet! - { - char errstring[256]; - sprintf (errstring, "There is no current ""scriptee"" window yet"); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); + // canvasWindowFrame.PrintToStream(); + CanvasWindow* canvasWindow = new CanvasWindow(canvasWindowFrame, title); + delete fCurrentScriptee; + fCurrentScriptee = new BMessenger(canvasWindow); + canvasWindow->Show(); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); + } + break; + } + case 'open': + openPanel->Show(); // Don't ask. + openPanel->Show(); + break; + case 'opnR': // open Recent + { + entry_ref ref; + if (message->FindRef("ref", &ref) == B_NO_ERROR) { + BEntry entry; + if ((entry.SetTo(&ref, true) == B_NO_ERROR) && entry.IsFile()) { + bool AskForAlpha = true; + char buffer[1024]; + BNode node(&ref); + ssize_t s; + if ((s = node.ReadAttr("BEOS:TYPE", B_STRING_TYPE, 0, buffer, 1022)) > 0) { + buffer[s] = 0; + if (!strcmp(buffer, "application/x-sum-becasso.palette")) { + BAlert* alert = new BAlert( + "", + lstring( + 6, "Please drop Becasso Palette files on the appropriate Color " + "button or on the associated Color Editor window." + ), + lstring(136, "OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT + ); + alert->Go(); + break; + } } - else - fprintf (stderr, "%s\n", errstring); - break; + try { + // message->PrintToStream(); + if (message->HasBool("AskForAlpha")) + message->FindBool("AskForAlpha", &AskForAlpha); + CanvasWindow* canvasWindow; + BRect canvasWindowFrame; + canvasWindowFrame.Set(100, 180, 500, 500); + canvasWindow = new CanvasWindow(canvasWindowFrame, ref, AskForAlpha); + delete fCurrentScriptee; + fCurrentScriptee = new BMessenger(canvasWindow); + BScreen screen; + canvasWindowFrame = canvasWindow->Frame() & screen.Frame(); + canvasWindow->ResizeTo(canvasWindowFrame.Width(), canvasWindowFrame.Height()); + canvasWindow->Show(); + } catch (...) { + printf("Caught in the act!\n"); + } + } else { + char name[B_FILE_NAME_LENGTH]; + if (entry.GetName(name) == B_OK) { + printf("Couldn't find %s\n", name); + } else { + printf("Not a file?\n"); + } + // Not a file? } - - BMessage cropMessage ('Crop'); - BRect rect; - if (message->FindRect ("data", &rect) == B_OK - || message->FindRect ("rect", &rect) == B_OK - || message->FindRect ("croprect", &rect) == B_OK - || message->FindRect ("CropRect", &rect) == B_OK) - { - cropMessage.AddRect ("data", rect); + } else { + printf("No ref?\n"); + // No refs? + } + break; + } + case 'opnf': { + entry_ref ref; + openPanel->Hide(); + if (message->FindRef("refs", &ref) == B_NO_ERROR) { + BEntry entry; + if ((entry.SetTo(&ref, true) == B_NO_ERROR) && entry.IsFile()) { + bool AskForAlpha = true; + char buffer[1024]; + BNode node = BNode(&ref); + ssize_t s; + if ((s = node.ReadAttr("BEOS:TYPE", B_STRING_TYPE, 0, buffer, 1022)) > 0) { + buffer[s] = 0; + if (!strcmp(buffer, "application/x-sum-becasso.palette")) { + BAlert* alert = new BAlert( + "", + lstring( + 6, "Please drop Becasso Palette files on the appropriate Color " + "button or on the associated Color Editor window." + ), + lstring(136, "OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT + ); + alert->Go(); + break; + } + } + try { + // message->PrintToStream(); + if (message->HasBool("AskForAlpha")) + message->FindBool("AskForAlpha", &AskForAlpha); + CanvasWindow* canvasWindow; + BRect canvasWindowFrame; + canvasWindowFrame.Set(100, 180, 500, 500); + canvasWindow = new CanvasWindow(canvasWindowFrame, ref, AskForAlpha); + delete fCurrentScriptee; + fCurrentScriptee = new BMessenger(canvasWindow); + BScreen screen; + canvasWindowFrame = canvasWindow->Frame() & screen.Frame(); + canvasWindow->ResizeTo(canvasWindowFrame.Width(), canvasWindowFrame.Height()); + extern int SilentOperation; + canvasWindow->Minimize(SilentOperation >= 1); + canvasWindow->Show(); + } catch (...) { + printf("Caught in the act!\n"); + break; + } + } else { + char name[B_FILE_NAME_LENGTH]; + if (entry.GetName(name) == B_OK) { + printf("Couldn't find %s\n", name); + } else { + printf("Not a file?\n"); + } + // Not a file? } - - BMessage reply; - fCurrentScriptee->SendMessage (&cropMessage, &reply); - if (message->IsSourceWaiting()) - { - message->SendReply (&reply); + } else { + printf("No refs?\n"); + // No refs? + } + break; + } + case 'aliv': // Sent by CanvasWindow itself, due to scripting AskForAlpha switch + { + BMessenger msgr; + message->FindMessenger("canvas", &msgr); + message->AddInt32("which", 1); + msgr.SendMessage(message); + break; + } + case 'SPst': { + BWindow* win; + for (int i = 1; i < CountWindows(); i++) { + win = WindowAt(i); + if (is_instance_of(win, CanvasWindow)) + win->PostMessage(message); + } + break; + } + case 'clrX': // color changed - warn all the windows + { + BWindow* win; + for (int i = 1; i < CountWindows(); i++) { + win = WindowAt(i); + if (is_instance_of(win, CanvasWindow)) + win->PostMessage(message); + } + break; + } + case 0: // Icon dropped from FileTypes (yes, 0!!) + { + BMessage msg; + if (message->FindMessage("icon/large", &msg) == B_OK) { + BBitmap* map = new BBitmap(&msg); + if (map->IsValid()) { + fNumberFormat.Format(windowNumber, newnum++); + title.SetToFormat("Untitled (Icon) %s", windowNumber.String()); + float newWidth = map->Bounds().Width(); + float newHeight = map->Bounds().Height(); + BRect canvasWindowFrame; + canvasWindowFrame.Set( + 128 + newnum * 16, 128 + newnum * 16, 128 + newnum * 16 + newWidth - 1, + 128 + newnum * 16 + newHeight - 1 + ); + CanvasWindow* canvasWindow = new CanvasWindow(canvasWindowFrame, title, map); + delete fCurrentScriptee; + fCurrentScriptee = new BMessenger(canvasWindow); + canvasWindow->Show(); + BMessage* m = new BMessage('M4'); + canvasWindow->PostMessage(m); + delete m; + m = new BMessage('rstf'); + canvasWindow->PostMessage(m); + delete m; + } else { + fprintf(stderr, "Invalid BBitmap\n"); + // Error } - break; } - case 'newc': - { - Unlock(); - static int32 newWidth = 256, newHeight = 256; - static int32 newColor = COLOR_BG; - SizeWindow *sizeWindow = new SizeWindow (newHeight, newWidth, newColor); - if (sizeWindow->Go()) - { - char title[MAXTITLE]; - sprintf (title, "%s %i", lstring (149, "Untitled"), newnum++); - newWidth = sizeWindow->w(); - newHeight = sizeWindow->h(); - newColor = sizeWindow->color(); + if (message->FindMessage("icon/mini", &msg) == B_OK) { + BBitmap* map = new BBitmap(&msg); + if (map->IsValid()) { + fNumberFormat.Format(windowNumber, newnum++); + title.SetToFormat("Untitled (MIcon) %s", windowNumber.String()); + float newWidth = map->Bounds().Width(); + float newHeight = map->Bounds().Height(); BRect canvasWindowFrame; - canvasWindowFrame.Set (128 + newnum*16, 128 + newnum*16, - 128 + newnum*16 + newWidth - 1, 128 + newnum*16 + newHeight - 1); - rgb_color color = White; - extern ColorMenuButton *hicolor, *locolor; - switch (newColor) - { - case COLOR_FG: - color = hicolor->color(); - break; - case COLOR_BG: - color = locolor->color(); - break; - case COLOR_TR: - color.red = 255; - color.green = 255; - color.blue = 255; - color.alpha = 0; - break; - } - CanvasWindow *canvasWindow = new CanvasWindow (canvasWindowFrame, title, NULL, NULL, false, color); + canvasWindowFrame.Set( + 128 + newnum * 16, 128 + newnum * 16, 128 + newnum * 16 + newWidth - 1, + 128 + newnum * 16 + newHeight - 1 + ); + CanvasWindow* canvasWindow = new CanvasWindow(canvasWindowFrame, title, map); delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (canvasWindow); + fCurrentScriptee = new BMessenger(canvasWindow); canvasWindow->Show(); + BMessage* m = new BMessage('M4'); + canvasWindow->PostMessage(m); + delete m; + m = new BMessage('rstf'); + canvasWindow->PostMessage(m); + delete m; + } else { + fprintf(stderr, "Invalid BBitmap\n"); + // Error } - Lock(); - sizeWindow->Lock(); - sizeWindow->Quit(); - break; } - case 'cnew': // Deprecated!!! - { - // message->PrintToStream(); - char title[MAXTITLE]; - sprintf (title, "%s %i", lstring (149, "Untitled"), newnum++); - BRect canvasWindowFrame; - canvasWindowFrame.Set (128 + newnum*16, 128 + newnum*16, - 128 + newnum*16 + 255, 128 + newnum*16 + 255); - - BMessage specifier; - int32 index; - while (message->GetCurrentSpecifier (&index, &specifier) == B_OK) - { - // printf ("Found a specifier:\n"); - // specifier.PrintToStream(); - const char *property; - if (specifier.FindString ("property", &property) == B_OK) - { - // printf ("Found property: %s\n", property); - if (!strcasecmp (property, "Size")) - { - char *sizestring; - if (specifier.FindString ("name", (const char **) &sizestring) == B_OK) - { - if (!strncmp (sizestring, "BRect", 5)) - sizestring += 6; - - canvasWindowFrame.left = atof (strtok (sizestring, " ,")); - canvasWindowFrame.top = atof (strtok (NULL, " ,")); - canvasWindowFrame.right = atof (strtok (NULL, " ,")); - canvasWindowFrame.bottom = atof (strtok (NULL, " ,")); - } - } - else if (!strcasecmp (property, "Name")) - { - const char *namestring; - if (specifier.FindString ("name", &namestring) == B_OK) - { - strcpy (title, namestring); - } - } - } - message->PopSpecifier(); + break; + } + case 'PPNT': // RRaster drop + { + if (launching) { + launchMessage = new BMessage(*message); + } else { + BRect bounds; + color_space colorspace; + ssize_t bits_length; + message->FindRect("bounds", &bounds); + message->FindInt32("bits_length", (int32*)&bits_length); + message->FindInt32("color_space", (int32*)&colorspace); + fNumberFormat.Format(windowNumber, newnum++); + title.SetToFormat("Untitled (RRaster) %s", windowNumber.String()); + BBitmap* map = new BBitmap(bounds, colorspace); + char* bits; + ssize_t numbytes; + message->FindData("bits", B_RAW_TYPE, (const void**)&bits, &numbytes); + if (numbytes != bits_length) { + fprintf(stderr, "Hey, bits_length != num_bytes!!\n"); } - // canvasWindowFrame.PrintToStream(); - CanvasWindow *canvasWindow = new CanvasWindow (canvasWindowFrame, title); + memcpy(map->Bits(), bits, numbytes); + float newWidth = bounds.Width(); + float newHeight = bounds.Height(); + BRect canvasWindowFrame; + canvasWindowFrame.Set( + 128 + newnum * 16, 128 + newnum * 16, 128 + newnum * 16 + newWidth - 1, + 128 + newnum * 16 + newHeight - 1 + ); + CanvasWindow* canvasWindow = new CanvasWindow(canvasWindowFrame, title, map); delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (canvasWindow); + fCurrentScriptee = new BMessenger(canvasWindow); canvasWindow->Show(); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); + } + break; + } + case BBP_REQUEST_BBITMAP: // BeDC Hack for interaction with ImageElements + { + // Find the active Canvas Window + CanvasWindow* activeWin = NULL; + CanvasWindow* firstWin = NULL; + for (int i = 0; i < CountWindows(); i++) { + BWindow* win = WindowAt(i); + if (is_instance_of(win, CanvasWindow)) { + if (!firstWin) + firstWin = dynamic_cast(win); + if (win->IsActive()) + activeWin = dynamic_cast(win); } - break; } - case 'open': - openPanel->Show(); // Don't ask. - openPanel->Show(); - break; - case 'opnR': // open Recent + if (!activeWin) // No active window? Hmmm. { - entry_ref ref; - if (message->FindRef ("ref", &ref) == B_NO_ERROR) + if (firstWin) { + activeWin = firstWin; // Just take the first Canvas Window you found. + } else // no canvas windows at all! { - BEntry entry; - if ((entry.SetTo (&ref, true) == B_NO_ERROR) && entry.IsFile()) + fprintf(stderr, "No canvas windows open...\n"); + if (message->IsSourceWaiting()) // Disappoint our friend. { - bool AskForAlpha = true; - char buffer[1024]; - BNode node (&ref); - ssize_t s; - if ((s = node.ReadAttr ("BEOS:TYPE", B_STRING_TYPE, 0, buffer, 1022)) > 0) - { - buffer[s] = 0; - if (!strcmp (buffer, "application/x-sum-becasso.palette")) - { - BAlert *alert = new BAlert ("", lstring (6, "Please drop Becasso Palette files on the appropriate Color button or on the associated Color Editor window."), lstring (136, "OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); - alert->Go(); - break; - } - } - try - { - // message->PrintToStream(); - if (message->HasBool ("AskForAlpha")) - message->FindBool ("AskForAlpha", &AskForAlpha); - CanvasWindow *canvasWindow; - BRect canvasWindowFrame; - canvasWindowFrame.Set (100, 180, 500, 500); - canvasWindow = new CanvasWindow (canvasWindowFrame, ref, AskForAlpha); - delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (canvasWindow); - BScreen screen; - canvasWindowFrame = canvasWindow->Frame() & screen.Frame(); - canvasWindow->ResizeTo (canvasWindowFrame.Width(), canvasWindowFrame.Height()); - canvasWindow->Show(); - } - catch(...) - { - printf ("Caught in the act!\n"); - } + BMessage* reply = new BMessage(BBP_NO_WINDOWS); + message->SendReply(reply); + delete reply; } - else - { - char name[B_FILE_NAME_LENGTH]; - if (entry.GetName (name) == B_OK) - { - printf ("Couldn't find %s\n", name); + break; + } + } + message->AddString("hack", ""); + activeWin->MessageReceived(message); + break; + } + case BBP_REPLACE_BBITMAP: // This is a _copy_!!! + { + // printf ("Got to the main app...\n"); + BMessage realmessage; + if (message->FindMessage("message", &realmessage) == B_OK) { + const char* name; + if (message->FindString("name", &name) == B_OK) { + title.SetTo(name); + } else { + fNumberFormat.Format(windowNumber, newnum++); + title.SetToFormat("Untitled %s", windowNumber.String()); + } + BMessage archive; + if (realmessage.FindMessage("BBitmap", &archive) == B_OK) { + BBitmap* map = new BBitmap(&archive); + if (map->IsValid()) { + BMessenger ie; + message->FindMessenger("target", &ie); + float newWidth = map->Bounds().Width(); + float newHeight = map->Bounds().Height(); + BRect canvasWindowFrame; + canvasWindowFrame.Set( + 128 + newnum * 16, 128 + newnum * 16, 128 + newnum * 16 + newWidth - 1, + 128 + newnum * 16 + newHeight - 1 + ); + CanvasWindow* canvasWindow = + new CanvasWindow(canvasWindowFrame, title, map, &ie); + delete fCurrentScriptee; + fCurrentScriptee = new BMessenger(canvasWindow); + extern int SilentOperation; + canvasWindow->Minimize(SilentOperation >= 1); + canvasWindow->Show(); + BMessage* ok = new BMessage(BBP_BBITMAP_OPENED); + ok->AddMessenger("target", BMessenger(canvasWindow, NULL)); + if (realmessage.IsSourceWaiting()) { + realmessage.SendReply(ok); + } else { + ie.SendMessage(ok); } - else - { - printf ("Not a file?\n"); + delete ok; + float zoom; + if (realmessage.FindFloat("zoom", &zoom) == B_OK) { + BMessage* m = new BMessage('Mnnn'); + m->AddFloat("zoom", zoom); + canvasWindow->PostMessage(m); + delete m; } - // Not a file? + } else { + fprintf(stderr, "Invalid BBitmap\n"); + // Error } - } - else - { - printf ("No ref?\n"); - // No refs? + } else { + fprintf(stderr, "Message didn't contain a valid BBitmap\n"); + // Error } break; + } else { + // Fall through to BBP_OPEN_BBITMAP. + // Explanation: Becasso received a BBP_REPLACE_BBITMAP message itself, + // which doesn't make sense (which bitmap should be replaced?). + // Apart from simply erroring out, the most sensible thing to do would be + // opening the bitmap in a new window. } - case 'opnf': - { + } + case BBP_OPEN_BBITMAP: { + // printf ("BBP_OPEN_BBITMAP\n"); + if (launching) { + launchMessage = new BMessage(*message); + } else { + const char* name; + if (message->FindString("name", &name) == B_OK) { + title.SetTo(name); + } else { + fNumberFormat.Format(windowNumber, newnum++); + title.SetToFormat("Untitled %s", windowNumber.String()); + } + BMessage archive; entry_ref ref; - openPanel->Hide(); - if (message->FindRef ("refs", &ref) == B_NO_ERROR) - { + if (message->FindMessage("BBitmap", &archive) == B_OK) { + BBitmap* map = new BBitmap(&archive); + if (map->IsValid()) { + BMessenger ie; + message->FindMessenger("target", &ie); + float newWidth = map->Bounds().Width(); + float newHeight = map->Bounds().Height(); + BRect canvasWindowFrame; + canvasWindowFrame.Set( + 128 + newnum * 16, 128 + newnum * 16, 128 + newnum * 16 + newWidth - 1, + 128 + newnum * 16 + newHeight - 1 + ); + CanvasWindow* canvasWindow = + new CanvasWindow(canvasWindowFrame, title, map, &ie); + delete fCurrentScriptee; + fCurrentScriptee = new BMessenger(canvasWindow); + extern int SilentOperation; + canvasWindow->Minimize(SilentOperation >= 1); + canvasWindow->Show(); + BMessage* ok = new BMessage(BBP_BBITMAP_OPENED); + ok->AddMessenger("target", BMessenger(canvasWindow, NULL)); + if (message->IsSourceWaiting()) { + message->SendReply(ok); + } else { + ie.SendMessage(ok); + } + delete ok; + float zoom; + if (message->FindFloat("zoom", &zoom) == B_OK) { + BMessage* m = new BMessage('Mnnn'); + m->AddFloat("zoom", zoom); + canvasWindow->PostMessage(m); + delete m; + } + } else { + fprintf(stderr, "Invalid BBitmap\n"); + // Error + } + } else if (message->FindRef("ref", &ref) == B_OK) { BEntry entry; - if ((entry.SetTo (&ref, true) == B_NO_ERROR) && entry.IsFile()) - { + if ((entry.SetTo(&ref, true) == B_NO_ERROR) && entry.IsFile()) { bool AskForAlpha = true; char buffer[1024]; - BNode node = BNode (&ref); + BNode node = BNode(&ref); ssize_t s; - if ((s = node.ReadAttr ("BEOS:TYPE", B_STRING_TYPE, 0, buffer, 1022)) > 0) - { + if ((s = node.ReadAttr("BEOS:TYPE", B_STRING_TYPE, 0, buffer, 1022)) > 0) { buffer[s] = 0; - if (!strcmp (buffer, "application/x-sum-becasso.palette")) - { - BAlert *alert = new BAlert ("", lstring (6, "Please drop Becasso Palette files on the appropriate Color button or on the associated Color Editor window."), lstring (136, "OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); + if (!strcmp(buffer, "application/x-sum-becasso.palette")) { + BAlert* alert = new BAlert( + "", + lstring( + 6, "Please drop Becasso Palette files on the appropriate Color " + "button or on the associated Color Editor window." + ), + lstring(136, "OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT + ); alert->Go(); break; } } - try - { + try { + BMessenger ie; + message->FindMessenger("target", &ie); // message->PrintToStream(); - if (message->HasBool ("AskForAlpha")) - message->FindBool ("AskForAlpha", &AskForAlpha); - CanvasWindow *canvasWindow; + if (message->HasBool("AskForAlpha")) + message->FindBool("AskForAlpha", &AskForAlpha); + CanvasWindow* canvasWindow; BRect canvasWindowFrame; - canvasWindowFrame.Set (100, 180, 500, 500); - canvasWindow = new CanvasWindow (canvasWindowFrame, ref, AskForAlpha); + canvasWindowFrame.Set(100, 180, 500, 500); + canvasWindow = new CanvasWindow(canvasWindowFrame, ref, AskForAlpha, &ie); delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (canvasWindow); + fCurrentScriptee = new BMessenger(canvasWindow); BScreen screen; canvasWindowFrame = canvasWindow->Frame() & screen.Frame(); - canvasWindow->ResizeTo (canvasWindowFrame.Width(), canvasWindowFrame.Height()); + canvasWindow->ResizeTo( + canvasWindowFrame.Width(), canvasWindowFrame.Height() + ); extern int SilentOperation; - canvasWindow->Minimize (SilentOperation >= 1); + canvasWindow->Minimize(SilentOperation >= 1); canvasWindow->Show(); - } - catch(...) - { - printf ("Caught in the act!\n"); + BMessage* ok = new BMessage(BBP_BBITMAP_OPENED); + ok->AddMessenger("target", BMessenger(canvasWindow, NULL)); + if (message->IsSourceWaiting()) { + message->SendReply(ok); + } else { + ie.SendMessage(ok); + } + delete ok; + float zoom; + if (message->FindFloat("zoom", &zoom) == B_OK) { + BMessage* m = new BMessage('Mnnn'); + m->AddFloat("zoom", zoom); + canvasWindow->PostMessage(m); + delete m; + } + } catch (...) { + printf("Caught in the act!\n"); break; } - } - else - { + } else { char name[B_FILE_NAME_LENGTH]; - if (entry.GetName (name) == B_OK) - { - printf ("Couldn't find %s\n", name); - } - else - { - printf ("Not a file?\n"); + if (entry.GetName(name) == B_OK) { + printf("Couldn't find %s\n", name); + } else { + printf("Not a file?\n"); } // Not a file? } + } else { + fprintf(stderr, "Message didn't contain a valid BBitmap or ref\n"); + // Error } - else - { - printf ("No refs?\n"); - // No refs? - } - break; } - case 'aliv': // Sent by CanvasWindow itself, due to scripting AskForAlpha switch - { - BMessenger msgr; - message->FindMessenger ("canvas", &msgr); - message->AddInt32 ("which", 1); - msgr.SendMessage (message); - break; - } - case 'SPst': - { - BWindow *win; - for (int i = 1; i < CountWindows(); i++) - { - win = WindowAt (i); - if (is_instance_of (win, CanvasWindow)) - win->PostMessage (message); - } - break; - } - case 'clrX': // color changed - warn all the windows - { - BWindow *win; - for (int i = 1; i < CountWindows(); i++) - { - win = WindowAt (i); - if (is_instance_of (win, CanvasWindow)) - win->PostMessage (message); - } - break; - } - case 0: // Icon dropped from FileTypes (yes, 0!!) - { - BMessage msg; - if (message->FindMessage ("icon/large", &msg) == B_OK) - { - BBitmap *map = new BBitmap (&msg); - if (map->IsValid()) - { - char title[MAXTITLE]; - sprintf (title, "%s (Icon) %i", lstring (149, "Untitled"), newnum++); - float newWidth = map->Bounds().Width(); - float newHeight = map->Bounds().Height(); - BRect canvasWindowFrame; - canvasWindowFrame.Set (128 + newnum*16, 128 + newnum*16, - 128 + newnum*16 + newWidth - 1, 128 + newnum*16 + newHeight - 1); - CanvasWindow *canvasWindow = new CanvasWindow (canvasWindowFrame, title, map); - delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (canvasWindow); - canvasWindow->Show(); - BMessage *m = new BMessage ('M4'); - canvasWindow->PostMessage (m); - delete m; - m = new BMessage ('rstf'); - canvasWindow->PostMessage (m); - delete m; - } - else - { - fprintf (stderr, "Invalid BBitmap\n"); - // Error - } - } - if (message->FindMessage ("icon/mini", &msg) == B_OK) - { - BBitmap *map = new BBitmap (&msg); - if (map->IsValid()) - { - char title[MAXTITLE]; - sprintf (title, "%s (MIcon) %i", lstring (149, "Untitled"), newnum++); - float newWidth = map->Bounds().Width(); - float newHeight = map->Bounds().Height(); + break; + } + case 'capt': { + extern BList* AddOns; + AddOn* addon; + int32 index; + message->FindInt32("index", &index); + addon = (AddOn*)AddOns->ItemAt(index); + addon->Open(NULL, NULL); + break; + } + case CAPTURE_READY: { + printf("Capturing...\n"); + extern BList* AddOns; + AddOn* addon; + int32 index; + if (message->FindInt32("index", &index) == B_OK) { + addon = (AddOn*)AddOns->ItemAt(index); + title = '0'; + // printf ("Calling Bitmap...\n"); + BString titleCopy = title; + char* mutableTitle = titleCopy.LockBuffer(titleCopy.Length() + 1); + strncpy(mutableTitle, titleCopy.String(), titleCopy.Length() + 1); + titleCopy.UnlockBuffer(); + BBitmap* map = addon->Bitmap(mutableTitle); + + // printf ("Got it!\n"); + BString windowNumber; + if (map) { + if (map->IsValid()) { + if (!title[0]) { + fNumberFormat.Format(windowNumber, newnum++); + title.SetToFormat("Untitled %s", windowNumber.String()); + } BRect canvasWindowFrame; - canvasWindowFrame.Set (128 + newnum*16, 128 + newnum*16, - 128 + newnum*16 + newWidth - 1, 128 + newnum*16 + newHeight - 1); - CanvasWindow *canvasWindow = new CanvasWindow (canvasWindowFrame, title, map); + canvasWindowFrame.Set( + 128 + newnum * 16, 128 + newnum * 16, + 128 + newnum * 16 + map->Bounds().Width(), + 128 + newnum * 16 + map->Bounds().Height() + ); + CanvasWindow* canvasWindow = new CanvasWindow(canvasWindowFrame, title, map); delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (canvasWindow); + fCurrentScriptee = new BMessenger(canvasWindow); + extern int SilentOperation; + canvasWindow->Minimize(SilentOperation >= 1); canvasWindow->Show(); - BMessage *m = new BMessage ('M4'); - canvasWindow->PostMessage (m); - delete m; - m = new BMessage ('rstf'); - canvasWindow->PostMessage (m); - delete m; - } - else - { - fprintf (stderr, "Invalid BBitmap\n"); - // Error - } - } - break; - } - case 'PPNT': // RRaster drop - { - if (launching) - { - launchMessage = new BMessage (*message); - } - else - { - BRect bounds; - color_space colorspace; - ssize_t bits_length; - message->FindRect ("bounds", &bounds); - message->FindInt32 ("bits_length", (int32 *) &bits_length); - message->FindInt32 ("color_space", (int32 *) &colorspace); - char title[MAXTITLE]; - sprintf (title, "%s (RRaster) %i", lstring (149, "Untitled"), newnum++); - BBitmap *map = new BBitmap (bounds, colorspace); - char *bits; - ssize_t numbytes; - message->FindData ("bits", B_RAW_TYPE, (const void **) &bits, &numbytes); - if (numbytes != bits_length) - { - fprintf (stderr, "Hey, bits_length != num_bytes!!\n"); - } - memcpy (map->Bits(), bits, numbytes); - float newWidth = bounds.Width(); - float newHeight = bounds.Height(); - BRect canvasWindowFrame; - canvasWindowFrame.Set (128 + newnum*16, 128 + newnum*16, - 128 + newnum*16 + newWidth - 1, 128 + newnum*16 + newHeight - 1); - CanvasWindow *canvasWindow = new CanvasWindow (canvasWindowFrame, title, map); - delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (canvasWindow); - canvasWindow->Show(); - } - break; - } - case BBP_REQUEST_BBITMAP: // BeDC Hack for interaction with ImageElements - { - // Find the active Canvas Window - CanvasWindow *activeWin = NULL; - CanvasWindow *firstWin = NULL; - for (int i = 0; i < CountWindows(); i++) - { - BWindow *win = WindowAt(i); - if (is_instance_of (win, CanvasWindow)) - { - if (!firstWin) - firstWin = dynamic_cast (win); - if (win->IsActive()) - activeWin = dynamic_cast (win); - } - } - if (!activeWin) // No active window? Hmmm. - { - if (firstWin) - { - activeWin = firstWin; // Just take the first Canvas Window you found. - } - else // no canvas windows at all! - { - fprintf (stderr, "No canvas windows open...\n"); - if (message->IsSourceWaiting()) // Disappoint our friend. - { - BMessage *reply = new BMessage (BBP_NO_WINDOWS); - message->SendReply (reply); - delete reply; - } - break; - } - } - message->AddString ("hack", ""); - activeWin->MessageReceived (message); - break; - } - case BBP_REPLACE_BBITMAP: // This is a _copy_!!! - { - // printf ("Got to the main app...\n"); - BMessage realmessage; - if (message->FindMessage ("message", &realmessage) == B_OK) - { - char title[MAXTITLE]; - const char *name; - if (message->FindString ("name", &name) == B_OK) - strcpy (title, name); - else - sprintf (title, "%s %i", lstring (149, "Untitled"), newnum++); - BMessage archive; - if (realmessage.FindMessage ("BBitmap", &archive) == B_OK) - { - BBitmap *map = new BBitmap (&archive); - if (map->IsValid()) - { - BMessenger ie; - message->FindMessenger ("target", &ie); - float newWidth = map->Bounds().Width(); - float newHeight = map->Bounds().Height(); - BRect canvasWindowFrame; - canvasWindowFrame.Set (128 + newnum*16, 128 + newnum*16, - 128 + newnum*16 + newWidth - 1, 128 + newnum*16 + newHeight - 1); - CanvasWindow *canvasWindow = new CanvasWindow (canvasWindowFrame, title, map, &ie); - delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (canvasWindow); - extern int SilentOperation; - canvasWindow->Minimize (SilentOperation >= 1); - canvasWindow->Show(); - BMessage *ok = new BMessage (BBP_BBITMAP_OPENED); - ok->AddMessenger ("target", BMessenger (canvasWindow, NULL)); - if (realmessage.IsSourceWaiting()) - { - realmessage.SendReply (ok); - } - else - { - ie.SendMessage (ok); - } - delete ok; - float zoom; - if (realmessage.FindFloat ("zoom", &zoom) == B_OK) - { - BMessage *m = new BMessage ('Mnnn'); - m->AddFloat ("zoom", zoom); - canvasWindow->PostMessage (m); - delete m; - } - } - else - { - fprintf (stderr, "Invalid BBitmap\n"); - // Error - } - } - else - { - fprintf (stderr, "Message didn't contain a valid BBitmap\n"); + } else { + fprintf(stderr, "Capture Error: Invalid BBitmap\n"); // Error } - break; - } - else + } else // map == NULL => Canceled { - // Fall through to BBP_OPEN_BBITMAP. - // Explanation: Becasso received a BBP_REPLACE_BBITMAP message itself, - // which doesn't make sense (which bitmap should be replaced?). - // Apart from simply erroring out, the most sensible thing to do would be - // opening the bitmap in a new window. } + } else { + fprintf( + stderr, "Error: Your capture add-on asked for a grab, but didn't identify itself.\n" + ); + fprintf( + stderr, + " You should AddInt32(\"index\", &index) to the CAPTURE_READY message.\n" + ); } - case BBP_OPEN_BBITMAP: - { - //printf ("BBP_OPEN_BBITMAP\n"); - if (launching) - { - launchMessage = new BMessage (*message); - } - else - { - char title[MAXTITLE]; - const char *name; - if (message->FindString ("name", &name) == B_OK) - strcpy (title, name); - else - sprintf (title, "%s %i", lstring (149, "Untitled"), newnum++); - BMessage archive; - entry_ref ref; - if (message->FindMessage ("BBitmap", &archive) == B_OK) - { - BBitmap *map = new BBitmap (&archive); - if (map->IsValid()) - { - BMessenger ie; - message->FindMessenger ("target", &ie); - float newWidth = map->Bounds().Width(); - float newHeight = map->Bounds().Height(); - BRect canvasWindowFrame; - canvasWindowFrame.Set (128 + newnum*16, 128 + newnum*16, - 128 + newnum*16 + newWidth - 1, 128 + newnum*16 + newHeight - 1); - CanvasWindow *canvasWindow = new CanvasWindow (canvasWindowFrame, title, map, &ie); - delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (canvasWindow); - extern int SilentOperation; - canvasWindow->Minimize (SilentOperation >= 1); - canvasWindow->Show(); - BMessage *ok = new BMessage (BBP_BBITMAP_OPENED); - ok->AddMessenger ("target", BMessenger (canvasWindow, NULL)); - if (message->IsSourceWaiting()) - { - message->SendReply (ok); - } - else - { - ie.SendMessage (ok); - } - delete ok; - float zoom; - if (message->FindFloat ("zoom", &zoom) == B_OK) - { - BMessage *m = new BMessage ('Mnnn'); - m->AddFloat ("zoom", zoom); - canvasWindow->PostMessage (m); - delete m; - } - } - else - { - fprintf (stderr, "Invalid BBitmap\n"); - // Error - } - } - else if (message->FindRef ("ref", &ref) == B_OK) - { - BEntry entry; - if ((entry.SetTo (&ref, true) == B_NO_ERROR) && entry.IsFile()) - { - bool AskForAlpha = true; - char buffer[1024]; - BNode node = BNode (&ref); - ssize_t s; - if ((s = node.ReadAttr ("BEOS:TYPE", B_STRING_TYPE, 0, buffer, 1022)) > 0) - { - buffer[s] = 0; - if (!strcmp (buffer, "application/x-sum-becasso.palette")) - { - BAlert *alert = new BAlert ("", lstring (6, "Please drop Becasso Palette files on the appropriate Color button or on the associated Color Editor window."), lstring (136, "OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); - alert->Go(); - break; - } - } - try - { - BMessenger ie; - message->FindMessenger ("target", &ie); - // message->PrintToStream(); - if (message->HasBool ("AskForAlpha")) - message->FindBool ("AskForAlpha", &AskForAlpha); - CanvasWindow *canvasWindow; - BRect canvasWindowFrame; - canvasWindowFrame.Set (100, 180, 500, 500); - canvasWindow = new CanvasWindow (canvasWindowFrame, ref, AskForAlpha, &ie); - delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (canvasWindow); - BScreen screen; - canvasWindowFrame = canvasWindow->Frame() & screen.Frame(); - canvasWindow->ResizeTo (canvasWindowFrame.Width(), canvasWindowFrame.Height()); - extern int SilentOperation; - canvasWindow->Minimize (SilentOperation >= 1); - canvasWindow->Show(); - BMessage *ok = new BMessage (BBP_BBITMAP_OPENED); - ok->AddMessenger ("target", BMessenger (canvasWindow, NULL)); - if (message->IsSourceWaiting()) - { - message->SendReply (ok); - } - else - { - ie.SendMessage (ok); - } - delete ok; - float zoom; - if (message->FindFloat ("zoom", &zoom) == B_OK) - { - BMessage *m = new BMessage ('Mnnn'); - m->AddFloat ("zoom", zoom); - canvasWindow->PostMessage (m); - delete m; - } - } - catch(...) - { - printf ("Caught in the act!\n"); - break; - } - } - else - { - char name[B_FILE_NAME_LENGTH]; - if (entry.GetName (name) == B_OK) - { - printf ("Couldn't find %s\n", name); - } - else - { - printf ("Not a file?\n"); - } - // Not a file? - } - } - else - { - fprintf (stderr, "Message didn't contain a valid BBitmap or ref\n"); - // Error - } + break; + } + case 'PrSU': { + PrintSetup(); + break; + } + case 'prfs': { + PrefsWindow* prefsWindow = new PrefsWindow(); + prefsWindow->Show(); + break; + } + case B_CREATE_PROPERTY: { + // message->PrintToStream(); + switch (fCurrentProperty) { + case PROP_CANVAS: { + // message->PrintToStream(); + fNumberFormat.Format(windowNumber, newnum++); + title.SetToFormat("Untitled %s", windowNumber.String()); + BRect canvasWindowFrame; + canvasWindowFrame.Set( + 128 + newnum * 16, 128 + newnum * 16, 128 + newnum * 16 + 255, + 128 + newnum * 16 + 255 + ); + + const char* namestring; + if (message->FindString("Name", &namestring) == B_OK || + message->FindString("name", &namestring) == B_OK) { + title.SetTo(namestring); } - break; - } - case 'capt': - { - extern BList *AddOns; - AddOn *addon; - int32 index; - message->FindInt32 ("index", &index); - addon = (AddOn *) AddOns->ItemAt (index); - addon->Open (NULL, NULL); - break; - } - case CAPTURE_READY: - { - printf ("Capturing...\n"); - extern BList *AddOns; - AddOn *addon; - int32 index; - if (message->FindInt32 ("index", &index) == B_OK) - { - addon = (AddOn *) AddOns->ItemAt (index); - char title[MAXTITLE]; - title[0] = '0'; - //printf ("Calling Bitmap...\n"); - BBitmap *map = addon->Bitmap (title); - //printf ("Got it!\n"); - if (map) - { - if (map->IsValid()) - { - if (!title[0]) - sprintf (title, "%s %i", lstring (149, "Untitled"), newnum++); - BRect canvasWindowFrame; - canvasWindowFrame.Set (128 + newnum*16, 128 + newnum*16, - 128 + newnum*16 + map->Bounds().Width(), 128 + newnum*16 + map->Bounds().Height()); - CanvasWindow *canvasWindow = new CanvasWindow (canvasWindowFrame, title, map); - delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (canvasWindow); - extern int SilentOperation; - canvasWindow->Minimize (SilentOperation >= 1); - canvasWindow->Show(); - } - else - { - fprintf (stderr, "Capture Error: Invalid BBitmap\n"); - // Error - } - } - else // map == NULL => Canceled - { - } + + BRect rect; + if (message->FindRect("Size", &rect) == B_OK || + message->FindRect("size", &rect) == B_OK) { + canvasWindowFrame = rect; } - else - { - fprintf (stderr, "Error: Your capture add-on asked for a grab, but didn't identify itself.\n"); - fprintf (stderr, " You should AddInt32(\"index\", &index) to the CAPTURE_READY message.\n"); + + // canvasWindowFrame.PrintToStream(); + CanvasWindow* canvasWindow = new CanvasWindow(canvasWindowFrame, title); + delete fCurrentScriptee; + fCurrentScriptee = new BMessenger(canvasWindow); + extern int SilentOperation; + canvasWindow->Minimize(SilentOperation >= 1); + canvasWindow->Show(); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } break; } - case 'PrSU': - { - PrintSetup(); - break; - } - case 'prfs': - { - PrefsWindow *prefsWindow = new PrefsWindow(); - prefsWindow->Show(); + default: + inherited::MessageReceived(message); break; } - case B_CREATE_PROPERTY: - { - // message->PrintToStream(); - switch (fCurrentProperty) - { - case PROP_CANVAS: - { - //message->PrintToStream(); - char title[MAXTITLE]; - sprintf (title, "%s %i", lstring (149, "Untitled"), newnum++); - BRect canvasWindowFrame; - canvasWindowFrame.Set (128 + newnum*16, 128 + newnum*16, - 128 + newnum*16 + 255, 128 + newnum*16 + 255); - - const char *namestring; - if (message->FindString ("Name", &namestring) == B_OK - || message->FindString ("name", &namestring) == B_OK) - { - strcpy (title, namestring); - } - - BRect rect; - if (message->FindRect ("Size", &rect) == B_OK - || message->FindRect ("size", &rect) == B_OK) - { - canvasWindowFrame = rect; - } - - // canvasWindowFrame.PrintToStream(); - CanvasWindow *canvasWindow = new CanvasWindow (canvasWindowFrame, title); - delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (canvasWindow); - extern int SilentOperation; - canvasWindow->Minimize (SilentOperation >= 1); - canvasWindow->Show(); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } - break; - } - default: - inherited::MessageReceived (message); - break; - } + break; + } + case B_COUNT_PROPERTIES: { + switch (fCurrentProperty) { + case PROP_TOOL: { + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_NO_ERROR); + reply.AddInt32("result", NumTools); + message->SendReply(&reply); + } else + fprintf(stderr, "Number of Tools: %ld\n", NumTools); break; } - case B_COUNT_PROPERTIES: - { - switch (fCurrentProperty) - { - case PROP_TOOL: - { - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddInt32 ("error", B_NO_ERROR); - reply.AddInt32 ("result", NumTools); - message->SendReply (&reply); - } - else - fprintf (stderr, "Number of Tools: %ld\n", NumTools); - break; - } - case PROP_MODE: - { - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddInt32 ("error", B_NO_ERROR); - reply.AddInt32 ("result", NumModes); - message->SendReply (&reply); - } - else - fprintf (stderr, "Number of Modes: %ld\n", NumModes); - break; - } - default: - inherited::MessageReceived (message); - } - fCurrentProperty = 0; + case PROP_MODE: { + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_NO_ERROR); + reply.AddInt32("result", NumModes); + message->SendReply(&reply); + } else + fprintf(stderr, "Number of Modes: %ld\n", NumModes); break; } - case B_GET_SUPPORTED_SUITES: - { - switch (fCurrentProperty) - { - case PROP_TOOL: - { - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddInt32 ("error", B_NO_ERROR); - char str[256]; - for (int i = 0; i < NumTools; i++) - { - sprintf (str, "suite/x-sum-becasso-%s", ToolSpecifiers[i]); - reply.AddString ("suites", str); - } - message->SendReply (&reply); - } - else - { - fprintf (stderr, "Available Tools:\n"); - for (int i = 0; i < NumTools; i++) - fprintf (stderr, "%s\n", ToolSpecifiers[i]); - } - break; - } - case PROP_MODE: - { - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddInt32 ("error", B_NO_ERROR); - char str[256]; - for (int i = 0; i < NumModes; i++) - { - sprintf (str, "suite/x-sum-becasso-%s", ModeSpecifiers[i]); - reply.AddString ("suites", str); - } - message->SendReply (&reply); - } - else - { - fprintf (stderr, "Available Modes:\n"); - for (int i = 0; i < NumModes; i++) - fprintf (stderr, "%s\n", ModeSpecifiers[i]); - } - break; + default: + inherited::MessageReceived(message); + } + fCurrentProperty = 0; + break; + } + case B_GET_SUPPORTED_SUITES: { + switch (fCurrentProperty) { + case PROP_TOOL: { + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_NO_ERROR); + char str[256]; + for (int i = 0; i < NumTools; i++) { + sprintf(str, "suite/x-sum-becasso-%s", ToolSpecifiers[i]); + reply.AddString("suites", str); + } + message->SendReply(&reply); + } else { + fprintf(stderr, "Available Tools:\n"); + for (int i = 0; i < NumTools; i++) + fprintf(stderr, "%s\n", ToolSpecifiers[i]); } - default: - inherited::MessageReceived (message); + break; + } + case PROP_MODE: { + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_NO_ERROR); + char str[256]; + for (int i = 0; i < NumModes; i++) { + sprintf(str, "suite/x-sum-becasso-%s", ModeSpecifiers[i]); + reply.AddString("suites", str); + } + message->SendReply(&reply); + } else { + fprintf(stderr, "Available Modes:\n"); + for (int i = 0; i < NumModes; i++) + fprintf(stderr, "%s\n", ModeSpecifiers[i]); } - fCurrentProperty = 0; break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_TOOL: - { - const char *namespecifier; - int32 numberspecifier; - if (message->FindString ("data", &namespecifier) == B_OK) - { - int index; - for (index = 0; index < NumTools; index++) - { - if (!strcasecmp (ToolSpecifiers[index], namespecifier)) - { - extern PicMenuButton *tool; - tool->set (index); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } - break; - } - } - if (index == NumTools) - { - char errstring[256]; - sprintf (errstring, "Invalid Tool Name: ""%s""", namespecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); - } - break; - } - else if (message->FindInt32 ("data", &numberspecifier) == B_OK) - { - if (0 <= numberspecifier && numberspecifier < NumTools) - { - extern PicMenuButton *tool; - tool->set (numberspecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); + default: + inherited::MessageReceived(message); + } + fCurrentProperty = 0; + break; + } + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_TOOL: { + const char* namespecifier; + int32 numberspecifier; + if (message->FindString("data", &namespecifier) == B_OK) { + int index; + for (index = 0; index < NumTools; index++) { + if (!strcasecmp(ToolSpecifiers[index], namespecifier)) { + extern PicMenuButton* tool; + tool->set(index); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } break; } - else - { - char errstring[256]; - sprintf (errstring, "Tool Index Out of Range [0..%ld]: %ld", NumTools - 1, numberspecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); - } } - else - { + if (index == NumTools) { char errstring[256]; - sprintf (errstring, "Invalid Tool Type (either string or int32 please)"); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + sprintf( + errstring, + "Invalid Tool Name: " + "%s" + "", + namespecifier + ); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); } break; - } - case PROP_MODE: - { - const char *namespecifier; - int32 numberspecifier; - if (message->FindString ("data", &namespecifier) == B_OK) - { - int index; - for (index = 0; index < NumModes; index++) - { - if (!strcasecmp (ModeSpecifiers[index], namespecifier)) - { - extern PicMenuButton *mode; - mode->set (index); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } - break; - } - } - if (index == NumModes) - { - char errstring[256]; - sprintf (errstring, "Invalid Mode Name: ""%s""", namespecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + } else if (message->FindInt32("data", &numberspecifier) == B_OK) { + if (0 <= numberspecifier && numberspecifier < NumTools) { + extern PicMenuButton* tool; + tool->set(numberspecifier); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } break; - } - else if (message->FindInt32 ("data", &numberspecifier) == B_OK) - { - if (0 <= numberspecifier && numberspecifier < NumModes) - { - extern PicMenuButton *mode; - mode->set (numberspecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); + } else { + BString numberToolsData, numberSpecifierData, errorString; + fNumberFormat.Format(numberToolsData, NumTools - 1); + fNumberFormat.Format(numberSpecifierData, numberspecifier); + errorString.SetToFormat( + "Tool index out of range [0..%s]: %s", numberToolsData.String(), + numberSpecifierData.String() + ); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errorString.String()); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errorString.String()); + } + } else { + char errstring[256]; + sprintf(errstring, "Invalid Tool Type (either string or int32 please)"); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); + } + break; + } + case PROP_MODE: { + const char* namespecifier; + int32 numberspecifier; + if (message->FindString("data", &namespecifier) == B_OK) { + int index; + for (index = 0; index < NumModes; index++) { + if (!strcasecmp(ModeSpecifiers[index], namespecifier)) { + extern PicMenuButton* mode; + mode->set(index); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } break; } - else - { - char errstring[256]; - sprintf (errstring, "Mode Index Out of Range [0..%ld]: %ld", NumTools - 1, numberspecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); - } } - else - { + if (index == NumModes) { char errstring[256]; - sprintf (errstring, "Invalid Mode Type (either string or int32 please)"); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + sprintf( + errstring, + "Invalid Mode Name: " + "%s" + "", + namespecifier + ); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); } break; - } - case PROP_FGCOLOR: - { - // printf ("Setting FG Color\n"); - const char *namespecifier; - rgb_color *rgbspecifier; - long dummy; - if (message->FindString ("data", &namespecifier) == B_OK) - { - rgb_color rgb; - int i; - for (i = 0; i < NumColors; i++) - { - if (!strcasecmp (namespecifier, (const char *)&(RGBColors[i][3]))) - { - rgb.red = RGBColors[i][0]; - rgb.green = RGBColors[i][1]; - rgb.blue = RGBColors[i][2]; - break; - } - } - if (i == NumColors) - { - char errstring[256]; - sprintf (errstring, "Unknown Named Color: ""%s""", namespecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); - break; - } - else - { - extern ColorMenuButton *hicolor; - hicolor->set (rgb); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } + } else if (message->FindInt32("data", &numberspecifier) == B_OK) { + if (0 <= numberspecifier && numberspecifier < NumModes) { + extern PicMenuButton* mode; + mode->set(numberspecifier); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } break; - } - else if (message->FindData ("data", B_RGB_COLOR_TYPE, (const void **) &rgbspecifier, &dummy) == B_OK) - { - extern ColorMenuButton *hicolor; - hicolor->set (*rgbspecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); + } else { + char errstring[256]; + sprintf( + errstring, "Mode Index Out of Range [0..%ld]: %ld", NumTools - 1, + numberspecifier + ); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); + } + } else { + char errstring[256]; + sprintf(errstring, "Invalid Mode Type (either string or int32 please)"); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); + } + break; + } + case PROP_FGCOLOR: { + // printf ("Setting FG Color\n"); + const char* namespecifier; + rgb_color* rgbspecifier; + long dummy; + if (message->FindString("data", &namespecifier) == B_OK) { + rgb_color rgb; + int i; + for (i = 0; i < NumColors; i++) { + if (!strcasecmp(namespecifier, (const char*)&(RGBColors[i][3]))) { + rgb.red = RGBColors[i][0]; + rgb.green = RGBColors[i][1]; + rgb.blue = RGBColors[i][2]; + break; } - break; } - else - { + if (i == NumColors) { char errstring[256]; - sprintf (errstring, "Invalid Color Type (either string or rgb_color please)"); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); + sprintf( + errstring, + "Unknown Named Color: " + "%s" + "", + namespecifier + ); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); + break; + } else { + extern ColorMenuButton* hicolor; + hicolor->set(rgb); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } - else - fprintf (stderr, "%s\n", errstring); } break; + } else if (message->FindData("data", B_RGB_COLOR_TYPE, (const void**)&rgbspecifier, &dummy) == B_OK) { + extern ColorMenuButton* hicolor; + hicolor->set(*rgbspecifier); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); + } + break; + } else { + char errstring[256]; + sprintf(errstring, "Invalid Color Type (either string or rgb_color please)"); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); } - case PROP_BGCOLOR: - { - // printf ("Setting BG Color\n"); - const char *namespecifier; - rgb_color *rgbspecifier; - long dummy; - if (message->FindString ("data", &namespecifier) == B_OK) - { - rgb_color rgb; - int i; - for (i = 0; i < NumColors; i++) - { - if (!strcasecmp (namespecifier, (const char *)&(RGBColors[i][3]))) - { - rgb.red = RGBColors[i][0]; - rgb.green = RGBColors[i][1]; - rgb.blue = RGBColors[i][2]; - break; - } - } - if (i == NumColors) - { - char errstring[256]; - sprintf (errstring, "Unknown Named Color: ""%s""", namespecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + break; + } + case PROP_BGCOLOR: { + // printf ("Setting BG Color\n"); + const char* namespecifier; + rgb_color* rgbspecifier; + long dummy; + if (message->FindString("data", &namespecifier) == B_OK) { + rgb_color rgb; + int i; + for (i = 0; i < NumColors; i++) { + if (!strcasecmp(namespecifier, (const char*)&(RGBColors[i][3]))) { + rgb.red = RGBColors[i][0]; + rgb.green = RGBColors[i][1]; + rgb.blue = RGBColors[i][2]; break; } - else - { - extern ColorMenuButton *locolor; - locolor->set (rgb); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } - } - break; - } - else if (message->FindData ("data", B_RGB_COLOR_TYPE, (const void **) &rgbspecifier, &dummy) == B_OK) - { - extern ColorMenuButton *locolor; - locolor->set (*rgbspecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } - break; } - else - { + if (i == NumColors) { char errstring[256]; - sprintf (errstring, "Invalid Color Type (either string or rgb_color please)"); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); + sprintf( + errstring, + "Unknown Named Color: " + "%s" + "", + namespecifier + ); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); + break; + } else { + extern ColorMenuButton* locolor; + locolor->set(rgb); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } - else - fprintf (stderr, "%s\n", errstring); } break; - } - case PROP_EXPFMT: - { - // printf ("Setting Export Format...\n"); - // message->PrintToStream(); - int32 out_type; - const char *namedspecifier; - if (message->FindInt32 ("data", &out_type) == B_OK) - { - // char *s = (char *) &def_out_type; - // fprintf (stderr, "Current Default Export Type: '%c%c%c%c'\n", s[0], s[1], s[2], s[3]); + } else if (message->FindData("data", B_RGB_COLOR_TYPE, (const void**)&rgbspecifier, &dummy) == B_OK) { + extern ColorMenuButton* locolor; + locolor->set(*rgbspecifier); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } - else if (message->FindString ("data", &namedspecifier) == B_OK) - { - const char *s = namedspecifier; - uint32 type; - - //#if defined (__POWERPC__) - type = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]; - //#else - // type = (s[3] << 24) | (s[2] << 16) | (s[1] << 8) | s[0]; - //#endif - - out_type = 0; - translator_id *translators; - int32 num_translators; - - BTranslatorRoster::Default()->GetAllTranslators (&translators, &num_translators); - - for (int32 i=0; i < num_translators; i++) - { - const translation_format *fmts; - int32 num_fmts; - - BTranslatorRoster::Default()->GetOutputFormats (translators[i], &fmts, &num_fmts); - - for (int32 j=0; j < num_fmts; j++) - { - if (!strcasecmp (fmts[j].MIME, s)) - // Type was specified as MIME string - { - out_type = fmts[j].type; - def_out_translator = translators[i]; - } - else if (fmts[j].type == type) - // Type was specified as type code - { - out_type = type; - def_out_translator = translators[i]; - } - } - } - - if (!out_type) - { - char errstring[256]; - sprintf (errstring, "No Translator available for '%s'", s); - if (message->IsSourceWaiting()) + break; + } else { + char errstring[256]; + sprintf(errstring, "Invalid Color Type (either string or rgb_color please)"); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); + } + break; + } + case PROP_EXPFMT: { + // printf ("Setting Export Format...\n"); + // message->PrintToStream(); + int32 out_type; + const char* namedspecifier; + if (message->FindInt32("data", &out_type) == B_OK) { + // char *s = (char *) &def_out_type; + // fprintf (stderr, "Current Default Export Type: '%c%c%c%c'\n", s[0], s[1], s[2], + // s[3]); + } else if (message->FindString("data", &namedspecifier) == B_OK) { + const char* s = namedspecifier; + uint32 type; + + // #if defined (__POWERPC__) + type = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3]; + // #else + // type = (s[3] << 24) | (s[2] << 16) | (s[1] << 8) | s[0]; + // #endif + + out_type = 0; + translator_id* translators; + int32 num_translators; + + BTranslatorRoster::Default()->GetAllTranslators(&translators, &num_translators); + + for (int32 i = 0; i < num_translators; i++) { + const translation_format* fmts; + int32 num_fmts; + + BTranslatorRoster::Default()->GetOutputFormats( + translators[i], &fmts, &num_fmts + ); + + for (int32 j = 0; j < num_fmts; j++) { + if (!strcasecmp(fmts[j].MIME, s)) + // Type was specified as MIME string { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); - break; - } - else - { - def_out_type = out_type; - if (message->IsSourceWaiting()) + out_type = fmts[j].type; + def_out_translator = translators[i]; + } else if (fmts[j].type == type) + // Type was specified as type code { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); + out_type = type; + def_out_translator = translators[i]; } - break; } } - else - { + + if (!out_type) { char errstring[256]; - sprintf (errstring, "Invalid Export Format Type (either string or int32 please)"); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + sprintf(errstring, "No Translator available for '%s'", s); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); break; - } - } - case PROP_SCRIPTEE: - { - const char *namespecifier; - int32 indexspecifier; - if (message->FindString ("data", &namespecifier) == B_OK) - { - int32 i; - for (i = 0; i < CountWindows(); i++) - { - BWindow *win = WindowAt (i); - if (!strcmp (namespecifier, win->Title())) - { - delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (win); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } - break; - } - } - if (i == CountWindows()) - { - char errstring[256]; - sprintf (errstring, "Invalid Scriptee: Couldn't find window named '%s'", namespecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + } else { + def_out_type = out_type; + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } break; } - else if (message->FindInt32 ("data", &indexspecifier) == B_OK) - { - if ((indexspecifier >= 0) && (indexspecifier < CountWindows())) - { + } else { + char errstring[256]; + sprintf(errstring, "Invalid Export Format Type (either string or int32 please)"); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); + break; + } + } + case PROP_SCRIPTEE: { + const char* namespecifier; + int32 indexspecifier; + if (message->FindString("data", &namespecifier) == B_OK) { + int32 i; + for (i = 0; i < CountWindows(); i++) { + BWindow* win = WindowAt(i); + if (!strcmp(namespecifier, win->Title())) { delete fCurrentScriptee; - fCurrentScriptee = new BMessenger (WindowAt (indexspecifier)); - - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } - } - else - { - char errstring[256]; - sprintf (errstring, "Invalid Scriptee: Index %ld out of range [0..%ld]", indexspecifier, CountWindows() - 1); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); + fCurrentScriptee = new BMessenger(win); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } - else - fprintf (stderr, "%s\n", errstring); + break; } - break; } - else - { + if (i == CountWindows()) { char errstring[256]; - sprintf (errstring, "Invalid Scriptee Type (either named (string) or indexed (int32) please)"); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + sprintf( + errstring, "Invalid Scriptee: Couldn't find window named '%s'", + namespecifier + ); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); } break; - } - case PROP_TABLET: - { - BRect rect; - if (message->FindRect ("data", &rect) == B_OK) - { - extern Tablet *wacom; - if (wacom && wacom->IsValid()) - { - wacom->SetRect (rect); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } - } - else - { - char errstring[256]; - sprintf (errstring, "No tablet initialized (at the moment)"); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + } else if (message->FindInt32("data", &indexspecifier) == B_OK) { + if ((indexspecifier >= 0) && (indexspecifier < CountWindows())) { + delete fCurrentScriptee; + fCurrentScriptee = new BMessenger(WindowAt(indexspecifier)); + + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } - } - else - { + } else { char errstring[256]; - sprintf (errstring, "Invalid TabletArea type (BRect please)"); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + sprintf( + errstring, "Invalid Scriptee: Index %ld out of range [0..%ld]", + indexspecifier, CountWindows() - 1 + ); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); } break; + } else { + char errstring[256]; + sprintf( + errstring, + "Invalid Scriptee Type (either named (string) or indexed (int32) please)" + ); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); } - default: - inherited::MessageReceived (message); - } - fCurrentProperty = 0; break; } - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_TOOL: - { - extern PicMenuButton *tool; - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddInt32 ("error", B_NO_ERROR); - reply.AddSpecifier ("result", ToolSpecifiers[tool->selected()]); - message->SendReply (&reply); - } - else - fprintf (stderr, "Current Tool: ""%s""\n", ToolSpecifiers[tool->selected()]); - break; - } - case PROP_MODE: - { - extern PicMenuButton *mode; - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddInt32 ("error", B_NO_ERROR); - reply.AddSpecifier ("result", ModeSpecifiers[mode->selected()]); - message->SendReply (&reply); - } - else - fprintf (stderr, "Current Mode: ""%s""\n", ModeSpecifiers[mode->selected()]); - break; - } - case PROP_FGCOLOR: - { - extern ColorMenuButton *hicolor; - rgb_color rgb = hicolor->color(); - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddInt32 ("error", B_NO_ERROR); - reply.AddData ("result", B_RGB_COLOR_TYPE, &rgb, sizeof (rgb_color)); - message->SendReply (&reply); - } - else - fprintf (stderr, "Current Foreground Color: [Red: %3d Green: %3d Blue: %3d Alpha: %3d]\n", rgb.red, rgb.green, rgb.blue, rgb.alpha); - break; - } - case PROP_BGCOLOR: - { - extern ColorMenuButton *locolor; - rgb_color rgb = locolor->color(); - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddInt32 ("error", B_NO_ERROR); - reply.AddData ("result", B_RGB_COLOR_TYPE, &rgb, sizeof (rgb_color)); - message->SendReply (&reply); - } - else - fprintf (stderr, "Current Background Color: [Red: %3d Green: %3d Blue: %3d Alpha: %3d]\n", rgb.red, rgb.green, rgb.blue, rgb.alpha); - break; - } - case PROP_TABLET: - { - extern Tablet *wacom; - if (wacom && wacom->IsValid()) - { - BRect rect = wacom->GetRect(); - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddInt32 ("error", B_NO_ERROR); - reply.AddRect ("result", rect); - message->SendReply (&reply); + case PROP_TABLET: { + BRect rect; + if (message->FindRect("data", &rect) == B_OK) { + extern Tablet* wacom; + if (wacom && wacom->IsValid()) { + wacom->SetRect(rect); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } - else - fprintf (stderr, "Current Tablet Area: [left: %5.0f top: %5.0f right: %5.0f bottom: %5.0f]\n", rect.left, rect.top, rect.right, rect.bottom); - } - else - { + } else { char errstring[256]; - sprintf (errstring, "No tablet initialized (at the moment)"); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); - } + sprintf(errstring, "No tablet initialized (at the moment)"); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); + } + } else { + char errstring[256]; + sprintf(errstring, "Invalid TabletArea type (BRect please)"); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); } - case PROP_EXPFMT: - { - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddInt32 ("error", B_NO_ERROR); - reply.AddData ("result", B_INT32_TYPE, &def_out_type, sizeof (int32)); - message->SendReply (&reply); - } - else - { - char *s = (char *) &def_out_type; - #if defined (__POWERPC__) - fprintf (stderr, "Current Default Export Type: '%c%c%c%c'\n", s[0], s[1], s[2], s[3]); - #else - fprintf (stderr, "Current Default Export Type: '%c%c%c%c'\n", s[3], s[2], s[1], s[0]); - #endif - } - break; + break; + } + default: + inherited::MessageReceived(message); + } + fCurrentProperty = 0; + break; + } + case B_GET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_TOOL: { + extern PicMenuButton* tool; + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_NO_ERROR); + reply.AddSpecifier("result", ToolSpecifiers[tool->selected()]); + message->SendReply(&reply); + } else + fprintf( + stderr, + "Current Tool: " + "%s" + "\n", + ToolSpecifiers[tool->selected()] + ); + break; + } + case PROP_MODE: { + extern PicMenuButton* mode; + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_NO_ERROR); + reply.AddSpecifier("result", ModeSpecifiers[mode->selected()]); + message->SendReply(&reply); + } else + fprintf( + stderr, + "Current Mode: " + "%s" + "\n", + ModeSpecifiers[mode->selected()] + ); + break; + } + case PROP_FGCOLOR: { + extern ColorMenuButton* hicolor; + rgb_color rgb = hicolor->color(); + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_NO_ERROR); + reply.AddData("result", B_RGB_COLOR_TYPE, &rgb, sizeof(rgb_color)); + message->SendReply(&reply); + } else + fprintf( + stderr, + "Current Foreground Color: [Red: %3d Green: %3d Blue: %3d Alpha: %3d]\n", + rgb.red, rgb.green, rgb.blue, rgb.alpha + ); + break; + } + case PROP_BGCOLOR: { + extern ColorMenuButton* locolor; + rgb_color rgb = locolor->color(); + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_NO_ERROR); + reply.AddData("result", B_RGB_COLOR_TYPE, &rgb, sizeof(rgb_color)); + message->SendReply(&reply); + } else + fprintf( + stderr, + "Current Background Color: [Red: %3d Green: %3d Blue: %3d Alpha: %3d]\n", + rgb.red, rgb.green, rgb.blue, rgb.alpha + ); + break; + } + case PROP_TABLET: { + extern Tablet* wacom; + if (wacom && wacom->IsValid()) { + BRect rect = wacom->GetRect(); + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_NO_ERROR); + reply.AddRect("result", rect); + message->SendReply(&reply); + } else + fprintf( + stderr, + "Current Tablet Area: [left: %5.0f top: %5.0f right: %5.0f bottom: " + "%5.0f]\n", + rect.left, rect.top, rect.right, rect.bottom + ); + } else { + char errstring[256]; + sprintf(errstring, "No tablet initialized (at the moment)"); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); } - case PROP_SCRIPTEE: - { - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddInt32 ("error", B_NO_ERROR); - reply.AddData ("result", B_MESSENGER_TYPE, &fCurrentScriptee, sizeof (BMessenger)); - message->SendReply (&reply); - } - else - { - fprintf (stderr, "Scriptee %s. I'd return a BMessenger * as reply.\n", fCurrentScriptee ? "set" : "not set"); - } - break; + } + case PROP_EXPFMT: { + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_NO_ERROR); + reply.AddData("result", B_INT32_TYPE, &def_out_type, sizeof(int32)); + message->SendReply(&reply); + } else { + char* s = (char*)&def_out_type; +#if defined(__POWERPC__) + fprintf( + stderr, "Current Default Export Type: '%c%c%c%c'\n", s[0], s[1], s[2], s[3] + ); +#else + fprintf( + stderr, "Current Default Export Type: '%c%c%c%c'\n", s[3], s[2], s[1], s[0] + ); +#endif } - default: - // message->PrintToStream(); - inherited::MessageReceived (message); + break; + } + case PROP_SCRIPTEE: { + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_NO_ERROR); + reply.AddData("result", B_MESSENGER_TYPE, &fCurrentScriptee, sizeof(BMessenger)); + message->SendReply(&reply); + } else { + fprintf( + stderr, "Scriptee %s. I'd return a BMessenger * as reply.\n", + fCurrentScriptee ? "set" : "not set" + ); } - fCurrentProperty = 0; break; } default: - { // message->PrintToStream(); - inherited::MessageReceived (message); - break; + inherited::MessageReceived(message); } + fCurrentProperty = 0; + break; + } + default: { + // message->PrintToStream(); + inherited::MessageReceived(message); + break; + } } } -#if defined (__MWCC__) -# pragma optimization_level reset +#if defined(__MWCC__) +#pragma optimization_level reset #endif -void Becasso::Pulse () +void +Becasso::Pulse() { - if (fBusy) - { - SetCursor (cross[fBusy - 1]); - fBusy = fBusy%3 + 1; + if (fBusy) { + SetCursor(cross[fBusy - 1]); + fBusy = fBusy % 3 + 1; } BApplication::Pulse(); if (!CountWindows()) - PostMessage (B_QUIT_REQUESTED); + PostMessage(B_QUIT_REQUESTED); } -void Becasso::setHand () +void +Becasso::setHand() { fBusy = 0; - SetCursor (B_HAND_CURSOR); + SetCursor(B_HAND_CURSOR); fCurrentCursor = CURSOR_HAND; } -void Becasso::setGrab (bool b, bool down) +void +Becasso::setGrab(bool b, bool down) { - if (b && fCurrentCursor != CURSOR_OPEN_HAND) - { + if (b && fCurrentCursor != CURSOR_OPEN_HAND) { fBusySave = fBusy; fBusy = 0; - SetCursor (down ? grab : hand); + SetCursor(down ? grab : hand); fCurrentCursorSave = fCurrentCursor; fCurrentCursor = CURSOR_OPEN_HAND; - } - else if (b && fCurrentCursor == CURSOR_OPEN_HAND) - { - SetCursor (down ? grab : hand); - } - else if (!b && fCurrentCursor == CURSOR_OPEN_HAND) - { - switch (fCurrentCursorSave) - { + } else if (b && fCurrentCursor == CURSOR_OPEN_HAND) { + SetCursor(down ? grab : hand); + } else if (!b && fCurrentCursor == CURSOR_OPEN_HAND) { + switch (fCurrentCursorSave) { case CURSOR_HAND: setHand(); break; @@ -2661,7 +2401,7 @@ void Becasso::setGrab (bool b, bool down) setRotator(); break; case CURSOR_PICKER: - setCross(); //! + setCross(); //! break; default: break; @@ -2670,70 +2410,66 @@ void Becasso::setGrab (bool b, bool down) } } -void Becasso::setCross () +void +Becasso::setCross() { - extern PicMenuButton *mode; - if (mode->selected() == M_SELECT) - { - SetCursor (scross); + extern PicMenuButton* mode; + if (mode->selected() == M_SELECT) { + SetCursor(scross); fCurrentCursor = CURSOR_SELECT; - } - else - { - SetCursor (cross[0]); + } else { + SetCursor(cross[0]); fCurrentCursor = CURSOR_CROSS; } } -void Becasso::setSelect () +void +Becasso::setSelect() { - SetCursor (scross); + SetCursor(scross); fCurrentCursor = CURSOR_SELECT; } -void Becasso::setBusy () +void +Becasso::setBusy() { fBusy = 1; fCurrentCursor = CURSOR_CROSS; } -void Becasso::setReady () +void +Becasso::setReady() { fBusy = 0; - extern PicMenuButton *mode; - if (mode->selected() == M_SELECT) - { - SetCursor (scross); + extern PicMenuButton* mode; + if (mode->selected() == M_SELECT) { + SetCursor(scross); fCurrentCursor = CURSOR_SELECT; - } - else - { - SetCursor (cross[0]); + } else { + SetCursor(cross[0]); fCurrentCursor = CURSOR_CROSS; } } -void Becasso::setCCross () +void +Becasso::setCCross() { fBusy = 0; - SetCursor (ccross); + SetCursor(ccross); fCurrentCursor = CURSOR_CCROSS; } -void Becasso::setPicker (bool b) +void +Becasso::setPicker(bool b) { - if (b && fCurrentCursor != CURSOR_PICKER) - { + if (b && fCurrentCursor != CURSOR_PICKER) { fBusySave = fBusy; fBusy = 0; - SetCursor (picker); + SetCursor(picker); fCurrentCursorSave = fCurrentCursor; fCurrentCursor = CURSOR_PICKER; - } - else if (!b && fCurrentCursor == CURSOR_PICKER) - { - switch (fCurrentCursorSave) - { + } else if (!b && fCurrentCursor == CURSOR_PICKER) { + switch (fCurrentCursorSave) { case CURSOR_HAND: setHand(); break; @@ -2753,7 +2489,7 @@ void Becasso::setPicker (bool b) setRotator(); break; case CURSOR_OPEN_HAND: - setGrab (false); + setGrab(false); break; default: break; @@ -2762,22 +2498,25 @@ void Becasso::setPicker (bool b) } } -void Becasso::setMover () +void +Becasso::setMover() { fBusy = 0; - SetCursor (mover); + SetCursor(mover); fCurrentCursor = CURSOR_MOVER; } -void Becasso::setRotator () +void +Becasso::setRotator() { fBusy = 0; - SetCursor (rotator); + SetCursor(rotator); fCurrentCursor = CURSOR_ROTATOR; } -void Becasso::FixCursor() // BeOS bug w.r.t. hot spot of cursors +void +Becasso::FixCursor() // BeOS bug w.r.t. hot spot of cursors { BMessage fix('fixC'); - mainWindow->PostMessage (&fix); + mainWindow->PostMessage(&fix); } diff --git a/source/Becasso.h b/source/Becasso.h index 255d464..42c56a8 100644 --- a/source/Becasso.h +++ b/source/Becasso.h @@ -3,76 +3,80 @@ #include #include +#include #include #include "AboutWindow.h" #define MAX_CANVAS_NAME 1024 -#define CURSOR_HAND 0 -#define CURSOR_CROSS 1 -#define CURSOR_CCROSS 2 -#define CURSOR_PICKER 3 -#define CURSOR_MOVER 4 -#define CURSOR_ROTATOR 5 -#define CURSOR_SELECT 6 -#define CURSOR_OPEN_HAND 7 -#define CURSOR_GRAB 8 +#define CURSOR_HAND 0 +#define CURSOR_CROSS 1 +#define CURSOR_CCROSS 2 +#define CURSOR_PICKER 3 +#define CURSOR_MOVER 4 +#define CURSOR_ROTATOR 5 +#define CURSOR_SELECT 6 +#define CURSOR_OPEN_HAND 7 +#define CURSOR_GRAB 8 class Becasso : public BApplication { -public: - Becasso (); -virtual ~Becasso (); + public: + Becasso(); + virtual ~Becasso(); -virtual void MessageReceived(BMessage *message); -virtual void AboutRequested (); -virtual bool QuitRequested (); -virtual void ReadyToRun (); -virtual void RefsReceived (BMessage *message); -virtual void ArgvReceived (int32 argc, char **argv); -virtual void Pulse (); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); - void setHand (); - void setCross (); - void setBusy (); - void setReady (); - void setCCross (); - void setSelect (); - void setGrab (bool b, bool down = false); - void setPicker (bool b); - void setMover (); - void setRotator (); - void FixCursor (); - void LoadAddOns (); - void PrintSetup (); + virtual void MessageReceived(BMessage* message); + virtual void AboutRequested(); + virtual bool QuitRequested(); + virtual void ReadyToRun(); + virtual void RefsReceived(BMessage* message); + virtual void ArgvReceived(int32 argc, char** argv); + virtual void Pulse(); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + void setHand(); + void setCross(); + void setBusy(); + void setReady(); + void setCCross(); + void setSelect(); + void setGrab(bool b, bool down = false); + void setPicker(bool b); + void setMover(); + void setRotator(); + void FixCursor(); + void LoadAddOns(); + void PrintSetup(); -private: -typedef BApplication inherited; -AboutWindow *about; -BMessage *launchMessage; -BMessenger *fCurrentScriptee; -entry_ref fRef; -int fBusy; -int fBusySave; -int fCurrentCursor; -int fCurrentCursorSave; -int fCurrentProperty; -bool launching; -bool refvalid; -BList canvases; -int32 canvas_index; + private: + typedef BApplication inherited; + AboutWindow* about; + BMessage* launchMessage; + BMessenger* fCurrentScriptee; + BNumberFormat fNumberFormat; + entry_ref fRef; + int fBusy; + int fBusySave; + int fCurrentCursor; + int fCurrentCursorSave; + int fCurrentProperty; + bool launching; + bool refvalid; + BList canvases; + int32 canvas_index; }; class canvas { -public: -int32 index; -char name[MAX_CANVAS_NAME]; -BLooper *its_looper; + public: + int32 index; + char name[MAX_CANVAS_NAME]; + BLooper* its_looper; }; const int32 NumTools = 14; const int32 NumModes = 2; -#endif \ No newline at end of file +#endif diff --git a/source/BecassoAPI2.0/API/AddOnSupport.h b/source/BecassoAPI2.0/API/AddOnSupport.h index 004ff8d..f3af82a 100644 --- a/source/BecassoAPI2.0/API/AddOnSupport.h +++ b/source/BecassoAPI2.0/API/AddOnSupport.h @@ -9,53 +9,96 @@ typedef uint32 bgra_pixel; typedef uint32 cmyk_pixel; -typedef uint8 grey_pixel; +typedef uint8 grey_pixel; + typedef struct { - float hue; // [0,360> - float saturation; // [0,1] - float value; // [0,1] - uint8 alpha; // [0,255] + float hue; // [0,360> + float saturation; // [0,1] + float value; // [0,1] + uint8 alpha; // [0,255] } hsv_color; -extern "C" IMPEXP bgra_pixel average4 (bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d); -extern "C" IMPEXP bgra_pixel average6 (bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d, bgra_pixel e, bgra_pixel f); -extern "C" IMPEXP bgra_pixel average9 (bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d, bgra_pixel e, bgra_pixel f, bgra_pixel g, bgra_pixel h, bgra_pixel i); -extern "C" IMPEXP bgra_pixel pixelblend (bgra_pixel d, bgra_pixel s); -extern "C" IMPEXP uint8 clip8 (int32 c); -extern "C" IMPEXP rgb_color highcolor (void); -extern "C" IMPEXP rgb_color lowcolor (void); -extern "C" IMPEXP int32 currentmode (void); -extern "C" IMPEXP rgb_color contrastingcolor (rgb_color a, rgb_color b); -extern "C" IMPEXP rgb_color *highpalette (void); -extern "C" IMPEXP int highpalettesize (void); -extern "C" IMPEXP rgb_color closesthigh (rgb_color a); -extern "C" IMPEXP rgb_color *lowpalette (void); -extern "C" IMPEXP int lowpalettesize (void); -extern "C" IMPEXP rgb_color closestlow (rgb_color a); -extern "C" IMPEXP pattern currentpattern (void); -extern "C" IMPEXP bgra_pixel weighted_average (bgra_pixel a, uint8 wa, bgra_pixel b, uint8 wb); -extern "C" IMPEXP bgra_pixel weighted_average_rgb (rgb_color a, uint8 wa, rgb_color b, uint8 wb); -extern "C" IMPEXP int Scale (BBitmap *src, BBitmap *srcmap, BBitmap *dest, BBitmap *destmap); -extern "C" IMPEXP void AddWithAlpha (BBitmap *src, BBitmap *dest, long x, long y, int strength = 255); -extern "C" IMPEXP void BlendWithAlpha (BBitmap *src, BBitmap *dest, long x, long y, int strength = 255); -extern "C" IMPEXP void CutOrCopy (BBitmap *src, BBitmap *dest, BBitmap *selection, long offx, long offy, bool cut); -extern "C" IMPEXP BBitmap *entry2bitmap (BEntry entry, bool silent = false); -extern "C" IMPEXP rgb_color hsv2rgb (hsv_color c); -extern "C" IMPEXP rgb_color bgra2rgb (bgra_pixel c); -extern "C" IMPEXP rgb_color cmyk2rgb (cmyk_pixel c); -extern "C" IMPEXP hsv_color rgb2hsv (rgb_color c); -extern "C" IMPEXP hsv_color bgra2hsv (bgra_pixel c); -extern "C" IMPEXP hsv_color cmyk2hsv (cmyk_pixel c); -extern "C" IMPEXP bgra_pixel cmyk2bgra (cmyk_pixel c); -extern "C" IMPEXP bgra_pixel rgb2bgra (rgb_color c); -extern "C" IMPEXP bgra_pixel hsv2bgra (hsv_color c); -extern "C" IMPEXP cmyk_pixel bgra2cmyk (bgra_pixel c); -extern "C" IMPEXP cmyk_pixel rgb2cmyk (rgb_color c); -extern "C" IMPEXP cmyk_pixel hsv2cmyk (hsv_color c); -extern "C" IMPEXP float diff (rgb_color a, rgb_color b); -extern "C" IMPEXP uchar clipchar (float x); -extern "C" IMPEXP float clipone (float x); -extern "C" IMPEXP float clipdegr (float x); +extern "C" IMPEXP bgra_pixel +average4(bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d); +extern "C" IMPEXP bgra_pixel +average6(bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d, bgra_pixel e, bgra_pixel f); +extern "C" IMPEXP bgra_pixel +average9( + bgra_pixel a, bgra_pixel b, bgra_pixel c, bgra_pixel d, bgra_pixel e, bgra_pixel f, + bgra_pixel g, bgra_pixel h, bgra_pixel i +); +extern "C" IMPEXP bgra_pixel +pixelblend(bgra_pixel d, bgra_pixel s); +extern "C" IMPEXP uint8 +clip8(int32 c); +extern "C" IMPEXP rgb_color +highcolor(void); +extern "C" IMPEXP rgb_color +lowcolor(void); +extern "C" IMPEXP int32 +currentmode(void); +extern "C" IMPEXP rgb_color +contrastingcolor(rgb_color a, rgb_color b); +extern "C" IMPEXP rgb_color* +highpalette(void); +extern "C" IMPEXP int +highpalettesize(void); +extern "C" IMPEXP rgb_color +closesthigh(rgb_color a); +extern "C" IMPEXP rgb_color* +lowpalette(void); +extern "C" IMPEXP int +lowpalettesize(void); +extern "C" IMPEXP rgb_color +closestlow(rgb_color a); +extern "C" IMPEXP pattern +currentpattern(void); +extern "C" IMPEXP bgra_pixel +weighted_average(bgra_pixel a, uint8 wa, bgra_pixel b, uint8 wb); +extern "C" IMPEXP bgra_pixel +weighted_average_rgb(rgb_color a, uint8 wa, rgb_color b, uint8 wb); +extern "C" IMPEXP int +Scale(BBitmap* src, BBitmap* srcmap, BBitmap* dest, BBitmap* destmap); +extern "C" IMPEXP void +AddWithAlpha(BBitmap* src, BBitmap* dest, long x, long y, int strength = 255); +extern "C" IMPEXP void +BlendWithAlpha(BBitmap* src, BBitmap* dest, long x, long y, int strength = 255); +extern "C" IMPEXP void +CutOrCopy(BBitmap* src, BBitmap* dest, BBitmap* selection, long offx, long offy, bool cut); +extern "C" IMPEXP BBitmap* +entry2bitmap(BEntry entry, bool silent = false); +extern "C" IMPEXP rgb_color +hsv2rgb(hsv_color c); +extern "C" IMPEXP rgb_color +bgra2rgb(bgra_pixel c); +extern "C" IMPEXP rgb_color +cmyk2rgb(cmyk_pixel c); +extern "C" IMPEXP hsv_color +rgb2hsv(rgb_color c); +extern "C" IMPEXP hsv_color +bgra2hsv(bgra_pixel c); +extern "C" IMPEXP hsv_color +cmyk2hsv(cmyk_pixel c); +extern "C" IMPEXP bgra_pixel +cmyk2bgra(cmyk_pixel c); +extern "C" IMPEXP bgra_pixel +rgb2bgra(rgb_color c); +extern "C" IMPEXP bgra_pixel +hsv2bgra(hsv_color c); +extern "C" IMPEXP cmyk_pixel +bgra2cmyk(bgra_pixel c); +extern "C" IMPEXP cmyk_pixel +rgb2cmyk(rgb_color c); +extern "C" IMPEXP cmyk_pixel +hsv2cmyk(hsv_color c); +extern "C" IMPEXP float +diff(rgb_color a, rgb_color b); +extern "C" IMPEXP uchar +clipchar(float x); +extern "C" IMPEXP float +clipone(float x); +extern "C" IMPEXP float +clipdegr(float x); -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/BecassoAPI2.0/API/BBP.h b/source/BecassoAPI2.0/API/BBP.h index cb0daae..19403e8 100644 --- a/source/BecassoAPI2.0/API/BBP.h +++ b/source/BecassoAPI2.0/API/BBP.h @@ -8,27 +8,27 @@ // reply message will contain the entry_ref to a saved graphic file. -const int32 BBP_OPEN_BBITMAP='BPob'; // External App -> BBitmap Editor App +const int32 BBP_OPEN_BBITMAP = 'BPob'; // External App -> BBitmap Editor App // B_MESSENGER_TYPE "target" (the target to send the reply to) // B_MESSAGE_TYPE "BBitmap" (BBitmap archive) *or* // B_REF_TYPE "ref" (entry_ref to the graphic file) // B_FLOAT_TYPE "zoom" (optional zooming factor e.g. 2.0f means 200%) // B_STRING_TYPE "name" (optional bitmap name, which can go in the window title ) -const int32 BBP_REPLACE_BBITMAP='BPpb'; // External App -> BBitmap Editor App +const int32 BBP_REPLACE_BBITMAP = 'BPpb'; // External App -> BBitmap Editor App // B_MESSAGE_TYPE "BBitmap" (BBitmap archive) // B_FLOAT_TYPE "zoom" (optional zooming factor e.g. 2.0f means 200%) // B_STRING_TYPE "name" (optional bitmap name, which can go in the window title ) -const int32 BBP_BBITMAP_OPENED='BPbo'; // BBitmap Editor App -> External Messenger +const int32 BBP_BBITMAP_OPENED = 'BPbo'; // BBitmap Editor App -> External Messenger // B_MESSENGER_TYPE "target" (the editor window messenger) -const int32 BBP_SEND_BBITMAP='BPsb'; // BBitmap Editor Window -> External Messenger +const int32 BBP_SEND_BBITMAP = 'BPsb'; // BBitmap Editor Window -> External Messenger // B_MESSAGE_TYPE "BBitmap" (edited BBitmap archive) *or* // B_REF_TYPE "ref" (edited graphic file). -const int32 BBP_BBITMAP_CLOSED='BPbc'; // BBitmap Editor Window -> External Messenger +const int32 BBP_BBITMAP_CLOSED = 'BPbc'; // BBitmap Editor Window -> External Messenger -const int32 BBP_REQUEST_BBITMAP='BPrb'; // External Messenger -> BBitmap Editor Window +const int32 BBP_REQUEST_BBITMAP = 'BPrb'; // External Messenger -> BBitmap Editor Window -const int32 BBP_NO_WINDOWS='BPnw'; // Becasso -> External Messenger \ No newline at end of file +const int32 BBP_NO_WINDOWS = 'BPnw'; // Becasso -> External Messenger \ No newline at end of file diff --git a/source/BecassoAPI2.0/API/BecassoAddOn.h b/source/BecassoAPI2.0/API/BecassoAddOn.h index 03d697b..63b1aaa 100644 --- a/source/BecassoAPI2.0/API/BecassoAddOn.h +++ b/source/BecassoAPI2.0/API/BecassoAddOn.h @@ -13,157 +13,180 @@ class BView; // The following is for exporting the necessary symbols. -#if !defined (BUILDING_BECASSO) || defined (BUILDING_ADDON) -# define ADDON_EXPORT __declspec(dllexport) +#if !defined(BUILDING_BECASSO) || defined(BUILDING_ADDON) +#define ADDON_EXPORT __declspec(dllexport) #else -# define ADDON_EXPORT __declspec(dllimport) +#define ADDON_EXPORT __declspec(dllimport) #endif // Undefined Hue - some of the HSV functions from Becasso can return this. #define HUE_UNDEF -1.0 // The type of add-on -#define BECASSO_FILTER 0 -#define BECASSO_TRANSFORMER 1 -#define BECASSO_GENERATOR 2 -#define BECASSO_CAPTURE 3 +#define BECASSO_FILTER 0 +#define BECASSO_TRANSFORMER 1 +#define BECASSO_GENERATOR 2 +#define BECASSO_CAPTURE 3 // Defines for constructing a preview info bit mask -#define PREVIEW_FULLSCALE 1 -#define PREVIEW_2x2 2 -#define PREVIEW_MOUSE 4 -#define LAYER_AND_SELECTION 8 +#define PREVIEW_FULLSCALE 1 +#define PREVIEW_2x2 2 +#define PREVIEW_MOUSE 4 +#define LAYER_AND_SELECTION 8 // Defines for addon type -#define LAYER_ONLY 1 -#define SELECTION_ONLY 2 +#define LAYER_ONLY 1 +#define SELECTION_ONLY 2 // Return codes for the process() function -#define ADDON_OK 0 -#define ADDON_ABORT 1 -#define ADDON_UNKNOWN 2 +#define ADDON_OK 0 +#define ADDON_ABORT 1 +#define ADDON_UNKNOWN 2 // Messages used in the communication with Becasso -#define ADDON_CLOSES 'AOcl' -#define ADDON_PREVIEW 'AOpr' -#define ADDON_RESIZED 'AOrz' -#define ADDON_FILTER 'ao_f' -#define ADDON_TRANSFORMER 'ao_t' -#define ADDON_GENERATOR 'ao_g' -#define CAPTURE_READY 'CTrd' - -// Useful functions to keep your add-on code as +#define ADDON_CLOSES 'AOcl' +#define ADDON_PREVIEW 'AOpr' +#define ADDON_RESIZED 'AOrz' +#define ADDON_FILTER 'ao_f' +#define ADDON_TRANSFORMER 'ao_t' +#define ADDON_GENERATOR 'ao_g' +#define CAPTURE_READY 'CTrd' + +// Useful functions to keep your add-on code as // processor-agnostic as possible -#if defined (__POWERPC__) -# define COLOR_MASK 0xFFFFFF00 -# define ALPHA_MASK 0x000000FF -# define RED_MASK 0x0000FF00 -# define GREEN_MASK 0x00FF0000 -# define BLUE_MASK 0xFF000000 -# define CYAN_MASK 0xFF000000 -# define MAGENTA_MASK 0x00FF0000 -# define YELLOW_MASK 0x0000FF00 -# define BLACK_MASK 0x000000FF -# define IRED_MASK 0xFFFF00FF -# define IGREEN_MASK 0xFF00FFFF -# define IBLUE_MASK 0x00FFFFFF -# define ICYAN_MASK 0x00FFFFFF -# define IMAGENTA_MASK 0xFF00FFFF -# define IYELLOW_MASK 0xFFFF00FF -# define IBLACK_MASK 0xFFFFFF00 -# define ALPHA_BPOS 0 -# define RED_BPOS 8 -# define GREEN_BPOS 16 -# define BLUE_BPOS 24 -# define CYAN_BPOS 24 -# define MAGENTA_BPOS 16 -# define YELLOW_BPOS 8 -# define BLACK_BPOS 0 -# define BLUE(x) ((x) >> 24) -# define GREEN(x) (((x) >> 16) & 0xFF) -# define RED(x) (((x) >> 8) & 0xFF) -# define ALPHA(x) ((x) & 0xFF) -# define CYAN(x) ((x) & 0xFF) -# define MAGENTA(x) (((x) >> 8) & 0xFF) -# define YELLOW(x) (((x) >> 16) & 0xFF) -# define BLACK(x) ((x) >> 24) -# define PIXEL(r,g,b,a) (((int(b) << 24) & 0xFF000000) | ((int(g) << 16) & 0xFF0000) | ((int(r) << 8) & 0xFF00) | (int(a) & 0xFF)) -#else // IA -# define COLOR_MASK 0x00FFFFFF -# define ALPHA_MASK 0xFF000000 -# define RED_MASK 0x00FF0000 -# define GREEN_MASK 0x0000FF00 -# define BLUE_MASK 0x000000FF -# define CYAN_MASK 0x000000FF -# define MAGENTA_MASK 0x0000FF00 -# define YELLOW_MASK 0x00FF0000 -# define BLACK_MASK 0xFF000000 -# define IRED_MASK 0xFF00FFFF -# define IGREEN_MASK 0xFFFF00FF -# define IBLUE_MASK 0xFFFFFF00 -# define ICYAN_MASK 0xFFFFFF00 -# define IMAGENTA_MASK 0xFFFF00FF -# define IYELLOW_MASK 0xFF00FFFF -# define IBLACK_MASK 0x00FFFFFF -# define ALPHA_BPOS 24 -# define RED_BPOS 16 -# define GREEN_BPOS 8 -# define BLUE_BPOS 0 -# define CYAN_BPOS 0 -# define MAGENTA_BPOS 8 -# define YELLOW_BPOS 16 -# define BLACK_BPOS 24 -# define ALPHA(x) ((x) >> 24) -# define RED(x) (((x) >> 16) & 0xFF) -# define GREEN(x) (((x) >> 8) & 0xFF) -# define BLUE(x) ((x) & 0xFF) -# define CYAN(x) ((x) & 0xFF) -# define MAGENTA(x) (((x) >> 8) & 0xFF) -# define YELLOW(x) (((x) >> 16) & 0xFF) -# define BLACK(x) ((x) >> 24) -# define PIXEL(r,g,b,a) (((int(a) << 24) & 0xFF000000) | ((int(r) << 16) & 0xFF0000) | ((int(g) << 8) & 0xFF00) | (int(b) & 0xFF)) +#if defined(__POWERPC__) +#define COLOR_MASK 0xFFFFFF00 +#define ALPHA_MASK 0x000000FF +#define RED_MASK 0x0000FF00 +#define GREEN_MASK 0x00FF0000 +#define BLUE_MASK 0xFF000000 +#define CYAN_MASK 0xFF000000 +#define MAGENTA_MASK 0x00FF0000 +#define YELLOW_MASK 0x0000FF00 +#define BLACK_MASK 0x000000FF +#define IRED_MASK 0xFFFF00FF +#define IGREEN_MASK 0xFF00FFFF +#define IBLUE_MASK 0x00FFFFFF +#define ICYAN_MASK 0x00FFFFFF +#define IMAGENTA_MASK 0xFF00FFFF +#define IYELLOW_MASK 0xFFFF00FF +#define IBLACK_MASK 0xFFFFFF00 +#define ALPHA_BPOS 0 +#define RED_BPOS 8 +#define GREEN_BPOS 16 +#define BLUE_BPOS 24 +#define CYAN_BPOS 24 +#define MAGENTA_BPOS 16 +#define YELLOW_BPOS 8 +#define BLACK_BPOS 0 +#define BLUE(x) ((x) >> 24) +#define GREEN(x) (((x) >> 16) & 0xFF) +#define RED(x) (((x) >> 8) & 0xFF) +#define ALPHA(x) ((x) & 0xFF) +#define CYAN(x) ((x) & 0xFF) +#define MAGENTA(x) (((x) >> 8) & 0xFF) +#define YELLOW(x) (((x) >> 16) & 0xFF) +#define BLACK(x) ((x) >> 24) +#define PIXEL(r, g, b, a) \ + (((int(b) << 24) & 0xFF000000) | ((int(g) << 16) & 0xFF0000) | ((int(r) << 8) & 0xFF00) | \ + (int(a) & 0xFF)) +#else // IA +#define COLOR_MASK 0x00FFFFFF +#define ALPHA_MASK 0xFF000000 +#define RED_MASK 0x00FF0000 +#define GREEN_MASK 0x0000FF00 +#define BLUE_MASK 0x000000FF +#define CYAN_MASK 0x000000FF +#define MAGENTA_MASK 0x0000FF00 +#define YELLOW_MASK 0x00FF0000 +#define BLACK_MASK 0xFF000000 +#define IRED_MASK 0xFF00FFFF +#define IGREEN_MASK 0xFFFF00FF +#define IBLUE_MASK 0xFFFFFF00 +#define ICYAN_MASK 0xFFFFFF00 +#define IMAGENTA_MASK 0xFFFF00FF +#define IYELLOW_MASK 0xFF00FFFF +#define IBLACK_MASK 0x00FFFFFF +#define ALPHA_BPOS 24 +#define RED_BPOS 16 +#define GREEN_BPOS 8 +#define BLUE_BPOS 0 +#define CYAN_BPOS 0 +#define MAGENTA_BPOS 8 +#define YELLOW_BPOS 16 +#define BLACK_BPOS 24 +#define ALPHA(x) ((x) >> 24) +#define RED(x) (((x) >> 16) & 0xFF) +#define GREEN(x) (((x) >> 8) & 0xFF) +#define BLUE(x) ((x) & 0xFF) +#define CYAN(x) ((x) & 0xFF) +#define MAGENTA(x) (((x) >> 8) & 0xFF) +#define YELLOW(x) (((x) >> 16) & 0xFF) +#define BLACK(x) ((x) >> 24) +#define PIXEL(r, g, b, a) \ + (((int(a) << 24) & 0xFF000000) | ((int(r) << 16) & 0xFF0000) | ((int(g) << 8) & 0xFF00) | \ + (int(b) & 0xFF)) #endif // Rectangle constants -const BRect EmptyRect = BRect (0, 0, 0, 0); +const BRect EmptyRect = BRect(0, 0, 0, 0); // The becasso_addon_info struct typedef struct { - char name[80]; // The name as it appears in the menu - uint32 index; // A unique index assigned at init time - int type; // Filter, Transformer, Generator, or Capture - int version; // Version of the add-on - int release; // Release of the add-on - int becasso_version; // Required Becasso version (other won't load) - int becasso_release; // Written for release (older will warn) - char author[128]; // Author (company) of the add-on - char copyright[128]; // Copyright notice - char description[256]; // Explains what the add-on does - uint8 does_preview; // bitmask for various preview notifications - uint32 flags; // bitmask + char name[80]; // The name as it appears in the menu + uint32 index; // A unique index assigned at init time + int type; // Filter, Transformer, Generator, or Capture + int version; // Version of the add-on + int release; // Release of the add-on + int becasso_version; // Required Becasso version (other won't load) + int becasso_release; // Written for release (older will warn) + char author[128]; // Author (company) of the add-on + char copyright[128]; // Copyright notice + char description[256]; // Explains what the add-on does + uint8 does_preview; // bitmask for various preview notifications + uint32 flags; // bitmask } becasso_addon_info; // Function prototypes -extern "C" ADDON_EXPORT status_t addon_init (uint32 index, becasso_addon_info *info); -extern "C" ADDON_EXPORT status_t addon_exit (void); -extern "C" ADDON_EXPORT status_t addon_close (void); -extern "C" ADDON_EXPORT status_t addon_make_config (BView **view, BRect rect); -extern "C" ADDON_EXPORT status_t process (Layer *inLayer, Selection *inSelection, Layer **outLayer, Selection **outSelection, int32 mode, BRect *frame, bool final, BPoint point, uint32 buttons); +extern "C" ADDON_EXPORT status_t +addon_init(uint32 index, becasso_addon_info* info); +extern "C" ADDON_EXPORT status_t +addon_exit(void); +extern "C" ADDON_EXPORT status_t +addon_close(void); +extern "C" ADDON_EXPORT status_t +addon_make_config(BView** view, BRect rect); +extern "C" ADDON_EXPORT status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* frame, bool final, BPoint point, uint32 buttons +); // for Capture add-ons -extern "C" ADDON_EXPORT status_t addon_open (void); -extern "C" ADDON_EXPORT BBitmap *bitmap (char *title); +extern "C" ADDON_EXPORT status_t +addon_open(void); +extern "C" ADDON_EXPORT BBitmap* +bitmap(char* title); // optional hooks -extern "C" ADDON_EXPORT void addon_color_changed (void); -extern "C" ADDON_EXPORT void addon_mode_changed (void); +extern "C" ADDON_EXPORT void +addon_color_changed(void); +extern "C" ADDON_EXPORT void +addon_mode_changed(void); // Status updating calls -IMPEXP void addon_start (void); -IMPEXP bool addon_stop (void); -IMPEXP void addon_done (void); -IMPEXP void addon_update_statusbar (float delta, const char *text = NULL, const char *trailingText = NULL); -IMPEXP void addon_reset_statusbar (const char *label = NULL, const char *trailingText = NULL); -IMPEXP void addon_preview (void); -IMPEXP void addon_refresh_config (void); +IMPEXP void +addon_start(void); +IMPEXP bool +addon_stop(void); +IMPEXP void +addon_done(void); +IMPEXP void +addon_update_statusbar(float delta, const char* text = NULL, const char* trailingText = NULL); +IMPEXP void +addon_reset_statusbar(const char* label = NULL, const char* trailingText = NULL); +IMPEXP void +addon_preview(void); +IMPEXP void +addon_refresh_config(void); #endif diff --git a/source/BecassoAPI2.0/API/Blur.cpp b/source/BecassoAPI2.0/API/Blur.cpp index 10d62a3..2668830 100644 --- a/source/BecassoAPI2.0/API/Blur.cpp +++ b/source/BecassoAPI2.0/API/Blur.cpp @@ -5,56 +5,61 @@ #include "AddOnSupport.h" #include -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Blur"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1999-2001 ∑ Sum Software"); - strcpy (info->description, "Applies a 3x3 blur kernel convolution"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 1; - info->release = 3; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "Blur"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1999-2001 ∑ Sum Software"); + strcpy(info->description, "Applies a 3x3 blur kernel convolution"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 1; + info->release = 3; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { // Blur hasn't got any UI return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */ +) { status_t error = ADDON_OK; BRect bounds = inLayer->Bounds(); -// printf ("Bounds: "); -// bounds.PrintToStream(); -// printf ("Frame: "); -// frame->PrintToStream(); + // printf ("Bounds: "); + // bounds.PrintToStream(); + // printf ("Frame: "); + // frame->PrintToStream(); if (*outLayer == NULL && mode == M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to blur! + *outSelection = new Selection(*inSelection); + else // No Selection to blur! return (0); } if (*outLayer) @@ -63,132 +68,122 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits(); - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits(); + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w + 2; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits(); - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits(); + float delta = 100.0 / h; // For the Status Bar. + + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits(); + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits(); // Note: We don't update the status bar during the corners and edges. // The time this takes is insignificant anyway. - + // First do the corners: // Left top if (!inSelection || *mapbits) - *dbits = average4 (*sbits, *(sbits + 1), - *(sbits + w), *(sbits + w + 1)); + *dbits = average4(*sbits, *(sbits + 1), *(sbits + w), *(sbits + w + 1)); else *dbits = *sbits; // Right top if (!inSelection || *(mapbits + w - 1)) - *(dbits + w - 1) = average4 (*(sbits + w - 2), *(sbits + w - 1), - *(sbits + 2*w - 2), *(sbits + 2*w - 1)); + *(dbits + w - 1) = average4( + *(sbits + w - 2), *(sbits + w - 1), *(sbits + 2 * w - 2), *(sbits + 2 * w - 1) + ); else *(dbits + w - 1) = *(sbits + w - 1); // Left bottom - if (!inSelection || *(mapbits + (h - 1)*mbpr)) - *(dbits + (h - 1)*w) = average4 (*(sbits + (h - 2)*w), *(sbits + (h - 2)*w + 1), - *(sbits + (h - 1)*w), *(sbits + (h - 1)*w)); + if (!inSelection || *(mapbits + (h - 1) * mbpr)) + *(dbits + (h - 1) * w) = average4( + *(sbits + (h - 2) * w), *(sbits + (h - 2) * w + 1), *(sbits + (h - 1) * w), + *(sbits + (h - 1) * w) + ); else - *(dbits + (h - 1)*w) = *(sbits + (h - 1)*w); + *(dbits + (h - 1) * w) = *(sbits + (h - 1) * w); // Right bottom - if (!inSelection || *(mapbits + (h - 1)*mbpr + w - 1)) - *(dbits + h*w - 1) = average4 (*(sbits + (h - 1)*w - 2), *(sbits + (h - 1)*w - 1), - *(sbits + h*w - 2), *(sbits + h*w - 1)); + if (!inSelection || *(mapbits + (h - 1) * mbpr + w - 1)) + *(dbits + h * w - 1) = average4( + *(sbits + (h - 1) * w - 2), *(sbits + (h - 1) * w - 1), *(sbits + h * w - 2), + *(sbits + h * w - 1) + ); else - *(dbits + h*w - 1) = *(sbits + h*w - 1); - + *(dbits + h * w - 1) = *(sbits + h * w - 1); + // Now do the edges: // Top/bottom edges - for (uint32 x = 1; x < w - 1; x++) - { - if (!inSelection || *(mapbits + x)) - { - bgra_pixel *sbitsx = sbits + x; - bgra_pixel *sbitsxl = sbitsx + w; - *(dbits + x) = average6 (*(sbitsx - 1), *sbitsx, *(sbitsx + 1), - *(sbitsxl - 1), *sbitsxl, *(sbitsxl + 1)); - } - else + for (uint32 x = 1; x < w - 1; x++) { + if (!inSelection || *(mapbits + x)) { + bgra_pixel* sbitsx = sbits + x; + bgra_pixel* sbitsxl = sbitsx + w; + *(dbits + x) = average6( + *(sbitsx - 1), *sbitsx, *(sbitsx + 1), *(sbitsxl - 1), *sbitsxl, *(sbitsxl + 1) + ); + } else *(dbits + x) = *(sbits + x); - - if (!inSelection || *(mapbits + (h - 1)*mbpr + x)) - { - bgra_pixel *sbitsx = sbits + (h - 1)*w + x; - bgra_pixel *sbitsxu = sbitsx - w; - *(dbits + (h - 1)*w + x) = average6 (*(sbitsx - 1), *sbitsx, *(sbitsx + 1), - *(sbitsxu - 1), *sbitsxu, *(sbitsxu + 1)); - } - else - *(dbits + (h - 1)*w + x) = *(sbits + (h - 1)*w + x); + + if (!inSelection || *(mapbits + (h - 1) * mbpr + x)) { + bgra_pixel* sbitsx = sbits + (h - 1) * w + x; + bgra_pixel* sbitsxu = sbitsx - w; + *(dbits + (h - 1) * w + x) = average6( + *(sbitsx - 1), *sbitsx, *(sbitsx + 1), *(sbitsxu - 1), *sbitsxu, *(sbitsxu + 1) + ); + } else + *(dbits + (h - 1) * w + x) = *(sbits + (h - 1) * w + x); } - + // Left/right edges: - for (uint32 y = 1; y < h - 1; y++) - { - if (!inSelection || *(mapbits + y*mbpr)) - { - bgra_pixel *sbitsy = sbits + y*w; - bgra_pixel *sbitsyr = sbitsy + 1; - *(dbits + y*w) = average6 (*(sbitsy - w), *sbitsy, *(sbitsy + w), - *(sbitsyr - w), *sbitsyr, *(sbitsyr + w)); - } - else - *(dbits + y*w) = *(sbits + y*w); - - if (!inSelection || *(mapbits + y*mbpr + w - 1)) - { - bgra_pixel *sbitsy = sbits + (y + 1)*w - 1; - bgra_pixel *sbitsyl = sbitsy - 1; - *(dbits + (y + 1)*w - 1) = average6 (*(sbitsy - w), *sbitsy, *(sbitsy + w), - *(sbitsyl - w), *sbitsyl, *(sbitsyl + w)); - } - else - *(dbits + (y + 1)*w - 1) = *(sbits + (y + 1)*w - 1); + for (uint32 y = 1; y < h - 1; y++) { + if (!inSelection || *(mapbits + y * mbpr)) { + bgra_pixel* sbitsy = sbits + y * w; + bgra_pixel* sbitsyr = sbitsy + 1; + *(dbits + y * w) = average6( + *(sbitsy - w), *sbitsy, *(sbitsy + w), *(sbitsyr - w), *sbitsyr, *(sbitsyr + w) + ); + } else + *(dbits + y * w) = *(sbits + y * w); + + if (!inSelection || *(mapbits + y * mbpr + w - 1)) { + bgra_pixel* sbitsy = sbits + (y + 1) * w - 1; + bgra_pixel* sbitsyl = sbitsy - 1; + *(dbits + (y + 1) * w - 1) = average6( + *(sbitsy - w), *sbitsy, *(sbitsy + w), *(sbitsyl - w), *sbitsyl, *(sbitsyl + w) + ); + } else + *(dbits + (y + 1) * w - 1) = *(sbits + (y + 1) * w - 1); } - + // Finally, the bulk of the canvas. dbits += w; sbits += w; mapbits += mbpr; - for (uint32 y = 1; y < h - 1; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + for (uint32 y = 1; y < h - 1; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 1; x < w - 1; x++) - { - if (!inSelection || *(++mapbits)) - { - bgra_pixel *sbitsu = ++sbits - w; - bgra_pixel *sbitsl = sbits + w; - *(++dbits) = average9 (*(sbitsu - 1), *sbitsu, *(sbitsu + 1), - *(sbits - 1), *sbits, *(sbits + 1), - *(sbitsl - 1), *sbitsl, *(sbitsl + 1)); - } - else + for (uint32 x = 1; x < w - 1; x++) { + if (!inSelection || *(++mapbits)) { + bgra_pixel* sbitsu = ++sbits - w; + bgra_pixel* sbitsl = sbits + w; + *(++dbits) = average9( + *(sbitsu - 1), *sbitsu, *(sbitsu + 1), *(sbits - 1), *sbits, *(sbits + 1), + *(sbitsl - 1), *sbitsl, *(sbitsl + 1) + ); + } else *(++dbits) = *(++sbits); } dbits += 2; @@ -197,79 +192,86 @@ status_t process (Layer *inLayer, Selection *inSelection, } break; } - case M_SELECT: - { + case M_SELECT: { if (!inSelection) *outSelection = NULL; - else - { - grey_pixel *sbits = mapbits; - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits(); + else { + grey_pixel* sbits = mapbits; + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits(); // First do the corners: // Left top - *dbits = (*sbits + *(sbits + 1) + *(sbits + mbpr) + *(sbits + mbpr + 1))/4; + *dbits = (*sbits + *(sbits + 1) + *(sbits + mbpr) + *(sbits + mbpr + 1)) / 4; // Right top - *(dbits + mbpr - 1) = (*(sbits + mbpr - 2) + *(sbits + mbpr - 1) + *(sbits + 2*mbpr - 2) + *(sbits + 2*mbpr - 1))/4; + *(dbits + mbpr - 1) = (*(sbits + mbpr - 2) + *(sbits + mbpr - 1) + + *(sbits + 2 * mbpr - 2) + *(sbits + 2 * mbpr - 1)) / + 4; // Left bottom - *(dbits + (h - 1)*mbpr) = (*(sbits + (h - 2)*mbpr) + *(sbits + (h - 2)*mbpr + 1) + *(sbits + (h - 1)*mbpr) + *(sbits + (h - 1)*mbpr))/4; + *(dbits + (h - 1) * mbpr) = (*(sbits + (h - 2) * mbpr) + *(sbits + (h - 2) * mbpr + 1) + + *(sbits + (h - 1) * mbpr) + *(sbits + (h - 1) * mbpr)) / + 4; // Right bottom - *(dbits + h*mbpr - 1) = (*(sbits + (h - 1)*mbpr - 2) + *(sbits + (h - 1)*mbpr - 1) + *(sbits + h*mbpr - 2) + *(sbits + h*mbpr - 1))/4; - + *(dbits + h * mbpr - 1) = + (*(sbits + (h - 1) * mbpr - 2) + *(sbits + (h - 1) * mbpr - 1) + + *(sbits + h * mbpr - 2) + *(sbits + h * mbpr - 1)) / + 4; + // Now do the edges: // Top/bottom edges - for (uint32 x = 1; x < w - 1; x++) - { - grey_pixel *sbitsx = sbits + x; - grey_pixel *sbitsxl = sbitsx + mbpr; - *(dbits + x) = (*(sbitsx - 1) + *sbitsx + *(sbitsx + 1) + *(sbitsxl - 1) + *sbitsxl + *(sbitsxl + 1))/6; - - sbitsx = sbits + (h - 1)*mbpr + x; - grey_pixel *sbitsxu = sbitsx - mbpr; - *(dbits + (h - 1)*mbpr + x) = (*(sbitsx - 1) + *sbitsx + *(sbitsx + 1) + *(sbitsxu - 1) + *sbitsxu + *(sbitsxu + 1))/6; + for (uint32 x = 1; x < w - 1; x++) { + grey_pixel* sbitsx = sbits + x; + grey_pixel* sbitsxl = sbitsx + mbpr; + *(dbits + x) = (*(sbitsx - 1) + *sbitsx + *(sbitsx + 1) + *(sbitsxl - 1) + + *sbitsxl + *(sbitsxl + 1)) / + 6; + + sbitsx = sbits + (h - 1) * mbpr + x; + grey_pixel* sbitsxu = sbitsx - mbpr; + *(dbits + (h - 1) * mbpr + x) = (*(sbitsx - 1) + *sbitsx + *(sbitsx + 1) + + *(sbitsxu - 1) + *sbitsxu + *(sbitsxu + 1)) / + 6; } - + // Left/right edges: - for (uint32 y = 1; y < h - 1; y++) - { - grey_pixel *sbitsy = sbits + y*mbpr; - grey_pixel *sbitsyr = sbitsy + 1; - *(dbits + y*mbpr) = (*(sbitsy - mbpr) + *sbitsy + *(sbitsy + mbpr) + *(sbitsyr - mbpr) + *sbitsyr + *(sbitsyr + mbpr))/6; - - sbitsy = sbits + (y + 1)*mbpr - 1; - grey_pixel *sbitsyl = sbitsy - 1; - *(dbits + (y + 1)*mbpr - 1) = (*(sbitsy - mbpr) + *sbitsy + *(sbitsy + mbpr) + *(sbitsyl - mbpr) + *sbitsyl + *(sbitsyl + mbpr))/6; + for (uint32 y = 1; y < h - 1; y++) { + grey_pixel* sbitsy = sbits + y * mbpr; + grey_pixel* sbitsyr = sbitsy + 1; + *(dbits + y * mbpr) = (*(sbitsy - mbpr) + *sbitsy + *(sbitsy + mbpr) + + *(sbitsyr - mbpr) + *sbitsyr + *(sbitsyr + mbpr)) / + 6; + + sbitsy = sbits + (y + 1) * mbpr - 1; + grey_pixel* sbitsyl = sbitsy - 1; + *(dbits + (y + 1) * mbpr - 1) = (*(sbitsy - mbpr) + *sbitsy + *(sbitsy + mbpr) + + *(sbitsyl - mbpr) + *sbitsyl + *(sbitsyl + mbpr)) / + 6; } - + // Finally, the bulk of the canvas. - dbits += mbpr; // We've already done the top row + dbits += mbpr; // We've already done the top row sbits += mbpr; - for (uint32 y = 1; y < h - 1; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + for (uint32 y = 1; y < h - 1; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - sbits = (grey_pixel *) inSelection->Bits() + y*mbpr; - dbits = (grey_pixel *) (*outSelection)->Bits() + y*mbpr; - for (uint32 x = 1; x < w - 1; x++) - { - grey_pixel *sbitsu = ++sbits - mbpr; - grey_pixel *sbitsl = sbits + mbpr; - *(++dbits) = (*(sbitsu - 1) + *sbitsu + *(sbitsu + 1) + - *(sbits - 1) + *sbits + *(sbits + 1) + - *(sbitsl - 1) + *sbitsl + *(sbitsl + 1))/9; + sbits = (grey_pixel*)inSelection->Bits() + y * mbpr; + dbits = (grey_pixel*)(*outSelection)->Bits() + y * mbpr; + for (uint32 x = 1; x < w - 1; x++) { + grey_pixel* sbitsu = ++sbits - mbpr; + grey_pixel* sbitsl = sbits + mbpr; + *(++dbits) = (*(sbitsu - 1) + *sbitsu + *(sbitsu + 1) + *(sbits - 1) + *sbits + + *(sbits + 1) + *(sbitsl - 1) + *sbitsl + *(sbitsl + 1)) / + 9; } } } break; } default: - fprintf (stderr, "Blur: Unknown mode\n"); + fprintf(stderr, "Blur: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -277,7 +279,7 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); - + if (final) addon_done(); diff --git a/source/BecassoAPI2.0/API/Build.h b/source/BecassoAPI2.0/API/Build.h index 7646f07..1de34c7 100644 --- a/source/BecassoAPI2.0/API/Build.h +++ b/source/BecassoAPI2.0/API/Build.h @@ -1,10 +1,10 @@ #ifndef _BUILD_H #define _BUILD_H -#if defined (BUILDING_BECASSO) -# define IMPEXP __declspec(dllexport) +#if defined(BUILDING_BECASSO) +#define IMPEXP __declspec(dllexport) #else -# define IMPEXP __declspec(dllimport) +#define IMPEXP __declspec(dllimport) #endif #endif diff --git a/source/BecassoAPI2.0/API/Colors.h b/source/BecassoAPI2.0/API/Colors.h index a84d863..c632510 100644 --- a/source/BecassoAPI2.0/API/Colors.h +++ b/source/BecassoAPI2.0/API/Colors.h @@ -8,14 +8,11 @@ extern IMPEXP rgb_color Black, LightGrey, DarkGrey, White, Transparent; extern IMPEXP rgb_color Red, Green, Blue; -extern IMPEXP rgb_color Grey0, Grey1, Grey2, Grey3, Grey4, Grey5, - Grey6, Grey7, Grey8, Grey9, Grey10, Grey11, - Grey12, Grey13, Grey14, Grey15, Grey16, Grey17, - Grey18, Grey19, Grey20, Grey21, Grey22, Grey23, - Grey24, Grey25, Grey26, Grey27, Grey28, Grey29, - Grey30, Grey31; +extern IMPEXP rgb_color Grey0, Grey1, Grey2, Grey3, Grey4, Grey5, Grey6, Grey7, Grey8, Grey9, + Grey10, Grey11, Grey12, Grey13, Grey14, Grey15, Grey16, Grey17, Grey18, Grey19, Grey20, Grey21, + Grey22, Grey23, Grey24, Grey25, Grey26, Grey27, Grey28, Grey29, Grey30, Grey31; #define SELECT_FULL B_TRANSPARENT_32_BIT #define SELECT_NONE Black -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/BecassoAPI2.0/API/DModes.h b/source/BecassoAPI2.0/API/DModes.h index 382c6b7..baa480a 100644 --- a/source/BecassoAPI2.0/API/DModes.h +++ b/source/BecassoAPI2.0/API/DModes.h @@ -3,9 +3,9 @@ #ifndef _DMODES_H #define _DMODES_H -#define DM_BLEND 0 -#define DM_MULTIPLY 1 -#define DM_DIFFERENCE 2 -#define DM_ALPHAMASK 3 +#define DM_BLEND 0 +#define DM_MULTIPLY 1 +#define DM_DIFFERENCE 2 +#define DM_ALPHAMASK 3 #endif diff --git a/source/BecassoAPI2.0/API/Layer.h b/source/BecassoAPI2.0/API/Layer.h index e7452d2..7649d6f 100644 --- a/source/BecassoAPI2.0/API/Layer.h +++ b/source/BecassoAPI2.0/API/Layer.h @@ -12,31 +12,43 @@ class IMPEXP Layer : public BBitmap { -public: - Layer (BRect bounds, const char *name); - Layer (const Layer& layer); - ~Layer (); -int getMode () { return fMode; }; -void setMode (const int mode) { fMode = mode; }; -char *getName () { return fName; }; -void setName (const char *name); -uchar getGlobalAlpha () { return fGlobalAlpha; }; -void setGlobalAlpha (const uchar a) { fGlobalAlpha = a; }; -BBitmap *getAlphaMap () { return fAlphaMap; }; -void setAlphaMap (BBitmap *a) { fAlphaMap = a; }; -BRect Bounds () { return fRect; }; -void Hide (bool h) { fHide = h; }; -bool IsHidden () { return fHide; }; -void ClearTo (bgra_pixel p); - -private: -typedef BBitmap inherited; -BBitmap *fAlphaMap; -uchar fGlobalAlpha; -BRect fRect; -int fMode; -bool fHide; -char fName[MAXLAYERNAME]; + public: + Layer(BRect bounds, const char* name); + Layer(const Layer& layer); + ~Layer(); + + int getMode() { return fMode; }; + + void setMode(const int mode) { fMode = mode; }; + + char* getName() { return fName; }; + + void setName(const char* name); + + uchar getGlobalAlpha() { return fGlobalAlpha; }; + + void setGlobalAlpha(const uchar a) { fGlobalAlpha = a; }; + + BBitmap* getAlphaMap() { return fAlphaMap; }; + + void setAlphaMap(BBitmap* a) { fAlphaMap = a; }; + + BRect Bounds() { return fRect; }; + + void Hide(bool h) { fHide = h; }; + + bool IsHidden() { return fHide; }; + + void ClearTo(bgra_pixel p); + + private: + typedef BBitmap inherited; + BBitmap* fAlphaMap; + uchar fGlobalAlpha; + BRect fRect; + int fMode; + bool fHide; + char fName[MAXLAYERNAME]; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/BecassoAPI2.0/API/Modes.h b/source/BecassoAPI2.0/API/Modes.h index 090ec9d..45ad594 100644 --- a/source/BecassoAPI2.0/API/Modes.h +++ b/source/BecassoAPI2.0/API/Modes.h @@ -3,12 +3,12 @@ #ifndef _MODES_H #define _MODES_H -#define M_DRAW 0 -#define M_SELECT 1 -#define M_DRAW_SELECT 2 -#define M_DRAG 3 -#define M_MERGE 4 -#define M_DELLAYER 5 -#define M_RESIZE 6 +#define M_DRAW 0 +#define M_SELECT 1 +#define M_DRAW_SELECT 2 +#define M_DRAG 3 +#define M_MERGE 4 +#define M_DELLAYER 5 +#define M_RESIZE 6 #endif diff --git a/source/BecassoAPI2.0/API/OilPaint.cpp b/source/BecassoAPI2.0/API/OilPaint.cpp index c57fe1e..859c2ef 100644 --- a/source/BecassoAPI2.0/API/OilPaint.cpp +++ b/source/BecassoAPI2.0/API/OilPaint.cpp @@ -5,54 +5,56 @@ #include "Slider.h" #include -// Simulate an oil painting by replacing each pixel with the most frequently +// Simulate an oil painting by replacing each pixel with the most frequently // appearing color in an n x n grid around it. // NB: This is a very straightforward implementation, and NOT very efficient! class cn_list { -public: - cn_list (int _max) : fMax (_max), fIndex (0), fMf (0) - { - clist = new bgra_pixel[fMax]; - nlist = new int[fMax]; - }; -virtual ~cn_list () - { - delete [] clist; - delete [] nlist; - }; -int add (bgra_pixel c); -void reset () - { - fIndex = 0; - fMf = 0; - } -bgra_pixel most_frequent (); - -private: -bgra_pixel *clist; -int *nlist; -int fMax; -int fIndex; -int fMf; + public: + cn_list(int _max) : fMax(_max), fIndex(0), fMf(0) + { + clist = new bgra_pixel[fMax]; + nlist = new int[fMax]; + }; + + virtual ~cn_list() + { + delete[] clist; + delete[] nlist; + }; + + int add(bgra_pixel c); + + void reset() + { + fIndex = 0; + fMf = 0; + } + + bgra_pixel most_frequent(); + + private: + bgra_pixel* clist; + int* nlist; + int fMax; + int fIndex; + int fMf; }; -int cn_list::add (bgra_pixel c) +int +cn_list::add(bgra_pixel c) { - for (int i = 0; i < fIndex; i++) - { - if (clist[i] == c) - { + for (int i = 0; i < fIndex; i++) { + if (clist[i] == c) { if (++nlist[i] > nlist[fMf]) fMf = i; return (i); } } - if (fIndex == fMax) - { - fprintf (stderr, "cn_list: Too many items\n"); + if (fIndex == fMax) { + fprintf(stderr, "cn_list: Too many items\n"); return (-1); } clist[fIndex] = c; @@ -60,95 +62,101 @@ int cn_list::add (bgra_pixel c) return (fIndex - 1); } -bgra_pixel cn_list::most_frequent () +bgra_pixel +cn_list::most_frequent() { - if (nlist[fMf] == 1) // Apparently, only different colors. Return the original middle pixel. - return (clist[fIndex/2]); + if (nlist[fMf] == 1) // Apparently, only different colors. Return the original middle pixel. + return (clist[fIndex / 2]); return clist[fMf]; } -int gSize; +int gSize; class OilView : public BView { -public: - OilView (BRect rect) : BView (rect, "oil_view", B_FOLLOW_ALL, B_WILL_DRAW) - { - gSize = 5; - ResizeTo (188, 28); - Slider *sSlid = new Slider (BRect (8, 8, 180, 24), 64, "Mask Size", 3, 15, 2, new BMessage ('oilS')); - sSlid->SetValue (5); - AddChild (sSlid); - } -virtual ~OilView () {}; -virtual void MessageReceived (BMessage *msg); + public: + OilView(BRect rect) : BView(rect, "oil_view", B_FOLLOW_ALL, B_WILL_DRAW) + { + gSize = 5; + ResizeTo(188, 28); + Slider* sSlid = + new Slider(BRect(8, 8, 180, 24), 64, "Mask Size", 3, 15, 2, new BMessage('oilS')); + sSlid->SetValue(5); + AddChild(sSlid); + } + + virtual ~OilView(){}; + virtual void MessageReceived(BMessage* msg); }; -void OilView::MessageReceived (BMessage *msg) +void +OilView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'oilS': - gSize = int (msg->FindFloat ("value") + 0.5); + gSize = int(msg->FindFloat("value") + 0.5); break; default: - BView::MessageReceived (msg); + BView::MessageReceived(msg); return; } addon_preview(); } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "OilPaint"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998-2001 ∑ Sum Software"); - strcpy (info->description, "Simulates an oil painting effect"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 0; - info->release = 7; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "OilPaint"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998-2001 ∑ Sum Software"); + strcpy(info->description, "Simulates an oil painting effect"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 0; + info->release = 7; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } - -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new OilView (rect); + *view = new OilView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /* frame */, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /* frame */, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); - if (*outLayer == NULL && mode== M_DRAW) - { - *outLayer = new Layer (*inLayer); + if (*outLayer == NULL && mode == M_DRAW) { + *outLayer = new Layer(*inLayer); // printf ("Allocated new outLayer\n"); } - if (mode == M_SELECT) - { + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to filter! + *outSelection = new Selection(*inSelection); + else // No Selection to filter! return (0); } if (*outLayer) @@ -157,97 +165,90 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); int32 h = bounds.IntegerHeight() + 1; int32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits() - 1; - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits() - 1; + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. + float delta = 100.0 / h; // For the Status Bar. - switch (mode) - { - case M_DRAW: - { - uint32 slpr = inLayer->BytesPerRow()/4; - uint32 dlpr = (*outLayer)->BytesPerRow()/4; - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits() - 1; + switch (mode) { + case M_DRAW: { + uint32 slpr = inLayer->BytesPerRow() / 4; + uint32 dlpr = (*outLayer)->BytesPerRow() / 4; + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits() - 1; int size = gSize; - int hsize = size/2; // Rounded down. Size is always odd. - cn_list colors (size*size); - -// printf ("size = %i, hsize = %i\n", size, hsize); -// printf ("slpr = %i, dlpr = %i, h = %i, w = %i\n", slpr, (*outLayer)->BytesPerRow(), h, w); - for (int32 y = 0; y < h; y++) - { - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits() + y*dlpr - 1; - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + int hsize = size / 2; // Rounded down. Size is always odd. + cn_list colors(size * size); + + // printf ("size = %i, hsize = %i\n", size, hsize); + // printf ("slpr = %i, dlpr = %i, h = %i, w = %i\n", slpr, (*outLayer)->BytesPerRow(), + // h, w); + for (int32 y = 0; y < h; y++) { + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits() + y * dlpr - 1; + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (int32 x = 0; x < w; x++) - { - if (!inSelection || *(++mapbits)) - { + for (int32 x = 0; x < w; x++) { + if (!inSelection || *(++mapbits)) { int f = 255; if (inSelection) f = *mapbits; - - int32 cl = x - hsize*f/255; - if (cl < 0) cl = 0; - int32 cr = x + hsize*f/255; - if (cr > w - 1) cr = w - 1; - int32 cu = y - hsize*f/255; - if (cu < 0) cu = 0; - int32 cb = y + hsize*f/255; - if (cb > h - 1) cb = h - 1; - - //printf ("(%i, %i) ", y, x); fflush (stdout); - //printf ("LT (%i, %i), RB: (%i, %i)\n", cu, cl, cb, cr); + + int32 cl = x - hsize * f / 255; + if (cl < 0) + cl = 0; + int32 cr = x + hsize * f / 255; + if (cr > w - 1) + cr = w - 1; + int32 cu = y - hsize * f / 255; + if (cu < 0) + cu = 0; + int32 cb = y + hsize * f / 255; + if (cb > h - 1) + cb = h - 1; + + // printf ("(%i, %i) ", y, x); fflush (stdout); + // printf ("LT (%i, %i), RB: (%i, %i)\n", cu, cl, cb, cr); colors.reset(); - for (int32 i = cu; i <= cb; i++) - { - bgra_pixel *s = sbits + i*slpr + cl; + for (int32 i = cu; i <= cb; i++) { + bgra_pixel* s = sbits + i * slpr + cl; for (int32 j = cl; j <= cr; j++) - colors.add (*(++s)); + colors.add(*(++s)); } // printf ("(%ld, %ld) -> %p\n", x, y, colors.most_frequent()); *(++dbits) = colors.most_frequent(); - } - else - *(++dbits) = *(sbits + y*slpr + x); + } else + *(++dbits) = *(sbits + y * slpr + x); } if (inSelection) mapbits += mdiff; } break; } - case M_SELECT: - { + case M_SELECT: { if (!inSelection) *outSelection = NULL; - else - { + else { } break; } default: - fprintf (stderr, "OilPaint: Unknown mode\n"); + fprintf(stderr, "OilPaint: Unknown mode\n"); error = ADDON_UNKNOWN; } - + if (*outSelection) (*outSelection)->Unlock(); if (*outLayer) diff --git a/source/BecassoAPI2.0/API/Scale.cpp b/source/BecassoAPI2.0/API/Scale.cpp index 65ef8da..e4dd6f3 100644 --- a/source/BecassoAPI2.0/API/Scale.cpp +++ b/source/BecassoAPI2.0/API/Scale.cpp @@ -5,42 +5,48 @@ #include #include -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Scale"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998-2001 ∑ Sum Software"); - strcpy (info->description, "Resize a selection of the canvas"); - info->type = BECASSO_TRANSFORMER; - info->index = index; - info->version = 1; - info->release = 1; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE | PREVIEW_MOUSE | LAYER_AND_SELECTION; - info->flags = 0; + strcpy(info->name, "Scale"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998-2001 ∑ Sum Software"); + strcpy(info->description, "Resize a selection of the canvas"); + info->type = BECASSO_TRANSFORMER; + info->index = index; + info->version = 1; + info->release = 1; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE | PREVIEW_MOUSE | LAYER_AND_SELECTION; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = NULL; // Scale has no GUI + *view = NULL; // Scale has no GUI return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect *frame, bool final, BPoint point, uint32 buttons) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* frame, bool final, BPoint point, uint32 buttons +) { // We don't use the StatusBar in the present incarnation of the Scale add-on, // because everything happens interactively and the final anti-aliased drawing @@ -49,104 +55,118 @@ status_t process (Layer *inLayer, Selection *inSelection, // a given BStatusBar object. static bool entry = false; - static BPoint firstpoint = BPoint (-1, -1); - static BPoint lastpoint = BPoint (-1, -1); - static Layer *oLayer = NULL; - static Selection *oSelection = NULL; + static BPoint firstpoint = BPoint(-1, -1); + static BPoint lastpoint = BPoint(-1, -1); + static Layer* oLayer = NULL; + static Selection* oSelection = NULL; static BRect oBounds = EmptyRect; static int varcorner = -1; static BRect newrect; int error = ADDON_OK; - - if (/*!inLayer || */!inSelection) - { - printf ("Scale only works with a valid selection ATM.\n"); + + if (/*!inLayer || */ !inSelection) { + printf("Scale only works with a valid selection ATM.\n"); return (error); } - - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = inLayer;//new Layer (*inLayer); + + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = inLayer; // new Layer (*inLayer); if (*outSelection == NULL) - *outSelection = inSelection;//new Selection (*inSelection); + *outSelection = inSelection; // new Selection (*inSelection); -// if (*outLayer) -// (*outLayer)->Lock(); -// if (*outSelection) -// (*outSelection)->Lock(); - - if (final) - { + // if (*outLayer) + // (*outLayer)->Lock(); + // if (*outSelection) + // (*outSelection)->Lock(); + + if (final) { // This means the user has clicked "Apply". // Set up our local cutout copies of the original layer and selection. // We still do this (although Becasso (as of 1.3) passes add-ons a "clean" // layer each time) because it saves us the work of cutting out the selected part. - -// firstpoint = point; + + // firstpoint = point; oBounds = *frame; BRect bounds = oBounds; // oBounds.PrintToStream(); - bounds.OffsetTo (B_ORIGIN); - oLayer = new Layer (bounds, "tmpLayer"); - oSelection = new Selection (bounds); - BView *view = new BView (bounds, "tmp view", 0, 0); + bounds.OffsetTo(B_ORIGIN); + oLayer = new Layer(bounds, "tmpLayer"); + oSelection = new Selection(bounds); + BView* view = new BView(bounds, "tmp view", 0, 0); oSelection->Lock(); - oSelection->AddChild (view); - view->DrawBitmap (inSelection, BPoint (-oBounds.left, -oBounds.top)); + oSelection->AddChild(view); + view->DrawBitmap(inSelection, BPoint(-oBounds.left, -oBounds.top)); view->Sync(); - oSelection->RemoveChild (view); + oSelection->RemoveChild(view); oSelection->Unlock(); entry = true; -// float dlt = ((frame->left - firstpoint.x)*(frame->left - firstpoint.x) + (frame->top - firstpoint.y)*(frame->top - firstpoint.y)); -// float drt = ((frame->right - firstpoint.x)*(frame->right - firstpoint.x) + (frame->top - firstpoint.y)*(frame->top - firstpoint.y)); -// float dlb = ((frame->left - firstpoint.x)*(frame->left - firstpoint.x) + (frame->bottom - firstpoint.y)*(frame->bottom - firstpoint.y)); -// float drb = ((frame->right - firstpoint.x)*(frame->right - firstpoint.x) + (frame->bottom - firstpoint.y)*(frame->bottom - firstpoint.y)); -// varcorner = 0; // LeftTop -// if (drt < dlt) varcorner = 1; // RightTop -// if (dlb < drt && dlb < dlt) varcorner = 2; // LeftBottom -// if (drb < dlb && drb < drt && drb < dlt) varcorner = 3; // RightBottom - printf ("Scale: final - setup done\n"); + // float dlt = ((frame->left - firstpoint.x)*(frame->left - firstpoint.x) + (frame->top + //- firstpoint.y)*(frame->top - firstpoint.y)); float drt = ((frame->right - + // firstpoint.x)*(frame->right - firstpoint.x) + (frame->top - firstpoint.y)*(frame->top - + // firstpoint.y)); float dlb = ((frame->left - firstpoint.x)*(frame->left - + // firstpoint.x) + (frame->bottom - firstpoint.y)*(frame->bottom - firstpoint.y)); + // float drb = ((frame->right + //- firstpoint.x)*(frame->right - firstpoint.x) + (frame->bottom - + // firstpoint.y)*(frame->bottom - firstpoint.y)); varcorner = 0; // LeftTop if + // (drt < dlt) varcorner = 1; // RightTop if (dlb < drt && dlb < dlt) varcorner = + // 2; // LeftBottom if (drb < dlb && drb < drt && drb < dlt) varcorner = 3; // + // RightBottom + printf("Scale: final - setup done\n"); } - - if (!final && buttons && !entry) // First entry of a realtime drag + + if (!final && buttons && !entry) // First entry of a realtime drag { // Set up our local cutout copies of the original layer and selection. // We still do this (although Becasso (as of 1.3) passes add-ons a "clean" // layer each time) because it saves us the work of cutting out the selected part. - + firstpoint = point; oBounds = *frame; BRect bounds = oBounds; // oBounds.PrintToStream(); - bounds.OffsetTo (B_ORIGIN); - oLayer = new Layer (bounds, "tmpLayer"); - oSelection = new Selection (bounds); - BView *view = new BView (bounds, "tmp view", 0, 0); + bounds.OffsetTo(B_ORIGIN); + oLayer = new Layer(bounds, "tmpLayer"); + oSelection = new Selection(bounds); + BView* view = new BView(bounds, "tmp view", 0, 0); oSelection->Lock(); - oSelection->AddChild (view); - view->DrawBitmap (inSelection, BPoint (-oBounds.left, -oBounds.top)); + oSelection->AddChild(view); + view->DrawBitmap(inSelection, BPoint(-oBounds.left, -oBounds.top)); view->Sync(); - oSelection->RemoveChild (view); + oSelection->RemoveChild(view); oSelection->Unlock(); - + entry = true; - float dlt = ((frame->left - firstpoint.x)*(frame->left - firstpoint.x) + (frame->top - firstpoint.y)*(frame->top - firstpoint.y)); - float drt = ((frame->right - firstpoint.x)*(frame->right - firstpoint.x) + (frame->top - firstpoint.y)*(frame->top - firstpoint.y)); - float dlb = ((frame->left - firstpoint.x)*(frame->left - firstpoint.x) + (frame->bottom - firstpoint.y)*(frame->bottom - firstpoint.y)); - float drb = ((frame->right - firstpoint.x)*(frame->right - firstpoint.x) + (frame->bottom - firstpoint.y)*(frame->bottom - firstpoint.y)); + float dlt = + ((frame->left - firstpoint.x) * (frame->left - firstpoint.x) + + (frame->top - firstpoint.y) * (frame->top - firstpoint.y)); + float drt = + ((frame->right - firstpoint.x) * (frame->right - firstpoint.x) + + (frame->top - firstpoint.y) * (frame->top - firstpoint.y)); + float dlb = + ((frame->left - firstpoint.x) * (frame->left - firstpoint.x) + + (frame->bottom - firstpoint.y) * (frame->bottom - firstpoint.y)); + float drb = + ((frame->right - firstpoint.x) * (frame->right - firstpoint.x) + + (frame->bottom - firstpoint.y) * (frame->bottom - firstpoint.y)); varcorner = 0; // LeftTop - if (drt < dlt) varcorner = 1; // RightTop - if (dlb < drt && dlb < dlt) varcorner = 2; // LeftBottom - if (drb < dlb && drb < drt && drb < dlt) varcorner = 3; // RightBottom + if (drt < dlt) + varcorner = 1; // RightTop + if (dlb < drt && dlb < dlt) + varcorner = 2; // LeftBottom + if (drb < dlb && drb < drt && drb < dlt) + varcorner = 3; // RightBottom } if (buttons) lastpoint = point; - if (mode == M_DRAW) - { + if (mode == M_DRAW) { oLayer->Lock(); inLayer->Lock(); inSelection->Lock(); - CutOrCopy (*outLayer ? *outLayer : inLayer, oLayer, inSelection, int (oBounds.left), int (oBounds.top), true); + CutOrCopy( + *outLayer ? *outLayer : inLayer, oLayer, inSelection, int(oBounds.left), + int(oBounds.top), true + ); inSelection->Unlock(); inLayer->Unlock(); oLayer->Unlock(); @@ -155,10 +175,9 @@ status_t process (Layer *inLayer, Selection *inSelection, BRect lframe = *frame; newrect = lframe; BRect bounds = lframe; - bounds.OffsetTo (B_ORIGIN); -// lastpoint = point; - switch (varcorner) - { + bounds.OffsetTo(B_ORIGIN); + // lastpoint = point; + switch (varcorner) { case 0: newrect.left = lastpoint.x; newrect.top = lastpoint.y; @@ -177,63 +196,62 @@ status_t process (Layer *inLayer, Selection *inSelection, } if (newrect.right <= newrect.left || newrect.bottom <= newrect.top) return (0); - + rgb_color hi = highcolor(); rgb_color lo = lowcolor(); - + if (*outLayer) (*outLayer)->Lock(); if (*outSelection) (*outSelection)->Lock(); - switch (mode) - { - case M_DRAW: - { - if (*outLayer && buttons) // The user is dragging. + switch (mode) { + case M_DRAW: { + if (*outLayer && buttons) // The user is dragging. { - printf ("Dragging\n"); + printf("Dragging\n"); BRect newbounds = newrect; - newbounds.OffsetTo (B_ORIGIN); - Layer *sLayer = new Layer (newbounds, "Scaled Layer"); - BView *view = new BView (newbounds, "tmp view", 0, 0); - view->SetHighColor (contrastingcolor (lo, hi)); + newbounds.OffsetTo(B_ORIGIN); + Layer* sLayer = new Layer(newbounds, "Scaled Layer"); + BView* view = new BView(newbounds, "tmp view", 0, 0); + view->SetHighColor(contrastingcolor(lo, hi)); sLayer->Lock(); - sLayer->AddChild (view); - view->DrawBitmap (oLayer, oLayer->Bounds(), newbounds); - view->StrokeRect (newbounds); + sLayer->AddChild(view); + view->DrawBitmap(oLayer, oLayer->Bounds(), newbounds); + view->StrokeRect(newbounds); view->Sync(); - sLayer->RemoveChild (view); + sLayer->RemoveChild(view); delete view; - AddWithAlpha (sLayer, (*outLayer), int (newrect.left), int (newrect.top)); + AddWithAlpha(sLayer, (*outLayer), int(newrect.left), int(newrect.top)); delete sLayer; - } - else if (entry) // The user has released the mouse. Clean up. + } else if (entry) // The user has released the mouse. Clean up. // N.B. We also get here when "Apply" is clicked. { - printf ("Clean up\n"); - firstpoint = BPoint (-1, -1); + printf("Clean up\n"); + firstpoint = BPoint(-1, -1); BRect newbounds = newrect; - newbounds.OffsetTo (B_ORIGIN); + newbounds.OffsetTo(B_ORIGIN); // newrect.PrintToStream(); - BView *view = new BView (inLayer->Bounds(), "tmp view", 0, 0); - Layer *sLayer = new Layer (newbounds, "Scaled Layer"); - Selection *sSelection = new Selection (newbounds); - Scale (oLayer, oSelection, sLayer, sSelection); - AddWithAlpha (sLayer, (*outLayer) ? (*outLayer) : inLayer, int (newrect.left), int (newrect.top)); + BView* view = new BView(inLayer->Bounds(), "tmp view", 0, 0); + Layer* sLayer = new Layer(newbounds, "Scaled Layer"); + Selection* sSelection = new Selection(newbounds); + Scale(oLayer, oSelection, sLayer, sSelection); + AddWithAlpha( + sLayer, (*outLayer) ? (*outLayer) : inLayer, int(newrect.left), int(newrect.top) + ); if (*outSelection) - (*outSelection)->AddChild (view); + (*outSelection)->AddChild(view); else - inSelection->AddChild (view); + inSelection->AddChild(view); - view->SetLowColor (SELECT_NONE); - view->FillRect (inLayer->Bounds(), B_SOLID_LOW); - view->DrawBitmap (sSelection, newrect.LeftTop()); + view->SetLowColor(SELECT_NONE); + view->FillRect(inLayer->Bounds(), B_SOLID_LOW); + view->DrawBitmap(sSelection, newrect.LeftTop()); view->Sync(); if (*outSelection) - (*outSelection)->RemoveChild (view); + (*outSelection)->RemoveChild(view); else - inSelection->RemoveChild (view); + inSelection->RemoveChild(view); delete view; delete sLayer; delete sSelection; @@ -245,43 +263,41 @@ status_t process (Layer *inLayer, Selection *inSelection, } break; } - case M_SELECT: - { - if (*outSelection && buttons) // The user is dragging. + case M_SELECT: { + if (*outSelection && buttons) // The user is dragging. { BRect newbounds = newrect; - newbounds.OffsetTo (B_ORIGIN); - BView *view = new BView (inSelection->Bounds(), "tmp view", 0, 0); - (*outSelection)->AddChild (view); - view->SetLowColor (SELECT_NONE); - view->FillRect (inLayer->Bounds(), B_SOLID_LOW); - view->DrawBitmapAsync (oSelection, oSelection->Bounds(), newrect); + newbounds.OffsetTo(B_ORIGIN); + BView* view = new BView(inSelection->Bounds(), "tmp view", 0, 0); + (*outSelection)->AddChild(view); + view->SetLowColor(SELECT_NONE); + view->FillRect(inLayer->Bounds(), B_SOLID_LOW); + view->DrawBitmapAsync(oSelection, oSelection->Bounds(), newrect); view->Sync(); - (*outSelection)->RemoveChild (view); + (*outSelection)->RemoveChild(view); delete view; - } - else if (entry) // The user has released the mouse. Clean up. + } else if (entry) // The user has released the mouse. Clean up. // N.B. We also get here when "Apply" is clicked. { - firstpoint = BPoint (-1, -1); + firstpoint = BPoint(-1, -1); BRect newbounds = newrect; - newbounds.OffsetTo (B_ORIGIN); + newbounds.OffsetTo(B_ORIGIN); // newrect.PrintToStream(); - BView *view = new BView (inLayer->Bounds(), "tmp view", 0, 0); - Selection *sSelection = new Selection (newbounds); - Scale (NULL, oSelection, NULL, sSelection); + BView* view = new BView(inLayer->Bounds(), "tmp view", 0, 0); + Selection* sSelection = new Selection(newbounds); + Scale(NULL, oSelection, NULL, sSelection); if (*outSelection) - (*outSelection)->AddChild (view); + (*outSelection)->AddChild(view); else - inSelection->AddChild (view); - view->SetLowColor (SELECT_NONE); - view->FillRect (inLayer->Bounds(), B_SOLID_LOW); - view->DrawBitmap (sSelection, newrect.LeftTop()); + inSelection->AddChild(view); + view->SetLowColor(SELECT_NONE); + view->FillRect(inLayer->Bounds(), B_SOLID_LOW); + view->DrawBitmap(sSelection, newrect.LeftTop()); view->Sync(); if (*outSelection) - (*outSelection)->RemoveChild (view); + (*outSelection)->RemoveChild(view); else - inSelection->RemoveChild (view); + inSelection->RemoveChild(view); delete view; delete sSelection; entry = false; @@ -293,7 +309,7 @@ status_t process (Layer *inLayer, Selection *inSelection, break; } default: - fprintf (stderr, "Scale: Unknown mode\n"); + fprintf(stderr, "Scale: Unknown mode\n"); error = 1; } diff --git a/source/BecassoAPI2.0/API/Selection.h b/source/BecassoAPI2.0/API/Selection.h index 470bea9..c328a49 100644 --- a/source/BecassoAPI2.0/API/Selection.h +++ b/source/BecassoAPI2.0/API/Selection.h @@ -10,19 +10,23 @@ class IMPEXP Selection : public BBitmap { -public: - Selection (BRect bounds); - Selection (const Selection& selection); - ~Selection (); -int getMode () { return fMode; }; -void setMode (int mode) { fMode = mode; }; -BRect Bounds () { return fRect; }; -void ClearTo (grey_pixel p); - -private: -typedef BBitmap inherited; -BRect fRect; -int fMode; + public: + Selection(BRect bounds); + Selection(const Selection& selection); + ~Selection(); + + int getMode() { return fMode; }; + + void setMode(int mode) { fMode = mode; }; + + BRect Bounds() { return fRect; }; + + void ClearTo(grey_pixel p); + + private: + typedef BBitmap inherited; + BRect fRect; + int fMode; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/BecassoAPI2.0/API/Slider.h b/source/BecassoAPI2.0/API/Slider.h index c9a9d52..d407050 100644 --- a/source/BecassoAPI2.0/API/Slider.h +++ b/source/BecassoAPI2.0/API/Slider.h @@ -12,45 +12,48 @@ class IMPEXP Slider : public BView { -public: - Slider (BRect frame, float sep, const char *name, float _min, float _max, float step, BMessage *_msg, orientation _posture = B_HORIZONTAL, int f = 0, const char *_fmt = "%.0f"); - ~Slider (); -//void ValueChanged (long newValue); -virtual void MouseDown (BPoint point); -virtual void Draw (BRect update); -virtual void AttachedToWindow (); -virtual void MessageReceived (BMessage *msg); -virtual void KeyDown (const char *bytes, int32 numBytes); -virtual void MakeFocus (bool focused = true); -virtual void SetTarget (BHandler *target); -float Value (); -void SetValue (float _v); + public: + Slider( + BRect frame, float sep, const char* name, float _min, float _max, float step, + BMessage* _msg, orientation _posture = B_HORIZONTAL, int f = 0, const char* _fmt = "%.0f" + ); + ~Slider(); + // void ValueChanged (long newValue); + virtual void MouseDown(BPoint point); + virtual void Draw(BRect update); + virtual void AttachedToWindow(); + virtual void MessageReceived(BMessage* msg); + virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void MakeFocus(bool focused = true); + virtual void SetTarget(BHandler* target); + float Value(); + void SetValue(float _v); -private: -typedef BView inherited; -void NotifyTarget (); -float min; -float max; -float sep; -float step; -BMessage *msg; -char fmt[16]; -char name[64]; -orientation pos; -float value; -BRect bounds; -BRect knob; -BBitmap *offslid; -BView *offview; -BPoint knobpos; -float knobsize; -int f; -float width; -float height; -bigtime_t dcspeed; -int click; -BTextControl *tc; -BHandler *target; + private: + typedef BView inherited; + void NotifyTarget(); + float min; + float max; + float sep; + float step; + BMessage* msg; + char fmt[16]; + char name[64]; + orientation pos; + float value; + BRect bounds; + BRect knob; + BBitmap* offslid; + BView* offview; + BPoint knobpos; + float knobsize; + int f; + float width; + float height; + bigtime_t dcspeed; + int click; + BTextControl* tc; + BHandler* target; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/BecassoAPI2.0/API/TabView.h b/source/BecassoAPI2.0/API/TabView.h index e72e824..d310527 100644 --- a/source/BecassoAPI2.0/API/TabView.h +++ b/source/BecassoAPI2.0/API/TabView.h @@ -8,30 +8,30 @@ #include #include "Build.h" -#define MAX_VIEWS 32 -#define MAX_TAB 32 +#define MAX_VIEWS 32 +#define MAX_TAB 32 #define TAB_HEIGHT 16 class IMPEXP TabView : public BView { -public: - TabView (BRect frame, const char *name, uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP); -virtual ~TabView (); -virtual void Draw (BRect update); -virtual void MouseDown (BPoint point); -virtual void KeyDown (const char *bytes, int32 numBytes); -virtual void MakeFocus (bool focused = true); -void AddView (BView *view, const char *tab); -//BView *Current (); -void RaiseView (int n); + public: + TabView(BRect frame, const char* name, uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP); + virtual ~TabView(); + virtual void Draw(BRect update); + virtual void MouseDown(BPoint point); + virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void MakeFocus(bool focused = true); + void AddView(BView* view, const char* tab); + // BView *Current (); + void RaiseView(int n); -private: -typedef BView inherited; -BView *views[MAX_VIEWS]; -char tabname[MAX_VIEWS][MAX_TAB]; -int index; -int current; -int focusedview; + private: + typedef BView inherited; + BView* views[MAX_VIEWS]; + char tabname[MAX_VIEWS][MAX_TAB]; + int index; + int current; + int focusedview; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/BecassoAddOn.h b/source/BecassoAddOn.h index 936d626..bbd1e7f 100644 --- a/source/BecassoAddOn.h +++ b/source/BecassoAddOn.h @@ -12,153 +12,176 @@ class BView; -# define ADDON_EXPORT +#define ADDON_EXPORT // Undefined Hue - some of the HSV functions from Becasso can return this. #define HUE_UNDEF -1.0 // The type of add-on -#define BECASSO_FILTER 0 -#define BECASSO_TRANSFORMER 1 -#define BECASSO_GENERATOR 2 -#define BECASSO_CAPTURE 3 +#define BECASSO_FILTER 0 +#define BECASSO_TRANSFORMER 1 +#define BECASSO_GENERATOR 2 +#define BECASSO_CAPTURE 3 // Defines for constructing a preview info bit mask -#define PREVIEW_FULLSCALE 1 -#define PREVIEW_2x2 2 -#define PREVIEW_MOUSE 4 -#define LAYER_AND_SELECTION 8 +#define PREVIEW_FULLSCALE 1 +#define PREVIEW_2x2 2 +#define PREVIEW_MOUSE 4 +#define LAYER_AND_SELECTION 8 // Defines for addon type -#define LAYER_ONLY 1 -#define SELECTION_ONLY 2 +#define LAYER_ONLY 1 +#define SELECTION_ONLY 2 // Return codes for the process() function -#define ADDON_OK 0 -#define ADDON_ABORT 1 -#define ADDON_UNKNOWN 2 +#define ADDON_OK 0 +#define ADDON_ABORT 1 +#define ADDON_UNKNOWN 2 // Messages used in the communication with Becasso -#define ADDON_CLOSES 'AOcl' -#define ADDON_PREVIEW 'AOpr' -#define ADDON_RESIZED 'AOrz' -#define ADDON_FILTER 'ao_f' -#define ADDON_TRANSFORMER 'ao_t' -#define ADDON_GENERATOR 'ao_g' -#define CAPTURE_READY 'CTrd' - -// Useful functions to keep your add-on code as +#define ADDON_CLOSES 'AOcl' +#define ADDON_PREVIEW 'AOpr' +#define ADDON_RESIZED 'AOrz' +#define ADDON_FILTER 'ao_f' +#define ADDON_TRANSFORMER 'ao_t' +#define ADDON_GENERATOR 'ao_g' +#define CAPTURE_READY 'CTrd' + +// Useful functions to keep your add-on code as // processor-agnostic as possible -#if defined (__POWERPC__) -# define COLOR_MASK 0xFFFFFF00 -# define ALPHA_MASK 0x000000FF -# define RED_MASK 0x0000FF00 -# define GREEN_MASK 0x00FF0000 -# define BLUE_MASK 0xFF000000 -# define CYAN_MASK 0xFF000000 -# define MAGENTA_MASK 0x00FF0000 -# define YELLOW_MASK 0x0000FF00 -# define BLACK_MASK 0x000000FF -# define IRED_MASK 0xFFFF00FF -# define IGREEN_MASK 0xFF00FFFF -# define IBLUE_MASK 0x00FFFFFF -# define ICYAN_MASK 0x00FFFFFF -# define IMAGENTA_MASK 0xFF00FFFF -# define IYELLOW_MASK 0xFFFF00FF -# define IBLACK_MASK 0xFFFFFF00 -# define ALPHA_BPOS 0 -# define RED_BPOS 8 -# define GREEN_BPOS 16 -# define BLUE_BPOS 24 -# define CYAN_BPOS 24 -# define MAGENTA_BPOS 16 -# define YELLOW_BPOS 8 -# define BLACK_BPOS 0 -# define BLUE(x) ((x) >> 24) -# define GREEN(x) (((x) >> 16) & 0xFF) -# define RED(x) (((x) >> 8) & 0xFF) -# define ALPHA(x) ((x) & 0xFF) -# define CYAN(x) ((x) & 0xFF) -# define MAGENTA(x) (((x) >> 8) & 0xFF) -# define YELLOW(x) (((x) >> 16) & 0xFF) -# define BLACK(x) ((x) >> 24) -# define PIXEL(r,g,b,a) (((int(b) << 24) & 0xFF000000) | ((int(g) << 16) & 0xFF0000) | ((int(r) << 8) & 0xFF00) | (int(a) & 0xFF)) -#else // IA -# define COLOR_MASK 0x00FFFFFF -# define ALPHA_MASK 0xFF000000 -# define RED_MASK 0x00FF0000 -# define GREEN_MASK 0x0000FF00 -# define BLUE_MASK 0x000000FF -# define CYAN_MASK 0x000000FF -# define MAGENTA_MASK 0x0000FF00 -# define YELLOW_MASK 0x00FF0000 -# define BLACK_MASK 0xFF000000 -# define IRED_MASK 0xFF00FFFF -# define IGREEN_MASK 0xFFFF00FF -# define IBLUE_MASK 0xFFFFFF00 -# define ICYAN_MASK 0xFFFFFF00 -# define IMAGENTA_MASK 0xFFFF00FF -# define IYELLOW_MASK 0xFF00FFFF -# define IBLACK_MASK 0x00FFFFFF -# define ALPHA_BPOS 24 -# define RED_BPOS 16 -# define GREEN_BPOS 8 -# define BLUE_BPOS 0 -# define CYAN_BPOS 0 -# define MAGENTA_BPOS 8 -# define YELLOW_BPOS 16 -# define BLACK_BPOS 24 -# define ALPHA(x) ((x) >> 24) -# define RED(x) (((x) >> 16) & 0xFF) -# define GREEN(x) (((x) >> 8) & 0xFF) -# define BLUE(x) ((x) & 0xFF) -# define CYAN(x) ((x) & 0xFF) -# define MAGENTA(x) (((x) >> 8) & 0xFF) -# define YELLOW(x) (((x) >> 16) & 0xFF) -# define BLACK(x) ((x) >> 24) -# define PIXEL(r,g,b,a) (((int(a) << 24) & 0xFF000000) | ((int(r) << 16) & 0xFF0000) | ((int(g) << 8) & 0xFF00) | (int(b) & 0xFF)) +#if defined(__POWERPC__) +#define COLOR_MASK 0xFFFFFF00 +#define ALPHA_MASK 0x000000FF +#define RED_MASK 0x0000FF00 +#define GREEN_MASK 0x00FF0000 +#define BLUE_MASK 0xFF000000 +#define CYAN_MASK 0xFF000000 +#define MAGENTA_MASK 0x00FF0000 +#define YELLOW_MASK 0x0000FF00 +#define BLACK_MASK 0x000000FF +#define IRED_MASK 0xFFFF00FF +#define IGREEN_MASK 0xFF00FFFF +#define IBLUE_MASK 0x00FFFFFF +#define ICYAN_MASK 0x00FFFFFF +#define IMAGENTA_MASK 0xFF00FFFF +#define IYELLOW_MASK 0xFFFF00FF +#define IBLACK_MASK 0xFFFFFF00 +#define ALPHA_BPOS 0 +#define RED_BPOS 8 +#define GREEN_BPOS 16 +#define BLUE_BPOS 24 +#define CYAN_BPOS 24 +#define MAGENTA_BPOS 16 +#define YELLOW_BPOS 8 +#define BLACK_BPOS 0 +#define BLUE(x) ((x) >> 24) +#define GREEN(x) (((x) >> 16) & 0xFF) +#define RED(x) (((x) >> 8) & 0xFF) +#define ALPHA(x) ((x) & 0xFF) +#define CYAN(x) ((x) & 0xFF) +#define MAGENTA(x) (((x) >> 8) & 0xFF) +#define YELLOW(x) (((x) >> 16) & 0xFF) +#define BLACK(x) ((x) >> 24) +#define PIXEL(r, g, b, a) \ + (((int(b) << 24) & 0xFF000000) | ((int(g) << 16) & 0xFF0000) | ((int(r) << 8) & 0xFF00) | \ + (int(a) & 0xFF)) +#else // IA +#define COLOR_MASK 0x00FFFFFF +#define ALPHA_MASK 0xFF000000 +#define RED_MASK 0x00FF0000 +#define GREEN_MASK 0x0000FF00 +#define BLUE_MASK 0x000000FF +#define CYAN_MASK 0x000000FF +#define MAGENTA_MASK 0x0000FF00 +#define YELLOW_MASK 0x00FF0000 +#define BLACK_MASK 0xFF000000 +#define IRED_MASK 0xFF00FFFF +#define IGREEN_MASK 0xFFFF00FF +#define IBLUE_MASK 0xFFFFFF00 +#define ICYAN_MASK 0xFFFFFF00 +#define IMAGENTA_MASK 0xFFFF00FF +#define IYELLOW_MASK 0xFF00FFFF +#define IBLACK_MASK 0x00FFFFFF +#define ALPHA_BPOS 24 +#define RED_BPOS 16 +#define GREEN_BPOS 8 +#define BLUE_BPOS 0 +#define CYAN_BPOS 0 +#define MAGENTA_BPOS 8 +#define YELLOW_BPOS 16 +#define BLACK_BPOS 24 +#define ALPHA(x) ((x) >> 24) +#define RED(x) (((x) >> 16) & 0xFF) +#define GREEN(x) (((x) >> 8) & 0xFF) +#define BLUE(x) ((x) & 0xFF) +#define CYAN(x) ((x) & 0xFF) +#define MAGENTA(x) (((x) >> 8) & 0xFF) +#define YELLOW(x) (((x) >> 16) & 0xFF) +#define BLACK(x) ((x) >> 24) +#define PIXEL(r, g, b, a) \ + (((int(a) << 24) & 0xFF000000) | ((int(r) << 16) & 0xFF0000) | ((int(g) << 8) & 0xFF00) | \ + (int(b) & 0xFF)) #endif // Rectangle constants -const BRect EmptyRect = BRect (0, 0, 0, 0); +const BRect EmptyRect = BRect(0, 0, 0, 0); // The becasso_addon_info struct typedef struct { - char name[80]; // The name as it appears in the menu - uint32 index; // A unique index assigned at init time - int type; // Filter, Transformer, Generator, or Capture - int version; // Version of the add-on - int release; // Release of the add-on - int becasso_version; // Required Becasso version (other won't load) - int becasso_release; // Written for release (older will warn) - char author[128]; // Author (company) of the add-on - char copyright[128]; // Copyright notice - char description[256]; // Explains what the add-on does - uint8 does_preview; // bitmask for various preview notifications - uint32 flags; // bitmask + char name[80]; // The name as it appears in the menu + uint32 index; // A unique index assigned at init time + int type; // Filter, Transformer, Generator, or Capture + int version; // Version of the add-on + int release; // Release of the add-on + int becasso_version; // Required Becasso version (other won't load) + int becasso_release; // Written for release (older will warn) + char author[128]; // Author (company) of the add-on + char copyright[128]; // Copyright notice + char description[256]; // Explains what the add-on does + uint8 does_preview; // bitmask for various preview notifications + uint32 flags; // bitmask } becasso_addon_info; // Function prototypes -extern "C" ADDON_EXPORT status_t addon_init (uint32 index, becasso_addon_info *info); -extern "C" ADDON_EXPORT status_t addon_exit (void); -extern "C" ADDON_EXPORT status_t addon_close (void); -extern "C" ADDON_EXPORT status_t addon_make_config (BView **view, BRect rect); -extern "C" ADDON_EXPORT status_t process (Layer *inLayer, Selection *inSelection, Layer **outLayer, Selection **outSelection, int32 mode, BRect *frame, bool final, BPoint point, uint32 buttons); +extern "C" ADDON_EXPORT status_t +addon_init(uint32 index, becasso_addon_info* info); +extern "C" ADDON_EXPORT status_t +addon_exit(void); +extern "C" ADDON_EXPORT status_t +addon_close(void); +extern "C" ADDON_EXPORT status_t +addon_make_config(BView** view, BRect rect); +extern "C" ADDON_EXPORT status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* frame, bool final, BPoint point, uint32 buttons +); // for Capture add-ons -extern "C" ADDON_EXPORT status_t addon_open (void); -extern "C" ADDON_EXPORT BBitmap *bitmap (char *title); +extern "C" ADDON_EXPORT status_t +addon_open(void); +extern "C" ADDON_EXPORT BBitmap* +bitmap(char* title); // optional hooks -extern "C" ADDON_EXPORT void addon_color_changed (void); -extern "C" ADDON_EXPORT void addon_mode_changed (void); +extern "C" ADDON_EXPORT void +addon_color_changed(void); +extern "C" ADDON_EXPORT void +addon_mode_changed(void); // Status updating calls -IMPEXP void addon_start (void); -IMPEXP bool addon_stop (void); -IMPEXP void addon_done (void); -IMPEXP void addon_update_statusbar (float delta, const char *text = NULL, const char *trailingText = NULL); -IMPEXP void addon_reset_statusbar (const char *label = NULL, const char *trailingText = NULL); -IMPEXP void addon_preview (void); -IMPEXP void addon_refresh_config (void); +IMPEXP void +addon_start(void); +IMPEXP bool +addon_stop(void); +IMPEXP void +addon_done(void); +IMPEXP void +addon_update_statusbar(float delta, const char* text = NULL, const char* trailingText = NULL); +IMPEXP void +addon_reset_statusbar(const char* label = NULL, const char* trailingText = NULL); +IMPEXP void +addon_preview(void); +IMPEXP void +addon_refresh_config(void); #endif diff --git a/source/BecassoMain.cpp b/source/BecassoMain.cpp index bc78e24..830b25c 100644 --- a/source/BecassoMain.cpp +++ b/source/BecassoMain.cpp @@ -21,85 +21,93 @@ #include "Settings.h" #include "RegWindow.h" -//#define TIME_LIMITED 1 +// #define TIME_LIMITED 1 -#define REGISTERED 0 -#define EASTER_EGG false +#define REGISTERED 0 +#define EASTER_EGG false -#define KEYFILE_MASK 0x87, 0xF6, 0xA1, 0x7C, 0xD6, 0x3A, 0x87, 0xE6, 0x0E, 0x84, 0xF6, 0xCA, 0x81, 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 0xA6, 0x19, \ + 0xEE, 0x28, 0x7F, 0x68, 0x48, 0x7D, 0xD6, 0x5A, 0xB3, 0x8C, 0xF7, 0x52, 0xFE, 0x32, 0xD9, \ + 0x84, 0xA7, 0xA5, 0xC9, 0x87, 0x2A, 0x8F, 0xF7, 0x6D, 0x48, 0x7D, 0xE6, 0x25, 0xED, 0x54, \ + 0x9B, 0xC3, 0x6A, 0xA5, 0x98, 0x64, 0xAC, 0x10, 0xD9, 0x8F, 0xE7, 0x30, 0xA9, 0x54, 0xE4, \ + 0x5C, 0xD4, 0x35, 0xA4, 0x35, 0xFF, 0x26, 0x4F, 0x87, 0xEA, 0x65, 0x3B, 0xDE, 0x48, 0x76, \ + 0x1E, 0xB8, 0x72, 0xC5, 0xD8, 0x5E, 0x8A, 0x24 -Becasso *mainapp; -SplashWindow *splash; +Becasso* mainapp; +SplashWindow* splash; bool VerbQuit, VerbAddOns, NoAddOns, EasterEgg, UseMMX, ShowColors, ExportCstruct; bool PatronizeMIME, BuiltInTablet, NoSettings, WriteSettings; int gGlobalAlpha; // this is actually "Registered", but for people with debuggers... -char gAlphaBuffer[256]; // this actually holds the key file +char gAlphaBuffer[256]; // this actually holds the key file char gAlphaMask[128]; // Registered to int SilentOperation; PrefsLoader g_prefsloader; -extern "C" int sqr (int a); +extern "C" int +sqr(int a); -void generate_alphabuffer (char *alpha); +void +generate_alphabuffer(char* alpha); + // This is for existing Becasso users upon first launch, to generate // the keyfile. Silly check: simply look for the SoftwareValet db file // (it need only exist, so a user can fake it by simply touching it. Oh well.) -void generate_alphabuffer (char *alpha) +void +generate_alphabuffer(char* alpha) { BPath p; char reg = REG_NONE; -#if defined (__POWERPC__) +#if defined(__POWERPC__) reg = REG_PPC; #else char path[B_FILE_NAME_LENGTH]; - find_directory (B_USER_SETTINGS_DIRECTORY, &p); - strcpy (path, p.Path()); - strcat (path, "/packages/Becasso 1.41.4.db"); - FILE *db = fopen (path, "rb"); - if (db) // db file exists, so generate the keyfile here. + find_directory(B_USER_SETTINGS_DIRECTORY, &p); + strcpy(path, p.Path()); + strcat(path, "/packages/Becasso 1.41.4.db"); + FILE* db = fopen(path, "rb"); + if (db) // db file exists, so generate the keyfile here. reg = REG_HAS_14; - fclose (db); + fclose(db); #endif -#if defined (__HAIKU__) +#if defined(__HAIKU__) reg = REG_HAIKU; #endif // Other possibility: Preinstalled Becasso - if (reg == REG_NONE) - { + if (reg == REG_NONE) { char path[B_FILE_NAME_LENGTH]; - find_directory (B_USER_SETTINGS_DIRECTORY, &p); - strcpy (path, p.Path()); - strcat (path, "/Becasso/Preinstalled"); - FILE *db = fopen (path, "rb"); - if (db) // file exists, so generate the keyfile here. + find_directory(B_USER_SETTINGS_DIRECTORY, &p); + strcpy(path, p.Path()); + strcat(path, "/Becasso/Preinstalled"); + FILE* db = fopen(path, "rb"); + if (db) // file exists, so generate the keyfile here. reg = REG_PREINST; - fclose (db); + fclose(db); } // Other possibility: This is a CD installation - if (reg == REG_NONE) - { + if (reg == REG_NONE) { bool done = false; - while (!done) - { - FILE *cd = fopen ("/BECASSO/README", "rb"); - if (cd) - { + while (!done) { + FILE* cd = fopen("/BECASSO/README", "rb"); + if (cd) { reg = REG_CD; done = true; } - fclose (cd); - if (!done) - { - int button = (new BAlert ("Reg", lstring (423, "For registration: please mount the Becasso 2.0 CD-ROM"), lstring (131, "Cancel"), lstring (424, "Done")))->Go(); + fclose(cd); + if (!done) { + int button = + (new BAlert( + "Reg", + lstring(423, "For registration: please mount the Becasso 2.0 CD-ROM"), + lstring(131, "Cancel"), lstring(424, "Done") + )) + ->Go(); if (button == 0) done = true; } @@ -107,40 +115,36 @@ void generate_alphabuffer (char *alpha) } if (reg == REG_NONE) return; - + extern char gAlphaBuffer[256]; extern char gAlphaMask[128]; - - if (reg == REG_HAIKU) - { + + if (reg == REG_HAIKU) { strcat(gAlphaMask, "Haiku"); - } - else - { - RegWindow *rw = new RegWindow (BRect (100, 100, 440, 240), lstring (420, "Register Becasso 2.0"), reg); + } else { + RegWindow* rw = + new RegWindow(BRect(100, 100, 440, 240), lstring(420, "Register Becasso 2.0"), reg); int val = rw->Go(); rw->Lock(); rw->Quit(); - + if (val == 0) return; } - - if (reg == REG_PREINST) - { - system ("rm -rf /boot/home/config/settings/Becasso/Preinstalled"); + if (reg == REG_PREINST) { + system("rm -rf /boot/home/config/settings/Becasso/Preinstalled"); } - + int i; - for (i = 0; i <= strlen (gAlphaMask); i++) - gAlphaBuffer[2*i] = gAlphaMask[i]; + for (i = 0; i <= strlen(gAlphaMask); i++) + gAlphaBuffer[2 * i] = gAlphaMask[i]; for (i = strlen(gAlphaMask) + 1; i < 128; i++) - gAlphaBuffer[2*i] = rand() & 0xFF; - time_t tm = time (NULL); - struct tm *tms = localtime (&tm); - extern const char *Version; + gAlphaBuffer[2 * i] = rand() & 0xFF; + time_t tm = time(NULL); + struct tm* tms = localtime(&tm); + extern const char* Version; int vlen = strlen(Version); gAlphaBuffer[1] = vlen; gAlphaBuffer[3] = tms->tm_year; @@ -150,291 +154,287 @@ void generate_alphabuffer (char *alpha) gAlphaBuffer[11] = 42; gAlphaBuffer[13] = reg; for (i = 0; i <= vlen; i++) - gAlphaBuffer[2*i + 15] = Version[i]; - char filler[] = "Well done, you have cracked the keyfile code! Please don't pass it on, I need to eat too - Sander"; + gAlphaBuffer[2 * i + 15] = Version[i]; + char filler[] = "Well done, you have cracked the keyfile code! Please don't pass it on, I " + "need to eat too - Sander"; for (i = 0; i < strlen(filler); i++) - gAlphaBuffer[2*i + 2*vlen + 15] = filler[i]; + gAlphaBuffer[2 * i + 2 * vlen + 15] = filler[i]; uint32 sum = 0; for (i = 0; i < 252; i++) sum += gAlphaBuffer[i]; - char *schar = (char *)(&sum); + char* schar = (char*)(&sum); gAlphaBuffer[252] = schar[0]; gAlphaBuffer[253] = schar[1]; gAlphaBuffer[254] = schar[2]; gAlphaBuffer[255] = schar[3]; - uchar xAlphaMask[256] = { KEYFILE_MASK }; + uchar xAlphaMask[256] = {KEYFILE_MASK}; char wbuffer[256]; for (i = 0; i < 255; i++) wbuffer[i] = gAlphaBuffer[i] ^ xAlphaMask[i]; - - FILE *kf = fopen (alpha, "wb"); - fwrite (wbuffer, 1, 255, kf); - fclose (kf); + + FILE* kf = fopen(alpha, "wb"); + fwrite(wbuffer, 1, 255, kf); + fclose(kf); extern int gGlobalAlpha; gGlobalAlpha = 1; } +void +setup_alphabuffer(); -void setup_alphabuffer (); // You guessed it: This actually does registration checking. -void setup_alphabuffer () +void +setup_alphabuffer() { extern int gGlobalAlpha; - #if defined(__HAIKU__) - gGlobalAlpha = 1; +#if defined(__HAIKU__) + gGlobalAlpha = 1; strcat(gAlphaMask, "Haiku"); - #else +#else char buffer[256]; BPath p; char path[B_FILE_NAME_LENGTH]; - find_directory (B_USER_SETTINGS_DIRECTORY, &p); - strcpy (path, p.Path()); - strcat (path, "/Becasso/Keyfile"); - FILE *kf = fopen (path, "rb"); - if (!kf) - { - fclose (kf); + find_directory(B_USER_SETTINGS_DIRECTORY, &p); + strcpy(path, p.Path()); + strcat(path, "/Becasso/Keyfile"); + FILE* kf = fopen(path, "rb"); + if (!kf) { + fclose(kf); // Hmm, there is no keyfile... Perhaps a SV db file then? - generate_alphabuffer (path); - } - else - { - if (fread (buffer, 255, 1, kf) != 1) - { - (new BAlert ("", lstring (8, "Your Keyfile is damaged"), lstring (136, "OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(); - fclose (kf); + generate_alphabuffer(path); + } else { + if (fread(buffer, 255, 1, kf) != 1) { + (new BAlert( + "", lstring(8, "Your Keyfile is damaged"), lstring(136, "OK"), NULL, NULL, + B_WIDTH_AS_USUAL, B_WARNING_ALERT + )) + ->Go(); + fclose(kf); return; } - fclose (kf); + fclose(kf); // Here, demangle the keyfile into the registration info. // first, xor using the mask. - char xAlphaMask[256] = { KEYFILE_MASK }; + char xAlphaMask[256] = {KEYFILE_MASK}; int i; for (i = 0; i < 255; i++) gAlphaBuffer[i] = buffer[i] ^ xAlphaMask[i]; - + // then, check the checksum uint32 sum = 0; for (i = 0; i < 252; i++) sum += gAlphaBuffer[i]; - char *schar = (char *)(&sum); -#if defined (__POWERPC__) - if (gAlphaBuffer[252] != schar[3] - || gAlphaBuffer[253] != schar[2] - || gAlphaBuffer[254] != schar[1] - || gAlphaBuffer[255] != schar[0]) + char* schar = (char*)(&sum); +#if defined(__POWERPC__) + if (gAlphaBuffer[252] != schar[3] || gAlphaBuffer[253] != schar[2] || + gAlphaBuffer[254] != schar[1] || gAlphaBuffer[255] != schar[0]) #else - if (gAlphaBuffer[252] != schar[0] - || gAlphaBuffer[253] != schar[1] - || gAlphaBuffer[254] != schar[2] - || gAlphaBuffer[255] != schar[3]) + if (gAlphaBuffer[252] != schar[0] || gAlphaBuffer[253] != schar[1] || + gAlphaBuffer[254] != schar[2] || gAlphaBuffer[255] != schar[3]) #endif { - fprintf (stderr, "keyfile checksum failure\n");//: %x, %x %x %x %x\n", sum, -// gAlphaBuffer[252], gAlphaBuffer[253], gAlphaBuffer[254], gAlphaBuffer[255]); - return; // checksum failure + fprintf(stderr, "keyfile checksum failure\n"); //: %x, %x %x %x %x\n", sum, + // gAlphaBuffer[252], gAlphaBuffer[253], gAlphaBuffer[254], + // gAlphaBuffer[255]); + return; // checksum failure } - + // check the magic numbers - if (gAlphaBuffer[9] != 31 - || gAlphaBuffer[11] != 42) - { - fprintf (stderr, "keyfile magic number failure\n"); + if (gAlphaBuffer[9] != 31 || gAlphaBuffer[11] != 42) { + fprintf(stderr, "keyfile magic number failure\n"); return; } - + // OK, I believe this is a genuine keyfile. // Extract the name from it extern char gAlphaMask[128]; for (i = 0; i < 128; i++) - gAlphaMask[i] = gAlphaBuffer[2*i]; + gAlphaMask[i] = gAlphaBuffer[2 * i]; gGlobalAlpha = 1; - + // Note that the keyfile contains more: The registered version, kind of registration, // and the date of registration. Who knows whether this will be interesting at one point. } - #endif +#endif } -int main (int argc, char **argv) +int +main(int argc, char** argv) { - extern bool VerbQuit, VerbAddOns, NoAddOns, EasterEgg, UseMMX, ShowColors, BuiltInTablet, ExportCstruct; + extern bool VerbQuit, VerbAddOns, NoAddOns, EasterEgg, UseMMX, ShowColors, BuiltInTablet, + ExportCstruct; extern int DebugLevel, SilentOperation; - - VerbQuit = false; - VerbAddOns = false; - NoAddOns = false; - ShowColors = false; - PatronizeMIME = true; - BuiltInTablet = false; - ExportCstruct = false; - NoSettings = false; - WriteSettings = false; - EasterEgg = EASTER_EGG; - gGlobalAlpha = REGISTERED; - DebugLevel = 0; - SilentOperation = 0; - - UseMMX = true; - - for (int i = 1; i < argc; i++) - { - if (argv[i][0] == '-') - { - switch (argv[i][1]) - { - case 'v': - { + + VerbQuit = false; + VerbAddOns = false; + NoAddOns = false; + ShowColors = false; + PatronizeMIME = true; + BuiltInTablet = false; + ExportCstruct = false; + NoSettings = false; + WriteSettings = false; + EasterEgg = EASTER_EGG; + gGlobalAlpha = REGISTERED; + DebugLevel = 0; + SilentOperation = 0; + + UseMMX = true; + + for (int i = 1; i < argc; i++) { + if (argv[i][0] == '-') { + switch (argv[i][1]) { + case 'v': { VerbAddOns = true; break; } - case 'q': - { + case 'q': { VerbQuit = true; break; } - case 'x': - { + case 'x': { NoAddOns = true; break; } - case 'e': - { + case 'e': { EasterEgg = !EASTER_EGG; break; } - case 'D': - { - DebugLevel = atoi (&(argv[i][2])); - fprintf (stderr, "Debug level set to %d\n", DebugLevel); + case 'D': { + DebugLevel = atoi(&(argv[i][2])); + fprintf(stderr, "Debug level set to %d\n", DebugLevel); break; } - case 'd': - { + case 'd': { NoSettings = true; break; } - case 'w': - { + case 'w': { WriteSettings = true; break; } - case 'S': - { - SilentOperation = atoi (&(argv[i][2]));; + case 'S': { + SilentOperation = atoi(&(argv[i][2])); + ; break; } - case 'M': - { + case 'M': { UseMMX = false; break; } - case 'C': - { + case 'C': { ExportCstruct = true; break; } - case 'c': - { + case 'c': { ShowColors = true; break; } - case 't': - { + case 't': { BuiltInTablet = true; break; } - case 'h': - { - fprintf (stderr, "Recognized command line options:\n"); - fprintf (stderr, " -v Verbose add-on loading (useful for debugging your own)\n"); - fprintf (stderr, " -q Verbose quitting\n"); - fprintf (stderr, " -x Don't load add-ons (faster launch time)\n"); - fprintf (stderr, " -d Use default settings (don't load settings)\n"); - fprintf (stderr, " -w Force saving of settings (use with -d)\n"); - fprintf (stderr, " -Dn Debug verbosity level\n"); - fprintf (stderr, " -Sn Silence level (scripting operation)\n"); - fprintf (stderr, " -M Don't use MMX\n"); - fprintf (stderr, " -c Show recognized RGB color names at startup\n"); - fprintf (stderr, " -C Enable export as C struct\n"); - fprintf (stderr, " -t Switch on builtin Wacom tablet support\n"); - fprintf (stderr, " -h Display this message\n"); + case 'h': { + fprintf(stderr, "Recognized command line options:\n"); + fprintf(stderr, " -v Verbose add-on loading (useful for debugging your own)\n"); + fprintf(stderr, " -q Verbose quitting\n"); + fprintf(stderr, " -x Don't load add-ons (faster launch time)\n"); + fprintf(stderr, " -d Use default settings (don't load settings)\n"); + fprintf(stderr, " -w Force saving of settings (use with -d)\n"); + fprintf(stderr, " -Dn Debug verbosity level\n"); + fprintf(stderr, " -Sn Silence level (scripting operation)\n"); + fprintf(stderr, " -M Don't use MMX\n"); + fprintf(stderr, " -c Show recognized RGB color names at startup\n"); + fprintf(stderr, " -C Enable export as C struct\n"); + fprintf(stderr, " -t Switch on builtin Wacom tablet support\n"); + fprintf(stderr, " -h Display this message\n"); break; } default: - fprintf (stderr, "Unrecognized command line option: '%c'\n(Becasso -h displays command line usage help)\n", argv[i][1]); + fprintf( + stderr, + "Unrecognized command line option: '%c'\n(Becasso -h displays command line " + "usage help)\n", + argv[i][1] + ); } } } - #if defined (TIME_LIMITED) - struct tm *mytime; - time_t mytimet = time (NULL); - #endif - -#if defined (__INTEL__) +#if defined(TIME_LIMITED) + struct tm* mytime; + time_t mytimet = time(NULL); +#endif + +#if defined(__INTEL__) if (UseMMX) - UseMMX = mmx_available(); + UseMMX = mmx_available(); #else - UseMMX = false; + UseMMX = false; #endif if (UseMMX) - verbose (1, "MMX detected\n"); + verbose(1, "MMX detected\n"); else - verbose (1, "No MMX\n"); - + verbose(1, "No MMX\n"); + if (BuiltInTablet) - verbose (1, "Builtin Tablet support enabled\n"); - + verbose(1, "Builtin Tablet support enabled\n"); + mainapp = new Becasso(); setup_alphabuffer(); - if (DebugLevel) - { - extern const char *Version; - fprintf (stderr, "Becasso version %s %s, built %s\n", - Version, (gGlobalAlpha ? "(Registered)" : "(Unregistered)"), __DATE__); + if (DebugLevel) { + extern const char* Version; + fprintf( + stderr, "Becasso version %s %s, built %s\n", Version, + (gGlobalAlpha ? "(Registered)" : "(Unregistered)"), __DATE__ + ); } size_t bsize, ssize; void *becassodata, *sumdata; app_info info; - mainapp->GetAppInfo (&info); - BFile file (&info.ref, O_RDONLY); - BResources res (&file); - if (!(becassodata = res.FindResource ('blog', 128, &bsize))) - fprintf (stderr, "Becasso logo resource not found\n"); - if (!(sumdata = res.FindResource ('slog', 129, &ssize))) - fprintf (stderr, "Sum logo resource not found\n"); + mainapp->GetAppInfo(&info); + BFile file(&info.ref, O_RDONLY); + BResources res(&file); + if (!(becassodata = res.FindResource('blog', 128, &bsize))) + fprintf(stderr, "Becasso logo resource not found\n"); + if (!(sumdata = res.FindResource('slog', 129, &ssize))) + fprintf(stderr, "Sum logo resource not found\n"); BScreen screen; - BRect becassorect = BRect (0, 0, 231, 93); - BRect sumrect = BRect (0, 0, 63, 83); - BBitmap *becasso = new BBitmap (becassorect, (screen.ColorSpace() == B_COLOR_8_BIT) ? B_COLOR_8_BIT : B_RGB32); + BRect becassorect = BRect(0, 0, 231, 93); + BRect sumrect = BRect(0, 0, 63, 83); + BBitmap* becasso = + new BBitmap(becassorect, (screen.ColorSpace() == B_COLOR_8_BIT) ? B_COLOR_8_BIT : B_RGB32); // This strange color space thing is because we can't store bitmaps in 16 bit depth, so we use // a 32bit version for this screen mode (which doesn't look too bad). - BBitmap *sum = new BBitmap (sumrect, B_RGB32); - becasso->SetBits (becassodata, bsize, 0, B_RGB32); - sum->SetBits (sumdata, ssize, 0, B_RGB32); - BRect center = BRect (0, 0, 280, 210); - center.OffsetTo (screen.Frame().Width()/2 - 140, screen.Frame().Height()/2 - 105); - splash = new SplashWindow (center, becasso, sum); - splash->Minimize (SilentOperation >= 3); + BBitmap* sum = new BBitmap(sumrect, B_RGB32); + becasso->SetBits(becassodata, bsize, 0, B_RGB32); + sum->SetBits(sumdata, ssize, 0, B_RGB32); + BRect center = BRect(0, 0, 280, 210); + center.OffsetTo(screen.Frame().Width() / 2 - 140, screen.Frame().Height() / 2 - 105); + splash = new SplashWindow(center, becasso, sum); + splash->Minimize(SilentOperation >= 3); splash->Show(); mainapp->LoadAddOns(); - #if defined (TIME_LIMITED) - mytime = localtime (&mytimet); -// if (mytime->tm_year == 97 && mytime->tm_mon < 11) - if (mytime->tm_year == 97) - mainapp->Run(); - else - { - BAlert *alert = new BAlert ("", "This demo version of Becasso has expired.\nOn http://www.sumware.demon.nl you can find info on obtaining a newer version.\nThanks for your interest in Becasso!", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); - alert->Go(); - } - #else +#if defined(TIME_LIMITED) + mytime = localtime(&mytimet); + // if (mytime->tm_year == 97 && mytime->tm_mon < 11) + if (mytime->tm_year == 97) mainapp->Run(); - #endif + else { + BAlert* alert = new BAlert( + "", + "This demo version of Becasso has expired.\nOn http://www.sumware.demon.nl you can " + "find info on obtaining a newer version.\nThanks for your interest in Becasso!", + "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT + ); + alert->Go(); + } +#else + mainapp->Run(); +#endif delete mainapp; -// delete BTranslatorRoster::Default(); + // delete BTranslatorRoster::Default(); return 0; } diff --git a/source/BitmapStream.cpp b/source/BitmapStream.cpp index e51d9f9..8330a39 100644 --- a/source/BitmapStream.cpp +++ b/source/BitmapStream.cpp @@ -7,9 +7,7 @@ #include #include - -BitmapStream::BitmapStream( - BBitmap * bitmap) +BitmapStream::BitmapStream(BBitmap* bitmap) { fMap = bitmap; fDetached = false; @@ -21,24 +19,19 @@ BitmapStream::BitmapStream( fHeader.bounds = fMap->Bounds(); fHeader.rowBytes = fMap->BytesPerRow(); fHeader.colors = fMap->ColorSpace(); - fHeader.dataSize = (fHeader.bounds.Height()+1)*fHeader.rowBytes; - fSize = sizeof(DATABitmap)+fHeader.dataSize; + fHeader.dataSize = (fHeader.bounds.Height() + 1) * fHeader.rowBytes; + fSize = sizeof(DATABitmap) + fHeader.dataSize; } } - BitmapStream::~BitmapStream() { if (fMap && !fDetached) delete fMap; } - status_t -BitmapStream::ReadAt( - off_t pos, - void * buffer, - size_t size) +BitmapStream::ReadAt(off_t pos, void* buffer, size_t size) { if (!fMap) return B_ERROR; @@ -48,14 +41,14 @@ BitmapStream::ReadAt( return B_ERROR; long toRead; - void *source; + void* source; if (fPosition < sizeof(DATABitmap)) { - toRead = sizeof(DATABitmap)-pos; - source = ((char *)&fHeader)+pos; + toRead = sizeof(DATABitmap) - pos; + source = ((char*)&fHeader) + pos; } else { - toRead = fSize-pos; - source = ((char *)fMap->Bits())+fPosition-sizeof(DATABitmap); + toRead = fSize - pos; + source = ((char*)fMap->Bits()) + fPosition - sizeof(DATABitmap); } if (toRead > size) toRead = size; @@ -63,49 +56,46 @@ BitmapStream::ReadAt( return toRead; } - status_t -BitmapStream::WriteAt( - off_t pos, - const void * data, - size_t size) +BitmapStream::WriteAt(off_t pos, const void* data, size_t size) { if (!size) return B_NO_ERROR; ssize_t written = 0; while (size > 0) { long toWrite; - void *dest; + void* dest; /* We depend on writing the header separately in detecting changes to it */ if (pos < sizeof(DATABitmap)) { - toWrite = sizeof(DATABitmap)-pos; - dest = ((char *)&fHeader)+pos; + toWrite = sizeof(DATABitmap) - pos; + dest = ((char*)&fHeader) + pos; } else { - toWrite = fHeader.dataSize-pos+sizeof(DATABitmap); - dest = ((char *)fMap->Bits())+pos-sizeof(DATABitmap); + toWrite = fHeader.dataSize - pos + sizeof(DATABitmap); + dest = ((char*)fMap->Bits()) + pos - sizeof(DATABitmap); } if (toWrite > size) toWrite = size; - if (!toWrite && size) // i e we've been told to write too much + if (!toWrite && size) // i e we've been told to write too much return B_BAD_VALUE; memcpy(dest, data, toWrite); pos += toWrite; written += toWrite; - data = ((char *)data)+toWrite; + data = ((char*)data) + toWrite; size -= toWrite; if (pos > fSize) fSize = pos; /* If we change the header, the rest goes */ if (pos == sizeof(DATABitmap)) { - if (fMap && ((fMap->Bounds() != fHeader.bounds) || - (fMap->ColorSpace() != fHeader.colors) || - (fMap->BytesPerRow() != fHeader.rowBytes))) { - if (!fDetached) // if someone detached, we don't delete + if (fMap && + ((fMap->Bounds() != fHeader.bounds) || (fMap->ColorSpace() != fHeader.colors) || + (fMap->BytesPerRow() != fHeader.rowBytes))) { + if (!fDetached) // if someone detached, we don't delete delete fMap; fMap = NULL; } if (!fMap) { -// fHeader.bounds.PrintToStream(); // ### Sander SToks, 23/07/97 commented out. + // fHeader.bounds.PrintToStream(); // ### Sander SToks, 23/07/97 + // commented out. if ((fHeader.bounds.left > 0.0) || (fHeader.bounds.top > 0.0)) DEBUGGER("non-origin bounds!"); fMap = new BBitmap(fHeader.bounds, fHeader.colors); @@ -114,18 +104,17 @@ BitmapStream::WriteAt( } } if (fMap) { - fSize = sizeof(DATABitmap)+fMap->BitsLength(); + fSize = sizeof(DATABitmap) + fMap->BitsLength(); } } } return written; } - off_t -BitmapStream::Seek( // returns 0 for success - off_t position, - uint32 whence) +BitmapStream::Seek( // returns 0 for success + off_t position, uint32 whence +) { if (whence == SEEK_CUR) position += fPosition; @@ -139,45 +128,41 @@ BitmapStream::Seek( // returns 0 for success return fPosition; } - off_t BitmapStream::Position() const { return fPosition; } - off_t BitmapStream::Size() const { return fSize; } - status_t -BitmapStream::SetSize( // returns 0 for success - off_t size) +BitmapStream::SetSize( // returns 0 for success + off_t size +) { if (size < 0) return B_BAD_VALUE; - if (fMap && (size > fHeader.dataSize+sizeof(DATABitmap))) + if (fMap && (size > fHeader.dataSize + sizeof(DATABitmap))) return B_BAD_VALUE; /* Problem: - * What if someone calls SetSize() before writing the header, so we don't know what + * What if someone calls SetSize() before writing the header, so we don't know what * bitmap to create? * Solution: - * We assume people will write the header before any data, + * We assume people will write the header before any data, * so SetSize() is really not going to do anything. */ - if (fMap) // if we checked that the size was OK + if (fMap) // if we checked that the size was OK fSize = size; return B_NO_ERROR; } - status_t -BitmapStream::DetachBitmap( - BBitmap * & outBitmap) +BitmapStream::DetachBitmap(BBitmap*& outBitmap) { outBitmap = NULL; if (!fMap) @@ -188,4 +173,3 @@ BitmapStream::DetachBitmap( outBitmap = fMap; return B_NO_ERROR; } - diff --git a/source/BitmapStuff.cpp b/source/BitmapStuff.cpp index 984ed50..bf486a7 100644 --- a/source/BitmapStuff.cpp +++ b/source/BitmapStuff.cpp @@ -18,101 +18,109 @@ #include #include -#if defined (DATATYPES) -# include "Datatypes.h" +#if defined(DATATYPES) +#include "Datatypes.h" #endif -#if defined (__POWERPC__) -# pragma optimization_level 4 -# pragma peephole on +#if defined(__POWERPC__) +#pragma optimization_level 4 +#pragma peephole on #endif // Note: This is a design mistake, discovered when 1.3 was already being released. // The "Merge" function should have been in here from day one; this is a copy of // the same method in CanvasView. -void Merge (BBitmap *a, Layer *b, BRect update, bool doselect, bool preserve_alpha); +void +Merge(BBitmap* a, Layer* b, BRect update, bool doselect, bool preserve_alpha); -void Merge (BBitmap *a, Layer *b, BRect update, bool doselect, bool preserve_alpha) +void +Merge(BBitmap* a, Layer* b, BRect update, bool doselect, bool preserve_alpha) { -// clock_t start, end; -// start = clock(); + // clock_t start, end; + // start = clock(); doselect = doselect; preserve_alpha = preserve_alpha; -// ulong h = update.IntegerHeight() + 1; // Was: fCanvasFrame! + // ulong h = update.IntegerHeight() + 1; // Was: fCanvasFrame! ulong w = update.IntegerWidth() + 1; -// ulong sbbpr = a->BytesPerRow(); - ulong sbpr = b->BytesPerRow()/4; - ulong rt = ulong (update.top); - ulong rb = ulong (update.bottom); - ulong rl = ulong (update.left); - ulong rr = ulong (update.right); + // ulong sbbpr = a->BytesPerRow(); + ulong sbpr = b->BytesPerRow() / 4; + ulong rt = ulong(update.top); + ulong rb = ulong(update.bottom); + ulong rl = ulong(update.left); + ulong rr = ulong(update.right); ulong dw = rr - rl + 1; ulong ddiff = (w - dw); ulong sdiff = sbpr - dw; -// ulong brl = rl; - uint32 *src = (uint32 *) b->Bits() + rt*sbpr + rl - 1; - uint32 *dest = (uint32 *) a->Bits() + (rt*w + rl) - 1; + // ulong brl = rl; + uint32* src = (uint32*)b->Bits() + rt * sbpr + rl - 1; + uint32* dest = (uint32*)a->Bits() + (rt * w + rl) - 1; int ga = b->getGlobalAlpha(); - switch (b->getMode()) - { + switch (b->getMode()) { case 0: - for (ulong y = rt; y <= rb; y++) - { - for (ulong x = rl; x <= rr; x++) - { -#if defined (__POWERPC__) + for (ulong y = rt; y <= rb; y++) { + for (ulong x = rl; x <= rr; x++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src); register uint32 destpixel = *(++dest); - register int sa = (srcpixel & 0xFF)*ga/255; + register int sa = (srcpixel & 0xFF) * ga / 255; register int da = 255 - sa; - if (da == 0) // Fully opaque pixel + if (da == 0) // Fully opaque pixel { *dest = srcpixel; - } - else if (da == 255) // Fully transparent pixel + } else if (da == 255) // Fully transparent pixel { - } - else - { -# if !defined (BLEND_USES_SHIFTS) - *dest = ((((destpixel & 0xFF000000)/255*da + (srcpixel & 0xFF000000)/255*sa)) & 0xFF000000) | - ((((destpixel & 0x00FF0000)*da + (srcpixel & 0x00FF0000)*sa)/255) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/255) & 0x0000FF00) |\ - // (max_c (sa, destpixel & 0xFF)); - (clipchar (sa + int (destpixel & 0xFF))); -# else - *dest = (((((destpixel & 0xFF000000)>>8)*da + ((srcpixel & 0xFF000000)>>8)*sa)) & 0xFF000000) | - ((((destpixel & 0x00FF0000)*da + (srcpixel & 0x00FF0000)*sa)>>8) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)>>8) & 0x0000FF00) |\ - (clipchar (sa + int (destpixel & 0xFF))); -# endif + } else { +#if !defined(BLEND_USES_SHIFTS) + *dest = + ((((destpixel & 0xFF000000) / 255 * da + (srcpixel & 0xFF000000) / 255 * sa) + ) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) * da + (srcpixel & 0x00FF0000) * sa) / 255) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) / 255) & + 0x0000FF00) | // (max_c (sa, destpixel & 0xFF)); + (clipchar(sa + int(destpixel & 0xFF))); +#else + *dest = (((((destpixel & 0xFF000000) >> 8) * da + + ((srcpixel & 0xFF000000) >> 8) * sa)) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) * da + (srcpixel & 0x00FF0000) * sa) >> 8) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) >> 8) & + 0x0000FF00) | + (clipchar(sa + int(destpixel & 0xFF))); +#endif } #else register uint32 srcpixel = *(++src); register uint32 destpixel = *(++dest); - register int sa = (srcpixel >> 24)*ga/255; + register int sa = (srcpixel >> 24) * ga / 255; register int da = 255 - sa; - if (da == 0) // Fully opaque pixel + if (da == 0) // Fully opaque pixel { *dest = srcpixel; - } - else if (da == 255) // Fully transparent pixel - { - } - else + } else if (da == 255) // Fully transparent pixel { -# if !defined (BLEND_USES_SHIFTS) - *dest = ((((destpixel & 0x00FF0000)*da + (srcpixel & 0x00FF0000)*sa)/255) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/255) & 0x0000FF00) | - ((((destpixel & 0x000000FF)*da + (srcpixel & 0x000000FF)*sa)/255) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); -# else - *dest = ((((destpixel & 0x00FF0000)*da + (srcpixel & 0x00FF0000)*sa)>>8) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)>>8) & 0x0000FF00) | - ((((destpixel & 0x000000FF)*da + (srcpixel & 0x000000FF)*sa)>>8) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); -# endif + } else { +#if !defined(BLEND_USES_SHIFTS) + *dest = + ((((destpixel & 0x00FF0000) * da + (srcpixel & 0x00FF0000) * sa) / 255) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) / 255) & + 0x0000FF00) | + ((((destpixel & 0x000000FF) * da + (srcpixel & 0x000000FF) * sa) / 255) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); +#else + *dest = ((((destpixel & 0x00FF0000) * da + (srcpixel & 0x00FF0000) * sa) >> 8) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) >> 8) & + 0x0000FF00) | + ((((destpixel & 0x000000FF) * da + (srcpixel & 0x000000FF) * sa) >> 8) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); +#endif } #endif } @@ -121,57 +129,81 @@ void Merge (BBitmap *a, Layer *b, BRect update, bool doselect, bool preserve_alp } break; case 1: - for (ulong y = rt; y <= rb; y++) - { - for (ulong x = rl; x <= rr; x++) - { -#if defined (__POWERPC__) + for (ulong y = rt; y <= rb; y++) { + for (ulong x = rl; x <= rr; x++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src); register uint32 destpixel = *(++dest); - register int sa = (srcpixel & 0xFF)*ga/255; + register int sa = (srcpixel & 0xFF) * ga / 255; register int da = destpixel & 0xFF; - register int tsa = 65025 - sa*255; - register int tda = 65025 - da*255; - if (sa == 0) // Fully transparent pixel - { - } - else if (sa == 255) // Fully opaque pixel + register int tsa = 65025 - sa * 255; + register int tda = 65025 - da * 255; + if (sa == 0) // Fully transparent pixel { - *dest = (((((srcpixel >> 24) )*(tda + da*((destpixel >> 24) ))/65025) << 24) & 0xFF000000) | - (((((srcpixel >> 16) & 0xFF)*(tda + da*((destpixel >> 16) & 0xFF))/65025) << 16) & 0x00FF0000) | - (((((srcpixel >> 8) & 0xFF)*(tda + da*((destpixel >> 8) & 0xFF))/65025) << 8) & 0x0000FF00) | - (clipchar (sa + int (destpixel & 0xFF))); - } - else + } else if (sa == 255) // Fully opaque pixel { - *dest = (((tsa + sa*((srcpixel >> 24) ))*(tda + da*((destpixel >> 24) ))/16581375 << 24) & 0xFF000000) | - (((tsa + sa*((srcpixel >> 16) & 0xFF))*(tda + da*((destpixel >> 16) & 0xFF))/16581375 << 16) & 0x00FF0000) | - (((tsa + sa*((srcpixel >> 8) & 0xFF))*(tda + da*((destpixel >> 8) & 0xFF))/16581375 << 8) & 0x0000FF00) | - (clipchar (sa + int (destpixel & 0xFF))); + *dest = + (((((srcpixel >> 24)) * (tda + da * ((destpixel >> 24))) / 65025) << 24) & + 0xFF000000) | + (((((srcpixel >> 16) & 0xFF) * (tda + da * ((destpixel >> 16) & 0xFF)) / + 65025) + << 16) & + 0x00FF0000) | + (((((srcpixel >> 8) & 0xFF) * (tda + da * ((destpixel >> 8) & 0xFF)) / 65025 + ) + << 8) & + 0x0000FF00) | + (clipchar(sa + int(destpixel & 0xFF))); + } else { + *dest = (((tsa + sa * ((srcpixel >> 24))) * (tda + da * ((destpixel >> 24))) / + 16581375 + << 24) & + 0xFF000000) | + (((tsa + sa * ((srcpixel >> 16) & 0xFF)) * + (tda + da * ((destpixel >> 16) & 0xFF)) / 16581375 + << 16) & + 0x00FF0000) | + (((tsa + sa * ((srcpixel >> 8) & 0xFF)) * + (tda + da * ((destpixel >> 8) & 0xFF)) / 16581375 + << 8) & + 0x0000FF00) | + (clipchar(sa + int(destpixel & 0xFF))); } #else register uint32 srcpixel = *(++src); register uint32 destpixel = *(++dest); - register int sa = (srcpixel >> 24)*ga/255; + register int sa = (srcpixel >> 24) * ga / 255; register int da = destpixel >> 24; - register int tsa = 65025 - sa*255; - register int tda = 65025 - da*255; - if (sa == 0) // Fully transparent pixel - { - } - else if (sa == 255) // Fully opaque pixel + register int tsa = 65025 - sa * 255; + register int tda = 65025 - da * 255; + if (sa == 0) // Fully transparent pixel { - *dest = (((((srcpixel >> 16) & 0xFF)*(tda + da*((destpixel >> 16) & 0xFF))/65025) << 16) & 0x00FF0000) | - (((((srcpixel >> 8) & 0xFF)*(tda + da*((destpixel >> 8) & 0xFF))/65025) << 8) & 0x0000FF00) | - (((((srcpixel ) & 0xFF)*(tda + da*((destpixel ) & 0xFF))/65025) ) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); - } - else + } else if (sa == 255) // Fully opaque pixel { - *dest = (((tsa + sa*((srcpixel >> 16) & 0xFF))*(tda + da*((destpixel >> 16) & 0xFF))/16581375 << 16) & 0x00FF0000) | - (((tsa + sa*((srcpixel >> 8) & 0xFF))*(tda + da*((destpixel >> 8) & 0xFF))/16581375 << 8) & 0x0000FF00) | - (((tsa + sa*((srcpixel ) & 0xFF))*(tda + da*((destpixel ) & 0xFF))/16581375 ) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); + *dest = (((((srcpixel >> 16) & 0xFF) * (tda + da * ((destpixel >> 16) & 0xFF)) / + 65025) + << 16) & + 0x00FF0000) | + (((((srcpixel >> 8) & 0xFF) * (tda + da * ((destpixel >> 8) & 0xFF)) / + 65025) + << 8) & + 0x0000FF00) | + (((((srcpixel) & 0xFF) * (tda + da * ((destpixel) & 0xFF)) / 65025)) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); + } else { + *dest = (((tsa + sa * ((srcpixel >> 16) & 0xFF)) * + (tda + da * ((destpixel >> 16) & 0xFF)) / 16581375 + << 16) & + 0x00FF0000) | + (((tsa + sa * ((srcpixel >> 8) & 0xFF)) * + (tda + da * ((destpixel >> 8) & 0xFF)) / 16581375 + << 8) & + 0x0000FF00) | + (((tsa + sa * ((srcpixel) & 0xFF)) * (tda + da * ((destpixel) & 0xFF)) / + 16581375) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); } #endif } @@ -180,49 +212,48 @@ void Merge (BBitmap *a, Layer *b, BRect update, bool doselect, bool preserve_alp } break; default: - fprintf (stderr, "Merge: Unknown Drawing Mode\n"); + fprintf(stderr, "Merge: Unknown Drawing Mode\n"); break; } -// end = clock(); -// printf ("Merge took %d ms\n", end - start); + // end = clock(); + // printf ("Merge took %d ms\n", end - start); } -void InsertGlobalAlpha (Layer *layer[], int numLayers) // Watermark all layers by inverting +void +InsertGlobalAlpha(Layer* layer[], int numLayers) // Watermark all layers by inverting { - SView *demoView = new SView (layer[0]->Bounds(), "demoview", B_FOLLOW_NONE, uint32 (NULL)); + SView* demoView = new SView(layer[0]->Bounds(), "demoview", B_FOLLOW_NONE, uint32(NULL)); const char demotext[] = "Becasso"; float h = layer[0]->Bounds().Height(); float w = layer[0]->Bounds().Width(); - BFont font (be_bold_font); + BFont font(be_bold_font); font_height fh; - font.GetHeight (&fh); - float ratio = font.StringWidth (demotext) / (fh.ascent + fh.descent + fh.leading); - float size = sqrt (h*h/(ratio*ratio) + w*w)/font.StringWidth (demotext) * 11; - float angle = 360*atan2 (h - (fh.ascent + fh.leading), w)/2/M_PI; - font.SetSize (size); + font.GetHeight(&fh); + float ratio = font.StringWidth(demotext) / (fh.ascent + fh.descent + fh.leading); + float size = sqrt(h * h / (ratio * ratio) + w * w) / font.StringWidth(demotext) * 11; + float angle = 360 * atan2(h - (fh.ascent + fh.leading), w) / 2 / M_PI; + font.SetSize(size); // printf ("Size = %f, ratio = %f, sqrt = %f\n", size, ratio, sqrt (h*h/(ratio*ratio) + w*w)); - font.SetRotation (angle); - font.SetFlags (B_DISABLE_ANTIALIASING); - BBitmap *tmp = new BBitmap (layer[0]->Bounds(), B_RGBA32, true); + font.SetRotation(angle); + font.SetFlags(B_DISABLE_ANTIALIASING); + BBitmap* tmp = new BBitmap(layer[0]->Bounds(), B_RGBA32, true); tmp->Lock(); - tmp->AddChild (demoView); - demoView->SetFont (&font); - demoView->SetFont (&font); - demoView->SetHighColor (0xBE, 0xBE, 0xBE, 0xBE); - demoView->SetDrawingMode (B_OP_COPY); - demoView->DrawString (demotext, BPoint (fh.ascent + fh.descent + fh.leading, h - fh.descent)); + tmp->AddChild(demoView); + demoView->SetFont(&font); + demoView->SetFont(&font); + demoView->SetHighColor(0xBE, 0xBE, 0xBE, 0xBE); + demoView->SetDrawingMode(B_OP_COPY); + demoView->DrawString(demotext, BPoint(fh.ascent + fh.descent + fh.leading, h - fh.descent)); demoView->Sync(); - tmp->RemoveChild (demoView); + tmp->RemoveChild(demoView); delete demoView; - for (int i = 0; i < numLayers; i++) - { + for (int i = 0; i < numLayers; i++) { layer[i]->Lock(); - uint32 *dst = (uint32 *)layer[i]->Bits(); - uint32 *src = (uint32 *)tmp->Bits(); - uint32 size = layer[i]->BitsLength()/4; - for (uint32 j = 0; j < size; j++) - { + uint32* dst = (uint32*)layer[i]->Bits(); + uint32* src = (uint32*)tmp->Bits(); + uint32 size = layer[i]->BitsLength() / 4; + for (uint32 j = 0; j < size; j++) { if (*src++ == 0xBEBEBEBE) *dst++ ^= COLOR_MASK; else @@ -233,258 +264,242 @@ void InsertGlobalAlpha (Layer *layer[], int numLayers) // Watermark all layers delete tmp; } -BBitmap *entry2bitmap (BEntry entry, bool silent) +BBitmap* +entry2bitmap(BEntry entry, bool silent) { - extern const char *Version; -// extern bool DataTypes; - BBitmap *map = NULL; + extern const char* Version; + // extern bool DataTypes; + BBitmap* map = NULL; char type[80]; - BNode node = BNode (&entry); + BNode node = BNode(&entry); ssize_t s; - FILE *fp = NULL; - if ((s = node.ReadAttr ("BEOS:TYPE", B_STRING_TYPE, 0, type, 79)) > 0) - { - if (!strcmp (type, "image/becasso") || !strcmp (type, "image/x-becasso")) - { - Layer *layer[MAX_LAYERS]; + FILE* fp = NULL; + if ((s = node.ReadAttr("BEOS:TYPE", B_STRING_TYPE, 0, type, 79)) > 0) { + if (!strcmp(type, "image/becasso") || !strcmp(type, "image/x-becasso")) { + Layer* layer[MAX_LAYERS]; BPath path; - entry.GetPath (&path); - fp = fopen (path.Path(), "r"); + entry.GetPath(&path); + fp = fopen(path.Path(), "r"); char line[81]; - do - { - fgets (line, 80, fp); - } while (line[0] == '#'); - char *endp = line; - float tvers = atof (Version); - float cvers = strtod (endp, &endp); - int numLayers = strtol (endp, &endp, 10); - /* int currentlayer = */ strtol (endp, &endp, 10); // not used - /* int dpi = */strtol (endp, &endp, 10); // not used - int watermarked = strtol (endp, &endp, 10); // watermarked image? + do { + fgets(line, 80, fp); + } while (line[0] == '#'); + char* endp = line; + float tvers = atof(Version); + float cvers = strtod(endp, &endp); + int numLayers = strtol(endp, &endp, 10); + /* int currentlayer = */ strtol(endp, &endp, 10); // not used + /* int dpi = */ strtol(endp, &endp, 10); // not used + int watermarked = strtol(endp, &endp, 10); // watermarked image? // printf ("#Layers = %d\n", numLayers); - /*int currentLayer = */strtol (endp, &endp, 10); + /*int currentLayer = */ strtol(endp, &endp, 10); BRect lFrame; - if (int (cvers) > int (tvers)) // Check major version + if (int(cvers) > int(tvers)) // Check major version { return NULL; } - if (int (cvers) == int (tvers) && cvers - int (cvers) > tvers - int (tvers)) // Check release + if (int(cvers) == int(tvers) && + cvers - int(cvers) > tvers - int(tvers)) // Check release { return NULL; } - switch (int (cvers)) - { + switch (int(cvers)) { case 0: - for (int i = 0; i < numLayers; i++) - { - fgets (line, 80, fp); + for (int i = 0; i < numLayers; i++) { + fgets(line, 80, fp); line[strlen(line) - 1] = 0; endp = line; - lFrame.left = strtod (endp, &endp); - lFrame.top = strtod (endp, &endp); - lFrame.right = strtod (endp, &endp); - lFrame.bottom = strtod (endp, &endp); - // int m = strtol (endp, &endp, 10); - bool h = strtol (endp, &endp, 10); - layer[i] = new Layer (lFrame, endp); - layer[i]->Hide (h); - layer[i]->setMode (0); // Note: DM_BLEND has moved to 0, and <1.1 didn't have any other ops anyway. - fread (layer[i]->Bits(), layer[i]->BitsLength(), 1, fp); + lFrame.left = strtod(endp, &endp); + lFrame.top = strtod(endp, &endp); + lFrame.right = strtod(endp, &endp); + lFrame.bottom = strtod(endp, &endp); + // int m = strtol (endp, &endp, 10); + bool h = strtol(endp, &endp, 10); + layer[i] = new Layer(lFrame, endp); + layer[i]->Hide(h); + layer[i]->setMode(0 + ); // Note: DM_BLEND has moved to 0, and <1.1 didn't have any other ops anyway. + fread(layer[i]->Bits(), layer[i]->BitsLength(), 1, fp); } break; - case 1: - { - uchar *tmpzbuf = NULL; + case 1: { + uchar* tmpzbuf = NULL; z_streamp zstream = new z_stream; zstream->zalloc = Z_NULL; zstream->zfree = Z_NULL; zstream->opaque = Z_NULL; - if (inflateInit (zstream) != Z_OK) - { - fprintf (stderr, "Oops! Problems with inflateInit()...\n"); + if (inflateInit(zstream) != Z_OK) { + fprintf(stderr, "Oops! Problems with inflateInit()...\n"); } - for (int i = 0; i < numLayers; i++) - { - fgets (line, 80, fp); + for (int i = 0; i < numLayers; i++) { + fgets(line, 80, fp); line[strlen(line) - 1] = 0; // printf ("%s\n", line); endp = line; - lFrame.left = strtod (endp, &endp); - lFrame.top = strtod (endp, &endp); - lFrame.right = strtod (endp, &endp); - lFrame.bottom = strtod (endp, &endp); - int m = strtol (endp, &endp, 10); - bool h = strtol (endp, &endp, 10); - uchar ga = strtol (endp, &endp, 10); - if (cvers > 1.1) - { - /* int am = */strtol (endp, &endp, 10); + lFrame.left = strtod(endp, &endp); + lFrame.top = strtod(endp, &endp); + lFrame.right = strtod(endp, &endp); + lFrame.bottom = strtod(endp, &endp); + int m = strtol(endp, &endp, 10); + bool h = strtol(endp, &endp, 10); + uchar ga = strtol(endp, &endp, 10); + if (cvers > 1.1) { + /* int am = */ strtol(endp, &endp, 10); // printf ("%salpha map\n", am ? "" : "no "); } - layer[i] = new Layer (lFrame, endp); - layer[i]->Hide (h); + layer[i] = new Layer(lFrame, endp); + layer[i]->Hide(h); if (cvers == 1.0) - layer[i]->setMode (0); // Note: DM_BLEND has moved to 0, and <1.1 didn't have any other ops anyway. + layer[i]->setMode(0); // Note: DM_BLEND has moved to 0, and <1.1 didn't have + // any other ops anyway. else - layer[i]->setMode (m); - layer[i]->setGlobalAlpha (ga); - layer[i]->setAlphaMap (NULL); + layer[i]->setMode(m); + layer[i]->setGlobalAlpha(ga); + layer[i]->setAlphaMap(NULL); } - for (int i = 0; i < numLayers; i++) - { - if (!tmpzbuf) - { - tmpzbuf = new uchar [layer[i]->BitsLength()]; + for (int i = 0; i < numLayers; i++) { + if (!tmpzbuf) { + tmpzbuf = new uchar[layer[i]->BitsLength()]; zstream->avail_in = 0; } zstream->next_in = tmpzbuf; - zstream->avail_in += fread (tmpzbuf, 1, layer[i]->BitsLength() - zstream->avail_in, fp); - zstream->next_out = (uchar *) layer[i]->Bits(); + zstream->avail_in += + fread(tmpzbuf, 1, layer[i]->BitsLength() - zstream->avail_in, fp); + zstream->next_out = (uchar*)layer[i]->Bits(); zstream->avail_out = layer[i]->BitsLength(); - // printf ("avail_in = %li, avail_out = %li\n", zstream->avail_in, zstream->avail_out); - if (inflate (zstream, Z_FINISH) != Z_STREAM_END) - { - fprintf (stderr, "Oops! Layer couldn't be decompressed completely...\n"); + // printf ("avail_in = %li, avail_out = %li\n", zstream->avail_in, + // zstream->avail_out); + if (inflate(zstream, Z_FINISH) != Z_STREAM_END) { + fprintf(stderr, "Oops! Layer couldn't be decompressed completely...\n"); } - memmove (tmpzbuf, zstream->next_in, zstream->avail_in); - inflateReset (zstream); + memmove(tmpzbuf, zstream->next_in, zstream->avail_in); + inflateReset(zstream); } - if (inflateEnd (zstream) != Z_OK) - { - fprintf (stderr, "Oops! Temporary zlib buffer couldn't be deallocated\n"); + if (inflateEnd(zstream) != Z_OK) { + fprintf(stderr, "Oops! Temporary zlib buffer couldn't be deallocated\n"); } - delete [] tmpzbuf; + delete[] tmpzbuf; delete zstream; break; if (watermarked) InsertGlobalAlpha(layer, numLayers); - } - case 2: - { - uchar *tmpzbuf = NULL; + case 2: { + uchar* tmpzbuf = NULL; z_streamp zstream = new z_stream; zstream->zalloc = Z_NULL; zstream->zfree = Z_NULL; zstream->opaque = Z_NULL; - if (inflateInit (zstream) != Z_OK) - { - fprintf (stderr, "Oops! Problems with inflateInit()...\n"); + if (inflateInit(zstream) != Z_OK) { + fprintf(stderr, "Oops! Problems with inflateInit()...\n"); } - for (int i = 0; i < numLayers; i++) - { - fgets (line, 80, fp); + for (int i = 0; i < numLayers; i++) { + fgets(line, 80, fp); line[strlen(line) - 1] = 0; // printf ("%s\n", line); endp = line; - lFrame.left = strtod (endp, &endp); - lFrame.top = strtod (endp, &endp); - lFrame.right = strtod (endp, &endp); - lFrame.bottom = strtod (endp, &endp); - int m = strtol (endp, &endp, 10); - bool h = strtol (endp, &endp, 10); - uchar ga = strtol (endp, &endp, 10); - if (cvers > 1.1) - { - /* int am = */strtol (endp, &endp, 10); + lFrame.left = strtod(endp, &endp); + lFrame.top = strtod(endp, &endp); + lFrame.right = strtod(endp, &endp); + lFrame.bottom = strtod(endp, &endp); + int m = strtol(endp, &endp, 10); + bool h = strtol(endp, &endp, 10); + uchar ga = strtol(endp, &endp, 10); + if (cvers > 1.1) { + /* int am = */ strtol(endp, &endp, 10); // printf ("%salpha map\n", am ? "" : "no "); } - layer[i] = new Layer (lFrame, endp); - layer[i]->Hide (h); + layer[i] = new Layer(lFrame, endp); + layer[i]->Hide(h); if (cvers == 1.0) - layer[i]->setMode (0); // Note: DM_BLEND has moved to 0, and <1.1 didn't have any other ops anyway. + layer[i]->setMode(0); // Note: DM_BLEND has moved to 0, and <1.1 didn't have + // any other ops anyway. else - layer[i]->setMode (m); - layer[i]->setGlobalAlpha (ga); - layer[i]->setAlphaMap (NULL); + layer[i]->setMode(m); + layer[i]->setGlobalAlpha(ga); + layer[i]->setAlphaMap(NULL); } - for (int i = 0; i < numLayers; i++) - { - if (!tmpzbuf) - { - tmpzbuf = new uchar [layer[i]->BitsLength()]; + for (int i = 0; i < numLayers; i++) { + if (!tmpzbuf) { + tmpzbuf = new uchar[layer[i]->BitsLength()]; zstream->avail_in = 0; } zstream->next_in = tmpzbuf; - zstream->avail_in += fread (tmpzbuf, 1, layer[i]->BitsLength() - zstream->avail_in, fp); - zstream->next_out = (uchar *) layer[i]->Bits(); + zstream->avail_in += + fread(tmpzbuf, 1, layer[i]->BitsLength() - zstream->avail_in, fp); + zstream->next_out = (uchar*)layer[i]->Bits(); zstream->avail_out = layer[i]->BitsLength(); - // printf ("avail_in = %li, avail_out = %li\n", zstream->avail_in, zstream->avail_out); - if (inflate (zstream, Z_FINISH) != Z_STREAM_END) - { - fprintf (stderr, "Oops! Layer couldn't be decompressed completely...\n"); + // printf ("avail_in = %li, avail_out = %li\n", zstream->avail_in, + // zstream->avail_out); + if (inflate(zstream, Z_FINISH) != Z_STREAM_END) { + fprintf(stderr, "Oops! Layer couldn't be decompressed completely...\n"); } - memmove (tmpzbuf, zstream->next_in, zstream->avail_in); - inflateReset (zstream); + memmove(tmpzbuf, zstream->next_in, zstream->avail_in); + inflateReset(zstream); } - if (inflateEnd (zstream) != Z_OK) - { - fprintf (stderr, "Oops! Temporary zlib buffer couldn't be deallocated\n"); + if (inflateEnd(zstream) != Z_OK) { + fprintf(stderr, "Oops! Temporary zlib buffer couldn't be deallocated\n"); } - delete [] tmpzbuf; + delete[] tmpzbuf; delete zstream; break; if (watermarked) InsertGlobalAlpha(layer, numLayers); - } - default: // This should never happen - fprintf (stderr, "Hmm, somehow a newer version file got through to the actual loading routine.\n"); + default: // This should never happen + fprintf( + stderr, + "Hmm, somehow a newer version file got through to the actual loading routine.\n" + ); } - fclose (fp); + fclose(fp); // OK, we've got the layers. Now blend them into a BBitmap. -// lFrame.PrintToStream(); - map = new BBitmap (lFrame, B_RGBA32, false); -// ulong h = height; + // lFrame.PrintToStream(); + map = new BBitmap(lFrame, B_RGBA32, false); + // ulong h = height; ulong w = lFrame.IntegerWidth() + 1; -// ulong sbbpr = bitmap->BytesPerRow(); + // ulong sbbpr = bitmap->BytesPerRow(); ulong sbpr = layer[0]->BytesPerRow(); - ulong rt = ulong (lFrame.top); - ulong rb = ulong (lFrame.bottom); - ulong rl = ulong (lFrame.left); - ulong rr = ulong (lFrame.right); + ulong rt = ulong(lFrame.top); + ulong rb = ulong(lFrame.bottom); + ulong rl = ulong(lFrame.left); + ulong rr = ulong(lFrame.right); ulong dw = rr - rl + 1; ulong ddiff = (w - dw); -// ulong sdiff = sbpr - dw; - uint32 *src = (uint32 *) layer[0]->Bits(); - src += rt*sbpr + rl; - uint32 *dest = (uint32 *) map->Bits() + (rt*w + rl) - 1; -// ulong brl = rl; - - // printf ("Background layer: [%ld, %ld, %ld, %ld]\n", rl, rt, rr, rb); - // printf ("3"); fflush (stdout); - #if defined (__POWERPC__) - uint32 check1 = 0xFFFFFF00; - uint32 check2 = 0xFFFFFF00; - #else - uint32 check1 = 0x00FFFFFF; - uint32 check2 = 0x00FFFFFF; - #endif - for (ulong y = rt; y <= rb; y++) // First layer: Background. + // ulong sdiff = sbpr - dw; + uint32* src = (uint32*)layer[0]->Bits(); + src += rt * sbpr + rl; + uint32* dest = (uint32*)map->Bits() + (rt * w + rl) - 1; + // ulong brl = rl; + +// printf ("Background layer: [%ld, %ld, %ld, %ld]\n", rl, rt, rr, rb); +// printf ("3"); fflush (stdout); +#if defined(__POWERPC__) + uint32 check1 = 0xFFFFFF00; + uint32 check2 = 0xFFFFFF00; +#else + uint32 check1 = 0x00FFFFFF; + uint32 check2 = 0x00FFFFFF; +#endif + for (ulong y = rt; y <= rb; y++) // First layer: Background. { - for (ulong x = rl; x <= rr; x++) - { - if (((x & 8) || (y & 8)) && !((x & 8) && (y & 8))) - { + for (ulong x = rl; x <= rr; x++) { + if (((x & 8) || (y & 8)) && !((x & 8) && (y & 8))) { *(++dest) = check1; - } - else - { + } else { *(++dest) = check2; } } dest += ddiff; } - for (int i = 0; i < numLayers; i++) // Next the layers: Add. + for (int i = 0; i < numLayers; i++) // Next the layers: Add. { // printf ("Layer %i\n", i); - if (!layer[i]->IsHidden()) - { - Merge (map, layer[i], lFrame, false, true); + if (!layer[i]->IsHidden()) { + Merge(map, layer[i], lFrame, false, true); } } @@ -492,65 +507,58 @@ BBitmap *entry2bitmap (BEntry entry, bool silent) } } -#if defined (DATATYPES) - if (DataTypes) - { - ProgressiveBitmapStream *bms; - BFile inStream (&entry, B_READ_ONLY); +#if defined(DATATYPES) + if (DataTypes) { + ProgressiveBitmapStream* bms; + BFile inStream(&entry, B_READ_ONLY); bms = new ProgressiveBitmapStream(); -// bms->DisplayProgressBar (BPoint (200, 200), "Reading Image…"); - if (DATATranslate (inStream, NULL, NULL, *bms, DATA_BITMAP)) - { - if (!silent) - { + // bms->DisplayProgressBar (BPoint (200, 200), "Reading Image…"); + if (DATATranslate(inStream, NULL, NULL, *bms, DATA_BITMAP)) { + if (!silent) { // Error translating... char errstring[B_FILE_NAME_LENGTH + 64]; - sprintf (errstring, "Datatypes error:\nCouldn't translate `%s'", fName); - BAlert *alert = new BAlert ("", errstring, "OK", NULL, NULL, - B_WIDTH_AS_USUAL, B_WARNING_ALERT); + sprintf(errstring, "Datatypes error:\nCouldn't translate `%s'", fName); + BAlert* alert = + new BAlert("", errstring, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->Go(); } - } - else - { + } else { map = bms->GetBitmap(); - bms->SetDispose (false); + bms->SetDispose(false); } delete bms; - } - else - { - printf ("No DataTypes (?!)\n"); + } else { + printf("No DataTypes (?!)\n"); // No DataTypes... } #else BPath path; - entry.GetPath (&path); - if (!(map = BTranslationUtils::GetBitmapFile (path.Path())) && !silent) - { + entry.GetPath(&path); + if (!(map = BTranslationUtils::GetBitmapFile(path.Path())) && !silent) { char errstring[B_FILE_NAME_LENGTH + 64]; - sprintf (errstring, "Translation Kit error:\nCouldn't translate '%s'", path.Path()); - BAlert *alert = new BAlert ("", errstring, "Help", "OK", NULL, - B_WIDTH_AS_USUAL, B_WARNING_ALERT); + sprintf(errstring, "Translation Kit error:\nCouldn't translate '%s'", path.Path()); + BAlert* alert = + new BAlert("", errstring, "Help", "OK", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); uint32 button = alert->Go(); - if (button == 0) - { - BNode node (&entry); + if (button == 0) { + BNode node(&entry); char filetype[80]; - filetype [node.ReadAttr ("BEOS:TYPE", 0, 0, filetype, 80)] = 0; - if (!strncmp (filetype, "image/", 6)) - { - sprintf (errstring, - "The file '%s' is of type '%s'.\nThis does look like an image format to me.\nMaybe you haven't installed the corresponding Translator?", - path.Path(), filetype); - } - else - { - sprintf (errstring, + filetype[node.ReadAttr("BEOS:TYPE", 0, 0, filetype, 80)] = 0; + if (!strncmp(filetype, "image/", 6)) { + sprintf( + errstring, + "The file '%s' is of type '%s'.\nThis does look like an image format to " + "me.\nMaybe you haven't installed the corresponding Translator?", + path.Path(), filetype + ); + } else { + sprintf( + errstring, "The file '%s' is of type '%s'.\nI don't think this is an image at all.", - path.Path(), filetype); + path.Path(), filetype + ); } - alert = new BAlert ("", errstring, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT); + alert = new BAlert("", errstring, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT); alert->Go(); } } @@ -558,118 +566,122 @@ BBitmap *entry2bitmap (BEntry entry, bool silent) return map; } -float AverageAlpha (BBitmap *src) +float +AverageAlpha(BBitmap* src) { float res = 0; - uint32 *src_data = (uint32 *) src->Bits(); + uint32* src_data = (uint32*)src->Bits(); int w = src->Bounds().IntegerWidth(); int h = src->Bounds().IntegerHeight(); src_data--; for (int i = 0; i <= h; i++) for (int j = 0; j <= w; j++) -#if defined (__POWERPC__) +#if defined(__POWERPC__) res += *(++src_data) & 0xFF; #else res += (*(++src_data) >> 24); #endif - res /= (w + 1)*(h + 1); + res /= (w + 1) * (h + 1); return res; } -void InvertAlpha (BBitmap *src) +void +InvertAlpha(BBitmap* src) { -// printf ("AverageAlpha before = %f\n", AverageAlpha (src)); - uint32 *src_data = (uint32 *) src->Bits() - 1; + // printf ("AverageAlpha before = %f\n", AverageAlpha (src)); + uint32* src_data = (uint32*)src->Bits() - 1; int w = src->Bounds().IntegerWidth(); int h = src->Bounds().IntegerHeight(); for (int i = 0; i <= h; i++) - for (int j = 0; j <= w; j++) - { + for (int j = 0; j <= w; j++) { uint32 pixel = *(++src_data); *src_data = (pixel & COLOR_MASK) | ((255 - ALPHA(pixel)) << ALPHA_BPOS); } -// printf ("AverageAlpha after = %f\n", AverageAlpha (src)); + // printf ("AverageAlpha after = %f\n", AverageAlpha (src)); } -void BlendWithAlpha (BBitmap *src, BBitmap *dest, long x, long y, int /* strength */) +void +BlendWithAlpha(BBitmap* src, BBitmap* dest, long x, long y, int /* strength */) { // src: 32bit BBitmap // dest: 32bit BBitmap // Note: Alpha = opacity! - uint32 *src_data = (uint32 *) src->Bits(); - ulong src_bpr = src->BytesPerRow()/4; - uint32 *dest_data = (uint32 *) dest->Bits(); - ulong dest_bpr = dest->BytesPerRow()/4; + uint32* src_data = (uint32*)src->Bits(); + ulong src_bpr = src->BytesPerRow() / 4; + uint32* dest_data = (uint32*)dest->Bits(); + ulong dest_bpr = dest->BytesPerRow() / 4; int src_w = src->Bounds().IntegerWidth(); int src_h = src->Bounds().IntegerHeight(); int dest_w = dest->Bounds().IntegerWidth(); int dest_h = dest->Bounds().IntegerHeight(); - if ((x + src_w <= 0) || (x > dest_w) || (y + src_h <= 0) || (y > dest_h)) - { + if ((x + src_w <= 0) || (x > dest_w) || (y + src_h <= 0) || (y > dest_h)) { return; } // Clipping - int minx = max_c (x, 0); - int maxx = min_c (x + src_w + 1, dest_w + 1); - int miny = max_c (y, 0); - int maxy = min_c (y + src_h + 1, dest_h + 1); + int minx = max_c(x, 0); + int maxx = min_c(x + src_w + 1, dest_w + 1); + int miny = max_c(y, 0); + int maxy = min_c(y + src_h + 1, dest_h + 1); ulong src_bprdiff = src_bpr - (maxx - minx); ulong dest_bprdiff = dest_bpr - (maxx - minx); if (y < 0) - src_data -= y*src_bpr; + src_data -= y * src_bpr; if (x < 0) src_data -= x; - dest_data += miny*dest_bpr + minx; + dest_data += miny * dest_bpr + minx; - dest_data--; // Note: On PPC, pre-increment is faster. + dest_data--; // Note: On PPC, pre-increment is faster. src_data--; - for (int j = miny; j < maxy; j++) - { - for (int i = minx; i < maxx; i++) - { -#if defined (__POWERPC__) + for (int j = miny; j < maxy; j++) { + for (int i = minx; i < maxx; i++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); register int sa = srcpixel & 0xFF; register int da = 255 - sa; // destpixel & 0xFF; - register int ta = 255; //sa + da; - if (sa == 255) // Fully Opaque + register int ta = 255; // sa + da; + if (sa == 255) // Fully Opaque { *dest_data = srcpixel; - } - else if (sa == 0) // Fully transparent - { - } - else + } else if (sa == 0) // Fully transparent { - *dest_data = ((((((destpixel>>24) )*da + ((srcpixel>>24) )*sa)/ta)<<24) & 0xFF000000) | - ((((((destpixel>>16) & 0xFF)*da + ((srcpixel>>16) & 0xFF)*sa)/ta)<<16) & 0x00FF0000) | - ((((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> 8) & 0xFF)*sa)/ta)<< 8) & 0x0000FF00) | - clipchar (sa + int (destpixel & 0xFF)); + } else { + *dest_data = + ((((((destpixel >> 24)) * da + ((srcpixel >> 24)) * sa) / ta) << 24) & + 0xFF000000) | + ((((((destpixel >> 16) & 0xFF) * da + ((srcpixel >> 16) & 0xFF) * sa) / ta) + << 16) & + 0x00FF0000) | + ((((((destpixel >> 8) & 0xFF) * da + ((srcpixel >> 8) & 0xFF) * sa) / ta) + << 8) & + 0x0000FF00) | + clipchar(sa + int(destpixel & 0xFF)); } #else register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); register int sa = srcpixel >> 24; register int da = 255 - sa; // destpixel >> 24; - register int ta = 255; // sa + da; - if (sa == 255) // Fully Opaque + register int ta = 255; // sa + da; + if (sa == 255) // Fully Opaque { *dest_data = srcpixel; - } - else if (sa == 0) // Fully transparent - { - } - else + } else if (sa == 0) // Fully transparent { - *dest_data = ((((((destpixel>>16) & 0xFF)*da + ((srcpixel>>16) & 0xFF)*sa)/ta)<<16) & 0x00FF0000) | - ((((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> 8) & 0xFF)*sa)/ta)<< 8) & 0x0000FF00) | - ((((((destpixel ) & 0xFF)*da + ((srcpixel ) & 0xFF)*sa)/ta) ) & 0x000000FF) | - ((clipchar (sa + int (destpixel >> 24))) << 24); + } else { + *dest_data = + ((((((destpixel >> 16) & 0xFF) * da + ((srcpixel >> 16) & 0xFF) * sa) / ta) + << 16) & + 0x00FF0000) | + ((((((destpixel >> 8) & 0xFF) * da + ((srcpixel >> 8) & 0xFF) * sa) / ta) + << 8) & + 0x0000FF00) | + ((((((destpixel) & 0xFF) * da + ((srcpixel) & 0xFF) * sa) / ta)) & 0x000000FF) | + ((clipchar(sa + int(destpixel >> 24))) << 24); } #endif } @@ -678,72 +690,75 @@ void BlendWithAlpha (BBitmap *src, BBitmap *dest, long x, long y, int /* strengt } } -void AddWithAlpha (BBitmap *src, BBitmap *dest, long x, long y, int strength) +void +AddWithAlpha(BBitmap* src, BBitmap* dest, long x, long y, int strength) { // src: 32bit BBitmap // dest: 32bit BBitmap // Note: Alpha = opacity! - uint32 *src_data = (uint32 *) src->Bits(); - ulong src_bpr = src->BytesPerRow()/4; - uint32 *dest_data = (uint32 *) dest->Bits(); - ulong dest_bpr = dest->BytesPerRow()/4; + uint32* src_data = (uint32*)src->Bits(); + ulong src_bpr = src->BytesPerRow() / 4; + uint32* dest_data = (uint32*)dest->Bits(); + ulong dest_bpr = dest->BytesPerRow() / 4; int src_w = src->Bounds().IntegerWidth(); int src_h = src->Bounds().IntegerHeight(); int dest_w = dest->Bounds().IntegerWidth(); int dest_h = dest->Bounds().IntegerHeight(); - if ((x + src_w <= 0) || (x > dest_w) || (y + src_h <= 0) || (y > dest_h) || !strength) - { + if ((x + src_w <= 0) || (x > dest_w) || (y + src_h <= 0) || (y > dest_h) || !strength) { return; } // Clipping - int minx = max_c (x, 0); - int maxx = min_c (x + src_w + 1, dest_w + 1); - int miny = max_c (y, 0); - int maxy = min_c (y + src_h + 1, dest_h + 1); + int minx = max_c(x, 0); + int maxx = min_c(x + src_w + 1, dest_w + 1); + int miny = max_c(y, 0); + int maxy = min_c(y + src_h + 1, dest_h + 1); ulong src_bprdiff = src_bpr - (maxx - minx); ulong dest_bprdiff = dest_bpr - (maxx - minx); if (y < 0) - src_data -= y*src_bpr; + src_data -= y * src_bpr; if (x < 0) src_data -= x; - dest_data += miny*dest_bpr + minx; + dest_data += miny * dest_bpr + minx; - dest_data--; // Note: On PPC, pre-increment is faster. + dest_data--; // Note: On PPC, pre-increment is faster. src_data--; - if (strength == 255) - { - for (int j = miny; j < maxy; j++) - { - for (int i = minx; i < maxx; i++) - { -#if defined (__POWERPC__) + if (strength == 255) { + for (int j = miny; j < maxy; j++) { + for (int i = minx; i < maxx; i++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); register int sa = srcpixel & 0xFF; register int da = /* destpixel & 0xFF; */ 255 - sa; register int ta = /* sa + da;*/ 255; - if (sa == 255 || /* da == 0*/ !(destpixel & 0xFF)) // Fully opaque + if (sa == 255 || /* da == 0*/ !(destpixel & 0xFF)) // Fully opaque { *dest_data = srcpixel; - } - else if (sa == 0) // Fully transparent - { - } - else + } else if (sa == 0) // Fully transparent { -// *dest_data = ((((((destpixel>>24) )*da + ((srcpixel>>24) )*sa)/ta)<<24) & 0xFF000000) | -// ((((((destpixel>>16) & 0xFF)*da + ((srcpixel>>16) & 0xFF)*sa)/ta)<<16) & 0x00FF0000) | -// ((((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> 8) & 0xFF)*sa)/ta)<< 8) & 0x0000FF00) | -// clipchar (sa + int (destpixel & 0xFF)); - *dest_data = ((((destpixel & 0xFF000000)/ta)*da + ((srcpixel & 0xFF000000)/ta)*sa) & 0xFF000000) | - ((((destpixel & 0x00FF0000)/ta)*da + ((srcpixel & 0x00FF0000)/ta)*sa) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa))/ta & 0x0000FF00) | - clipchar (sa + int (destpixel & 0xFF)); - // clipchar (ta); + } else { + // *dest_data = ((((((destpixel>>24) )*da + + //((srcpixel>>24) )*sa)/ta)<<24) & 0xFF000000) | + // ((((((destpixel>>16) & 0xFF)*da + + //((srcpixel>>16) & 0xFF)*sa)/ta)<<16) & 0x00FF0000) | + // ((((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> + // 8) & 0xFF)*sa)/ta)<< 8) & 0x0000FF00) | + // clipchar (sa + int (destpixel & 0xFF)); + *dest_data = + ((((destpixel & 0xFF000000) / ta) * da + ((srcpixel & 0xFF000000) / ta) * sa + ) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) / ta) * da + ((srcpixel & 0x00FF0000) / ta) * sa + ) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa)) / ta & + 0x0000FF00) | + clipchar(sa + int(destpixel & 0xFF)); + // clipchar (ta); } #else register uint32 srcpixel = *(++src_data); @@ -751,122 +766,123 @@ void AddWithAlpha (BBitmap *src, BBitmap *dest, long x, long y, int strength) register int sa = srcpixel >> 24; register int da = /*destpixel >> 24;*/ 255 - sa; register int ta = /*sa + da; */ ta = 255; - if (sa == 255 || /*da == 0*/ !(destpixel & 0xFF000000)) // Fully opaque + if (sa == 255 || /*da == 0*/ !(destpixel & 0xFF000000)) // Fully opaque { *dest_data = srcpixel; - } - else if (sa == 0) // Fully transparent - { - } - else + } else if (sa == 0) // Fully transparent { - *dest_data = ((((((destpixel & 0x00FF0000) >> 1)*da + ((srcpixel & 0x00FF0000) >> 1)*sa)/ta) << 1) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/ta) & 0x0000FF00) | - ((((destpixel & 0x000000FF)*da + (srcpixel & 0x000000FF)*sa)/ta) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); + } else { + *dest_data = + ((((((destpixel & 0x00FF0000) >> 1) * da + + ((srcpixel & 0x00FF0000) >> 1) * sa) / + ta) + << 1) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) / ta) & + 0x0000FF00) | + ((((destpixel & 0x000000FF) * da + (srcpixel & 0x000000FF) * sa) / ta) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); } #endif } src_data += src_bprdiff; dest_data += dest_bprdiff; } - } - else if (strength > 0) - { - for (int j = miny; j < maxy; j++) - { - for (int i = minx; i < maxx; i++) - { -#if defined (__POWERPC__) + } else if (strength > 0) { + for (int j = miny; j < maxy; j++) { + for (int i = minx; i < maxx; i++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); - register int sa = (srcpixel & 0xFF)*strength/255; + register int sa = (srcpixel & 0xFF) * strength / 255; register int da = /* destpixel & 0xFF;*/ 255 - sa; register int ta = /* sa + da;*/ 255; - if (sa == 255 || /* da == 0*/ !(destpixel & 0xFF)) // Fully opaque + if (sa == 255 || /* da == 0*/ !(destpixel & 0xFF)) // Fully opaque { *dest_data = srcpixel; - } - else if (sa == 0) // Fully transparent - { - } - else + } else if (sa == 0) // Fully transparent { -// *dest_data = ((((((destpixel>>24) )*da + ((srcpixel>>24) )*sa)/ta)<<24) & 0xFF000000) | -// ((((((destpixel>>16) & 0xFF)*da + ((srcpixel>>16) & 0xFF)*sa)/ta)<<16) & 0x00FF0000) | -// ((((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> 8) & 0xFF)*sa)/ta)<< 8) & 0x0000FF00) | -// clipchar (sa + int (destpixel & 0xFF)); - *dest_data = ((((destpixel & 0xFF000000)/ta)*da + ((srcpixel & 0xFF000000)/ta)*sa) & 0xFF000000) | - ((((destpixel & 0x00FF0000)/ta)*da + ((srcpixel & 0x00FF0000)/ta)*sa) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa))/ta & 0x0000FF00) | - clipchar (sa + int (destpixel & 0xFF)); - //clipchar (ta); + } else { + // *dest_data = ((((((destpixel>>24) )*da + + //((srcpixel>>24) )*sa)/ta)<<24) & 0xFF000000) | + // ((((((destpixel>>16) & 0xFF)*da + + //((srcpixel>>16) & 0xFF)*sa)/ta)<<16) & 0x00FF0000) | + // ((((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> + // 8) & 0xFF)*sa)/ta)<< 8) & 0x0000FF00) | + // clipchar (sa + int (destpixel & 0xFF)); + *dest_data = + ((((destpixel & 0xFF000000) / ta) * da + ((srcpixel & 0xFF000000) / ta) * sa + ) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) / ta) * da + ((srcpixel & 0x00FF0000) / ta) * sa + ) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa)) / ta & + 0x0000FF00) | + clipchar(sa + int(destpixel & 0xFF)); + // clipchar (ta); } #else register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); - register int sa = (srcpixel >> 24)*strength/255; + register int sa = (srcpixel >> 24) * strength / 255; register int da = /*destpixel >> 24;*/ 255 - sa; - register int ta = sa + da; // 255 - if (sa == 255 || /* da == 0 */ !(destpixel & 0xFF000000)) // Fully opaque + register int ta = sa + da; // 255 + if (sa == 255 || /* da == 0 */ !(destpixel & 0xFF000000)) // Fully opaque { *dest_data = srcpixel; - } - else if (sa == 0) // Fully transparent - { - } - else + } else if (sa == 0) // Fully transparent { - *dest_data = ((((((destpixel & 0x00FF0000) >> 1)*da + ((srcpixel & 0x00FF0000) >> 1)*sa)/ta) << 1) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/ta) & 0x0000FF00) | - ((((destpixel & 0x000000FF)*da + (srcpixel & 0x000000FF)*sa)/ta) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); + } else { + *dest_data = + ((((((destpixel & 0x00FF0000) >> 1) * da + + ((srcpixel & 0x00FF0000) >> 1) * sa) / + ta) + << 1) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) / ta) & + 0x0000FF00) | + ((((destpixel & 0x000000FF) * da + (srcpixel & 0x000000FF) * sa) / ta) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); } #endif } src_data += src_bprdiff; dest_data += dest_bprdiff; } - } - else // Very special case: Only "erase" transparency. + } else // Very special case: Only "erase" transparency. { - for (int j = miny; j < maxy; j++) - { - for (int i = minx; i < maxx; i++) - { -#if defined (__POWERPC__) + for (int j = miny; j < maxy; j++) { + for (int i = minx; i < maxx; i++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); - register int sa = (srcpixel & 0xFF)*(-strength)/255; + register int sa = (srcpixel & 0xFF) * (-strength) / 255; register int da = (destpixel & 0xFF); register int ta = 255; - if (sa == 255 || !(destpixel & 0xFF)) // Fully opaque + if (sa == 255 || !(destpixel & 0xFF)) // Fully opaque { *dest_data = destpixel & 0xFFFFFF00; - } - else if (sa == 0) // Fully transparent - { - } - else + } else if (sa == 0) // Fully transparent { - *dest_data = (destpixel & 0xFFFFFF00) | clipchar (da - sa); + } else { + *dest_data = (destpixel & 0xFFFFFF00) | clipchar(da - sa); } #else register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); - register int sa = (srcpixel >> 24)*(-strength)/255; + register int sa = (srcpixel >> 24) * (-strength) / 255; register int da = (destpixel >> 24); -// register int ta = 255; - if (sa == 255 || !(destpixel & 0xFF000000)) // Fully opaque + // register int ta = 255; + if (sa == 255 || !(destpixel & 0xFF000000)) // Fully opaque { *dest_data = destpixel & 0x00FFFFFF; - } - else if (sa == 0) // Fully transparent - { - } - else + } else if (sa == 0) // Fully transparent { - *dest_data = (destpixel & 0x00FFFFFF) | (clipchar (da - sa) << 24); + } else { + *dest_data = (destpixel & 0x00FFFFFF) | (clipchar(da - sa) << 24); } #endif } @@ -876,31 +892,28 @@ void AddWithAlpha (BBitmap *src, BBitmap *dest, long x, long y, int strength) } } -void InvertWithInverseAlpha (BBitmap *src, BBitmap *selection) +void +InvertWithInverseAlpha(BBitmap* src, BBitmap* selection) // Note: Inverse alpha because the selection map is an inverse alpha map. // i.e. alpha = transparency { long w = src->Bounds().IntegerWidth(); long h = src->Bounds().IntegerHeight(); - uchar *src_data = (uchar *) src->Bits(); - uchar *sel_data = (uchar *) selection->Bits(); + uchar* src_data = (uchar*)src->Bits(); + uchar* sel_data = (uchar*)selection->Bits(); long src_bpr = src->BytesPerRow(); long sel_bpr = selection->BytesPerRow(); long sel_bprdif = sel_bpr - w - 1; src_data--; sel_data--; - if (src->ColorSpace() == B_RGBA32) - { - for (int j = 0; j <= h; j++) - { - for (int i = 0; i <= w; i++) - { + if (src->ColorSpace() == B_RGBA32) { + for (int j = 0; j <= h; j++) { + for (int i = 0; i <= w; i++) { register unsigned int ialpha = *(++sel_data); if (ialpha == 255) src_data += 4; - else - { + else { *src_data = 255 - *(++src_data); *src_data = 255 - *(++src_data); *src_data = 255 - *(++src_data); @@ -909,15 +922,11 @@ void InvertWithInverseAlpha (BBitmap *src, BBitmap *selection) } sel_data += sel_bprdif; } - } - else if (src->ColorSpace() == B_COLOR_8_BIT) - { - const color_map *map = system_colors(); + } else if (src->ColorSpace() == B_COLOR_8_BIT) { + const color_map* map = system_colors(); long src_bprdif = src_bpr - w - 1; - for (int j = 0; j <= h; j++) - { - for (int i = 0; i <= w; i++) - { + for (int j = 0; j <= h; j++) { + for (int i = 0; i <= w; i++) { register unsigned int ialpha = *(++sel_data); if (ialpha == 255) ++src_data; @@ -930,7 +939,8 @@ void InvertWithInverseAlpha (BBitmap *src, BBitmap *selection) } } -void AddToSelection (Brush *src, BBitmap *dest, long x, long y, int strength) +void +AddToSelection(Brush* src, BBitmap* dest, long x, long y, int strength) { // dest: Transparency alpha map, 8bit (selection) @@ -938,56 +948,48 @@ void AddToSelection (Brush *src, BBitmap *dest, long x, long y, int strength) long src_h = src->Height(); long dest_w = dest->Bounds().IntegerWidth(); long dest_h = dest->Bounds().IntegerHeight(); - uchar *src_data = src->Data(); + uchar* src_data = src->Data(); ulong src_bpr = src_w; - uchar *dest_data = (uchar *) dest->Bits(); + uchar* dest_data = (uchar*)dest->Bits(); ulong dest_bpr = dest->BytesPerRow(); - if ((x + src_w <= 0) || (x > dest_w) || (y + src_h <= 0) || (y > dest_h) || !strength) - { + if ((x + src_w <= 0) || (x > dest_w) || (y + src_h <= 0) || (y > dest_h) || !strength) { return; } // Clipping - long minx = max_c (x, 0); - long maxx = min_c (x + src_w + 1, dest_w + 1); - long miny = max_c (y, 0); - long maxy = min_c (y + src_h + 1, dest_h + 1); + long minx = max_c(x, 0); + long maxx = min_c(x + src_w + 1, dest_w + 1); + long miny = max_c(y, 0); + long maxy = min_c(y + src_h + 1, dest_h + 1); ulong src_bprdiff = src_bpr - (maxx - minx); ulong dest_bprdiff = dest_bpr - (maxx - minx); if (y < 0) - src_data -= y*src_bpr; + src_data -= y * src_bpr; if (x < 0) src_data -= x; - dest_data += miny*dest_bpr + minx; + dest_data += miny * dest_bpr + minx; dest_data--; src_data--; - if (strength == 255) - { - for (long j = miny; j < maxy; j++) - { - for (long i = minx; i < maxx; i++) - { + if (strength == 255) { + for (long j = miny; j < maxy; j++) { + for (long i = minx; i < maxx; i++) { int sa = *(++src_data); -// int da = 255 - sa; - *dest_data = clipchar (int (*(++dest_data) + sa)); + // int da = 255 - sa; + *dest_data = clipchar(int(*(++dest_data) + sa)); } src_data += src_bprdiff; dest_data += dest_bprdiff; } - } - else - { - for (long j = miny; j < maxy; j++) - { - for (long i = minx; i < maxx; i++) - { - int sa = *(++src_data) * strength/255; -// int da = 255 - sa; - *dest_data = clipchar (int (*(++dest_data) + sa)); + } else { + for (long j = miny; j < maxy; j++) { + for (long i = minx; i < maxx; i++) { + int sa = *(++src_data) * strength / 255; + // int da = 255 - sa; + *dest_data = clipchar(int(*(++dest_data) + sa)); } src_data += src_bprdiff; dest_data += dest_bprdiff; @@ -995,52 +997,50 @@ void AddToSelection (Brush *src, BBitmap *dest, long x, long y, int strength) } } -void CopyWithTransparency (BBitmap *src, BBitmap *dest, long x, long y) +void +CopyWithTransparency(BBitmap* src, BBitmap* dest, long x, long y) // This is for bitmaps with B_TRANSPARENT_32_BIT as transparency values // (not `real' alpha-aware bitmaps) { -#if defined (__POWERPC__) - uint32 transparent = (B_TRANSPARENT_32_BIT.blue << 24) + (B_TRANSPARENT_32_BIT.green << 16) - + (B_TRANSPARENT_32_BIT.red << 8) + (B_TRANSPARENT_32_BIT.alpha); +#if defined(__POWERPC__) + uint32 transparent = (B_TRANSPARENT_32_BIT.blue << 24) + (B_TRANSPARENT_32_BIT.green << 16) + + (B_TRANSPARENT_32_BIT.red << 8) + (B_TRANSPARENT_32_BIT.alpha); #else - uint32 transparent = (B_TRANSPARENT_32_BIT.alpha << 24) + (B_TRANSPARENT_32_BIT.red << 16) - + (B_TRANSPARENT_32_BIT.green << 8) + (B_TRANSPARENT_32_BIT.blue); + uint32 transparent = (B_TRANSPARENT_32_BIT.alpha << 24) + (B_TRANSPARENT_32_BIT.red << 16) + + (B_TRANSPARENT_32_BIT.green << 8) + (B_TRANSPARENT_32_BIT.blue); #endif - uint32 *src_data = (uint32 *) src->Bits(); - ulong src_bprl = src->BytesPerRow()/4; - uint32 *dest_data = (uint32 *) dest->Bits(); - ulong dest_bprl = dest->BytesPerRow()/4; + uint32* src_data = (uint32*)src->Bits(); + ulong src_bprl = src->BytesPerRow() / 4; + uint32* dest_data = (uint32*)dest->Bits(); + ulong dest_bprl = dest->BytesPerRow() / 4; long src_w = src->Bounds().IntegerWidth(); long src_h = src->Bounds().IntegerHeight(); long dest_w = dest->Bounds().IntegerWidth(); long dest_h = dest->Bounds().IntegerHeight(); - if ((x + src_w <= 0) || (x > dest_w) || (y + src_h <= 0) || (y > dest_h)) - { + if ((x + src_w <= 0) || (x > dest_w) || (y + src_h <= 0) || (y > dest_h)) { return; } // Clipping - long minx = max_c (x, 0); - long maxx = min_c (x + src_w + 1, dest_w + 1); - long miny = max_c (y, 0); - long maxy = min_c (y + src_h + 1, dest_h + 1); + long minx = max_c(x, 0); + long maxx = min_c(x + src_w + 1, dest_w + 1); + long miny = max_c(y, 0); + long maxy = min_c(y + src_h + 1, dest_h + 1); ulong src_bprldiff = src_bprl - (maxx - minx); ulong dest_bprldiff = dest_bprl - (maxx - minx); if (y < 0) - src_data -= y*src_bprl; + src_data -= y * src_bprl; if (x < 0) src_data -= x; - dest_data += miny*dest_bprl + minx; + dest_data += miny * dest_bprl + minx; src_data--; - for (long j = miny; j < maxy; j++) - { - for (long i = minx; i < maxx; i++) - { - if ( *(++src_data) != transparent) + for (long j = miny; j < maxy; j++) { + for (long i = minx; i < maxx; i++) { + if (*(++src_data) != transparent) *dest_data = *src_data; dest_data++; } @@ -1049,24 +1049,22 @@ void CopyWithTransparency (BBitmap *src, BBitmap *dest, long x, long y) } } -BRect GetSmallestRect (BBitmap *b) +BRect +GetSmallestRect(BBitmap* b) { b->Lock(); - uchar *data = (uchar *) b->Bits(); + uchar* data = (uchar*)b->Bits(); long bpr = b->BytesPerRow(); long h = b->Bounds().IntegerHeight(); long w = b->Bounds().IntegerWidth(); - long bprdif = bpr - w - 1; - BRect res = BRect (w, h, 0, 0); + long bprdif = bpr - w - 1; + BRect res = BRect(w, h, 0, 0); data--; - for (long i = 0; i <= h; i++) - { - for (long j = 0; j <= w; j++) - { - if (*(++data)) - { + for (long i = 0; i <= h; i++) { + for (long j = 0; j <= w; j++) { + if (*(++data)) { if (i < res.top) res.top = i; if (i > res.bottom) @@ -1075,7 +1073,6 @@ BRect GetSmallestRect (BBitmap *b) res.left = j; if (j > res.right) res.right = j; - } } data += bprdif; @@ -1084,12 +1081,13 @@ BRect GetSmallestRect (BBitmap *b) b->Unlock(); if (res.right < res.left || res.bottom < res.top) - res = BRect (0, 0, w, h); + res = BRect(0, 0, w, h); return (res); } -void CutOrCopy (BBitmap *src, BBitmap *dest, BBitmap *sel, long offx, long offy, bool cut) +void +CutOrCopy(BBitmap* src, BBitmap* dest, BBitmap* sel, long offx, long offy, bool cut) { // The following code copies a rect of dest->Bounds() out of `src' at (offx, offy) // into `dest' selectively via `sel'. @@ -1102,51 +1100,48 @@ void CutOrCopy (BBitmap *src, BBitmap *dest, BBitmap *sel, long offx, long offy, sel->Lock(); dest->Lock(); uchar trans8; -#if defined (__POWERPC__) - uint32 transparent = (B_TRANSPARENT_32_BIT.blue << 24) + (B_TRANSPARENT_32_BIT.green << 16) - + (B_TRANSPARENT_32_BIT.red << 8) + (B_TRANSPARENT_32_BIT.alpha); +#if defined(__POWERPC__) + uint32 transparent = (B_TRANSPARENT_32_BIT.blue << 24) + (B_TRANSPARENT_32_BIT.green << 16) + + (B_TRANSPARENT_32_BIT.red << 8) + (B_TRANSPARENT_32_BIT.alpha); #else // uint32 transparent = (B_TRANSPARENT_32_BIT.alpha << 24) + (B_TRANSPARENT_32_BIT.red << 16) // + (B_TRANSPARENT_32_BIT.green << 8) + (B_TRANSPARENT_32_BIT.blue); #endif { BScreen screen; - trans8 = screen.IndexForColor (B_TRANSPARENT_32_BIT); + trans8 = screen.IndexForColor(B_TRANSPARENT_32_BIT); } - uchar *selbits = 0; + uchar* selbits = 0; long selbpr = 0; - if (sel) - { - selbits = (uchar *) sel->Bits(); + if (sel) { + selbits = (uchar*)sel->Bits(); selbpr = sel->BytesPerRow(); } - uint32 *srcbits = (uint32 *) src->Bits(); - long srcbprl = src->BytesPerRow()/4; - uint32 *destbits = (uint32 *) dest->Bits(); -// long destbprl = dest->BytesPerRow()/4; - ulong selbprdif = selbpr - long (dest->Bounds().right) - 1; - ulong srcbprldif = srcbprl - long (dest->Bounds().right) - 1; + uint32* srcbits = (uint32*)src->Bits(); + long srcbprl = src->BytesPerRow() / 4; + uint32* destbits = (uint32*)dest->Bits(); + // long destbprl = dest->BytesPerRow()/4; + ulong selbprdif = selbpr - long(dest->Bounds().right) - 1; + ulong srcbprldif = srcbprl - long(dest->Bounds().right) - 1; - selbits += offy*selbpr + offx; - srcbits += offy*srcbprl + offx; + selbits += offy * selbpr + offx; + srcbits += offy * srcbprl + offx; selbits--; - for (long i = 0; i <= dest->Bounds().bottom; i++) - { - for (long j = 0; j <= dest->Bounds().right; j++) - { + for (long i = 0; i <= dest->Bounds().bottom; i++) { + for (long j = 0; j <= dest->Bounds().right; j++) { register unsigned int opacity = sel ? *(++selbits) : 255; -// register unsigned int transparency = 255 - opacity; -// uchar *dpixel = (uchar *)destbits; - uchar *spixel = (uchar *)srcbits; -#if defined (__POWERPC__) - *destbits = (*srcbits & 0xFFFFFF00) | ((opacity*spixel[3]/255) & 0xFF); + // register unsigned int transparency = 255 - opacity; + // uchar *dpixel = (uchar *)destbits; + uchar* spixel = (uchar*)srcbits; +#if defined(__POWERPC__) + *destbits = (*srcbits & 0xFFFFFF00) | ((opacity * spixel[3] / 255) & 0xFF); #else - *destbits = (*srcbits & 0x00FFFFFF) | ((opacity*spixel[3]/255) << 24); + *destbits = (*srcbits & 0x00FFFFFF) | ((opacity * spixel[3] / 255) << 24); #endif if (cut) - spixel[3] = clipchar (int (spixel[3] - opacity)); + spixel[3] = clipchar(int(spixel[3] - opacity)); destbits++; srcbits++; } @@ -1159,75 +1154,76 @@ void CutOrCopy (BBitmap *src, BBitmap *dest, BBitmap *sel, long offx, long offy, src->Unlock(); } -void FastCopy (BBitmap *src, BBitmap *dest) +void +FastCopy(BBitmap* src, BBitmap* dest) { // Lock them yourself first! - double *destdata = (double *) dest->Bits(); - double *srcdata = (double *) src->Bits(); + double* destdata = (double*)dest->Bits(); + double* srcdata = (double*)src->Bits(); destdata--; srcdata--; - for (long i = 0; i < dest->BitsLength()/8; i++) + for (long i = 0; i < dest->BitsLength() / 8; i++) *(++destdata) = *(++srcdata); - if (dest->BitsLength() % 8) // Odd number of pixels... - *( (long *) ++destdata) = *( (long *) ++srcdata); + if (dest->BitsLength() % 8) // Odd number of pixels... + *((long*)++destdata) = *((long*)++srcdata); } #ifndef QUICK_DITHER // check HSV! -void FSDither (BBitmap *b32, BBitmap *b8, BRect place) +void +FSDither(BBitmap* b32, BBitmap* b8, BRect place) // Foley & Van Dam, pp 572. // Own note: Probably the errors in the different color channels should be weighted // according to visual sensibility. But this version is primarily meant to // be quick. { - uint32 width = place.IntegerWidth() + 1; -// uint32 height = place.IntegerHeight() + 1; - uint32 slpr = b32->BytesPerRow()/4; - bgra_pixel *src = (bgra_pixel *) b32->Bits() + int (place.top)*slpr + int (place.left) - 1; - int32 sdif = slpr - width; - uint32 dbpr = b8->BytesPerRow(); - uint8 *dest = (uint8 *) b8->Bits() + int (place.top)*dbpr + int (place.left) - 1; - int32 ddif = dbpr - width; - uint8 *xpal = (uint8 *) system_colors()->index_map; - const rgb_color *sysc = system_colors()->color_list; - - int *nera = new int[width]; - int *nega = new int[width]; - int *neba = new int[width]; - int *cera = new int[width]; - int *cega = new int[width]; - int *ceba = new int[width]; - - bzero (nera, width*sizeof(int)); - bzero (nega, width*sizeof(int)); - bzero (neba, width*sizeof(int)); - bzero (cera, width*sizeof(int)); - bzero (cega, width*sizeof(int)); - bzero (ceba, width*sizeof(int)); + uint32 width = place.IntegerWidth() + 1; + // uint32 height = place.IntegerHeight() + 1; + uint32 slpr = b32->BytesPerRow() / 4; + bgra_pixel* src = (bgra_pixel*)b32->Bits() + int(place.top) * slpr + int(place.left) - 1; + int32 sdif = slpr - width; + uint32 dbpr = b8->BytesPerRow(); + uint8* dest = (uint8*)b8->Bits() + int(place.top) * dbpr + int(place.left) - 1; + int32 ddif = dbpr - width; + uint8* xpal = (uint8*)system_colors()->index_map; + const rgb_color* sysc = system_colors()->color_list; + + int* nera = new int[width]; + int* nega = new int[width]; + int* neba = new int[width]; + int* cera = new int[width]; + int* cega = new int[width]; + int* ceba = new int[width]; + + bzero(nera, width * sizeof(int)); + bzero(nega, width * sizeof(int)); + bzero(neba, width * sizeof(int)); + bzero(cera, width * sizeof(int)); + bzero(cega, width * sizeof(int)); + bzero(ceba, width * sizeof(int)); int r, g, b, er, eg, eb, per, peg, peb; uint8 appr; uint32 x, y; rgb_color a; - for (y = uint32 (place.top); y < uint32 (place.bottom); y++) - { + for (y = uint32(place.top); y < uint32(place.bottom); y++) { x = 0; // Special case: First pixel in a row bgra_pixel s = *(++src); - r = clip8 (RED (s) + cera[0]); - g = clip8 (GREEN (s) + cega[0]); - b = clip8 (BLUE (s) + ceba[0]); + r = clip8(RED(s) + cera[0]); + g = clip8(GREEN(s) + cega[0]); + b = clip8(BLUE(s) + ceba[0]); cera[0] = 0; cega[0] = 0; ceba[0] = 0; // Find the nearest match in the palette and write it out - appr = xpal[((r << 7) & 0x7C00)|((g << 2) & 0x03E0)|((b >> 3) & 0x001F)]; + appr = xpal[((r << 7) & 0x7C00) | ((g << 2) & 0x03E0) | ((b >> 3) & 0x001F)]; *(++dest) = appr; // And the corresponding RGB color @@ -1238,35 +1234,34 @@ void FSDither (BBitmap *b32, BBitmap *b8, BRect place) eg = g - a.green; eb = b - a.blue; - per = 7*er/16; - peg = 7*eg/16; - peb = 7*eb/16; + per = 7 * er / 16; + peg = 7 * eg / 16; + peb = 7 * eb / 16; // Put all the remaining error in the pixels down and down-right // (since there is no pixel down-left...) - nera[x] += er/2; - nega[x] += eg/2; - neba[x] += eb/2; - nera[x + 1] += er/16; - nega[x + 1] += eg/16; - neba[x + 1] += eb/16; - - for (x = 1; x < width - 1; x++) - { + nera[x] += er / 2; + nega[x] += eg / 2; + neba[x] += eb / 2; + nera[x + 1] += er / 16; + nega[x + 1] += eg / 16; + neba[x + 1] += eb / 16; + + for (x = 1; x < width - 1; x++) { // Get one source pixel s = *(++src); // Get color components and add errors from previous pixel - r = clip8 (RED (s) + per + cera[x]); - g = clip8 (GREEN (s) + peg + cega[x]); - b = clip8 (BLUE (s) + peb + ceba[x]); + r = clip8(RED(s) + per + cera[x]); + g = clip8(GREEN(s) + peg + cega[x]); + b = clip8(BLUE(s) + peb + ceba[x]); cera[x] = 0; cega[x] = 0; ceba[x] = 0; // Find the nearest match in the palette and write it out - appr = xpal[((r << 7) & 0x7C00)|((g << 2) & 0x03E0)|((b >> 3) & 0x001F)]; + appr = xpal[((r << 7) & 0x7C00) | ((g << 2) & 0x03E0) | ((b >> 3) & 0x001F)]; *(++dest) = appr; // And the corresponding RGB color @@ -1277,34 +1272,34 @@ void FSDither (BBitmap *b32, BBitmap *b8, BRect place) eg = g - a.green; eb = b - a.blue; - per = 7*er/16; - peg = 7*eg/16; - peb = 7*eb/16; - - nera[x - 1] += 3*er/16; - nega[x - 1] += 3*eg/16; - neba[x - 1] += 3*eb/16; - nera[x] += 5*er/16; - nega[x] += 5*eg/16; - neba[x] += 5*eb/16; - nera[x + 1] += er/16; - nega[x + 1] += eg/16; - neba[x + 1] += eb/16; + per = 7 * er / 16; + peg = 7 * eg / 16; + peb = 7 * eb / 16; + + nera[x - 1] += 3 * er / 16; + nega[x - 1] += 3 * eg / 16; + neba[x - 1] += 3 * eb / 16; + nera[x] += 5 * er / 16; + nega[x] += 5 * eg / 16; + neba[x] += 5 * eb / 16; + nera[x + 1] += er / 16; + nega[x + 1] += eg / 16; + neba[x + 1] += eb / 16; } // Special case: Last pixel s = *(++src); // Get color components and add errors from previous pixel - r = clip8 (RED (s) + per + cera[x]); - g = clip8 (GREEN (s) + peg + cega[x]); - b = clip8 (BLUE (s) + peb + ceba[x]); + r = clip8(RED(s) + per + cera[x]); + g = clip8(GREEN(s) + peg + cega[x]); + b = clip8(BLUE(s) + peb + ceba[x]); cera[x] = 0; cega[x] = 0; ceba[x] = 0; // Find the nearest match in the palette and write it out - appr = xpal[((r << 7) & 0x7C00)|((g << 2) & 0x03E0)|((b >> 3) & 0x001F)]; + appr = xpal[((r << 7) & 0x7C00) | ((g << 2) & 0x03E0) | ((b >> 3) & 0x001F)]; *(++dest) = appr; // And the corresponding RGB color @@ -1316,21 +1311,27 @@ void FSDither (BBitmap *b32, BBitmap *b8, BRect place) eb = b - a.blue; // Put all the error in the pixels down and down-left - nera[x - 1] += er/2; - nega[x - 1] += eg/2; - neba[x - 1] += eb/2; - nera[x] += er/2; - nega[x] += eg/2; - neba[x] += eb/2; + nera[x - 1] += er / 2; + nega[x - 1] += eg / 2; + neba[x - 1] += eb / 2; + nera[x] += er / 2; + nega[x] += eg / 2; + neba[x] += eb / 2; // Switch the scratch data - int *tmp; - tmp = cera; cera = nera; nera = tmp; - tmp = cega; cega = nega; nega = tmp; - tmp = ceba; ceba = neba; neba = tmp; + int* tmp; + tmp = cera; + cera = nera; + nera = tmp; + tmp = cega; + cega = nega; + nega = tmp; + tmp = ceba; + ceba = neba; + neba = tmp; dest += ddif; - src += sdif; + src += sdif; } // Special case: Last line // All the error goes into the right pixel. @@ -1338,18 +1339,17 @@ void FSDither (BBitmap *b32, BBitmap *b8, BRect place) eg = 0; eb = 0; - for (x = 0; x < width - 1; x++) - { + for (x = 0; x < width - 1; x++) { // Get one source pixel bgra_pixel s = *(++src); // Get color components and add errors from previous pixel - r = clip8 (RED (s) + er + cera[x]); - g = clip8 (GREEN (s) + eg + cega[x]); - b = clip8 (BLUE (s) + eb + ceba[x]); + r = clip8(RED(s) + er + cera[x]); + g = clip8(GREEN(s) + eg + cega[x]); + b = clip8(BLUE(s) + eb + ceba[x]); // Find the nearest match in the palette and write it out - appr = xpal[((r << 7) & 0x7C00)|((g << 2) & 0x03E0)|((b >> 3) & 0x001F)]; + appr = xpal[((r << 7) & 0x7C00) | ((g << 2) & 0x03E0) | ((b >> 3) & 0x001F)]; *(++dest) = appr; // And the corresponding RGB color @@ -1363,95 +1363,92 @@ void FSDither (BBitmap *b32, BBitmap *b8, BRect place) // Last but not least, the bottom right pixel. bgra_pixel s = *(++src); - r = clip8 (RED (s) + er + cera[x]); - g = clip8 (GREEN (s) + eg + cega[x]); - b = clip8 (BLUE (s) + eb + ceba[x]); + r = clip8(RED(s) + er + cera[x]); + g = clip8(GREEN(s) + eg + cega[x]); + b = clip8(BLUE(s) + eb + ceba[x]); - *(++dest) = xpal[((r << 7) & 0x7C00)|((g << 2) & 0x03E0)|((b >> 3) & 0x001F)]; + *(++dest) = xpal[((r << 7) & 0x7C00) | ((g << 2) & 0x03E0) | ((b >> 3) & 0x001F)]; - delete [] nera; - delete [] nega; - delete [] neba; - delete [] cera; - delete [] cega; - delete [] ceba; + delete[] nera; + delete[] nega; + delete[] neba; + delete[] cera; + delete[] cega; + delete[] ceba; } #else -void FSDither (BBitmap *b32, BBitmap *b8, BRect place) +void +FSDither(BBitmap* b32, BBitmap* b8, BRect place) { -// b32 32bit bitmap -// b8 8bit bitmap -// place The rect of the b8 bitmap into which b32 must be dithered. - -/* - * Does a floyd alike dithering to a BBitmap - * - * in_data = input data in BGRA format - * in_width = width of the picture (== bytes per row!) - * in_height = height of the picture - * dest_bitmap = pointer to a BBitmap with COLOR_8_BIT colorspace - * Make sure that the BBitmap is big enough... - * - * corrections are done this way: - * - * +-----+-----+- - - * | | 0.5 | - * +-----+-----+- - - * | 0.5 | 0.0 | - * +-----+-----+- - - * | | | - * - * This allows to use only shifting and avoiding real divisions. - * You will note a slight diagonal dithering, but this is no - * real disadvantage. - * - */ - ulong in_width = place.Width() + 1; - ulong in_height = place.Height() + 1; - uint32 *in_data = (uint32 *) b32->Bits() - + ulong (place.top)*b32->BytesPerRow()/4 - + ulong (place.left) - 1; - char *delta = new char[(in_width)*2*4]; - uchar *dstb = (uchar *) b8->Bits() - + ulong (place.left) - 1; - uchar *xpal = (uchar *) system_colors()->index_map; - ulong *cpal = (ulong *) system_colors()->color_list; - char *fcwrite = delta + in_width; - char *cread = delta - 1; - char *cwrite = fcwrite - 1; - ulong xmod = b8->BytesPerRow(); - ulong smod = b32->BytesPerRow()/4 - in_width; - long switcher = 0; - - bzero (delta, in_width*2*4); - - for (int y = place.top; y <= int (place.bottom); y++) - { - long rdlast = 0; - long gdlast = 0; - long bdlast = 0; - uchar *dst = dstb + y*xmod; - - for (int x = place.left; x <= int (place.right); x++) - { + // b32 32bit bitmap + // b8 8bit bitmap + // place The rect of the b8 bitmap into which b32 must be dithered. + + /* + * Does a floyd alike dithering to a BBitmap + * + * in_data = input data in BGRA format + * in_width = width of the picture (== bytes per row!) + * in_height = height of the picture + * dest_bitmap = pointer to a BBitmap with COLOR_8_BIT colorspace + * Make sure that the BBitmap is big enough... + * + * corrections are done this way: + * + * +-----+-----+- - + * | | 0.5 | + * +-----+-----+- - + * | 0.5 | 0.0 | + * +-----+-----+- - + * | | | + * + * This allows to use only shifting and avoiding real divisions. + * You will note a slight diagonal dithering, but this is no + * real disadvantage. + * + */ + ulong in_width = place.Width() + 1; + ulong in_height = place.Height() + 1; + uint32* in_data = + (uint32*)b32->Bits() + ulong(place.top) * b32->BytesPerRow() / 4 + ulong(place.left) - 1; + char* delta = new char[(in_width) * 2 * 4]; + uchar* dstb = (uchar*)b8->Bits() + ulong(place.left) - 1; + uchar* xpal = (uchar*)system_colors()->index_map; + ulong* cpal = (ulong*)system_colors()->color_list; + char* fcwrite = delta + in_width; + char* cread = delta - 1; + char* cwrite = fcwrite - 1; + ulong xmod = b8->BytesPerRow(); + ulong smod = b32->BytesPerRow() / 4 - in_width; + long switcher = 0; + + bzero(delta, in_width * 2 * 4); + + for (int y = place.top; y <= int(place.bottom); y++) { + long rdlast = 0; + long gdlast = 0; + long bdlast = 0; + uchar* dst = dstb + y * xmod; + + for (int x = place.left; x <= int(place.right); x++) { // get 1 pixel from the input buffer - ulong p = *(++in_data); + ulong p = *(++in_data); // add corrections from previous pixels. - ulong cread_data = *(++cread); + ulong cread_data = *(++cread); -#if defined (__POWERPC__) - long b = (p>>24) + ((*(++cread) + bdlast)/2); - long g = ((p>>16)&0xFF) + ((*(++cread) + gdlast)/2); - long r = ((p>> 8)&0xFF) + ((*(++cread) + rdlast)/2); +#if defined(__POWERPC__) + long b = (p >> 24) + ((*(++cread) + bdlast) / 2); + long g = ((p >> 16) & 0xFF) + ((*(++cread) + gdlast) / 2); + long r = ((p >> 8) & 0xFF) + ((*(++cread) + rdlast) / 2); #else - long b = (p & 0xFF) + ((*(++cread) + bdlast)/2); - long g = ((p>> 8)&0xFF) + ((*(++cread) + gdlast)/2); - long r = ((p>>16)&0xFF) + ((*(++cread) + rdlast)/2); + long b = (p & 0xFF) + ((*(++cread) + bdlast) / 2); + long g = ((p >> 8) & 0xFF) + ((*(++cread) + gdlast) / 2); + long r = ((p >> 16) & 0xFF) + ((*(++cread) + rdlast) / 2); #endif // fix high and low values @@ -1461,8 +1458,8 @@ void FSDither (BBitmap *b32, BBitmap *b8, BRect place) b = b > 255 ? 255 : (b < 0 ? 0 : b); // lets see which color we get from the BeOS palette. - uchar q = xpal[((r<<7)&0x7C00)|((g<<2)&0x03E0)|((b>>3)&0x001F)]; - ulong s = cpal[q]; + uchar q = xpal[((r << 7) & 0x7C00) | ((g << 2) & 0x03E0) | ((b >> 3) & 0x001F)]; + ulong s = cpal[q]; // output the pixel @@ -1470,51 +1467,51 @@ void FSDither (BBitmap *b32, BBitmap *b8, BRect place) // save the differences to the requested color -#if defined (__POWERPC__) - *(++cwrite) = rdlast = r - (s>>24); - *(++cwrite) = gdlast = g - ((s>>16)&0xFF); - *(++cwrite) = bdlast = b - ((s>> 8)&0xFF); +#if defined(__POWERPC__) + *(++cwrite) = rdlast = r - (s >> 24); + *(++cwrite) = gdlast = g - ((s >> 16) & 0xFF); + *(++cwrite) = bdlast = b - ((s >> 8) & 0xFF); #else - *(++cwrite) = rdlast = r - ((s>>16)&0xFF); - *(++cwrite) = gdlast = g - ((s>> 8)&0xFF); - *(++cwrite) = bdlast = b - (s &0xFF); + *(++cwrite) = rdlast = r - ((s >> 16) & 0xFF); + *(++cwrite) = gdlast = g - ((s >> 8) & 0xFF); + *(++cwrite) = bdlast = b - (s & 0xFF); #endif } - if (switcher) - { - cwrite = delta - 1; - cread = fcwrite - 1; + if (switcher) { + cwrite = delta - 1; + cread = fcwrite - 1; switcher = 0; - } - else - { - cread = delta - 1; - cwrite = fcwrite - 1; + } else { + cread = delta - 1; + cwrite = fcwrite - 1; switcher = 1; } in_data += smod; } - delete [] delta; + delete[] delta; } #endif -int32 gcd (int32 p, int32 q) +int32 +gcd(int32 p, int32 q) { int32 r; - while (r = p % q, r) - { + while (r = p % q, r) { p = q; q = r; } return q; } -extern "C" void mmx_scale_32_h (bgra_pixel *s, bgra_pixel *d, int32 h, int32 sw, int32 dw, int32 dbpr); -extern "C" void mmx_scale_32_v (bgra_pixel *s, bgra_pixel *d, int32 w, int32 sh, int32 dh, int32 dbpr); +extern "C" void +mmx_scale_32_h(bgra_pixel* s, bgra_pixel* d, int32 h, int32 sw, int32 dw, int32 dbpr); +extern "C" void +mmx_scale_32_v(bgra_pixel* s, bgra_pixel* d, int32 w, int32 sh, int32 dh, int32 dbpr); -int Scale (BBitmap *src, BBitmap *srcmap, BBitmap *dest, BBitmap *destmap) +int +Scale(BBitmap* src, BBitmap* srcmap, BBitmap* dest, BBitmap* destmap) // Note: Scale doesn't treat the alpha channel any different from R, G, and B. // Therefore, it doesn't need to be modified for LE vs BE issues, only the // nomenclature of the channels is correct on PPC @@ -1534,97 +1531,88 @@ int Scale (BBitmap *src, BBitmap *srcmap, BBitmap *dest, BBitmap *destmap) int sh = srcRect.IntegerHeight() + 1; int dw = destRect.IntegerWidth() + 1; int dh = destRect.IntegerHeight() + 1; - int nbx = gcd (dw, sw); - int nby = gcd (dh, sh); - int mdx = dw/nbx; - int mdy = dh/nby; - int msx = sw/nbx; - int msy = sh/nby; - - BRect horiRect = srcRect; - double xscale = (destRect.Width() + 1)/(srcRect.Width() + 1); - double yscale = (destRect.Height() + 1)/(srcRect.Height() + 1); + int nbx = gcd(dw, sw); + int nby = gcd(dh, sh); + int mdx = dw / nbx; + int mdy = dh / nby; + int msx = sw / nbx; + int msy = sh / nby; + + BRect horiRect = srcRect; + double xscale = (destRect.Width() + 1) / (srcRect.Width() + 1); + double yscale = (destRect.Height() + 1) / (srcRect.Height() + 1); horiRect.right = destRect.right; - BBitmap *stmp = new BBitmap (horiRect, B_RGBA32); - BBitmap *mtmp = new BBitmap (horiRect, B_COLOR_8_BIT); - //printf ("xscale = %f\n", xscale); - float f = float (mdx)/msx; + BBitmap* stmp = new BBitmap(horiRect, B_RGBA32); + BBitmap* mtmp = new BBitmap(horiRect, B_COLOR_8_BIT); + // printf ("xscale = %f\n", xscale); + float f = float(mdx) / msx; extern bool UseMMX; extern int DebugLevel; - if (xscale < 1) // Shrink horizontally + if (xscale < 1) // Shrink horizontally { - //printf ("Shrink horizontally:\n"); - if (src) // Code for the Layer + // printf ("Shrink horizontally:\n"); + if (src) // Code for the Layer { if (DebugLevel) - printf ("Scaling %d -> %d; gcd = %d\n", sw, dw, nbx); + printf("Scaling %d -> %d; gcd = %d\n", sw, dw, nbx); time_t start = clock(); - if (UseMMX && sw <= 1024) // otherwise, fixed point arithmetic in MMX code will overflow. + if (UseMMX && + sw <= 1024) // otherwise, fixed point arithmetic in MMX code will overflow. { -#if defined (__INTEL__) - mmx_scale_32_h ((bgra_pixel *) src->Bits(), (bgra_pixel *) stmp->Bits(), sh, sw, dw, stmp->BytesPerRow()); +#if defined(__INTEL__) + mmx_scale_32_h( + (bgra_pixel*)src->Bits(), (bgra_pixel*)stmp->Bits(), sh, sw, dw, + stmp->BytesPerRow() + ); #endif - } - else - { - //printf ("Layer...\n"); - bgra_pixel *srcdata = (bgra_pixel *) src->Bits(); - bgra_pixel *destdata = (bgra_pixel *) stmp->Bits(); - int32 slpr = src->BytesPerRow()/4; - int32 dlpr = stmp->BytesPerRow()/4; - for (int y = 0; y < sh; y++) - { - bgra_pixel *srcline = srcdata + y*slpr; - bgra_pixel *destline = destdata + y*dlpr; - for (int nb = 0; nb < nbx; nb++) - { + } else { + // printf ("Layer...\n"); + bgra_pixel* srcdata = (bgra_pixel*)src->Bits(); + bgra_pixel* destdata = (bgra_pixel*)stmp->Bits(); + int32 slpr = src->BytesPerRow() / 4; + int32 dlpr = stmp->BytesPerRow() / 4; + for (int y = 0; y < sh; y++) { + bgra_pixel* srcline = srcdata + y * slpr; + bgra_pixel* destline = destdata + y * dlpr; + for (int nb = 0; nb < nbx; nb++) { int s = 1; int d = 1; bool stillinblock = true; float r = 0, g = 0, b = 0, a = 0; - while (stillinblock) - { - while (s*mdx < d*msx) - { + while (stillinblock) { + while (s * mdx < d * msx) { bgra_pixel pixel = *srcline++; s++; - r += ((pixel & 0x0000FF00) >> 8)*f; - g += ((pixel & 0x00FF0000) >> 16)*f; - b += (pixel >> 24)*f; - a += (pixel & 0x000000FF)*f; + r += ((pixel & 0x0000FF00) >> 8) * f; + g += ((pixel & 0x00FF0000) >> 16) * f; + b += (pixel >> 24) * f; + a += (pixel & 0x000000FF) * f; } - if (s*mdx != d*msx) - { - float beta = s*f - d; + if (s * mdx != d * msx) { + float beta = s * f - d; float alpha = f - beta; d++; s++; bgra_pixel pixel = *srcline; - r += ((pixel & 0x0000FF00) >> 8)*alpha; - g += ((pixel & 0x00FF0000) >> 16)*alpha; - b += (pixel >> 24)*alpha; - a += (pixel & 0x000000FF)*alpha; - *(destline++) = (uint8 (b) << 24) - + (uint8 (g) << 16) - + (uint8 (r) << 8) - + (uint8 (a)); - r = ((pixel & 0x0000FF00) >> 8)*beta; - g = ((pixel & 0x00FF0000) >> 16)*beta; - b = (pixel >> 24)*beta; - a = (pixel & 0x000000FF)*beta; + r += ((pixel & 0x0000FF00) >> 8) * alpha; + g += ((pixel & 0x00FF0000) >> 16) * alpha; + b += (pixel >> 24) * alpha; + a += (pixel & 0x000000FF) * alpha; + *(destline++) = (uint8(b) << 24) + (uint8(g) << 16) + + (uint8(r) << 8) + (uint8(a)); + r = ((pixel & 0x0000FF00) >> 8) * beta; + g = ((pixel & 0x00FF0000) >> 16) * beta; + b = (pixel >> 24) * beta; + a = (pixel & 0x000000FF) * beta; srcline++; - } - else - { + } else { bgra_pixel pixel = *(srcline++); - r += ((pixel & 0x0000FF00) >> 8)*f; - g += ((pixel & 0x00FF0000) >> 16)*f; - b += (pixel >> 24)*f; - a += (pixel & 0x000000FF)*f; - *(destline++) = (uint8 (b) << 24) - + (uint8 (g) << 16) - + (uint8 (r) << 8) - + (uint8 (a)); + r += ((pixel & 0x0000FF00) >> 8) * f; + g += ((pixel & 0x00FF0000) >> 16) * f; + b += (pixel >> 24) * f; + a += (pixel & 0x000000FF) * f; + *(destline++) = (uint8(b) << 24) + (uint8(g) << 16) + + (uint8(r) << 8) + (uint8(a)); stillinblock = false; } } @@ -1634,113 +1622,96 @@ int Scale (BBitmap *src, BBitmap *srcmap, BBitmap *dest, BBitmap *destmap) time_t end = clock(); extern int DebugLevel; if (DebugLevel > 1) - printf ("H Scale took %ld ms\n", end - start); + printf("H Scale took %ld ms\n", end - start); } - if (srcmap) // Code for Selection + if (srcmap) // Code for Selection { - //printf ("Selection...\n"); - grey_pixel *srcdata = (grey_pixel *) srcmap->Bits(); - grey_pixel *destdata = (grey_pixel *) mtmp->Bits(); + // printf ("Selection...\n"); + grey_pixel* srcdata = (grey_pixel*)srcmap->Bits(); + grey_pixel* destdata = (grey_pixel*)mtmp->Bits(); int32 sbpr = srcmap->BytesPerRow(); int32 dbpr = mtmp->BytesPerRow(); - for (int y = 0; y < sh; y++) - { - grey_pixel *srcline = srcdata + y*sbpr; - grey_pixel *destline = destdata + y*dbpr; - for (int nb = 0; nb < nbx; nb++) - { + for (int y = 0; y < sh; y++) { + grey_pixel* srcline = srcdata + y * sbpr; + grey_pixel* destline = destdata + y * dbpr; + for (int nb = 0; nb < nbx; nb++) { int s = 1; int d = 1; bool stillinblock = true; float r = 0; - while (stillinblock) - { - while (s*mdx < d*msx) - { - r += (*srcline++)*f; + while (stillinblock) { + while (s * mdx < d * msx) { + r += (*srcline++) * f; s++; } - if (s*mdx != d*msx) - { - float beta = s*f - d; + if (s * mdx != d * msx) { + float beta = s * f - d; float alpha = f - beta; - r += alpha* *(srcline); - *(destline++) = grey_pixel (r); + r += alpha * *(srcline); + *(destline++) = grey_pixel(r); d++; - r = beta* *(srcline++); + r = beta * *(srcline++); s++; - } - else - { - r += *(srcline++)*f; - *(destline++) = uint8 (r); + } else { + r += *(srcline++) * f; + *(destline++) = uint8(r); stillinblock = false; } } } } } - } - else if (xscale > 1) // Stretch horizontally + } else if (xscale > 1) // Stretch horizontally { - //printf ("Stretch horizontally\n"); - if (src) // Code for Layer + // printf ("Stretch horizontally\n"); + if (src) // Code for Layer { if (DebugLevel) - printf ("Scaling %d -> %d; gcd = %d\n", sw, dw, nbx); + printf("Scaling %d -> %d; gcd = %d\n", sw, dw, nbx); time_t start = clock(); - if (UseMMX) - { -#if defined (__INTEL__) - mmx_scale_32_h ((bgra_pixel *) src->Bits(), (bgra_pixel *) stmp->Bits(), sh, sw, dw, stmp->BytesPerRow()); + if (UseMMX) { +#if defined(__INTEL__) + mmx_scale_32_h( + (bgra_pixel*)src->Bits(), (bgra_pixel*)stmp->Bits(), sh, sw, dw, + stmp->BytesPerRow() + ); #endif - } - else - { - //printf ("Layer...\n"); - bgra_pixel *srcdata = (bgra_pixel *) src->Bits(); - bgra_pixel *destdata = (bgra_pixel *) stmp->Bits(); - int32 slpr = src->BytesPerRow()/4; - int32 dlpr = stmp->BytesPerRow()/4; - for (int y = 0; y < sh; y++) - { - bgra_pixel *srcline = srcdata + y*slpr; - bgra_pixel *destline = destdata + y*dlpr; - for (int nb = 0; nb < nbx; nb++) - { + } else { + // printf ("Layer...\n"); + bgra_pixel* srcdata = (bgra_pixel*)src->Bits(); + bgra_pixel* destdata = (bgra_pixel*)stmp->Bits(); + int32 slpr = src->BytesPerRow() / 4; + int32 dlpr = stmp->BytesPerRow() / 4; + for (int y = 0; y < sh; y++) { + bgra_pixel* srcline = srcdata + y * slpr; + bgra_pixel* destline = destdata + y * dlpr; + for (int nb = 0; nb < nbx; nb++) { float s = 1; float d = 1; bool stillinblock = true; - while (stillinblock) - { - while (d*msx < s*mdx) - { + while (stillinblock) { + while (d * msx < s * mdx) { *(destline++) = *srcline; d++; } - if (d*msx != s*mdx) - { - float beta = d/f - s; + if (d * msx != s * mdx) { + float beta = d / f - s; float alpha = 1 - beta; bgra_pixel pixela = *srcline; bgra_pixel pixelb = *(++srcline); s++; - float r = ((pixela & 0x0000FF00) >> 8)*alpha; - float g = ((pixela & 0x00FF0000) >> 16)*alpha; - float b = (pixela >> 24)*alpha; - float a = (pixela & 0x000000FF)*alpha; - r += ((pixelb & 0x0000FF00) >> 8)*beta; - g += ((pixelb & 0x00FF0000) >> 16)*beta; - b += (pixelb >> 24)*beta; - a += (pixelb & 0x000000FF)*beta; - *(destline++) = (uint8 (b) << 24) - + (uint8 (g) << 16) - + (uint8 (r) << 8) - + (uint8 (a)); + float r = ((pixela & 0x0000FF00) >> 8) * alpha; + float g = ((pixela & 0x00FF0000) >> 16) * alpha; + float b = (pixela >> 24) * alpha; + float a = (pixela & 0x000000FF) * alpha; + r += ((pixelb & 0x0000FF00) >> 8) * beta; + g += ((pixelb & 0x00FF0000) >> 16) * beta; + b += (pixelb >> 24) * beta; + a += (pixelb & 0x000000FF) * beta; + *(destline++) = (uint8(b) << 24) + (uint8(g) << 16) + + (uint8(r) << 8) + (uint8(a)); d++; - } - else - { + } else { *(destline++) = *(srcline++); stillinblock = false; } @@ -1751,42 +1722,35 @@ int Scale (BBitmap *src, BBitmap *srcmap, BBitmap *dest, BBitmap *destmap) time_t end = clock(); extern int DebugLevel; if (DebugLevel > 1) - printf ("H Scale took %ld ms\n", end - start); + printf("H Scale took %ld ms\n", end - start); } - if (srcmap) // Code for selection + if (srcmap) // Code for selection { - //printf ("Selection\n"); - grey_pixel *srcdata = (grey_pixel *) srcmap->Bits(); - grey_pixel *destdata = (grey_pixel *) mtmp->Bits(); + // printf ("Selection\n"); + grey_pixel* srcdata = (grey_pixel*)srcmap->Bits(); + grey_pixel* destdata = (grey_pixel*)mtmp->Bits(); int32 sbpr = srcmap->BytesPerRow(); int32 dbpr = mtmp->BytesPerRow(); - for (int y = 0; y < sh; y++) - { - grey_pixel *srcline = srcdata + y*sbpr; - grey_pixel *destline = destdata + y*dbpr; - for (int nb = 0; nb < nbx; nb++) - { + for (int y = 0; y < sh; y++) { + grey_pixel* srcline = srcdata + y * sbpr; + grey_pixel* destline = destdata + y * dbpr; + for (int nb = 0; nb < nbx; nb++) { int s = 1; int d = 1; bool stillinblock = true; - while (stillinblock) - { - while (d*msx < s*mdx) - { + while (stillinblock) { + while (d * msx < s * mdx) { *(destline++) = *srcline; d++; } - if (d*msx != s*mdx) - { - float beta = d/f - s; + if (d * msx != s * mdx) { + float beta = d / f - s; float alpha = 1 - beta; - *(destline++) = uchar (alpha* *srcline + beta * *(srcline + 1)); + *(destline++) = uchar(alpha * *srcline + beta * *(srcline + 1)); srcline++; s++; d++; - } - else - { + } else { *(destline++) = *(srcline++); stillinblock = false; } @@ -1794,94 +1758,82 @@ int Scale (BBitmap *src, BBitmap *srcmap, BBitmap *dest, BBitmap *destmap) } } } - } - else // No scaling in x-dimension -> copy to temp bitmap. + } else // No scaling in x-dimension -> copy to temp bitmap. { - //printf ("copying\n"); + // printf ("copying\n"); if (src) - memcpy (stmp->Bits(), src->Bits(), src->BitsLength()); + memcpy(stmp->Bits(), src->Bits(), src->BitsLength()); if (srcmap) - memcpy (mtmp->Bits(), srcmap->Bits(), srcmap->BitsLength()); + memcpy(mtmp->Bits(), srcmap->Bits(), srcmap->BitsLength()); } - //printf ("yscale = %f\n", yscale); - f = float (mdy)/msy; - if (yscale < 1) // Shrink vertically + // printf ("yscale = %f\n", yscale); + f = float(mdy) / msy; + if (yscale < 1) // Shrink vertically { - //printf ("Shrink vertically:\n"); - if (src) // Code for Layer + // printf ("Shrink vertically:\n"); + if (src) // Code for Layer { if (DebugLevel) - printf ("Scaling %d -> %d; gcd = %d\n", sh, dh, nby); + printf("Scaling %d -> %d; gcd = %d\n", sh, dh, nby); time_t start = clock(); - if (UseMMX && sh <= 1024) - { -#if defined (__INTEL__) - mmx_scale_32_v ((bgra_pixel *) stmp->Bits(), (bgra_pixel *) dest->Bits(), dw, sh, dh, dest->BytesPerRow()); + if (UseMMX && sh <= 1024) { +#if defined(__INTEL__) + mmx_scale_32_v( + (bgra_pixel*)stmp->Bits(), (bgra_pixel*)dest->Bits(), dw, sh, dh, + dest->BytesPerRow() + ); #endif - } - else - { - //printf ("Layer...\n"); - bgra_pixel *srcdata = (bgra_pixel *) stmp->Bits(); - bgra_pixel *destdata = (bgra_pixel *) dest->Bits(); - int32 slpr = stmp->BytesPerRow()/4; - int32 dlpr = dest->BytesPerRow()/4; - for (int x = 0; x < dw; x++) - { - bgra_pixel *srccol = srcdata + x; - bgra_pixel *destcol = destdata + x; - for (int nb = 0; nb < nby; nb++) - { + } else { + // printf ("Layer...\n"); + bgra_pixel* srcdata = (bgra_pixel*)stmp->Bits(); + bgra_pixel* destdata = (bgra_pixel*)dest->Bits(); + int32 slpr = stmp->BytesPerRow() / 4; + int32 dlpr = dest->BytesPerRow() / 4; + for (int x = 0; x < dw; x++) { + bgra_pixel* srccol = srcdata + x; + bgra_pixel* destcol = destdata + x; + for (int nb = 0; nb < nby; nb++) { int s = 1; int d = 1; bool stillinblock = true; float r = 0, g = 0, b = 0, a = 0; - while (stillinblock) - { - while (s*mdy < d*msy) - { + while (stillinblock) { + while (s * mdy < d * msy) { bgra_pixel pixel = *srccol; srccol += slpr; s++; - r += ((pixel & 0x0000FF00) >> 8)*f; - g += ((pixel & 0x00FF0000) >> 16)*f; - b += (pixel >> 24)*f; - a += (pixel & 0x000000FF)*f; + r += ((pixel & 0x0000FF00) >> 8) * f; + g += ((pixel & 0x00FF0000) >> 16) * f; + b += (pixel >> 24) * f; + a += (pixel & 0x000000FF) * f; } - if (s*mdy != d*msy) - { - float beta = s*f - d; + if (s * mdy != d * msy) { + float beta = s * f - d; float alpha = f - beta; bgra_pixel pixel = *srccol; - r += ((pixel & 0x0000FF00) >> 8)*alpha; - g += ((pixel & 0x00FF0000) >> 16)*alpha; - b += (pixel >> 24)*alpha; - a += (pixel & 0x000000FF)*alpha; - *destcol = (uint8 (b) << 24) - + (uint8 (g) << 16) - + (uint8 (r) << 8) - + (uint8 (a)); + r += ((pixel & 0x0000FF00) >> 8) * alpha; + g += ((pixel & 0x00FF0000) >> 16) * alpha; + b += (pixel >> 24) * alpha; + a += (pixel & 0x000000FF) * alpha; + *destcol = (uint8(b) << 24) + (uint8(g) << 16) + (uint8(r) << 8) + + (uint8(a)); destcol += dlpr; d++; - r = ((pixel & 0x0000FF00) >> 8)*beta; - g = ((pixel & 0x00FF0000) >> 16)*beta; - b = (pixel >> 24)*beta; - a = (pixel & 0x000000FF)*beta; + r = ((pixel & 0x0000FF00) >> 8) * beta; + g = ((pixel & 0x00FF0000) >> 16) * beta; + b = (pixel >> 24) * beta; + a = (pixel & 0x000000FF) * beta; srccol += slpr; s++; - } - else - { + } else { bgra_pixel pixel = *srccol; srccol += slpr; - r += ((pixel & 0x0000FF00) >> 8)*f; - g += ((pixel & 0x00FF0000) >> 16)*f; - b += (pixel >> 24)*f; - a += (pixel & 0x000000FF)*f; - *destcol = (uint8 (b) << 24) - + (uint8 (g) << 16) - + (uint8 (r) << 8) - + (uint8 (a)); + r += ((pixel & 0x0000FF00) >> 8) * f; + g += ((pixel & 0x00FF0000) >> 16) * f; + b += (pixel >> 24) * f; + a += (pixel & 0x000000FF) * f; + *destcol = (uint8(b) << 24) + (uint8(g) << 16) + (uint8(r) << 8) + + (uint8(a)); destcol += dlpr; stillinblock = false; } @@ -1892,50 +1844,43 @@ int Scale (BBitmap *src, BBitmap *srcmap, BBitmap *dest, BBitmap *destmap) time_t end = clock(); extern int DebugLevel; if (DebugLevel > 1) - printf ("V Scale took %ld ms\n", end - start); + printf("V Scale took %ld ms\n", end - start); } - if (srcmap) // Code for Selection + if (srcmap) // Code for Selection { - //printf ("Selection...\n"); - grey_pixel *srcdata = (grey_pixel *) mtmp->Bits(); - grey_pixel *destdata = (grey_pixel *) destmap->Bits(); + // printf ("Selection...\n"); + grey_pixel* srcdata = (grey_pixel*)mtmp->Bits(); + grey_pixel* destdata = (grey_pixel*)destmap->Bits(); int32 sbpr = mtmp->BytesPerRow(); int32 dbpr = destmap->BytesPerRow(); - for (int x = 0; x < dw; x++) - { - grey_pixel *srccol = srcdata + x; - grey_pixel *destcol = destdata + x; - for (int nb = 0; nb < nby; nb++) - { + for (int x = 0; x < dw; x++) { + grey_pixel* srccol = srcdata + x; + grey_pixel* destcol = destdata + x; + for (int nb = 0; nb < nby; nb++) { int s = 1; int d = 1; bool stillinblock = true; float r = 0; - while (stillinblock) - { - while (s*mdy < d*msy) - { - r += *srccol*f; + while (stillinblock) { + while (s * mdy < d * msy) { + r += *srccol * f; srccol += sbpr; s++; } - if (s*mdy != d*msy) - { - float beta = s*f - d; + if (s * mdy != d * msy) { + float beta = s * f - d; float alpha = f - beta; - r += alpha* *srccol; - *destcol = grey_pixel (r); + r += alpha * *srccol; + *destcol = grey_pixel(r); destcol += dbpr; d++; - r = beta* *srccol; + r = beta * *srccol; srccol += sbpr; s++; - } - else - { - r += (*srccol)*f; + } else { + r += (*srccol) * f; srccol += sbpr; - *destcol = uchar (r); + *destcol = uchar(r); destcol += dbpr; stillinblock = false; } @@ -1943,73 +1888,63 @@ int Scale (BBitmap *src, BBitmap *srcmap, BBitmap *dest, BBitmap *destmap) } } } - } - else if (yscale > 1) // Stretch vertically + } else if (yscale > 1) // Stretch vertically { - //printf ("Stretch vertically:\n"); - if (src) // Code for Layer + // printf ("Stretch vertically:\n"); + if (src) // Code for Layer { if (DebugLevel) - printf ("Scaling %d -> %d; gcd = %d\n", sh, dh, nby); + printf("Scaling %d -> %d; gcd = %d\n", sh, dh, nby); time_t start = clock(); - if (UseMMX) - { -#if defined (__INTEL__) - mmx_scale_32_v ((bgra_pixel *) stmp->Bits(), (bgra_pixel *) dest->Bits(), dw, sh, dh, dest->BytesPerRow()); + if (UseMMX) { +#if defined(__INTEL__) + mmx_scale_32_v( + (bgra_pixel*)stmp->Bits(), (bgra_pixel*)dest->Bits(), dw, sh, dh, + dest->BytesPerRow() + ); #endif - } - else - { - //printf ("Layer...\n"); - bgra_pixel *srcdata = (bgra_pixel *) stmp->Bits(); - bgra_pixel *destdata = (bgra_pixel *) dest->Bits(); - int32 slpr = stmp->BytesPerRow()/4; - int32 dlpr = dest->BytesPerRow()/4; - for (int x = 0; x < dw; x++) - { - bgra_pixel *srccol = srcdata + x; - bgra_pixel *destcol = destdata + x; - for (int nb = 0; nb < nby; nb++) - { + } else { + // printf ("Layer...\n"); + bgra_pixel* srcdata = (bgra_pixel*)stmp->Bits(); + bgra_pixel* destdata = (bgra_pixel*)dest->Bits(); + int32 slpr = stmp->BytesPerRow() / 4; + int32 dlpr = dest->BytesPerRow() / 4; + for (int x = 0; x < dw; x++) { + bgra_pixel* srccol = srcdata + x; + bgra_pixel* destcol = destdata + x; + for (int nb = 0; nb < nby; nb++) { int s = 1; int d = 1; bool stillinblock = true; - while (stillinblock) - { - while (d*msy < s*mdy) - { + while (stillinblock) { + while (d * msy < s * mdy) { *destcol = *srccol; destcol += dlpr; - d++; + d++; } - if (d*msy != s*mdy) - { - float beta = d/f - s; + if (d * msy != s * mdy) { + float beta = d / f - s; float alpha = 1 - beta; bgra_pixel pixela = *srccol; bgra_pixel pixelb = *(srccol + slpr); srccol += slpr; s++; - float r = ((pixela & 0x0000FF00) >> 8)*alpha; - float g = ((pixela & 0x00FF0000) >> 16)*alpha; - float b = (pixela >> 24)*alpha; - float a = (pixela & 0x000000FF)*alpha; - r += ((pixelb & 0x0000FF00) >> 8)*beta; - g += ((pixelb & 0x00FF0000) >> 16)*beta; - b += (pixelb >> 24)*beta; - a += (pixelb & 0x000000FF)*beta; - *destcol = (uint8 (b) << 24) - + (uint8 (g) << 16) - + (uint8 (r) << 8) - + (uint8 (a)); + float r = ((pixela & 0x0000FF00) >> 8) * alpha; + float g = ((pixela & 0x00FF0000) >> 16) * alpha; + float b = (pixela >> 24) * alpha; + float a = (pixela & 0x000000FF) * alpha; + r += ((pixelb & 0x0000FF00) >> 8) * beta; + g += ((pixelb & 0x00FF0000) >> 16) * beta; + b += (pixelb >> 24) * beta; + a += (pixelb & 0x000000FF) * beta; + *destcol = (uint8(b) << 24) + (uint8(g) << 16) + (uint8(r) << 8) + + (uint8(a)); destcol += dlpr; d++; - } - else - { + } else { *destcol = *srccol; destcol += dlpr; - srccol += slpr; + srccol += slpr; stillinblock = false; } } @@ -2019,212 +1954,184 @@ int Scale (BBitmap *src, BBitmap *srcmap, BBitmap *dest, BBitmap *destmap) time_t end = clock(); extern int DebugLevel; if (DebugLevel > 1) - printf ("V Scale took %ld ms\n", end - start); + printf("V Scale took %ld ms\n", end - start); } - if (srcmap) // Code for Selection + if (srcmap) // Code for Selection { - //printf ("Selection...\n"); - grey_pixel *srcdata = (grey_pixel *) mtmp->Bits(); - grey_pixel *destdata = (grey_pixel *) destmap->Bits(); + // printf ("Selection...\n"); + grey_pixel* srcdata = (grey_pixel*)mtmp->Bits(); + grey_pixel* destdata = (grey_pixel*)destmap->Bits(); int32 sbpr = mtmp->BytesPerRow(); int32 dbpr = destmap->BytesPerRow(); - for (int x = 0; x < dw; x++) - { - grey_pixel *srccol = srcdata + x; - grey_pixel *destcol = destdata + x; - for (int nb = 0; nb < nby; nb++) - { + for (int x = 0; x < dw; x++) { + grey_pixel* srccol = srcdata + x; + grey_pixel* destcol = destdata + x; + for (int nb = 0; nb < nby; nb++) { int s = 1; int d = 1; bool stillinblock = true; - while (stillinblock) - { - while (d*msy < s*mdy) - { + while (stillinblock) { + while (d * msy < s * mdy) { *destcol = *srccol; destcol += dbpr; d++; } - if (d*msy != s*mdy) - { - float beta = d/f - s; + if (d * msy != s * mdy) { + float beta = d / f - s; float alpha = 1 - beta; - *destcol = uchar (alpha* *srccol + beta* *(srccol + sbpr)); + *destcol = uchar(alpha * *srccol + beta * *(srccol + sbpr)); destcol += dbpr; d++; srccol += sbpr; s++; - } - else - { + } else { *destcol = *srccol; destcol += dbpr; - srccol += sbpr; + srccol += sbpr; stillinblock = false; } } } } } - } - else // No scaling in y-dimension -> Just copy the bitmap to dest. + } else // No scaling in y-dimension -> Just copy the bitmap to dest. { - //printf ("Copying...\n"); + // printf ("Copying...\n"); if (src) - memcpy (dest->Bits(), stmp->Bits(), stmp->BitsLength()); + memcpy(dest->Bits(), stmp->Bits(), stmp->BitsLength()); if (srcmap) - memcpy (destmap->Bits(), mtmp->Bits(), mtmp->BitsLength()); + memcpy(destmap->Bits(), mtmp->Bits(), mtmp->BitsLength()); } delete mtmp; delete stmp; return 0; } - -void Rotate (SBitmap *s, Layer *d, BPoint o, float rad, bool hiq) +void +Rotate(SBitmap* s, Layer* d, BPoint o, float rad, bool hiq) { - float sr = sin (rad); - float cr = cos (rad); + float sr = sin(rad); + float cr = cos(rad); float ix, iy; float bw, bh; - uint32 bpr = s->BytesPerRow()/4; + uint32 bpr = s->BytesPerRow() / 4; bw = s->Bounds().right; bh = s->Bounds().bottom; - bgra_pixel *dp = (bgra_pixel *) d->Bits() - 1; - bgra_pixel *sp = (bgra_pixel *) s->Bits(); + bgra_pixel* dp = (bgra_pixel*)d->Bits() - 1; + bgra_pixel* sp = (bgra_pixel*)s->Bits(); float ox, oy; - ox = o.y*sr + o.x*(1 - cr); - oy = o.y*(1 - cr) - o.x*sr; - if (hiq && rad != 0) // do anti-aliasing + ox = o.y * sr + o.x * (1 - cr); + oy = o.y * (1 - cr) - o.x * sr; + if (hiq && rad != 0) // do anti-aliasing { - for (int i = 0; i <= bh; i++) - { - ix = ox - i*sr; - iy = oy + i*cr; - bgra_pixel *dl = dp + i*bpr; - for (int j = 0; j <= bw; j++) - { - int iix = int (ix); - int iiy = int (iy); - float fix = (float) iix; - float fiy = (float) iiy; + for (int i = 0; i <= bh; i++) { + ix = ox - i * sr; + iy = oy + i * cr; + bgra_pixel* dl = dp + i * bpr; + for (int j = 0; j <= bw; j++) { + int iix = int(ix); + int iiy = int(iy); + float fix = (float)iix; + float fiy = (float)iiy; bgra_pixel a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0, a7 = 0, a8 = 0, a9 = 0; if (iix >= 0 && iix <= bw && iiy >= 0 && iiy <= bh) - a5 = *(sp + iiy*bpr + iix); + a5 = *(sp + iiy * bpr + iix); - float A1 = 0, A2 = 0, A3 = 0, A4 = 0, A5 = 0, A6 = 0, A7 = 0, A8 = 0, A9 = 0; // Areas + float A1 = 0, A2 = 0, A3 = 0, A4 = 0, A5 = 0, A6 = 0, A7 = 0, A8 = 0, + A9 = 0; // Areas float w, h; w = ix - (fix + .5); h = iy - (fiy + .5); -// float r = sqrt (w*w + h*h); + // float r = sqrt (w*w + h*h); - if (w < 0 && h < 0) // TLC + if (w < 0 && h < 0) // TLC { if (iix - 1 >= 0 && iix - 1 <= bw && iiy - 1 >= 0 && iiy - 1 <= bh) - a1 = *(sp + (iiy - 1)*bpr + iix - 1); + a1 = *(sp + (iiy - 1) * bpr + iix - 1); if (iix >= 0 && iix <= bw && iiy - 1 >= 0 && iiy - 1 <= bh) - a2 = *(sp + (iiy - 1)*bpr + iix); + a2 = *(sp + (iiy - 1) * bpr + iix); if (iix - 1 >= 0 && iix - 1 <= bw && iiy >= 0 && iiy <= bh) - a4 = *(sp + iiy*bpr + iix - 1); - A1 = w*h*ALPHA(a1); - A2 = (-h - A1/256)*ALPHA(a2); - A4 = (-w - A1/256)*ALPHA(a3); + a4 = *(sp + iiy * bpr + iix - 1); + A1 = w * h * ALPHA(a1); + A2 = (-h - A1 / 256) * ALPHA(a2); + A4 = (-w - A1 / 256) * ALPHA(a3); A5 = ALPHA(a5) - A1 - A2 - A4; - } - else if (w > 0 && h < 0) // TRC + } else if (w > 0 && h < 0) // TRC { if (iix >= 0 && iix <= bw && iiy - 1 >= 0 && iiy - 1 <= bh) - a2 = *(sp + (iiy - 1)*bpr + iix); + a2 = *(sp + (iiy - 1) * bpr + iix); if (iix + 1 >= 0 && iix + 1 <= bw && iiy - 1 >= 0 && iiy - 1 <= bh) - a3 = *(sp + (iiy - 1)*bpr + iix + 1); + a3 = *(sp + (iiy - 1) * bpr + iix + 1); if (iix + 1 >= 0 && iix + 1 <= bw && iiy >= 0 && iiy <= bh) - a6 = *(sp + iiy*bpr + iix + 1); - A3 = -w*h*ALPHA(a3); - A2 = (-h - A3/256)*ALPHA(a2); - A6 = (w - A3/256)*ALPHA(a6); + a6 = *(sp + iiy * bpr + iix + 1); + A3 = -w * h * ALPHA(a3); + A2 = (-h - A3 / 256) * ALPHA(a2); + A6 = (w - A3 / 256) * ALPHA(a6); A5 = ALPHA(a5) - A3 - A2 - A6; - } - else if (w < 0 && h > 0) // BLC + } else if (w < 0 && h > 0) // BLC { if (iix - 1 >= 0 && iix - 1 <= bw && iiy >= 0 && iiy <= bh) - a4 = *(sp + iiy*bpr + iix - 1); + a4 = *(sp + iiy * bpr + iix - 1); if (iix - 1 >= 0 && iix - 1 <= bw && iiy + 1 >= 0 && iiy + 1 <= bh) - a7 = *(sp + (iiy + 1)*bpr + iix - 1); + a7 = *(sp + (iiy + 1) * bpr + iix - 1); if (iix >= 0 && iix <= bw && iiy + 1 >= 0 && iiy + 1 <= bh) - a8 = *(sp + (iiy + 1)*bpr + iix); - A7 = -w*h*ALPHA(a7); - A4 = (-w - A7/256)*ALPHA(a4); - A8 = (h - A7/256)*ALPHA(a8); + a8 = *(sp + (iiy + 1) * bpr + iix); + A7 = -w * h * ALPHA(a7); + A4 = (-w - A7 / 256) * ALPHA(a4); + A8 = (h - A7 / 256) * ALPHA(a8); A5 = ALPHA(a5) - A7 - A4 - A8; - } - else if (w > 0 && h > 0) // BRC + } else if (w > 0 && h > 0) // BRC { if (iix + 1 >= 0 && iix + 1 <= bw && iiy >= 0 && iiy <= bh) - a6 = *(sp + iiy*bpr + iix + 1); + a6 = *(sp + iiy * bpr + iix + 1); if (iix >= 0 && iix <= bw && iiy + 1 >= 0 && iiy + 1 <= bh) - a8 = *(sp + (iiy + 1)*bpr + iix); + a8 = *(sp + (iiy + 1) * bpr + iix); if (iix + 1 >= 0 && iix + 1 <= bw && iiy + 1 >= 0 && iiy + 1 <= bh) - a9 = *(sp + (iiy + 1)*bpr + iix + 1); - A9 = w*h*ALPHA(a9); - A6 = (w - A9/256)*ALPHA(a6); - A8 = (h - A9/256)*ALPHA(a8); + a9 = *(sp + (iiy + 1) * bpr + iix + 1); + A9 = w * h * ALPHA(a9); + A6 = (w - A9 / 256) * ALPHA(a6); + A8 = (h - A9 / 256) * ALPHA(a8); A5 = ALPHA(a5) - A9 - A6 - A8; - } - else // do 9-aliasing + } else // do 9-aliasing { A5 = ALPHA(a5); } uint8 red, green, blue, alpha; - red = clipchar (float ((RED(a1)*A1 - + RED(a2)*A2 - + RED(a3)*A3 - + RED(a4)*A4 - + RED(a5)*A5 - + RED(a6)*A6 - + RED(a7)*A7 - + RED(a8)*A8 - + RED(a9)*A9)/256)); - green = clipchar (float ((GREEN(a1)*A1 - + GREEN(a2)*A2 - + GREEN(a3)*A3 - + GREEN(a4)*A4 - + GREEN(a5)*A5 - + GREEN(a6)*A6 - + GREEN(a7)*A7 - + GREEN(a8)*A8 - + GREEN(a9)*A9)/256)); - blue = clipchar (float ((BLUE(a1)*A1 - + BLUE(a2)*A2 - + BLUE(a3)*A3 - + BLUE(a4)*A4 - + BLUE(a5)*A5 - + BLUE(a6)*A6 - + BLUE(a7)*A7 - + BLUE(a8)*A8 - + BLUE(a9)*A9)/256)); - alpha = clipchar (float (A1 + A2 + A3 + A4 + A5 + A6 + A7 + A8 + A9)); - *(++dl) = PIXEL (red, green, blue, alpha); + red = clipchar(float( + (RED(a1) * A1 + RED(a2) * A2 + RED(a3) * A3 + RED(a4) * A4 + RED(a5) * A5 + + RED(a6) * A6 + RED(a7) * A7 + RED(a8) * A8 + RED(a9) * A9) / + 256 + )); + green = clipchar(float( + (GREEN(a1) * A1 + GREEN(a2) * A2 + GREEN(a3) * A3 + GREEN(a4) * A4 + + GREEN(a5) * A5 + GREEN(a6) * A6 + GREEN(a7) * A7 + GREEN(a8) * A8 + + GREEN(a9) * A9) / + 256 + )); + blue = clipchar(float( + (BLUE(a1) * A1 + BLUE(a2) * A2 + BLUE(a3) * A3 + BLUE(a4) * A4 + BLUE(a5) * A5 + + BLUE(a6) * A6 + BLUE(a7) * A7 + BLUE(a8) * A8 + BLUE(a9) * A9) / + 256 + )); + alpha = clipchar(float(A1 + A2 + A3 + A4 + A5 + A6 + A7 + A8 + A9)); + *(++dl) = PIXEL(red, green, blue, alpha); ix += cr; iy += sr; } } - } - else - { - for (int i = 0; i <= bh; i++) - { - ix = ox - i*sr; - iy = oy + i*cr; - bgra_pixel *dl = dp + i*bpr; - for (int j = 0; j <= bw; j++) - { - int iix = int (ix + .5); - int iiy = int (iy + .5); + } else { + for (int i = 0; i <= bh; i++) { + ix = ox - i * sr; + iy = oy + i * cr; + bgra_pixel* dl = dp + i * bpr; + for (int j = 0; j <= bw; j++) { + int iix = int(ix + .5); + int iiy = int(iy + .5); if (iix >= 0 && iix <= bw && iiy >= 0 && iiy <= bh) - *(++dl) = *(sp + iiy*bpr + iix); + *(++dl) = *(sp + iiy * bpr + iix); else *(++dl) = 0; ix += cr; @@ -2234,122 +2141,114 @@ void Rotate (SBitmap *s, Layer *d, BPoint o, float rad, bool hiq) } } -void Rotate (SBitmap *s, Selection *d, BPoint o, float rad, bool hiq) +void +Rotate(SBitmap* s, Selection* d, BPoint o, float rad, bool hiq) { - float sr = sin (rad); - float cr = cos (rad); + float sr = sin(rad); + float cr = cos(rad); float ix, iy; float bw, bh; uint32 bpr = s->BytesPerRow(); bw = s->Bounds().right; bh = s->Bounds().bottom; - grey_pixel *dp = (grey_pixel *) d->Bits() - 1; - grey_pixel *sp = (grey_pixel *) s->Bits(); + grey_pixel* dp = (grey_pixel*)d->Bits() - 1; + grey_pixel* sp = (grey_pixel*)s->Bits(); float ox, oy; - ox = o.y*sr + o.x*(1 - cr); - oy = o.y*(1 - cr) - o.x*sr; - if (hiq && rad != 0) // do anti-aliasing + ox = o.y * sr + o.x * (1 - cr); + oy = o.y * (1 - cr) - o.x * sr; + if (hiq && rad != 0) // do anti-aliasing { - for (int i = 0; i <= bh; i++) - { - ix = ox - i*sr; - iy = oy + i*cr; - grey_pixel *dl = dp + i*bpr; - for (int j = 0; j <= bw; j++) - { - int iix = int (ix); - int iiy = int (iy); - float fix = (float) iix; - float fiy = (float) iiy; + for (int i = 0; i <= bh; i++) { + ix = ox - i * sr; + iy = oy + i * cr; + grey_pixel* dl = dp + i * bpr; + for (int j = 0; j <= bw; j++) { + int iix = int(ix); + int iiy = int(iy); + float fix = (float)iix; + float fiy = (float)iiy; grey_pixel a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0, a7 = 0, a8 = 0, a9 = 0; if (iix >= 0 && iix <= bw && iiy >= 0 && iiy <= bh) - a5 = *(sp + iiy*bpr + iix); + a5 = *(sp + iiy * bpr + iix); - float A1 = 0, A2 = 0, A3 = 0, A4 = 0, A5 = 0, A6 = 0, A7 = 0, A8 = 0, A9 = 0; // Areas + float A1 = 0, A2 = 0, A3 = 0, A4 = 0, A5 = 0, A6 = 0, A7 = 0, A8 = 0, + A9 = 0; // Areas float w, h; w = ix - (fix + .5); h = iy - (fiy + .5); -// float r = sqrt (w*w + h*h); + // float r = sqrt (w*w + h*h); - if (w < 0 && h < 0) // TLC + if (w < 0 && h < 0) // TLC { if (iix - 1 >= 0 && iix - 1 <= bw && iiy - 1 >= 0 && iiy - 1 <= bh) - a1 = *(sp + (iiy - 1)*bpr + iix - 1); + a1 = *(sp + (iiy - 1) * bpr + iix - 1); if (iix >= 0 && iix <= bw && iiy - 1 >= 0 && iiy - 1 <= bh) - a2 = *(sp + (iiy - 1)*bpr + iix); + a2 = *(sp + (iiy - 1) * bpr + iix); if (iix - 1 >= 0 && iix - 1 <= bw && iiy >= 0 && iiy <= bh) - a4 = *(sp + iiy*bpr + iix - 1); - A1 = w*h*a1; - A2 = (-h - A1/256)*a2; - A4 = (-w - A1/256)*a4; + a4 = *(sp + iiy * bpr + iix - 1); + A1 = w * h * a1; + A2 = (-h - A1 / 256) * a2; + A4 = (-w - A1 / 256) * a4; A5 = a5 - A1 - A2 - A4; - } - else if (w > 0 && h < 0) // TRC + } else if (w > 0 && h < 0) // TRC { if (iix >= 0 && iix <= bw && iiy - 1 >= 0 && iiy - 1 <= bh) - a2 = *(sp + (iiy - 1)*bpr + iix); + a2 = *(sp + (iiy - 1) * bpr + iix); if (iix + 1 >= 0 && iix + 1 <= bw && iiy - 1 >= 0 && iiy - 1 <= bh) - a3 = *(sp + (iiy - 1)*bpr + iix + 1); + a3 = *(sp + (iiy - 1) * bpr + iix + 1); if (iix + 1 >= 0 && iix + 1 <= bw && iiy >= 0 && iiy <= bh) - a6 = *(sp + iiy*bpr + iix + 1); - A3 = -w*h*a3; - A2 = (-h - A3/256)*a2; - A6 = (w - A3/256)*a6; + a6 = *(sp + iiy * bpr + iix + 1); + A3 = -w * h * a3; + A2 = (-h - A3 / 256) * a2; + A6 = (w - A3 / 256) * a6; A5 = a5 - A3 - A2 - A6; - } - else if (w < 0 && h > 0) // BLC + } else if (w < 0 && h > 0) // BLC { if (iix - 1 >= 0 && iix - 1 <= bw && iiy >= 0 && iiy <= bh) - a4 = *(sp + iiy*bpr + iix - 1); + a4 = *(sp + iiy * bpr + iix - 1); if (iix - 1 >= 0 && iix - 1 <= bw && iiy + 1 >= 0 && iiy + 1 <= bh) - a7 = *(sp + (iiy + 1)*bpr + iix - 1); + a7 = *(sp + (iiy + 1) * bpr + iix - 1); if (iix >= 0 && iix <= bw && iiy + 1 >= 0 && iiy + 1 <= bh) - a8 = *(sp + (iiy + 1)*bpr + iix); - A7 = -w*h*a7; - A4 = (-w - A7/256)*a4; - A8 = (h - A7/256)*a8; + a8 = *(sp + (iiy + 1) * bpr + iix); + A7 = -w * h * a7; + A4 = (-w - A7 / 256) * a4; + A8 = (h - A7 / 256) * a8; A5 = a5 - A7 - A4 - A8; - } - else if (w > 0 && h > 0) // BRC + } else if (w > 0 && h > 0) // BRC { if (iix + 1 >= 0 && iix + 1 <= bw && iiy >= 0 && iiy <= bh) - a6 = *(sp + iiy*bpr + iix + 1); + a6 = *(sp + iiy * bpr + iix + 1); if (iix >= 0 && iix <= bw && iiy + 1 >= 0 && iiy + 1 <= bh) - a8 = *(sp + (iiy + 1)*bpr + iix); + a8 = *(sp + (iiy + 1) * bpr + iix); if (iix + 1 >= 0 && iix + 1 <= bw && iiy + 1 >= 0 && iiy + 1 <= bh) - a9 = *(sp + (iiy + 1)*bpr + iix + 1); - A9 = w*h*a9; - A6 = (w - A9/256)*a6; - A8 = (h - A9/256)*a8; + a9 = *(sp + (iiy + 1) * bpr + iix + 1); + A9 = w * h * a9; + A6 = (w - A9 / 256) * a6; + A8 = (h - A9 / 256) * a8; A5 = a5 - A9 - A6 - A8; - } - else // do 9-aliasing + } else // do 9-aliasing { A5 = a5; } - uint8 alpha = clipchar (float (A1 + A2 + A3 + A4 + A5 + A6 + A7 + A8 + A9)); + uint8 alpha = clipchar(float(A1 + A2 + A3 + A4 + A5 + A6 + A7 + A8 + A9)); *(++dl) = alpha; ix += cr; iy += sr; } } - } - else - { - for (int i = 0; i <= bh; i++) - { - ix = ox - i*sr; - iy = oy + i*cr; - grey_pixel *dl = dp + i*bpr; - for (int j = 0; j <= bw; j++) - { - int iix = int (ix + .5); - int iiy = int (iy + .5); + } else { + for (int i = 0; i <= bh; i++) { + ix = ox - i * sr; + iy = oy + i * cr; + grey_pixel* dl = dp + i * bpr; + for (int j = 0; j <= bw; j++) { + int iix = int(ix + .5); + int iiy = int(iy + .5); if (iix >= 0 && iix <= bw && iiy >= 0 && iiy <= bh) - *(++dl) = *(sp + iiy*bpr + iix); + *(++dl) = *(sp + iiy * bpr + iix); else *(++dl) = 0; ix += cr; @@ -2359,14 +2258,13 @@ void Rotate (SBitmap *s, Selection *d, BPoint o, float rad, bool hiq) } } - -void SBitmapToLayer (SBitmap *s, Layer *d, BPoint &p) +void +SBitmapToLayer(SBitmap* s, Layer* d, BPoint& p) { - ASSERT (s->BytesPerPixel() == 4); + ASSERT(s->BytesPerPixel() == 4); - if (p == B_ORIGIN) - { - memcpy (d->Bits(), s->Bits(), s->BitsLength()); + if (p == B_ORIGIN) { + memcpy(d->Bits(), s->Bits(), s->BitsLength()); return; } @@ -2375,108 +2273,94 @@ void SBitmapToLayer (SBitmap *s, Layer *d, BPoint &p) if (p.y > s->Bounds().bottom || p.y < -s->Bounds().bottom) return; - if (p.x >= 0) - { - if (p.y >= 0) - { - int32 rt = int32 (p.y); - int32 rb = int32 (s->Bounds().bottom); - int32 rl = int32 (p.x); - int32 rr = int32 (s->Bounds().right); - - int32 bpr = 4*(rr - rl + 1); - for (int32 y = rt; y <= rb; y++) - { - uint32 *sp = (uint32 *) s->Bits() + (y - rt)*s->BytesPerRow()/4; - uint32 *dp = (uint32 *) d->Bits() + y*d->BytesPerRow()/4 + rl; - memcpy (dp, sp, bpr); + if (p.x >= 0) { + if (p.y >= 0) { + int32 rt = int32(p.y); + int32 rb = int32(s->Bounds().bottom); + int32 rl = int32(p.x); + int32 rr = int32(s->Bounds().right); + + int32 bpr = 4 * (rr - rl + 1); + for (int32 y = rt; y <= rb; y++) { + uint32* sp = (uint32*)s->Bits() + (y - rt) * s->BytesPerRow() / 4; + uint32* dp = (uint32*)d->Bits() + y * d->BytesPerRow() / 4 + rl; + memcpy(dp, sp, bpr); } - } - else - { - int32 rt = -int32 (p.y); - int32 rb = int32 (s->Bounds().bottom); - int32 rl = int32 (p.x); - int32 rr = int32 (s->Bounds().right); - - int32 bpr = 4*(rr - rl + 1); - for (int32 y = rt; y <= rb; y++) - { - uint32 *sp = (uint32 *) s->Bits() + y*s->BytesPerRow()/4; - uint32 *dp = (uint32 *) d->Bits() + (y - rt)*d->BytesPerRow()/4 + rl; - memcpy (dp, sp, bpr); + } else { + int32 rt = -int32(p.y); + int32 rb = int32(s->Bounds().bottom); + int32 rl = int32(p.x); + int32 rr = int32(s->Bounds().right); + + int32 bpr = 4 * (rr - rl + 1); + for (int32 y = rt; y <= rb; y++) { + uint32* sp = (uint32*)s->Bits() + y * s->BytesPerRow() / 4; + uint32* dp = (uint32*)d->Bits() + (y - rt) * d->BytesPerRow() / 4 + rl; + memcpy(dp, sp, bpr); } } - } - else - { - if (p.y >= 0) - { - int32 rt = int32 (p.y); - int32 rb = int32 (s->Bounds().bottom); - int32 rl = -int32 (p.x); - int32 rr = int32 (s->Bounds().right); - - int32 bpr = 4*(rr - rl + 1); - for (int32 y = rt; y <= rb; y++) - { - uint32 *sp = (uint32 *) s->Bits() + (y - rt)*s->BytesPerRow()/4 + rl; - uint32 *dp = (uint32 *) d->Bits() + y*d->BytesPerRow()/4; - memcpy (dp, sp, bpr); + } else { + if (p.y >= 0) { + int32 rt = int32(p.y); + int32 rb = int32(s->Bounds().bottom); + int32 rl = -int32(p.x); + int32 rr = int32(s->Bounds().right); + + int32 bpr = 4 * (rr - rl + 1); + for (int32 y = rt; y <= rb; y++) { + uint32* sp = (uint32*)s->Bits() + (y - rt) * s->BytesPerRow() / 4 + rl; + uint32* dp = (uint32*)d->Bits() + y * d->BytesPerRow() / 4; + memcpy(dp, sp, bpr); } - } - else - { - int32 rt = -int32 (p.y); - int32 rb = int32 (s->Bounds().bottom); - int32 rl = -int32 (p.x); - int32 rr = int32 (s->Bounds().right); - - int32 bpr = 4*(rr - rl + 1); - for (int32 y = rt; y <= rb; y++) - { - uint32 *sp = (uint32 *) s->Bits() + y*s->BytesPerRow()/4 + rl; - uint32 *dp = (uint32 *) d->Bits() + (y - rt)*d->BytesPerRow()/4; - memcpy (dp, sp, bpr); + } else { + int32 rt = -int32(p.y); + int32 rb = int32(s->Bounds().bottom); + int32 rl = -int32(p.x); + int32 rr = int32(s->Bounds().right); + + int32 bpr = 4 * (rr - rl + 1); + for (int32 y = rt; y <= rb; y++) { + uint32* sp = (uint32*)s->Bits() + y * s->BytesPerRow() / 4 + rl; + uint32* dp = (uint32*)d->Bits() + (y - rt) * d->BytesPerRow() / 4; + memcpy(dp, sp, bpr); } } } } -void SBitmapToLayer (SBitmap *s, Layer *d, BRect &r) +void +SBitmapToLayer(SBitmap* s, Layer* d, BRect& r) { - ASSERT (s->BytesPerPixel() == 4); + ASSERT(s->BytesPerPixel() == 4); - if (s->Bounds() == d->Bounds() && d->Bounds() == r) - { - memcpy (d->Bits(), s->Bits(), s->BitsLength()); + if (s->Bounds() == d->Bounds() && d->Bounds() == r) { + memcpy(d->Bits(), s->Bits(), s->BitsLength()); return; } - int32 rt = max_c (0, int32 (r.top)); - int32 rb = min_c (int32 (d->Bounds().bottom), max_c (int32 (s->Bounds().bottom), int32 (r.bottom))); - int32 rl = max_c (0, int32 (r.left)); - int32 rr = min_c (int32 (d->Bounds().right), max_c (int32 (s->Bounds().right), int32 (r.right))); + int32 rt = max_c(0, int32(r.top)); + int32 rb = min_c(int32(d->Bounds().bottom), max_c(int32(s->Bounds().bottom), int32(r.bottom))); + int32 rl = max_c(0, int32(r.left)); + int32 rr = min_c(int32(d->Bounds().right), max_c(int32(s->Bounds().right), int32(r.right))); - int32 bpr = 4*(rr - rl + 1); + int32 bpr = 4 * (rr - rl + 1); if (bpr <= 0) return; - for (int32 y = rt; y <= rb; y++) - { - uint32 *sp = (uint32 *) s->Bits() + y*s->BytesPerRow()/4 + rl; - uint32 *dp = (uint32 *) d->Bits() + y*d->BytesPerRow()/4 + rl; - memcpy (dp, sp, bpr); + for (int32 y = rt; y <= rb; y++) { + uint32* sp = (uint32*)s->Bits() + y * s->BytesPerRow() / 4 + rl; + uint32* dp = (uint32*)d->Bits() + y * d->BytesPerRow() / 4 + rl; + memcpy(dp, sp, bpr); } } -void SBitmapToSelection (SBitmap *s, Selection *d, BPoint &p) +void +SBitmapToSelection(SBitmap* s, Selection* d, BPoint& p) { - ASSERT (s->BytesPerPixel() == 1); + ASSERT(s->BytesPerPixel() == 1); - if (p == B_ORIGIN) - { - memcpy (d->Bits(), s->Bits(), s->BitsLength()); + if (p == B_ORIGIN) { + memcpy(d->Bits(), s->Bits(), s->BitsLength()); return; } @@ -2485,102 +2369,88 @@ void SBitmapToSelection (SBitmap *s, Selection *d, BPoint &p) if (p.y > s->Bounds().bottom || p.y < -s->Bounds().bottom) return; - if (p.x >= 0) - { - if (p.y >= 0) - { - int32 rt = int32 (p.y); - int32 rb = int32 (s->Bounds().bottom); - int32 rl = int32 (p.x); - int32 rr = int32 (s->Bounds().right); + if (p.x >= 0) { + if (p.y >= 0) { + int32 rt = int32(p.y); + int32 rb = int32(s->Bounds().bottom); + int32 rl = int32(p.x); + int32 rr = int32(s->Bounds().right); int32 bpr = rr - rl + 1; - for (int32 y = rt; y <= rb; y++) - { - uint8 *sp = (uint8 *) s->Bits() + (y - rt)*s->BytesPerRow(); - uint8 *dp = (uint8 *) d->Bits() + y*d->BytesPerRow() + rl; - memcpy (dp, sp, bpr); + for (int32 y = rt; y <= rb; y++) { + uint8* sp = (uint8*)s->Bits() + (y - rt) * s->BytesPerRow(); + uint8* dp = (uint8*)d->Bits() + y * d->BytesPerRow() + rl; + memcpy(dp, sp, bpr); } - } - else - { - int32 rt = -int32 (p.y); - int32 rb = int32 (s->Bounds().bottom); - int32 rl = int32 (p.x); - int32 rr = int32 (s->Bounds().right); + } else { + int32 rt = -int32(p.y); + int32 rb = int32(s->Bounds().bottom); + int32 rl = int32(p.x); + int32 rr = int32(s->Bounds().right); int32 bpr = rr - rl + 1; - for (int32 y = rt; y <= rb; y++) - { - uint8 *sp = (uint8 *) s->Bits() + y*s->BytesPerRow(); - uint8 *dp = (uint8 *) d->Bits() + (y - rt)*d->BytesPerRow() + rl; - memcpy (dp, sp, bpr); + for (int32 y = rt; y <= rb; y++) { + uint8* sp = (uint8*)s->Bits() + y * s->BytesPerRow(); + uint8* dp = (uint8*)d->Bits() + (y - rt) * d->BytesPerRow() + rl; + memcpy(dp, sp, bpr); } } - } - else - { - if (p.y >= 0) - { - int32 rt = int32 (p.y); - int32 rb = int32 (s->Bounds().bottom); - int32 rl = -int32 (p.x); - int32 rr = int32 (s->Bounds().right); + } else { + if (p.y >= 0) { + int32 rt = int32(p.y); + int32 rb = int32(s->Bounds().bottom); + int32 rl = -int32(p.x); + int32 rr = int32(s->Bounds().right); int32 bpr = rr - rl + 1; - for (int32 y = rt; y <= rb; y++) - { - uint8 *sp = (uint8 *) s->Bits() + (y - rt)*s->BytesPerRow() + rl; - uint8 *dp = (uint8 *) d->Bits() + y*d->BytesPerRow(); - memcpy (dp, sp, bpr); + for (int32 y = rt; y <= rb; y++) { + uint8* sp = (uint8*)s->Bits() + (y - rt) * s->BytesPerRow() + rl; + uint8* dp = (uint8*)d->Bits() + y * d->BytesPerRow(); + memcpy(dp, sp, bpr); } - } - else - { - int32 rt = -int32 (p.y); - int32 rb = int32 (s->Bounds().bottom); - int32 rl = -int32 (p.x); - int32 rr = int32 (s->Bounds().right); + } else { + int32 rt = -int32(p.y); + int32 rb = int32(s->Bounds().bottom); + int32 rl = -int32(p.x); + int32 rr = int32(s->Bounds().right); int32 bpr = rr - rl + 1; - for (int32 y = rt; y <= rb; y++) - { - uint8 *sp = (uint8 *) s->Bits() + y*s->BytesPerRow() + rl; - uint8 *dp = (uint8 *) d->Bits() + (y - rt)*d->BytesPerRow(); - memcpy (dp, sp, bpr); + for (int32 y = rt; y <= rb; y++) { + uint8* sp = (uint8*)s->Bits() + y * s->BytesPerRow() + rl; + uint8* dp = (uint8*)d->Bits() + (y - rt) * d->BytesPerRow(); + memcpy(dp, sp, bpr); } } } } -void SBitmapToSelection (SBitmap *s, Selection *d, BRect &r) +void +SBitmapToSelection(SBitmap* s, Selection* d, BRect& r) { - ASSERT (s->BytesPerPixel() == 1); + ASSERT(s->BytesPerPixel() == 1); - if (s->Bounds() == d->Bounds() && d->Bounds() == r) - { - memcpy (d->Bits(), s->Bits(), s->BitsLength()); + if (s->Bounds() == d->Bounds() && d->Bounds() == r) { + memcpy(d->Bits(), s->Bits(), s->BitsLength()); return; } - int32 rt = max_c (0, int32 (r.top)); - int32 rb = min_c (int32 (d->Bounds().bottom), max_c (int32 (s->Bounds().bottom), int32 (r.bottom))); - int32 rl = max_c (0, int32 (r.left)); - int32 rr = min_c (int32 (d->Bounds().right), max_c (int32 (s->Bounds().right), int32 (r.right))); + int32 rt = max_c(0, int32(r.top)); + int32 rb = min_c(int32(d->Bounds().bottom), max_c(int32(s->Bounds().bottom), int32(r.bottom))); + int32 rl = max_c(0, int32(r.left)); + int32 rr = min_c(int32(d->Bounds().right), max_c(int32(s->Bounds().right), int32(r.right))); int32 bpr = (rr - rl + 1); if (bpr <= 0) return; - for (int32 y = rt; y <= rb; y++) - { - uint8 *sp = (uint8 *) s->Bits() + y*s->BytesPerRow() + rl; - uint8 *dp = (uint8 *) d->Bits() + y*d->BytesPerRow() + rl; - memcpy (dp, sp, bpr); + for (int32 y = rt; y <= rb; y++) { + uint8* sp = (uint8*)s->Bits() + y * s->BytesPerRow() + rl; + uint8* dp = (uint8*)d->Bits() + y * d->BytesPerRow() + rl; + memcpy(dp, sp, bpr); } } -#if defined (__MWCC__) +#if defined(__MWCC__) #pragma peephole reset #endif diff --git a/source/BitmapStuff.h b/source/BitmapStuff.h index 0327bac..f02634e 100644 --- a/source/BitmapStuff.h +++ b/source/BitmapStuff.h @@ -9,23 +9,40 @@ class SBitmap; -BBitmap *entry2bitmap (BEntry entry, bool silent/* = false*/); -float AverageAlpha (BBitmap *src); -void InvertAlpha (BBitmap *src); -void InsertGlobalAlpha (Layer *layers[], int numLayers); -void InvertWithInverseAlpha (BBitmap *src, BBitmap *selection); -void AddToSelection (Brush *src, BBitmap *dest, long x, long y, int strength = 255); -void CopyWithTransparency (BBitmap *src, BBitmap *dest, long x, long y); -void FastCopy (BBitmap *src, BBitmap *dest); -void FSDither (BBitmap *b32, BBitmap *b8, BRect place); -BRect GetSmallestRect (BBitmap *b); -int32 gcd (int32 p, int32 q); -void Rotate (SBitmap *s, Layer *d, BPoint origin, float rad, bool hiq); -void Rotate (SBitmap *s, Selection *d, BPoint origin, float rad, bool hiq); -void SBitmapToLayer (SBitmap *s, Layer *d, BPoint &p); -void SBitmapToLayer (SBitmap *s, Layer *d, BRect &r); -void SBitmapToSelection (SBitmap *s, Selection *d, BPoint &p); -void SBitmapToSelection (SBitmap *s, Selection *d, BRect &r); +BBitmap* +entry2bitmap(BEntry entry, bool silent /* = false*/); +float +AverageAlpha(BBitmap* src); +void +InvertAlpha(BBitmap* src); +void +InsertGlobalAlpha(Layer* layers[], int numLayers); +void +InvertWithInverseAlpha(BBitmap* src, BBitmap* selection); +void +AddToSelection(Brush* src, BBitmap* dest, long x, long y, int strength = 255); +void +CopyWithTransparency(BBitmap* src, BBitmap* dest, long x, long y); +void +FastCopy(BBitmap* src, BBitmap* dest); +void +FSDither(BBitmap* b32, BBitmap* b8, BRect place); +BRect +GetSmallestRect(BBitmap* b); +int32 +gcd(int32 p, int32 q); +void +Rotate(SBitmap* s, Layer* d, BPoint origin, float rad, bool hiq); +void +Rotate(SBitmap* s, Selection* d, BPoint origin, float rad, bool hiq); +void +SBitmapToLayer(SBitmap* s, Layer* d, BPoint& p); +void +SBitmapToLayer(SBitmap* s, Layer* d, BRect& r); +void +SBitmapToSelection(SBitmap* s, Selection* d, BPoint& p); +void +SBitmapToSelection(SBitmap* s, Selection* d, BRect& r); /* @@ -37,4 +54,4 @@ void BlendWithAlpha (BBitmap *src, BBitmap *dest, long x, long y, int strength = #pragma export reset */ -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/BitmapView.cpp b/source/BitmapView.cpp index 5ddc6b7..fc57a20 100644 --- a/source/BitmapView.cpp +++ b/source/BitmapView.cpp @@ -2,55 +2,56 @@ #include "Colors.h" #include -BitmapView::BitmapView (BRect bounds, const char *name, BBitmap *map, drawing_mode mode, bool center, bool own) -: BView (bounds, name, B_FOLLOW_NONE, B_WILL_DRAW) +BitmapView::BitmapView( + BRect bounds, const char* name, BBitmap* map, drawing_mode mode, bool center, bool own +) + : BView(bounds, name, B_FOLLOW_NONE, B_WILL_DRAW) { if (own) fBitmap = map; else - fBitmap = new BBitmap (map); - SetViewColor (White); - SetDrawingMode (mode); + fBitmap = new BBitmap(map); + SetViewColor(White); + SetDrawingMode(mode); fCenter = center; fPosition = B_ORIGIN; } -BitmapView::BitmapView (BRect bounds, const char *name) -: BView (bounds, name, B_FOLLOW_NONE, B_WILL_DRAW) +BitmapView::BitmapView(BRect bounds, const char* name) + : BView(bounds, name, B_FOLLOW_NONE, B_WILL_DRAW) { fBitmap = NULL; - SetViewColor (White); + SetViewColor(White); fCenter = true; } -BitmapView::~BitmapView () -{ - delete fBitmap; -} +BitmapView::~BitmapView() { delete fBitmap; } -void BitmapView::SetPosition (BPoint point) +void +BitmapView::SetPosition(BPoint point) { fPosition = point; fCenter = false; } -void BitmapView::SetBitmap (BBitmap *bitmap) +void +BitmapView::SetBitmap(BBitmap* bitmap) { delete fBitmap; - fBitmap = new BBitmap (bitmap); + fBitmap = new BBitmap(bitmap); } -void BitmapView::Draw (BRect /*update*/) +void +BitmapView::Draw(BRect /*update*/) { - if (fBitmap) - { - if (fCenter) - { - BPoint place = BPoint ((Bounds().Width() - fBitmap->Bounds().Width())/2, - (Bounds().Height() - fBitmap->Bounds().Height())/2); - DrawBitmap (fBitmap, place); - } - else - DrawBitmap (fBitmap, fPosition); + if (fBitmap) { + if (fCenter) { + BPoint place = BPoint( + (Bounds().Width() - fBitmap->Bounds().Width()) / 2, + (Bounds().Height() - fBitmap->Bounds().Height()) / 2 + ); + DrawBitmap(fBitmap, place); + } else + DrawBitmap(fBitmap, fPosition); } } \ No newline at end of file diff --git a/source/BitmapView.h b/source/BitmapView.h index 4c0e9b0..d4143ac 100644 --- a/source/BitmapView.h +++ b/source/BitmapView.h @@ -7,19 +7,22 @@ class BitmapView : public BView { -public: - BitmapView (BRect bounds, const char *name); - BitmapView (BRect bounds, const char *name, BBitmap *map, drawing_mode mode = B_OP_COPY, bool center = true, bool own = true); -virtual ~BitmapView (); -virtual void Draw (BRect update); -virtual void SetBitmap (BBitmap *bitmap); -virtual void SetPosition (const BPoint leftTop); + public: + BitmapView(BRect bounds, const char* name); + BitmapView( + BRect bounds, const char* name, BBitmap* map, drawing_mode mode = B_OP_COPY, + bool center = true, bool own = true + ); + virtual ~BitmapView(); + virtual void Draw(BRect update); + virtual void SetBitmap(BBitmap* bitmap); + virtual void SetPosition(const BPoint leftTop); -private: -typedef BView inherited; -BBitmap *fBitmap; -BPoint fPosition; -bool fCenter; + private: + typedef BView inherited; + BBitmap* fBitmap; + BPoint fPosition; + bool fCenter; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/Brush.cpp b/source/Brush.cpp index 1731828..a45516a 100644 --- a/source/Brush.cpp +++ b/source/Brush.cpp @@ -1,81 +1,84 @@ #include "Brush.h" -#include "hsv.h" // For the clipchar() +#include "hsv.h" // For the clipchar() -Brush::Brush (int h, int w, float s) +Brush::Brush(int h, int w, float s) { fHeight = h; fWidth = w; fSpacing = s; - data = new unsigned char [(w + 1)*(h + 1)]; // Yes I know this is 1 off. - for (int i = 0; i < (w + 1)*(h + 1); i++) // So much to do, so little time :-) + data = new unsigned char[(w + 1) * (h + 1)]; // Yes I know this is 1 off. + for (int i = 0; i < (w + 1) * (h + 1); i++) // So much to do, so little time :-) data[i] = 0; bitmap = NULL; } -Brush::~Brush () +Brush::~Brush() { - delete [] data; + delete[] data; if (bitmap) delete bitmap; } -void Brush::Set (int x, int y, uchar v) +void +Brush::Set(int x, int y, uchar v) { if (x >= 0 && x < fWidth && y >= 0 && y < fHeight) - data[fWidth*y + x] = v; + data[fWidth * y + x] = v; } -uchar Brush::Get (int x, int y) +uchar +Brush::Get(int x, int y) { if (x >= 0 && x < fWidth && y >= 0 && y < fHeight) - return (data[fWidth*y + x]); + return (data[fWidth * y + x]); else return 0; } -rgb_color Brush::ToColor (int x, int y, rgb_color src, rgb_color dst) +rgb_color +Brush::ToColor(int x, int y, rgb_color src, rgb_color dst) { - dst.red = clipchar (dst.red - (255 - src.red)*Get (x, y)/255); - dst.green = clipchar (dst.green - (255 - src.green)*Get (x, y)/255); - dst.blue = clipchar (dst.blue - (255 - src.blue)*Get (x, y)/255); + dst.red = clipchar(dst.red - (255 - src.red) * Get(x, y) / 255); + dst.green = clipchar(dst.green - (255 - src.green) * Get(x, y) / 255); + dst.blue = clipchar(dst.blue - (255 - src.blue) * Get(x, y) / 255); return (dst); } -BBitmap *Brush::ToBitmap (rgb_color hi) +BBitmap* +Brush::ToBitmap(rgb_color hi) { -// Note: A brush map contains alpha = opacity. + // Note: A brush map contains alpha = opacity. if (!bitmap) - bitmap = new BBitmap (BRect (0, 0, fWidth - 1, fHeight - 1), B_RGBA32); - uchar *cdata = (uchar *) bitmap->Bits(); - uchar *pdata = data - 1; -// long bpr = bitmap->BytesPerRow(); + bitmap = new BBitmap(BRect(0, 0, fWidth - 1, fHeight - 1), B_RGBA32); + uchar* cdata = (uchar*)bitmap->Bits(); + uchar* pdata = data - 1; + // long bpr = bitmap->BytesPerRow(); cdata--; - int maxopacity = hi.alpha*255/256; // Hack to fix black center pixel bug + int maxopacity = hi.alpha * 255 / 256; // Hack to fix black center pixel bug for (int j = 0; j < fHeight; j++) - for (int i = 0; i < fWidth; i++) - { -// pdata = (cdata + j*bpr + 4*i); + for (int i = 0; i < fWidth; i++) { + // pdata = (cdata + j*bpr + 4*i); *(++cdata) = hi.blue; *(++cdata) = hi.green; *(++cdata) = hi.red; - *(++cdata) = *(++pdata)*maxopacity/255; + *(++cdata) = *(++pdata) * maxopacity / 255; } return bitmap; } -BBitmap *Brush::ToBitmap (rgb_color hi, rgb_color lo) +BBitmap* +Brush::ToBitmap(rgb_color hi, rgb_color lo) { if (!bitmap) - bitmap = new BBitmap (BRect (0, 0, fWidth - 1, fHeight - 1), B_RGBA32); - uchar *cdata = (uchar *) bitmap->Bits() - 1; -// long bpr = bitmap->BytesPerRow(); + bitmap = new BBitmap(BRect(0, 0, fWidth - 1, fHeight - 1), B_RGBA32); + uchar* cdata = (uchar*)bitmap->Bits() - 1; + // long bpr = bitmap->BytesPerRow(); for (int j = 0; j < fHeight; j++) - for (int i = 0; i < fWidth; i++) - { - int f = data[fWidth*j + i]; - *(++cdata) = (f*hi.blue + (255 - f)*lo.blue)/255; - *(++cdata) = (f*hi.green + (255 - f)*lo.green)/255; - *(++cdata) = (f*hi.red + (255 - f)*lo.red)/255; + for (int i = 0; i < fWidth; i++) { + int f = data[fWidth * j + i]; + *(++cdata) = (f * hi.blue + (255 - f) * lo.blue) / 255; + *(++cdata) = (f * hi.green + (255 - f) * lo.green) / 255; + *(++cdata) = (f * hi.red + (255 - f) * lo.red) / 255; *(++cdata) = 255; } return bitmap; diff --git a/source/Brush.h b/source/Brush.h index 0bd14c1..7294c3e 100644 --- a/source/Brush.h +++ b/source/Brush.h @@ -5,25 +5,30 @@ class Brush { -public: - Brush (int h, int w, float s); - ~Brush (); -void Set (int x, int y, uchar v); -uchar Get (int x, int y); -int Height () { return fHeight; }; -int Width () { return fWidth; }; -float Spacing () { return fSpacing; }; -rgb_color ToColor (int x, int y, rgb_color src, rgb_color dst); -BBitmap *ToBitmap (rgb_color hi); -BBitmap *ToBitmap (rgb_color hi, rgb_color lo); -uchar *Data () { return data; }; - -private: -int fHeight; -int fWidth; -float fSpacing; -uchar *data; -BBitmap *bitmap; + public: + Brush(int h, int w, float s); + ~Brush(); + void Set(int x, int y, uchar v); + uchar Get(int x, int y); + + int Height() { return fHeight; }; + + int Width() { return fWidth; }; + + float Spacing() { return fSpacing; }; + + rgb_color ToColor(int x, int y, rgb_color src, rgb_color dst); + BBitmap* ToBitmap(rgb_color hi); + BBitmap* ToBitmap(rgb_color hi, rgb_color lo); + + uchar* Data() { return data; }; + + private: + int fHeight; + int fWidth; + float fSpacing; + uchar* data; + BBitmap* bitmap; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/CanvasTools.cpp b/source/CanvasTools.cpp index f4d4047..dce1bf6 100644 --- a/source/CanvasTools.cpp +++ b/source/CanvasTools.cpp @@ -38,140 +38,136 @@ // #define USE_THREAD_FOR_POSITION #define FIX_STROKELINE_BUG -#define USE_MOUSEMOVED // instead of polling - works since 4.5 +#define USE_MOUSEMOVED // instead of polling - works since 4.5 -void CanvasView::tBrush (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tBrush(int32 mode, BPoint point, uint32 buttons) { -// printf ("Top of tBrush\n"); + // printf ("Top of tBrush\n"); Position position; - GetPosition (&position); + GetPosition(&position); extern ColorMenuButton *hicolor, *locolor; - extern AttribBrush *tAttribBrush; + extern AttribBrush* tAttribBrush; float Spacing = tAttribBrush->getSpacing(); int _w = tAttribBrush->getBrush()->Width(); int _h = tAttribBrush->getBrush()->Height(); - float cx = _w/2; - float cy = _h/2; - extern AttribDraw *mAttribDraw; + float cx = _w / 2; + float cy = _h / 2; + extern AttribDraw* mAttribDraw; drawing_mode dm = mAttribDraw->getDrawingMode(); - drawView->SetDrawingMode (dm); - SetDrawingMode (dm); - SetupUndo (mode); - drawView->MovePenTo (point); - MovePenTo (point); - if (buttons & B_PRIMARY_MOUSE_BUTTON) - { - drawView->SetHighColor (hicolor->color()); - drawView->SetLowColor (locolor->color()); - SetHighColor (hicolor->color()); - SetLowColor (locolor->color()); - } - if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { - drawView->SetHighColor (locolor->color()); - drawView->SetLowColor (hicolor->color()); - SetHighColor (locolor->color()); - SetLowColor (hicolor->color()); - } - Brush *b = tAttribBrush->getBrush(); - BBitmap *brushbm = b->ToBitmap (HighColor()); - SView::setSnoozeTime (max_c (20 * b->Height() * b->Width(), 20000)); + drawView->SetDrawingMode(dm); + SetDrawingMode(dm); + SetupUndo(mode); + drawView->MovePenTo(point); + MovePenTo(point); + if (buttons & B_PRIMARY_MOUSE_BUTTON) { + drawView->SetHighColor(hicolor->color()); + drawView->SetLowColor(locolor->color()); + SetHighColor(hicolor->color()); + SetLowColor(locolor->color()); + } + if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { + drawView->SetHighColor(locolor->color()); + drawView->SetLowColor(hicolor->color()); + SetHighColor(locolor->color()); + SetLowColor(hicolor->color()); + } + Brush* b = tAttribBrush->getBrush(); + BBitmap* brushbm = b->ToBitmap(HighColor()); + SView::setSnoozeTime(max_c(20 * b->Height() * b->Width(), 20000)); int strength = position.fPressure; twi = brushbm->Bounds().IntegerWidth(); thi = brushbm->Bounds().IntegerHeight(); bwi = fCanvasFrame.IntegerWidth(); bhi = fCanvasFrame.IntegerHeight(); - + fBC.cx = cx; fBC.cy = cy; fBC.Spacing = Spacing; fBC.b = b; fBC.brushbm = brushbm; fBC.pstrength = strength; - -// uchar *bits = (uchar *) currentLayer()->Bits(); -// long bytesperrow = currentLayer()->BytesPerRow(); - tbits = (uchar *) brushbm->Bits(); + + // uchar *bits = (uchar *) currentLayer()->Bits(); + // long bytesperrow = currentLayer()->BytesPerRow(); + tbits = (uchar*)brushbm->Bits(); tbpr = brushbm->BytesPerRow(); - bbits = (uchar *) currentLayer()->Bits(); + bbits = (uchar*)currentLayer()->Bits(); bbpr = currentLayer()->BytesPerRow(); - SetHighColor (Black); - if (abs (strength) > fTreshold) - { - if (mode == M_SELECT) - { - AddToSelection (b, selection, int (point.x - cx), int (point.y - cy), buttons & B_SECONDARY_MOUSE_BUTTON ? -strength : strength); - } - else if (dm == B_OP_COPY || dm == B_OP_OVER) - { - FastAddWithAlpha (point.x - cx, point.y - cy, strength); - } - else - { - DrawBitmapAsync (brushbm, BPoint (point.x - cx, point.y - cy)); - drawView->DrawBitmap (brushbm, BPoint (point.x - cx, point.y - cy)); + SetHighColor(Black); + if (abs(strength) > fTreshold) { + if (mode == M_SELECT) { + AddToSelection( + b, selection, int(point.x - cx), int(point.y - cy), + buttons & B_SECONDARY_MOUSE_BUTTON ? -strength : strength + ); + } else if (dm == B_OP_COPY || dm == B_OP_OVER) { + FastAddWithAlpha(point.x - cx, point.y - cy, strength); + } else { + DrawBitmapAsync(brushbm, BPoint(point.x - cx, point.y - cy)); + drawView->DrawBitmap(brushbm, BPoint(point.x - cx, point.y - cy)); } } // For immediate feedback at the first click: - Invalidate (BRect (point.x - cx - 1, point.y - cy - 1, point.x + cx + 1, point.y + cy + 1)); + Invalidate(BRect(point.x - cx - 1, point.y - cy - 1, point.x + cx + 1, point.y + cy + 1)); BPoint pos = point; fBC.pos = pos; -#if !defined (USE_MOUSEMOVED) +#if !defined(USE_MOUSEMOVED) BPoint nextPos; -// BRect frame = fCanvasFrame; + // BRect frame = fCanvasFrame; int pstrength = strength; - while (buttons) - { + while (buttons) { register float dx = pos.x - point.x; register float dy = pos.y - point.y; - register float ds = dx*dx + dy*dy; - register float distance = sqrt (ds); - BRect aR = BRect (point.x - cx - 1, point.y - cy - 1, point.x + cx + 1, point.y + cy + 1); - BRect bR = BRect (pos.x - cx - 1, pos.y - cy - 1, pos.x + cx + 1, pos.y + cy + 1); - if (distance > Spacing) - { + register float ds = dx * dx + dy * dy; + register float distance = sqrt(ds); + BRect aR = BRect(point.x - cx - 1, point.y - cy - 1, point.x + cx + 1, point.y + cy + 1); + BRect bR = BRect(pos.x - cx - 1, pos.y - cy - 1, pos.x + cx + 1, pos.y + cy + 1); + if (distance > Spacing) { clock_t start, end; start = clock(); - register float num = distance/Spacing; - register float facx = (point.x - pos.x)/num; - register float facy = (point.y - pos.y)/num; - register float facs = (strength - pstrength)/num; - for (float i = 1; i < num; i++) - { - nextPos = BPoint (pos.x + i*facx, pos.y + i*facy); - if (mode == M_SELECT) - { - AddToSelection (b, selection, int (nextPos.x - cx), int (nextPos.y - cy), int (pstrength + i*facs)); - } - else // if (dm == B_OP_COPY || dm == B_OP_OVER) + register float num = distance / Spacing; + register float facx = (point.x - pos.x) / num; + register float facy = (point.y - pos.y) / num; + register float facs = (strength - pstrength) / num; + for (float i = 1; i < num; i++) { + nextPos = BPoint(pos.x + i * facx, pos.y + i * facy); + if (mode == M_SELECT) { + AddToSelection( + b, selection, int(nextPos.x - cx), int(nextPos.y - cy), + int(pstrength + i * facs) + ); + } else // if (dm == B_OP_COPY || dm == B_OP_OVER) { - FastAddWithAlpha (int (nextPos.x - cx), int (nextPos.y - cy), int (pstrength + i*facs)); + FastAddWithAlpha( + int(nextPos.x - cx), int(nextPos.y - cy), int(pstrength + i * facs) + ); } -// else -// { -// DrawBitmapAsync (brushbm, BPoint (nextPos.x - cx, nextPos.y - cy)); -// drawView->DrawBitmap (brushbm, BPoint (nextPos.x - cx, nextPos.y - cy)); -// drawView->Sync(); -// selectionView->Sync(); -// } + // else + // { + // DrawBitmapAsync (brushbm, BPoint (nextPos.x - cx, nextPos.y - + // cy)); drawView->DrawBitmap (brushbm, BPoint (nextPos.x - cx, + // nextPos.y - cy)); drawView->Sync(); + // selectionView->Sync(); + // } } pos = nextPos; - Invalidate (aR | bR); -// DrawBitmap (currentLayer(), dirty, dirty); + Invalidate(aR | bR); + // DrawBitmap (currentLayer(), dirty, dirty); end = clock(); extern int DebugLevel; if (DebugLevel > 7) - printf ("Brush Stroke took %ld ms\n", end - start); + printf("Brush Stroke took %ld ms\n", end - start); } - snooze (10000); + snooze(10000); // We're not being good citizens, but Beatware's brush is faster... myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); - ScrollIfNeeded (point); + ScrollIfNeeded(point); // GetMouse (&point, &buttons, true); - GetPosition (&position); + GetPosition(&position); point = position.fPoint; buttons = position.fButtons; pstrength = strength; @@ -183,165 +179,165 @@ void CanvasView::tBrush (int32 mode, BPoint point, uint32 buttons) #endif } - -void CanvasView::tBrushM (int32 mode, BPoint point, uint32 buttons, int strength, BPoint /*tilt*/) +void +CanvasView::tBrushM(int32 mode, BPoint point, uint32 buttons, int strength, BPoint /*tilt*/) { -// printf ("Top of tBrushM: (%.0f, %.0f), %i (%.3f, %.3f)\n", point.x, point.y, strength, tilt.x, tilt.y); + // printf ("Top of tBrushM: (%.0f, %.0f), %i (%.3f, %.3f)\n", point.x, point.y, strength, + // tilt.x, tilt.y); BPoint pos = fBC.pos; BPoint nextPos; float cx = fBC.cx; float cy = fBC.cy; float Spacing = fBC.Spacing; - Brush *b = fBC.b; + Brush* b = fBC.b; int pstrength = fBC.pstrength; -// BBitmap *brushbm = fBC.brushbm; - + // BBitmap *brushbm = fBC.brushbm; + register float dx = pos.x - point.x; register float dy = pos.y - point.y; - register float ds = dx*dx + dy*dy; - register float distance = sqrt (ds); - BRect aR = BRect (point.x - cx - 1, point.y - cy - 1, point.x + cx + 1, point.y + cy + 1); - BRect bR = BRect (pos.x - cx - 1, pos.y - cy - 1, pos.x + cx + 1, pos.y + cy + 1); - -// extern AttribDraw *mAttribDraw; -// drawing_mode dm = mAttribDraw->getDrawingMode(); -// SetDrawingMode (dm); - if (distance > Spacing) - { + register float ds = dx * dx + dy * dy; + register float distance = sqrt(ds); + BRect aR = BRect(point.x - cx - 1, point.y - cy - 1, point.x + cx + 1, point.y + cy + 1); + BRect bR = BRect(pos.x - cx - 1, pos.y - cy - 1, pos.x + cx + 1, pos.y + cy + 1); + + // extern AttribDraw *mAttribDraw; + // drawing_mode dm = mAttribDraw->getDrawingMode(); + // SetDrawingMode (dm); + if (distance > Spacing) { clock_t start, end; start = clock(); - register float num = distance/Spacing; - register float facx = (point.x - pos.x)/num; - register float facy = (point.y - pos.y)/num; - register float facs = (strength - pstrength)/num; - for (float i = 1; i < num; i++) - { - nextPos = BPoint (pos.x + i*facx, pos.y + i*facy); - if (mode == M_SELECT) + register float num = distance / Spacing; + register float facx = (point.x - pos.x) / num; + register float facy = (point.y - pos.y) / num; + register float facs = (strength - pstrength) / num; + for (float i = 1; i < num; i++) { + nextPos = BPoint(pos.x + i * facx, pos.y + i * facy); + if (mode == M_SELECT) { + AddToSelection( + b, selection, int(nextPos.x - cx), int(nextPos.y - cy), + buttons & B_SECONDARY_MOUSE_BUTTON ? -int(pstrength + i * facs) + : int(pstrength + i * facs) + ); + } else // if (dm == B_OP_COPY || dm == B_OP_OVER) { - AddToSelection (b, selection, int (nextPos.x - cx), int (nextPos.y - cy), buttons & B_SECONDARY_MOUSE_BUTTON ? -int (pstrength + i*facs) : int (pstrength + i*facs)); + FastAddWithAlpha( + int(nextPos.x - cx), int(nextPos.y - cy), int(pstrength + i * facs) + ); } - else // if (dm == B_OP_COPY || dm == B_OP_OVER) - { - FastAddWithAlpha (int (nextPos.x - cx), int (nextPos.y - cy), int (pstrength + i*facs)); - } -// else -// { -// drawView->SetDrawingMode (dm); -// DrawBitmapAsync (brushbm, BPoint (nextPos.x - cx, nextPos.y - cy)); -// drawView->DrawBitmap (brushbm, BPoint (nextPos.x - cx, nextPos.y - cy)); -// drawView->Sync(); -// } + // else + // { + // drawView->SetDrawingMode (dm); + // DrawBitmapAsync (brushbm, BPoint (nextPos.x - cx, nextPos.y - cy)); + // drawView->DrawBitmap (brushbm, BPoint (nextPos.x - cx, nextPos.y - cy)); + // drawView->Sync(); + // } } pos = nextPos; - Invalidate (aR | bR); -// DrawBitmap (currentLayer(), dirty, dirty); + Invalidate(aR | bR); + // DrawBitmap (currentLayer(), dirty, dirty); end = clock(); extern int DebugLevel; if (DebugLevel > 7) - printf ("Brush Stroke took %ld ms\n", end - start); + printf("Brush Stroke took %ld ms\n", end - start); fBC.pos = pos; } -// snooze (10000); -// // We're not being good citizens, but Beatware's brush is faster... -// myWindow->Lock(); -// myWindow->posview->Pulse(); -// myWindow->Unlock(); - ScrollIfNeeded (point); + // snooze (10000); + // // We're not being good citizens, but Beatware's brush is faster... + // myWindow->Lock(); + // myWindow->posview->Pulse(); + // myWindow->Unlock(); + ScrollIfNeeded(point); // GetMouse (&point, &buttons, true); -// GetPosition (&position); -// point = position.fPoint; -// buttons = position.fButtons; + // GetPosition (&position); + // point = position.fPoint; + // buttons = position.fButtons; fBC.pstrength = strength; -// strength = position.fPressure; -// if (buttons & B_TERTIARY_MOUSE_BUTTON) -// strength = -strength; + // strength = position.fPressure; + // if (buttons & B_TERTIARY_MOUSE_BUTTON) + // strength = -strength; } - -void CanvasView::tClone (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tClone(int32 mode, BPoint point, uint32 buttons) { -// printf ("Top of tClone\n"); + // printf ("Top of tClone\n"); Position position; - GetPosition (&position); - extern AttribClone *tAttribClone; + GetPosition(&position); + extern AttribClone* tAttribClone; float Spacing = tAttribClone->getSpacing(); int _w = tAttribClone->getBrush()->Width(); int _h = tAttribClone->getBrush()->Height(); - float cx = _w/2; - float cy = _h/2; - extern AttribDraw *mAttribDraw; + float cx = _w / 2; + float cy = _h / 2; + extern AttribDraw* mAttribDraw; drawing_mode dm = mAttribDraw->getDrawingMode(); - drawView->SetDrawingMode (dm); - SetDrawingMode (dm); - SetupUndo (mode); - drawView->MovePenTo (point); - MovePenTo (point); - bbits = (uchar *) currentLayer()->Bits(); + drawView->SetDrawingMode(dm); + SetDrawingMode(dm); + SetupUndo(mode); + drawView->MovePenTo(point); + MovePenTo(point); + bbits = (uchar*)currentLayer()->Bits(); bbpr = currentLayer()->BytesPerRow(); - bbprl = bbpr/4; + bbprl = bbpr / 4; bwi = currentLayer()->Bounds().IntegerWidth(); bhi = currentLayer()->Bounds().IntegerHeight(); - extern Becasso *mainapp; - if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { + extern Becasso* mainapp; + if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { mainapp->setCCross(); fCC.offset.x = point.x - fCC.pos.x; fCC.offset.y = point.y - fCC.pos.y; } - if (buttons & B_PRIMARY_MOUSE_BUTTON) - { + if (buttons & B_PRIMARY_MOUSE_BUTTON) { if (mode == M_SELECT) mainapp->setSelect(); else mainapp->setCross(); - Brush *b = tAttribClone->getBrush(); - SView::setSnoozeTime (max_c (20 * b->Height() * b->Width(), 20000)); + Brush* b = tAttribClone->getBrush(); + SView::setSnoozeTime(max_c(20 * b->Height() * b->Width(), 20000)); int strength = position.fPressure; - + fCC.cx = cx; fCC.cy = cy; fCC.Spacing = Spacing; fCC.b = b; fCC.pstrength = strength; - - if (abs (strength) > fTreshold) - { - int32 h = b->Height(); // note: brush width/height is num pixels! + + if (abs(strength) > fTreshold) { + int32 h = b->Height(); // note: brush width/height is num pixels! int32 w = b->Width(); - uint8 *bd = b->Data(); + uint8* bd = b->Data(); int32 ch = currentLayer()->Bounds().IntegerHeight(); int32 cw = currentLayer()->Bounds().IntegerWidth(); - BBitmap *copy = new BBitmap (BRect (0, 0, w, h), B_RGB32); - tbits = (uint8 *) copy->Bits(); + BBitmap* copy = new BBitmap(BRect(0, 0, w, h), B_RGB32); + tbits = (uint8*)copy->Bits(); tbpr = copy->BytesPerRow(); twi = w - 1; thi = h - 1; - if (mode == M_SELECT) - { - } - else - { - // first, extract the cloned area into "copy" with alpha replaced by the brush values - uint32 *cbits = (uint32*) copy->Bits(); - uint32 *dbits = (uint32*) bbits; - uint32 cbprl = copy->BytesPerRow()/4; - int32 off_x = int32 (point.x + fCC.offset.x - w/2); - int32 off_y = int32 (point.y + fCC.offset.y - h/2); - for (int y = 0; y < h; y++) - { - for (int x = 0; x < w; x++) - { - cbits[y*cbprl + x] = (y + off_y <= ch && x + off_x <= cw && y + off_y >= 0 && x + off_x >= 0) ? - ((dbits[(y + off_y)*bbprl + x + off_x] & COLOR_MASK) | bd[y*w + x] << ALPHA_BPOS) : 0; -// (0xFF00FF00 & COLOR_MASK | bd[y*w + x] << ALPHA_BPOS) : 0; + if (mode == M_SELECT) { + } else { + // first, extract the cloned area into "copy" with alpha replaced by the brush + // values + uint32* cbits = (uint32*)copy->Bits(); + uint32* dbits = (uint32*)bbits; + uint32 cbprl = copy->BytesPerRow() / 4; + int32 off_x = int32(point.x + fCC.offset.x - w / 2); + int32 off_y = int32(point.y + fCC.offset.y - h / 2); + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + cbits[y * cbprl + x] = + (y + off_y <= ch && x + off_x <= cw && y + off_y >= 0 && x + off_x >= 0) + ? ((dbits[(y + off_y) * bbprl + x + off_x] & COLOR_MASK) | + bd[y * w + x] << ALPHA_BPOS) + : 0; + // (0xFF00FF00 & COLOR_MASK | bd[y*w + x] << + // ALPHA_BPOS) : 0; } } - + // next, add the copy back to the cursor position - FastAddWithAlpha (point.x - w/2, point.y - h/2, strength); + FastAddWithAlpha(point.x - w / 2, point.y - h / 2, strength); } delete copy; } @@ -349,299 +345,292 @@ void CanvasView::tClone (int32 mode, BPoint point, uint32 buttons) BPoint ctr; ctr.x = point.x + fCC.offset.x; ctr.y = point.y + fCC.offset.y; - SetLowColor (White); - SetHighColor (Black); - StrokeLine (BPoint (ctr.x - 1, ctr.y - 3), BPoint (ctr.x - 1, ctr.y + 3), B_SOLID_LOW); - StrokeLine (BPoint (ctr.x + 1, ctr.y - 3), BPoint (ctr.x + 1, ctr.y + 3), B_SOLID_LOW); - StrokeLine (BPoint (ctr.x - 3, ctr.y - 1), BPoint (ctr.x + 3, ctr.y - 1), B_SOLID_LOW); - StrokeLine (BPoint (ctr.x - 3, ctr.y + 1), BPoint (ctr.x + 3, ctr.y + 1), B_SOLID_LOW); - StrokeLine (BPoint (ctr.x - 3, ctr.y), BPoint (ctr.x + 3, ctr.y)); - StrokeLine (BPoint (ctr.x, ctr.y - 3), BPoint (ctr.x, ctr.y + 3)); + SetLowColor(White); + SetHighColor(Black); + StrokeLine(BPoint(ctr.x - 1, ctr.y - 3), BPoint(ctr.x - 1, ctr.y + 3), B_SOLID_LOW); + StrokeLine(BPoint(ctr.x + 1, ctr.y - 3), BPoint(ctr.x + 1, ctr.y + 3), B_SOLID_LOW); + StrokeLine(BPoint(ctr.x - 3, ctr.y - 1), BPoint(ctr.x + 3, ctr.y - 1), B_SOLID_LOW); + StrokeLine(BPoint(ctr.x - 3, ctr.y + 1), BPoint(ctr.x + 3, ctr.y + 1), B_SOLID_LOW); + StrokeLine(BPoint(ctr.x - 3, ctr.y), BPoint(ctr.x + 3, ctr.y)); + StrokeLine(BPoint(ctr.x, ctr.y - 3), BPoint(ctr.x, ctr.y + 3)); fCC.prevctr = ctr; } - + // For immediate feedback at the first click: - Invalidate (BRect (point.x - cx - 1, point.y - cy - 1, point.x + cx + 1, point.y + cy + 1)); + Invalidate(BRect(point.x - cx - 1, point.y - cy - 1, point.x + cx + 1, point.y + cy + 1)); fCC.pos = point; } - -void CanvasView::tCloneM (int32 mode, BPoint point, uint32 buttons, int strength, BPoint /*tilt*/) +void +CanvasView::tCloneM(int32 mode, BPoint point, uint32 buttons, int strength, BPoint /*tilt*/) { -// printf ("Top of tCloneM: (%.0f, %.0f), %i (%.3f, %.3f)\n", point.x, point.y, strength, tilt.x, tilt.y); + // printf ("Top of tCloneM: (%.0f, %.0f), %i (%.3f, %.3f)\n", point.x, point.y, strength, + // tilt.x, tilt.y); BPoint pos = fCC.pos; BPoint nextPos; float cx = fCC.cx; float cy = fCC.cy; float Spacing = fCC.Spacing; - Brush *b = fCC.b; + Brush* b = fCC.b; int pstrength = fCC.pstrength; - + register float dx = pos.x - point.x; register float dy = pos.y - point.y; - register float ds = dx*dx + dy*dy; - register float distance = sqrt (ds); - BRect aR = BRect (point.x - cx - 1, point.y - cy - 1, point.x + cx + 1, point.y + cy + 1); - BRect bR = BRect (pos.x - cx - 1, pos.y - cy - 1, pos.x + cx + 1, pos.y + cy + 1); - extern Becasso *mainapp; - if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { + register float ds = dx * dx + dy * dy; + register float distance = sqrt(ds); + BRect aR = BRect(point.x - cx - 1, point.y - cy - 1, point.x + cx + 1, point.y + cy + 1); + BRect bR = BRect(pos.x - cx - 1, pos.y - cy - 1, pos.x + cx + 1, pos.y + cy + 1); + extern Becasso* mainapp; + if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { mainapp->setCCross(); fCC.offset.x = point.x - fCC.pos.x; fCC.offset.y = point.y - fCC.pos.y; BPoint pos = PenLocation(); - BRect frame = PRect (pos.x, pos.y, point.x, point.y); - BRect pframe = PRect (pos.x, pos.y, fCC.pos.x, fCC.pos.y); + BRect frame = PRect(pos.x, pos.y, point.x, point.y); + BRect pframe = PRect(pos.x, pos.y, fCC.pos.x, fCC.pos.y); BRect tframe = frame | pframe; - Invalidate (tframe); - SetHighColor (Red); - StrokeLine (fCC.pos, point); + Invalidate(tframe); + SetHighColor(Red); + StrokeLine(fCC.pos, point); } - if (buttons & B_PRIMARY_MOUSE_BUTTON) - { + if (buttons & B_PRIMARY_MOUSE_BUTTON) { if (mode == M_SELECT) mainapp->setSelect(); else mainapp->setCross(); - if (distance > Spacing) - { + if (distance > Spacing) { clock_t start, end; start = clock(); - int32 h = b->Height(); // note: brush width/height is num pixels! + int32 h = b->Height(); // note: brush width/height is num pixels! int32 w = b->Width(); - uint8 *bd = b->Data(); + uint8* bd = b->Data(); int32 ch = currentLayer()->Bounds().IntegerHeight(); int32 cw = currentLayer()->Bounds().IntegerWidth(); - BBitmap *copy = new BBitmap (BRect (0, 0, w, h), B_RGB32); - tbits = (uint8 *) copy->Bits(); + BBitmap* copy = new BBitmap(BRect(0, 0, w, h), B_RGB32); + tbits = (uint8*)copy->Bits(); tbpr = copy->BytesPerRow(); twi = w - 1; thi = h - 1; - float num = distance/Spacing; - float facx = (point.x - pos.x)/num; - float facy = (point.y - pos.y)/num; - float facs = (strength - pstrength)/num; - for (float i = 1; i < num; i++) - { - nextPos = BPoint (pos.x + i*facx, pos.y + i*facy); - if (mode == M_SELECT) - { - } - else - { - // first, extract the cloned area into "copy" with alpha replaced by the brush values - uint32 *cbits = (uint32*) copy->Bits(); - uint32 *dbits = (uint32*) bbits; - uint32 cbprl = copy->BytesPerRow()/4; - int32 off_x = int32 (nextPos.x + fCC.offset.x - w/2); - int32 off_y = int32 (nextPos.y + fCC.offset.y - h/2); - for (int y = 0; y < h; y++) - { - for (int x = 0; x < w; x++) - { - cbits[y*cbprl + x] = (y + off_y <= ch && x + off_x <= cw && y + off_y >= 0 && x + off_x >= 0) ? - ((dbits[(y + off_y)*bbprl + x + off_x] & COLOR_MASK) | bd[y*w + x] << ALPHA_BPOS) : 0; -// (0xFF00FF00 & COLOR_MASK | bd[y*w + x] << ALPHA_BPOS) : 0; + float num = distance / Spacing; + float facx = (point.x - pos.x) / num; + float facy = (point.y - pos.y) / num; + float facs = (strength - pstrength) / num; + for (float i = 1; i < num; i++) { + nextPos = BPoint(pos.x + i * facx, pos.y + i * facy); + if (mode == M_SELECT) { + } else { + // first, extract the cloned area into "copy" with alpha replaced by the brush + // values + uint32* cbits = (uint32*)copy->Bits(); + uint32* dbits = (uint32*)bbits; + uint32 cbprl = copy->BytesPerRow() / 4; + int32 off_x = int32(nextPos.x + fCC.offset.x - w / 2); + int32 off_y = int32(nextPos.y + fCC.offset.y - h / 2); + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + cbits[y * cbprl + x] = + (y + off_y <= ch && x + off_x <= cw && y + off_y >= 0 && + x + off_x >= 0) + ? ((dbits[(y + off_y) * bbprl + x + off_x] & COLOR_MASK) | + bd[y * w + x] << ALPHA_BPOS) + : 0; + // (0xFF00FF00 & COLOR_MASK | bd[y*w + x] + //<< ALPHA_BPOS) : 0; } } - + // next, add the copy back to the cursor position - FastAddWithAlpha (nextPos.x - w/2, nextPos.y - h/2, int (pstrength + i*facs)); + FastAddWithAlpha( + nextPos.x - w / 2, nextPos.y - h / 2, int(pstrength + i * facs) + ); } } pos = nextPos; delete copy; - + // Draw a little cursor at the clone source spot BPoint ctr; ctr.x = point.x + fCC.offset.x; ctr.y = point.y + fCC.offset.y; - SetLowColor (White); - SetHighColor (Black); - Invalidate (BRect (fCC.prevctr.x - 3, fCC.prevctr.y - 3, fCC.prevctr.x + 3, fCC.prevctr.y + 3)); - StrokeLine (BPoint (ctr.x - 1, ctr.y - 3), BPoint (ctr.x - 1, ctr.y + 3), B_SOLID_LOW); - StrokeLine (BPoint (ctr.x + 1, ctr.y - 3), BPoint (ctr.x + 1, ctr.y + 3), B_SOLID_LOW); - StrokeLine (BPoint (ctr.x - 3, ctr.y - 1), BPoint (ctr.x + 3, ctr.y - 1), B_SOLID_LOW); - StrokeLine (BPoint (ctr.x - 3, ctr.y + 1), BPoint (ctr.x + 3, ctr.y + 1), B_SOLID_LOW); - StrokeLine (BPoint (ctr.x - 3, ctr.y), BPoint (ctr.x + 3, ctr.y)); - StrokeLine (BPoint (ctr.x, ctr.y - 3), BPoint (ctr.x, ctr.y + 3)); + SetLowColor(White); + SetHighColor(Black); + Invalidate( + BRect(fCC.prevctr.x - 3, fCC.prevctr.y - 3, fCC.prevctr.x + 3, fCC.prevctr.y + 3) + ); + StrokeLine(BPoint(ctr.x - 1, ctr.y - 3), BPoint(ctr.x - 1, ctr.y + 3), B_SOLID_LOW); + StrokeLine(BPoint(ctr.x + 1, ctr.y - 3), BPoint(ctr.x + 1, ctr.y + 3), B_SOLID_LOW); + StrokeLine(BPoint(ctr.x - 3, ctr.y - 1), BPoint(ctr.x + 3, ctr.y - 1), B_SOLID_LOW); + StrokeLine(BPoint(ctr.x - 3, ctr.y + 1), BPoint(ctr.x + 3, ctr.y + 1), B_SOLID_LOW); + StrokeLine(BPoint(ctr.x - 3, ctr.y), BPoint(ctr.x + 3, ctr.y)); + StrokeLine(BPoint(ctr.x, ctr.y - 3), BPoint(ctr.x, ctr.y + 3)); fCC.prevctr = ctr; - - Invalidate (aR | bR); -// DrawBitmap (currentLayer(), dirty, dirty); + + Invalidate(aR | bR); + // DrawBitmap (currentLayer(), dirty, dirty); end = clock(); extern int DebugLevel; if (DebugLevel > 7) - printf ("Clone Stroke took %ld ms\n", end - start); + printf("Clone Stroke took %ld ms\n", end - start); fCC.pos = pos; } } - ScrollIfNeeded (point); + ScrollIfNeeded(point); fCC.pstrength = strength; } - -void CanvasView::tTablet (int32 mode) +void +CanvasView::tTablet(int32 mode) { -// printf ("tTablet\n"); - extern Becasso *mainapp; + // printf ("tTablet\n"); + extern Becasso* mainapp; extern ColorMenuButton *hicolor, *locolor; - extern AttribBrush *tAttribBrush; - extern Tablet *wacom; - #if defined (USE_THREAD_FOR_POSITION) - extern port_id position_port; - thread_id position_thread = spawn_thread (position_tracker, "Position Tracker", B_DISPLAY_PRIORITY, this); - #endif - wacom->SetScale (fCanvasFrame.Width(), fCanvasFrame.Height()); - #if defined (USE_THREAD_FOR_POSITION) - resume_thread (position_thread); - #endif + extern AttribBrush* tAttribBrush; + extern Tablet* wacom; +#if defined(USE_THREAD_FOR_POSITION) + extern port_id position_port; + thread_id position_thread = + spawn_thread(position_tracker, "Position Tracker", B_DISPLAY_PRIORITY, this); +#endif + wacom->SetScale(fCanvasFrame.Width(), fCanvasFrame.Height()); +#if defined(USE_THREAD_FOR_POSITION) + resume_thread(position_thread); +#endif float Spacing = tAttribBrush->getSpacing(); int _w = tAttribBrush->getBrush()->Width(); int _h = tAttribBrush->getBrush()->Height(); - float cx = _w/2; - float cy = _h/2; - float borderx = max_c (cx + 1, 7); - float bordery = max_c (cy + 1, 7); -// Window()->Lock(); + float cx = _w / 2; + float cy = _h / 2; + float borderx = max_c(cx + 1, 7); + float bordery = max_c(cy + 1, 7); + // Window()->Lock(); currentLayer()->Lock(); selection->Lock(); - extern AttribDraw *mAttribDraw; + extern AttribDraw* mAttribDraw; drawing_mode dm = mAttribDraw->getDrawingMode(); - drawView->SetDrawingMode (dm); - //printf ("Setting up Undo\n"); - SetupUndo (mode); + drawView->SetDrawingMode(dm); + // printf ("Setting up Undo\n"); + SetupUndo(mode); Position position; - #if defined (USE_THREAD_FOR_POSITION) - int32 msg_code; - read_port (position_port, &msg_code, (void *) &position, sizeof (Position)); - #else - GetPosition (&position); - #endif +#if defined(USE_THREAD_FOR_POSITION) + int32 msg_code; + read_port(position_port, &msg_code, (void*)&position, sizeof(Position)); +#else + GetPosition(&position); +#endif BPoint point = position.fPoint; - drawView->MovePenTo (point); + drawView->MovePenTo(point); uint32 buttons = position.fButtons; int strength = position.fPressure; - MovePenTo (point); + MovePenTo(point); mainapp->HideCursor(); - if (buttons & B_PRIMARY_MOUSE_BUTTON) // Drawing + if (buttons & B_PRIMARY_MOUSE_BUTTON) // Drawing { - drawView->SetHighColor (hicolor->color()); - drawView->SetLowColor (locolor->color()); - SetHighColor (hicolor->color()); - SetLowColor (locolor->color()); + drawView->SetHighColor(hicolor->color()); + drawView->SetLowColor(locolor->color()); + SetHighColor(hicolor->color()); + SetLowColor(locolor->color()); } - if (buttons & B_SECONDARY_MOUSE_BUTTON) // Erasing + if (buttons & B_SECONDARY_MOUSE_BUTTON) // Erasing { - drawView->SetHighColor (locolor->color()); - drawView->SetLowColor (hicolor->color()); - SetHighColor (locolor->color()); - SetLowColor (hicolor->color()); + drawView->SetHighColor(locolor->color()); + drawView->SetLowColor(hicolor->color()); + SetHighColor(locolor->color()); + SetLowColor(hicolor->color()); strength = -strength; } - //printf ("Preparing brush\n"); - Brush *b = tAttribBrush->getBrush(); - BBitmap *brushbm = b->ToBitmap (HighColor()); - SView::setSnoozeTime (max_c (20 * b->Height() * b->Width(), 20000)); + // printf ("Preparing brush\n"); + Brush* b = tAttribBrush->getBrush(); + BBitmap* brushbm = b->ToBitmap(HighColor()); + SView::setSnoozeTime(max_c(20 * b->Height() * b->Width(), 20000)); twi = brushbm->Bounds().IntegerWidth(); thi = brushbm->Bounds().IntegerHeight(); bwi = fCanvasFrame.IntegerWidth(); bhi = fCanvasFrame.IntegerHeight(); -// uchar *bits = (uchar *) currentLayer()->Bits(); -// long bytesperrow = currentLayer()->BytesPerRow(); - tbits = (uchar *) brushbm->Bits(); + // uchar *bits = (uchar *) currentLayer()->Bits(); + // long bytesperrow = currentLayer()->BytesPerRow(); + tbits = (uchar*)brushbm->Bits(); tbpr = brushbm->BytesPerRow(); - bbits = (uchar *) currentLayer()->Bits(); + bbits = (uchar*)currentLayer()->Bits(); bbpr = currentLayer()->BytesPerRow(); - SetHighColor (Black); - SetDrawingMode (B_OP_INVERT); - SetScale (fScale); - StrokeLine (BPoint (point.x - 5, point.y), BPoint (point.x + 5, point.y)); - StrokeLine (BPoint (point.x, point.y - 5), BPoint (point.x, point.y + 5)); - SetScale (1); - SetDrawingMode (dm); - if (abs (strength) > 255*wacom->Threshold()) - { - if (mode == M_SELECT) - { - AddToSelection (b, selection, int (point.x - cx), int (point.y - cy), int (strength)); - } - else if (dm == B_OP_COPY || dm == B_OP_OVER) - { - FastAddWithAlpha (point.x - cx, point.y - cy, strength); - } - else - { - DrawBitmapAsync (brushbm, BPoint (point.x - cx, point.y - cy)); - drawView->DrawBitmap (brushbm, BPoint (point.x - cx, point.y - cy)); + SetHighColor(Black); + SetDrawingMode(B_OP_INVERT); + SetScale(fScale); + StrokeLine(BPoint(point.x - 5, point.y), BPoint(point.x + 5, point.y)); + StrokeLine(BPoint(point.x, point.y - 5), BPoint(point.x, point.y + 5)); + SetScale(1); + SetDrawingMode(dm); + if (abs(strength) > 255 * wacom->Threshold()) { + if (mode == M_SELECT) { + AddToSelection(b, selection, int(point.x - cx), int(point.y - cy), int(strength)); + } else if (dm == B_OP_COPY || dm == B_OP_OVER) { + FastAddWithAlpha(point.x - cx, point.y - cy, strength); + } else { + DrawBitmapAsync(brushbm, BPoint(point.x - cx, point.y - cy)); + drawView->DrawBitmap(brushbm, BPoint(point.x - cx, point.y - cy)); } } BPoint pos = point; BPoint nextPos; -// BRect frame = fCanvasFrame; + // BRect frame = fCanvasFrame; int pstrength = strength; bool proximity = true; // printf ("Entering loop\n"); - while (proximity && Window()->IsActive()) - { + while (proximity && Window()->IsActive()) { register float dx = pos.x - point.x; register float dy = pos.y - point.y; - register float ds = dx*dx + dy*dy; - register float distance = sqrt (ds); - BRect aR = BRect (point.x - borderx, point.y - bordery, point.x + borderx, point.y + bordery); - BRect bR = BRect (pos.x - borderx, pos.y - bordery, pos.x + borderx, pos.y + bordery); - if (distance > Spacing) - { - register float num = distance/Spacing; - register float facx = (point.x - pos.x)/num; - register float facy = (point.y - pos.y)/num; - register float facs = (strength - pstrength)/num; - for (float i = 1; i < num; i++) - { - nextPos = BPoint (pos.x + i*facx, pos.y + i*facy); - int str = int (strength + i*facs); - if (abs (str) > 255*wacom->Threshold()) - { - if (mode == M_SELECT) - { - AddToSelection (b, selection, int (nextPos.x - cx), int (nextPos.y - cy), int (strength)); - } - else if (dm == B_OP_COPY || dm == B_OP_OVER) - { - FastAddWithAlpha (int (nextPos.x - cx), int (nextPos.y - cy), int (pstrength + i*facs)); - } - else - { - DrawBitmapAsync (brushbm, BPoint (nextPos.x - cx, nextPos.y - cy)); - drawView->DrawBitmap (brushbm, BPoint (nextPos.x - cx, nextPos.y - cy)); + register float ds = dx * dx + dy * dy; + register float distance = sqrt(ds); + BRect aR = + BRect(point.x - borderx, point.y - bordery, point.x + borderx, point.y + bordery); + BRect bR = BRect(pos.x - borderx, pos.y - bordery, pos.x + borderx, pos.y + bordery); + if (distance > Spacing) { + register float num = distance / Spacing; + register float facx = (point.x - pos.x) / num; + register float facy = (point.y - pos.y) / num; + register float facs = (strength - pstrength) / num; + for (float i = 1; i < num; i++) { + nextPos = BPoint(pos.x + i * facx, pos.y + i * facy); + int str = int(strength + i * facs); + if (abs(str) > 255 * wacom->Threshold()) { + if (mode == M_SELECT) { + AddToSelection( + b, selection, int(nextPos.x - cx), int(nextPos.y - cy), int(strength) + ); + } else if (dm == B_OP_COPY || dm == B_OP_OVER) { + FastAddWithAlpha( + int(nextPos.x - cx), int(nextPos.y - cy), int(pstrength + i * facs) + ); + } else { + DrawBitmapAsync(brushbm, BPoint(nextPos.x - cx, nextPos.y - cy)); + drawView->DrawBitmap(brushbm, BPoint(nextPos.x - cx, nextPos.y - cy)); drawView->Sync(); selectionView->Sync(); } } } pos = nextPos; - Invalidate (aR | bR); - SetDrawingMode (B_OP_INVERT); - SetScale (fScale); - StrokeLine (BPoint (point.x - 5, point.y), BPoint (point.x + 5, point.y)); - StrokeLine (BPoint (point.x, point.y - 5), BPoint (point.x, point.y + 5)); - SetScale (1); - SetDrawingMode (dm); -// DrawBitmap (currentLayer(), dirty, dirty); + Invalidate(aR | bR); + SetDrawingMode(B_OP_INVERT); + SetScale(fScale); + StrokeLine(BPoint(point.x - 5, point.y), BPoint(point.x + 5, point.y)); + StrokeLine(BPoint(point.x, point.y - 5), BPoint(point.x, point.y + 5)); + SetScale(1); + SetDrawingMode(dm); + // DrawBitmap (currentLayer(), dirty, dirty); } Window()->Unlock(); - snooze (10000); + snooze(10000); Window()->Lock(); // We're not being good citizens, but Beatware's brush is faster... myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); - ScrollIfNeeded (point); - #if defined (USE_THREAD_FOR_POSITION) - read_port (position_port, &msg_code, (void *) &position, sizeof (Position)); - #else - GetPosition (&position); - #endif + ScrollIfNeeded(point); +#if defined(USE_THREAD_FOR_POSITION) + read_port(position_port, &msg_code, (void*)&position, sizeof(Position)); +#else + GetPosition(&position); +#endif point = position.fPoint; buttons = position.fButtons; pstrength = strength; @@ -659,236 +648,219 @@ void CanvasView::tTablet (int32 mode) } //////////////////////////// -#if defined (__POWERPC__) -# pragma optimization_level 1 +#if defined(__POWERPC__) +#pragma optimization_level 1 #endif -void CanvasView::tEraser (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tEraser(int32 mode, BPoint point, uint32 buttons) { -// clock_t start, end; - extern AttribEraser *tAttribEraser; + // clock_t start, end; + extern AttribEraser* tAttribEraser; Position position; int type = tAttribEraser->getType(); - SetupUndo (mode); + SetupUndo(mode); float h = tAttribEraser->getYSize(); float w = tAttribEraser->getXSize(); - BRect eraser = BRect (0, 0, w, h); - SetHighColor (Black); - SetLowColor (White); - drawView->SetLowColor (Transparent); - selectionView->SetLowColor (SELECT_NONE); - SetDrawingMode (B_OP_COPY); - drawView->SetDrawingMode (B_OP_COPY); - selectionView->SetDrawingMode (B_OP_COPY); - SetPenSize (1); - drawView->SetPenSize (0); - selectionView->SetPenSize (0); -// BRect frame = fCanvasFrame; - while (buttons) - { -// start = clock(); - eraser.OffsetTo (point.x - w/2, point.y - h/2); - switch (type) - { + BRect eraser = BRect(0, 0, w, h); + SetHighColor(Black); + SetLowColor(White); + drawView->SetLowColor(Transparent); + selectionView->SetLowColor(SELECT_NONE); + SetDrawingMode(B_OP_COPY); + drawView->SetDrawingMode(B_OP_COPY); + selectionView->SetDrawingMode(B_OP_COPY); + SetPenSize(1); + drawView->SetPenSize(0); + selectionView->SetPenSize(0); + // BRect frame = fCanvasFrame; + while (buttons) { + // start = clock(); + eraser.OffsetTo(point.x - w / 2, point.y - h / 2); + switch (type) { case ERASER_RECT: - if (mode == M_DRAW) - { - drawView->FillRect (eraser, B_SOLID_LOW); -// FillRect (eraser, B_SOLID_LOW); - } - else - selectionView->FillRect (eraser, B_SOLID_LOW); - /*S*/StrokeRect (eraser); + if (mode == M_DRAW) { + drawView->FillRect(eraser, B_SOLID_LOW); + // FillRect (eraser, B_SOLID_LOW); + } else + selectionView->FillRect(eraser, B_SOLID_LOW); + /*S*/ StrokeRect(eraser); break; case ERASER_ELLIPSE: - if (mode == M_DRAW) - { - drawView->FillEllipse (eraser, B_SOLID_LOW); -// FillEllipse (eraser, B_SOLID_LOW); - } - else - selectionView->FillEllipse (eraser, B_SOLID_LOW); - /*S*/StrokeEllipse (eraser); + if (mode == M_DRAW) { + drawView->FillEllipse(eraser, B_SOLID_LOW); + // FillEllipse (eraser, B_SOLID_LOW); + } else + selectionView->FillEllipse(eraser, B_SOLID_LOW); + /*S*/ StrokeEllipse(eraser); break; default: - fprintf (stderr, "Unknown Eraser type...\n"); + fprintf(stderr, "Unknown Eraser type...\n"); } drawView->Sync(); selectionView->Sync(); Sync(); - Invalidate (eraser); - snooze (20000); - ScrollIfNeeded (point); + Invalidate(eraser); + snooze(20000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); -// GetMouse (&point, &buttons, true); - GetPosition (&position); + // GetMouse (&point, &buttons, true); + GetPosition(&position); point = position.fPoint; buttons = position.fButtons; -// end = clock(); -// printf ("Took %d ms\n", end - start); + // end = clock(); + // printf ("Took %d ms\n", end - start); } Invalidate(); - Window()->UpdateIfNeeded (); + Window()->UpdateIfNeeded(); } -void CanvasView::tEraserM (int32 /* mode */, BPoint point) +void +CanvasView::tEraserM(int32 /* mode */, BPoint point) { - extern AttribEraser *tAttribEraser; + extern AttribEraser* tAttribEraser; int type = tAttribEraser->getType(); float h = tAttribEraser->getYSize(); float w = tAttribEraser->getXSize(); - BRect eraser = BRect (0, 0, w, h); - eraser.OffsetTo (point.x - w/2, point.y - h/2); - SetPenSize (1); - SetDrawingMode (B_OP_INVERT); - SetHighColor (Black); - Invalidate (prev_eraser | eraser); + BRect eraser = BRect(0, 0, w, h); + eraser.OffsetTo(point.x - w / 2, point.y - h / 2); + SetPenSize(1); + SetDrawingMode(B_OP_INVERT); + SetHighColor(Black); + Invalidate(prev_eraser | eraser); prev_eraser = eraser; Window()->UpdateIfNeeded(); - switch (type) - { + switch (type) { case ERASER_RECT: - /*S*/StrokeRect (eraser); + /*S*/ StrokeRect(eraser); break; case ERASER_ELLIPSE: - /*S*/StrokeEllipse (eraser); // THIS DOESN'T DO ANYTHING?! + /*S*/ StrokeEllipse(eraser); // THIS DOESN'T DO ANYTHING?! break; default: - fprintf (stderr, "Unknown Eraser type...\n"); + fprintf(stderr, "Unknown Eraser type...\n"); } } -void CanvasView::tText (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tText(int32 mode, BPoint point, uint32 buttons) { -#if defined (USE_OLD_TEXT_TOOL) +#if defined(USE_OLD_TEXT_TOOL) if (text) - return; // The old BTextControl is still there... - text = new BTextControl (BRect (point.x*fScale, point.y*fScale, point.x*fScale, point.y*fScale), "tTextControl", NULL, NULL, new BMessage ('tTed')); - extern AttribText *tAttribText; + return; // The old BTextControl is still there... + text = new BTextControl( + BRect(point.x * fScale, point.y * fScale, point.x * fScale, point.y * fScale), + "tTextControl", NULL, NULL, new BMessage('tTed') + ); + extern AttribText* tAttribText; extern ColorMenuButton *locolor, *hicolor; - SetupUndo (mode); - if (mode == M_DRAW) - { - if (fButtons & B_PRIMARY_MOUSE_BUTTON) - { - SetHighColor (hicolor->color()); - SetLowColor (locolor->color()); + SetupUndo(mode); + if (mode == M_DRAW) { + if (fButtons & B_PRIMARY_MOUSE_BUTTON) { + SetHighColor(hicolor->color()); + SetLowColor(locolor->color()); } - if (fButtons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { - SetHighColor (locolor->color()); - SetLowColor (hicolor->color()); + if (fButtons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { + SetHighColor(locolor->color()); + SetLowColor(hicolor->color()); } - } - else - { - SetHighColor (Black); - SetLowColor (White); + } else { + SetHighColor(Black); + SetLowColor(White); } BFont font = tAttribText->getFont(); - font.SetSpacing (B_BITMAP_SPACING); + font.SetSpacing(B_BITMAP_SPACING); fMode = mode; fButtons = buttons; fPoint = point; -// text->TextView()->SetScale (fScale); // Fix this once. + // text->TextView()->SetScale (fScale); // Fix this once. rgb_color hi = HighColor(); - text->TextView()->SetFontAndColor (&font, B_FONT_ALL, &hi); - text->TextView()->MakeResizable (true, text); + text->TextView()->SetFontAndColor(&font, B_FONT_ALL, &hi); + text->TextView()->MakeResizable(true, text); text->ResizeToPreferred(); - if (mode == M_DRAW) - { -// text->TextView()->SetHighColor (HighColor()); -// text->TextView()->SetLowColor (LowColor()); - } - else - { - text->TextView()->SetHighColor (Black); - text->TextView()->SetLowColor (White); + if (mode == M_DRAW) { + // text->TextView()->SetHighColor (HighColor()); + // text->TextView()->SetLowColor (LowColor()); + } else { + text->TextView()->SetHighColor(Black); + text->TextView()->SetLowColor(White); } float dx = -text->TextView()->TextRect().left - 3; float dy = text->TextView()->Bounds().top - text->TextView()->TextRect().bottom + 4; - text->MoveBy (dx, dy); - text->TextView()->SetTextRect (text->Bounds()); - AddChild (text); + text->MoveBy(dx, dy); + text->TextView()->SetTextRect(text->Bounds()); + AddChild(text); text->MakeFocus(); #else // New 2.0 text tool - extern AttribText *tAttribText; + extern AttribText* tAttribText; extern ColorMenuButton *locolor, *hicolor; - SetupUndo (mode); + SetupUndo(mode); -// drawing_mode dm = mAttribDraw->getDrawingMode(); + // drawing_mode dm = mAttribDraw->getDrawingMode(); BFont font = tAttribText->getFont(); - const char *text = tAttribText->getText(); - font.SetSpacing (B_BITMAP_SPACING); + const char* text = tAttribText->getText(); + font.SetSpacing(B_BITMAP_SPACING); // all of this is for multiline texts font_height fh; - font.GetHeight (&fh); + font.GetHeight(&fh); float height = fh.ascent + fh.descent + fh.leading; - float rot = font.Rotation()*M_PI/180.0; - float fx = height*sin(rot); - float fy = height*cos(rot); - - int len = strlen (text); - char *stext = strdup (text); // we poke zeroes in this string + float rot = font.Rotation() * M_PI / 180.0; + float fx = height * sin(rot); + float fy = height * cos(rot); + + int len = strlen(text); + char* stext = strdup(text); // we poke zeroes in this string int i = 0, j = 0; BPoint nextpoint = point; - if (mode == M_DRAW) - { - if (buttons & B_PRIMARY_MOUSE_BUTTON) - { - drawView->SetHighColor (hicolor->color()); - drawView->SetLowColor (locolor->color()); + if (mode == M_DRAW) { + if (buttons & B_PRIMARY_MOUSE_BUTTON) { + drawView->SetHighColor(hicolor->color()); + drawView->SetLowColor(locolor->color()); } - if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { - drawView->SetHighColor (locolor->color()); - drawView->SetLowColor (hicolor->color()); + if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { + drawView->SetHighColor(locolor->color()); + drawView->SetLowColor(hicolor->color()); } - drawView->SetDrawingMode (B_OP_OVER); - drawView->SetFont (&font); + drawView->SetDrawingMode(B_OP_OVER); + drawView->SetFont(&font); - while (i <= len) - { - if (stext[i] == '\n' || !stext[i]) - { + while (i <= len) { + if (stext[i] == '\n' || !stext[i]) { stext[i] = 0; - drawView->DrawString (stext + j, nextpoint); + drawView->DrawString(stext + j, nextpoint); j = i + 1; nextpoint.x += fx; nextpoint.y += fy; } i++; } - } - else - { + } else { // Yuk this is silly - but I'm afraid it's necessary. Sigh. // The reason is that selection maps are 8 bit, but you can't // set the HighColor by index directly. rgb_color c = hicolor->color(); - int value = 255 - int (0.5*c.green + 0.3*c.red + 0.2*c.blue + 0.5); - BBitmap *tempsel = new BBitmap (fCanvasFrame, B_RGBA32, true); - bzero (tempsel->Bits(), tempsel->BitsLength()); - BView *tempselView = new BView (fCanvasFrame, "Temp Selection View", uint32 (NULL), uint32 (NULL)); + int value = 255 - int(0.5 * c.green + 0.3 * c.red + 0.2 * c.blue + 0.5); + BBitmap* tempsel = new BBitmap(fCanvasFrame, B_RGBA32, true); + bzero(tempsel->Bits(), tempsel->BitsLength()); + BView* tempselView = + new BView(fCanvasFrame, "Temp Selection View", uint32(NULL), uint32(NULL)); tempsel->Lock(); - tempsel->AddChild (tempselView); - tempselView->SetHighColor (value, value, value); - tempselView->SetLowColor (Black); - tempselView->SetFont (&font); - tempselView->SetDrawingMode (B_OP_OVER); - while (i <= len) - { - if (stext[i] == '\n' || !stext[i]) - { + tempsel->AddChild(tempselView); + tempselView->SetHighColor(value, value, value); + tempselView->SetLowColor(Black); + tempselView->SetFont(&font); + tempselView->SetDrawingMode(B_OP_OVER); + while (i <= len) { + if (stext[i] == '\n' || !stext[i]) { stext[i] = 0; - tempselView->DrawString (stext + j, nextpoint); + tempselView->DrawString(stext + j, nextpoint); j = i + 1; nextpoint.x += fx; nextpoint.y += fy; @@ -896,23 +868,22 @@ void CanvasView::tText (int32 mode, BPoint point, uint32 buttons) i++; } tempselView->Sync(); - uint32 *tdata = ((uint32 *) tempsel->Bits()) - 1; - uchar *sdata = (uchar *) selection->Bits() - 1; + uint32* tdata = ((uint32*)tempsel->Bits()) - 1; + uchar* sdata = (uchar*)selection->Bits() - 1; ulong h = fCanvasFrame.IntegerHeight() + 1; ulong w = fCanvasFrame.IntegerWidth() + 1; int32 diff = selection->BytesPerRow() - w; - for (ulong i = 0; i < h; i++) - { + for (ulong i = 0; i < h; i++) { for (ulong j = 0; j < w; j++) - *sdata = clipchar (int (*(++sdata) + ((*(++tdata) >> 8) & 0xFF))); + *sdata = clipchar(int(*(++sdata) + ((*(++tdata) >> 8) & 0xFF))); sdata += diff; } - tempsel->RemoveChild (tempselView); + tempsel->RemoveChild(tempselView); delete tempselView; - delete tempsel; + delete tempsel; } - free (stext); + free(stext); drawView->Sync(); selectionView->Sync(); Invalidate(); @@ -920,121 +891,116 @@ void CanvasView::tText (int32 mode, BPoint point, uint32 buttons) #endif } -void CanvasView::tTextM (int32 mode, BPoint point) +void +CanvasView::tTextM(int32 mode, BPoint point) { - extern AttribText *tAttribText; - + extern AttribText* tAttribText; + extern ColorMenuButton *locolor, *hicolor; - - if (mode == M_DRAW) - { - SetHighColor (hicolor->color()); - SetLowColor (locolor->color()); - } - else - { - SetHighColor (Black); - SetLowColor (White); + + if (mode == M_DRAW) { + SetHighColor(hicolor->color()); + SetLowColor(locolor->color()); + } else { + SetHighColor(Black); + SetLowColor(White); } - + BFont font = tAttribText->getFont(); - const char *text = tAttribText->getText(); - - font.SetSpacing (B_BITMAP_SPACING); - + const char* text = tAttribText->getText(); + + font.SetSpacing(B_BITMAP_SPACING); + if (mode == M_DRAW) - SetDrawingMode (B_OP_OVER); + SetDrawingMode(B_OP_OVER); else - SetDrawingMode (B_OP_INVERT); - - SetFont (&font); + SetDrawingMode(B_OP_INVERT); + + SetFont(&font); // all of this is for multiline texts font_height fh; - font.GetHeight (&fh); + font.GetHeight(&fh); float height = fh.ascent + fh.descent + fh.leading; - float rot = font.Rotation()*M_PI/180.0; - float fx = height*sin(rot); - float fy = height*cos(rot); - - int len = strlen (text); - char *stext = strdup (text); // we poke zeroes in this string + float rot = font.Rotation() * M_PI / 180.0; + float fx = height * sin(rot); + float fy = height * cos(rot); + + int len = strlen(text); + char* stext = strdup(text); // we poke zeroes in this string int i = 0, j = 0; BPoint nextpoint = point; Invalidate(); - while (i <= len) - { - if (stext[i] == '\n' || !stext[i]) - { + while (i <= len) { + if (stext[i] == '\n' || !stext[i]) { stext[i] = 0; - DrawString (stext + j, nextpoint); + DrawString(stext + j, nextpoint); j = i + 1; nextpoint.x += fx; nextpoint.y += fy; } i++; } - free (stext); + free(stext); } -void CanvasView::tTextD () +void +CanvasView::tTextD() { -#if defined (USE_OLD_TEXT_TOOL) +#if defined(USE_OLD_TEXT_TOOL) // Note: This function gets called by CanvasWindow - hence all the locking. myWindow->Lock(); currentLayer()->Lock(); selection->Lock(); extern ColorMenuButton *locolor, *hicolor; - extern PicMenuButton *mode; - extern AttribText *tAttribText; - extern AttribDraw *mAttribDraw; + extern PicMenuButton* mode; + extern AttribText* tAttribText; + extern AttribDraw* mAttribDraw; myWindow->Lock(); int32 currentMode = mode->selected(); myWindow->Unlock(); BFont font = tAttribText->getFont(); - font.SetSpacing (B_BITMAP_SPACING); + font.SetSpacing(B_BITMAP_SPACING); drawing_mode dm = mAttribDraw->getDrawingMode(); - SetDrawingMode (dm); - drawView->SetDrawingMode (dm); - drawView->SetFont (&font); - if (currentMode == M_DRAW) - { - if (fButtons & B_PRIMARY_MOUSE_BUTTON) - { - drawView->SetHighColor (hicolor->color()); - drawView->SetLowColor (locolor->color()); - } - if (fButtons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { - drawView->SetHighColor (locolor->color()); - drawView->SetLowColor (hicolor->color()); - } - } - BPoint place = ConvertFromScreen (text->TextView()->ConvertToScreen ((text->TextView()->TextRect().LeftBottom()))); - place.x = (place.x + 7)/fScale; - place.y = (place.y - 7)/fScale; + SetDrawingMode(dm); + drawView->SetDrawingMode(dm); + drawView->SetFont(&font); + if (currentMode == M_DRAW) { + if (fButtons & B_PRIMARY_MOUSE_BUTTON) { + drawView->SetHighColor(hicolor->color()); + drawView->SetLowColor(locolor->color()); + } + if (fButtons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { + drawView->SetHighColor(locolor->color()); + drawView->SetLowColor(hicolor->color()); + } + } + BPoint place = ConvertFromScreen( + text->TextView()->ConvertToScreen((text->TextView()->TextRect().LeftBottom())) + ); + place.x = (place.x + 7) / fScale; + place.y = (place.y - 7) / fScale; // Oh, the joy of not having access to the anti-aliasing alpha data... - if (currentMode == M_DRAW) - { - if (dm == B_OP_COPY || dm == B_OP_BLEND) - { - BBitmap *tempsel = new BBitmap (fCanvasFrame, B_RGBA32, true); - bzero (tempsel->Bits(), tempsel->BitsLength()); - BView *tempselView = new BView (fCanvasFrame, "Temp Text View", uint32 (NULL), uint32 (NULL)); + if (currentMode == M_DRAW) { + if (dm == B_OP_COPY || dm == B_OP_BLEND) { + BBitmap* tempsel = new BBitmap(fCanvasFrame, B_RGBA32, true); + bzero(tempsel->Bits(), tempsel->BitsLength()); + BView* tempselView = + new BView(fCanvasFrame, "Temp Text View", uint32(NULL), uint32(NULL)); tempsel->Lock(); - tempsel->AddChild (tempselView); - tempselView->SetHighColor (White); - tempselView->SetLowColor (Black); - tempselView->SetFont (&font); - tempselView->SetDrawingMode (B_OP_OVER); - tempselView->DrawString (text->Text(), place); + tempsel->AddChild(tempselView); + tempselView->SetHighColor(White); + tempselView->SetLowColor(Black); + tempselView->SetFont(&font); + tempselView->SetDrawingMode(B_OP_OVER); + tempselView->DrawString(text->Text(), place); tempselView->Sync(); - uint32 *tdata = ((uint32 *) tempsel->Bits()) - 1; + uint32* tdata = ((uint32*)tempsel->Bits()) - 1; ulong h = fCanvasFrame.IntegerHeight() + 1; ulong w = fCanvasFrame.IntegerWidth() + 1; rgb_color c = drawView->HighColor(); -#if defined (__POWERPC__) +#if defined(__POWERPC__) uint32 pixel = (c.blue << 24) + (c.green << 16) + (c.red << 8); for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) @@ -1046,50 +1012,46 @@ void CanvasView::tTextD () *(tdata) = pixel | ((*(++tdata) << 8) & 0xFF000000); #endif if (dm == B_OP_COPY) - AddWithAlpha (tempsel, currentLayer(), 0, 0); + AddWithAlpha(tempsel, currentLayer(), 0, 0); else - BlendWithAlpha (tempsel, currentLayer(), 0, 0); - tempsel->RemoveChild (tempselView); + BlendWithAlpha(tempsel, currentLayer(), 0, 0); + tempsel->RemoveChild(tempselView); delete tempselView; - delete tempsel; - } - else - { - drawView->DrawString (text->Text(), place); - } - } - else - { - BBitmap *tempsel = new BBitmap (fCanvasFrame, B_RGBA32, true); - bzero (tempsel->Bits(), tempsel->BitsLength()); - BView *tempselView = new BView (fCanvasFrame, "Temp Selection View", uint32 (NULL), uint32 (NULL)); + delete tempsel; + } else { + drawView->DrawString(text->Text(), place); + } + } else { + BBitmap* tempsel = new BBitmap(fCanvasFrame, B_RGBA32, true); + bzero(tempsel->Bits(), tempsel->BitsLength()); + BView* tempselView = + new BView(fCanvasFrame, "Temp Selection View", uint32(NULL), uint32(NULL)); tempsel->Lock(); - tempsel->AddChild (tempselView); - tempselView->SetHighColor (White); - tempselView->SetLowColor (Black); - tempselView->SetFont (&font); - tempselView->SetDrawingMode (B_OP_OVER); - tempselView->DrawString (text->Text(), place); + tempsel->AddChild(tempselView); + tempselView->SetHighColor(White); + tempselView->SetLowColor(Black); + tempselView->SetFont(&font); + tempselView->SetDrawingMode(B_OP_OVER); + tempselView->DrawString(text->Text(), place); tempselView->Sync(); - uint32 *tdata = ((uint32 *) tempsel->Bits()) - 1; - uchar *sdata = (uchar *) selection->Bits() - 1; + uint32* tdata = ((uint32*)tempsel->Bits()) - 1; + uchar* sdata = (uchar*)selection->Bits() - 1; ulong h = fCanvasFrame.IntegerHeight() + 1; ulong w = fCanvasFrame.IntegerWidth() + 1; int32 diff = selection->BytesPerRow() - w; - for (ulong i = 0; i < h; i++) - { + for (ulong i = 0; i < h; i++) { for (ulong j = 0; j < w; j++) - *sdata = clipchar (int (*(++sdata) + ((*(++tdata) >> 8) & 0xFF))); + *sdata = clipchar(int(*(++sdata) + ((*(++tdata) >> 8) & 0xFF))); sdata += diff; } - tempsel->RemoveChild (tempselView); + tempsel->RemoveChild(tempselView); delete tempselView; - delete tempsel; + delete tempsel; } Sync(); drawView->Sync(); selectionView->Sync(); - RemoveChild (text); + RemoveChild(text); delete text; text = NULL; selection->Unlock(); @@ -1100,491 +1062,468 @@ void CanvasView::tTextD () #endif } -void CanvasView::tSpraycan (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tSpraycan(int32 mode, BPoint point, uint32 buttons) { extern ColorMenuButton *locolor, *hicolor; - extern AttribSpraycan *tAttribSpraycan; -// Position position; + extern AttribSpraycan* tAttribSpraycan; + // Position position; int strength = 0; - SetupUndo (mode); + SetupUndo(mode); float sigma = tAttribSpraycan->getSigma(); - float ssq = sigma*sigma; + float ssq = sigma * sigma; float color_ratio = tAttribSpraycan->getColorRatio(); float flowrate = tAttribSpraycan->getFlowRate(); bool lighten = tAttribSpraycan->getLighten(); - extern AttribDraw *mAttribDraw; + extern AttribDraw* mAttribDraw; drawing_mode dm = mAttribDraw->getDrawingMode(); - drawView->SetDrawingMode (dm); - SetDrawingMode (dm); - SetPenSize (0); - drawView->SetPenSize (0); - selectionView->SetPenSize (0); - MovePenTo (point); - drawView->MovePenTo (point); + drawView->SetDrawingMode(dm); + SetDrawingMode(dm); + SetPenSize(0); + drawView->SetPenSize(0); + selectionView->SetPenSize(0); + MovePenTo(point); + drawView->MovePenTo(point); if (mode == M_DRAW) - StrokeLine (point); // This fixes a _very_ strange bug... After drawing with another + StrokeLine(point); // This fixes a _very_ strange bug... After drawing with another // tool in a large pen size, it seemed no drawing took place to the canvas BView... (R3) - + rgb_color hi, lo, hit = Black, lot = Black; - if (buttons & B_PRIMARY_MOUSE_BUTTON) - { + if (buttons & B_PRIMARY_MOUSE_BUTTON) { BScreen screen; - hi = hicolor->color (); - lo = locolor->color (); -// selectionView->SetLowColor (SELECT_NONE); -// selectionView->SetHighColor (SELECT_FULL); - selectionView->SetLowColor (screen.ColorMap()->color_list[lo.alpha]); - selectionView->SetHighColor (screen.ColorMap()->color_list[hi.alpha]); - } - if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { + hi = hicolor->color(); + lo = locolor->color(); + // selectionView->SetLowColor (SELECT_NONE); + // selectionView->SetHighColor (SELECT_FULL); + selectionView->SetLowColor(screen.ColorMap()->color_list[lo.alpha]); + selectionView->SetHighColor(screen.ColorMap()->color_list[hi.alpha]); + } + if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { BScreen screen; - hi = locolor->color (); - lo = hicolor->color (); - selectionView->SetLowColor (screen.ColorMap()->color_list[hi.alpha]); - selectionView->SetHighColor (screen.ColorMap()->color_list[lo.alpha]); + hi = locolor->color(); + lo = hicolor->color(); + selectionView->SetLowColor(screen.ColorMap()->color_list[hi.alpha]); + selectionView->SetHighColor(screen.ColorMap()->color_list[lo.alpha]); } if (mode == M_SELECT) - drawView->SetDrawingMode (B_OP_INVERT); - else - { + drawView->SetDrawingMode(B_OP_INVERT); + else { // Setup parameters for fplot[_alpha] - sbptr = (uint32 *) currentLayer()->Bits(); - sblpr = currentLayer()->BytesPerRow()/4; + sbptr = (uint32*)currentLayer()->Bits(); + sblpr = currentLayer()->BytesPerRow() / 4; } - const color_map *cmap; + const color_map* cmap; { BScreen screen; cmap = screen.ColorMap(); } - + fSC.cmap = cmap; fSC.flowrate = flowrate; fSC.color_ratio = color_ratio; fSC.lighten = lighten; fSC.ssq = ssq; fSC.sigma = sigma; - fSC.hi = hi; fSC.lo = lo; - fSC.hit = hit; fSC.lot = lot; + fSC.hi = hi; + fSC.lo = lo; + fSC.hit = hit; + fSC.lot = lot; fSC.strength = strength; - -#if !defined (USE_MOUSEMOVED) - while (buttons) - { - for (int i = 0; i < (buttons & B_TERTIARY_MOUSE_BUTTON ? flowrate : flowrate*strength/255); i++) - { - float msigma = (buttons & B_TERTIARY_MOUSE_BUTTON ? sigma*strength/255 : sigma); - float r = frand()*msigma; - float phi = frand()*2*M_PI; - float rsq = r*r; - float gauss = exp (-rsq/ssq); - if (frand() < gauss || lighten) - { - float x = r*cos(phi); - float y = r*sin(phi); + +#if !defined(USE_MOUSEMOVED) + while (buttons) { + for (int i = 0; + i < (buttons & B_TERTIARY_MOUSE_BUTTON ? flowrate : flowrate * strength / 255); i++) { + float msigma = (buttons & B_TERTIARY_MOUSE_BUTTON ? sigma * strength / 255 : sigma); + float r = frand() * msigma; + float phi = frand() * 2 * M_PI; + float rsq = r * r; + float gauss = exp(-rsq / ssq); + if (frand() < gauss || lighten) { + float x = r * cos(phi); + float y = r * sin(phi); hit = hi; lot = lo; - if (lighten) - { -// float factor = 1 - gauss; -// hit.red += (255 - hit.red)*factor; -// hit.green += (255 - hit.green)*factor; -// hit.blue += (255 - hit.blue)*factor; -// lot.red += (255 - lot.red)*factor; -// lot.green += (255 - lot.green)*factor; -// lot.blue += (255 - lot.blue)*factor; - hit.alpha = uint8 (255*gauss); - lot.alpha = uint8 (255*gauss); + if (lighten) { + // float factor = 1 - gauss; + // hit.red += (255 - hit.red)*factor; + // hit.green += (255 - hit.green)*factor; + // hit.blue += (255 - hit.blue)*factor; + // lot.red += (255 - lot.red)*factor; + // lot.green += (255 - lot.green)*factor; + // lot.blue += (255 - lot.blue)*factor; + hit.alpha = uint8(255 * gauss); + lot.alpha = uint8(255 * gauss); } - BPoint p = BPoint (point.x + x, point.y + y); - //SetHighColor (hit); - //SetLowColor (lot); - if (mode == M_SELECT) - { - selectionView->SetHighColor (cmap->color_list[hit.alpha]); - selectionView->MovePenTo (p); - selectionView->StrokeLine (p); -// MovePenTo (p); -// StrokeLine (p); - } - else if (frand() > color_ratio) - { + BPoint p = BPoint(point.x + x, point.y + y); + // SetHighColor (hit); + // SetLowColor (lot); + if (mode == M_SELECT) { + selectionView->SetHighColor(cmap->color_list[hit.alpha]); + selectionView->MovePenTo(p); + selectionView->StrokeLine(p); + // MovePenTo (p); + // StrokeLine (p); + } else if (frand() > color_ratio) { if (lighten) - fplot_alpha (p, hit); + fplot_alpha(p, hit); else - fplot (p, hit); -// MovePenTo (p); -// StrokeLine (p); - } - else - { + fplot(p, hit); + // MovePenTo (p); + // StrokeLine (p); + } else { if (lighten) - fplot_alpha (p, lot); + fplot_alpha(p, lot); else - fplot (p, lot); -// MovePenTo (p); -// StrokeLine (p, B_SOLID_LOW); + fplot(p, lot); + // MovePenTo (p); + // StrokeLine (p, B_SOLID_LOW); } } } Sync(); drawView->Sync(); selectionView->Sync(); - Invalidate (BRect (point.x - 2*sigma, point.y - 2*sigma, point.x + 2*sigma, point.y + 2*sigma)); - Window()->UpdateIfNeeded (); + Invalidate(BRect( + point.x - 2 * sigma, point.y - 2 * sigma, point.x + 2 * sigma, point.y + 2 * sigma + )); + Window()->UpdateIfNeeded(); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); - ScrollIfNeeded (point); - snooze (20000); -// GetMouse (&point, &buttons, true); - GetPosition (&position); + ScrollIfNeeded(point); + snooze(20000); + // GetMouse (&point, &buttons, true); + GetPosition(&position); point = position.fPoint; buttons = position.fButtons; - strength = abs (position.fPressure); + strength = abs(position.fPressure); } - drawView->SetDrawingMode (dm); - Invalidate (); + drawView->SetDrawingMode(dm); + Invalidate(); #endif } -void CanvasView::tSpraycanM (int32 mode, BPoint point, uint32 buttons, int pressure, BPoint /*tilt*/) +void +CanvasView::tSpraycanM(int32 mode, BPoint point, uint32 buttons, int pressure, BPoint /*tilt*/) { - const color_map *cmap = fSC.cmap; + const color_map* cmap = fSC.cmap; float flowrate = fSC.flowrate; float color_ratio = fSC.color_ratio; bool lighten = fSC.lighten; float sigma = fSC.sigma; float ssq = fSC.ssq; rgb_color hi, lo, hit, lot; - hi = fSC.hi; lo = fSC.lo; - hit = fSC.hit; lot = fSC.lot; - int strength = pressure; //fSC.strength; + hi = fSC.hi; + lo = fSC.lo; + hit = fSC.hit; + lot = fSC.lot; + int strength = pressure; // fSC.strength; Position position; - + // make preference!! - for (int i = 0; i < (buttons & B_TERTIARY_MOUSE_BUTTON ? flowrate : flowrate*strength/255); i++) - { - float msigma = (buttons & B_TERTIARY_MOUSE_BUTTON ? sigma*strength/255 : sigma); - float r = frand()*msigma; - float phi = frand()*2*M_PI; - float rsq = r*r; - float gauss = exp (-rsq/ssq); - if (frand() < gauss || lighten) - { - float x = r*cos(phi); - float y = r*sin(phi); + for (int i = 0; i < (buttons & B_TERTIARY_MOUSE_BUTTON ? flowrate : flowrate * strength / 255); + i++) { + float msigma = (buttons & B_TERTIARY_MOUSE_BUTTON ? sigma * strength / 255 : sigma); + float r = frand() * msigma; + float phi = frand() * 2 * M_PI; + float rsq = r * r; + float gauss = exp(-rsq / ssq); + if (frand() < gauss || lighten) { + float x = r * cos(phi); + float y = r * sin(phi); hit = hi; lot = lo; - if (lighten) - { -// float factor = 1 - gauss; -// hit.red += (255 - hit.red)*factor; -// hit.green += (255 - hit.green)*factor; -// hit.blue += (255 - hit.blue)*factor; -// lot.red += (255 - lot.red)*factor; -// lot.green += (255 - lot.green)*factor; -// lot.blue += (255 - lot.blue)*factor; - hit.alpha = uint8 (255*gauss); - lot.alpha = uint8 (255*gauss); + if (lighten) { + // float factor = 1 - gauss; + // hit.red += (255 - hit.red)*factor; + // hit.green += (255 - hit.green)*factor; + // hit.blue += (255 - hit.blue)*factor; + // lot.red += (255 - lot.red)*factor; + // lot.green += (255 - lot.green)*factor; + // lot.blue += (255 - lot.blue)*factor; + hit.alpha = uint8(255 * gauss); + lot.alpha = uint8(255 * gauss); } - BPoint p = BPoint (point.x + x, point.y + y); - //SetHighColor (hit); - //SetLowColor (lot); - if (mode == M_SELECT) - { - selectionView->SetHighColor (cmap->color_list[hit.alpha]); - selectionView->MovePenTo (p); - selectionView->StrokeLine (p); -// MovePenTo (p); -// StrokeLine (p); - } - else if (frand() > color_ratio) - { + BPoint p = BPoint(point.x + x, point.y + y); + // SetHighColor (hit); + // SetLowColor (lot); + if (mode == M_SELECT) { + selectionView->SetHighColor(cmap->color_list[hit.alpha]); + selectionView->MovePenTo(p); + selectionView->StrokeLine(p); + // MovePenTo (p); + // StrokeLine (p); + } else if (frand() > color_ratio) { if (lighten) - fplot_alpha (p, hit); + fplot_alpha(p, hit); else - fplot (p, hit); -// MovePenTo (p); -// StrokeLine (p); - } - else - { + fplot(p, hit); + // MovePenTo (p); + // StrokeLine (p); + } else { if (lighten) - fplot_alpha (p, lot); + fplot_alpha(p, lot); else - fplot (p, lot); -// MovePenTo (p); -// StrokeLine (p, B_SOLID_LOW); + fplot(p, lot); + // MovePenTo (p); + // StrokeLine (p, B_SOLID_LOW); } } } Sync(); drawView->Sync(); selectionView->Sync(); - Invalidate (BRect (point.x - 2*sigma, point.y - 2*sigma, point.x + 2*sigma, point.y + 2*sigma)); - Window()->UpdateIfNeeded (); + Invalidate( + BRect(point.x - 2 * sigma, point.y - 2 * sigma, point.x + 2 * sigma, point.y + 2 * sigma) + ); + Window()->UpdateIfNeeded(); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); - ScrollIfNeeded (point); -// snooze (20000); -// GetMouse (&point, &buttons, true); - GetPosition (&position); + ScrollIfNeeded(point); + // snooze (20000); + // GetMouse (&point, &buttons, true); + GetPosition(&position); fSC.position = position; - fSC.strength = abs (position.fPressure); + fSC.strength = abs(position.fPressure); } -void CanvasView::tFreehand (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tFreehand(int32 mode, BPoint point, uint32 buttons) // Note: Support for singe-pixel editing is still not perfect! { - extern PatternMenuButton *pat; - extern AttribFreehand *tAttribFreehand; + extern PatternMenuButton* pat; + extern AttribFreehand* tAttribFreehand; Position position; - SetupUndo (mode); + SetupUndo(mode); float pensize = tAttribFreehand->getPenSize(); - extern AttribDraw *mAttribDraw; + extern AttribDraw* mAttribDraw; drawing_mode dm = mAttribDraw->getDrawingMode(); - drawView->SetDrawingMode (dm); - SetDrawingMode (dm); - point.x = int (point.x + 0.5); - point.y = int (point.y + 0.5); - drawView->MovePenTo (point); - selectionView->MovePenTo (point); - MovePenTo (point); - float halfpensize = int (pensize/2 - 0.5); - drawView->SetPenSize (pensize); - selectionView->SetPenSize (pensize); - drawView->SetLineMode (B_ROUND_CAP, B_ROUND_JOIN); - selectionView->SetLineMode (B_ROUND_CAP, B_ROUND_JOIN); - SetPenSize (pensize); + drawView->SetDrawingMode(dm); + SetDrawingMode(dm); + point.x = int(point.x + 0.5); + point.y = int(point.y + 0.5); + drawView->MovePenTo(point); + selectionView->MovePenTo(point); + MovePenTo(point); + float halfpensize = int(pensize / 2 - 0.5); + drawView->SetPenSize(pensize); + selectionView->SetPenSize(pensize); + drawView->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN); + selectionView->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN); + SetPenSize(pensize); pattern curpat = pat->pat(); - tSetColors (buttons); -// if (mode == M_SELECT) -// drawView->SetDrawingMode (B_OP_INVERT); -// BRect frame = fCanvasFrame; + tSetColors(buttons); + // if (mode == M_SELECT) + // drawView->SetDrawingMode (B_OP_INVERT); + // BRect frame = fCanvasFrame; BPoint prev = point; - while (buttons) - { + while (buttons) { BPoint p; - if (mode == M_DRAW) - { + if (mode == M_DRAW) { p = drawView->PenLocation(); - #if defined (FIX_STROKELINE_BUG) - if (halfpensize > 0.5 && point == prev) - drawView->FillEllipse (point, halfpensize, halfpensize, curpat); +#if defined(FIX_STROKELINE_BUG) + if (halfpensize > 0.5 && point == prev) + drawView->FillEllipse(point, halfpensize, halfpensize, curpat); else - #endif - drawView->StrokeLine (point, curpat); - } - else - { +#endif + drawView->StrokeLine(point, curpat); + } else { p = selectionView->PenLocation(); - #if defined (FIX_STROKELINE_BUG) +#if defined(FIX_STROKELINE_BUG) if (halfpensize > 0.5 && point == prev) - selectionView->FillEllipse (point, halfpensize, halfpensize, curpat); + selectionView->FillEllipse(point, halfpensize, halfpensize, curpat); else - #endif - selectionView->StrokeLine (point, curpat); +#endif + selectionView->StrokeLine(point, curpat); } - #if defined (FIX_STROKELINE_BUG) +#if defined(FIX_STROKELINE_BUG) if (halfpensize > 0.5 && point == prev) - FillEllipse (point, halfpensize, halfpensize, curpat); + FillEllipse(point, halfpensize, halfpensize, curpat); else - #endif - StrokeLine (point, curpat); +#endif + StrokeLine(point, curpat); Sync(); drawView->Sync(); selectionView->Sync(); - BRect r = PRect (p.x, p.y, point.x, point.y); - r.InsetBy (-halfpensize - 1, -halfpensize - 1); - Invalidate (r); - snooze (20000); - ScrollIfNeeded (point); + BRect r = PRect(p.x, p.y, point.x, point.y); + r.InsetBy(-halfpensize - 1, -halfpensize - 1); + Invalidate(r); + snooze(20000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); -// GetMouse (&point, &buttons, true); - GetPosition (&position); + // GetMouse (&point, &buttons, true); + GetPosition(&position); prev = point; point = position.fPoint; buttons = position.fButtons; } -/* -#if defined (FIX_STROKELINE_BUG) - if (prev == point && halfpensize > 0.5) // Fixes R4 bug? - { - point.x += 0.1; - point.y += 0.1; - if (mode == M_DRAW) - { - drawView->FillEllipse (point, halfpensize, halfpensize, curpat); - } - else + /* + #if defined (FIX_STROKELINE_BUG) + if (prev == point && halfpensize > 0.5) // Fixes R4 bug? { - selectionView->FillEllipse (point, halfpensize, halfpensize, curpat); + point.x += 0.1; + point.y += 0.1; + if (mode == M_DRAW) + { + drawView->FillEllipse (point, halfpensize, halfpensize, curpat); + } + else + { + selectionView->FillEllipse (point, halfpensize, halfpensize, curpat); + } } - } -#endif -*/ + #endif + */ Invalidate(); } -void CanvasView::tLines (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tLines(int32 mode, BPoint point, uint32 buttons) { - extern PatternMenuButton *pat; - extern AttribLines *tAttribLines; - extern AttribDraw *mAttribDraw; + extern PatternMenuButton* pat; + extern AttribLines* tAttribLines; + extern AttribDraw* mAttribDraw; Position position; drawing_mode dm = mAttribDraw->getDrawingMode(); - drawView->SetDrawingMode (dm); - selectionView->SetDrawingMode (dm); - SetDrawingMode (dm); + drawView->SetDrawingMode(dm); + selectionView->SetDrawingMode(dm); + SetDrawingMode(dm); float pensize = tAttribLines->getPenSize(); - float halfpensize = int (pensize/2 - 0.5); + float halfpensize = int(pensize / 2 - 0.5); bool fillcorners = tAttribLines->fillCorners(); - if (fillcorners) - { - drawView->SetLineMode (B_ROUND_CAP, B_ROUND_JOIN); - selectionView->SetLineMode (B_ROUND_CAP, B_ROUND_JOIN); - } - else - { - drawView->SetLineMode (B_BUTT_CAP, B_MITER_JOIN); - selectionView->SetLineMode (B_BUTT_CAP, B_MITER_JOIN); - } - drawView->SetPenSize (pensize); - selectionView->SetPenSize (pensize); - SetPenSize (pensize); + if (fillcorners) { + drawView->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN); + selectionView->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN); + } else { + drawView->SetLineMode(B_BUTT_CAP, B_MITER_JOIN); + selectionView->SetLineMode(B_BUTT_CAP, B_MITER_JOIN); + } + drawView->SetPenSize(pensize); + selectionView->SetPenSize(pensize); + SetPenSize(pensize); pattern curpat = pat->pat(); - tSetColors (buttons); - if (!entry) - { + tSetColors(buttons); + if (!entry) { BPoint pos = point; BPoint prev = point; fLastCenter = point; -// BRect frame = fCanvasFrame; - SetupUndo (mode); - while (buttons) - { + // BRect frame = fCanvasFrame; + SetupUndo(mode); + while (buttons) { BRect frame, pframe, tframe; - if (point != prev) - { - frame.Set (pos.x, pos.y, point.x, point.y); - pframe.Set (pos.x, pos.y, prev.x, prev.y); - frame = makePositive (frame); - pframe = makePositive (pframe); + if (point != prev) { + frame.Set(pos.x, pos.y, point.x, point.y); + pframe.Set(pos.x, pos.y, prev.x, prev.y); + frame = makePositive(frame); + pframe = makePositive(pframe); tframe = frame | pframe; - tframe.InsetBy (-halfpensize - 1, -halfpensize - 1); + tframe.InsetBy(-halfpensize - 1, -halfpensize - 1); currentLayer()->Lock(); selection->Lock(); - if (mode == M_DRAW) - { - //drawView->SetDrawingMode (B_OP_COPY); - //drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); - //drawView->SetDrawingMode (dm); - //drawView->Sync(); - SBitmapToLayer (undo[indexUndo].bitmap, currentLayer(), tframe); -// if (fillcorners) -// { -// drawView->FillEllipse (pos, halfpensize, halfpensize, curpat); -// drawView->FillEllipse (point, halfpensize, halfpensize, curpat); -// } - drawView->StrokeLine (pos, point, curpat); - } - else - { -// selectionView->SetDrawingMode (B_OP_COPY); -// selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); -// drawView->SetDrawingMode (dm); -// selectionView->Sync(); - SBitmapToSelection (undo[indexUndo].sbitmap, selection, tframe); -// if (fillcorners) -// { -// selectionView->FillEllipse (pos, halfpensize, halfpensize, curpat); -// selectionView->FillEllipse (point, halfpensize, halfpensize, curpat); -// } - selectionView->StrokeLine (pos, point, curpat); + if (mode == M_DRAW) { + // drawView->SetDrawingMode (B_OP_COPY); + // drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); + // drawView->SetDrawingMode (dm); + // drawView->Sync(); + SBitmapToLayer(undo[indexUndo].bitmap, currentLayer(), tframe); + // if (fillcorners) + // { + // drawView->FillEllipse (pos, halfpensize, halfpensize, + // curpat); drawView->FillEllipse (point, halfpensize, + // halfpensize, curpat); + // } + drawView->StrokeLine(pos, point, curpat); + } else { + // selectionView->SetDrawingMode (B_OP_COPY); + // selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, + // tframe); drawView->SetDrawingMode (dm); + // selectionView->Sync(); + SBitmapToSelection(undo[indexUndo].sbitmap, selection, tframe); + // if (fillcorners) + // { + // selectionView->FillEllipse (pos, halfpensize, + // halfpensize, curpat); selectionView->FillEllipse + // (point, halfpensize, halfpensize, curpat); + // } + selectionView->StrokeLine(pos, point, curpat); } drawView->Sync(); selectionView->Sync(); selection->Unlock(); currentLayer()->Unlock(); - Invalidate (tframe); + Invalidate(tframe); } - snooze (20000); - ScrollIfNeeded (point); + snooze(20000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); prev = point; -// GetMouse (&point, &buttons, true); - GetPosition (&position); + // GetMouse (&point, &buttons, true); + GetPosition(&position); point = position.fPoint; buttons = position.fButtons; } - if (point == pos) - { - MovePenTo (pos); + if (point == pos) { + MovePenTo(pos); Sync(); entry++; - } - else - { - if (mode == M_DRAW) - { - memcpy (currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), currentLayer()->BitsLength()); -// if (fillcorners) -// { -// drawView->FillEllipse (pos, halfpensize, halfpensize, curpat); -// drawView->FillEllipse (point, halfpensize, halfpensize, curpat); -// } - drawView->StrokeLine (pos, point, curpat); + } else { + if (mode == M_DRAW) { + memcpy( + currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), + currentLayer()->BitsLength() + ); + // if (fillcorners) + // { + // drawView->FillEllipse (pos, halfpensize, halfpensize, curpat); + // drawView->FillEllipse (point, halfpensize, halfpensize, curpat); + // } + drawView->StrokeLine(pos, point, curpat); + } else { + memcpy(selection->Bits(), undo[indexUndo].sbitmap->Bits(), selection->BitsLength()); + // if (fillcorners) + // { + // selectionView->FillEllipse (pos, halfpensize, halfpensize, + // curpat); selectionView->FillEllipse (point, halfpensize, + // halfpensize, curpat); + // } + selectionView->StrokeLine(pos, point, curpat); } - else - { - memcpy (selection->Bits(), undo[indexUndo].sbitmap->Bits(), selection->BitsLength()); -// if (fillcorners) -// { -// selectionView->FillEllipse (pos, halfpensize, halfpensize, curpat); -// selectionView->FillEllipse (point, halfpensize, halfpensize, curpat); -// } - selectionView->StrokeLine (pos, point, curpat); - } - } - } - else if (!(buttons & B_TERTIARY_MOUSE_BUTTON)) - { - if (mode == M_DRAW) - { - memcpy (currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), currentLayer()->BitsLength()); -// if (fillcorners) -// { -// drawView->FillEllipse (PenLocation(), halfpensize, halfpensize, curpat); -// drawView->FillEllipse (point, halfpensize, halfpensize, curpat); -// } - drawView->StrokeLine (PenLocation(), point, curpat); } - else - { - memcpy (selection->Bits(), undo[indexUndo].sbitmap->Bits(), selection->BitsLength()); -// if (fillcorners) -// { -// selectionView->FillEllipse (PenLocation(), halfpensize, halfpensize, curpat); -// selectionView->FillEllipse (point, halfpensize, halfpensize, curpat); -// } - selectionView->StrokeLine (PenLocation(), point, curpat); + } else if (!(buttons & B_TERTIARY_MOUSE_BUTTON)) { + if (mode == M_DRAW) { + memcpy( + currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), currentLayer()->BitsLength() + ); + // if (fillcorners) + // { + // drawView->FillEllipse (PenLocation(), halfpensize, halfpensize, curpat); + // drawView->FillEllipse (point, halfpensize, halfpensize, curpat); + // } + drawView->StrokeLine(PenLocation(), point, curpat); + } else { + memcpy(selection->Bits(), undo[indexUndo].sbitmap->Bits(), selection->BitsLength()); + // if (fillcorners) + // { + // selectionView->FillEllipse (PenLocation(), halfpensize, halfpensize, + // curpat); selectionView->FillEllipse (point, halfpensize, halfpensize, + // curpat); + // } + selectionView->StrokeLine(PenLocation(), point, curpat); } entry++; - MovePenTo (point); + MovePenTo(point); drawView->Sync(); selectionView->Sync(); - SetupUndo (mode); - } - else - { + SetupUndo(mode); + } else { entry = 0; - myWindow->posview->SetPoint (-1, -1); + myWindow->posview->SetPoint(-1, -1); } selectionView->Sync(); drawView->Sync(); @@ -1593,131 +1532,124 @@ void CanvasView::tLines (int32 mode, BPoint point, uint32 buttons) Window()->UpdateIfNeeded(); } -void CanvasView::tLinesM (int32 mode, BPoint point) +void +CanvasView::tLinesM(int32 mode, BPoint point) { - if (entry && mouse_on_canvas) - { - extern AttribLines *tAttribLines; - extern PatternMenuButton *pat; + if (entry && mouse_on_canvas) { + extern AttribLines* tAttribLines; + extern PatternMenuButton* pat; pattern curpat = pat->pat(); float pensize = tAttribLines->getPenSize(); - float halfpensize = int (pensize/2 - 0.5); + float halfpensize = int(pensize / 2 - 0.5); currentLayer()->Lock(); selection->Lock(); - SetPenSize (pensize); - drawView->SetPenSize (pensize); - selectionView->SetPenSize (pensize); + SetPenSize(pensize); + drawView->SetPenSize(pensize); + selectionView->SetPenSize(pensize); BPoint pos = PenLocation(); - BRect frame = PRect (pos.x, pos.y, point.x, point.y); - BRect pframe = PRect (pos.x, pos.y, prev.x, prev.y); + BRect frame = PRect(pos.x, pos.y, point.x, point.y); + BRect pframe = PRect(pos.x, pos.y, prev.x, prev.y); BRect tframe = frame | pframe; - tframe.InsetBy (-halfpensize - 1, -halfpensize - 1); - if (mode == M_DRAW) - { + tframe.InsetBy(-halfpensize - 1, -halfpensize - 1); + if (mode == M_DRAW) { if (tAttribLines->fillCorners() && entry == 1) - drawView->SetLineMode (B_ROUND_CAP, B_ROUND_JOIN); + drawView->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN); else - drawView->SetLineMode (B_BUTT_CAP, B_MITER_JOIN); -// drawView->FillEllipse (pos, halfpensize, halfpensize, curpat); - drawView->StrokeLine (pos, point, curpat); - } - else - { + drawView->SetLineMode(B_BUTT_CAP, B_MITER_JOIN); + // drawView->FillEllipse (pos, halfpensize, halfpensize, curpat); + drawView->StrokeLine(pos, point, curpat); + } else { if (tAttribLines->fillCorners() && entry == 1) - selectionView->SetLineMode (B_ROUND_CAP, B_ROUND_JOIN); + selectionView->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN); else - selectionView->SetLineMode (B_BUTT_CAP, B_MITER_JOIN); -// selectionView->FillEllipse (pos, halfpensize, halfpensize, curpat); - selectionView->StrokeLine (pos, point, curpat); + selectionView->SetLineMode(B_BUTT_CAP, B_MITER_JOIN); + // selectionView->FillEllipse (pos, halfpensize, halfpensize, curpat); + selectionView->StrokeLine(pos, point, curpat); } -// drawView->MovePenTo (pos); -// selectionView->MovePenTo (pos); + // drawView->MovePenTo (pos); + // selectionView->MovePenTo (pos); drawView->Sync(); selectionView->Sync(); - Invalidate (tframe); + Invalidate(tframe); if (mode == M_DRAW) // drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); - SBitmapToLayer (undo[indexUndo].bitmap, currentLayer(), tframe); + SBitmapToLayer(undo[indexUndo].bitmap, currentLayer(), tframe); else // selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); - SBitmapToSelection (undo[indexUndo].sbitmap, selection, tframe); + SBitmapToSelection(undo[indexUndo].sbitmap, selection, tframe); currentLayer()->Unlock(); selection->Unlock(); prev = point; } } -void CanvasView::tPolyblob (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tPolyblob(int32 mode, BPoint point, uint32 buttons) { - extern PatternMenuButton *pat; - extern AttribPolyblob *tAttribPolyblob; + extern PatternMenuButton* pat; + extern AttribPolyblob* tAttribPolyblob; float pensize = tAttribPolyblob->getPenSize(); - extern AttribDraw *mAttribDraw; + extern AttribDraw* mAttribDraw; Position position; drawing_mode dm = mAttribDraw->getDrawingMode(); - drawView->SetDrawingMode (dm); - SetDrawingMode (dm); - drawView->MovePenTo (point); -// MovePenTo (BPoint (point.x*fScale, point.y*fScale)); - MovePenTo (BPoint (point.x, point.y)); -// float halfpensize = int (pensize/2 - 0.5); - drawView->SetPenSize (pensize); - selectionView->SetPenSize (pensize); - SetPenSize (pensize); + drawView->SetDrawingMode(dm); + SetDrawingMode(dm); + drawView->MovePenTo(point); + // MovePenTo (BPoint (point.x*fScale, point.y*fScale)); + MovePenTo(BPoint(point.x, point.y)); + // float halfpensize = int (pensize/2 - 0.5); + drawView->SetPenSize(pensize); + selectionView->SetPenSize(pensize); + SetPenSize(pensize); pattern curpat = pat->pat(); - tSetColors (buttons); - SetupUndo (mode); - delete polygon; // Pity there isn't a BPolygon::Reset or ::Clear or whatever... - polygon = new BPolygon (); + tSetColors(buttons); + SetupUndo(mode); + delete polygon; // Pity there isn't a BPolygon::Reset or ::Clear or whatever... + polygon = new BPolygon(); if (mode == M_SELECT) - SetDrawingMode (B_OP_INVERT); -// BRect frame = fCanvasFrame; - while (buttons) - { - polygon->AddPoints (&point, 1); -// StrokeLine (BPoint (point.x*fScale, point.y*fScale)); - StrokeLine (BPoint (point.x, point.y)); -// Sync(); // This doesn't help. You will see dots when scrolling. Strange. -// Another strange thing, by the way, happens when the lot gets invalidated when there -// was some scrolling. This doesn't redraw correctly, apparently. - snooze (20000); - ScrollIfNeeded (point); + SetDrawingMode(B_OP_INVERT); + // BRect frame = fCanvasFrame; + while (buttons) { + polygon->AddPoints(&point, 1); + // StrokeLine (BPoint (point.x*fScale, point.y*fScale)); + StrokeLine(BPoint(point.x, point.y)); + // Sync(); // This doesn't help. You will see dots when scrolling. Strange. + // Another strange thing, by the way, happens when the lot gets invalidated when there + // was some scrolling. This doesn't redraw correctly, apparently. + snooze(20000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); -// GetMouse (&point, &buttons, true); - GetPosition (&position); + // GetMouse (&point, &buttons, true); + GetPosition(&position); point = position.fPoint; buttons = position.fButtons; } - switch (tAttribPolyblob->getType()) - { + switch (tAttribPolyblob->getType()) { case POLYBLOB_OUTLINE: if (mode == M_DRAW) - drawView->StrokePolygon (polygon, true, curpat); + drawView->StrokePolygon(polygon, true, curpat); else - selectionView->StrokePolygon (polygon, true, curpat); + selectionView->StrokePolygon(polygon, true, curpat); break; case POLYBLOB_FILL: if (mode == M_DRAW) - drawView->FillPolygon (polygon, curpat); + drawView->FillPolygon(polygon, curpat); else - selectionView->FillPolygon (polygon, curpat); + selectionView->FillPolygon(polygon, curpat); break; case POLYBLOB_OUTFILL: - if (mode == M_DRAW) - { - drawView->FillPolygon (polygon, curpat); - drawView->StrokePolygon (polygon); - } - else - { - selectionView->FillPolygon (polygon, curpat); - selectionView->StrokePolygon (polygon); + if (mode == M_DRAW) { + drawView->FillPolygon(polygon, curpat); + drawView->StrokePolygon(polygon); + } else { + selectionView->FillPolygon(polygon, curpat); + selectionView->StrokePolygon(polygon); } break; default: - fprintf (stderr, "Unknown Free Shape type...\n"); + fprintf(stderr, "Unknown Free Shape type...\n"); } selectionView->Sync(); drawView->Sync(); @@ -1725,103 +1657,94 @@ void CanvasView::tPolyblob (int32 mode, BPoint point, uint32 buttons) Invalidate(); } -void CanvasView::tPolygon (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tPolygon(int32 mode, BPoint point, uint32 buttons) // Add points with one mouse button, close with the other. // Yes, I know this isn't consistent with the rest. Got any better ideas? // Note: Added 13 Oct 98: Closing with tertiary mouse button. { - extern PatternMenuButton *pat; - extern AttribPolygon *tAttribPolygon; - extern AttribDraw *mAttribDraw; + extern PatternMenuButton* pat; + extern AttribPolygon* tAttribPolygon; + extern AttribDraw* mAttribDraw; drawing_mode dm = mAttribDraw->getDrawingMode(); - drawView->SetDrawingMode (dm); - SetDrawingMode (dm); + drawView->SetDrawingMode(dm); + SetDrawingMode(dm); float pensize = tAttribPolygon->getPenSize(); - drawView->MovePenTo (point); - MovePenTo (BPoint (point.x*fScale, point.y*fScale)); -// float halfpensize = int (pensize/2 - 0.5); - drawView->SetPenSize (pensize); - selectionView->SetPenSize (pensize); - SetPenSize (pensize); + drawView->MovePenTo(point); + MovePenTo(BPoint(point.x * fScale, point.y * fScale)); + // float halfpensize = int (pensize/2 - 0.5); + drawView->SetPenSize(pensize); + selectionView->SetPenSize(pensize); + SetPenSize(pensize); pattern curpat = pat->pat(); if (leftfirst) - tSetColors (B_PRIMARY_MOUSE_BUTTON); + tSetColors(B_PRIMARY_MOUSE_BUTTON); else - tSetColors (B_SECONDARY_MOUSE_BUTTON); - if (!entry) - { + tSetColors(B_SECONDARY_MOUSE_BUTTON); + if (!entry) { if (buttons & B_PRIMARY_MOUSE_BUTTON) leftfirst = true; if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) leftfirst = false; } if (mode == M_SELECT) - SetDrawingMode (B_OP_INVERT); - if (!entry) - { - delete polygon; // There should be a more elegant way of clearing an old BPolygon. - polygon = new BPolygon (&point, 1); - polypoint = point; // This is a hack. Apparently, a 2-point BPolygon can't be - // drawn, so this is for tPolygonM(). + SetDrawingMode(B_OP_INVERT); + if (!entry) { + delete polygon; // There should be a more elegant way of clearing an old BPolygon. + polygon = new BPolygon(&point, 1); + polypoint = point; // This is a hack. Apparently, a 2-point BPolygon can't be + // drawn, so this is for tPolygonM(). entry = 1; - } - else - { - if ((leftfirst && (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY)) - || (!leftfirst && (buttons & B_PRIMARY_MOUSE_BUTTON)) - || (buttons & B_TERTIARY_MOUSE_BUTTON)) // Polygon closed + } else { + if ((leftfirst && (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY)) || + (!leftfirst && (buttons & B_PRIMARY_MOUSE_BUTTON)) || + (buttons & B_TERTIARY_MOUSE_BUTTON)) // Polygon closed { - SetupUndo (mode); - switch (tAttribPolygon->getType()) - { + SetupUndo(mode); + switch (tAttribPolygon->getType()) { case POLYGON_OUTLINE: if (mode == M_DRAW) - drawView->StrokePolygon (polygon, true, curpat); + drawView->StrokePolygon(polygon, true, curpat); else - selectionView->StrokePolygon (polygon, true, curpat); + selectionView->StrokePolygon(polygon, true, curpat); break; case POLYGON_FILL: if (mode == M_DRAW) - drawView->FillPolygon (polygon, curpat); + drawView->FillPolygon(polygon, curpat); else - selectionView->StrokePolygon (polygon, true, curpat); + selectionView->StrokePolygon(polygon, true, curpat); break; case POLYGON_OUTFILL: - if (mode == M_DRAW) - { - drawView->FillPolygon (polygon, curpat); - drawView->StrokePolygon (polygon); - } - else - { - selectionView->FillPolygon (polygon, curpat); - selectionView->StrokePolygon (polygon); + if (mode == M_DRAW) { + drawView->FillPolygon(polygon, curpat); + drawView->StrokePolygon(polygon); + } else { + selectionView->FillPolygon(polygon, curpat); + selectionView->StrokePolygon(polygon); } break; default: - fprintf (stderr, "Unknown Polygon type...\n"); + fprintf(stderr, "Unknown Polygon type...\n"); } Sync(); selectionView->Sync(); drawView->Sync(); Invalidate(); entry = 0; - myWindow->posview->SetPoint (-1, -1); - } - else - { - polygon->AddPoints (&point, 1); + myWindow->posview->SetPoint(-1, -1); + } else { + polygon->AddPoints(&point, 1); Sync(); myWindow->Lock(); - Draw (fCanvasFrame); + Draw(fCanvasFrame); myWindow->Unlock(); -// SetScale (fScale); - StrokePolygon (polygon, false, curpat); + // SetScale (fScale); + StrokePolygon(polygon, false, curpat); if (entry == 1) - StrokeLine (polypoint, point, curpat); - snooze (20000); + StrokeLine(polypoint, point, curpat); + snooze(20000); Sync(); -// SetScale (1); + // SetScale (1); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); @@ -1830,955 +1753,964 @@ void CanvasView::tPolygon (int32 mode, BPoint point, uint32 buttons) } } -void CanvasView::tPolygonM (int32 mode, BPoint point) +void +CanvasView::tPolygonM(int32 mode, BPoint point) { - if (entry && mouse_on_canvas) - { - extern AttribPolygon *tAttribPolygon; - extern AttribDraw *mAttribDraw; + if (entry && mouse_on_canvas) { + extern AttribPolygon* tAttribPolygon; + extern AttribDraw* mAttribDraw; drawing_mode dm = mAttribDraw->getDrawingMode(); - drawView->SetDrawingMode (dm); + drawView->SetDrawingMode(dm); float pensize = tAttribPolygon->getPenSize(); -// float halfpensize = int (pensize/2 - 0.5); - SetPenSize (pensize); + // float halfpensize = int (pensize/2 - 0.5); + SetPenSize(pensize); myWindow->Lock(); - Draw (fCanvasFrame); + Draw(fCanvasFrame); myWindow->Unlock(); -// SetScale (fScale); + // SetScale (fScale); BPoint pos = PenLocation(); if (mode == M_SELECT) - SetDrawingMode (B_OP_INVERT); - if (entry == 2) // Apparently, a 2-point polygon can't be drawn...? - { - StrokeLine (polypoint, pos); - StrokeLine (point); - } - else + SetDrawingMode(B_OP_INVERT); + if (entry == 2) // Apparently, a 2-point polygon can't be drawn...? { - StrokePolygon (polygon, false); - StrokeLine (BPoint (pos.x/fScale, pos.y/fScale), point); + StrokeLine(polypoint, pos); + StrokeLine(point); + } else { + StrokePolygon(polygon, false); + StrokeLine(BPoint(pos.x / fScale, pos.y / fScale), point); } - MovePenTo (pos); -// SetScale (1); + MovePenTo(pos); + // SetScale (1); } } -void CanvasView::tRect (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tRect(int32 mode, BPoint point, uint32 buttons) { - extern PatternMenuButton *pat; - extern AttribRect *tAttribRect; - extern AttribDraw *mAttribDraw; + extern PatternMenuButton* pat; + extern AttribRect* tAttribRect; + extern AttribDraw* mAttribDraw; Position position; drawing_mode dm = mAttribDraw->getDrawingMode(); currentLayer()->Lock(); selection->Lock(); - selectionView->SetDrawingMode (dm); - drawView->SetDrawingMode (dm); - SetDrawingMode (dm); + selectionView->SetDrawingMode(dm); + drawView->SetDrawingMode(dm); + SetDrawingMode(dm); float pensize = tAttribRect->getPenSize(); - float halfpensize = int (pensize/2 - 0.5); - drawView->SetPenSize (pensize); - selectionView->SetPenSize (pensize); - SetPenSize (pensize); + float halfpensize = int(pensize / 2 - 0.5); + drawView->SetPenSize(pensize); + selectionView->SetPenSize(pensize); + SetPenSize(pensize); pattern curpat = pat->pat(); - tSetColors (buttons); + tSetColors(buttons); rgb_color c = HighColor(); - if (!entry) - { + if (!entry) { BPoint pos = point; BPoint prev = point; fLastCenter = point; -// BRect frame = fCanvasFrame; - SetupUndo (mode); - while (buttons) - { + // BRect frame = fCanvasFrame; + SetupUndo(mode); + while (buttons) { BRect frame, pframe, tframe; - if (point != prev) - { - frame.Set (pos.x, pos.y, point.x, point.y); - pframe.Set (pos.x, pos.y, prev.x, prev.y); - frame = makePositive (frame); - pframe = makePositive (pframe); + if (point != prev) { + frame.Set(pos.x, pos.y, point.x, point.y); + pframe.Set(pos.x, pos.y, prev.x, prev.y); + frame = makePositive(frame); + pframe = makePositive(pframe); tframe = frame | pframe; - tframe.InsetBy (-halfpensize - 1, -halfpensize - 1); - if (mode == M_DRAW) - { - //drawView->SetDrawingMode (B_OP_COPY); - //drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); - //drawView->SetDrawingMode (dm); - SBitmapToLayer (undo[indexUndo].bitmap, currentLayer(), tframe); - switch (tAttribRect->getType()) - { + tframe.InsetBy(-halfpensize - 1, -halfpensize - 1); + if (mode == M_DRAW) { + // drawView->SetDrawingMode (B_OP_COPY); + // drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); + // drawView->SetDrawingMode (dm); + SBitmapToLayer(undo[indexUndo].bitmap, currentLayer(), tframe); + switch (tAttribRect->getType()) { case RECT_OUTLINE: - drawView->StrokeRect (BRect (pos, point), curpat); + drawView->StrokeRect(BRect(pos, point), curpat); break; case RECT_FILL: - drawView->FillRect (BRect (pos, point), curpat); + drawView->FillRect(BRect(pos, point), curpat); break; case RECT_OUTFILL: - drawView->FillRect (BRect (pos, point), curpat); - drawView->StrokeRect (BRect (pos, point)); + drawView->FillRect(BRect(pos, point), curpat); + drawView->StrokeRect(BRect(pos, point)); break; default: - fprintf (stderr, "Unknown Rect type...\n"); + fprintf(stderr, "Unknown Rect type...\n"); } - } - else - { - //selectionView->SetDrawingMode (B_OP_COPY); - //selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); - //selectionView->SetDrawingMode (dm); - SBitmapToSelection (undo[indexUndo].sbitmap, selection, tframe); - switch (tAttribRect->getType()) - { + } else { + // selectionView->SetDrawingMode (B_OP_COPY); + // selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); + // selectionView->SetDrawingMode (dm); + SBitmapToSelection(undo[indexUndo].sbitmap, selection, tframe); + switch (tAttribRect->getType()) { case RECT_OUTLINE: - selectionView->StrokeRect (BRect (pos, point), curpat); + selectionView->StrokeRect(BRect(pos, point), curpat); break; case RECT_FILL: - selectionView->FillRect (BRect (pos, point), curpat); + selectionView->FillRect(BRect(pos, point), curpat); break; case RECT_OUTFILL: - selectionView->FillRect (BRect (pos, point), curpat); - selectionView->StrokeRect (BRect (pos, point)); + selectionView->FillRect(BRect(pos, point), curpat); + selectionView->StrokeRect(BRect(pos, point)); break; default: - fprintf (stderr, "Unknown Rect type...\n"); + fprintf(stderr, "Unknown Rect type...\n"); } } drawView->Sync(); selectionView->Sync(); - Invalidate (tframe); + Invalidate(tframe); } - snooze (20000); - ScrollIfNeeded (point); + snooze(20000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); prev = point; -// GetMouse (&point, &buttons, true); - GetPosition (&position); + // GetMouse (&point, &buttons, true); + GetPosition(&position); point = position.fPoint; buttons = position.fButtons; } - if (point == pos) - { - MovePenTo (pos); + if (point == pos) { + MovePenTo(pos); Sync(); entry = 1; - } - else - { - if (mode == M_DRAW) - { - memcpy (currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), currentLayer()->BitsLength()); - switch (tAttribRect->getType()) - { + } else { + if (mode == M_DRAW) { + memcpy( + currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), + currentLayer()->BitsLength() + ); + switch (tAttribRect->getType()) { case RECT_OUTLINE: - drawView->StrokeRect (BRect (pos, point), curpat); + drawView->StrokeRect(BRect(pos, point), curpat); break; case RECT_FILL: - drawView->FillRect (BRect (pos, point), curpat); + drawView->FillRect(BRect(pos, point), curpat); break; case RECT_OUTFILL: - drawView->FillRect (BRect (pos, point), curpat); - drawView->StrokeRect (BRect (pos, point)); + drawView->FillRect(BRect(pos, point), curpat); + drawView->StrokeRect(BRect(pos, point)); break; default: - fprintf (stderr, "Unknown Rect type...\n"); + fprintf(stderr, "Unknown Rect type...\n"); } drawView->Sync(); - } - else - { - memcpy (selection->Bits(), undo[indexUndo].sbitmap->Bits(), selection->BitsLength()); - switch (tAttribRect->getType()) - { + } else { + memcpy(selection->Bits(), undo[indexUndo].sbitmap->Bits(), selection->BitsLength()); + switch (tAttribRect->getType()) { case RECT_OUTLINE: - selectionView->StrokeRect (BRect (pos, point), curpat); + selectionView->StrokeRect(BRect(pos, point), curpat); break; case RECT_FILL: - selectionView->FillRect (BRect (pos, point), curpat); + selectionView->FillRect(BRect(pos, point), curpat); break; case RECT_OUTFILL: - selectionView->FillRect (BRect (pos, point), curpat); - selectionView->StrokeRect (BRect (pos, point)); + selectionView->FillRect(BRect(pos, point), curpat); + selectionView->StrokeRect(BRect(pos, point)); break; default: - fprintf (stderr, "Unknown Rect type...\n"); + fprintf(stderr, "Unknown Rect type...\n"); } selectionView->Sync(); } entry = 0; - myWindow->posview->SetPoint (-1, -1); + myWindow->posview->SetPoint(-1, -1); } - } - else - { - if (mode == M_DRAW) - { - switch (tAttribRect->getType()) - { + } else { + if (mode == M_DRAW) { + switch (tAttribRect->getType()) { case RECT_OUTLINE: - drawView->StrokeRect (BRect (PenLocation(), point), curpat); + drawView->StrokeRect(BRect(PenLocation(), point), curpat); break; case RECT_FILL: - drawView->FillRect (BRect (PenLocation(), point), curpat); + drawView->FillRect(BRect(PenLocation(), point), curpat); break; case RECT_OUTFILL: - drawView->FillRect (BRect (PenLocation(), point), curpat); - drawView->StrokeRect (BRect (PenLocation(), point)); + drawView->FillRect(BRect(PenLocation(), point), curpat); + drawView->StrokeRect(BRect(PenLocation(), point)); break; default: - fprintf (stderr, "Unknown Rect type...\n"); + fprintf(stderr, "Unknown Rect type...\n"); } drawView->Sync(); - } - else - { - switch (tAttribRect->getType()) - { + } else { + switch (tAttribRect->getType()) { case RECT_OUTLINE: - selectionView->StrokeRect (BRect (PenLocation(), point), curpat); + selectionView->StrokeRect(BRect(PenLocation(), point), curpat); break; case RECT_FILL: - selectionView->FillRect (BRect (PenLocation(), point), curpat); + selectionView->FillRect(BRect(PenLocation(), point), curpat); break; case RECT_OUTFILL: - selectionView->FillRect (BRect (PenLocation(), point), curpat); - selectionView->StrokeRect (BRect (PenLocation(), point)); + selectionView->FillRect(BRect(PenLocation(), point), curpat); + selectionView->StrokeRect(BRect(PenLocation(), point)); break; default: - fprintf (stderr, "Unknown Rect type...\n"); + fprintf(stderr, "Unknown Rect type...\n"); } selectionView->Sync(); } entry = 0; - myWindow->posview->SetPoint (-1, -1); + myWindow->posview->SetPoint(-1, -1); } Invalidate(); selection->Unlock(); currentLayer()->Unlock(); } -void CanvasView::tRectM (int32 mode, BPoint point) +void +CanvasView::tRectM(int32 mode, BPoint point) { - if (entry && mouse_on_canvas) - { - extern AttribRect *tAttribRect; - extern PatternMenuButton *pat; - extern AttribDraw *mAttribDraw; + if (entry && mouse_on_canvas) { + extern AttribRect* tAttribRect; + extern PatternMenuButton* pat; + extern AttribDraw* mAttribDraw; drawing_mode dm = mAttribDraw->getDrawingMode(); currentLayer()->Lock(); selection->Lock(); - drawView->SetDrawingMode (dm); - selectionView->SetDrawingMode (dm); - SetDrawingMode (dm); -// tSetColors (B_PRIMARY_MOUSE_BUTTON); -// selectionView->SetHighColor (SELECT_FULL); -// selectionView->SetLowColor (SELECT_NONE); + drawView->SetDrawingMode(dm); + selectionView->SetDrawingMode(dm); + SetDrawingMode(dm); + // tSetColors (B_PRIMARY_MOUSE_BUTTON); + // selectionView->SetHighColor (SELECT_FULL); + // selectionView->SetLowColor (SELECT_NONE); pattern curpat = pat->pat(); float pensize = tAttribRect->getPenSize(); - float halfpensize = int (pensize/2 - 0.5); + float halfpensize = int(pensize / 2 - 0.5); BPoint pos = PenLocation(); - BRect frame = PRect (pos.x, pos.y, point.x, point.y); - BRect pframe = PRect (pos.x, pos.y, prev.x, prev.y); + BRect frame = PRect(pos.x, pos.y, point.x, point.y); + BRect pframe = PRect(pos.x, pos.y, prev.x, prev.y); BRect tframe = frame | pframe; - tframe.InsetBy (-halfpensize - 1, -halfpensize - 1); - if (mode == M_DRAW) - { - switch (tAttribRect->getType()) - { + tframe.InsetBy(-halfpensize - 1, -halfpensize - 1); + if (mode == M_DRAW) { + switch (tAttribRect->getType()) { case RECT_OUTLINE: - drawView->StrokeRect (BRect (PenLocation(), point), curpat); + drawView->StrokeRect(BRect(PenLocation(), point), curpat); break; case RECT_FILL: - drawView->FillRect (BRect (PenLocation(), point), curpat); + drawView->FillRect(BRect(PenLocation(), point), curpat); break; case RECT_OUTFILL: - drawView->FillRect (BRect (PenLocation(), point), curpat); - drawView->StrokeRect (BRect (PenLocation(), point)); + drawView->FillRect(BRect(PenLocation(), point), curpat); + drawView->StrokeRect(BRect(PenLocation(), point)); break; default: - fprintf (stderr, "Unknown Rect type...\n"); + fprintf(stderr, "Unknown Rect type...\n"); } - drawView->MovePenTo (pos); + drawView->MovePenTo(pos); drawView->Sync(); - } - else - { - switch (tAttribRect->getType()) - { + } else { + switch (tAttribRect->getType()) { case RECT_OUTLINE: - selectionView->StrokeRect (BRect (PenLocation(), point), curpat); + selectionView->StrokeRect(BRect(PenLocation(), point), curpat); break; case RECT_FILL: - selectionView->FillRect (BRect (PenLocation(), point), curpat); + selectionView->FillRect(BRect(PenLocation(), point), curpat); break; case RECT_OUTFILL: - selectionView->FillRect (BRect (PenLocation(), point), curpat); - selectionView->StrokeRect (BRect (PenLocation(), point)); + selectionView->FillRect(BRect(PenLocation(), point), curpat); + selectionView->StrokeRect(BRect(PenLocation(), point)); break; default: - fprintf (stderr, "Unknown Rect type...\n"); + fprintf(stderr, "Unknown Rect type...\n"); } - selectionView->MovePenTo (pos); + selectionView->MovePenTo(pos); selectionView->Sync(); } - Invalidate (tframe); - drawView->SetDrawingMode (B_OP_COPY); - selectionView->SetDrawingMode (B_OP_COPY); + Invalidate(tframe); + drawView->SetDrawingMode(B_OP_COPY); + selectionView->SetDrawingMode(B_OP_COPY); if (mode == M_DRAW) - //drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); - SBitmapToLayer (undo[indexUndo].bitmap, currentLayer(), tframe); + // drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); + SBitmapToLayer(undo[indexUndo].bitmap, currentLayer(), tframe); else - //selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); - SBitmapToSelection (undo[indexUndo].sbitmap, selection, tframe); + // selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); + SBitmapToSelection(undo[indexUndo].sbitmap, selection, tframe); selection->Unlock(); currentLayer()->Unlock(); prev = point; } } -void CanvasView::tRoundRect (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tRoundRect(int32 mode, BPoint point, uint32 buttons) { - extern PatternMenuButton *pat; - extern AttribRoundRect *tAttribRoundRect; - extern AttribDraw *mAttribDraw; + extern PatternMenuButton* pat; + extern AttribRoundRect* tAttribRoundRect; + extern AttribDraw* mAttribDraw; Position position; drawing_mode dm = mAttribDraw->getDrawingMode(); currentLayer()->Lock(); selection->Lock(); - drawView->SetDrawingMode (dm); - selectionView->SetDrawingMode (dm); - SetDrawingMode (dm); + drawView->SetDrawingMode(dm); + selectionView->SetDrawingMode(dm); + SetDrawingMode(dm); float pensize = tAttribRoundRect->getPenSize(); - float halfpensize = int (pensize/2 - 0.5); - drawView->SetPenSize (pensize); - selectionView->SetPenSize (pensize); - SetPenSize (pensize); + float halfpensize = int(pensize / 2 - 0.5); + drawView->SetPenSize(pensize); + selectionView->SetPenSize(pensize); + SetPenSize(pensize); pattern curpat = pat->pat(); - tSetColors (buttons); + tSetColors(buttons); float xRad; float yRad; - if (!entry) - { + if (!entry) { BPoint pos = point; BPoint prev = point; fLastCenter = point; -// BRect frame = fCanvasFrame; - SetupUndo (mode); - while (buttons) - { + // BRect frame = fCanvasFrame; + SetupUndo(mode); + while (buttons) { BRect frame, pframe, tframe; - if (point != prev) - { - frame.Set (pos.x, pos.y, point.x, point.y); - pframe.Set (pos.x, pos.y, prev.x, prev.y); - frame = makePositive (frame); - pframe = makePositive (pframe); + if (point != prev) { + frame.Set(pos.x, pos.y, point.x, point.y); + pframe.Set(pos.x, pos.y, prev.x, prev.y); + frame = makePositive(frame); + pframe = makePositive(pframe); tframe = frame | pframe; - tframe.InsetBy (-halfpensize - 1, -halfpensize - 1); - switch (tAttribRoundRect->getRadType()) - { + tframe.InsetBy(-halfpensize - 1, -halfpensize - 1); + switch (tAttribRoundRect->getRadType()) { case RRECT_RELATIVE: - xRad = abs (int (pos.x - point.x))*tAttribRoundRect->getRadXrel(); - yRad = abs (int (pos.y - point.y))*tAttribRoundRect->getRadYrel(); + xRad = abs(int(pos.x - point.x)) * tAttribRoundRect->getRadXrel(); + yRad = abs(int(pos.y - point.y)) * tAttribRoundRect->getRadYrel(); break; case RRECT_ABSOLUTE: xRad = tAttribRoundRect->getRadXabs(); yRad = tAttribRoundRect->getRadYabs(); break; default: - fprintf (stderr, "RoundRect: Unknown radius type\n"); + fprintf(stderr, "RoundRect: Unknown radius type\n"); xRad = 8; yRad = 8; } - if (mode == M_DRAW) - { - //drawView->SetDrawingMode (B_OP_COPY); - //drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); - //drawView->SetDrawingMode (dm); - SBitmapToLayer (undo[indexUndo].bitmap, currentLayer(), tframe); - switch (tAttribRoundRect->getType()) - { + if (mode == M_DRAW) { + // drawView->SetDrawingMode (B_OP_COPY); + // drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); + // drawView->SetDrawingMode (dm); + SBitmapToLayer(undo[indexUndo].bitmap, currentLayer(), tframe); + switch (tAttribRoundRect->getType()) { case RRECT_OUTLINE: - drawView->StrokeRoundRect (BRect (pos, point), xRad, yRad, curpat); + drawView->StrokeRoundRect(BRect(pos, point), xRad, yRad, curpat); break; case RRECT_FILL: - drawView->FillRoundRect (BRect (pos, point), xRad, yRad, curpat); + drawView->FillRoundRect(BRect(pos, point), xRad, yRad, curpat); break; case RRECT_OUTFILL: - drawView->FillRoundRect (BRect (pos, point), xRad, yRad, curpat); - drawView->StrokeRoundRect (BRect (pos, point), xRad, yRad); + drawView->FillRoundRect(BRect(pos, point), xRad, yRad, curpat); + drawView->StrokeRoundRect(BRect(pos, point), xRad, yRad); break; default: - fprintf (stderr, "Unknown RoundRect type...\n"); + fprintf(stderr, "Unknown RoundRect type...\n"); } drawView->Sync(); - } - else - { - //selectionView->SetDrawingMode (B_OP_COPY); - //selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); - //selectionView->SetDrawingMode (dm); - SBitmapToSelection (undo[indexUndo].sbitmap, selection, tframe); - switch (tAttribRoundRect->getType()) - { + } else { + // selectionView->SetDrawingMode (B_OP_COPY); + // selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); + // selectionView->SetDrawingMode (dm); + SBitmapToSelection(undo[indexUndo].sbitmap, selection, tframe); + switch (tAttribRoundRect->getType()) { case RRECT_OUTLINE: - selectionView->StrokeRoundRect (BRect (pos, point), xRad, yRad, curpat); + selectionView->StrokeRoundRect(BRect(pos, point), xRad, yRad, curpat); break; case RRECT_FILL: - selectionView->FillRoundRect (BRect (pos, point), xRad, yRad, curpat); + selectionView->FillRoundRect(BRect(pos, point), xRad, yRad, curpat); break; case RRECT_OUTFILL: - selectionView->FillRoundRect (BRect (pos, point), xRad, yRad, curpat); - selectionView->StrokeRoundRect (BRect (pos, point), xRad, yRad); + selectionView->FillRoundRect(BRect(pos, point), xRad, yRad, curpat); + selectionView->StrokeRoundRect(BRect(pos, point), xRad, yRad); break; default: - fprintf (stderr, "Unknown RoundRect type...\n"); + fprintf(stderr, "Unknown RoundRect type...\n"); } selectionView->Sync(); } - Invalidate (tframe); + Invalidate(tframe); } - snooze (20000); - ScrollIfNeeded (point); + snooze(20000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); prev = point; -// GetMouse (&point, &buttons, true); - GetPosition (&position); + // GetMouse (&point, &buttons, true); + GetPosition(&position); point = position.fPoint; buttons = position.fButtons; } - if (point == pos) - { - MovePenTo (pos); + if (point == pos) { + MovePenTo(pos); Sync(); - entry = 1; - } - else - { - switch (tAttribRoundRect->getRadType()) - { + entry = 1; + } else { + switch (tAttribRoundRect->getRadType()) { case RRECT_RELATIVE: - xRad = abs (int (pos.x - point.x))*tAttribRoundRect->getRadXrel(); - yRad = abs (int (pos.y - point.y))*tAttribRoundRect->getRadYrel(); + xRad = abs(int(pos.x - point.x)) * tAttribRoundRect->getRadXrel(); + yRad = abs(int(pos.y - point.y)) * tAttribRoundRect->getRadYrel(); break; case RRECT_ABSOLUTE: xRad = tAttribRoundRect->getRadXabs(); yRad = tAttribRoundRect->getRadYabs(); break; default: - fprintf (stderr, "RoundRect: Unknown radius type\n"); + fprintf(stderr, "RoundRect: Unknown radius type\n"); xRad = 8; yRad = 8; } - if (mode == M_DRAW) - { - memcpy (currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), currentLayer()->BitsLength()); - switch (tAttribRoundRect->getType()) - { + if (mode == M_DRAW) { + memcpy( + currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), + currentLayer()->BitsLength() + ); + switch (tAttribRoundRect->getType()) { case RRECT_OUTLINE: - drawView->StrokeRoundRect (BRect (pos, point), xRad, yRad, curpat); + drawView->StrokeRoundRect(BRect(pos, point), xRad, yRad, curpat); break; case RRECT_FILL: - drawView->FillRoundRect (BRect (pos, point), xRad, yRad, curpat); + drawView->FillRoundRect(BRect(pos, point), xRad, yRad, curpat); break; case RRECT_OUTFILL: - drawView->FillRoundRect (BRect (pos, point), xRad, yRad, curpat); - drawView->StrokeRoundRect (BRect (pos, point), xRad, yRad); + drawView->FillRoundRect(BRect(pos, point), xRad, yRad, curpat); + drawView->StrokeRoundRect(BRect(pos, point), xRad, yRad); break; default: - fprintf (stderr, "Unknown RoundRect type...\n"); + fprintf(stderr, "Unknown RoundRect type...\n"); } drawView->Sync(); - } - else - { - memcpy (undo[indexUndo].sbitmap->Bits(), selection->Bits(), selection->BitsLength()); - switch (tAttribRoundRect->getType()) - { + } else { + memcpy(undo[indexUndo].sbitmap->Bits(), selection->Bits(), selection->BitsLength()); + switch (tAttribRoundRect->getType()) { case RRECT_OUTLINE: - selectionView->StrokeRoundRect (BRect (pos, point), xRad, yRad, curpat); + selectionView->StrokeRoundRect(BRect(pos, point), xRad, yRad, curpat); break; case RRECT_FILL: - selectionView->FillRoundRect (BRect (pos, point), xRad, yRad, curpat); + selectionView->FillRoundRect(BRect(pos, point), xRad, yRad, curpat); break; case RRECT_OUTFILL: - selectionView->FillRoundRect (BRect (pos, point), xRad, yRad, curpat); - selectionView->StrokeRoundRect (BRect (pos, point), xRad, yRad); + selectionView->FillRoundRect(BRect(pos, point), xRad, yRad, curpat); + selectionView->StrokeRoundRect(BRect(pos, point), xRad, yRad); break; default: - fprintf (stderr, "Unknown RoundRect type...\n"); + fprintf(stderr, "Unknown RoundRect type...\n"); } selectionView->Sync(); } entry = 0; - myWindow->posview->SetPoint (-1, -1); + myWindow->posview->SetPoint(-1, -1); } - } - else - { + } else { BPoint pos = PenLocation(); float xRad; float yRad; - switch (tAttribRoundRect->getRadType()) - { + switch (tAttribRoundRect->getRadType()) { case RRECT_RELATIVE: - xRad = abs (int (pos.x - point.x))*tAttribRoundRect->getRadXrel(); - yRad = abs (int (pos.y - point.y))*tAttribRoundRect->getRadYrel(); + xRad = abs(int(pos.x - point.x)) * tAttribRoundRect->getRadXrel(); + yRad = abs(int(pos.y - point.y)) * tAttribRoundRect->getRadYrel(); break; case RRECT_ABSOLUTE: xRad = tAttribRoundRect->getRadXabs(); yRad = tAttribRoundRect->getRadYabs(); break; default: - fprintf (stderr, "RoundRect: Unknown radius type\n"); + fprintf(stderr, "RoundRect: Unknown radius type\n"); xRad = 8; yRad = 8; } - if (mode == M_DRAW) - { - switch (tAttribRoundRect->getType()) - { + if (mode == M_DRAW) { + switch (tAttribRoundRect->getType()) { case RRECT_OUTLINE: - drawView->StrokeRoundRect (BRect (PenLocation(), point), xRad, yRad, curpat); + drawView->StrokeRoundRect(BRect(PenLocation(), point), xRad, yRad, curpat); break; case RRECT_FILL: - drawView->FillRoundRect (BRect (PenLocation(), point), xRad, yRad, curpat); + drawView->FillRoundRect(BRect(PenLocation(), point), xRad, yRad, curpat); break; case RRECT_OUTFILL: - drawView->FillRoundRect (BRect (PenLocation(), point), xRad, yRad, curpat); - drawView->StrokeRoundRect (BRect (PenLocation(), point), xRad, yRad); + drawView->FillRoundRect(BRect(PenLocation(), point), xRad, yRad, curpat); + drawView->StrokeRoundRect(BRect(PenLocation(), point), xRad, yRad); break; default: - fprintf (stderr, "Unknown RoundRect type...\n"); + fprintf(stderr, "Unknown RoundRect type...\n"); } drawView->Sync(); - } - else - { - switch (tAttribRoundRect->getType()) - { + } else { + switch (tAttribRoundRect->getType()) { case RRECT_OUTLINE: - selectionView->StrokeRoundRect (BRect (PenLocation(), point), xRad, yRad, curpat); + selectionView->StrokeRoundRect(BRect(PenLocation(), point), xRad, yRad, curpat); break; case RRECT_FILL: - selectionView->FillRoundRect (BRect (PenLocation(), point), xRad, yRad, curpat); + selectionView->FillRoundRect(BRect(PenLocation(), point), xRad, yRad, curpat); break; case RRECT_OUTFILL: - selectionView->FillRoundRect (BRect (PenLocation(), point), xRad, yRad, curpat); - selectionView->StrokeRoundRect (BRect (PenLocation(), point), xRad, yRad); + selectionView->FillRoundRect(BRect(PenLocation(), point), xRad, yRad, curpat); + selectionView->StrokeRoundRect(BRect(PenLocation(), point), xRad, yRad); break; default: - fprintf (stderr, "Unknown RoundRect type...\n"); + fprintf(stderr, "Unknown RoundRect type...\n"); } selectionView->Sync(); } entry = 0; - myWindow->posview->SetPoint (-1, -1); + myWindow->posview->SetPoint(-1, -1); } Invalidate(); selection->Unlock(); currentLayer()->Unlock(); } -void CanvasView::tRoundRectM (int32 mode, BPoint point) +void +CanvasView::tRoundRectM(int32 mode, BPoint point) { - if (entry && mouse_on_canvas) - { - extern AttribRoundRect *tAttribRoundRect; - extern PatternMenuButton *pat; - extern AttribDraw *mAttribDraw; -// Position position; + if (entry && mouse_on_canvas) { + extern AttribRoundRect* tAttribRoundRect; + extern PatternMenuButton* pat; + extern AttribDraw* mAttribDraw; + // Position position; drawing_mode dm = mAttribDraw->getDrawingMode(); currentLayer()->Lock(); selection->Lock(); - drawView->SetDrawingMode (dm); - selectionView->SetDrawingMode (dm); - SetDrawingMode (dm); + drawView->SetDrawingMode(dm); + selectionView->SetDrawingMode(dm); + SetDrawingMode(dm); pattern curpat = pat->pat(); float pensize = tAttribRoundRect->getPenSize(); - float halfpensize = int (pensize/2 - 0.5); - SetPenSize (pensize); + float halfpensize = int(pensize / 2 - 0.5); + SetPenSize(pensize); BPoint pos = PenLocation(); - BRect frame = PRect (pos.x, pos.y, point.x, point.y); - BRect pframe = PRect (pos.x, pos.y, prev.x, prev.y); + BRect frame = PRect(pos.x, pos.y, point.x, point.y); + BRect pframe = PRect(pos.x, pos.y, prev.x, prev.y); BRect tframe = frame | pframe; - tframe.InsetBy (-halfpensize - 1, -halfpensize - 1); + tframe.InsetBy(-halfpensize - 1, -halfpensize - 1); float xRad; float yRad; - switch (tAttribRoundRect->getRadType()) - { + switch (tAttribRoundRect->getRadType()) { case RRECT_RELATIVE: - xRad = abs (int (pos.x - point.x))*tAttribRoundRect->getRadXrel(); - yRad = abs (int (pos.y - point.y))*tAttribRoundRect->getRadYrel(); + xRad = abs(int(pos.x - point.x)) * tAttribRoundRect->getRadXrel(); + yRad = abs(int(pos.y - point.y)) * tAttribRoundRect->getRadYrel(); break; case RRECT_ABSOLUTE: xRad = tAttribRoundRect->getRadXabs(); yRad = tAttribRoundRect->getRadYabs(); break; default: - fprintf (stderr, "RoundRect: Unknown radius type\n"); + fprintf(stderr, "RoundRect: Unknown radius type\n"); xRad = 8; yRad = 8; } - if (mode == M_DRAW) - { - switch (tAttribRoundRect->getType()) - { + if (mode == M_DRAW) { + switch (tAttribRoundRect->getType()) { case RRECT_OUTLINE: - drawView->StrokeRoundRect (BRect (PenLocation(), point), xRad, yRad, curpat); + drawView->StrokeRoundRect(BRect(PenLocation(), point), xRad, yRad, curpat); break; case RRECT_FILL: - drawView->FillRoundRect (BRect (PenLocation(), point), xRad, yRad, curpat); + drawView->FillRoundRect(BRect(PenLocation(), point), xRad, yRad, curpat); break; case RRECT_OUTFILL: - drawView->FillRoundRect (BRect (PenLocation(), point), xRad, yRad, curpat); - drawView->StrokeRoundRect (BRect (PenLocation(), point), xRad, yRad); + drawView->FillRoundRect(BRect(PenLocation(), point), xRad, yRad, curpat); + drawView->StrokeRoundRect(BRect(PenLocation(), point), xRad, yRad); break; default: - fprintf (stderr, "Unknown RoundRect type...\n"); + fprintf(stderr, "Unknown RoundRect type...\n"); } - drawView->MovePenTo (pos); + drawView->MovePenTo(pos); drawView->Sync(); - } - else - { - switch (tAttribRoundRect->getType()) - { + } else { + switch (tAttribRoundRect->getType()) { case RRECT_OUTLINE: - selectionView->StrokeRoundRect (BRect (PenLocation(), point), xRad, yRad, curpat); + selectionView->StrokeRoundRect(BRect(PenLocation(), point), xRad, yRad, curpat); break; case RRECT_FILL: - selectionView->FillRoundRect (BRect (PenLocation(), point), xRad, yRad, curpat); + selectionView->FillRoundRect(BRect(PenLocation(), point), xRad, yRad, curpat); break; case RRECT_OUTFILL: - selectionView->FillRoundRect (BRect (PenLocation(), point), xRad, yRad, curpat); - selectionView->StrokeRoundRect (BRect (PenLocation(), point), xRad, yRad); + selectionView->FillRoundRect(BRect(PenLocation(), point), xRad, yRad, curpat); + selectionView->StrokeRoundRect(BRect(PenLocation(), point), xRad, yRad); break; default: - fprintf (stderr, "Unknown RoundRect type...\n"); + fprintf(stderr, "Unknown RoundRect type...\n"); } - selectionView->MovePenTo (pos); + selectionView->MovePenTo(pos); selectionView->Sync(); } - Invalidate (tframe); - drawView->SetDrawingMode (B_OP_COPY); - selectionView->SetDrawingMode (B_OP_COPY); + Invalidate(tframe); + drawView->SetDrawingMode(B_OP_COPY); + selectionView->SetDrawingMode(B_OP_COPY); if (mode == M_DRAW) - //drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); - SBitmapToLayer (undo[indexUndo].bitmap, currentLayer(), tframe); + // drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); + SBitmapToLayer(undo[indexUndo].bitmap, currentLayer(), tframe); else - //selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); - SBitmapToSelection (undo[indexUndo].sbitmap, selection, tframe); + // selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); + SBitmapToSelection(undo[indexUndo].sbitmap, selection, tframe); selection->Unlock(); currentLayer()->Unlock(); prev = point; } } -void CanvasView::tCircle (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tCircle(int32 mode, BPoint point, uint32 buttons) { - extern PatternMenuButton *pat; - extern AttribCircle *tAttribCircle; - extern AttribDraw *mAttribDraw; + extern PatternMenuButton* pat; + extern AttribCircle* tAttribCircle; + extern AttribDraw* mAttribDraw; Position position; drawing_mode dm = mAttribDraw->getDrawingMode(); currentLayer()->Lock(); selection->Lock(); - drawView->SetDrawingMode (dm); - selectionView->SetDrawingMode (dm); - SetDrawingMode (dm); + drawView->SetDrawingMode(dm); + selectionView->SetDrawingMode(dm); + SetDrawingMode(dm); int cent = tAttribCircle->getFirst(); float pensize = tAttribCircle->getPenSize(); - float halfpensize = int (pensize/2 - 0.5); - drawView->SetPenSize (pensize); - selectionView->SetPenSize (pensize); - SetPenSize (pensize); + float halfpensize = int(pensize / 2 - 0.5); + drawView->SetPenSize(pensize); + selectionView->SetPenSize(pensize); + SetPenSize(pensize); pattern curpat = pat->pat(); - tSetColors (buttons); - if (!entry) - { + tSetColors(buttons); + if (!entry) { BPoint prev = point; BPoint center = point; fLastCenter = point; -// BRect frame = fCanvasFrame; + // BRect frame = fCanvasFrame; float radius = 0; - SetupUndo (mode); - while (buttons) - { + SetupUndo(mode); + while (buttons) { BRect frame, pframe, tframe; - if (point != prev) - { - radius = sqrt ((center.x - point.x)*(center.x - point.x) + (center.y - point.y)*(center.y - point.y)); - if (cent == FIXES_CENTER) - { - frame.Set (center.x - radius, center.y - radius, center.x + radius, center.y + radius); - pframe.Set (center.x - pradius, center.y - pradius, center.x + pradius, center.y + pradius); + if (point != prev) { + radius = sqrt( + (center.x - point.x) * (center.x - point.x) + + (center.y - point.y) * (center.y - point.y) + ); + if (cent == FIXES_CENTER) { + frame.Set( + center.x - radius, center.y - radius, center.x + radius, center.y + radius + ); + pframe.Set( + center.x - pradius, center.y - pradius, center.x + pradius, + center.y + pradius + ); + } else { + frame.Set( + point.x - radius, point.y - radius, point.x + radius, point.y + radius + ); + pframe.Set( + prev.x - pradius, prev.y - pradius, prev.x + pradius, prev.y + pradius + ); } - else - { - frame.Set (point.x - radius, point.y - radius, point.x + radius, point.y + radius); - pframe.Set (prev.x - pradius, prev.y - pradius, prev.x + pradius, prev.y + pradius); - } - frame = makePositive (frame); - pframe = makePositive (pframe); + frame = makePositive(frame); + pframe = makePositive(pframe); tframe = frame | pframe; - tframe.InsetBy (-halfpensize - 1, -halfpensize - 1); - if (mode == M_DRAW) - { - //drawView->SetDrawingMode (B_OP_COPY); - //drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); - //drawView->SetDrawingMode (dm); - SBitmapToLayer (undo[indexUndo].bitmap, currentLayer(), tframe); - switch (tAttribCircle->getType()) - { + tframe.InsetBy(-halfpensize - 1, -halfpensize - 1); + if (mode == M_DRAW) { + // drawView->SetDrawingMode (B_OP_COPY); + // drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); + // drawView->SetDrawingMode (dm); + SBitmapToLayer(undo[indexUndo].bitmap, currentLayer(), tframe); + switch (tAttribCircle->getType()) { case CIRCLE_OUTLINE: - drawView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + drawView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_FILL: - drawView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + drawView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_OUTFILL: - drawView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); - drawView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius); + drawView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); + drawView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius + ); break; default: - fprintf (stderr, "Unknown Circle type...\n"); + fprintf(stderr, "Unknown Circle type...\n"); } drawView->Sync(); - } - else - { - //selectionView->SetDrawingMode (B_OP_COPY); - //selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); - //selectionView->SetDrawingMode (dm); - SBitmapToSelection (undo[indexUndo].sbitmap, selection, tframe); - switch (tAttribCircle->getType()) - { + } else { + // selectionView->SetDrawingMode (B_OP_COPY); + // selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); + // selectionView->SetDrawingMode (dm); + SBitmapToSelection(undo[indexUndo].sbitmap, selection, tframe); + switch (tAttribCircle->getType()) { case CIRCLE_OUTLINE: - selectionView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + selectionView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_FILL: - selectionView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + selectionView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_OUTFILL: - selectionView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); - selectionView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius); + selectionView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); + selectionView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius + ); break; default: - fprintf (stderr, "Unknown Circle type...\n"); + fprintf(stderr, "Unknown Circle type...\n"); } selectionView->Sync(); } - Invalidate (tframe); + Invalidate(tframe); } - snooze (20000); - ScrollIfNeeded (point); + snooze(20000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); prev = point; pradius = radius; -// GetMouse (&point, &buttons, true); - GetPosition (&position); + // GetMouse (&point, &buttons, true); + GetPosition(&position); point = position.fPoint; buttons = position.fButtons; } - if (point == center) - { - MovePenTo (center); + if (point == center) { + MovePenTo(center); Sync(); entry = 1; - } - else - { - if (mode == M_DRAW) - { - memcpy (currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), currentLayer()->BitsLength()); - radius = sqrt ((center.x - point.x)*(center.x - point.x) + (center.y - point.y)*(center.y - point.y)); - switch (tAttribCircle->getType()) - { + } else { + if (mode == M_DRAW) { + memcpy( + currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), + currentLayer()->BitsLength() + ); + radius = sqrt( + (center.x - point.x) * (center.x - point.x) + + (center.y - point.y) * (center.y - point.y) + ); + switch (tAttribCircle->getType()) { case CIRCLE_OUTLINE: - drawView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + drawView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_FILL: - drawView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + drawView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_OUTFILL: - drawView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); - drawView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius); + drawView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); + drawView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius + ); break; default: - fprintf (stderr, "Unknown Circle type...\n"); + fprintf(stderr, "Unknown Circle type...\n"); } drawView->Sync(); - } - else - { - memcpy (selection->Bits(), undo[indexUndo].sbitmap->Bits(), selection->BitsLength()); - radius = sqrt ((center.x - point.x)*(center.x - point.x) + (center.y - point.y)*(center.y - point.y)); - switch (tAttribCircle->getType()) - { + } else { + memcpy(selection->Bits(), undo[indexUndo].sbitmap->Bits(), selection->BitsLength()); + radius = sqrt( + (center.x - point.x) * (center.x - point.x) + + (center.y - point.y) * (center.y - point.y) + ); + switch (tAttribCircle->getType()) { case CIRCLE_OUTLINE: - selectionView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + selectionView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_FILL: - selectionView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + selectionView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_OUTFILL: - selectionView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); - selectionView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius); + selectionView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); + selectionView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius + ); break; default: - fprintf (stderr, "Unknown Circle type...\n"); + fprintf(stderr, "Unknown Circle type...\n"); } selectionView->Sync(); } entry = 0; - myWindow->posview->SetPoint (-1, -1); + myWindow->posview->SetPoint(-1, -1); } - } - else - { + } else { BPoint center = PenLocation(); -// float radius = sqrt ((center.x - point.x)*(center.x - point.x) + (center.y - point.y)*(center.y - point.y)); - if (mode == M_DRAW) - { - memcpy (currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), currentLayer()->BitsLength()); - float radius = sqrt ((center.x - point.x)*(center.x - point.x) + (center.y - point.y)*(center.y - point.y)); - switch (tAttribCircle->getType()) - { + // float radius = sqrt ((center.x - point.x)*(center.x - point.x) + (center.y - + // point.y)*(center.y - point.y)); + if (mode == M_DRAW) { + memcpy( + currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), currentLayer()->BitsLength() + ); + float radius = sqrt( + (center.x - point.x) * (center.x - point.x) + + (center.y - point.y) * (center.y - point.y) + ); + switch (tAttribCircle->getType()) { case CIRCLE_OUTLINE: - drawView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + drawView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_FILL: - drawView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + drawView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_OUTFILL: - drawView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); - drawView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius); + drawView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); + drawView->StrokeEllipse((cent == FIXES_CENTER) ? center : point, radius, radius); break; default: - fprintf (stderr, "Unknown Circle type...\n"); + fprintf(stderr, "Unknown Circle type...\n"); } drawView->Sync(); - } - else - { - memcpy (selection->Bits(), undo[indexUndo].sbitmap->Bits(), selection->BitsLength()); - float radius = sqrt ((center.x - point.x)*(center.x - point.x) + (center.y - point.y)*(center.y - point.y)); - switch (tAttribCircle->getType()) - { + } else { + memcpy(selection->Bits(), undo[indexUndo].sbitmap->Bits(), selection->BitsLength()); + float radius = sqrt( + (center.x - point.x) * (center.x - point.x) + + (center.y - point.y) * (center.y - point.y) + ); + switch (tAttribCircle->getType()) { case CIRCLE_OUTLINE: - selectionView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + selectionView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_FILL: - selectionView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + selectionView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_OUTFILL: - selectionView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); - selectionView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius); + selectionView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); + selectionView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius + ); break; default: - fprintf (stderr, "Unknown Circle type...\n"); + fprintf(stderr, "Unknown Circle type...\n"); } selectionView->Sync(); } entry = 0; - myWindow->posview->SetPoint (-1, -1); + myWindow->posview->SetPoint(-1, -1); } selection->Unlock(); currentLayer()->Unlock(); Invalidate(); } -void CanvasView::tCircleM (int32 mode, BPoint point) +void +CanvasView::tCircleM(int32 mode, BPoint point) { - if (entry && mouse_on_canvas) - { - extern AttribCircle *tAttribCircle; - extern PatternMenuButton *pat; - extern AttribDraw *mAttribDraw; + if (entry && mouse_on_canvas) { + extern AttribCircle* tAttribCircle; + extern PatternMenuButton* pat; + extern AttribDraw* mAttribDraw; drawing_mode dm = mAttribDraw->getDrawingMode(); currentLayer()->Lock(); selection->Lock(); - drawView->SetDrawingMode (dm); - selectionView->SetDrawingMode (dm); - SetDrawingMode (dm); + drawView->SetDrawingMode(dm); + selectionView->SetDrawingMode(dm); + SetDrawingMode(dm); pattern curpat = pat->pat(); float pensize = tAttribCircle->getPenSize(); - float halfpensize = int (pensize/2 - 0.5); + float halfpensize = int(pensize / 2 - 0.5); int cent = tAttribCircle->getFirst(); BPoint center = PenLocation(); - float radius = sqrt ((center.x - point.x)*(center.x - point.x) + (center.y - point.y)*(center.y - point.y)); - SetPenSize (pensize); + float radius = sqrt( + (center.x - point.x) * (center.x - point.x) + + (center.y - point.y) * (center.y - point.y) + ); + SetPenSize(pensize); BPoint pos = PenLocation(); BRect frame, pframe; - if (cent == FIXES_CENTER) - { - frame = PRect (center.x - radius, center.y - radius, center.x + radius, center.y + radius); - pframe = PRect (center.x - pradius, center.y - pradius, center.x + pradius, center.y + pradius); - } - else - { - frame = PRect (point.x - radius, point.y - radius, point.x + radius, point.y + radius); - pframe = PRect (prev.x - pradius, prev.y - pradius, prev.x + pradius, prev.y + pradius); + if (cent == FIXES_CENTER) { + frame = + PRect(center.x - radius, center.y - radius, center.x + radius, center.y + radius); + pframe = PRect( + center.x - pradius, center.y - pradius, center.x + pradius, center.y + pradius + ); + } else { + frame = PRect(point.x - radius, point.y - radius, point.x + radius, point.y + radius); + pframe = PRect(prev.x - pradius, prev.y - pradius, prev.x + pradius, prev.y + pradius); } BRect tframe = frame | pframe; - tframe.InsetBy (-halfpensize - 1, -halfpensize - 1); - if (mode == M_DRAW) - { - switch (tAttribCircle->getType()) - { + tframe.InsetBy(-halfpensize - 1, -halfpensize - 1); + if (mode == M_DRAW) { + switch (tAttribCircle->getType()) { case CIRCLE_OUTLINE: - drawView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + drawView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_FILL: - drawView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + drawView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_OUTFILL: - drawView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); - drawView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius); + drawView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); + drawView->StrokeEllipse((cent == FIXES_CENTER) ? center : point, radius, radius); break; default: - fprintf (stderr, "Unknown Circle type...\n"); + fprintf(stderr, "Unknown Circle type...\n"); } - drawView->MovePenTo (pos); + drawView->MovePenTo(pos); drawView->Sync(); - } - else - { - switch (tAttribCircle->getType()) - { + } else { + switch (tAttribCircle->getType()) { case CIRCLE_OUTLINE: - selectionView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + selectionView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_FILL: - selectionView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); + selectionView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); break; case CIRCLE_OUTFILL: - selectionView->FillEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius, curpat); - selectionView->StrokeEllipse ((cent == FIXES_CENTER) ? center : point, radius, radius); + selectionView->FillEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius, curpat + ); + selectionView->StrokeEllipse( + (cent == FIXES_CENTER) ? center : point, radius, radius + ); break; default: - fprintf (stderr, "Unknown Circle type...\n"); + fprintf(stderr, "Unknown Circle type...\n"); } - selectionView->MovePenTo (pos); + selectionView->MovePenTo(pos); selectionView->Sync(); } - Invalidate (tframe); - drawView->SetDrawingMode (B_OP_COPY); - selectionView->SetDrawingMode (B_OP_COPY); - if (mode == M_DRAW) - //drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); - SBitmapToLayer (undo[indexUndo].bitmap, currentLayer(), tframe); + Invalidate(tframe); + drawView->SetDrawingMode(B_OP_COPY); + selectionView->SetDrawingMode(B_OP_COPY); + if (mode == M_DRAW) + // drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); + SBitmapToLayer(undo[indexUndo].bitmap, currentLayer(), tframe); else - //selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); - SBitmapToSelection (undo[indexUndo].sbitmap, selection, tframe); + // selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); + SBitmapToSelection(undo[indexUndo].sbitmap, selection, tframe); selection->Unlock(); currentLayer()->Unlock(); prev = point; @@ -2786,272 +2718,248 @@ void CanvasView::tCircleM (int32 mode, BPoint point) } } -void CanvasView::tEllipse (int32 mode, BPoint point, uint32 buttons) +void +CanvasView::tEllipse(int32 mode, BPoint point, uint32 buttons) { - extern PatternMenuButton *pat; - extern AttribEllipse *tAttribEllipse; - extern AttribDraw *mAttribDraw; + extern PatternMenuButton* pat; + extern AttribEllipse* tAttribEllipse; + extern AttribDraw* mAttribDraw; Position position; drawing_mode dm = mAttribDraw->getDrawingMode(); currentLayer()->Lock(); selection->Lock(); - selectionView->SetDrawingMode (dm); - drawView->SetDrawingMode (dm); - SetDrawingMode (dm); + selectionView->SetDrawingMode(dm); + drawView->SetDrawingMode(dm); + SetDrawingMode(dm); pattern curpat = pat->pat(); float pensize = tAttribEllipse->getPenSize(); - float halfpensize = int (pensize/2 - 0.5); - drawView->SetPenSize (pensize); - selectionView->SetPenSize (pensize); - SetPenSize (pensize); - tSetColors (buttons); - if (!entry) - { + float halfpensize = int(pensize / 2 - 0.5); + drawView->SetPenSize(pensize); + selectionView->SetPenSize(pensize); + SetPenSize(pensize); + tSetColors(buttons); + if (!entry) { BPoint pos = point; BPoint prev = point; fLastCenter = point; -// BRect frame = fCanvasFrame; - SetupUndo (mode); - while (buttons) - { + // BRect frame = fCanvasFrame; + SetupUndo(mode); + while (buttons) { BRect frame, pframe, tframe; - if (point != prev) - { - frame.Set (pos.x, pos.y, point.x, point.y); - pframe.Set (pos.x, pos.y, prev.x, prev.y); - frame = makePositive (frame); - pframe = makePositive (pframe); + if (point != prev) { + frame.Set(pos.x, pos.y, point.x, point.y); + pframe.Set(pos.x, pos.y, prev.x, prev.y); + frame = makePositive(frame); + pframe = makePositive(pframe); tframe = frame | pframe; - tframe.InsetBy (-halfpensize - 1, -halfpensize - 1); - if (mode == M_DRAW) - { - //drawView->SetDrawingMode (B_OP_COPY); - //drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); - //drawView->SetDrawingMode (dm); - SBitmapToLayer (undo[indexUndo].bitmap, currentLayer(), tframe); - switch (tAttribEllipse->getType()) - { + tframe.InsetBy(-halfpensize - 1, -halfpensize - 1); + if (mode == M_DRAW) { + // drawView->SetDrawingMode (B_OP_COPY); + // drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); + // drawView->SetDrawingMode (dm); + SBitmapToLayer(undo[indexUndo].bitmap, currentLayer(), tframe); + switch (tAttribEllipse->getType()) { case ELLIPSE_OUTLINE: - drawView->StrokeEllipse (BRect (pos, point), curpat); + drawView->StrokeEllipse(BRect(pos, point), curpat); break; case ELLIPSE_FILL: - drawView->FillEllipse (BRect (pos, point), curpat); + drawView->FillEllipse(BRect(pos, point), curpat); break; case ELLIPSE_OUTFILL: - drawView->FillEllipse (BRect (pos, point), curpat); - drawView->StrokeEllipse (BRect (pos, point)); + drawView->FillEllipse(BRect(pos, point), curpat); + drawView->StrokeEllipse(BRect(pos, point)); break; default: - fprintf (stderr, "Unknown Ellipse type...\n"); + fprintf(stderr, "Unknown Ellipse type...\n"); } drawView->Sync(); - } - else - { - //selectionView->SetDrawingMode (B_OP_COPY); - //selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); - //selectionView->SetDrawingMode (dm); - SBitmapToSelection (undo[indexUndo].sbitmap, selection, tframe); - switch (tAttribEllipse->getType()) - { + } else { + // selectionView->SetDrawingMode (B_OP_COPY); + // selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); + // selectionView->SetDrawingMode (dm); + SBitmapToSelection(undo[indexUndo].sbitmap, selection, tframe); + switch (tAttribEllipse->getType()) { case ELLIPSE_OUTLINE: - selectionView->StrokeEllipse (BRect (pos, point), curpat); + selectionView->StrokeEllipse(BRect(pos, point), curpat); break; case ELLIPSE_FILL: - selectionView->FillEllipse (BRect (pos, point), curpat); + selectionView->FillEllipse(BRect(pos, point), curpat); break; case ELLIPSE_OUTFILL: - selectionView->FillEllipse (BRect (pos, point), curpat); - selectionView->StrokeEllipse (BRect (pos, point)); + selectionView->FillEllipse(BRect(pos, point), curpat); + selectionView->StrokeEllipse(BRect(pos, point)); break; default: - fprintf (stderr, "Unknown Ellipse type...\n"); + fprintf(stderr, "Unknown Ellipse type...\n"); } selectionView->Sync(); } - Invalidate (tframe); + Invalidate(tframe); } - snooze (20000); - ScrollIfNeeded (point); + snooze(20000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); prev = point; -// GetMouse (&point, &buttons, true); - GetPosition (&position); + // GetMouse (&point, &buttons, true); + GetPosition(&position); point = position.fPoint; buttons = position.fButtons; } - if (point == pos) - { - MovePenTo (pos); + if (point == pos) { + MovePenTo(pos); Sync(); entry = 1; - } - else - { - if (mode == M_DRAW) - { - memcpy (currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), currentLayer()->BitsLength()); - switch (tAttribEllipse->getType()) - { + } else { + if (mode == M_DRAW) { + memcpy( + currentLayer()->Bits(), undo[indexUndo].bitmap->Bits(), + currentLayer()->BitsLength() + ); + switch (tAttribEllipse->getType()) { case ELLIPSE_OUTLINE: - drawView->StrokeEllipse (BRect (pos, point), curpat); + drawView->StrokeEllipse(BRect(pos, point), curpat); break; case ELLIPSE_FILL: - drawView->FillEllipse (BRect (pos, point), curpat); + drawView->FillEllipse(BRect(pos, point), curpat); break; case ELLIPSE_OUTFILL: - drawView->FillEllipse (BRect (pos, point), curpat); - drawView->StrokeEllipse (BRect (pos, point)); + drawView->FillEllipse(BRect(pos, point), curpat); + drawView->StrokeEllipse(BRect(pos, point)); break; default: - fprintf (stderr, "Unknown Ellipse type...\n"); + fprintf(stderr, "Unknown Ellipse type...\n"); } drawView->Sync(); - } - else - { - memcpy (selection->Bits(), undo[indexUndo].sbitmap->Bits(), selection->BitsLength()); - switch (tAttribEllipse->getType()) - { + } else { + memcpy(selection->Bits(), undo[indexUndo].sbitmap->Bits(), selection->BitsLength()); + switch (tAttribEllipse->getType()) { case ELLIPSE_OUTLINE: - selectionView->StrokeEllipse (BRect (pos, point), curpat); + selectionView->StrokeEllipse(BRect(pos, point), curpat); break; case ELLIPSE_FILL: - selectionView->FillEllipse (BRect (pos, point), curpat); + selectionView->FillEllipse(BRect(pos, point), curpat); break; case ELLIPSE_OUTFILL: - selectionView->FillEllipse (BRect (pos, point), curpat); - selectionView->StrokeEllipse (BRect (pos, point)); + selectionView->FillEllipse(BRect(pos, point), curpat); + selectionView->StrokeEllipse(BRect(pos, point)); break; default: - fprintf (stderr, "Unknown Ellipse type...\n"); + fprintf(stderr, "Unknown Ellipse type...\n"); } selectionView->Sync(); } entry = 0; - myWindow->posview->SetPoint (-1, -1); + myWindow->posview->SetPoint(-1, -1); } - } - else - { - if (mode == M_DRAW) - { - switch (tAttribEllipse->getType()) - { + } else { + if (mode == M_DRAW) { + switch (tAttribEllipse->getType()) { case ELLIPSE_OUTLINE: - drawView->StrokeEllipse (BRect (PenLocation(), point), curpat); + drawView->StrokeEllipse(BRect(PenLocation(), point), curpat); break; case ELLIPSE_FILL: - drawView->FillEllipse (BRect (PenLocation(), point), curpat); + drawView->FillEllipse(BRect(PenLocation(), point), curpat); break; case ELLIPSE_OUTFILL: - drawView->FillEllipse (BRect (PenLocation(), point), curpat); - drawView->StrokeEllipse (BRect (PenLocation(), point)); + drawView->FillEllipse(BRect(PenLocation(), point), curpat); + drawView->StrokeEllipse(BRect(PenLocation(), point)); break; default: - fprintf (stderr, "Unknown Ellipse type...\n"); + fprintf(stderr, "Unknown Ellipse type...\n"); } drawView->Sync(); - } - else - { - switch (tAttribEllipse->getType()) - { + } else { + switch (tAttribEllipse->getType()) { case ELLIPSE_OUTLINE: - selectionView->StrokeEllipse (BRect (PenLocation(), point), curpat); + selectionView->StrokeEllipse(BRect(PenLocation(), point), curpat); break; case ELLIPSE_FILL: - selectionView->FillEllipse (BRect (PenLocation(), point), curpat); + selectionView->FillEllipse(BRect(PenLocation(), point), curpat); break; case ELLIPSE_OUTFILL: - selectionView->FillEllipse (BRect (PenLocation(), point), curpat); - selectionView->StrokeEllipse (BRect (PenLocation(), point)); + selectionView->FillEllipse(BRect(PenLocation(), point), curpat); + selectionView->StrokeEllipse(BRect(PenLocation(), point)); break; default: - fprintf (stderr, "Unknown Ellipse type...\n"); + fprintf(stderr, "Unknown Ellipse type...\n"); } selectionView->Sync(); } entry = 0; - myWindow->posview->SetPoint (-1, -1); + myWindow->posview->SetPoint(-1, -1); } selection->Unlock(); currentLayer()->Unlock(); - Invalidate (); + Invalidate(); } -void CanvasView::tEllipseM (int32 mode, BPoint point) +void +CanvasView::tEllipseM(int32 mode, BPoint point) { - if (entry && mouse_on_canvas) - { - extern AttribEllipse *tAttribEllipse; - extern PatternMenuButton *pat; - extern AttribDraw *mAttribDraw; + if (entry && mouse_on_canvas) { + extern AttribEllipse* tAttribEllipse; + extern PatternMenuButton* pat; + extern AttribDraw* mAttribDraw; drawing_mode dm = mAttribDraw->getDrawingMode(); currentLayer()->Lock(); selection->Lock(); - drawView->SetDrawingMode (dm); - SetDrawingMode (dm); + drawView->SetDrawingMode(dm); + SetDrawingMode(dm); pattern curpat = pat->pat(); float pensize = tAttribEllipse->getPenSize(); - float halfpensize = int (pensize/2 - 0.5); - SetPenSize (pensize); + float halfpensize = int(pensize / 2 - 0.5); + SetPenSize(pensize); BPoint pos = PenLocation(); - BRect frame = PRect (pos.x, pos.y, point.x, point.y); - BRect pframe = PRect (pos.x, pos.y, prev.x, prev.y); + BRect frame = PRect(pos.x, pos.y, point.x, point.y); + BRect pframe = PRect(pos.x, pos.y, prev.x, prev.y); BRect tframe = frame | pframe; - tframe.InsetBy (-halfpensize - 1, -halfpensize - 1); - if (mode == M_DRAW) - { - switch (tAttribEllipse->getType()) - { + tframe.InsetBy(-halfpensize - 1, -halfpensize - 1); + if (mode == M_DRAW) { + switch (tAttribEllipse->getType()) { case ELLIPSE_OUTLINE: - drawView->StrokeEllipse (BRect (PenLocation(), point), curpat); + drawView->StrokeEllipse(BRect(PenLocation(), point), curpat); break; case ELLIPSE_FILL: - drawView->FillEllipse (BRect (PenLocation(), point), curpat); + drawView->FillEllipse(BRect(PenLocation(), point), curpat); break; case ELLIPSE_OUTFILL: - drawView->FillEllipse (BRect (PenLocation(), point), curpat); - drawView->StrokeEllipse (BRect (PenLocation(), point)); + drawView->FillEllipse(BRect(PenLocation(), point), curpat); + drawView->StrokeEllipse(BRect(PenLocation(), point)); break; default: - fprintf (stderr, "Unknown Ellipse type...\n"); + fprintf(stderr, "Unknown Ellipse type...\n"); } - drawView->MovePenTo (pos); + drawView->MovePenTo(pos); drawView->Sync(); - } - else - { - switch (tAttribEllipse->getType()) - { + } else { + switch (tAttribEllipse->getType()) { case ELLIPSE_OUTLINE: - selectionView->StrokeEllipse (BRect (PenLocation(), point), curpat); + selectionView->StrokeEllipse(BRect(PenLocation(), point), curpat); break; case ELLIPSE_FILL: - selectionView->FillEllipse (BRect (PenLocation(), point), curpat); + selectionView->FillEllipse(BRect(PenLocation(), point), curpat); break; case ELLIPSE_OUTFILL: - selectionView->FillEllipse (BRect (PenLocation(), point), curpat); - selectionView->StrokeEllipse (BRect (PenLocation(), point)); + selectionView->FillEllipse(BRect(PenLocation(), point), curpat); + selectionView->StrokeEllipse(BRect(PenLocation(), point)); break; default: - fprintf (stderr, "Unknown Ellipse type...\n"); + fprintf(stderr, "Unknown Ellipse type...\n"); } - selectionView->MovePenTo (pos); + selectionView->MovePenTo(pos); selectionView->Sync(); } - Invalidate (tframe); - drawView->SetDrawingMode (B_OP_COPY); - selectionView->SetDrawingMode (B_OP_COPY); + Invalidate(tframe); + drawView->SetDrawingMode(B_OP_COPY); + selectionView->SetDrawingMode(B_OP_COPY); if (mode == M_DRAW) - //drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); - SBitmapToLayer (undo[indexUndo].bitmap, currentLayer(), tframe); + // drawView->DrawSBitmap (undo[indexUndo].bitmap, tframe, tframe); + SBitmapToLayer(undo[indexUndo].bitmap, currentLayer(), tframe); else - //selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); - SBitmapToSelection (undo[indexUndo].sbitmap, selection, tframe); + // selectionView->DrawSBitmap (undo[indexUndo].sbitmap, tframe, tframe); + SBitmapToSelection(undo[indexUndo].sbitmap, selection, tframe); selection->Unlock(); currentLayer()->Unlock(); prev = point; @@ -3059,316 +2967,282 @@ void CanvasView::tEllipseM (int32 mode, BPoint point) } //////////////////////////// -#if defined (__POWERPC__) -# pragma optimization_level 4 +#if defined(__POWERPC__) +#pragma optimization_level 4 #endif -inline bool CanvasView::inbounds (LPoint p) +inline bool +CanvasView::inbounds(LPoint p) { return (p.x >= 0 && p.x <= tw && p.y >= 0 && p.y <= th); } -inline bool CanvasView::isfillcolor0 (LPoint point) +inline bool +CanvasView::isfillcolor0(LPoint point) { - ulong *addr = bbitsl + bbprl*point.y + point.x; + ulong* addr = bbitsl + bbprl * point.y + point.x; return (*(uint32*)addr == fill32 || (!(fill32 & ALPHA_MASK) && !(*addr & ALPHA_MASK))); } -inline bool CanvasView::isfillcolorrgb (LPoint point, uchar *t) +inline bool +CanvasView::isfillcolorrgb(LPoint point, uchar* t) { - rgb_color c = getColor (point); - + rgb_color c = getColor(point); + if (!fillcolor.alpha && !c.alpha) return true; - - if (c.alpha - && abs (c.red - fillcolor.red) <= toleranceRGB.red - && abs (c.green - fillcolor.green) <= toleranceRGB.green - && abs (c.blue - fillcolor.blue) <= toleranceRGB.blue) - { - if (c.alpha == 255) // Special case - *t = clipchar (255 - diff (c, fillcolor)); + + if (c.alpha && abs(c.red - fillcolor.red) <= toleranceRGB.red && + abs(c.green - fillcolor.green) <= toleranceRGB.green && + abs(c.blue - fillcolor.blue) <= toleranceRGB.blue) { + if (c.alpha == 255) // Special case + *t = clipchar(255 - diff(c, fillcolor)); else *t = c.alpha; return true; - } - else - { + } else { *t = 0; return false; } } -inline bool CanvasView::isfillcolort (LPoint point, uchar *t) +inline bool +CanvasView::isfillcolort(LPoint point, uchar* t) { - rgb_color c = getColor (point); + rgb_color c = getColor(point); register uchar d; - if (!c.alpha) // Special cases + if (!c.alpha) // Special cases { - if (!fillcolor.alpha) - { + if (!fillcolor.alpha) { *t = 255; return (true); - } - else - { + } else { *t = 0; return (false); } } - if (c.alpha == 255) - { - d = uchar (diff (c, fillcolor)); - *t = uchar (255 - d*254/tolerance); - } - else - { + if (c.alpha == 255) { + d = uchar(diff(c, fillcolor)); + *t = uchar(255 - d * 254 / tolerance); + } else { d = c.alpha; *t = c.alpha; } return (d <= tolerance); } -inline bool CanvasView::istransparent8 (LPoint point) +inline bool +CanvasView::istransparent8(LPoint point) { - uchar *addr = tbits + tbpr*point.y + point.x; + uchar* addr = tbits + tbpr * point.y + point.x; return (*addr == 0); } -void CanvasView::Fill (int32 mode, BPoint point, rgb_color *c) +void +CanvasView::Fill(int32 mode, BPoint point, rgb_color* c) { - tFill (mode, point, B_PRIMARY_MOUSE_BUTTON, c); + tFill(mode, point, B_PRIMARY_MOUSE_BUTTON, c); } -void CanvasView::tFill (int32 mode, BPoint point, uint32 buttons, rgb_color *c) +void +CanvasView::tFill(int32 mode, BPoint point, uint32 buttons, rgb_color* c) { - extern Becasso *mainapp; + extern Becasso* mainapp; extern ColorMenuButton *locolor, *hicolor; - extern PatternMenuButton *pat; - extern AttribFill *tAttribFill; - extern AttribDraw *mAttribDraw; - SetupUndo (mode); + extern PatternMenuButton* pat; + extern AttribFill* tAttribFill; + extern AttribDraw* mAttribDraw; + SetupUndo(mode); mainapp->setBusy(); currentLayer()->Lock(); - temp = new BBitmap (fCanvasFrame, B_BITMAP_ACCEPTS_VIEWS, B_COLOR_8_BIT); + temp = new BBitmap(fCanvasFrame, B_BITMAP_ACCEPTS_VIEWS, B_COLOR_8_BIT); temp->Lock(); - SView *tempView = new SView (fCanvasFrame, "TempView for Fill", B_FOLLOW_NONE, uint32 (NULL)); - temp->AddChild (tempView); - tbits = (uchar *) temp->Bits(); + SView* tempView = new SView(fCanvasFrame, "TempView for Fill", B_FOLLOW_NONE, uint32(NULL)); + temp->AddChild(tempView); + tbits = (uchar*)temp->Bits(); tbpr = temp->BytesPerRow(); - tbprl = tbpr/4; - bbitsl = (ulong *) currentLayer()->Bits(); - bbits = (uchar *) bbitsl; + tbprl = tbpr / 4; + bbitsl = (ulong*)currentLayer()->Bits(); + bbits = (uchar*)bbitsl; bbpr = currentLayer()->BytesPerRow(); - bbprl = bbpr/4; + bbprl = bbpr / 4; tw = fCanvasFrame.Width(); th = fCanvasFrame.Height(); - bzero (temp->Bits(), temp->BitsLength()); + bzero(temp->Bits(), temp->BitsLength()); tolerance = tAttribFill->getTolerance(); toleranceRGB = tAttribFill->getToleranceRGB(); - fillcolor = getColor (point); - fill32 = PIXEL (fillcolor.red, fillcolor.green, fillcolor.blue, fillcolor.alpha); - PointStack ps (point); - tplot8 (point); - tempView->Sync (); + fillcolor = getColor(point); + fill32 = PIXEL(fillcolor.red, fillcolor.green, fillcolor.blue, fillcolor.alpha); + PointStack ps(point); + tplot8(point); + tempView->Sync(); // printf ("Everything set up - entering loop\n"); - if (((tAttribFill->getTolMode() == FILLTOL_TOL) && (tolerance == 0)) - || (tAttribFill->getTolMode() == FILLTOL_RGB) && (toleranceRGB.red == 0) - && (toleranceRGB.green == 0) && (toleranceRGB.blue == 0)) - { // Use the special case functions for zero tolerance - while (!(ps.isempty ())) - { - LPoint p = ps.pop (); + if (((tAttribFill->getTolMode() == FILLTOL_TOL) && (tolerance == 0)) || + (tAttribFill->getTolMode() == FILLTOL_RGB) && (toleranceRGB.red == 0) && + (toleranceRGB.green == 0) && + (toleranceRGB.blue == 0)) { // Use the special case functions for zero tolerance + while (!(ps.isempty())) { + LPoint p = ps.pop(); LPoint next; - next = LPoint (p.x + 1, p.y); - if (inbounds (next) && istransparent8 (next) && isfillcolor0 (next)) - { -// if (next.x > frame.right) -// frame.right++; - tplot8 (next); - ps.push (next); + next = LPoint(p.x + 1, p.y); + if (inbounds(next) && istransparent8(next) && isfillcolor0(next)) { + // if (next.x > frame.right) + // frame.right++; + tplot8(next); + ps.push(next); } - next = LPoint (p.x - 1, p.y); - if (inbounds (next) && istransparent8 (next) && isfillcolor0 (next)) - { -// if (next.x < frame.left) -// frame.left--; - tplot8 (next); - ps.push (next); + next = LPoint(p.x - 1, p.y); + if (inbounds(next) && istransparent8(next) && isfillcolor0(next)) { + // if (next.x < frame.left) + // frame.left--; + tplot8(next); + ps.push(next); } - next = LPoint (p.x, p.y + 1); - if (inbounds (next) && istransparent8 (next) && isfillcolor0 (next)) - { -// if (next.y > frame.bottom) -// frame.bottom++; - tplot8 (next); - ps.push (next); + next = LPoint(p.x, p.y + 1); + if (inbounds(next) && istransparent8(next) && isfillcolor0(next)) { + // if (next.y > frame.bottom) + // frame.bottom++; + tplot8(next); + ps.push(next); } - next = LPoint (p.x, p.y - 1); - if (inbounds (next) && istransparent8 (next) && isfillcolor0 (next)) - { -// if (next.y < frame.top) -// frame.top--; - tplot8 (next); - ps.push (next); + next = LPoint(p.x, p.y - 1); + if (inbounds(next) && istransparent8(next) && isfillcolor0(next)) { + // if (next.y < frame.top) + // frame.top--; + tplot8(next); + ps.push(next); } -// snooze (0); -// tempView->Sync (); + // snooze (0); + // tempView->Sync (); } - } - else if (tAttribFill->getTolMode() == FILLTOL_TOL) - { - while (!(ps.isempty ())) - { + } else if (tAttribFill->getTolMode() == FILLTOL_TOL) { + while (!(ps.isempty())) { uchar t; - LPoint p = ps.pop (); + LPoint p = ps.pop(); LPoint next; - next = BPoint (p.x + 1, p.y); - if (inbounds (next) && istransparent8 (next) && isfillcolort (next, &t)) - { -// if (next.x > frame.right) -// frame.right++; - tplot8 (next, t); - ps.push (next); + next = BPoint(p.x + 1, p.y); + if (inbounds(next) && istransparent8(next) && isfillcolort(next, &t)) { + // if (next.x > frame.right) + // frame.right++; + tplot8(next, t); + ps.push(next); } - next = LPoint (p.x - 1, p.y); - if (inbounds (next) && istransparent8 (next) && isfillcolort (next, &t)) - { -// if (next.x < frame.left) -// frame.left--; - tplot8 (next, t); - ps.push (next); + next = LPoint(p.x - 1, p.y); + if (inbounds(next) && istransparent8(next) && isfillcolort(next, &t)) { + // if (next.x < frame.left) + // frame.left--; + tplot8(next, t); + ps.push(next); } - next = LPoint (p.x, p.y + 1); - if (inbounds (next) && istransparent8 (next) && isfillcolort (next, &t)) - { -// if (next.y > frame.bottom) -// frame.bottom++; - tplot8 (next, t); - ps.push (next); + next = LPoint(p.x, p.y + 1); + if (inbounds(next) && istransparent8(next) && isfillcolort(next, &t)) { + // if (next.y > frame.bottom) + // frame.bottom++; + tplot8(next, t); + ps.push(next); } - next = LPoint (p.x, p.y - 1); - if (inbounds (next) && istransparent8 (next) && isfillcolort (next, &t)) - { -// if (next.y < frame.top) -// frame.top--; - tplot8 (next, t); - ps.push (next); + next = LPoint(p.x, p.y - 1); + if (inbounds(next) && istransparent8(next) && isfillcolort(next, &t)) { + // if (next.y < frame.top) + // frame.top--; + tplot8(next, t); + ps.push(next); } -// snooze (0); -// tempView->Sync (); + // snooze (0); + // tempView->Sync (); } - } - else - { - while (!(ps.isempty ())) - { + } else { + while (!(ps.isempty())) { uchar t; - LPoint p = ps.pop (); + LPoint p = ps.pop(); LPoint next; - next = LPoint (p.x + 1, p.y); - if (inbounds (next) && istransparent8 (next) && isfillcolorrgb (next, &t)) - { -// if (next.x > frame.right) -// frame.right++; - tplot8 (next, t); - ps.push (next); + next = LPoint(p.x + 1, p.y); + if (inbounds(next) && istransparent8(next) && isfillcolorrgb(next, &t)) { + // if (next.x > frame.right) + // frame.right++; + tplot8(next, t); + ps.push(next); } - next = LPoint (p.x - 1, p.y); - if (inbounds (next) && istransparent8 (next) && isfillcolorrgb (next, &t)) - { -// if (next.x < frame.left) -// frame.left--; - tplot8 (next, t); - ps.push (next); + next = LPoint(p.x - 1, p.y); + if (inbounds(next) && istransparent8(next) && isfillcolorrgb(next, &t)) { + // if (next.x < frame.left) + // frame.left--; + tplot8(next, t); + ps.push(next); } - next = LPoint (p.x, p.y + 1); - if (inbounds (next) && istransparent8 (next) && isfillcolorrgb (next, &t)) - { -// if (next.y > frame.bottom) -// frame.bottom++; - tplot8 (next, t); - ps.push (next); + next = LPoint(p.x, p.y + 1); + if (inbounds(next) && istransparent8(next) && isfillcolorrgb(next, &t)) { + // if (next.y > frame.bottom) + // frame.bottom++; + tplot8(next, t); + ps.push(next); } - next = LPoint (p.x, p.y - 1); - if (inbounds (next) && istransparent8 (next) && isfillcolorrgb (next, &t)) - { -// if (next.y < frame.top) -// frame.top--; - tplot8 (next, t); - ps.push (next); + next = LPoint(p.x, p.y - 1); + if (inbounds(next) && istransparent8(next) && isfillcolorrgb(next, &t)) { + // if (next.y < frame.top) + // frame.top--; + tplot8(next, t); + ps.push(next); } -// snooze (0); -// tempView->Sync (); + // snooze (0); + // tempView->Sync (); } } - + // printf ("Exited loop.\n"); pattern curpat = pat->pat(); - BBitmap *temp2 = new BBitmap (fCanvasFrame, B_BITMAP_ACCEPTS_VIEWS, B_RGBA32); - SView *temp2View = new SView (fCanvasFrame, "Temp2View for Fill", B_FOLLOW_NONE, uint32 (NULL)); + BBitmap* temp2 = new BBitmap(fCanvasFrame, B_BITMAP_ACCEPTS_VIEWS, B_RGBA32); + SView* temp2View = new SView(fCanvasFrame, "Temp2View for Fill", B_FOLLOW_NONE, uint32(NULL)); temp2->Lock(); - temp2->AddChild (temp2View); - temp2View->SetDrawingMode (B_OP_COPY); - if (buttons & B_PRIMARY_MOUSE_BUTTON) - { - temp2View->SetHighColor (hicolor->color()); - temp2View->SetLowColor (locolor->color()); - } - if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { - temp2View->SetHighColor (locolor->color()); - temp2View->SetLowColor (hicolor->color()); - } - if (c) - { - temp2View->SetHighColor (*c); - temp2View->FillRect (temp2->Bounds()); - } - else - { - temp2View->FillRect (temp2->Bounds(), curpat); + temp2->AddChild(temp2View); + temp2View->SetDrawingMode(B_OP_COPY); + if (buttons & B_PRIMARY_MOUSE_BUTTON) { + temp2View->SetHighColor(hicolor->color()); + temp2View->SetLowColor(locolor->color()); + } + if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { + temp2View->SetHighColor(locolor->color()); + temp2View->SetLowColor(hicolor->color()); + } + if (c) { + temp2View->SetHighColor(*c); + temp2View->FillRect(temp2->Bounds()); + } else { + temp2View->FillRect(temp2->Bounds(), curpat); } temp2View->Sync(); - // Change the following code some day to only iterate over BRect frame, since we have that anyway. - // printf ("Adding alpha channel to temp bitmap\n"); + // Change the following code some day to only iterate over BRect frame, since we have that + // anyway. printf ("Adding alpha channel to temp bitmap\n"); selection->Lock(); - uint32 *t2bits = (uint32 *) temp2->Bits(); - tbits = (uchar *) temp->Bits() - 1; - long tbprdif = long (tbpr - tw - 1); - for (long i = 0; i <= th; i++) - { - for (long j = 0; j <= tw; j++) - { - uchar *pixel = (uchar *) t2bits++; - pixel[3] = (pixel[3]* *(++tbits))/255; + uint32* t2bits = (uint32*)temp2->Bits(); + tbits = (uchar*)temp->Bits() - 1; + long tbprdif = long(tbpr - tw - 1); + for (long i = 0; i <= th; i++) { + for (long j = 0; j <= tw; j++) { + uchar* pixel = (uchar*)t2bits++; + pixel[3] = (pixel[3] * *(++tbits)) / 255; } tbits += tbprdif; } // printf ("Do the actual drawing\n"); - if (mode == M_DRAW) - { + if (mode == M_DRAW) { if (mAttribDraw->getDrawingMode() == B_OP_BLEND) - BlendWithAlpha (temp2, currentLayer(), 0, 0); + BlendWithAlpha(temp2, currentLayer(), 0, 0); else - AddWithAlpha (temp2, currentLayer(), 0, 0); - } - else - { - uchar *sbits = (uchar *) selection->Bits(); - long sbprdif = selection->BytesPerRow() - long (tw) - 1; - t2bits = (uint32 *) temp2->Bits(); + AddWithAlpha(temp2, currentLayer(), 0, 0); + } else { + uchar* sbits = (uchar*)selection->Bits(); + long sbprdif = selection->BytesPerRow() - long(tw) - 1; + t2bits = (uint32*)temp2->Bits(); uchar hir = temp2View->HighColor().red; uchar hig = temp2View->HighColor().green; uchar hib = temp2View->HighColor().blue; - for (long i = 0; i <= th; i++) - { - for (long j = 0; j <= tw; j++) - { - uchar *pixel = (uchar *) t2bits++; + for (long i = 0; i <= th; i++) { + for (long j = 0; j <= tw; j++) { + uchar* pixel = (uchar*)t2bits++; if (pixel[0] == hib && pixel[1] == hig && pixel[2] == hir && pixel[3]) *sbits = pixel[3]; sbits++; @@ -3383,36 +3257,36 @@ void CanvasView::tFill (int32 mode, BPoint point, uint32 buttons, rgb_color *c) delete temp; delete temp2; currentLayer()->Unlock(); - Invalidate (/*frame*/); + Invalidate(/*frame*/); mainapp->setReady(); } -void CanvasView::tSetColors (uint32 buttons) +void +CanvasView::tSetColors(uint32 buttons) { extern ColorMenuButton *hicolor, *locolor; rgb_color lo = locolor->color(); rgb_color hi = hicolor->color(); - if (buttons & B_PRIMARY_MOUSE_BUTTON) - { + if (buttons & B_PRIMARY_MOUSE_BUTTON) { BScreen screen; - drawView->SetHighColor (hi); - drawView->SetLowColor (lo); - SetHighColor (hi); - SetLowColor (lo); -// selectionView->SetLowColor (screen.ColorMap()->color_list[(lo.red + lo.green + lo.blue)/3]); -// selectionView->SetHighColor (screen.ColorMap()->color_list[(hi.red + hi.green + hi.blue)/3]); - selectionView->SetLowColor (SELECT_NONE); - selectionView->SetHighColor (SELECT_FULL); - } - if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { + drawView->SetHighColor(hi); + drawView->SetLowColor(lo); + SetHighColor(hi); + SetLowColor(lo); + // selectionView->SetLowColor (screen.ColorMap()->color_list[(lo.red + lo.green + + // lo.blue)/3]); selectionView->SetHighColor (screen.ColorMap()->color_list[(hi.red + + // hi.green + hi.blue)/3]); + selectionView->SetLowColor(SELECT_NONE); + selectionView->SetHighColor(SELECT_FULL); + } + if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { BScreen screen; - drawView->SetHighColor (lo); - drawView->SetLowColor (hi); - SetHighColor (lo); - SetLowColor (hi); - selectionView->SetLowColor (screen.ColorMap()->color_list[hi.alpha]); - selectionView->SetHighColor (screen.ColorMap()->color_list[lo.alpha]); + drawView->SetHighColor(lo); + drawView->SetLowColor(hi); + SetHighColor(lo); + SetLowColor(hi); + selectionView->SetLowColor(screen.ColorMap()->color_list[hi.alpha]); + selectionView->SetHighColor(screen.ColorMap()->color_list[lo.alpha]); } } diff --git a/source/CanvasView.cpp b/source/CanvasView.cpp index 24d13bc..859c393 100644 --- a/source/CanvasView.cpp +++ b/source/CanvasView.cpp @@ -42,289 +42,272 @@ #define BLEND_USES_SHIFTS -static BRect PreviewRect() +static BRect +PreviewRect() { extern BLocker g_settings_lock; extern becasso_settings g_settings; g_settings_lock.Lock(); - BRect rect (0, 0, g_settings.preview_size - 1, g_settings.preview_size - 1); + BRect rect(0, 0, g_settings.preview_size - 1, g_settings.preview_size - 1); g_settings_lock.Unlock(); return rect; } -status_t GetExportingTranslators (BMessage *inHere); -uint32 TypeCodeForMIME (const char *MIME); +status_t +GetExportingTranslators(BMessage* inHere); +uint32 +TypeCodeForMIME(const char* MIME); -CanvasView::CanvasView (const BRect frame, const char *name, BBitmap *map, rgb_color color) -: SView (frame, name, B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED | B_SUBPIXEL_PRECISE) +CanvasView::CanvasView(const BRect frame, const char* name, BBitmap* map, rgb_color color) + : SView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW | B_PULSE_NEEDED | B_SUBPIXEL_PRECISE) { -// printf ("Map version\n"); - SetViewColor (DarkGrey); + // printf ("Map version\n"); + SetViewColor(DarkGrey); BRect bitmapRect; - if (map) - { + if (map) { bitmapRect = map->Bounds(); - } - else - { - bitmapRect.Set (0, 0, frame.Width(), frame.Height()); + } else { + bitmapRect.Set(0, 0, frame.Width(), frame.Height()); } fCanvasFrame = bitmapRect; - layer[0] = new Layer (bitmapRect, lstring (162, "Background")); + layer[0] = new Layer(bitmapRect, lstring(162, "Background")); fCurrentLayer = 0; fNumLayers = 1; - drawView = new SView (bitmapRect, name, B_FOLLOW_NONE, uint32 (NULL)); + drawView = new SView(bitmapRect, name, B_FOLLOW_NONE, uint32(NULL)); layer[0]->Lock(); - layer[0]->AddChild (drawView); - drawView->SetDrawingMode (B_OP_COPY); - if (map) - { - if (map->ColorSpace() == B_COLOR_8_BIT) // This should *NOT* be necessary! + layer[0]->AddChild(drawView); + drawView->SetDrawingMode(B_OP_COPY); + if (map) { + if (map->ColorSpace() == B_COLOR_8_BIT) // This should *NOT* be necessary! { - const color_map *cmap = system_colors(); - const rgb_color *palette = cmap->color_list; + const color_map* cmap = system_colors(); + const rgb_color* palette = cmap->color_list; rgb_color color; - uint8 *sourceptrb = (uint8 *) map->Bits(); - uint8 *rowptr = sourceptrb; - uint8 *destptrb = (uint8 *) layer[0]->Bits() - 1; + uint8* sourceptrb = (uint8*)map->Bits(); + uint8* rowptr = sourceptrb; + uint8* destptrb = (uint8*)layer[0]->Bits() - 1; int32 x, y, deltarow = map->BytesPerRow(); int32 numrows = map->Bounds().IntegerHeight() + 1; int32 numcolumns = map->Bounds().IntegerWidth() + 1; uint8 pixelb; - for (y = 0; y < numrows; y++) - { + for (y = 0; y < numrows; y++) { sourceptrb = rowptr - 1; - for (x = 0; x < numcolumns; x++) - { + for (x = 0; x < numcolumns; x++) { pixelb = *(++sourceptrb); color = palette[pixelb]; *(++destptrb) = color.blue; *(++destptrb) = color.green; *(++destptrb) = color.red; - *(++destptrb) = 255; // opaque + *(++destptrb) = 255; // opaque } rowptr += deltarow; } - } - else - { - drawView->DrawBitmapAsync (map, B_ORIGIN); + } else { + drawView->DrawBitmapAsync(map, B_ORIGIN); drawView->Sync(); -// uint8 *srcptr = (uint8 *) map->Bits(); -// uint8 *lptr = (uint8 *) layer[0]->Bits(); -// printf ("b = %i, g = %i, r = %i, a = %i\n", *srcptr++, *srcptr++, *srcptr++, *srcptr); -// printf ("b = %i, g = %i, r = %i, a = %i\n", *lptr++, *lptr++, *lptr++, *lptr); - } - } - else - { - drawView->SetLowColor (color); - drawView->FillRect (bitmapRect, B_SOLID_LOW); + // uint8 *srcptr = (uint8 *) map->Bits(); + // uint8 *lptr = (uint8 *) layer[0]->Bits(); + // printf ("b = %i, g = %i, r = %i, a = %i\n", *srcptr++, *srcptr++, *srcptr++, + //*srcptr); printf ("b = %i, g = %i, r = %i, a = %i\n", *lptr++, *lptr++, + //*lptr++, *lptr); + } + } else { + drawView->SetLowColor(color); + drawView->FillRect(bitmapRect, B_SOLID_LOW); drawView->Sync(); } layer[0]->Unlock(); - RestOfCtor (); + RestOfCtor(); } -CanvasView::CanvasView (const BRect frame, const char *name, FILE *fp) -: SView (frame, name, B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED) +CanvasView::CanvasView(const BRect frame, const char* name, FILE* fp) + : SView(frame, name, B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED) { -// printf ("*fp version\n"); - SetViewColor (B_TRANSPARENT_32_BIT); + // printf ("*fp version\n"); + SetViewColor(B_TRANSPARENT_32_BIT); BRect bitmapRect; - bitmapRect.Set (0, 0, frame.Width(), frame.Height()); + bitmapRect.Set(0, 0, frame.Width(), frame.Height()); fCanvasFrame = bitmapRect; - rewind (fp); + rewind(fp); char line[81]; - do - { - fgets (line, 80, fp); - } while (line[0] == '#'); - char *endp = line; - float vers = strtod (endp, &endp); - fNumLayers = strtol (endp, &endp, 10); - fCurrentLayer = strtol (endp, &endp, 10); - /*int32 dpi = */strtol (endp, &endp, 10); // not used - int watermarked = strtol (endp, &endp, 10); // watermarked image? - switch (int (vers)) - { + do { + fgets(line, 80, fp); + } while (line[0] == '#'); + char* endp = line; + float vers = strtod(endp, &endp); + fNumLayers = strtol(endp, &endp, 10); + fCurrentLayer = strtol(endp, &endp, 10); + /*int32 dpi = */ strtol(endp, &endp, 10); // not used + int watermarked = strtol(endp, &endp, 10); // watermarked image? + switch (int(vers)) { case 0: - for (int i = 0; i < fNumLayers; i++) - { - fgets (line, 80, fp); + for (int i = 0; i < fNumLayers; i++) { + fgets(line, 80, fp); line[strlen(line) - 1] = 0; endp = line; BRect lFrame; - lFrame.left = strtod (endp, &endp); - lFrame.top = strtod (endp, &endp); - lFrame.right = strtod (endp, &endp); - lFrame.bottom = strtod (endp, &endp); -// int m = strtol (endp, &endp, 10); - bool h = strtol (endp, &endp, 10); - layer[i] = new Layer (lFrame, endp); - layer[i]->Hide (h); - layer[i]->setMode (0); // Note: DM_BLEND has moved to 0, and <1.1 didn't have any other ops anyway. - fread (layer[i]->Bits(), layer[i]->BitsLength(), 1, fp); + lFrame.left = strtod(endp, &endp); + lFrame.top = strtod(endp, &endp); + lFrame.right = strtod(endp, &endp); + lFrame.bottom = strtod(endp, &endp); + // int m = strtol (endp, &endp, 10); + bool h = strtol(endp, &endp, 10); + layer[i] = new Layer(lFrame, endp); + layer[i]->Hide(h); + layer[i]->setMode(0 + ); // Note: DM_BLEND has moved to 0, and <1.1 didn't have any other ops anyway. + fread(layer[i]->Bits(), layer[i]->BitsLength(), 1, fp); } break; - case 1: - { - uchar *tmpzbuf = NULL; + case 1: { + uchar* tmpzbuf = NULL; z_streamp zstream = new z_stream; zstream->zalloc = Z_NULL; zstream->zfree = Z_NULL; zstream->opaque = Z_NULL; - if (inflateInit (zstream) != Z_OK) - { - fprintf (stderr, "Oops! Problems with inflateInit()...\n"); + if (inflateInit(zstream) != Z_OK) { + fprintf(stderr, "Oops! Problems with inflateInit()...\n"); } - for (int i = 0; i < fNumLayers; i++) - { - fgets (line, 80, fp); + for (int i = 0; i < fNumLayers; i++) { + fgets(line, 80, fp); line[strlen(line) - 1] = 0; endp = line; BRect lFrame; - lFrame.left = strtod (endp, &endp); - lFrame.top = strtod (endp, &endp); - lFrame.right = strtod (endp, &endp); - lFrame.bottom = strtod (endp, &endp); - int m = strtol (endp, &endp, 10); - bool h = strtol (endp, &endp, 10); - uchar ga = strtol (endp, &endp, 10); - if (vers > 1.1) - { - /* int am = */strtol (endp, &endp, 10); + lFrame.left = strtod(endp, &endp); + lFrame.top = strtod(endp, &endp); + lFrame.right = strtod(endp, &endp); + lFrame.bottom = strtod(endp, &endp); + int m = strtol(endp, &endp, 10); + bool h = strtol(endp, &endp, 10); + uchar ga = strtol(endp, &endp, 10); + if (vers > 1.1) { + /* int am = */ strtol(endp, &endp, 10); // printf ("%salpha map\n", am ? "" : "no "); } - layer[i] = new Layer (lFrame, endp); - layer[i]->Hide (h); + layer[i] = new Layer(lFrame, endp); + layer[i]->Hide(h); if (vers == 1.0) - layer[i]->setMode (0); // Note: DM_BLEND has moved to 0, and <1.1 didn't have any other ops anyway. + layer[i]->setMode(0 + ); // Note: DM_BLEND has moved to 0, and <1.1 didn't have any other ops anyway. else - layer[i]->setMode (m); - layer[i]->setGlobalAlpha (ga); - layer[i]->setAlphaMap (NULL); + layer[i]->setMode(m); + layer[i]->setGlobalAlpha(ga); + layer[i]->setAlphaMap(NULL); } - for (int i = 0; i < fNumLayers; i++) - { - if (!tmpzbuf) - { - tmpzbuf = new uchar [layer[i]->BitsLength()]; + for (int i = 0; i < fNumLayers; i++) { + if (!tmpzbuf) { + tmpzbuf = new uchar[layer[i]->BitsLength()]; zstream->avail_in = 0; } zstream->next_in = tmpzbuf; - zstream->avail_in += fread (tmpzbuf, 1, layer[i]->BitsLength() - zstream->avail_in, fp); - zstream->next_out = (uchar *) layer[i]->Bits(); + zstream->avail_in += fread(tmpzbuf, 1, layer[i]->BitsLength() - zstream->avail_in, fp); + zstream->next_out = (uchar*)layer[i]->Bits(); zstream->avail_out = layer[i]->BitsLength(); -// printf ("avail_in = %li, avail_out = %li\n", zstream->avail_in, zstream->avail_out); - if (inflate (zstream, Z_FINISH) != Z_STREAM_END) - { - fprintf (stderr, "Oops! Layer couldn't be decompressed completely...\n"); + // printf ("avail_in = %li, avail_out = %li\n", zstream->avail_in, + // zstream->avail_out); + if (inflate(zstream, Z_FINISH) != Z_STREAM_END) { + fprintf(stderr, "Oops! Layer couldn't be decompressed completely...\n"); } - memmove (tmpzbuf, zstream->next_in, zstream->avail_in); - inflateReset (zstream); + memmove(tmpzbuf, zstream->next_in, zstream->avail_in); + inflateReset(zstream); } - if (inflateEnd (zstream) != Z_OK) - { - fprintf (stderr, "Oops! Temporary zlib buffer couldn't be deallocated\n"); + if (inflateEnd(zstream) != Z_OK) { + fprintf(stderr, "Oops! Temporary zlib buffer couldn't be deallocated\n"); } - delete [] tmpzbuf; + delete[] tmpzbuf; delete zstream; if (watermarked) - InsertGlobalAlpha (layer, fNumLayers); + InsertGlobalAlpha(layer, fNumLayers); break; } - case 2: - { - uchar *tmpzbuf = NULL; + case 2: { + uchar* tmpzbuf = NULL; z_streamp zstream = new z_stream; zstream->zalloc = Z_NULL; zstream->zfree = Z_NULL; zstream->opaque = Z_NULL; - if (inflateInit (zstream) != Z_OK) - { - fprintf (stderr, "Oops! Problems with inflateInit()...\n"); + if (inflateInit(zstream) != Z_OK) { + fprintf(stderr, "Oops! Problems with inflateInit()...\n"); } - for (int i = 0; i < fNumLayers; i++) - { - fgets (line, 80, fp); + for (int i = 0; i < fNumLayers; i++) { + fgets(line, 80, fp); line[strlen(line) - 1] = 0; endp = line; BRect lFrame; - lFrame.left = strtod (endp, &endp); - lFrame.top = strtod (endp, &endp); - lFrame.right = strtod (endp, &endp); - lFrame.bottom = strtod (endp, &endp); - int m = strtol (endp, &endp, 10); - bool h = strtol (endp, &endp, 10); - uchar ga = strtol (endp, &endp, 10); - if (vers > 1.1) - { - /* int am = */strtol (endp, &endp, 10); + lFrame.left = strtod(endp, &endp); + lFrame.top = strtod(endp, &endp); + lFrame.right = strtod(endp, &endp); + lFrame.bottom = strtod(endp, &endp); + int m = strtol(endp, &endp, 10); + bool h = strtol(endp, &endp, 10); + uchar ga = strtol(endp, &endp, 10); + if (vers > 1.1) { + /* int am = */ strtol(endp, &endp, 10); // printf ("%salpha map\n", am ? "" : "no "); } - layer[i] = new Layer (lFrame, endp + 1); - layer[i]->Hide (h); + layer[i] = new Layer(lFrame, endp + 1); + layer[i]->Hide(h); if (vers == 1.0) - layer[i]->setMode (0); // Note: DM_BLEND has moved to 0, and <1.1 didn't have any other ops anyway. + layer[i]->setMode(0 + ); // Note: DM_BLEND has moved to 0, and <1.1 didn't have any other ops anyway. else - layer[i]->setMode (m); - layer[i]->setGlobalAlpha (ga); - layer[i]->setAlphaMap (NULL); + layer[i]->setMode(m); + layer[i]->setGlobalAlpha(ga); + layer[i]->setAlphaMap(NULL); } - for (int i = 0; i < fNumLayers; i++) - { - if (!tmpzbuf) - { - tmpzbuf = new uchar [layer[i]->BitsLength()]; + for (int i = 0; i < fNumLayers; i++) { + if (!tmpzbuf) { + tmpzbuf = new uchar[layer[i]->BitsLength()]; zstream->avail_in = 0; } zstream->next_in = tmpzbuf; - zstream->avail_in += fread (tmpzbuf, 1, layer[i]->BitsLength() - zstream->avail_in, fp); - zstream->next_out = (uchar *) layer[i]->Bits(); + zstream->avail_in += fread(tmpzbuf, 1, layer[i]->BitsLength() - zstream->avail_in, fp); + zstream->next_out = (uchar*)layer[i]->Bits(); zstream->avail_out = layer[i]->BitsLength(); -// printf ("avail_in = %li, avail_out = %li\n", zstream->avail_in, zstream->avail_out); - if (inflate (zstream, Z_FINISH) != Z_STREAM_END) - { - fprintf (stderr, "Oops! Layer couldn't be decompressed completely...\n"); + // printf ("avail_in = %li, avail_out = %li\n", zstream->avail_in, + // zstream->avail_out); + if (inflate(zstream, Z_FINISH) != Z_STREAM_END) { + fprintf(stderr, "Oops! Layer couldn't be decompressed completely...\n"); } - memmove (tmpzbuf, zstream->next_in, zstream->avail_in); - inflateReset (zstream); + memmove(tmpzbuf, zstream->next_in, zstream->avail_in); + inflateReset(zstream); } - if (inflateEnd (zstream) != Z_OK) - { - fprintf (stderr, "Oops! Temporary zlib buffer couldn't be deallocated\n"); + if (inflateEnd(zstream) != Z_OK) { + fprintf(stderr, "Oops! Temporary zlib buffer couldn't be deallocated\n"); } - delete [] tmpzbuf; + delete[] tmpzbuf; delete zstream; if (watermarked) - InsertGlobalAlpha (layer, fNumLayers); + InsertGlobalAlpha(layer, fNumLayers); break; } - default: // This should never happen - fprintf (stderr, "Hmm, somehow a newer version file got through to the actual loading routine.\n"); + default: // This should never happen + fprintf( + stderr, "Hmm, somehow a newer version file got through to the actual loading routine.\n" + ); } - fclose (fp); + fclose(fp); - drawView = new SView (bitmapRect, name, B_FOLLOW_NONE, B_SUBPIXEL_PRECISE); - currentLayer()->AddChild (drawView); - RestOfCtor (); + drawView = new SView(bitmapRect, name, B_FOLLOW_NONE, B_SUBPIXEL_PRECISE); + currentLayer()->AddChild(drawView); + RestOfCtor(); } -void CanvasView::RestOfCtor () +void +CanvasView::RestOfCtor() { - selection = new Selection (fCanvasFrame); - selectionView = new SView (fCanvasFrame, "Selection View", B_FOLLOW_NONE, B_SUBPIXEL_PRECISE); - selection->AddChild (selectionView); - SetViewColor (B_TRANSPARENT_32_BIT); + selection = new Selection(fCanvasFrame); + selectionView = new SView(fCanvasFrame, "Selection View", B_FOLLOW_NONE, B_SUBPIXEL_PRECISE); + selection->AddChild(selectionView); + SetViewColor(B_TRANSPARENT_32_BIT); selchanged = false; prevPaste = fCanvasFrame; prev_eraser = fCanvasFrame; @@ -334,7 +317,7 @@ void CanvasView::RestOfCtor () prevTool = -1; mouse_on_canvas = false; polygon = new BPolygon; - polypoint = BPoint (-1, -1); + polypoint = BPoint(-1, -1); tolerance = 0; toleranceRGB.red = 0; toleranceRGB.green = 0; @@ -344,18 +327,17 @@ void CanvasView::RestOfCtor () fIndex1 = -1; fIndex2 = -1; maxUndo = 0; - for (int i = 0; i < MAX_UNDO; i++) - { - undo[i].bitmap = NULL; + for (int i = 0; i < MAX_UNDO; i++) { + undo[i].bitmap = NULL; undo[i].sbitmap = NULL; } myWindow = NULL; windowLock = false; -// extern bool inPaste, inDrag; -// if (inPaste) -// printf ("inPaste\n"); -// if (inDrag) -// printf ("inDrag\n"); + // extern bool inPaste, inDrag; + // if (inPaste) + // printf ("inPaste\n"); + // if (inDrag) + // printf ("inDrag\n"); firstDrag = true; first = true; sel = false; @@ -371,12 +353,12 @@ void CanvasView::RestOfCtor () filterOpen = NULL; transformerOpen = NULL; generatorOpen = NULL; - previewLayer = new Layer (fPreviewRect, "Preview Layer"); - previewSelection = new Selection (fPreviewRect); + previewLayer = new Layer(fPreviewRect, "Preview Layer"); + previewSelection = new Selection(fPreviewRect); didPreview = 0; transformerSaved = false; generatorSaved = false; -// addonInQueue = NULL; + // addonInQueue = NULL; fCurrentProperty = 0; fLayerSpecifier = -1; fTreshold = 0; @@ -387,14 +369,14 @@ void CanvasView::RestOfCtor () fDragScroll = false; fTranslating = false; fRotating = false; - fLastCenter = BPoint (fCanvasFrame.Width()/2, fCanvasFrame.Height()/2); + fLastCenter = BPoint(fCanvasFrame.Width() / 2, fCanvasFrame.Height() / 2); } -CanvasView::~CanvasView () +CanvasView::~CanvasView() { - extern Becasso *mainapp; + extern Becasso* mainapp; mainapp->setHand(); - layer[fCurrentLayer]->RemoveChild (drawView); + layer[fCurrentLayer]->RemoveChild(drawView); delete drawView; for (int i = 0; i < fNumLayers; i++) @@ -405,12 +387,11 @@ CanvasView::~CanvasView () delete screenbitmap; delete polygon; - selection->RemoveChild (selectionView); + selection->RemoveChild(selectionView); delete selectionView; delete selection; - for (int i = 0; i < MAX_UNDO; i++) - { + for (int i = 0; i < MAX_UNDO; i++) { delete undo[i].bitmap; delete undo[i].sbitmap; } @@ -418,574 +399,570 @@ CanvasView::~CanvasView () delete cutbg; delete previewLayer; delete previewSelection; -// delete cutView; + // delete cutView; } -void CanvasView::AttachedToWindow () +void +CanvasView::AttachedToWindow() { extern bool inPaste; bool wasInPaste = inPaste; // printf ("Attached to window%s.\n", inPaste ? " while in paste" : ""); inPaste = false; - extern BBitmap *clip; + extern BBitmap* clip; BScreen screen; - if (screen.ColorSpace() == B_COLOR_8_BIT) - { - screenbitmap = new BBitmap (fCanvasFrame, B_COLOR_8_BIT, true); - screenbitmap32 = new BBitmap (fCanvasFrame, B_RGBA32, true); - } - else // 32 or 16 bit screens + if (screen.ColorSpace() == B_COLOR_8_BIT) { + screenbitmap = new BBitmap(fCanvasFrame, B_COLOR_8_BIT, true); + screenbitmap32 = new BBitmap(fCanvasFrame, B_RGBA32, true); + } else // 32 or 16 bit screens { - screenbitmap = new BBitmap (fCanvasFrame, B_RGBA32, true); + screenbitmap = new BBitmap(fCanvasFrame, B_RGBA32, true); screenbitmap32 = screenbitmap; } -// totaldatalen = (fCanvasFrame.IntegerWidth() + 1)*(fCanvasFrame.IntegerHeight() + 1)*3; -// totaldata = new uchar [totaldatalen]; + // totaldatalen = (fCanvasFrame.IntegerWidth() + 1)*(fCanvasFrame.IntegerHeight() + 1)*3; + // totaldata = new uchar [totaldatalen]; - FrameResized (Bounds().Width(), Bounds().Height()); + FrameResized(Bounds().Width(), Bounds().Height()); // This is here to get the scrollbars right. - myWindow = (CanvasWindow *)Window(); + myWindow = (CanvasWindow*)Window(); myWindow->Lock(); - myWindow->setMenuItem (B_UNDO, false); - myWindow->setMenuItem ('redo', false); - myWindow->setMenuItem (B_CUT, false); - myWindow->setMenuItem (B_COPY, false); - myWindow->setMenuItem ('csel', false); - myWindow->setPaste (clip != NULL); - myWindow->setMenuItem ('sund', false); - myWindow->setMenuItem ('sinv', false); - if (wasInPaste) - { - Paste (true); + myWindow->setMenuItem(B_UNDO, false); + myWindow->setMenuItem('redo', false); + myWindow->setMenuItem(B_CUT, false); + myWindow->setMenuItem(B_COPY, false); + myWindow->setMenuItem('csel', false); + myWindow->setPaste(clip != NULL); + myWindow->setMenuItem('sund', false); + myWindow->setMenuItem('sinv', false); + if (wasInPaste) { + Paste(true); } myWindow->Unlock(); Invalidate(); MakeFocus(); } -void CanvasView::ScreenChanged (BRect /* frame */, color_space mode) +void +CanvasView::ScreenChanged(BRect /* frame */, color_space mode) { - if (mode == B_COLOR_8_BIT) - { - if (screenbitmap->ColorSpace() != B_COLOR_8_BIT) - { + if (mode == B_COLOR_8_BIT) { + if (screenbitmap->ColorSpace() != B_COLOR_8_BIT) { delete screenbitmap; - screenbitmap = new BBitmap (fCanvasFrame, B_COLOR_8_BIT, true); - screenbitmap32 = new BBitmap (fCanvasFrame, B_RGBA32, true); + screenbitmap = new BBitmap(fCanvasFrame, B_COLOR_8_BIT, true); + screenbitmap32 = new BBitmap(fCanvasFrame, B_RGBA32, true); } - } - else - { - if (screenbitmap->ColorSpace() == B_COLOR_8_BIT) - { + } else { + if (screenbitmap->ColorSpace() == B_COLOR_8_BIT) { delete screenbitmap32; delete screenbitmap; - screenbitmap = new BBitmap (fCanvasFrame, B_RGBA32, true); + screenbitmap = new BBitmap(fCanvasFrame, B_RGBA32, true); screenbitmap32 = screenbitmap; } } Invalidate(); } -void CanvasView::FrameResized (float width, float height) +void +CanvasView::FrameResized(float width, float height) { - SView::FrameResized (width, height); + SView::FrameResized(width, height); } -void CanvasView::setScale (float s, bool invalidate) +void +CanvasView::setScale(float s, bool invalidate) { BRect frame; -// frame.right = (fCanvasFrame.right + 1)*s - 1; -// frame.bottom = (fCanvasFrame.bottom + 1)*s - 1; - frame.right = fCanvasFrame.right*s; - frame.bottom = fCanvasFrame.bottom*s; + // frame.right = (fCanvasFrame.right + 1)*s - 1; + // frame.bottom = (fCanvasFrame.bottom + 1)*s - 1; + frame.right = fCanvasFrame.right * s; + frame.bottom = fCanvasFrame.bottom * s; fScale = s; - ResizeTo (frame.Width(), frame.Height()); -// frame.PrintToStream(); - SetScale (s); - fBGView->setScale (s); // For the scrollbars and background - inherited::setScale (s); // For the mouse positions et al. -// inherited::FrameResized (Bounds().Width()*s, Bounds().Height()*s); - BMessage *msg = new BMessage ('Crsd'); - msg->AddFloat ("width", frame.Width()); - msg->AddFloat ("height", frame.Height()); - msg->AddFloat ("scale", s); - Window()->PostMessage (msg); + ResizeTo(frame.Width(), frame.Height()); + // frame.PrintToStream(); + SetScale(s); + fBGView->setScale(s); // For the scrollbars and background + inherited::setScale(s); // For the mouse positions et al. + // inherited::FrameResized (Bounds().Width()*s, Bounds().Height()*s); + BMessage* msg = new BMessage('Crsd'); + msg->AddFloat("width", frame.Width()); + msg->AddFloat("height", frame.Height()); + msg->AddFloat("scale", s); + Window()->PostMessage(msg); delete msg; if (invalidate) Invalidate(); } -void CanvasView::ZoomIn () +void +CanvasView::ZoomIn() { BPoint c1, c2; uint32 dummy; - GetMouse (&c1, &dummy, false); + GetMouse(&c1, &dummy, false); float cs = getScale(); if (cs < 1) - setScale (1/(1/cs - 1), false); + setScale(1 / (1 / cs - 1), false); else - setScale (cs + 1, false); + setScale(cs + 1, false); - if (mouse_on_canvas) - { + if (mouse_on_canvas) { cs = getScale(); - GetMouse (&c2, &dummy, false); - fBGView->ScrollBy ((c1.x - c2.x)*cs, (c1.y - c2.y)*cs); + GetMouse(&c2, &dummy, false); + fBGView->ScrollBy((c1.x - c2.x) * cs, (c1.y - c2.y) * cs); } Invalidate(); } -void CanvasView::ZoomOut () +void +CanvasView::ZoomOut() { BPoint c1, c2; uint32 dummy; - GetMouse (&c1, &dummy, false); + GetMouse(&c1, &dummy, false); float cs = getScale(); if (cs <= 1) - setScale (1/(1/cs + 1), false); + setScale(1 / (1 / cs + 1), false); else - setScale (cs - 1, false); + setScale(cs - 1, false); - if (mouse_on_canvas) - { + if (mouse_on_canvas) { cs = getScale(); - GetMouse (&c2, &dummy, false); - fBGView->ScrollBy ((c1.x - c2.x)*cs, (c1.y - c2.y)*cs); + GetMouse(&c2, &dummy, false); + fBGView->ScrollBy((c1.x - c2.x) * cs, (c1.y - c2.y) * cs); } Invalidate(); } -rgb_color CanvasView::getColor (long x, long y) +rgb_color +CanvasView::getColor(long x, long y) { - uint32 *addr = (uint32 *) currentLayer()->Bits() + currentLayer()->BytesPerRow()/4*y + x; - return (bgra2rgb (*addr)); + uint32* addr = (uint32*)currentLayer()->Bits() + currentLayer()->BytesPerRow() / 4 * y + x; + return (bgra2rgb(*addr)); } -rgb_color CanvasView::getColor (BPoint p) +rgb_color +CanvasView::getColor(BPoint p) { - if (Bounds().Contains (p)) - return (getColor (long (p.x), long (p.y))); + if (Bounds().Contains(p)) + return (getColor(long(p.x), long(p.y))); else return (Black); } -rgb_color CanvasView::getColor (LPoint p) +rgb_color +CanvasView::getColor(LPoint p) { - uint32 *addr = (uint32 *) bbits + bbpr/4*p.y + p.x; - return (bgra2rgb (*addr)); + uint32* addr = (uint32*)bbits + bbpr / 4 * p.y + p.x; + return (bgra2rgb(*addr)); } -uint32 CanvasView::get_and_plot (BPoint p, rgb_color c) +uint32 +CanvasView::get_and_plot(BPoint p, rgb_color c) { - if (Bounds().Contains (p)) - { - uint32 *addr = (uint32 *) currentLayer()->Bits() + currentLayer()->BytesPerRow()/4*long (p.y + 0.5) + long (p.x + 0.5); + if (Bounds().Contains(p)) { + uint32* addr = (uint32*)currentLayer()->Bits() + + currentLayer()->BytesPerRow() / 4 * long(p.y + 0.5) + long(p.x + 0.5); uint32 pix = *addr; - *addr = PIXEL (c.red, c.green, c.blue, c.alpha); + *addr = PIXEL(c.red, c.green, c.blue, c.alpha); changed = true; return pix; - } - else + } else return 0; } -void CanvasView::plot (BPoint p, rgb_color c) +void +CanvasView::plot(BPoint p, rgb_color c) { - if (Bounds().Contains (p)) - { - uint32 *addr = (uint32 *) currentLayer()->Bits() + currentLayer()->BytesPerRow()/4*long (p.y + 0.5) + long (p.x + 0.5); - *addr = PIXEL (c.red, c.green, c.blue, c.alpha); + if (Bounds().Contains(p)) { + uint32* addr = (uint32*)currentLayer()->Bits() + + currentLayer()->BytesPerRow() / 4 * long(p.y + 0.5) + long(p.x + 0.5); + *addr = PIXEL(c.red, c.green, c.blue, c.alpha); changed = true; } } -void CanvasView::plot_alpha (BPoint p, rgb_color c) +void +CanvasView::plot_alpha(BPoint p, rgb_color c) { // Needs: // sbptr -> pointer to currentLayer()->Bits(); // sblpr -> currentLayer()->BytesPerRow()/4; - if (Bounds().Contains (p)) - { - uint32 *addr = sbptr + sblpr*long (p.y + 0.5) + long (p.x + 0.5); + if (Bounds().Contains(p)) { + uint32* addr = sbptr + sblpr * long(p.y + 0.5) + long(p.x + 0.5); uint32 pixel = *addr; int sa = c.alpha; int da = 255 - sa; - *addr = PIXEL ((RED(pixel)*da + c.red*sa)/255, - (GREEN(pixel)*da + c.green*sa)/255, - (BLUE(pixel)*da + c.blue*sa)/255, - clipchar (int (ALPHA(pixel)) + int (c.alpha))); + *addr = PIXEL( + (RED(pixel) * da + c.red * sa) / 255, (GREEN(pixel) * da + c.green * sa) / 255, + (BLUE(pixel) * da + c.blue * sa) / 255, clipchar(int(ALPHA(pixel)) + int(c.alpha)) + ); changed = true; } } -void CanvasView::fplot (BPoint p, rgb_color c) +void +CanvasView::fplot(BPoint p, rgb_color c) { // Needs: // sbptr -> pointer to currentLayer()->Bits(); // sblpr -> currentLayer()->BytesPerRow()/4; - if (Bounds().Contains (p)) - { - uint32 *addr = sbptr + sblpr*long (p.y + 0.5) + long (p.x + 0.5); - *addr = PIXEL (c.red, c.green, c.blue, c.alpha); + if (Bounds().Contains(p)) { + uint32* addr = sbptr + sblpr * long(p.y + 0.5) + long(p.x + 0.5); + *addr = PIXEL(c.red, c.green, c.blue, c.alpha); changed = true; } } -void CanvasView::fplot_alpha (BPoint p, rgb_color c) +void +CanvasView::fplot_alpha(BPoint p, rgb_color c) { // Needs: // sbptr -> pointer to currentLayer()->Bits(); // sblpr -> currentLayer()->BytesPerRow()/4; - if (Bounds().Contains (p)) - { - uint32 *addr = sbptr + sblpr*long (p.y + 0.5) + long (p.x + 0.5); -// uint32 *addr = (uint32 *) currentLayer()->Bits() + currentLayer()->BytesPerRow()/4*long (p.y + 0.5) + long (p.x + 0.5); + if (Bounds().Contains(p)) { + uint32* addr = sbptr + sblpr * long(p.y + 0.5) + long(p.x + 0.5); + // uint32 *addr = (uint32 *) currentLayer()->Bits() + + // currentLayer()->BytesPerRow()/4*long (p.y + 0.5) + long (p.x + 0.5); uint32 pixel = *addr; int sa = c.alpha; int da = 255 - sa; - *addr = PIXEL ((RED(pixel)*da + c.red*sa)/255, - (GREEN(pixel)*da + c.green*sa)/255, - (BLUE(pixel)*da + c.blue*sa)/255, - clipchar (int (ALPHA(pixel)) + int (c.alpha))); + *addr = PIXEL( + (RED(pixel) * da + c.red * sa) / 255, (GREEN(pixel) * da + c.green * sa) / 255, + (BLUE(pixel) * da + c.blue * sa) / 255, clipchar(int(ALPHA(pixel)) + int(c.alpha)) + ); changed = true; } } /* This one is for when Be fixes B_TRANSPARENT_32_BIT... */ -void CanvasView::tplot32 (BPoint p, rgb_color c) +void +CanvasView::tplot32(BPoint p, rgb_color c) { - if (temp->Bounds().Contains (p)) - { - uint32 *addr = (uint32 *) temp->Bits() + temp->BytesPerRow()/4*long (p.y) + long (p.x); - *addr = PIXEL (c.red, c.green, c.blue, c.alpha); + if (temp->Bounds().Contains(p)) { + uint32* addr = (uint32*)temp->Bits() + temp->BytesPerRow() / 4 * long(p.y) + long(p.x); + *addr = PIXEL(c.red, c.green, c.blue, c.alpha); } } -void CanvasView::tplot8 (LPoint p, uchar c) +void +CanvasView::tplot8(LPoint p, uchar c) { -// if (temp->Bounds().Contains (p)) // Warning! No check! -// { - uchar *addr = tbits + tbpr*p.y + p.x; - *addr = c; -// } + // if (temp->Bounds().Contains (p)) // Warning! No check! + // { + uchar* addr = tbits + tbpr * p.y + p.x; + *addr = c; + // } } -void CanvasView::AttachCurrentLayer () +void +CanvasView::AttachCurrentLayer() { extern bool inPaste; - extern BBitmap *clip; - //printf ("Attaching current layer\n"); + extern BBitmap* clip; + // printf ("Attaching current layer\n"); currentLayer()->Lock(); - currentLayer()->AddChild (drawView); - if (inPaste) - { + currentLayer()->AddChild(drawView); + if (inPaste) { BPoint point; uint32 buttons; extern long pasteX, pasteY; - GetMouse (&point, &buttons, true); + GetMouse(&point, &buttons, true); cutbg->Lock(); - cutView->DrawBitmap (currentLayer(), BPoint (-point.x - pasteX, -point.y - pasteY)); + cutView->DrawBitmap(currentLayer(), BPoint(-point.x - pasteX, -point.y - pasteY)); cutbg->Unlock(); - prevPaste = BRect (point.x + pasteX, point.y + pasteY, - point.x + pasteX + clip->Bounds().right, point.y + pasteY + clip->Bounds().bottom); - ePasteM (point); + prevPaste = BRect( + point.x + pasteX, point.y + pasteY, point.x + pasteX + clip->Bounds().right, + point.y + pasteY + clip->Bounds().bottom + ); + ePasteM(point); } currentLayer()->Unlock(); } -void CanvasView::DetachCurrentLayer () +void +CanvasView::DetachCurrentLayer() { extern bool inPaste; currentLayer()->Lock(); -// printf ("Detaching current layer\n"); - if (inPaste) - { -// printf ("In paste!\n"); - drawView->DrawBitmap (cutbg, prevPaste.LeftTop()); + // printf ("Detaching current layer\n"); + if (inPaste) { + // printf ("In paste!\n"); + drawView->DrawBitmap(cutbg, prevPaste.LeftTop()); } - currentLayer()->RemoveChild (drawView); + currentLayer()->RemoveChild(drawView); currentLayer()->Unlock(); } -void CanvasView::AttachSelection () +void +CanvasView::AttachSelection() { selection->Lock(); - selection->AddChild (selectionView); + selection->AddChild(selectionView); selection->Unlock(); } -void CanvasView::DetachSelection () +void +CanvasView::DetachSelection() { selection->Lock(); - selection->RemoveChild (selectionView); + selection->RemoveChild(selectionView); selection->Unlock(); } -void CanvasView::addLayer (const char *name) +void +CanvasView::addLayer(const char* name) { DetachCurrentLayer(); - layer[fNumLayers] = new Layer (fCanvasFrame, name); + layer[fNumLayers] = new Layer(fCanvasFrame, name); fCurrentLayer = fNumLayers; AttachCurrentLayer(); fNumLayers++; - BMessage *msg = new BMessage ('lChg'); - if (myWindow->LockWithTimeout (100000) == B_OK) - { - myWindow->PostMessage (msg); + BMessage* msg = new BMessage('lChg'); + if (myWindow->LockWithTimeout(100000) == B_OK) { + myWindow->PostMessage(msg); myWindow->Unlock(); - } - else - printf ("1. Couldn't get lock\n"); + } else + printf("1. Couldn't get lock\n"); delete msg; - if (myWindow->isLayerOpen()) - { + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->doChanges(); myWindow->layerWindow->Unlock(); } -// UndoSelection(); // This is debatable. + // UndoSelection(); // This is debatable. changed = true; checkMetaLayer(); Invalidate(); } -void CanvasView::insertLayer (int index, const char *name) +void +CanvasView::insertLayer(int index, const char* name) { DetachCurrentLayer(); - for (int i = fNumLayers; i > index; i--) - { + for (int i = fNumLayers; i > index; i--) { layer[i] = layer[i - 1]; } fNumLayers++; - layer[index] = new Layer (fCanvasFrame, name); + layer[index] = new Layer(fCanvasFrame, name); fCurrentLayer = index; AttachCurrentLayer(); - BMessage *msg = new BMessage ('lChg'); + BMessage* msg = new BMessage('lChg'); myWindow->Lock(); - myWindow->PostMessage (msg); + myWindow->PostMessage(msg); myWindow->Unlock(); delete msg; - if (myWindow->isLayerOpen()) - { + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->doChanges(); myWindow->layerWindow->Unlock(); } -// UndoSelection(); + // UndoSelection(); checkMetaLayer(); changed = true; Invalidate(); } -void CanvasView::duplicateLayer (int index) +void +CanvasView::duplicateLayer(int index) { - char name[1024]; // Should be a nice #define. - strcpy (name, layer[index]->getName()); - strcat (name, lstring (163, " copy")); + char name[1024]; // Should be a nice #define. + strcpy(name, layer[index]->getName()); + strcat(name, lstring(163, " copy")); DetachCurrentLayer(); for (int i = fNumLayers; i > index; i--) layer[i] = layer[i - 1]; fNumLayers++; - layer[index + 1] = new Layer (fCanvasFrame, name); + layer[index + 1] = new Layer(fCanvasFrame, name); fCurrentLayer = index + 1; - memcpy (currentLayer()->Bits(), layer[index]->Bits(), layer[index]->BitsLength()); + memcpy(currentLayer()->Bits(), layer[index]->Bits(), layer[index]->BitsLength()); AttachCurrentLayer(); - BMessage *msg = new BMessage ('lChg'); - myWindow->Lock(); - myWindow->PostMessage (msg); + BMessage* msg = new BMessage('lChg'); + myWindow->Lock(); + myWindow->PostMessage(msg); myWindow->Unlock(); delete msg; - if (myWindow->isLayerOpen()) - { + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->doChanges(); myWindow->layerWindow->Unlock(); } -// UndoSelection(); + // UndoSelection(); checkMetaLayer(); changed = true; Invalidate(); } -void CanvasView::translateLayer (int index) +void +CanvasView::translateLayer(int index) { - extern Becasso *mainapp; + extern Becasso* mainapp; mainapp->setMover(); fTranslating = index + 1; fRotating = 0; } -void CanvasView::rotateLayer (int index) +void +CanvasView::rotateLayer(int index) { - extern Becasso *mainapp; + extern Becasso* mainapp; mainapp->setRotator(); fRotating = index + 1; fTranslating = 0; } -void CanvasView::do_translateLayer (int /*index*/, int32 mode) +void +CanvasView::do_translateLayer(int /*index*/, int32 mode) { - extern Becasso *mainapp; - SetupUndo (mode); + extern Becasso* mainapp; + SetupUndo(mode); uint32 buttons; BPoint point, origin, prev; - GetMouse (&point, &buttons); + GetMouse(&point, &buttons); prev = point; origin = point; - if (mode == M_DRAW) - { - while (buttons) - { - if (prev != point) - { - currentLayer()->ClearTo (0); - BPoint p = BPoint (point.x - origin.x, point.y - origin.y); + if (mode == M_DRAW) { + while (buttons) { + if (prev != point) { + currentLayer()->ClearTo(0); + BPoint p = BPoint(point.x - origin.x, point.y - origin.y); // drawView->DrawBitmap (undo[indexUndo].bitmap, p); - SBitmapToLayer (undo[indexUndo].bitmap, currentLayer(), p); + SBitmapToLayer(undo[indexUndo].bitmap, currentLayer(), p); mainapp->setMover(); Invalidate(); prev = point; } - snooze (20000); - GetMouse (&point, &buttons); - } - } - else - { - while (buttons) - { - if (prev != point) - { - selection->ClearTo (0); - BPoint p = BPoint (point.x - origin.x, point.y - origin.y); + snooze(20000); + GetMouse(&point, &buttons); + } + } else { + while (buttons) { + if (prev != point) { + selection->ClearTo(0); + BPoint p = BPoint(point.x - origin.x, point.y - origin.y); // selectionView->DrawSBitmap (undo[indexUndo].sbitmap, p); - SBitmapToSelection (undo[indexUndo].sbitmap, selection, p); + SBitmapToSelection(undo[indexUndo].sbitmap, selection, p); mainapp->setMover(); Invalidate(); prev = point; } - snooze (20000); - GetMouse (&point, &buttons); + snooze(20000); + GetMouse(&point, &buttons); } } } -void CanvasView::do_rotateLayer (int /*index*/, int32 mode) +void +CanvasView::do_rotateLayer(int /*index*/, int32 mode) { - extern Becasso *mainapp; - SetupUndo (mode); + extern Becasso* mainapp; + SetupUndo(mode); uint32 buttons; BPoint point, origin, prev; - GetMouse (&point, &buttons); + GetMouse(&point, &buttons); prev = point; origin = point; float angle = 0; float dangle; - if (mode == M_DRAW) - { - while (buttons) - { - if (prev != point) - { - angle = atan2 (origin.y - point.y, point.x - origin.x); - dangle = angle*180/M_PI; - currentLayer()->ClearTo (0); - Rotate (undo[indexUndo].bitmap, currentLayer(), origin, angle, false); + BString angleData; + BString angleString; + if (mode == M_DRAW) { + while (buttons) { + if (prev != point) { + angle = atan2(origin.y - point.y, point.x - origin.x); + dangle = angle * 180 / M_PI; + currentLayer()->ClearTo(0); + Rotate(undo[indexUndo].bitmap, currentLayer(), origin, angle, false); // printf ("angle = %f°\n", dangle); mainapp->setRotator(); Invalidate(); - SetDrawingMode (B_OP_INVERT); - SetPenSize (0); - StrokeLine (BPoint (Bounds().right, origin.y), origin); - StrokeLine (point); - StrokeArc (origin, 10, 10, 0, dangle); - char angletxt[16]; - sprintf (angletxt, "%.1f°", dangle); - DrawString (angletxt, BPoint (origin.x + 15, origin.y + (angle > 0 ? 10 : -2))); + SetDrawingMode(B_OP_INVERT); + SetPenSize(0); + StrokeLine(BPoint(Bounds().right, origin.y), origin); + StrokeLine(point); + StrokeArc(origin, 10, 10, 0, dangle); + fNumberFormat.SetPrecision(1); + fNumberFormat.Format(angleData, dangle); + angleString.SetToFormat("%s°", angleData.String()); + DrawString( + angleString.String(), BPoint(origin.x + 15, origin.y + (angle > 0 ? 10 : -2)) + ); prev = point; } - snooze (20000); - GetMouse (&point, &buttons); + snooze(20000); + GetMouse(&point, &buttons); } mainapp->setBusy(); - Rotate (undo[indexUndo].bitmap, currentLayer(), origin, angle, true); - } - else - { - while (buttons) - { - if (prev != point) - { - angle = atan2 (origin.y - point.y, point.x - origin.x); - dangle = angle*180/M_PI; - selection->ClearTo (0); - Rotate (undo[indexUndo].sbitmap, selection, origin, angle, false); + Rotate(undo[indexUndo].bitmap, currentLayer(), origin, angle, true); + } else { + while (buttons) { + if (prev != point) { + angle = atan2(origin.y - point.y, point.x - origin.x); + dangle = angle * 180 / M_PI; + selection->ClearTo(0); + Rotate(undo[indexUndo].sbitmap, selection, origin, angle, false); // printf ("angle = %f°\n", dangle); mainapp->setRotator(); Invalidate(); - SetDrawingMode (B_OP_INVERT); - SetPenSize (0); - StrokeLine (BPoint (Bounds().right, origin.y), origin); - StrokeLine (point); - StrokeArc (origin, 10, 10, 0, dangle); - char angletxt[16]; - sprintf (angletxt, "%.1f°", dangle); - DrawString (angletxt, BPoint (origin.x + 15, origin.y + (angle > 0 ? 10 : -2))); + SetDrawingMode(B_OP_INVERT); + SetPenSize(0); + StrokeLine(BPoint(Bounds().right, origin.y), origin); + StrokeLine(point); + StrokeArc(origin, 10, 10, 0, dangle); + fNumberFormat.SetPrecision(1); + fNumberFormat.Format(angleData, dangle); + angleString.SetToFormat("%s°", angleData.String()); + DrawString( + angleString.String(), BPoint(origin.x + 15, origin.y + (angle > 0 ? 10 : -2)) + ); prev = point; } - snooze (20000); - GetMouse (&point, &buttons); + snooze(20000); + GetMouse(&point, &buttons); } mainapp->setBusy(); - Rotate (undo[indexUndo].sbitmap, selection, origin, angle, true); + Rotate(undo[indexUndo].sbitmap, selection, origin, angle, true); } mainapp->setReady(); Invalidate(); } -void CanvasView::flipLayer (int hv, int index) +void +CanvasView::flipLayer(int hv, int index) { - extern PicMenuButton *mode; + extern PicMenuButton* mode; int m = mode->selected(); - SetupUndo (m); + SetupUndo(m); - if (m == M_DRAW) - { + if (m == M_DRAW) { if (index == -1) index = fCurrentLayer; - Layer *l = layer[index]; - bgra_pixel *p = (bgra_pixel *) l->Bits(); - uint32 ppr = l->BytesPerRow()/4; + Layer* l = layer[index]; + bgra_pixel* p = (bgra_pixel*)l->Bits(); + uint32 ppr = l->BytesPerRow() / 4; int32 w = fCanvasFrame.IntegerWidth(); int32 h = fCanvasFrame.IntegerHeight(); - if (hv == 0) // horizontal flip + if (hv == 0) // horizontal flip { - for (int32 y = 0; y <= h; y++) - { - bgra_pixel *lp = p + y*ppr; - bgra_pixel *ilp = p + y*ppr + w; - for (int32 x = 0; x <= w/2; x++) - { + for (int32 y = 0; y <= h; y++) { + bgra_pixel* lp = p + y * ppr; + bgra_pixel* ilp = p + y * ppr + w; + for (int32 x = 0; x <= w / 2; x++) { bgra_pixel tmp = *lp; *lp++ = *ilp; *ilp-- = tmp; } } - } - else // vertical flip + } else // vertical flip { - for (int32 x = 0; x <= w; x++) - { - bgra_pixel *lp = p + x; - bgra_pixel *ilp = p + h*ppr + x; - for (int32 y = 0; y <= h/2; y++) - { + for (int32 x = 0; x <= w; x++) { + bgra_pixel* lp = p + x; + bgra_pixel* ilp = p + h * ppr + x; + for (int32 y = 0; y <= h / 2; y++) { bgra_pixel tmp = *lp; *lp = *ilp; *ilp = tmp; @@ -994,35 +971,28 @@ void CanvasView::flipLayer (int hv, int index) } } } - } - else - { - grey_pixel *p = (grey_pixel *) selection->Bits(); + } else { + grey_pixel* p = (grey_pixel*)selection->Bits(); uint32 ppr = selection->BytesPerRow(); int32 w = fCanvasFrame.IntegerWidth(); int32 h = fCanvasFrame.IntegerHeight(); - if (hv == 0) // horizontal flip + if (hv == 0) // horizontal flip { - for (int32 y = 0; y <= h; y++) - { - grey_pixel *lp = p + y*ppr; - grey_pixel *ilp = p + y*ppr + w; - for (int32 x = 0; x < w/2; x++) - { + for (int32 y = 0; y <= h; y++) { + grey_pixel* lp = p + y * ppr; + grey_pixel* ilp = p + y * ppr + w; + for (int32 x = 0; x < w / 2; x++) { grey_pixel tmp = *lp; *lp++ = *ilp; *ilp-- = tmp; } } - } - else // vertical flip + } else // vertical flip { - for (int32 x = 0; x <= w; x++) - { - grey_pixel *lp = p + x; - grey_pixel *ilp = p + h*ppr + x; - for (int32 y = 0; y < h/2; y++) - { + for (int32 x = 0; x <= w; x++) { + grey_pixel* lp = p + x; + grey_pixel* ilp = p + h * ppr + x; + for (int32 y = 0; y < h / 2; y++) { grey_pixel tmp = *lp; *lp = *ilp; *ilp = tmp; @@ -1035,11 +1005,11 @@ void CanvasView::flipLayer (int hv, int index) Invalidate(); } -void CanvasView::moveLayers (int from, int to) +void +CanvasView::moveLayers(int from, int to) { - if (from == to) - { - makeCurrentLayer (from); + if (from == to) { + makeCurrentLayer(from); return; } if (to < 0) @@ -1047,103 +1017,95 @@ void CanvasView::moveLayers (int from, int to) if (to >= fNumLayers) to = fNumLayers - 1; DetachCurrentLayer(); - if (from < to) - { - Layer *tmp = layer[from]; + if (from < to) { + Layer* tmp = layer[from]; for (int i = from; i < to; i++) layer[i] = layer[i + 1]; layer[to] = tmp; - } - else - { - Layer *tmp = layer[from]; + } else { + Layer* tmp = layer[from]; for (int i = from; i > to; i--) layer[i] = layer[i - 1]; layer[to] = tmp; } fCurrentLayer = to; AttachCurrentLayer(); - BMessage msg ('lChg'); + BMessage msg('lChg'); myWindow->Lock(); - myWindow->PostMessage (&msg); + myWindow->PostMessage(&msg); myWindow->Unlock(); - if (myWindow->isLayerOpen()) - { + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->doChanges(); myWindow->layerWindow->Unlock(); } -// UndoSelection(); + // UndoSelection(); checkMetaLayer(); changed = true; Invalidate(); } -void CanvasView::removeLayer (int index) +void +CanvasView::removeLayer(int index) { - if (!index) // Don't remove the background layer! + if (!index) // Don't remove the background layer! return; extern int DebugLevel; if (DebugLevel) - printf ("Removing layer %i\n", index); + printf("Removing layer %i\n", index); - snooze (20000); // ahem. + snooze(20000); // ahem. fIndex2 = index; - SetupUndo (M_DELLAYER); + SetupUndo(M_DELLAYER); fIndex2 = -1; - do_removeLayer (index); + do_removeLayer(index); changed = true; Invalidate(); } -void CanvasView::do_removeLayer (int index) +void +CanvasView::do_removeLayer(int index) { -/////////////////////////// -// - snooze (100000); -// -// Ahem. This means there's some deadlock. If I remove this, -// sometimes the LayerWindow would crash (it would probably be redrawing its -// thumbnail view when CanvasView was already deleting it...) -// -//////////////////////////// - - if (index >= fCurrentLayer) - { -// printf ("Detaching current layer\n"); snooze (20000); + /////////////////////////// + // + snooze(100000); + // + // Ahem. This means there's some deadlock. If I remove this, + // sometimes the LayerWindow would crash (it would probably be redrawing its + // thumbnail view when CanvasView was already deleting it...) + // + //////////////////////////// + + if (index >= fCurrentLayer) { + // printf ("Detaching current layer\n"); snooze (20000); DetachCurrentLayer(); } -// printf ("Moving layers\n"); snooze (20000); + // printf ("Moving layers\n"); snooze (20000); delete layer[index]; - for (int i = index; i < fNumLayers - 1; i++) - { -// printf ("%i <- %i\n", i, i + 1); snooze (20000); + for (int i = index; i < fNumLayers - 1; i++) { + // printf ("%i <- %i\n", i, i + 1); snooze (20000); layer[i] = layer[i + 1]; } fNumLayers--; layer[fNumLayers] = NULL; - if (index >= fCurrentLayer) - { + if (index >= fCurrentLayer) { fCurrentLayer--; -// printf ("Huu\n"); snooze (20000); + // printf ("Huu\n"); snooze (20000); AttachCurrentLayer(); -// printf ("Current Layer attached.\n"); - snooze (20000); - } - else - { -// printf ("Boe\n"); snooze (20000); - //fCurrentLayer--; - //UndoSelection(); - } - BMessage *msg = new BMessage ('lChg'); + // printf ("Current Layer attached.\n"); + snooze(20000); + } else { + // printf ("Boe\n"); snooze (20000); + // fCurrentLayer--; + // UndoSelection(); + } + BMessage* msg = new BMessage('lChg'); myWindow->Lock(); - myWindow->PostMessage (msg); + myWindow->PostMessage(msg); myWindow->Unlock(); delete msg; -// printf ("Almost done...\n"); snooze (20000); - if (myWindow->isLayerOpen()) - { + // printf ("Almost done...\n"); snooze (20000); + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->doChanges(); myWindow->layerWindow->Unlock(); @@ -1151,49 +1113,48 @@ void CanvasView::do_removeLayer (int index) checkMetaLayer(); } -void CanvasView::makeCurrentLayer (int index) +void +CanvasView::makeCurrentLayer(int index) { - if (index >= 0 && index < fNumLayers) - { + if (index >= 0 && index < fNumLayers) { DetachCurrentLayer(); - BMessage msg ('lChg'); - msg.AddInt32 ("prev", fCurrentLayer); - msg.AddInt32 ("current", index); + BMessage msg('lChg'); + msg.AddInt32("prev", fCurrentLayer); + msg.AddInt32("current", index); fCurrentLayer = index; AttachCurrentLayer(); myWindow->Lock(); - myWindow->PostMessage (&msg); + myWindow->PostMessage(&msg); myWindow->Unlock(); - if (myWindow->isLayerOpen()) - { + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); - myWindow->layerWindow->doChanges (index); + myWindow->layerWindow->doChanges(index); myWindow->layerWindow->Unlock(); } -// printf ("Hey!\n"); -// UndoSelection(); + // printf ("Hey!\n"); + // UndoSelection(); checkMetaLayer(); changed = true; Invalidate(); - } - else - fprintf (stderr, "Becasso: Layer index %d out of range\n", index); + } else + fprintf(stderr, "Becasso: Layer index %d out of range\n", index); } -void CanvasView::checkMetaLayer () +void +CanvasView::checkMetaLayer() { - myWindow->posview->SetTextLayer (false); + myWindow->posview->SetTextLayer(false); } -void CanvasView::mergeLayers (int bottom, int top) +void +CanvasView::mergeLayers(int bottom, int top) { fIndex1 = bottom; fIndex2 = top; - SetupUndo (M_MERGE); - Merge (layer[bottom], layer[top], fCanvasFrame, false); - do_removeLayer (top); - if (myWindow->isLayerOpen()) - { + SetupUndo(M_MERGE); + Merge(layer[bottom], layer[top], fCanvasFrame, false); + do_removeLayer(top); + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->doChanges(); myWindow->layerWindow->Unlock(); @@ -1205,107 +1166,109 @@ void CanvasView::mergeLayers (int bottom, int top) Invalidate(); } -void CanvasView::setChannelOperation (int index, int newmode) +void +CanvasView::setChannelOperation(int index, int newmode) { - layer[index]->setMode (newmode); + layer[index]->setMode(newmode); changed = true; Invalidate(); } -void CanvasView::setGlobalAlpha (int index, int ga) +void +CanvasView::setGlobalAlpha(int index, int ga) { -// printf ("setGlobalAlpha of %d to %d\n", index, ga); + // printf ("setGlobalAlpha of %d to %d\n", index, ga); layer[index]->Lock(); -// printf ("Locked... "); fflush (stdout); - layer[index]->setGlobalAlpha (ga); -// printf ("Set... "); fflush (stdout); + // printf ("Locked... "); fflush (stdout); + layer[index]->setGlobalAlpha(ga); + // printf ("Set... "); fflush (stdout); layer[index]->Unlock(); -// printf ("Done\n"); + // printf ("Done\n"); changed = true; Invalidate(); } -void CanvasView::setLayerContentsToBitmap (int index, BBitmap *map, int32 resize) +void +CanvasView::setLayerContentsToBitmap(int index, BBitmap* map, int32 resize) { clock_t start, end; start = clock(); int previousCurrentLayer = fCurrentLayer; - makeCurrentLayer (index); + makeCurrentLayer(index); currentLayer()->Lock(); - SetupUndo (M_DRAW); - if (map->Bounds() != fCanvasFrame && resize == STRETCH_TO_FIT) - { - verbose (1, "Stretching bitmap to fit\n"); - ::Scale (map, NULL, currentLayer(), NULL); - } - else - { - drawView->DrawBitmap (map, B_ORIGIN); + SetupUndo(M_DRAW); + if (map->Bounds() != fCanvasFrame && resize == STRETCH_TO_FIT) { + verbose(1, "Stretching bitmap to fit\n"); + ::Scale(map, NULL, currentLayer(), NULL); + } else { + drawView->DrawBitmap(map, B_ORIGIN); } currentLayer()->Unlock(); - makeCurrentLayer (previousCurrentLayer); + makeCurrentLayer(previousCurrentLayer); changed = true; checkMetaLayer(); Invalidate(); end = clock(); extern int DebugLevel; if (DebugLevel > 2) - printf ("CanvasView::setLayerContentsToBitmap Took %ld ms\n", end - start); + printf("CanvasView::setLayerContentsToBitmap Took %ld ms\n", end - start); } -void CanvasView::invertAlpha () +void +CanvasView::invertAlpha() { -// printf ("Inverting alpha channel...\n"); + // printf ("Inverting alpha channel...\n"); currentLayer()->Lock(); - InvertAlpha (currentLayer()); + InvertAlpha(currentLayer()); currentLayer()->Unlock(); Invalidate(); } -void CanvasView::CenterMouse () +void +CanvasView::CenterMouse() { - BPoint sp = ConvertToScreen (BPoint (fLastCenter.x*fScale, fLastCenter.y*fScale)); - set_mouse_position (int (sp.x), int (sp.y)); + BPoint sp = ConvertToScreen(BPoint(fLastCenter.x * fScale, fLastCenter.y * fScale)); + set_mouse_position(int(sp.x), int(sp.y)); } -void CanvasView::CropToWindow () +void +CanvasView::CropToWindow() { - BRect rect (Parent()->Bounds()); - rect.left = int (rect.left/fScale + 0.5); - rect.top = int (rect.top/fScale + 0.5); - rect.right = int (rect.right/fScale + 0.5); - rect.bottom = int (rect.bottom/fScale + 0.5); - Crop (rect); + BRect rect(Parent()->Bounds()); + rect.left = int(rect.left / fScale + 0.5); + rect.top = int(rect.top / fScale + 0.5); + rect.right = int(rect.right / fScale + 0.5); + rect.bottom = int(rect.bottom / fScale + 0.5); + Crop(rect); } -void CanvasView::CropToSelection () +void +CanvasView::CropToSelection() { - BRect rect = GetSmallestRect (selection); - Crop (rect); + BRect rect = GetSmallestRect(selection); + Crop(rect); } -void CanvasView::AutoCrop () +void +CanvasView::AutoCrop() { currentLayer()->Lock(); rgb_color border = GuessBackgroundColor(); -// printf ("%d, %d, %d, %d\n", border.red, border.green, border.blue, border.alpha); - uint32 trans = PIXEL (border.red, border.green, border.blue, border.alpha); + // printf ("%d, %d, %d, %d\n", border.red, border.green, border.blue, border.alpha); + uint32 trans = PIXEL(border.red, border.green, border.blue, border.alpha); //(border.blue << 24) | (border.green << 16) | (border.red << 8) | border.alpha; -// printf ("%lx\n", trans); + // printf ("%lx\n", trans); - uint32 *data = (uint32 *) currentLayer()->Bits(); -// long bpr = currentLayer()->BytesPerRow(); + uint32* data = (uint32*)currentLayer()->Bits(); + // long bpr = currentLayer()->BytesPerRow(); long h = fCanvasFrame.IntegerHeight(); long w = fCanvasFrame.IntegerWidth(); - BRect res = BRect (w, h, 0, 0); + BRect res = BRect(w, h, 0, 0); data--; - for (long i = 0; i <= h; i++) - { - for (long j = 0; j <= w; j++) - { - if (*(++data) != trans) - { + for (long i = 0; i <= h; i++) { + for (long j = 0; j <= w; j++) { + if (*(++data) != trans) { if (i < res.top) res.top = i; if (i > res.bottom) @@ -1318,10 +1281,11 @@ void CanvasView::AutoCrop () } } currentLayer()->Unlock(); - Crop (res); + Crop(res); } -status_t CanvasView::Crop (BRect rect) +status_t +CanvasView::Crop(BRect rect) { CloseOpenAddons(); if (rect == fCanvasFrame) @@ -1330,33 +1294,33 @@ status_t CanvasView::Crop (BRect rect) rect.bottom += fCanvasFrame.bottom; if (rect.right < 0) rect.right += fCanvasFrame.right; - if (rect.left < 0 || rect.top < 0 || rect.bottom > fCanvasFrame.bottom || rect.right > fCanvasFrame.right) + if (rect.left < 0 || rect.top < 0 || rect.bottom > fCanvasFrame.bottom || + rect.right > fCanvasFrame.right) return -2; if (rect.left > fCanvasFrame.right || rect.top > fCanvasFrame.bottom) return -3; - SetupUndo (M_RESIZE); - fBGView->ScrollTo (B_ORIGIN); + SetupUndo(M_RESIZE); + fBGView->ScrollTo(B_ORIGIN); changed = true; BRect newrect = rect; - newrect.OffsetTo (B_ORIGIN); + newrect.OffsetTo(B_ORIGIN); // printf ("Detaching Current Layer\n"); DetachCurrentLayer(); // printf ("Resizing DrawView\n"); - drawView->ResizeTo (newrect.Width(), newrect.Height()); - for (int i = 0; i < fNumLayers; i++) - { + drawView->ResizeTo(newrect.Width(), newrect.Height()); + for (int i = 0; i < fNumLayers; i++) { // printf ("Cropping layer %i\n", i); layer[i]->Lock(); - Layer *tmp = new Layer (newrect, layer[i]->getName()); - tmp->setMode (layer[i]->getMode()); - tmp->setGlobalAlpha (layer[i]->getGlobalAlpha()); - tmp->Hide (layer[i]->IsHidden()); - tmp->AddChild (drawView); + Layer* tmp = new Layer(newrect, layer[i]->getName()); + tmp->setMode(layer[i]->getMode()); + tmp->setGlobalAlpha(layer[i]->getGlobalAlpha()); + tmp->Hide(layer[i]->IsHidden()); + tmp->AddChild(drawView); tmp->Lock(); - drawView->SetDrawingMode (B_OP_COPY); - drawView->DrawBitmap (layer[i], rect, newrect); + drawView->SetDrawingMode(B_OP_COPY); + drawView->DrawBitmap(layer[i], rect, newrect); tmp->Unlock(); - tmp->RemoveChild (drawView); + tmp->RemoveChild(drawView); delete layer[i]; layer[i] = tmp; } @@ -1365,14 +1329,14 @@ status_t CanvasView::Crop (BRect rect) fCanvasFrame = newrect; selection->Lock(); DetachSelection(); - selectionView->ResizeTo (newrect.Width(), newrect.Height()); - Selection *tmp = new Selection (newrect); - tmp->AddChild (selectionView); + selectionView->ResizeTo(newrect.Width(), newrect.Height()); + Selection* tmp = new Selection(newrect); + tmp->AddChild(selectionView); tmp->Lock(); - selectionView->SetDrawingMode (B_OP_COPY); - selectionView->DrawBitmap (selection, rect, newrect); + selectionView->SetDrawingMode(B_OP_COPY); + selectionView->DrawBitmap(selection, rect, newrect); tmp->Unlock(); - tmp->RemoveChild (selectionView); + tmp->RemoveChild(selectionView); delete selection; selection = tmp; AttachSelection(); @@ -1381,24 +1345,21 @@ status_t CanvasView::Crop (BRect rect) delete screenbitmap32; delete screenbitmap; BScreen screen; - if (screen.ColorSpace() == B_COLOR_8_BIT) + if (screen.ColorSpace() == B_COLOR_8_BIT) { + screenbitmap = new BBitmap(fCanvasFrame, B_COLOR_8_BIT, true); + screenbitmap32 = new BBitmap(fCanvasFrame, B_RGBA32, true); + } else // 32 or 16 bit screens { - screenbitmap = new BBitmap (fCanvasFrame, B_COLOR_8_BIT, true); - screenbitmap32 = new BBitmap (fCanvasFrame, B_RGBA32, true); - } - else // 32 or 16 bit screens - { - screenbitmap = new BBitmap (fCanvasFrame, B_RGBA32, true); + screenbitmap = new BBitmap(fCanvasFrame, B_RGBA32, true); screenbitmap32 = screenbitmap; } - ResizeTo ((rect.Width())*fScale, (rect.Height())*fScale); - myWindow->FrameResized (myWindow->Bounds().Width(), myWindow->Bounds().Height()); - fBGView->setFrame (newrect); + ResizeTo((rect.Width()) * fScale, (rect.Height()) * fScale); + myWindow->FrameResized(myWindow->Bounds().Width(), myWindow->Bounds().Height()); + fBGView->setFrame(newrect); // hack to kick the BGView into repositioning - fBGView->FrameResized ((rect.Width())*fScale + 1, (rect.Height())*fScale + 1); - fBGView->FrameResized ((rect.Width())*fScale, (rect.Height())*fScale); - if (myWindow->isLayerOpen()) - { + fBGView->FrameResized((rect.Width()) * fScale + 1, (rect.Height()) * fScale + 1); + fBGView->FrameResized((rect.Width()) * fScale, (rect.Height()) * fScale); + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->doChanges(); myWindow->layerWindow->Unlock(); @@ -1409,59 +1370,58 @@ status_t CanvasView::Crop (BRect rect) return B_OK; } -void CanvasView::Pad (uint32 what) +void +CanvasView::Pad(uint32 what) // 'pwlt', 'pwrt', 'pwlb', 'pwrb', 'pwct' { CloseOpenAddons(); - SetupUndo (M_RESIZE); + SetupUndo(M_RESIZE); BRect rect = Parent()->Bounds(); - rect.left = int (rect.left/fScale + 0.5); - rect.top = int (rect.top/fScale + 0.5); - rect.right = int (rect.right/fScale + 0.5); - rect.bottom = int (rect.bottom/fScale + 0.5); + rect.left = int(rect.left / fScale + 0.5); + rect.top = int(rect.top / fScale + 0.5); + rect.right = int(rect.right / fScale + 0.5); + rect.bottom = int(rect.bottom / fScale + 0.5); changed = true; BRect newrect = rect; - newrect.OffsetTo (B_ORIGIN); + newrect.OffsetTo(B_ORIGIN); DetachCurrentLayer(); - drawView->ResizeTo (newrect.Width(), newrect.Height()); + drawView->ResizeTo(newrect.Width(), newrect.Height()); BPoint pos; float wd = rect.Width() - fCanvasFrame.Width(); float hd = rect.Height() - fCanvasFrame.Height(); - switch (what) - { + switch (what) { case 'pwlt': pos = B_ORIGIN; break; case 'pwrt': - pos = BPoint (wd, 0); + pos = BPoint(wd, 0); break; case 'pwlb': - pos = BPoint (0, hd); + pos = BPoint(0, hd); break; case 'pwrb': - pos = BPoint (wd, hd); + pos = BPoint(wd, hd); break; case 'pwct': - pos = BPoint (wd/2, hd/2); + pos = BPoint(wd / 2, hd / 2); break; default: - fprintf (stderr, "CanvasView::Pad: Invalid position\n"); + fprintf(stderr, "CanvasView::Pad: Invalid position\n"); pos = B_ORIGIN; } - for (int i = 0; i < fNumLayers; i++) - { + for (int i = 0; i < fNumLayers; i++) { layer[i]->Lock(); - Layer *tmp = new Layer (newrect, layer[i]->getName()); - tmp->AddChild (drawView); + Layer* tmp = new Layer(newrect, layer[i]->getName()); + tmp->AddChild(drawView); tmp->Lock(); - tmp->setMode (layer[i]->getMode()); - tmp->setGlobalAlpha (layer[i]->getGlobalAlpha()); - tmp->Hide (layer[i]->IsHidden()); - drawView->SetDrawingMode (B_OP_COPY); - drawView->DrawBitmap (layer[i], pos); + tmp->setMode(layer[i]->getMode()); + tmp->setGlobalAlpha(layer[i]->getGlobalAlpha()); + tmp->Hide(layer[i]->IsHidden()); + drawView->SetDrawingMode(B_OP_COPY); + drawView->DrawBitmap(layer[i], pos); drawView->Sync(); tmp->Unlock(); - tmp->RemoveChild (drawView); + tmp->RemoveChild(drawView); delete layer[i]; layer[i] = tmp; } @@ -1469,14 +1429,14 @@ void CanvasView::Pad (uint32 what) fCanvasFrame = newrect; DetachSelection(); selection->Lock(); - selectionView->ResizeTo (newrect.Width(), newrect.Height()); - Selection *tmp = new Selection (newrect); - tmp->AddChild (selectionView); + selectionView->ResizeTo(newrect.Width(), newrect.Height()); + Selection* tmp = new Selection(newrect); + tmp->AddChild(selectionView); tmp->Lock(); - selectionView->SetDrawingMode (B_OP_COPY); - selectionView->DrawBitmap (selection, pos); + selectionView->SetDrawingMode(B_OP_COPY); + selectionView->DrawBitmap(selection, pos); tmp->Unlock(); - tmp->RemoveChild (selectionView); + tmp->RemoveChild(selectionView); delete selection; selection = tmp; AttachSelection(); @@ -1485,26 +1445,23 @@ void CanvasView::Pad (uint32 what) delete screenbitmap32; delete screenbitmap; BScreen screen; - if (screen.ColorSpace() == B_COLOR_8_BIT) - { - screenbitmap = new BBitmap (fCanvasFrame, B_COLOR_8_BIT, true); - screenbitmap32 = new BBitmap (fCanvasFrame, B_RGBA32, true); - } - else // 32 or 16 bit screens + if (screen.ColorSpace() == B_COLOR_8_BIT) { + screenbitmap = new BBitmap(fCanvasFrame, B_COLOR_8_BIT, true); + screenbitmap32 = new BBitmap(fCanvasFrame, B_RGBA32, true); + } else // 32 or 16 bit screens { - screenbitmap = new BBitmap (fCanvasFrame, B_RGBA32, true); + screenbitmap = new BBitmap(fCanvasFrame, B_RGBA32, true); screenbitmap32 = screenbitmap; } -// screenbitmap = new BBitmap (fCanvasFrame, screen.ColorSpace(), true); -// totaldatalen = (fCanvasFrame.IntegerWidth() + 1)*(fCanvasFrame.IntegerHeight() + 1)*3; -// delete [] totaldata; -// totaldata = new uchar [totaldatalen]; - ResizeTo (rect.Width()*fScale, rect.Height()*fScale); - fBGView->setFrame (newrect); - ScrollTo (B_ORIGIN); - myWindow->FrameResized (myWindow->Bounds().Width(), myWindow->Bounds().Height()); - if (myWindow->isLayerOpen()) - { + // screenbitmap = new BBitmap (fCanvasFrame, screen.ColorSpace(), true); + // totaldatalen = (fCanvasFrame.IntegerWidth() + 1)*(fCanvasFrame.IntegerHeight() + 1)*3; + // delete [] totaldata; + // totaldata = new uchar [totaldatalen]; + ResizeTo(rect.Width() * fScale, rect.Height() * fScale); + fBGView->setFrame(newrect); + ScrollTo(B_ORIGIN); + myWindow->FrameResized(myWindow->Bounds().Width(), myWindow->Bounds().Height()); + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->doChanges(); myWindow->layerWindow->Unlock(); @@ -1513,30 +1470,30 @@ void CanvasView::Pad (uint32 what) Invalidate(); } -void CanvasView::resizeTo (int32 w, int32 h) +void +CanvasView::resizeTo(int32 w, int32 h) { CloseOpenAddons(); - SetupUndo (M_RESIZE); - BRect newrect = BRect (0, 0, w - 1, h - 1); + SetupUndo(M_RESIZE); + BRect newrect = BRect(0, 0, w - 1, h - 1); changed = true; DetachCurrentLayer(); - drawView->ResizeTo (newrect.Width(), newrect.Height()); - for (int i = 0; i < fNumLayers; i++) - { + drawView->ResizeTo(newrect.Width(), newrect.Height()); + for (int i = 0; i < fNumLayers; i++) { layer[i]->Lock(); - Layer *tmp = new Layer (newrect, layer[i]->getName()); - tmp->setMode (layer[i]->getMode()); - tmp->setGlobalAlpha (layer[i]->getGlobalAlpha()); - tmp->Hide (layer[i]->IsHidden()); - tmp->AddChild (drawView); + Layer* tmp = new Layer(newrect, layer[i]->getName()); + tmp->setMode(layer[i]->getMode()); + tmp->setGlobalAlpha(layer[i]->getGlobalAlpha()); + tmp->Hide(layer[i]->IsHidden()); + tmp->AddChild(drawView); tmp->Lock(); - drawView->SetDrawingMode (B_OP_COPY); - ::Scale (layer[i], NULL, tmp, NULL); + drawView->SetDrawingMode(B_OP_COPY); + ::Scale(layer[i], NULL, tmp, NULL); // Ugly scaling... - //drawView->DrawBitmap (layer[i], layer[i]->Bounds(), newrect); + // drawView->DrawBitmap (layer[i], layer[i]->Bounds(), newrect); drawView->Sync(); tmp->Unlock(); - tmp->RemoveChild (drawView); + tmp->RemoveChild(drawView); delete layer[i]; layer[i] = tmp; } @@ -1544,9 +1501,9 @@ void CanvasView::resizeTo (int32 w, int32 h) fCanvasFrame = newrect; DetachSelection(); selection->Lock(); - selectionView->ResizeTo (newrect.Width(), newrect.Height()); - Selection *newselection = new Selection (fCanvasFrame); - ::Scale (NULL, selection, NULL, newselection); + selectionView->ResizeTo(newrect.Width(), newrect.Height()); + Selection* newselection = new Selection(fCanvasFrame); + ::Scale(NULL, selection, NULL, newselection); delete selection; selection = newselection; AttachSelection(); @@ -1555,22 +1512,19 @@ void CanvasView::resizeTo (int32 w, int32 h) delete screenbitmap32; delete screenbitmap; BScreen screen; - if (screen.ColorSpace() == B_COLOR_8_BIT) - { - screenbitmap = new BBitmap (fCanvasFrame, B_COLOR_8_BIT, true); - screenbitmap32 = new BBitmap (fCanvasFrame, B_RGBA32, true); - } - else // 32 or 16 bit screens + if (screen.ColorSpace() == B_COLOR_8_BIT) { + screenbitmap = new BBitmap(fCanvasFrame, B_COLOR_8_BIT, true); + screenbitmap32 = new BBitmap(fCanvasFrame, B_RGBA32, true); + } else // 32 or 16 bit screens { - screenbitmap = new BBitmap (fCanvasFrame, B_RGBA32, true); + screenbitmap = new BBitmap(fCanvasFrame, B_RGBA32, true); screenbitmap32 = screenbitmap; } - ResizeTo (newrect.Width()*fScale, newrect.Height()*fScale); - fBGView->setFrame (newrect); - ScrollTo (B_ORIGIN); - myWindow->FrameResized (myWindow->Bounds().Width(), myWindow->Bounds().Height()); - if (myWindow->isLayerOpen()) - { + ResizeTo(newrect.Width() * fScale, newrect.Height() * fScale); + fBGView->setFrame(newrect); + ScrollTo(B_ORIGIN); + myWindow->FrameResized(myWindow->Bounds().Width(), myWindow->Bounds().Height()); + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->doChanges(); myWindow->layerWindow->Unlock(); @@ -1579,45 +1533,42 @@ void CanvasView::resizeTo (int32 w, int32 h) Invalidate(); } -void CanvasView::ResizeToWindow (uint32 what) +void +CanvasView::ResizeToWindow(uint32 what) // 'rwkr', 'rwar' { BRect rect = Parent()->Bounds(); - rect.left = int (rect.left/fScale + 0.5); - rect.top = int (rect.top/fScale + 0.5); - rect.right = int (rect.right/fScale + 0.5); - rect.bottom = int (rect.bottom/fScale + 0.5); + rect.left = int(rect.left / fScale + 0.5); + rect.top = int(rect.top / fScale + 0.5); + rect.right = int(rect.right / fScale + 0.5); + rect.bottom = int(rect.bottom / fScale + 0.5); changed = true; BRect newrect = rect; - newrect.OffsetTo (B_ORIGIN); - switch (what) - { - case 'rwkr': - { + newrect.OffsetTo(B_ORIGIN); + switch (what) { + case 'rwkr': { float ratio = Bounds().Width() / Bounds().Height(); - if (rect.Height()*ratio > newrect.Width()) - { - newrect.bottom = int (rect.right/ratio); - } - else - { - newrect.right = int (rect.bottom*ratio); + if (rect.Height() * ratio > newrect.Width()) { + newrect.bottom = int(rect.right / ratio); + } else { + newrect.right = int(rect.bottom * ratio); } } case 'rwar': break; default: - fprintf (stderr, "CanvasView::ResizeToWindow: Invalid ratio mode\n"); + fprintf(stderr, "CanvasView::ResizeToWindow: Invalid ratio mode\n"); } - resizeTo (newrect.IntegerWidth() + 1, newrect.IntegerHeight() + 1); + resizeTo(newrect.IntegerWidth() + 1, newrect.IntegerHeight() + 1); } -void CanvasView::RotateCanvas (uint32 what) +void +CanvasView::RotateCanvas(uint32 what) // 'r90', 'r180', 'r270' { CloseOpenAddons(); // This is so easy to undo, we shouldn't waste buffers on it... -// SetupUndo (M_RESIZE); + // SetupUndo (M_RESIZE); changed = true; BRect rect = Bounds(); BRect newrect = Bounds(); @@ -1630,11 +1581,9 @@ void CanvasView::RotateCanvas (uint32 what) newrect.top /= fScale; newrect.bottom /= fScale; DetachCurrentLayer(); - switch (what) - { + switch (what) { case 'r90': - case 'r270': - { + case 'r270': { float tmp = newrect.right; newrect.right = newrect.bottom; newrect.bottom = tmp; @@ -1643,31 +1592,27 @@ void CanvasView::RotateCanvas (uint32 what) case 'r180': break; default: - fprintf (stderr, "CanvasView::RotateCanvas: Invalid angle\n"); + fprintf(stderr, "CanvasView::RotateCanvas: Invalid angle\n"); } - drawView->ResizeTo (newrect.Width(), newrect.Height()); - for (int i = 0; i < fNumLayers; i++) - { + drawView->ResizeTo(newrect.Width(), newrect.Height()); + for (int i = 0; i < fNumLayers; i++) { layer[i]->Lock(); - Layer *tmp = new Layer (newrect, layer[i]->getName()); - tmp->setMode (layer[i]->getMode()); - tmp->setGlobalAlpha (layer[i]->getGlobalAlpha()); - tmp->Hide (layer[i]->IsHidden()); + Layer* tmp = new Layer(newrect, layer[i]->getName()); + tmp->setMode(layer[i]->getMode()); + tmp->setGlobalAlpha(layer[i]->getGlobalAlpha()); + tmp->Hide(layer[i]->IsHidden()); tmp->Lock(); - uint32 *src = (uint32 *) layer[i]->Bits(); - uint32 *dest = (uint32 *) tmp->Bits(); + uint32* src = (uint32*)layer[i]->Bits(); + uint32* dest = (uint32*)tmp->Bits(); int w = layer[i]->Bounds().IntegerWidth() + 1; int h = layer[i]->Bounds().IntegerHeight() + 1; - uint32 bpr = layer[i]->BytesPerRow()/4; - switch (what) - { + uint32 bpr = layer[i]->BytesPerRow() / 4; + switch (what) { case 'r90': dest--; - for (int y = 0; y < w; y++) - { - src = (uint32 *) layer[i]->Bits() + bpr - y - 1; - for (int x = 0; x < h; x++) - { + for (int y = 0; y < w; y++) { + src = (uint32*)layer[i]->Bits() + bpr - y - 1; + for (int x = 0; x < h; x++) { *(++dest) = *src; src += bpr; } @@ -1675,7 +1620,7 @@ void CanvasView::RotateCanvas (uint32 what) break; case 'r180': src--; - dest += tmp->BitsLength()/4; + dest += tmp->BitsLength() / 4; for (int y = 0; y < h; y++) for (int x = 0; x < w; x++) *(--dest) = *(++src); @@ -1683,18 +1628,16 @@ void CanvasView::RotateCanvas (uint32 what) case 'r270': dest--; src += bpr - 1; - for (int y = 0; y < w; y++) - { - src = (uint32 *) layer[i]->Bits() + layer[i]->BitsLength()/4 - bpr + y; - for (int x = 0; x < h; x++) - { + for (int y = 0; y < w; y++) { + src = (uint32*)layer[i]->Bits() + layer[i]->BitsLength() / 4 - bpr + y; + for (int x = 0; x < h; x++) { *(++dest) = *src; src -= bpr; } } break; default: - fprintf (stderr, "CanvasView::RotateCanvas: Invalid angle\n"); + fprintf(stderr, "CanvasView::RotateCanvas: Invalid angle\n"); } tmp->Unlock(); delete layer[i]; @@ -1704,26 +1647,22 @@ void CanvasView::RotateCanvas (uint32 what) fCanvasFrame = newrect; DetachSelection(); selection->Lock(); - selectionView->ResizeTo (newrect.Width(), newrect.Height()); - Selection *tmp = new Selection (fCanvasFrame); + selectionView->ResizeTo(newrect.Width(), newrect.Height()); + Selection* tmp = new Selection(fCanvasFrame); tmp->Lock(); - grey_pixel *src = (grey_pixel *) selection->Bits(); - grey_pixel *dest = (grey_pixel *) tmp->Bits(); + grey_pixel* src = (grey_pixel*)selection->Bits(); + grey_pixel* dest = (grey_pixel*)tmp->Bits(); int w = selection->Bounds().IntegerWidth() + 1; int h = selection->Bounds().IntegerHeight() + 1; uint32 sbpr = selection->BytesPerRow(); uint32 dbpr = tmp->BytesPerRow(); - switch (what) - { - case 'r90': - { + switch (what) { + case 'r90': { int ddif = dbpr - h; dest--; - for (int y = 0; y < w; y++) - { - src = (grey_pixel *) selection->Bits() + w - y - 1; - for (int x = 0; x < h; x++) - { + for (int y = 0; y < w; y++) { + src = (grey_pixel*)selection->Bits() + w - y - 1; + for (int x = 0; x < h; x++) { *(++dest) = *src; src += sbpr; } @@ -1731,33 +1670,27 @@ void CanvasView::RotateCanvas (uint32 what) } break; } - case 'r180': - { + case 'r180': { int ddif = dbpr - w; int sdif = sbpr - w; src--; dest += tmp->BitsLength() - ddif + 1; - for (int y = 0; y < h; y++) - { - for (int x = 0; x < w; x++) - { + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { *(--dest) = *(++src); } dest -= ddif; - src += sdif; + src += sdif; } break; } - case 'r270': - { + case 'r270': { int ddif = dbpr - h; dest--; src += w - 1; - for (int y = 0; y < w; y++) - { - src = (grey_pixel *) selection->Bits() + selection->BitsLength() - sbpr + y; - for (int x = 0; x < h; x++) - { + for (int y = 0; y < w; y++) { + src = (grey_pixel*)selection->Bits() + selection->BitsLength() - sbpr + y; + for (int x = 0; x < h; x++) { *(++dest) = *src; src -= sbpr; } @@ -1766,7 +1699,7 @@ void CanvasView::RotateCanvas (uint32 what) break; } default: - fprintf (stderr, "CanvasView::RotateCanvas: Invalid angle\n"); + fprintf(stderr, "CanvasView::RotateCanvas: Invalid angle\n"); } tmp->Unlock(); delete selection; @@ -1777,22 +1710,19 @@ void CanvasView::RotateCanvas (uint32 what) delete screenbitmap32; delete screenbitmap; BScreen screen; - if (screen.ColorSpace() == B_COLOR_8_BIT) - { - screenbitmap = new BBitmap (fCanvasFrame, B_COLOR_8_BIT, true); - screenbitmap32 = new BBitmap (fCanvasFrame, B_RGBA32, true); - } - else // 32 or 16 bit screens + if (screen.ColorSpace() == B_COLOR_8_BIT) { + screenbitmap = new BBitmap(fCanvasFrame, B_COLOR_8_BIT, true); + screenbitmap32 = new BBitmap(fCanvasFrame, B_RGBA32, true); + } else // 32 or 16 bit screens { - screenbitmap = new BBitmap (fCanvasFrame, B_RGBA32, true); + screenbitmap = new BBitmap(fCanvasFrame, B_RGBA32, true); screenbitmap32 = screenbitmap; } - ResizeTo (newrect.Width()*fScale, newrect.Height()*fScale); - fBGView->setFrame (newrect); - ScrollTo (B_ORIGIN); - myWindow->FrameResized (myWindow->Bounds().Width(), myWindow->Bounds().Height()); - if (myWindow->isLayerOpen()) - { + ResizeTo(newrect.Width() * fScale, newrect.Height() * fScale); + fBGView->setFrame(newrect); + ScrollTo(B_ORIGIN); + myWindow->FrameResized(myWindow->Bounds().Width(), myWindow->Bounds().Height()); + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->doChanges(); myWindow->layerWindow->Unlock(); @@ -1801,181 +1731,173 @@ void CanvasView::RotateCanvas (uint32 what) Invalidate(); } -void CanvasView::ReplaceCurrentLayer (BBitmap *newlayer) +void +CanvasView::ReplaceCurrentLayer(BBitmap* newlayer) { - if (newlayer->Bounds() != fCanvasFrame) - { + if (newlayer->Bounds() != fCanvasFrame) { CloseOpenAddons(); - SetupUndo (M_RESIZE); + SetupUndo(M_RESIZE); BRect rect = newlayer->Bounds(); - rect.left = int (rect.left/fScale + 0.5); - rect.top = int (rect.top/fScale + 0.5); - rect.right = int (rect.right/fScale + 0.5); - rect.bottom = int (rect.bottom/fScale + 0.5); + rect.left = int(rect.left / fScale + 0.5); + rect.top = int(rect.top / fScale + 0.5); + rect.right = int(rect.right / fScale + 0.5); + rect.bottom = int(rect.bottom / fScale + 0.5); changed = true; BRect newrect = rect; - newrect.OffsetTo (B_ORIGIN); + newrect.OffsetTo(B_ORIGIN); DetachCurrentLayer(); - drawView->ResizeTo (newrect.Width(), newrect.Height()); - for (int i = 0; i < fNumLayers; i++) - { + drawView->ResizeTo(newrect.Width(), newrect.Height()); + for (int i = 0; i < fNumLayers; i++) { layer[i]->Lock(); delete layer[i]; - layer[i] = new Layer (newrect, layer[i]->getName()); + layer[i] = new Layer(newrect, layer[i]->getName()); } AttachCurrentLayer(); fCanvasFrame = newrect; DetachSelection(); selection->Lock(); - selectionView->ResizeTo (newrect.Width(), newrect.Height()); + selectionView->ResizeTo(newrect.Width(), newrect.Height()); delete selection; - selection = new Selection (fCanvasFrame); + selection = new Selection(fCanvasFrame); AttachSelection(); myWindow->Lock(); if (screenbitmap->ColorSpace() != B_RGBA32) delete screenbitmap32; delete screenbitmap; BScreen screen; - if (screen.ColorSpace() == B_COLOR_8_BIT) - { - screenbitmap = new BBitmap (fCanvasFrame, B_COLOR_8_BIT, true); - screenbitmap32 = new BBitmap (fCanvasFrame, B_RGBA32, true); - } - else // 32 or 16 bit screens + if (screen.ColorSpace() == B_COLOR_8_BIT) { + screenbitmap = new BBitmap(fCanvasFrame, B_COLOR_8_BIT, true); + screenbitmap32 = new BBitmap(fCanvasFrame, B_RGBA32, true); + } else // 32 or 16 bit screens { - screenbitmap = new BBitmap (fCanvasFrame, B_RGBA32, true); + screenbitmap = new BBitmap(fCanvasFrame, B_RGBA32, true); screenbitmap32 = screenbitmap; } - ResizeTo (newrect.Width()*fScale, newrect.Height()*fScale); - fBGView->setFrame (newrect); - ScrollTo (B_ORIGIN); - myWindow->FrameResized (myWindow->Bounds().Width(), myWindow->Bounds().Height()); - if (myWindow->isLayerOpen()) - { + ResizeTo(newrect.Width() * fScale, newrect.Height() * fScale); + fBGView->setFrame(newrect); + ScrollTo(B_ORIGIN); + myWindow->FrameResized(myWindow->Bounds().Width(), myWindow->Bounds().Height()); + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->doChanges(); myWindow->layerWindow->Unlock(); } myWindow->Unlock(); Invalidate(); - } - else - { - extern PicMenuButton *mode; - SetupUndo (mode->selected()); + } else { + extern PicMenuButton* mode; + SetupUndo(mode->selected()); } currentLayer()->Lock(); - drawView->DrawBitmapAsync (newlayer, B_ORIGIN); + drawView->DrawBitmapAsync(newlayer, B_ORIGIN); drawView->Sync(); currentLayer()->Unlock(); Invalidate(); } -void CanvasView::OpenAddon (AddOn *addon, const char *name) +void +CanvasView::OpenAddon(AddOn* addon, const char* name) { - printf ("OpenAddon\n"); -// extern PicMenuButton *mode; + printf("OpenAddon\n"); + // extern PicMenuButton *mode; Window()->Unlock(); - switch (addon->Type()) - { + switch (addon->Type()) { case BECASSO_FILTER: -// if (filterOpen && filterOpen != addon) -// { -// printf ("Closing filter...\n"); -// addonInQueue = addon; -// filterOpen->Close(); -// } -// else - filterOpen = addon; + // if (filterOpen && filterOpen != addon) + // { + // printf ("Closing filter...\n"); + // addonInQueue = addon; + // filterOpen->Close(); + // } + // else + filterOpen = addon; break; case BECASSO_TRANSFORMER: -// if (transformerOpen && transformerOpen != addon) -// { -// addonInQueue = addon; -// transformerOpen->Close(); -// } -// else - transformerOpen = addon; + // if (transformerOpen && transformerOpen != addon) + // { + // addonInQueue = addon; + // transformerOpen->Close(); + // } + // else + transformerOpen = addon; transformerSaved = false; break; case BECASSO_GENERATOR: -// if (generatorOpen && transformerOpen != addon) -// { -// addonInQueue = addon; -// generatorOpen->Close(); -// } -// else - generatorOpen = addon; + // if (generatorOpen && transformerOpen != addon) + // { + // addonInQueue = addon; + // generatorOpen->Close(); + // } + // else + generatorOpen = addon; generatorSaved = false; break; default: - fprintf (stderr, "OpenAddon: Unknown Add-on type!\n"); + fprintf(stderr, "OpenAddon: Unknown Add-on type!\n"); } Window()->Lock(); - myWindow->setMenuItem ('redo', false); - myWindow->setMenuItem (B_UNDO, false); - addon->Open (myWindow, name); + myWindow->setMenuItem('redo', false); + myWindow->setMenuItem(B_UNDO, false); + addon->Open(myWindow, name); - if (generatorOpen && !(generatorOpen->DoesPreview() & PREVIEW_MOUSE)) - { - Generate (generatorOpen, 1); // For stuff like the Tile add-on - immediately call - // it one time once selected. + if (generatorOpen && !(generatorOpen->DoesPreview() & PREVIEW_MOUSE)) { + Generate(generatorOpen, 1); // For stuff like the Tile add-on - immediately call + // it one time once selected. } - if (transformerOpen && !(transformerOpen->DoesPreview() & PREVIEW_MOUSE)) - { - Transform (transformerOpen, 1); + if (transformerOpen && !(transformerOpen->DoesPreview() & PREVIEW_MOUSE)) { + Transform(transformerOpen, 1); } - if (addon->DoesPreview() && !(addon->DoesPreview() & PREVIEW_MOUSE)) - { - Invalidate (fPreviewRect); + if (addon->DoesPreview() && !(addon->DoesPreview() & PREVIEW_MOUSE)) { + Invalidate(fPreviewRect); } } -void CanvasView::CloseAddon (AddOn *addon) +void +CanvasView::CloseAddon(AddOn* addon) { -// printf ("Closing Addon.\n"); -// if (addonInQueue) -// printf (" Addon in Queue\n"); - switch (addon->Type()) - { + // printf ("Closing Addon.\n"); + // if (addonInQueue) + // printf (" Addon in Queue\n"); + switch (addon->Type()) { case BECASSO_FILTER: -// if (addonInQueue) -// filterOpen = addonInQueue; -// else - filterOpen = NULL; + // if (addonInQueue) + // filterOpen = addonInQueue; + // else + filterOpen = NULL; break; case BECASSO_TRANSFORMER: -// if (addonInQueue) -// transformerOpen = addonInQueue; -// else - transformerOpen = NULL; + // if (addonInQueue) + // transformerOpen = addonInQueue; + // else + transformerOpen = NULL; if (transformerSaved) Undo(); transformerSaved = false; break; case BECASSO_GENERATOR: -// if (addonInQueue) -// generatorOpen = addonInQueue; -// else - generatorOpen = NULL; + // if (addonInQueue) + // generatorOpen = addonInQueue; + // else + generatorOpen = NULL; if (generatorSaved) Undo(); generatorSaved = false; break; default: - fprintf (stderr, "CloseAddon: Unknown Add-on type!\n"); + fprintf(stderr, "CloseAddon: Unknown Add-on type!\n"); } -// addonInQueue = NULL; + // addonInQueue = NULL; Invalidate(); addon->Close(); myWindow->Lock(); - myWindow->setMenuItem (B_UNDO, indexUndo > 0); - myWindow->setMenuItem ('redo', indexUndo + 1 < maxIndexUndo); + myWindow->setMenuItem(B_UNDO, indexUndo > 0); + myWindow->setMenuItem('redo', indexUndo + 1 < maxIndexUndo); myWindow->Unlock(); } -void CanvasView::CloseOpenAddons () +void +CanvasView::CloseOpenAddons() { if (filterOpen) filterOpen->Close(); @@ -1984,39 +1906,40 @@ void CanvasView::CloseOpenAddons () if (generatorOpen) generatorOpen->Close(); myWindow->Lock(); - myWindow->setMenuItem (B_UNDO, indexUndo > 0); - myWindow->setMenuItem ('redo', indexUndo + 1 < maxIndexUndo); + myWindow->setMenuItem(B_UNDO, indexUndo > 0); + myWindow->setMenuItem('redo', indexUndo + 1 < maxIndexUndo); myWindow->Unlock(); -// printf ("All Open Addons closed\n"); + // printf ("All Open Addons closed\n"); } -void CanvasView::Filter (AddOn *addon, uint8 preview) +void +CanvasView::Filter(AddOn* addon, uint8 preview) // preview is true when the add-on signals a change in parameters // preview is false when this is called for "the real thing". { -// extern PicMenuButton *mode; - //printf ("Calling from Filter. sel = %s, preview = %s\n", sel ? "true" : "false", preview ? "true" : "false"); - if (preview) - { - Invalidate (fPreviewRect); - } - else // User clicked "Apply", so Do The Real Thing. - { - extern Becasso *mainapp; - extern PicMenuButton *mode; - SetupUndo (mode->selected()); - if (!preview) mainapp->setBusy(); + // extern PicMenuButton *mode; + // printf ("Calling from Filter. sel = %s, preview = %s\n", sel ? "true" : "false", preview ? + // "true" : "false"); + if (preview) { + Invalidate(fPreviewRect); + } else // User clicked "Apply", so Do The Real Thing. + { + extern Becasso* mainapp; + extern PicMenuButton* mode; + SetupUndo(mode->selected()); + if (!preview) + mainapp->setBusy(); currentLayer()->Lock(); selection->Lock(); - Layer *newlayer = NULL; - Selection *newselection = NULL; + Layer* newlayer = NULL; + Selection* newselection = NULL; DetachCurrentLayer(); DetachSelection(); - BRect pRect = sel ? GetSmallestRect (selection) : fCanvasFrame; - if (addon->Process (currentLayer(), sel ? selection : NULL, - &newlayer, &newselection, mode->selected(), &pRect, !preview) - != ADDON_OK) - { + BRect pRect = sel ? GetSmallestRect(selection) : fCanvasFrame; + if (addon->Process( + currentLayer(), sel ? selection : NULL, &newlayer, &newselection, mode->selected(), + &pRect, !preview + ) != ADDON_OK) { if (newlayer != currentLayer()) delete newlayer; if (newselection != selection) @@ -2031,14 +1954,12 @@ void CanvasView::Filter (AddOn *addon, uint8 preview) } selection->Unlock(); currentLayer()->Unlock(); - if (newlayer != currentLayer() && newlayer) - { + if (newlayer != currentLayer() && newlayer) { currentLayer()->Lock(); delete currentLayer(); layer[fCurrentLayer] = newlayer; } - if (newselection != selection && newselection) - { + if (newselection != selection && newselection) { selection->Lock(); delete selection; selection = newselection; @@ -2046,10 +1967,9 @@ void CanvasView::Filter (AddOn *addon, uint8 preview) AttachSelection(); AttachCurrentLayer(); myWindow->Lock(); - if (myWindow->isLayerOpen()) - { + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); - myWindow->layerWindow->doChanges (currentLayerIndex()); + myWindow->layerWindow->doChanges(currentLayerIndex()); myWindow->layerWindow->Unlock(); } myWindow->Unlock(); @@ -2059,48 +1979,47 @@ void CanvasView::Filter (AddOn *addon, uint8 preview) } } -void CanvasView::Transform (AddOn *addon, uint8 preview) +void +CanvasView::Transform(AddOn* addon, uint8 preview) { -// printf ("Transform\n"); - extern Becasso *mainapp; - extern PicMenuButton *mode; + // printf ("Transform\n"); + extern Becasso* mainapp; + extern PicMenuButton* mode; static int32 prevmode = mode->selected(); - if (prevmode != mode->selected()) - { - Undo (true); + if (prevmode != mode->selected()) { + Undo(true); Invalidate(); transformerSaved = false; prevmode = mode->selected(); } - if (!transformerSaved) // There's no undo buffer set up yet. + if (!transformerSaved) // There's no undo buffer set up yet. { - SetupUndo (mode->selected()); // Save now. + SetupUndo(mode->selected()); // Save now. // But if we're `just' previewing, there's no need to flush the undo // buffer, so we shouldn't save next time we come here. - } - else - { + } else { // We're here for a second (...) time, so restore the previous state // of the canvas. // I'm not too happy with this because it causes quite an overhead for // large pictures, but otherwise translators got their own previous result // back, which wasn't good. - Undo (false); + Undo(false); } transformerSaved = preview; - if (!preview) mainapp->setBusy(); + if (!preview) + mainapp->setBusy(); currentLayer()->Lock(); selection->Lock(); - Layer *newlayer = NULL; - Selection *newselection = NULL; + Layer* newlayer = NULL; + Selection* newselection = NULL; DetachCurrentLayer(); DetachSelection(); - BRect pRect = sel ? GetSmallestRect (selection) : fCanvasFrame; - if (addon->Process (currentLayer(), sel ? selection : NULL, - &newlayer, &newselection, mode->selected(), &pRect, !preview) - != ADDON_OK) - { + BRect pRect = sel ? GetSmallestRect(selection) : fCanvasFrame; + if (addon->Process( + currentLayer(), sel ? selection : NULL, &newlayer, &newselection, mode->selected(), + &pRect, !preview + ) != ADDON_OK) { if (newlayer != currentLayer()) delete newlayer; if (newselection != selection) @@ -2115,14 +2034,12 @@ void CanvasView::Transform (AddOn *addon, uint8 preview) } selection->Unlock(); currentLayer()->Unlock(); - if (newlayer != currentLayer() && newlayer) - { + if (newlayer != currentLayer() && newlayer) { currentLayer()->Lock(); delete currentLayer(); layer[fCurrentLayer] = newlayer; } - if (newselection != selection && newselection) - { + if (newselection != selection && newselection) { selection->Lock(); delete selection; selection = newselection; @@ -2131,10 +2048,9 @@ void CanvasView::Transform (AddOn *addon, uint8 preview) AttachSelection(); AttachCurrentLayer(); myWindow->Lock(); - if (myWindow->isLayerOpen()) - { + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); - myWindow->layerWindow->doChanges (currentLayerIndex()); + myWindow->layerWindow->doChanges(currentLayerIndex()); myWindow->layerWindow->Unlock(); } myWindow->Unlock(); @@ -2142,48 +2058,48 @@ void CanvasView::Transform (AddOn *addon, uint8 preview) mainapp->setHand(); } -void CanvasView::Generate (AddOn *addon, uint8 preview) +void +CanvasView::Generate(AddOn* addon, uint8 preview) { - extern Becasso *mainapp; - extern PicMenuButton *mode; - if (!generatorSaved) // There's no undo buffer setup yet. + extern Becasso* mainapp; + extern PicMenuButton* mode; + if (!generatorSaved) // There's no undo buffer setup yet. { - SetupUndo (mode->selected()); // Save now. + SetupUndo(mode->selected()); // Save now. // But if we're `just' previewing, there's no need to flush the undo // buffer, so we shouldn't save next time we come here. - } - else - { + } else { // We're here for a second (...) time, so restore the previous state // of the canvas. // I'm not too happy with this because it causes quite an overhead for // large pictures, but otherwise generators that "blended" with the old // bitmap got their own previous result back, which wasn't good (especially // using the Tile Generator with a non-255 selection map). - Undo (false); + Undo(false); } generatorSaved = preview; - if (!preview) mainapp->setBusy(); + if (!preview) + mainapp->setBusy(); currentLayer()->Lock(); selection->Lock(); - Layer *newlayer = NULL; - Selection *newselection = NULL; -// Layer *newlayer = new Layer (*currentLayer()); -// Selection *newselection = new Selection (selection->Bounds()); -// newlayer->Lock(); -// newselection->Lock(); -// memcpy (newlayer->Bits(), currentLayer()->Bits(), newlayer->BitsLength()); -// memcpy (newselection->Bits(), selection->Bits(), newselection->BitsLength()); -// selection->Unlock(); -// currentLayer()->Unlock(); + Layer* newlayer = NULL; + Selection* newselection = NULL; + // Layer *newlayer = new Layer (*currentLayer()); + // Selection *newselection = new Selection (selection->Bounds()); + // newlayer->Lock(); + // newselection->Lock(); + // memcpy (newlayer->Bits(), currentLayer()->Bits(), newlayer->BitsLength()); + // memcpy (newselection->Bits(), selection->Bits(), newselection->BitsLength()); + // selection->Unlock(); + // currentLayer()->Unlock(); DetachCurrentLayer(); DetachSelection(); - BRect pRect = sel ? GetSmallestRect (selection) : fCanvasFrame; - if (addon->Process (currentLayer(), sel ? selection : NULL, - &newlayer, &newselection, mode->selected(), &pRect, !preview) - != ADDON_OK) - { + BRect pRect = sel ? GetSmallestRect(selection) : fCanvasFrame; + if (addon->Process( + currentLayer(), sel ? selection : NULL, &newlayer, &newselection, mode->selected(), + &pRect, !preview + ) != ADDON_OK) { if (newlayer != currentLayer()) delete newlayer; if (newselection != selection) @@ -2196,18 +2112,16 @@ void CanvasView::Generate (AddOn *addon, uint8 preview) mainapp->setHand(); return; } - selection->Unlock(); // WHOOPEE!! global alpha channel bug is fixed with this. - // Don't ask me why. It just works now. + selection->Unlock(); // WHOOPEE!! global alpha channel bug is fixed with this. + // Don't ask me why. It just works now. // currentLayer()->Unlock(); - if (newlayer != currentLayer() && newlayer) - { + if (newlayer != currentLayer() && newlayer) { // printf ("Replacing layer\n"); // currentLayer()->Lock(); delete currentLayer(); layer[fCurrentLayer] = newlayer; } - if (newselection != selection && newselection) - { + if (newselection != selection && newselection) { // printf ("Replacing selection\n"); // selection->Lock(); delete selection; @@ -2218,10 +2132,9 @@ void CanvasView::Generate (AddOn *addon, uint8 preview) AttachSelection(); AttachCurrentLayer(); myWindow->Lock(); - if (myWindow->isLayerOpen()) - { + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); - myWindow->layerWindow->doChanges (currentLayerIndex()); + myWindow->layerWindow->doChanges(currentLayerIndex()); myWindow->layerWindow->Unlock(); } myWindow->Unlock(); @@ -2229,111 +2142,108 @@ void CanvasView::Generate (AddOn *addon, uint8 preview) mainapp->setHand(); } -void CanvasView::eFilter (BPoint point, uint32 buttons) +void +CanvasView::eFilter(BPoint point, uint32 buttons) { - while (buttons) - { - if (prev != point) - { + while (buttons) { + if (prev != point) { BRect prevpreviewRect = fPreviewRect; - fPreviewRect.OffsetTo (point); - fPreviewRect.left = int (fPreviewRect.left); - fPreviewRect.top = int (fPreviewRect.top); - fPreviewRect.right = int (fPreviewRect.right); - fPreviewRect.bottom = int (fPreviewRect.bottom); - Invalidate (prevpreviewRect | fPreviewRect); + fPreviewRect.OffsetTo(point); + fPreviewRect.left = int(fPreviewRect.left); + fPreviewRect.top = int(fPreviewRect.top); + fPreviewRect.right = int(fPreviewRect.right); + fPreviewRect.bottom = int(fPreviewRect.bottom); + Invalidate(prevpreviewRect | fPreviewRect); } prev = point; - snooze (100000); - ScrollIfNeeded (point); + snooze(100000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); - GetMouse (&point, &buttons, true); + GetMouse(&point, &buttons, true); } } -//#define OLD_ETRANSFORM 1 +// #define OLD_ETRANSFORM 1 -#if defined (OLD_ETRANSFORM) +#if defined(OLD_ETRANSFORM) -void CanvasView::eTransform (BPoint point, uint32 buttons) +void +CanvasView::eTransform(BPoint point, uint32 buttons) { // Note: inefficient. If !sel, don't `new' newselection! - extern PicMenuButton *mode; - if (!transformerSaved) // There's no undo buffer setup yet. + extern PicMenuButton* mode; + if (!transformerSaved) // There's no undo buffer setup yet. { - SetupUndo (mode->selected()); // Save now. + SetupUndo(mode->selected()); // Save now. // But we're `just' previewing (interactively here), there's no need to // flush the undo buffer, so we shouldn't save next time we come here. transformerSaved = true; - } - else - { - Undo (false); + } else { + Undo(false); } currentLayer()->Lock(); selection->Lock(); - Layer *newlayer = new Layer (*currentLayer()); - Selection *newselection = new Selection (*selection); - memcpy (newlayer->Bits(), currentLayer()->Bits(), currentLayer()->BitsLength()); - memcpy (newselection->Bits(), selection->Bits(), selection->BitsLength()); + Layer* newlayer = new Layer(*currentLayer()); + Selection* newselection = new Selection(*selection); + memcpy(newlayer->Bits(), currentLayer()->Bits(), currentLayer()->BitsLength()); + memcpy(newselection->Bits(), selection->Bits(), selection->BitsLength()); selection->Unlock(); currentLayer()->Unlock(); -// DetachCurrentLayer(); -// DetachSelection(); - BRect pRect = GetSmallestRect (selection); - BPoint prev = BPoint (0, 0); - Layer *cLayer = currentLayer(); -// printf ("currentLayer() = %p, ->Bits() = %p\n", cLayer, cLayer->Bits()); + // DetachCurrentLayer(); + // DetachSelection(); + BRect pRect = GetSmallestRect(selection); + BPoint prev = BPoint(0, 0); + Layer* cLayer = currentLayer(); + // printf ("currentLayer() = %p, ->Bits() = %p\n", cLayer, cLayer->Bits()); BRect prevRect = pRect; BRect dirty = prevRect; - inAddOn = (mode->selected() == M_DRAW); // ConstructCanvas wants to know about this. - while (buttons) - { - if (prev != point) - { + inAddOn = (mode->selected() == M_DRAW); // ConstructCanvas wants to know about this. + while (buttons) { + if (prev != point) { dirty = prevRect | pRect; - //dirty.PrintToStream(); - drawView->DrawBitmap (newlayer, B_ORIGIN /*, dirty, dirty */); - selectionView->DrawBitmap (newselection, B_ORIGIN /*, dirty, dirty*/); + // dirty.PrintToStream(); + drawView->DrawBitmap(newlayer, B_ORIGIN /*, dirty, dirty */); + selectionView->DrawBitmap(newselection, B_ORIGIN /*, dirty, dirty*/); drawView->Sync(); selectionView->Sync(); - transformerOpen->Process (newlayer, sel ? newselection : NULL, - &cLayer, &selection, - mode->selected(), &pRect, false, point, buttons); - Invalidate (pRect | dirty); + transformerOpen->Process( + newlayer, sel ? newselection : NULL, &cLayer, &selection, mode->selected(), &pRect, + false, point, buttons + ); + Invalidate(pRect | dirty); prevRect = pRect; } prev = point; - snooze (100000); - ScrollIfNeeded (point); + snooze(100000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); - GetMouse (&point, &buttons, true); + GetMouse(&point, &buttons, true); } - drawView->DrawBitmap (newlayer, B_ORIGIN /* dirty, dirty */); - selectionView->DrawBitmap (newselection, B_ORIGIN /* dirty, dirty */); + drawView->DrawBitmap(newlayer, B_ORIGIN /* dirty, dirty */); + selectionView->DrawBitmap(newselection, B_ORIGIN /* dirty, dirty */); drawView->Sync(); selectionView->Sync(); inAddOn = false; - transformerOpen->Process (newlayer, sel ? newselection : NULL, - &cLayer, &selection, - mode->selected(), &pRect, false, point, buttons); -// AttachSelection(); -// AttachCurrentLayer(); + transformerOpen->Process( + newlayer, sel ? newselection : NULL, &cLayer, &selection, mode->selected(), &pRect, false, + point, buttons + ); + // AttachSelection(); + // AttachCurrentLayer(); newlayer->Lock(); delete newlayer; newselection->Lock(); delete newselection; myWindow->Lock(); - if (myWindow->isLayerOpen()) - { + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); - myWindow->layerWindow->doChanges (currentLayerIndex()); + myWindow->layerWindow->doChanges(currentLayerIndex()); myWindow->layerWindow->Unlock(); } myWindow->Unlock(); @@ -2344,73 +2254,70 @@ void CanvasView::eTransform (BPoint point, uint32 buttons) #else -void CanvasView::eTransform (BPoint point, uint32 buttons) +void +CanvasView::eTransform(BPoint point, uint32 buttons) // This is where we arrive when a Transformer add-on tells us it's interested in mouse // movements (for instance, Scale and Ripple). { -// printf ("eTransform\n"); - extern PicMenuButton *mode; + // printf ("eTransform\n"); + extern PicMenuButton* mode; uint8 previewmode = transformerOpen->DoesPreview(); BRect halfsize = fCanvasFrame; static int32 prevmode = mode->selected(); - if (prevmode != mode->selected()) - { - Undo (true); + if (prevmode != mode->selected()) { + Undo(true); Invalidate(); transformerSaved = false; prevmode = mode->selected(); } - if (!transformerSaved) // There's no undo buffer setup yet. + if (!transformerSaved) // There's no undo buffer setup yet. { if (mode->selected() == M_DRAW && (previewmode & LAYER_AND_SELECTION)) - SetupUndo (M_DRAW_SELECT); + SetupUndo(M_DRAW_SELECT); else - SetupUndo (mode->selected()); // Save now. + SetupUndo(mode->selected()); // Save now. // But we're `just' previewing (interactively here), there's no need to // flush the undo buffer, so we shouldn't save next time we come here. transformerSaved = true; - } - else - Undo (false); + } else + Undo(false); - if (previewmode & PREVIEW_2x2) - { + if (previewmode & PREVIEW_2x2) { // Set up a 2x2 scaled version of the current layer and the selection. - halfsize.left /= 2; - halfsize.top /= 2; // just to be sure... - halfsize.right /= 2; + halfsize.left /= 2; + halfsize.top /= 2; // just to be sure... + halfsize.right /= 2; halfsize.bottom /= 2; - tr2x2Layer = new Layer (halfsize, "temp 2x2 preview layer"); + tr2x2Layer = new Layer(halfsize, "temp 2x2 preview layer"); tr2x2Layer->Lock(); - SView *tmpView = new SView (halfsize, "temp 2x2 preview view", B_FOLLOW_NONE, uint32 (NULL)); - if (sel) - { - tr2x2Selection = new Selection (halfsize); + SView* tmpView = new SView(halfsize, "temp 2x2 preview view", B_FOLLOW_NONE, uint32(NULL)); + if (sel) { + tr2x2Selection = new Selection(halfsize); tr2x2Selection->Lock(); - tr2x2Selection->AddChild (tmpView); - tmpView->DrawBitmap (selection, selection->Bounds(), halfsize); - tr2x2Selection->RemoveChild (tmpView); + tr2x2Selection->AddChild(tmpView); + tmpView->DrawBitmap(selection, selection->Bounds(), halfsize); + tr2x2Selection->RemoveChild(tmpView); } - tr2x2Layer->AddChild (tmpView); - tmpView->DrawBitmap (currentLayer(), fCanvasFrame, halfsize); - tr2x2Layer->RemoveChild (tmpView); + tr2x2Layer->AddChild(tmpView); + tmpView->DrawBitmap(currentLayer(), fCanvasFrame, halfsize); + tr2x2Layer->RemoveChild(tmpView); delete tmpView; } -// currentLayer()->Lock(); -// selection->Lock(); - Layer *newlayer = NULL; - Selection *newselection = NULL; + // currentLayer()->Lock(); + // selection->Lock(); + Layer* newlayer = NULL; + Selection* newselection = NULL; - BRect pRect = sel ? GetSmallestRect (selection) : fCanvasFrame; + BRect pRect = sel ? GetSmallestRect(selection) : fCanvasFrame; BRect savePRect = pRect; - BPoint prev = BPoint (0, 0); + BPoint prev = BPoint(0, 0); if (mode->selected() == M_SELECT) selchanged = true; // if (sel) printf ("Sel!\n"); // else printf ("No Sel!\n"); - inAddOn = (mode->selected() == M_DRAW); // ConstructCanvas wants to know about this. -// printf ("Detaching\n"); + inAddOn = (mode->selected() == M_DRAW); // ConstructCanvas wants to know about this. + // printf ("Detaching\n"); DetachCurrentLayer(); DetachSelection(); bool hascreatednewlayer = true; @@ -2418,86 +2325,80 @@ void CanvasView::eTransform (BPoint point, uint32 buttons) bool hascreatednewlayeronce = false; bool hascreatednewselectiononce = false; bool first = true; -// printf ("Entering loop\n"); + // printf ("Entering loop\n"); if (previewmode & PREVIEW_2x2) // in this case the loop looks slightly different... { - pRect.left /= 2; - pRect.top /= 2; - pRect.right /= 2; + pRect.left /= 2; + pRect.top /= 2; + pRect.right /= 2; pRect.bottom /= 2; point.x /= 2; point.y /= 2; - while (buttons) - { - if (prev != point) - { - if (!first) - { - if (!hascreatednewlayer && !hascreatednewselection) - { -// printf ("Restoring previous result\n"); - Undo (false); + while (buttons) { + if (prev != point) { + if (!first) { + if (!hascreatednewlayer && !hascreatednewselection) { + // printf ("Restoring previous result\n"); + Undo(false); } - if (hascreatednewlayer) // Cheap way of restoring old result... + if (hascreatednewlayer) // Cheap way of restoring old result... { -// printf ("Restoring previous 2x2 result (cheaply)\n"); - Layer *tmp = newlayer; + // printf ("Restoring previous 2x2 result + //(cheaply)\n"); + Layer* tmp = newlayer; newlayer = tr2x2Layer; tr2x2Layer = tmp; } - if (hascreatednewselection) - { -// printf ("Restoring previous 2x2 result (s) (cheaply)\n"); - Selection *tmp = newselection; + if (hascreatednewselection) { + // printf ("Restoring previous 2x2 result (s) + //(cheaply)\n"); + Selection* tmp = newselection; newselection = tr2x2Selection; tr2x2Selection = tmp; } } first = false; -// printf ("Calling Process (%f, %f)\n", point.x, point.y); - transformerOpen->Process (tr2x2Layer, sel ? tr2x2Selection : NULL, - &newlayer, &newselection, - mode->selected(), &pRect, false, point, buttons); - if (newlayer && newlayer != tr2x2Layer) - { -// printf ("newlayer\n"); + // printf ("Calling Process (%f, %f)\n", point.x, point.y); + transformerOpen->Process( + tr2x2Layer, sel ? tr2x2Selection : NULL, &newlayer, &newselection, + mode->selected(), &pRect, false, point, buttons + ); + if (newlayer && newlayer != tr2x2Layer) { + // printf ("newlayer\n"); hascreatednewlayer = true; hascreatednewlayeronce = true; - Layer *tmp = tr2x2Layer; + Layer* tmp = tr2x2Layer; tr2x2Layer = newlayer; newlayer = tmp; - } - else + } else hascreatednewlayer = false; - if (newselection && newselection != tr2x2Selection) - { -// printf ("newselection\n"); + if (newselection && newselection != tr2x2Selection) { + // printf ("newselection\n"); hascreatednewselection = true; hascreatednewselectiononce = true; - Selection *tmp = tr2x2Selection; + Selection* tmp = tr2x2Selection; tr2x2Selection = newselection; newselection = tmp; - } - else + } else hascreatednewselection = false; -// printf ("Rescaling bitmap\n"); + // printf ("Rescaling bitmap\n"); AttachCurrentLayer(); - drawView->DrawBitmap (tr2x2Layer, halfsize, fCanvasFrame); + drawView->DrawBitmap(tr2x2Layer, halfsize, fCanvasFrame); DetachCurrentLayer(); -// printf ("Invalidating...\n"); - Invalidate (); + // printf ("Invalidating...\n"); + Invalidate(); } prev = point; - snooze (100000); - ScrollIfNeeded (point); + snooze(100000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); - GetMouse (&point, &buttons, true); + GetMouse(&point, &buttons, true); point.x /= 2; point.y /= 2; } @@ -2514,115 +2415,100 @@ void CanvasView::eTransform (BPoint point, uint32 buttons) pRect = savePRect; point.x *= 2; point.y *= 2; - } - else - { - while (buttons) - { - if (prev != point) - { - if (!first) - { - if (!hascreatednewlayer && !hascreatednewselection) - { -// printf ("Restoring previous result\n"); - Undo (false); + } else { + while (buttons) { + if (prev != point) { + if (!first) { + if (!hascreatednewlayer && !hascreatednewselection) { + // printf ("Restoring previous result\n"); + Undo(false); } - if (hascreatednewlayer) // Cheap way of restoring old result... + if (hascreatednewlayer) // Cheap way of restoring old result... { -// printf ("Restoring previous result (cheaply)\n"); - Layer *tmp = newlayer; + // printf ("Restoring previous result (cheaply)\n"); + Layer* tmp = newlayer; newlayer = currentLayer(); layer[fCurrentLayer] = tmp; } - if (hascreatednewselection) - { -// printf ("Restoring previous result (cheaply)\n"); - Selection *tmp = newselection; + if (hascreatednewselection) { + // printf ("Restoring previous result (cheaply)\n"); + Selection* tmp = newselection; newselection = selection; selection = tmp; } } first = false; -// printf ("Calling Process\n"); - transformerOpen->Process (currentLayer(), sel ? selection : NULL, - &newlayer, &newselection, - mode->selected(), &pRect, false, point, buttons); - if (newlayer && newlayer != currentLayer()) - { -// printf ("newlayer\n"); + // printf ("Calling Process\n"); + transformerOpen->Process( + currentLayer(), sel ? selection : NULL, &newlayer, &newselection, + mode->selected(), &pRect, false, point, buttons + ); + if (newlayer && newlayer != currentLayer()) { + // printf ("newlayer\n"); hascreatednewlayer = true; hascreatednewlayeronce = true; - Layer *tmp = currentLayer(); + Layer* tmp = currentLayer(); layer[fCurrentLayer] = newlayer; newlayer = tmp; - } - else + } else hascreatednewlayer = false; - if (newselection && newselection != selection) - { -// printf ("newselection\n"); + if (newselection && newselection != selection) { + // printf ("newselection\n"); hascreatednewselection = true; hascreatednewselectiononce = true; - Selection *tmp = selection; + Selection* tmp = selection; selection = newselection; newselection = tmp; - } - else + } else hascreatednewselection = false; -// printf ("Invalidating...\n"); - Invalidate (); + // printf ("Invalidating...\n"); + Invalidate(); } prev = point; - snooze (100000); - ScrollIfNeeded (point); + snooze(100000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); - GetMouse (&point, &buttons, true); + GetMouse(&point, &buttons, true); } } -// printf ("Exited loop\n"); + // printf ("Exited loop\n"); inAddOn = false; - if (!hascreatednewlayeronce && !hascreatednewselectiononce) - { -// printf ("Restoring previous result\n"); - Undo (false); - } - else - { - if (hascreatednewlayer) // Cheap way of restoring old result... - { -// printf ("Restoring previous result (cheaply)\n"); - Layer *tmp = newlayer; + if (!hascreatednewlayeronce && !hascreatednewselectiononce) { + // printf ("Restoring previous result\n"); + Undo(false); + } else { + if (hascreatednewlayer) // Cheap way of restoring old result... + { + // printf ("Restoring previous result (cheaply)\n"); + Layer* tmp = newlayer; newlayer = currentLayer(); layer[fCurrentLayer] = tmp; } - if (hascreatednewselection) - { -// printf ("Restoring previous result (cheaply)\n"); - Selection *tmp = newselection; + if (hascreatednewselection) { + // printf ("Restoring previous result (cheaply)\n"); + Selection* tmp = newselection; newselection = selection; selection = tmp; } } -// printf ("Calling Process (%f, %f) again for final preview\n", point.x, point.y); - transformerOpen->Process (currentLayer(), sel ? selection : NULL, - &newlayer, &newselection, - mode->selected(), &pRect, false, point, buttons); -// printf ("Done.\n"); - if (newlayer && newlayer != currentLayer()) - { -// printf ("newlayer\n"); + // printf ("Calling Process (%f, %f) again for final preview\n", point.x, point.y); + transformerOpen->Process( + currentLayer(), sel ? selection : NULL, &newlayer, &newselection, mode->selected(), &pRect, + false, point, buttons + ); + // printf ("Done.\n"); + if (newlayer && newlayer != currentLayer()) { + // printf ("newlayer\n"); delete currentLayer(); layer[fCurrentLayer] = newlayer; } - if (newselection && newselection != selection) - { -// printf ("newselection\n"); + if (newselection && newselection != selection) { + // printf ("newselection\n"); delete selection; selection = newselection; } @@ -2632,19 +2518,18 @@ void CanvasView::eTransform (BPoint point, uint32 buttons) tr2x2Selection = NULL; tr2x2Layer = NULL; -// printf ("Attaching\n"); + // printf ("Attaching\n"); AttachSelection(); AttachCurrentLayer(); myWindow->Lock(); - if (myWindow->isLayerOpen()) - { + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); - myWindow->layerWindow->doChanges (currentLayerIndex()); + myWindow->layerWindow->doChanges(currentLayerIndex()); myWindow->layerWindow->Unlock(); } myWindow->Unlock(); -// printf ("Finishing up...\n"); + // printf ("Finishing up...\n"); currentLayer()->Lock(); selection->Lock(); Invalidate(); @@ -2654,14 +2539,15 @@ void CanvasView::eTransform (BPoint point, uint32 buttons) #endif -void CanvasView::eGenerate (BPoint point, uint32 buttons) +void +CanvasView::eGenerate(BPoint point, uint32 buttons) { -// printf ("CanvasView::eGenerate()\n"); + // printf ("CanvasView::eGenerate()\n"); // Note: inefficient. If !sel, don't `new' newselection! - extern PicMenuButton *mode; - if (!generatorSaved) // There's no undo buffer setup yet. + extern PicMenuButton* mode; + if (!generatorSaved) // There's no undo buffer setup yet. { - SetupUndo (mode->selected()); // Save now. + SetupUndo(mode->selected()); // Save now. // But we're `just' previewing (interactively here), there's no need to // flush the undo buffer, so we shouldn't save next time we come here. generatorSaved = true; @@ -2669,44 +2555,44 @@ void CanvasView::eGenerate (BPoint point, uint32 buttons) currentLayer()->Lock(); selection->Lock(); - Layer *newlayer = new Layer (*currentLayer()); - Selection *newselection = new Selection (*selection); - memcpy (newlayer->Bits(), currentLayer()->Bits(), currentLayer()->BitsLength()); - memcpy (newselection->Bits(), selection->Bits(), selection->BitsLength()); + Layer* newlayer = new Layer(*currentLayer()); + Selection* newselection = new Selection(*selection); + memcpy(newlayer->Bits(), currentLayer()->Bits(), currentLayer()->BitsLength()); + memcpy(newselection->Bits(), selection->Bits(), selection->BitsLength()); selection->Unlock(); currentLayer()->Unlock(); - BRect pRect = sel ? GetSmallestRect (selection) : fCanvasFrame; - BPoint prev = BPoint (0, 0); - Layer *cLayer = currentLayer(); + BRect pRect = sel ? GetSmallestRect(selection) : fCanvasFrame; + BPoint prev = BPoint(0, 0); + Layer* cLayer = currentLayer(); DetachCurrentLayer(); DetachSelection(); -// printf ("currentLayer() = %p, ->Bits() = %p\n", cLayer, cLayer->Bits()); + // printf ("currentLayer() = %p, ->Bits() = %p\n", cLayer, cLayer->Bits()); if (mode->selected() == M_SELECT) selchanged = true; // if (sel) printf ("Sel!\n"); // else printf ("No Sel!\n"); - inAddOn = (mode->selected() == M_DRAW); // ConstructCanvas wants to know about this. - while (buttons) - { - if (prev != point) - { - generatorOpen->Process (newlayer, sel ? newselection : NULL, - &cLayer, &selection, - mode->selected(), &pRect, false, point, buttons); - Invalidate (); + inAddOn = (mode->selected() == M_DRAW); // ConstructCanvas wants to know about this. + while (buttons) { + if (prev != point) { + generatorOpen->Process( + newlayer, sel ? newselection : NULL, &cLayer, &selection, mode->selected(), &pRect, + false, point, buttons + ); + Invalidate(); } prev = point; - snooze (100000); - ScrollIfNeeded (point); + snooze(100000); + ScrollIfNeeded(point); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); - GetMouse (&point, &buttons, true); + GetMouse(&point, &buttons, true); } inAddOn = false; - generatorOpen->Process (newlayer, sel ? newselection : NULL, - &cLayer, &selection, - mode->selected(), &pRect, false, point, buttons); + generatorOpen->Process( + newlayer, sel ? newselection : NULL, &cLayer, &selection, mode->selected(), &pRect, false, + point, buttons + ); AttachSelection(); AttachCurrentLayer(); newlayer->Lock(); @@ -2714,10 +2600,9 @@ void CanvasView::eGenerate (BPoint point, uint32 buttons) newselection->Lock(); delete newselection; myWindow->Lock(); - if (myWindow->isLayerOpen()) - { + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); - myWindow->layerWindow->doChanges (currentLayerIndex()); + myWindow->layerWindow->doChanges(currentLayerIndex()); myWindow->layerWindow->Unlock(); } myWindow->Unlock(); @@ -2726,63 +2611,63 @@ void CanvasView::eGenerate (BPoint point, uint32 buttons) sel = true; } -BBitmap *CanvasView::canvas (bool do_export) +BBitmap* +CanvasView::canvas(bool do_export) { - BBitmap *cvBitmap = new BBitmap (fCanvasFrame, B_RGBA32, true); - ConstructCanvas (cvBitmap, fCanvasFrame, !do_export, do_export); + BBitmap* cvBitmap = new BBitmap(fCanvasFrame, B_RGBA32, true); + ConstructCanvas(cvBitmap, fCanvasFrame, !do_export, do_export); return cvBitmap; } -void CanvasView::Print () +void +CanvasView::Print() { status_t res = B_OK; - extern BMessage *printSetup; + extern BMessage* printSetup; char name[1024]; - sprintf (name, "Becasso: %s", myWindow->Name()); - BPrintJob job (name); - if (!printSetup) - { - verbose (2, "No existing print setup\n"); - if ((res = job.ConfigPage()) == B_OK) - { + sprintf(name, "Becasso: %s", myWindow->Name()); + BPrintJob job(name); + if (!printSetup) { + verbose(2, "No existing print setup\n"); + if ((res = job.ConfigPage()) == B_OK) { printSetup = job.Settings(); - verbose (2, "Got new settings\n"); + verbose(2, "Got new settings\n"); } } - if (res == B_OK) - { - job.SetSettings (new BMessage (*printSetup)); - if ((res = job.ConfigJob()) == B_OK) - { - verbose (2, "Print job configured\n"); + if (res == B_OK) { + job.SetSettings(new BMessage(*printSetup)); + if ((res = job.ConfigJob()) == B_OK) { + verbose(2, "Print job configured\n"); if (!printSetup) - printf ("HUH?!\n"); + printf("HUH?!\n"); delete printSetup; printSetup = job.Settings(); job.BeginJob(); - verbose (2, "BeginJob() done\n"); - job.DrawView (this, fCanvasFrame, B_ORIGIN); - verbose (2, "DrawView() done\n"); + verbose(2, "BeginJob() done\n"); + job.DrawView(this, fCanvasFrame, B_ORIGIN); + verbose(2, "DrawView() done\n"); job.SpoolPage(); - verbose (2, "SpoolPage() done\n"); + verbose(2, "SpoolPage() done\n"); job.CommitJob(); - verbose (2, "CommitJob() done\n"); + verbose(2, "CommitJob() done\n"); } } } -void CanvasView::ConstructCanvas (BBitmap *bitmap, BRect update, bool doselect, bool do_export) +void +CanvasView::ConstructCanvas(BBitmap* bitmap, BRect update, bool doselect, bool do_export) { -// clock_t start, end; -// start = clock(); -// extern PicMenuButton *mode; + // clock_t start, end; + // start = clock(); + // extern PicMenuButton *mode; bitmap->Lock(); if (doselect) selection->Lock(); - update = update & bitmap->Bounds(); // This used not to be necessary, but somehow R3 can crash if you - // go (too far) outside the bitmap. Strange that PR2 didn't! + update = + update & bitmap->Bounds(); // This used not to be necessary, but somehow R3 can crash if you + // go (too far) outside the bitmap. Strange that PR2 didn't! #if 0 BPoint po = fPreviewRect.LeftTop(); @@ -2799,91 +2684,82 @@ void CanvasView::ConstructCanvas (BBitmap *bitmap, BRect update, bool doselect, fPreviewRect.OffsetTo (po); #endif -// ulong h = fCanvasFrame.IntegerHeight() + 1; // Note the + 1 ! Really! + // ulong h = fCanvasFrame.IntegerHeight() + 1; // Note the + 1 ! Really! ulong w = fCanvasFrame.IntegerWidth() + 1; -// ulong sbbpr = bitmap->BytesPerRow(); + // ulong sbbpr = bitmap->BytesPerRow(); ulong sbpr = layer[0]->BytesPerRow(); - ulong rt = ulong (update.top); - ulong rb = ulong (update.bottom); - ulong rl = ulong (update.left); - ulong rr = ulong (update.right); + ulong rt = ulong(update.top); + ulong rb = ulong(update.bottom); + ulong rl = ulong(update.left); + ulong rr = ulong(update.right); ulong dw = rr - rl + 1; ulong ddiff = (w - dw); -// ulong sdiff = sbpr - dw; - uint32 *src = (uint32 *) layer[0]->Bits(); - src += rt*sbpr + rl; - uint32 *dest = (uint32 *) screenbitmap32->Bits() + (rt*w + rl) - 1; -// ulong brl = rl; -// long sel_bpr = selection->BytesPerRow(); -// uchar *sel_data = (uchar *) selection->Bits() + rt*sel_bpr + rl - 1; -// long seldiff = sel_bpr - dw; - -// printf ("sdiff = %li, ddiff = %li\n", sdiff, ddiff); -// printf ("Background layer\n"); - #if defined (__POWERPC__) - uint32 check1 = do_export ? 0xFFFFFF00 : 0xC8C8C800; - uint32 check2 = do_export ? 0xFFFFFF00 : 0xEBEBEB00; - #else - uint32 check1 = do_export ? 0x00FFFFFF : 0x00C8C8C8; - uint32 check2 = do_export ? 0x00FFFFFF : 0x00EBEBEB; - #endif - for (ulong y = rt; y <= rb; y++) // First layer: Background. + // ulong sdiff = sbpr - dw; + uint32* src = (uint32*)layer[0]->Bits(); + src += rt * sbpr + rl; + uint32* dest = (uint32*)screenbitmap32->Bits() + (rt * w + rl) - 1; + // ulong brl = rl; + // long sel_bpr = selection->BytesPerRow(); + // uchar *sel_data = (uchar *) selection->Bits() + rt*sel_bpr + rl - 1; + // long seldiff = sel_bpr - dw; + + // printf ("sdiff = %li, ddiff = %li\n", sdiff, ddiff); + // printf ("Background layer\n"); +#if defined(__POWERPC__) + uint32 check1 = do_export ? 0xFFFFFF00 : 0xC8C8C800; + uint32 check2 = do_export ? 0xFFFFFF00 : 0xEBEBEB00; +#else + uint32 check1 = do_export ? 0x00FFFFFF : 0x00C8C8C8; + uint32 check2 = do_export ? 0x00FFFFFF : 0x00EBEBEB; +#endif + for (ulong y = rt; y <= rb; y++) // First layer: Background. { - for (ulong x = rl; x <= rr; x++) - { - if (((x & 8) || (y & 8)) && !((x & 8) && (y & 8))) - { + for (ulong x = rl; x <= rr; x++) { + if (((x & 8) || (y & 8)) && !((x & 8) && (y & 8))) { *(++dest) = check1; - } - else - { + } else { *(++dest) = check2; } } dest += ddiff; } - for (int i = 0; i < fNumLayers; i++) // Next the layers: Add. + for (int i = 0; i < fNumLayers; i++) // Next the layers: Add. { -// printf ("Layer %i\n", i); + // printf ("Layer %i\n", i); // printf ("[%d]", i); fflush (stdout); - if (!layer[i]->IsHidden()) - { - Layer *pLayer = NULL; - Selection *pSelection = NULL; + if (!layer[i]->IsHidden()) { + Layer* pLayer = NULL; + Selection* pSelection = NULL; bool preview_done = false; - if ((currentLayerIndex() == i) - && (doselect) - && (filterOpen) - && (filterOpen->DoesPreview())& (update.Intersects (fPreviewRect))) - { - pLayer = new Layer (*previewLayer); - pSelection = new Selection (*previewSelection); - BView *preView = new SView (pLayer->Bounds(), "preView", B_FOLLOW_ALL, uint32 (NULL)); + if ((currentLayerIndex() == i) && (doselect) && (filterOpen) && + (filterOpen->DoesPreview()) & (update.Intersects(fPreviewRect))) { + pLayer = new Layer(*previewLayer); + pSelection = new Selection(*previewSelection); + BView* preView = new SView(pLayer->Bounds(), "preView", B_FOLLOW_ALL, uint32(NULL)); pLayer->Lock(); - pLayer->AddChild (preView); - preView->DrawBitmap (currentLayer(), BPoint (-fPreviewRect.left, -fPreviewRect.top)); - pLayer->RemoveChild (preView); + pLayer->AddChild(preView); + preView->DrawBitmap(currentLayer(), BPoint(-fPreviewRect.left, -fPreviewRect.top)); + pLayer->RemoveChild(preView); pSelection->Lock(); - pSelection->AddChild (preView); - preView->DrawBitmap (selection, BPoint (-fPreviewRect.left, -fPreviewRect.top)); - pSelection->RemoveChild (preView); + pSelection->AddChild(preView); + preView->DrawBitmap(selection, BPoint(-fPreviewRect.left, -fPreviewRect.top)); + pSelection->RemoveChild(preView); delete preView; currentLayer()->Lock(); - drawView->DrawBitmap (previewLayer, fPreviewRect.LeftTop()); + drawView->DrawBitmap(previewLayer, fPreviewRect.LeftTop()); currentLayer()->Unlock(); selection->Lock(); - selectionView->DrawBitmap (previewSelection, fPreviewRect.LeftTop()); + selectionView->DrawBitmap(previewSelection, fPreviewRect.LeftTop()); selection->Unlock(); preview_done = true; } - Merge (screenbitmap32, layer[i], update, doselect & (i == fCurrentLayer), do_export); - if (preview_done) - { + Merge(screenbitmap32, layer[i], update, doselect & (i == fCurrentLayer), do_export); + if (preview_done) { currentLayer()->Lock(); - drawView->DrawBitmap (pLayer, fPreviewRect.LeftTop()); + drawView->DrawBitmap(pLayer, fPreviewRect.LeftTop()); currentLayer()->Unlock(); selection->Lock(); - selectionView->DrawBitmap (pSelection, fPreviewRect.LeftTop()); + selectionView->DrawBitmap(pSelection, fPreviewRect.LeftTop()); selection->Unlock(); delete pLayer; delete pSelection; @@ -2891,56 +2767,54 @@ void CanvasView::ConstructCanvas (BBitmap *bitmap, BRect update, bool doselect, } } } - if (bitmap->ColorSpace() == B_COLOR_8_BIT) - { - FSDither (screenbitmap32, bitmap, update); - } - else if (bitmap != screenbitmap) - { + if (bitmap->ColorSpace() == B_COLOR_8_BIT) { + FSDither(screenbitmap32, bitmap, update); + } else if (bitmap != screenbitmap) { /////////////////// // printf ("Here?!\n"); if (bitmap->ColorSpace() == B_RGBA32) - memcpy (bitmap->Bits(), screenbitmap32->Bits(), bitmap->BitsLength()); + memcpy(bitmap->Bits(), screenbitmap32->Bits(), bitmap->BitsLength()); else - printf ("Whoa, big trouble.\n"); + printf("Whoa, big trouble.\n"); } - extern int gGlobalAlpha; // == registered - if (do_export && !gGlobalAlpha) - { - SView *demoView = new SView (fCanvasFrame, "demoview", B_FOLLOW_NONE, uint32 (NULL)); + extern int gGlobalAlpha; // == registered + if (do_export && !gGlobalAlpha) { + SView* demoView = new SView(fCanvasFrame, "demoview", B_FOLLOW_NONE, uint32(NULL)); const char demotext[] = "Becasso"; - bitmap->AddChild (demoView); + bitmap->AddChild(demoView); float h = fCanvasFrame.Height(); float w = fCanvasFrame.Width(); - BFont font (be_bold_font); + BFont font(be_bold_font); font_height fh; - font.GetHeight (&fh); - float ratio = font.StringWidth (demotext) / (fh.ascent + fh.descent + fh.leading); - float size = sqrt (h*h/(ratio*ratio) + w*w)/font.StringWidth (demotext) * 11; - float angle = 360*atan2 (h - (fh.ascent + fh.leading), w)/2/M_PI; - font.SetSize (size); - // printf ("Size = %f, ratio = %f, sqrt = %f\n", size, ratio, sqrt (h*h/(ratio*ratio) + w*w)); - font.SetRotation (angle); - demoView->SetFont (&font); - demoView->SetDrawingMode (B_OP_OVER); - demoView->SetHighColor (Red); - demoView->DrawString (demotext, BPoint (fh.ascent + fh.descent + fh.leading, h - fh.descent)); + font.GetHeight(&fh); + float ratio = font.StringWidth(demotext) / (fh.ascent + fh.descent + fh.leading); + float size = sqrt(h * h / (ratio * ratio) + w * w) / font.StringWidth(demotext) * 11; + float angle = 360 * atan2(h - (fh.ascent + fh.leading), w) / 2 / M_PI; + font.SetSize(size); + // printf ("Size = %f, ratio = %f, sqrt = %f\n", size, ratio, sqrt (h*h/(ratio*ratio) + + // w*w)); + font.SetRotation(angle); + demoView->SetFont(&font); + demoView->SetDrawingMode(B_OP_OVER); + demoView->SetHighColor(Red); + demoView->DrawString(demotext, BPoint(fh.ascent + fh.descent + fh.leading, h - fh.descent)); demoView->Sync(); - bitmap->RemoveChild (demoView); + bitmap->RemoveChild(demoView); delete demoView; } if (doselect) selection->Unlock(); bitmap->Unlock(); -// end = clock(); -// printf ("ConstructCanvas took %d ms\n", end - start); + // end = clock(); + // printf ("ConstructCanvas took %d ms\n", end - start); } -void CanvasView::Merge (BBitmap *a, Layer *b, BRect update, bool doselect, bool preserve_alpha) +void +CanvasView::Merge(BBitmap* a, Layer* b, BRect update, bool doselect, bool preserve_alpha) { -// clock_t start, end; -// start = clock(); + // clock_t start, end; + // start = clock(); extern bool UseMMX; extern BLocker g_settings_lock; extern becasso_settings g_settings; @@ -2949,117 +2823,158 @@ void CanvasView::Merge (BBitmap *a, Layer *b, BRect update, bool doselect, bool if (g_settings.selection_type != SELECTION_IN_OUT) invertselect = true; g_settings_lock.Unlock(); -// ulong h = fCanvasFrame.IntegerHeight() + 1; // Note the + 1 ! Really! + // ulong h = fCanvasFrame.IntegerHeight() + 1; // Note the + 1 ! Really! ulong w = fCanvasFrame.IntegerWidth() + 1; -// ulong sbbpr = a->BytesPerRow(); - ulong sbpr = b->BytesPerRow()/4; - ulong rt = ulong (update.top); - ulong rb = ulong (update.bottom); - ulong rl = ulong (update.left); - ulong rr = ulong (update.right); + // ulong sbbpr = a->BytesPerRow(); + ulong sbpr = b->BytesPerRow() / 4; + ulong rt = ulong(update.top); + ulong rb = ulong(update.bottom); + ulong rl = ulong(update.left); + ulong rr = ulong(update.right); ulong dw = rr - rl + 1; ulong ddiff = (w - dw); ulong sdiff = sbpr - dw; -// ulong brl = rl; + // ulong brl = rl; long sel_bpr = selection->BytesPerRow(); - uchar *sel_data = (uchar *) selection->Bits() + rt*sel_bpr + rl - 1; + uchar* sel_data = (uchar*)selection->Bits() + rt * sel_bpr + rl - 1; long seldiff = sel_bpr - dw; - uint32 *src = (uint32 *) b->Bits() + rt*sbpr + rl - 1; - uint32 *dest = (uint32 *) a->Bits() + (rt*w + rl) - 1; + uint32* src = (uint32*)b->Bits() + rt * sbpr + rl - 1; + uint32* dest = (uint32*)a->Bits() + (rt * w + rl) - 1; int ga = b->getGlobalAlpha(); - switch (b->getMode()) - { + switch (b->getMode()) { case DM_BLEND: - if (/* mode->selected() == M_SELECT && */ invertselect && selchanged && doselect && !inAddOn) - { -// printf ("Selection in layer %i\n", i); - for (ulong y = rt; y <= rb; y++) - { - for (ulong x = rl; x <= rr; x++) - { -#if defined (__POWERPC__) + if (/* mode->selected() == M_SELECT && */ invertselect && selchanged && doselect && + !inAddOn) { + // printf ("Selection in layer %i\n", i); + for (ulong y = rt; y <= rb; y++) { + for (ulong x = rl; x <= rr; x++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src); register uint32 destpixel = *(++dest); - register int sa = (srcpixel & 0xFF)*ga/255; + register int sa = (srcpixel & 0xFF) * ga / 255; register int da = 255 - sa; register unsigned int sel = *(++sel_data); - if (!sel) - { -// *dest = ((((destpixel & 0xFF00FF00) >> 8)*da + ((srcpixel & 0xFF00FF00) >> 8)*sa) & 0xFF00FF00) | -// ((((destpixel & 0x00FF0000) >> 8)*da + ((srcpixel & 0x00FF0000) >> 8)*sa) * 0x00FF0000) | -// (sa); -// *dest = (((((destpixel>>24) *da + (srcpixel>>24) *sa)<<16)) & 0xFF000000) | -// (((((destpixel>>16) & 0xFF)*da + ((srcpixel>>16) & 0xFF)*sa)<< 8) & 0x00FF0000) | -// ((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> 8) & 0xFF)*sa) & 0x0000FF00) | -// (sa & 0xFF);//(max_c (sa, da) & 0xFF); -# if !defined (BLEND_USES_SHIFTS) - *dest = ((((destpixel & 0xFF000000)/255*da + (srcpixel & 0xFF000000)/255*sa)) & 0xFF000000) | - ((((destpixel & 0x00FF0000)*da + (srcpixel & 0x00FF0000)*sa)/255) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/255) & 0x0000FF00) |\ - // (max_c (sa, destpixel & 0xFF)); - (clipchar (sa + int (destpixel & 0xFF))); -# else - *dest = (((((destpixel & 0xFF000000)>>8)*da + ((srcpixel & 0xFF000000)>>8)*sa)) & 0xFF000000) | - ((((destpixel & 0x00FF0000)*da + (srcpixel & 0x00FF0000)*sa)>>8) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)>>8) & 0x0000FF00) |\ - (clipchar (sa + int (destpixel & 0xFF))); -# endif - } - else - { -// *dest = (0xFFFFFF00 - (srcpixel & 0xFFFFFF00)) | sa; - register uint32 ipixel = pixelblend (srcpixel, (0xFFFFFF00 - (srcpixel & 0xFFFFFF00)) | sel); -# if !defined (BLEND_USES_SHIFTS) - *dest = ((((destpixel & 0xFF000000)/255*da + (ipixel & 0xFF000000)/255*sa)) & 0xFF000000) | - ((((destpixel & 0x00FF0000)*da + (ipixel & 0x00FF0000)*sa)/255) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (ipixel & 0x0000FF00)*sa)/255) & 0x0000FF00) | - sa; -# else - *dest = (((((destpixel & 0xFF000000)>>8)*da + ((ipixel & 0xFF000000)>>8)*sa)) & 0xFF000000) | - ((((destpixel & 0x00FF0000)*da + (ipixel & 0x00FF0000)*sa)>>8) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (ipixel & 0x0000FF00)*sa)>>8) & 0x0000FF00) | - sa; -# endif + if (!sel) { +// *dest = ((((destpixel & 0xFF00FF00) >> 8)*da + ((srcpixel & 0xFF00FF00) >> +// 8)*sa) & 0xFF00FF00) | +// ((((destpixel & 0x00FF0000) >> 8)*da + ((srcpixel & 0x00FF0000) >> +// 8)*sa) * 0x00FF0000) | (sa); *dest = +// (((((destpixel>>24) *da + (srcpixel>>24) *sa)<<16)) & 0xFF000000) | +// (((((destpixel>>16) & 0xFF)*da + ((srcpixel>>16) & 0xFF)*sa)<< 8) & +// 0x00FF0000) | +// ((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> 8) & 0xFF)*sa) & +// 0x0000FF00) | (sa & 0xFF);//(max_c (sa, da) & 0xFF); +#if !defined(BLEND_USES_SHIFTS) + *dest = ((((destpixel & 0xFF000000) / 255 * da + + (srcpixel & 0xFF000000) / 255 * sa)) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) * da + (srcpixel & 0x00FF0000) * sa) / + 255) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) / + 255) & + 0x0000FF00) | // (max_c (sa, destpixel & 0xFF)); + (clipchar(sa + int(destpixel & 0xFF))); +#else + *dest = + (((((destpixel & 0xFF000000) >> 8) * da + + ((srcpixel & 0xFF000000) >> 8) * sa)) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) * da + (srcpixel & 0x00FF0000) * sa) >> 8) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) >> 8) & + 0x0000FF00) | + (clipchar(sa + int(destpixel & 0xFF))); +#endif + } else { + // *dest = (0xFFFFFF00 - (srcpixel & 0xFFFFFF00)) | sa; + register uint32 ipixel = + pixelblend(srcpixel, (0xFFFFFF00 - (srcpixel & 0xFFFFFF00)) | sel); +#if !defined(BLEND_USES_SHIFTS) + *dest = + ((((destpixel & 0xFF000000) / 255 * da + + (ipixel & 0xFF000000) / 255 * sa)) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) * da + (ipixel & 0x00FF0000) * sa) / 255) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (ipixel & 0x0000FF00) * sa) / 255) & + 0x0000FF00) | + sa; +#else + *dest = + (((((destpixel & 0xFF000000) >> 8) * da + + ((ipixel & 0xFF000000) >> 8) * sa)) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) * da + (ipixel & 0x00FF0000) * sa) >> 8) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (ipixel & 0x0000FF00) * sa) >> 8) & + 0x0000FF00) | + sa; +#endif } -#else // Intel +#else // Intel register uint32 srcpixel = *(++src); register uint32 destpixel = *(++dest); - register int sa = (srcpixel >> 24)*ga/255; + register int sa = (srcpixel >> 24) * ga / 255; register int da = 255 - sa; register unsigned int sel = *(++sel_data); - if (!sel) - { -// *dest = ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/255) & 0x0000FF00) | -// ((((destpixel & 0x00FF00FF)*da + (srcpixel & 0x00FF00FF)*sa)/255) & 0x00FF00FF) | -// (sa); -# if !defined (BLEND_USES_SHIFTS) - *dest = ((((destpixel & 0x00FF0000)*da + (srcpixel & 0x00FF0000)*sa)/255) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/255) & 0x0000FF00) | - ((((destpixel & 0x000000FF)*da + (srcpixel & 0x000000FF)*sa)/255) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); - //((max_c (sa, destpixel >> 24)) << 24); -# else - *dest = (((((destpixel & 0x00FF0000) - (srcpixel & 0x00FF0000))*da + ((srcpixel & 0x00FF0000)<<8))>>8) & 0x00FF0000) | - (((((destpixel & 0x0000FF00) - (srcpixel & 0x0000FF00))*da + ((srcpixel & 0x0000FF00)<<8))>>8) & 0x0000FF00) | - (((((destpixel & 0x000000FF) - (srcpixel & 0x000000FF))*da + ((srcpixel & 0x000000FF)<<8))>>8) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); -# endif - } - else - { -// *dest = (0x00FFFFFF - (srcpixel & 0x00FFFFFF)) | (sa << 24); - register uint32 ipixel = pixelblend (srcpixel, (0x00FFFFFF - (srcpixel & 0x00FFFFFF)) | (sel << 24)); -# if !defined (BLEND_USES_SHIFTS) - *dest = ((((destpixel & 0x00FF0000)*da + (ipixel & 0x00FF0000)*sa)/255) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (ipixel & 0x0000FF00)*sa)/255) & 0x0000FF00) | - ((((destpixel & 0x000000FF)*da + (ipixel & 0x000000FF)*sa)/255) & 0x000000FF) | - (sa << 24); -# else - *dest = ((((destpixel & 0x00FF0000)*da + (ipixel & 0x00FF0000)*sa)>>8) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (ipixel & 0x0000FF00)*sa)>>8) & 0x0000FF00) | - ((((destpixel & 0x000000FF)*da + (ipixel & 0x000000FF)*sa)>>8) & 0x000000FF) | - (sa << 24); -# endif + if (!sel) { +// *dest = ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/255) & +// 0x0000FF00) | +// ((((destpixel & 0x00FF00FF)*da + (srcpixel & 0x00FF00FF)*sa)/255) & +// 0x00FF00FF) | (sa); +#if !defined(BLEND_USES_SHIFTS) + *dest = ((((destpixel & 0x00FF0000) * da + (srcpixel & 0x00FF0000) * sa) / + 255) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) / + 255) & + 0x0000FF00) | + ((((destpixel & 0x000000FF) * da + (srcpixel & 0x000000FF) * sa) / + 255) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); + //((max_c (sa, destpixel >> 24)) << 24); +#else + *dest = (((((destpixel & 0x00FF0000) - (srcpixel & 0x00FF0000)) * da + + ((srcpixel & 0x00FF0000) << 8)) >> + 8) & + 0x00FF0000) | + (((((destpixel & 0x0000FF00) - (srcpixel & 0x0000FF00)) * da + + ((srcpixel & 0x0000FF00) << 8)) >> + 8) & + 0x0000FF00) | + (((((destpixel & 0x000000FF) - (srcpixel & 0x000000FF)) * da + + ((srcpixel & 0x000000FF) << 8)) >> + 8) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); +#endif + } else { + // *dest = (0x00FFFFFF - (srcpixel & 0x00FFFFFF)) | (sa + //<< 24); + register uint32 ipixel = pixelblend( + srcpixel, (0x00FFFFFF - (srcpixel & 0x00FFFFFF)) | (sel << 24) + ); +#if !defined(BLEND_USES_SHIFTS) + *dest = + ((((destpixel & 0x00FF0000) * da + (ipixel & 0x00FF0000) * sa) / 255) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (ipixel & 0x0000FF00) * sa) / 255) & + 0x0000FF00) | + ((((destpixel & 0x000000FF) * da + (ipixel & 0x000000FF) * sa) / 255) & + 0x000000FF) | + (sa << 24); +#else + *dest = + ((((destpixel & 0x00FF0000) * da + (ipixel & 0x00FF0000) * sa) >> 8) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (ipixel & 0x0000FF00) * sa) >> 8) & + 0x0000FF00) | + ((((destpixel & 0x000000FF) * da + (ipixel & 0x000000FF) * sa) >> 8) & + 0x000000FF) | + (sa << 24); +#endif } #endif } @@ -3067,83 +2982,106 @@ void CanvasView::Merge (BBitmap *a, Layer *b, BRect update, bool doselect, bool dest += ddiff; sel_data += seldiff; } - } - else // doselect et al. + } else // doselect et al. { if (UseMMX && !preserve_alpha) - mmx_alpha_blend ((uint32 *) b->Bits(), (uint32 *) a->Bits(), ga, w, rl, rt, rr, rb); - else - { - for (ulong y = rt; y <= rb; y++) - { - for (ulong x = rl; x <= rr; x++) - { -#if defined (__POWERPC__) + mmx_alpha_blend((uint32*)b->Bits(), (uint32*)a->Bits(), ga, w, rl, rt, rr, rb); + else { + for (ulong y = rt; y <= rb; y++) { + for (ulong x = rl; x <= rr; x++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src); register uint32 destpixel = *(++dest); - register int sa = (srcpixel & 0xFF)*ga/255; + register int sa = (srcpixel & 0xFF) * ga / 255; register int da = 255 - sa; - if (da == 0) // Fully opaque pixel + if (da == 0) // Fully opaque pixel { *dest = srcpixel; - } - else if (da == 255) // Fully transparent pixel - { - } - else + } else if (da == 255) // Fully transparent pixel { -// *dest = ((((destpixel & 0xFF00FF00)/255)*da + ((srcpixel & 0xFF00FF00)/255)*sa) & 0xFF00FF00) | -// ((((destpixel & 0x00FF0000)/255)*da + ((srcpixel & 0x00FF0000)/255)*sa) & 0x00FF0000) | -// (sa); -// *dest = (((((destpixel>>24) *da + (srcpixel>>24) *sa)<<16)) & 0xFF000000) | -// (((((destpixel>>16) & 0xFF)*da + ((srcpixel>>16) & 0xFF)*sa)<< 8) & 0x00FF0000) | -// ((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> 8) & 0xFF)*sa) & 0x0000FF00) | -// (sa & 0xFF);//(max_c (sa, da) & 0xFF); -# if !defined (BLEND_USES_SHIFTS) - *dest = ((((destpixel & 0xFF000000)/255*da + (srcpixel & 0xFF000000)/255*sa)) & 0xFF000000) | - ((((destpixel & 0x00FF0000)*da + (srcpixel & 0x00FF0000)*sa)/255) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/255) & 0x0000FF00) |\ - // (max_c (sa, destpixel & 0xFF)); - (clipchar (sa + int (destpixel & 0xFF))); -# else - *dest = (((((destpixel & 0xFF000000)>>8)*da + ((srcpixel & 0xFF000000)>>8)*sa)) & 0xFF000000) | - ((((destpixel & 0x00FF0000)*da + (srcpixel & 0x00FF0000)*sa)>>8) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)>>8) & 0x0000FF00) |\ - (clipchar (sa + int (destpixel & 0xFF))); -# endif + } else { +// *dest = ((((destpixel & 0xFF00FF00)/255)*da + ((srcpixel & +// 0xFF00FF00)/255)*sa) & 0xFF00FF00) | +// ((((destpixel & 0x00FF0000)/255)*da + ((srcpixel & +// 0x00FF0000)/255)*sa) & 0x00FF0000) | (sa); +// *dest = (((((destpixel>>24) *da + (srcpixel>>24) *sa)<<16)) & 0xFF000000) | +// (((((destpixel>>16) & 0xFF)*da + ((srcpixel>>16) & 0xFF)*sa)<< +// 8) & 0x00FF0000) | +// ((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> 8) & 0xFF)*sa) & +// 0x0000FF00) | (sa & 0xFF);//(max_c (sa, da) & 0xFF); +#if !defined(BLEND_USES_SHIFTS) + *dest = + ((((destpixel & 0xFF000000) / 255 * da + + (srcpixel & 0xFF000000) / 255 * sa)) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) * da + (srcpixel & 0x00FF0000) * sa) / + 255) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) / + 255) & + 0x0000FF00) | // (max_c (sa, destpixel & 0xFF)); + (clipchar(sa + int(destpixel & 0xFF))); +#else + *dest = + (((((destpixel & 0xFF000000) >> 8) * da + + ((srcpixel & 0xFF000000) >> 8) * sa)) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) * da + (srcpixel & 0x00FF0000) * sa) >> + 8) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) >> + 8) & + 0x0000FF00) | + (clipchar(sa + int(destpixel & 0xFF))); +#endif } -#else // Intel +#else // Intel register uint32 srcpixel = *(++src); register uint32 destpixel = *(++dest); - register int sa = (srcpixel >> 24)*ga/255; + register int sa = (srcpixel >> 24) * ga / 255; register int da = 255 - sa; - if (da == 0) // Fully opaque pixel + if (da == 0) // Fully opaque pixel { *dest = srcpixel; - } - else if (da == 255) // Fully transparent pixel - { - } - else + } else if (da == 255) // Fully transparent pixel { -// *dest = ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa) >> 8) & 0x0000FF00) | -// ((((destpixel & 0x00FF00FF)*da + (srcpixel & 0x00FF00FF)*sa) & 0xFF00FF00) >> 8) | -// (clipchar (sa + int (destpixel >> 24)) << 24); -// *dest = ((((((destpixel>>16) & 0xFF)*da + ((srcpixel>>16) & 0xFF)*sa) << 16)/255) & 0x00FF0000) | -// ((((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> 8) & 0xFF)*sa) << 8)/255) & 0x0000FF00) | -// ((((((destpixel ) & 0xFF)*da + ((srcpixel ) & 0xFF)*sa) )/255) & 0x000000FF) | -# if !defined (BLEND_USES_SHIFTS) - *dest = ((((destpixel & 0x00FF0000)*da + (srcpixel & 0x00FF0000)*sa)/255) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/255) & 0x0000FF00) | - ((((destpixel & 0x000000FF)*da + (srcpixel & 0x000000FF)*sa)/255) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); - //((max_c (sa, destpixel >> 24)) << 24); -# else - *dest = ((((destpixel & 0x00FF0000)*da + (srcpixel & 0x00FF0000)*sa)>>8) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)>>8) & 0x0000FF00) | - ((((destpixel & 0x000000FF)*da + (srcpixel & 0x000000FF)*sa)>>8) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); -# endif + } else { +// *dest = ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa) >> +// 8) & 0x0000FF00) | +// ((((destpixel & 0x00FF00FF)*da + (srcpixel & 0x00FF00FF)*sa) & +// 0xFF00FF00) >> 8) | (clipchar (sa + int (destpixel >> 24)) << +// 24); *dest = ((((((destpixel>>16) & 0xFF)*da + ((srcpixel>>16) & +// 0xFF)*sa) << 16)/255) & 0x00FF0000) | +// ((((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> 8) & 0xFF)*sa) << +// 8)/255) & 0x0000FF00) | +// ((((((destpixel ) & 0xFF)*da + ((srcpixel ) & 0xFF)*sa) +//)/255) & 0x000000FF) | +#if !defined(BLEND_USES_SHIFTS) + *dest = + ((((destpixel & 0x00FF0000) * da + (srcpixel & 0x00FF0000) * sa) / + 255) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) / + 255) & + 0x0000FF00) | + ((((destpixel & 0x000000FF) * da + (srcpixel & 0x000000FF) * sa) / + 255) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); + //((max_c (sa, destpixel >> 24)) << 24); +#else + *dest = + ((((destpixel & 0x00FF0000) * da + (srcpixel & 0x00FF0000) * sa) >> + 8) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) >> + 8) & + 0x0000FF00) | + ((((destpixel & 0x000000FF) * da + (srcpixel & 0x000000FF) * sa) >> + 8) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); +#endif } #endif } @@ -3154,63 +3092,86 @@ void CanvasView::Merge (BBitmap *a, Layer *b, BRect update, bool doselect, bool } break; case DM_MULTIPLY: - if (/* mode->selected() == M_SELECT && */ invertselect && selchanged && doselect && !inAddOn) - { -// printf ("Selection in layer %i\n", i); - for (ulong y = rt; y <= rb; y++) - { - for (ulong x = rl; x <= rr; x++) - { -#if defined (__POWERPC__) + if (/* mode->selected() == M_SELECT && */ invertselect && selchanged && doselect && + !inAddOn) { + // printf ("Selection in layer %i\n", i); + for (ulong y = rt; y <= rb; y++) { + for (ulong x = rl; x <= rr; x++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src); register uint32 destpixel = *(++dest); - register int sa = (srcpixel & 0xFF)*ga/255; + register int sa = (srcpixel & 0xFF) * ga / 255; register int da = destpixel & 0xFF; register unsigned int sel = *(++sel_data); - register int tsa = 65025 - sa*255; - register int tda = 65025 - da*255; - if (!sel) - { - *dest = (((tsa + sa*((srcpixel >> 24) ))*(tda + da*((destpixel >> 24) ))/16581375 << 24) & 0xFF000000) | - (((tsa + sa*((srcpixel >> 16) & 0xFF))*(tda + da*((destpixel >> 16) & 0xFF))/16581375 << 16) & 0x00FF0000) | - (((tsa + sa*((srcpixel >> 8) & 0xFF))*(tda + da*((destpixel >> 8) & 0xFF))/16581375 << 8) & 0x0000FF00) | - (max_c (sa, da) & 0xFF); - } - else - { -// *dest = (0xFFFFFF00 - (srcpixel & 0xFFFFFF00)) | sa; - register uint32 ipixel = pixelblend (srcpixel, (0xFFFFFF00 - (srcpixel & 0xFFFFFF00)) | sel); -// register uint32 ipixel = 0xFFFFFF00 - (srcpixel & 0xFFFFFF00); - *dest = ((((destpixel & 0xFF000000)/255*da + (ipixel & 0xFF000000)/255*sa)) & 0xFF000000) | - ((((destpixel & 0x00FF0000)*da + (ipixel & 0x00FF0000)*sa)/255) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (ipixel & 0x0000FF00)*sa)/255) & 0x0000FF00) | - sa; + register int tsa = 65025 - sa * 255; + register int tda = 65025 - da * 255; + if (!sel) { + *dest = (((tsa + sa * ((srcpixel >> 24))) * + (tda + da * ((destpixel >> 24))) / 16581375 + << 24) & + 0xFF000000) | + (((tsa + sa * ((srcpixel >> 16) & 0xFF)) * + (tda + da * ((destpixel >> 16) & 0xFF)) / 16581375 + << 16) & + 0x00FF0000) | + (((tsa + sa * ((srcpixel >> 8) & 0xFF)) * + (tda + da * ((destpixel >> 8) & 0xFF)) / 16581375 + << 8) & + 0x0000FF00) | + (max_c(sa, da) & 0xFF); + } else { + // *dest = (0xFFFFFF00 - (srcpixel & 0xFFFFFF00)) | sa; + register uint32 ipixel = + pixelblend(srcpixel, (0xFFFFFF00 - (srcpixel & 0xFFFFFF00)) | sel); + // register uint32 ipixel = 0xFFFFFF00 - (srcpixel & + // 0xFFFFFF00); + *dest = + ((((destpixel & 0xFF000000) / 255 * da + + (ipixel & 0xFF000000) / 255 * sa)) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) * da + (ipixel & 0x00FF0000) * sa) / 255) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (ipixel & 0x0000FF00) * sa) / 255) & + 0x0000FF00) | + sa; } #else register uint32 srcpixel = *(++src); register uint32 destpixel = *(++dest); - register int sa = (srcpixel >> 24)*ga/255; + register int sa = (srcpixel >> 24) * ga / 255; register int da = destpixel >> 24; register unsigned int sel = *(++sel_data); - register int tsa = 65025 - sa*255; - register int tda = 65025 - da*255; - if (!sel) - { - *dest = (((tsa + sa*((srcpixel >> 16) & 0xFF))*(tda + da*((destpixel >> 16) & 0xFF))/16581375 << 16) & 0x00FF0000) | - (((tsa + sa*((srcpixel >> 8) & 0xFF))*(tda + da*((destpixel >> 8) & 0xFF))/16581375 << 8) & 0x0000FF00) | - (((tsa + sa*((srcpixel ) & 0xFF))*(tda + da*((destpixel ) & 0xFF))/16581375 ) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); - //((max_c (sa, da) & 0xFF) << 24); - } - else - { -// *dest = (0x00FFFFFF - (srcpixel & 0x00FFFFFF)) | (sa << 24); -// register uint32 ipixel = 0x00FFFFFF - (srcpixel & 0x00FFFFFF); - register uint32 ipixel = pixelblend (srcpixel, (0x00FFFFFF - (srcpixel & 0x00FFFFFF)) | (sel << 24)); - *dest = ((((destpixel & 0x00FF0000)*da + (ipixel & 0x00FF0000)*sa)/255) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (ipixel & 0x0000FF00)*sa)/255) & 0x0000FF00) | - ((((destpixel & 0x000000FF)*da + (ipixel & 0x000000FF)*sa)/255) & 0x000000FF) | - (sa << 24); + register int tsa = 65025 - sa * 255; + register int tda = 65025 - da * 255; + if (!sel) { + *dest = (((tsa + sa * ((srcpixel >> 16) & 0xFF)) * + (tda + da * ((destpixel >> 16) & 0xFF)) / 16581375 + << 16) & + 0x00FF0000) | + (((tsa + sa * ((srcpixel >> 8) & 0xFF)) * + (tda + da * ((destpixel >> 8) & 0xFF)) / 16581375 + << 8) & + 0x0000FF00) | + (((tsa + sa * ((srcpixel) & 0xFF)) * + (tda + da * ((destpixel) & 0xFF)) / 16581375) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); + //((max_c (sa, da) & 0xFF) << 24); + } else { + // *dest = (0x00FFFFFF - (srcpixel & 0x00FFFFFF)) | (sa + //<< 24); register uint32 ipixel = 0x00FFFFFF - + //(srcpixel & 0x00FFFFFF); + register uint32 ipixel = pixelblend( + srcpixel, (0x00FFFFFF - (srcpixel & 0x00FFFFFF)) | (sel << 24) + ); + *dest = + ((((destpixel & 0x00FF0000) * da + (ipixel & 0x00FF0000) * sa) / 255) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (ipixel & 0x0000FF00) * sa) / 255) & + 0x0000FF00) | + ((((destpixel & 0x000000FF) * da + (ipixel & 0x000000FF) * sa) / 255) & + 0x000000FF) | + (sa << 24); } #endif } @@ -3218,64 +3179,87 @@ void CanvasView::Merge (BBitmap *a, Layer *b, BRect update, bool doselect, bool dest += ddiff; sel_data += seldiff; } - } - else - { - for (ulong y = rt; y <= rb; y++) - { - for (ulong x = rl; x <= rr; x++) - { -#if defined (__POWERPC__) + } else { + for (ulong y = rt; y <= rb; y++) { + for (ulong x = rl; x <= rr; x++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src); register uint32 destpixel = *(++dest); - register int sa = (srcpixel & 0xFF)*ga/255; + register int sa = (srcpixel & 0xFF) * ga / 255; register int da = destpixel & 0xFF; - register int tsa = 65025 - sa*255; - register int tda = 65025 - da*255; - if (sa == 0) // Fully transparent pixel - { - } - else if (sa == 255) // Fully opaque pixel + register int tsa = 65025 - sa * 255; + register int tda = 65025 - da * 255; + if (sa == 0) // Fully transparent pixel { - *dest = (((((srcpixel >> 24) )*(tda + da*((destpixel >> 24) ))/65025) << 24) & 0xFF000000) | - (((((srcpixel >> 16) & 0xFF)*(tda + da*((destpixel >> 16) & 0xFF))/65025) << 16) & 0x00FF0000) | - (((((srcpixel >> 8) & 0xFF)*(tda + da*((destpixel >> 8) & 0xFF))/65025) << 8) & 0x0000FF00) | - (clipchar (sa + int (destpixel & 0xFF))); - //(max_c (sa, da) & 0xFF); - } - else + } else if (sa == 255) // Fully opaque pixel { - *dest = (((tsa + sa*((srcpixel >> 24) ))*(tda + da*((destpixel >> 24) ))/16581375 << 24) & 0xFF000000) | - (((tsa + sa*((srcpixel >> 16) & 0xFF))*(tda + da*((destpixel >> 16) & 0xFF))/16581375 << 16) & 0x00FF0000) | - (((tsa + sa*((srcpixel >> 8) & 0xFF))*(tda + da*((destpixel >> 8) & 0xFF))/16581375 << 8) & 0x0000FF00) | - (clipchar (sa + int (destpixel & 0xFF))); - //(max_c (sa, da) & 0xFF); + *dest = (((((srcpixel >> 24)) * (tda + da * ((destpixel >> 24))) / 65025) + << 24) & + 0xFF000000) | + (((((srcpixel >> 16) & 0xFF) * + (tda + da * ((destpixel >> 16) & 0xFF)) / 65025) + << 16) & + 0x00FF0000) | + (((((srcpixel >> 8) & 0xFF) * + (tda + da * ((destpixel >> 8) & 0xFF)) / 65025) + << 8) & + 0x0000FF00) | + (clipchar(sa + int(destpixel & 0xFF))); + //(max_c (sa, da) & 0xFF); + } else { + *dest = (((tsa + sa * ((srcpixel >> 24))) * + (tda + da * ((destpixel >> 24))) / 16581375 + << 24) & + 0xFF000000) | + (((tsa + sa * ((srcpixel >> 16) & 0xFF)) * + (tda + da * ((destpixel >> 16) & 0xFF)) / 16581375 + << 16) & + 0x00FF0000) | + (((tsa + sa * ((srcpixel >> 8) & 0xFF)) * + (tda + da * ((destpixel >> 8) & 0xFF)) / 16581375 + << 8) & + 0x0000FF00) | + (clipchar(sa + int(destpixel & 0xFF))); + //(max_c (sa, da) & 0xFF); } #else register uint32 srcpixel = *(++src); register uint32 destpixel = *(++dest); - register int sa = (srcpixel >> 24)*ga/255; + register int sa = (srcpixel >> 24) * ga / 255; register int da = destpixel >> 24; - register int tsa = 65025 - sa*255; - register int tda = 65025 - da*255; - if (sa == 0) // Fully transparent pixel + register int tsa = 65025 - sa * 255; + register int tda = 65025 - da * 255; + if (sa == 0) // Fully transparent pixel { - } - else if (sa == 255) // Fully opaque pixel - { - *dest = (((((srcpixel >> 16) & 0xFF)*(tda + da*((destpixel >> 16) & 0xFF))/65025) << 16) & 0x00FF0000) | - (((((srcpixel >> 8) & 0xFF)*(tda + da*((destpixel >> 8) & 0xFF))/65025) << 8) & 0x0000FF00) | - (((((srcpixel ) & 0xFF)*(tda + da*((destpixel ) & 0xFF))/65025) ) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); - //((max_c (sa, da) & 0xFF) << 24); - } - else + } else if (sa == 255) // Fully opaque pixel { - *dest = (((tsa + sa*((srcpixel >> 16) & 0xFF))*(tda + da*((destpixel >> 16) & 0xFF))/16581375 << 16) & 0x00FF0000) | - (((tsa + sa*((srcpixel >> 8) & 0xFF))*(tda + da*((destpixel >> 8) & 0xFF))/16581375 << 8) & 0x0000FF00) | - (((tsa + sa*((srcpixel ) & 0xFF))*(tda + da*((destpixel ) & 0xFF))/16581375 ) & 0x000000FF) | - (clipchar (sa + int (destpixel >> 24)) << 24); - //((max_c (sa, da) & 0xFF) << 24); + *dest = + (((((srcpixel >> 16) & 0xFF) * (tda + da * ((destpixel >> 16) & 0xFF)) / + 65025) + << 16) & + 0x00FF0000) | + (((((srcpixel >> 8) & 0xFF) * (tda + da * ((destpixel >> 8) & 0xFF)) / + 65025) + << 8) & + 0x0000FF00) | + (((((srcpixel) & 0xFF) * (tda + da * ((destpixel) & 0xFF)) / 65025)) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); + //((max_c (sa, da) & 0xFF) << 24); + } else { + *dest = (((tsa + sa * ((srcpixel >> 16) & 0xFF)) * + (tda + da * ((destpixel >> 16) & 0xFF)) / 16581375 + << 16) & + 0x00FF0000) | + (((tsa + sa * ((srcpixel >> 8) & 0xFF)) * + (tda + da * ((destpixel >> 8) & 0xFF)) / 16581375 + << 8) & + 0x0000FF00) | + (((tsa + sa * ((srcpixel) & 0xFF)) * + (tda + da * ((destpixel) & 0xFF)) / 16581375) & + 0x000000FF) | + (clipchar(sa + int(destpixel >> 24)) << 24); + //((max_c (sa, da) & 0xFF) << 24); } #endif } @@ -3286,15 +3270,16 @@ void CanvasView::Merge (BBitmap *a, Layer *b, BRect update, bool doselect, bool break; case DM_DIFFERENCE: default: - fprintf (stderr, "Merge: Unknown Drawing Mode\n"); + fprintf(stderr, "Merge: Unknown Drawing Mode\n"); break; } -// end = clock(); -// printf ("Merge took %d ms\n", end - start); + // end = clock(); + // printf ("Merge took %d ms\n", end - start); } // Used when a color change is made in the palette - some add-ons may need to recalculate. -void CanvasView::InvalidateAddons () +void +CanvasView::InvalidateAddons() { if (filterOpen && filterOpen->DoesPreview()) filterOpen->ColorChanged(); @@ -3304,59 +3289,60 @@ void CanvasView::InvalidateAddons () generatorOpen->ColorChanged(); } -void CanvasView::Invalidate (const BRect rect) +void +CanvasView::Invalidate(const BRect rect) { clock_t start, end; start = clock(); // fprintf (stderr, "CanvasView::Invalidate (BRect) ... "); fflush (stderr); - extern PicMenuButton *mode; -// inherited::Invalidate (rect); -// rect.PrintToStream(); + extern PicMenuButton* mode; + // inherited::Invalidate (rect); + // rect.PrintToStream(); BPoint po = fPreviewRect.LeftTop(); fPreviewRect = PreviewRect(); - if (fPreviewRect != fPrevpreviewRect) - { + if (fPreviewRect != fPrevpreviewRect) { // Preview Rect size has changed in prefs... delete previewLayer; delete previewSelection; - previewLayer = new Layer (fPreviewRect, "Preview Layer"); - previewSelection = new Selection (fPreviewRect); + previewLayer = new Layer(fPreviewRect, "Preview Layer"); + previewSelection = new Selection(fPreviewRect); fPrevpreviewRect = fPreviewRect; } - fPreviewRect.OffsetTo (po); - - BRect update = makePositive (rect); - update.left = min_c (max_c (int (update.left), fCanvasFrame.left), fCanvasFrame.right); - update.top = min_c (max_c (int (update.top), fCanvasFrame.top), fCanvasFrame.bottom); - update.right = max_c (min_c (int (update.right), fCanvasFrame.right), fCanvasFrame.left); - update.bottom = max_c (min_c (int (update.bottom), fCanvasFrame.bottom), fCanvasFrame.top); -// update.PrintToStream(); - if (filterOpen && rect.Intersects (fPreviewRect) && filterOpen->DoesPreview()) - { - Layer *pLayer = previewLayer; - Selection *pSelection = previewSelection; + fPreviewRect.OffsetTo(po); + + BRect update = makePositive(rect); + update.left = min_c(max_c(int(update.left), fCanvasFrame.left), fCanvasFrame.right); + update.top = min_c(max_c(int(update.top), fCanvasFrame.top), fCanvasFrame.bottom); + update.right = max_c(min_c(int(update.right), fCanvasFrame.right), fCanvasFrame.left); + update.bottom = max_c(min_c(int(update.bottom), fCanvasFrame.bottom), fCanvasFrame.top); + // update.PrintToStream(); + if (filterOpen && rect.Intersects(fPreviewRect) && filterOpen->DoesPreview()) { + Layer* pLayer = previewLayer; + Selection* pSelection = previewSelection; if (mode->selected() == M_DRAW) - pLayer = new Layer (*previewLayer); + pLayer = new Layer(*previewLayer); else - pSelection = new Selection (*previewSelection); - BView *preView = new SView (pLayer->Bounds(), "preView", B_FOLLOW_ALL, uint32 (NULL)); + pSelection = new Selection(*previewSelection); + BView* preView = new SView(pLayer->Bounds(), "preView", B_FOLLOW_ALL, uint32(NULL)); pLayer->Lock(); - pLayer->AddChild (preView); - preView->DrawBitmap (currentLayer(), BPoint (-fPreviewRect.left, -fPreviewRect.top)); + pLayer->AddChild(preView); + preView->DrawBitmap(currentLayer(), BPoint(-fPreviewRect.left, -fPreviewRect.top)); preView->Sync(); - pLayer->RemoveChild (preView); + pLayer->RemoveChild(preView); pSelection->Lock(); - pSelection->AddChild (preView); - preView->DrawBitmap (selection, BPoint (-fPreviewRect.left, -fPreviewRect.top)); + pSelection->AddChild(preView); + preView->DrawBitmap(selection, BPoint(-fPreviewRect.left, -fPreviewRect.top)); preView->Sync(); - pSelection->RemoveChild (preView); - BRect pRect = sel ? (GetSmallestRect (selection) & fPreviewRect) : fPreviewRect; - pRect.OffsetBy (-fPreviewRect.left, -fPreviewRect.top); -// printf ("Calling from Invalidate. sel = %s\n", sel ? "true" : "false"); - filterOpen->Process (pLayer, sel ? pSelection : NULL, &previewLayer, &previewSelection, - mode->selected(), &pRect, false); - pRect.OffsetBy (fPreviewRect.left, fPreviewRect.top); + pSelection->RemoveChild(preView); + BRect pRect = sel ? (GetSmallestRect(selection) & fPreviewRect) : fPreviewRect; + pRect.OffsetBy(-fPreviewRect.left, -fPreviewRect.top); + // printf ("Calling from Invalidate. sel = %s\n", sel ? "true" : "false"); + filterOpen->Process( + pLayer, sel ? pSelection : NULL, &previewLayer, &previewSelection, mode->selected(), + &pRect, false + ); + pRect.OffsetBy(fPreviewRect.left, fPreviewRect.top); delete preView; if (mode->selected() == M_DRAW) delete pLayer; @@ -3365,21 +3351,20 @@ void CanvasView::Invalidate (const BRect rect) } extern bool inPaste; bool doselect = !inPaste; - ConstructCanvas (screenbitmap, update, doselect); - BRect drawRect = BRect (update.left*fScale, update.top*fScale, update.right*fScale, update.bottom*fScale); - Draw (drawRect); - if (myWindow->isLayerOpen()) - { + ConstructCanvas(screenbitmap, update, doselect); + BRect drawRect = BRect( + update.left * fScale, update.top * fScale, update.right * fScale, update.bottom * fScale + ); + Draw(drawRect); + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->layerView->getLayerItem(fCurrentLayer)->DrawThumbOnly(); myWindow->layerWindow->Unlock(); } - if (myWindow->TheMagWindow()) - { - if (!(myWindow->TheMagWindow()->IsActive())) - { + if (myWindow->TheMagWindow()) { + if (!(myWindow->TheMagWindow()->IsActive())) { // printf ("Sending 'draw' to MagWindow\n"); - myWindow->TheMagWindow()->PostMessage ('draw'); + myWindow->TheMagWindow()->PostMessage('draw'); } // (otherwise, the redraw probably comes from the mag window itself...) } @@ -3387,95 +3372,100 @@ void CanvasView::Invalidate (const BRect rect) end = clock(); extern int DebugLevel; if (DebugLevel > 7) - printf ("Invalidate (BRect) took %ld ms\n", end - start); + printf("Invalidate (BRect) took %ld ms\n", end - start); } -void CanvasView::Invalidate () +void +CanvasView::Invalidate() { BRect update; -// if (fBGView) -// { -// update = fBGView->Bounds(); -// update.left /= fScale; -// update.right /= fScale; -// update.top /= fScale; -// update.bottom /= fScale; -// } -// else - update = fCanvasFrame; - Invalidate (update); + // if (fBGView) + // { + // update = fBGView->Bounds(); + // update.left /= fScale; + // update.right /= fScale; + // update.top /= fScale; + // update.bottom /= fScale; + // } + // else + update = fCanvasFrame; + Invalidate(update); if (!text) MakeFocus(); } -void CanvasView::Draw (BRect updateRect) +void +CanvasView::Draw(BRect updateRect) { -// printf ("Draw: "); fflush (stdout); - if (IsPrinting()) - { - verbose (2, "IsPrinting()\n"); - BBitmap *b = canvas(); - DrawBitmap (b); + // printf ("Draw: "); fflush (stdout); + if (IsPrinting()) { + verbose(2, "IsPrinting()\n"); + BBitmap* b = canvas(); + DrawBitmap(b); Sync(); - verbose (2, "DrawBitmap(), Sync()\n"); + verbose(2, "DrawBitmap(), Sync()\n"); delete b; - } - else - { - updateRect.left = int (updateRect.left/fScale); - updateRect.top = int (updateRect.top/fScale); - updateRect.right = int (updateRect.right/fScale) + 1; - updateRect.bottom = int (updateRect.bottom/fScale) + 1; -// updateRect.PrintToStream(); -// BRegion clip = BRegion(); -// clip.Include (updateRect); + } else { + updateRect.left = int(updateRect.left / fScale); + updateRect.top = int(updateRect.top / fScale); + updateRect.right = int(updateRect.right / fScale) + 1; + updateRect.bottom = int(updateRect.bottom / fScale) + 1; + // updateRect.PrintToStream(); + // BRegion clip = BRegion(); + // clip.Include (updateRect); // This might break in R3... -// SetScale (fScale); -// ConstrainClippingRegion (&clip); -// printf ("Drawing... "); fflush (stdout); + // SetScale (fScale); + // ConstrainClippingRegion (&clip); + // printf ("Drawing... "); fflush (stdout); screenbitmap->Lock(); - SetDrawingMode (B_OP_COPY); + SetDrawingMode(B_OP_COPY); if (fScale == 1) - DrawBitmapAsync (screenbitmap, updateRect, updateRect); + DrawBitmapAsync(screenbitmap, updateRect, updateRect); else - DrawBitmapAsync (screenbitmap, B_ORIGIN); -// printf ("Syncing... "); fflush (stdout); - //DrawBitmapAsync (screenbitmap, B_ORIGIN); + DrawBitmapAsync(screenbitmap, B_ORIGIN); + // printf ("Syncing... "); fflush (stdout); + // DrawBitmapAsync (screenbitmap, B_ORIGIN); Sync(); screenbitmap->Unlock(); -// printf ("Unlocked... "); fflush (stdout); - if (filterOpen) - { - SetDrawingMode (B_OP_INVERT); - SetPenSize (0); - StrokeRect (fPreviewRect); + // printf ("Unlocked... "); fflush (stdout); + if (filterOpen) { + SetDrawingMode(B_OP_INVERT); + SetPenSize(0); + StrokeRect(fPreviewRect); } -// SetScale (1); + // SetScale (1); } -// printf ("Done\n"); + // printf ("Done\n"); } -void CanvasView::setScrollBars (BScrollBar *_h, BScrollBar *_v) +void +CanvasView::setScrollBars(BScrollBar* _h, BScrollBar* _v) { hSB = _h; vSB = _v; - hSB->SetProportion (min_c (1, Bounds().Width()/fScale/fCanvasFrame.Width())); - vSB->SetProportion (min_c (1, Bounds().Height()/fScale/fCanvasFrame.Height())); + hSB->SetProportion(min_c(1, Bounds().Width() / fScale / fCanvasFrame.Width())); + vSB->SetProportion(min_c(1, Bounds().Height() / fScale / fCanvasFrame.Height())); } -void CanvasView::Save (BEntry entry) +void +CanvasView::Save(BEntry entry) { extern int gGlobalAlpha; - if (!gGlobalAlpha) - { + if (!gGlobalAlpha) { #if SAVE_DISABLED int32 result; - BAlert *alert = new BAlert ("Disabled", - lstring (158, "Saving is disabled in this demo version of Becasso.\nOn http://www.sumware.demon.nl you can find information on obtaining the full version.\n\nThanks for your interest in Becasso!"), - lstring (131, "Cancel"), lstring (159, "Visit URL"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); + BAlert* alert = new BAlert( + "Disabled", + lstring( + 158, "Saving is disabled in this demo version of Becasso.\nOn " + "http://www.sumware.demon.nl you can find information on obtaining the full " + "version.\n\nThanks for your interest in Becasso!" + ), + lstring(131, "Cancel"), lstring(159, "Visit URL"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT + ); result = alert->Go(); if (result == 1) - system ("NetPositive http://www.sumware.demon.nl &"); + system("NetPositive http://www.sumware.demon.nl &"); return; #elif SAVE_NAG LockLooper(); @@ -3486,118 +3476,118 @@ void CanvasView::Save (BEntry entry) rect.right = rect.left + 340; rect.bottom = rect.top + 80; Window()->Hide(); - (new NagWindow (rect))->Go(); + (new NagWindow(rect))->Go(); Window()->Show(); Invalidate(); #endif } - extern const char *Version; - extern Becasso *mainapp; - FILE *fp; + extern const char* Version; + extern Becasso* mainapp; + FILE* fp; char line[81]; mainapp->setBusy(); - BFile file = BFile (&entry, B_CREATE_FILE | B_READ_WRITE | B_ERASE_FILE); + BFile file = BFile(&entry, B_CREATE_FILE | B_READ_WRITE | B_ERASE_FILE); BPath path; - entry.GetPath (&path); - BNode node = BNode (&entry); + entry.GetPath(&path); + BNode node = BNode(&entry); BNodeInfo nodeinfo; - nodeinfo.SetTo (&node); + nodeinfo.SetTo(&node); // node.WriteAttr ("BEOS:TYPE", B_STRING_TYPE, 0, "image/x-becasso\0", 16); - nodeinfo.SetType ("image/x-becasso"); - BMimeType mime ("image/x-becasso"); - if (!mime.IsInstalled()) - { + nodeinfo.SetType("image/x-becasso"); + BMimeType mime("image/x-becasso"); + if (!mime.IsInstalled()) { mime.Install(); } - fp = fopen (path.Path(), "w"); - fputs ("# Becasso image file\n", fp); + fp = fopen(path.Path(), "w"); + fputs("# Becasso image file\n", fp); if (!gGlobalAlpha) - fputs ("# (Unregistered Version)\n", fp); - sprintf (line, "%s %i %i 72 %i\n", Version, fNumLayers, fCurrentLayer, gGlobalAlpha ? 0: 1); - fputs (line, fp); - uchar *tmpzbuf = new uchar [uint32 (currentLayer()->BitsLength()*1.002) + 12L]; + fputs("# (Unregistered Version)\n", fp); + sprintf(line, "%s %i %i 72 %i\n", Version, fNumLayers, fCurrentLayer, gGlobalAlpha ? 0 : 1); + fputs(line, fp); + uchar* tmpzbuf = new uchar[uint32(currentLayer()->BitsLength() * 1.002) + 12L]; z_streamp zstream = new z_stream; zstream->zalloc = Z_NULL; zstream->zfree = Z_NULL; zstream->opaque = Z_NULL; - if (deflateInit (zstream, Z_DEFAULT_COMPRESSION) != Z_OK) - { - fprintf (stderr, "zlib error!\n"); - } - for (int i = 0; i < fNumLayers; i++) - { - sprintf (line, "%.0f %.0f %.0f %.0f %i %i %i %i %s\n", - layer[i]->Bounds().left, - layer[i]->Bounds().top, - layer[i]->Bounds().right, - layer[i]->Bounds().bottom, - layer[i]->getMode(), - layer[i]->IsHidden() ? 1 : 0, - layer[i]->getGlobalAlpha(), - layer[i]->getAlphaMap() ? 1 : 0, - layer[i]->getName()); - fputs (line, fp); + if (deflateInit(zstream, Z_DEFAULT_COMPRESSION) != Z_OK) { + fprintf(stderr, "zlib error!\n"); + } + BString lineString, leftBound, topBound, rightBound, bottomBound, mode, layerHidden, + globalAlpha, alphaMap, name; + for (int i = 0; i < fNumLayers; i++) { + fNumberFormat.SetPrecision(0); + fNumberFormat.Format(leftBound, layer[i]->Bounds().left); + fNumberFormat.Format(topBound, layer[i]->Bounds().top); + fNumberFormat.Format(rightBound, layer[i]->Bounds().right); + fNumberFormat.Format(bottomBound, layer[i]->Bounds().bottom); + fNumberFormat.Format(mode, layer[i]->getMode()); + fNumberFormat.Format(layerHidden, layer[i]->IsHidden() ? 1 : 0); + fNumberFormat.Format(globalAlpha, layer[i]->getGlobalAlpha()); + fNumberFormat.Format(alphaMap, layer[i]->getAlphaMap() ? 1 : 0); + lineString.SetToFormat( + "%s %s %s %s %s %s %s %s %s\n", leftBound.String(), topBound.String(), + rightBound.String(), bottomBound.String(), mode.String(), layerHidden.String(), + globalAlpha.String(), alphaMap.String(), layer[i]->getName() + ); + strcpy(line, lineString.String()); + fputs(line, fp); } if (!gGlobalAlpha) - InsertGlobalAlpha (layer, fNumLayers); - for (int i = 0; i < fNumLayers; i++) - { -// printf ("Compressing layer %i\n", i); - zstream->next_in = (uchar *) layer[i]->Bits(); + InsertGlobalAlpha(layer, fNumLayers); + for (int i = 0; i < fNumLayers; i++) { + // printf ("Compressing layer %i\n", i); + zstream->next_in = (uchar*)layer[i]->Bits(); zstream->avail_in = layer[i]->BitsLength(); zstream->next_out = tmpzbuf; zstream->avail_out = zstream->avail_in; - if (deflate (zstream, Z_FINISH) != Z_STREAM_END) - { - fprintf (stderr, "Argh, zlib couldn't compress the whole layer!\n"); + if (deflate(zstream, Z_FINISH) != Z_STREAM_END) { + fprintf(stderr, "Argh, zlib couldn't compress the whole layer!\n"); } - fwrite (tmpzbuf, zstream->next_out - tmpzbuf, 1, fp); - deflateReset (zstream); + fwrite(tmpzbuf, zstream->next_out - tmpzbuf, 1, fp); + deflateReset(zstream); } if (!gGlobalAlpha) InsertGlobalAlpha(layer, fNumLayers); - deflateEnd (zstream); + deflateEnd(zstream); delete zstream; - delete [] tmpzbuf; - fclose (fp); + delete[] tmpzbuf; + fclose(fp); mainapp->setReady(); } -void CanvasView::Pulse () +void +CanvasView::Pulse() { - extern BLocker *clipLock; + extern BLocker* clipLock; - if (clipLock->LockWithTimeout (500000) != B_OK) - { - printf ("Still switching windows..? %s\n", myWindow->Name()); + if (clipLock->LockWithTimeout(500000) != B_OK) { + printf("Still switching windows..? %s\n", myWindow->Name()); return; } extern bool inPaste, inDrag; - extern Tablet *wacom; - if (wacom && wacom->IsValid() && Window()->IsActive()) - { - //printf ("Updating tablet... "); fflush (stdout); + extern Tablet* wacom; + if (wacom && wacom->IsValid() && Window()->IsActive()) { + // printf ("Updating tablet... "); fflush (stdout); wacom->Update(); - //printf ("Done.\n"); - if (wacom->Proximity()) - { + // printf ("Done.\n"); + if (wacom->Proximity()) { // printf ("Proximity detected!\n"); -// thread_id position_thread; -// if (find_thread ("Position Tracker") == B_NAME_NOT_FOUND) -// { -// posision_thread = spawn_thread (position_tracker, "Position Tracker", B_DISPLAY_PRIORITY, this); -// } + // thread_id position_thread; + // if (find_thread ("Position Tracker") == B_NAME_NOT_FOUND) + // { + // posision_thread = spawn_thread (position_tracker, "Position Tracker", + // B_DISPLAY_PRIORITY, this); + // } extern bool BuiltInTablet; - if (BuiltInTablet) - { + if (BuiltInTablet) { Position position; - wacom->SetScale (fCanvasFrame.Width(), fCanvasFrame.Height()); + wacom->SetScale(fCanvasFrame.Width(), fCanvasFrame.Height()); fTreshold = wacom->Threshold(); - GetPosition (&position); + GetPosition(&position); if (position.fButtons) - MouseOrTablet (&position); + MouseOrTablet(&position); } // printf ("Back home.\n"); clipLock->Unlock(); @@ -3606,54 +3596,47 @@ void CanvasView::Pulse () } BPoint point; uint32 buttons; - GetMouse (&point, &buttons, true); + GetMouse(&point, &buttons, true); - extern Becasso *mainapp; - if (modifiers() & B_OPTION_KEY && mouse_on_canvas) // Color Picker / DragScroll + extern Becasso* mainapp; + if (modifiers() & B_OPTION_KEY && mouse_on_canvas) // Color Picker / DragScroll { - if (modifiers() & B_SHIFT_KEY) - { + if (modifiers() & B_SHIFT_KEY) { if (fPicking) - mainapp->setPicker (false); + mainapp->setPicker(false); - mainapp->setGrab (true, buttons); - if (!fDragScroll & buttons) - { + mainapp->setGrab(true, buttons); + if (!fDragScroll & buttons) { BPoint lt = Frame().LeftTop(); - BPoint p = ConvertToScreen (BPoint (point.x*fScale, point.y*fScale)); - fPoint = BPoint (p.x - lt.x, p.y - lt.y); -// printf ("New drag: "); -// fPoint.PrintToStream(); + BPoint p = ConvertToScreen(BPoint(point.x * fScale, point.y * fScale)); + fPoint = BPoint(p.x - lt.x, p.y - lt.y); + // printf ("New drag: "); + // fPoint.PrintToStream(); } fDragScroll = true; fPicking = false; - } - else - { + } else { if (fDragScroll) - mainapp->setGrab (false); + mainapp->setGrab(false); - mainapp->setPicker (true); + mainapp->setPicker(true); fPicking = true; fDragScroll = false; } - } - else if (fPicking || fDragScroll) - { - if (fPicking) - { - mainapp->setPicker (false); + } else if (fPicking || fDragScroll) { + if (fPicking) { + mainapp->setPicker(false); fPicking = false; } - if (fDragScroll) - { - mainapp->setGrab (false); + if (fDragScroll) { + mainapp->setGrab(false); fDragScroll = false; } if (mouse_on_canvas && !buttons) - mainapp->FixCursor(); // Otherwise: Few pixels off!! (BeOS bug w.r.t. hot spot of cursors ...) + mainapp->FixCursor( + ); // Otherwise: Few pixels off!! (BeOS bug w.r.t. hot spot of cursors ...) } extern PicMenuButton *tool, *mode; @@ -3661,57 +3644,52 @@ void CanvasView::Pulse () int32 currentTool = tool->selected(); static int32 lastTool = tool->selected(); static int32 lastMode = mode->selected(); - if (lastMode != currentMode) - { + if (lastMode != currentMode) { lastMode = currentMode; mainapp->setCross(); } - if (lastTool != currentTool) - { + if (lastTool != currentTool) { lastTool = currentTool; - myWindow->posview->SetPoint (-1, -1); + myWindow->posview->SetPoint(-1, -1); } - if (point != prev && Window()->IsActive() && !(modifiers() & B_OPTION_KEY)) - { - if (currentTool != prevTool) - { + if (point != prev && Window()->IsActive() && !(modifiers() & B_OPTION_KEY)) { + if (currentTool != prevTool) { entry = 0; prevTool = currentTool; } currentLayer()->Lock(); if (inPaste && !inDrag) - ePasteM (point); + ePasteM(point); else if (fTranslating && mouse_on_canvas) mainapp->setMover(); else if (fRotating && mouse_on_canvas) mainapp->setRotator(); - else - { - switch (currentTool) // Only some tools are interested in this. + else { + switch (currentTool) // Only some tools are interested in this. { case T_ERASER: - tEraserM (currentMode, point); + tEraserM(currentMode, point); break; case T_TEXT: - tTextM (currentMode, point); + tTextM(currentMode, point); break; case T_LINES: - tLinesM (currentMode, point); + tLinesM(currentMode, point); break; case T_POLYGON: - tPolygonM (currentMode, point); + tPolygonM(currentMode, point); break; case T_RECT: - tRectM (currentMode, point); + tRectM(currentMode, point); break; case T_RRECT: - tRoundRectM (currentMode, point); + tRoundRectM(currentMode, point); break; case T_CIRCLE: - tCircleM (currentMode, point); + tCircleM(currentMode, point); break; case T_ELLIPSE: - tEllipseM (currentMode, point); + tEllipseM(currentMode, point); break; default: break; @@ -3723,106 +3701,94 @@ void CanvasView::Pulse () clipLock->Unlock(); } - -BHandler *CanvasView::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +CanvasView::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { -// printf ("CanvasView::ResolveSpecifier!! message:\n"); -// message->PrintToStream(); -// printf ("\nspecifier:\n"); -// specifier->PrintToStream(); -// printf ("command: %ld, property: ""%s""\n", command, property); + // printf ("CanvasView::ResolveSpecifier!! message:\n"); + // message->PrintToStream(); + // printf ("\nspecifier:\n"); + // specifier->PrintToStream(); + // printf ("command: %ld, property: ""%s""\n", command, property); -// This is a bit nonstandard, but we want the same BHandler to first find out -// which Layer is specified, and then again be called for the actual property. + // This is a bit nonstandard, but we want the same BHandler to first find out + // which Layer is specified, and then again be called for the actual property. - if (!strcasecmp (property, "Layer")) - { + if (!strcasecmp(property, "Layer")) { fLayerSpecifier = -1; - const char *namedspecifier; + const char* namedspecifier; int32 indexspecifier; int32 i; - if (specifier->FindString ("name", &namedspecifier) == B_OK) - { + if (specifier->FindString("name", &namedspecifier) == B_OK) { // printf ("name = %s\n", namedspecifier); - for (i = 0; i < fNumLayers; i++) - { - Layer *l = layer[i]; - if (!strcmp (namedspecifier, l->getName())) - { + for (i = 0; i < fNumLayers; i++) { + Layer* l = layer[i]; + if (!strcmp(namedspecifier, l->getName())) { fLayerSpecifier = i; } } - } - else if (specifier->FindInt32 ("index", &indexspecifier) == B_OK) - { - if (indexspecifier >= 0 && indexspecifier < fNumLayers) - { + } else if (specifier->FindInt32("index", &indexspecifier) == B_OK) { + if (indexspecifier >= 0 && indexspecifier < fNumLayers) { fLayerSpecifier = indexspecifier; } } message->PopSpecifier(); - message->GetCurrentSpecifier (&index, specifier, &command, &property); + message->GetCurrentSpecifier(&index, specifier, &command, &property); fCurrentProperty = PROP_LAYER; if (message->what == B_DELETE_PROPERTY) return this; else - return ResolveSpecifier (message, index, specifier, command, property); + return ResolveSpecifier(message, index, specifier, command, property); } - if (!strcasecmp (property, "GlobalAlpha") && fLayerSpecifier != -1) - { + if (!strcasecmp(property, "GlobalAlpha") && fLayerSpecifier != -1) { fCurrentProperty = PROP_GLOBALALPHA; return this; } - if (!strcasecmp (property, "Contents") && fLayerSpecifier != -1) - { + if (!strcasecmp(property, "Contents") && fLayerSpecifier != -1) { fCurrentProperty = PROP_CONTENTS; return this; } - if (!strcasecmp (property, "Name") && fLayerSpecifier != -1) - { + if (!strcasecmp(property, "Name") && fLayerSpecifier != -1) { fCurrentProperty = PROP_NAME; return this; } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -void CanvasView::MessageReceived (BMessage *msg) +void +CanvasView::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_GLOBALALPHA: - { - if (fLayerSpecifier != -1) - { - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("result", layer[fLayerSpecifier]->getGlobalAlpha()); - msg->SendReply (&error); - } - else - fprintf (stderr, "Alpha of Layer %s = %d\n", layer[fLayerSpecifier]->getName(), layer[fLayerSpecifier]->getGlobalAlpha()); + switch (msg->what) { + case B_GET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_GLOBALALPHA: { + if (fLayerSpecifier != -1) { + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("result", layer[fLayerSpecifier]->getGlobalAlpha()); + msg->SendReply(&error); + } else + fprintf( + stderr, "Alpha of Layer %s = %d\n", layer[fLayerSpecifier]->getName(), + layer[fLayerSpecifier]->getGlobalAlpha() + ); } fLayerSpecifier = -1; break; } - case PROP_NAME: - { - if (fLayerSpecifier != -1) - { - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddString ("result", layer[fLayerSpecifier]->getName()); - msg->SendReply (&error); - } - else - fprintf (stderr, "Layer %ld = %s\n", fLayerSpecifier, layer[fLayerSpecifier]->getName()); + case PROP_NAME: { + if (fLayerSpecifier != -1) { + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddString("result", layer[fLayerSpecifier]->getName()); + msg->SendReply(&error); + } else + fprintf( + stderr, "Layer %ld = %s\n", fLayerSpecifier, + layer[fLayerSpecifier]->getName() + ); } fLayerSpecifier = -1; break; @@ -3833,98 +3799,77 @@ void CanvasView::MessageReceived (BMessage *msg) fCurrentProperty = 0; break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_NAME: - { - const char *name; - if (msg->FindString ("data", &name) == B_OK && fLayerSpecifier != -1) - { - + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_NAME: { + const char* name; + if (msg->FindString("data", &name) == B_OK && fLayerSpecifier != -1) { } fLayerSpecifier = -1; break; } - case PROP_GLOBALALPHA: - { + case PROP_GLOBALALPHA: { int32 value; - if (msg->FindInt32 ("data", &value) == B_OK && fLayerSpecifier != -1) - { - if (value >= 0 && value <= 255) - { - setGlobalAlpha (fLayerSpecifier, value); - if (myWindow->isLayerOpen()) - { + if (msg->FindInt32("data", &value) == B_OK && fLayerSpecifier != -1) { + if (value >= 0 && value <= 255) { + setGlobalAlpha(fLayerSpecifier, value); + if (myWindow->isLayerOpen()) { myWindow->layerWindow->Lock(); myWindow->layerWindow->doChanges(); myWindow->layerWindow->Unlock(); } - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } } } fLayerSpecifier = -1; break; } - case PROP_CONTENTS: - { + case PROP_CONTENTS: { clock_t start, end; start = clock(); - verbose (3, "Changing Layer Contents: Entered MessageReceived case\n"); + verbose(3, "Changing Layer Contents: Entered MessageReceived case\n"); entry_ref eref; - const char *fname; - if (msg->FindRef ("data", &eref) == B_OK && fLayerSpecifier != -1) - { - BBitmap *map; - BEntry entry = BEntry (&eref); + const char* fname; + if (msg->FindRef("data", &eref) == B_OK && fLayerSpecifier != -1) { + BBitmap* map; + BEntry entry = BEntry(&eref); BPath path; - entry.GetPath (&path); - if ((map = BTranslationUtils::GetBitmapFile (path.Path())), map) - { - setLayerContentsToBitmap (fLayerSpecifier, map); + entry.GetPath(&path); + if ((map = BTranslationUtils::GetBitmapFile(path.Path())), map) { + setLayerContentsToBitmap(fLayerSpecifier, map); delete map; - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); } - } - else - { - if (msg->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_NO_TRANSLATOR); - msg->SendReply (&error); + } else { + if (msg->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_NO_TRANSLATOR); + msg->SendReply(&error); } } - } - else if (msg->FindString ("data", &fname) == B_OK) - { + } else if (msg->FindString("data", &fname) == B_OK) { char errstring[256]; - sprintf (errstring, "File added by name (%s) not supported - use ref", fname); - if (msg->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - msg->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); + sprintf(errstring, "File added by name (%s) not supported - use ref", fname); + if (msg->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + msg->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); } fLayerSpecifier = -1; end = clock(); extern int DebugLevel; if (DebugLevel > 2) - printf ("MessageReceived case Took %ld ms\n", end - start); + printf("MessageReceived case Took %ld ms\n", end - start); break; } default: @@ -3933,99 +3878,93 @@ void CanvasView::MessageReceived (BMessage *msg) fCurrentProperty = 0; break; } - case B_DELETE_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_LAYER: - if (fLayerSpecifier != -1) - removeLayer (fLayerSpecifier); - fLayerSpecifier = -1; - if (myWindow->isLayerOpen()) - { - myWindow->layerWindow->Lock(); - myWindow->layerWindow->doChanges(); - myWindow->layerWindow->Unlock(); - } - if (msg->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - msg->SendReply (&error); - } - break; - default: - inherited::MessageReceived (msg); - break; + case B_DELETE_PROPERTY: { + switch (fCurrentProperty) { + case PROP_LAYER: + if (fLayerSpecifier != -1) + removeLayer(fLayerSpecifier); + fLayerSpecifier = -1; + if (myWindow->isLayerOpen()) { + myWindow->layerWindow->Lock(); + myWindow->layerWindow->doChanges(); + myWindow->layerWindow->Unlock(); + } + if (msg->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + msg->SendReply(&error); + } + break; + default: + inherited::MessageReceived(msg); + break; } fCurrentProperty = 0; break; } - case 'drag': - { + case 'drag': { extern bool inPaste, inDrag; - printf ("%s gets dragmessage, inPaste = %s\n", Window()->Title(), inPaste ? "true" : "false"); -// SetupUndo (M_DRAG); -// inPaste = false; + printf( + "%s gets dragmessage, inPaste = %s\n", Window()->Title(), inPaste ? "true" : "false" + ); + // SetupUndo (M_DRAG); + // inPaste = false; inDrag = true; -// firstDrag = true; -// changed = true; - //if (inPaste) - Paste (inPaste); + // firstDrag = true; + // changed = true; + // if (inPaste) + Paste(inPaste); inDrag = false; break; } - case 'lNch': - { + case 'lNch': { // Layer name has changed... int32 index; - msg->FindInt32 ("index", &index); + msg->FindInt32("index", &index); changed = true; break; } case B_SIMPLE_DATA: case B_MIME_DATA: - case B_ARCHIVED_OBJECT: - { - if (msg->HasBool ("not_top")) - { + case B_ARCHIVED_OBJECT: { + if (msg->HasBool("not_top")) { extern bool inPaste, inDrag; - printf ("inDrag = %s, inPaste = %s\n", (inDrag ? "true" : "false"), (inPaste ? "true" : "false")); + printf( + "inDrag = %s, inPaste = %s\n", (inDrag ? "true" : "false"), + (inPaste ? "true" : "false") + ); inDrag = true; - Paste (inPaste); + Paste(inPaste); inDrag = false; - } - else - SimpleData (msg); + } else + SimpleData(msg); break; } - case B_COPY_TARGET: - { - CopyTarget (msg); + case B_COPY_TARGET: { + CopyTarget(msg); break; } - case B_TRASH_TARGET: - { - TrashTarget (msg); + case B_TRASH_TARGET: { + TrashTarget(msg); break; } - default: - { + default: { extern int DebugLevel; if (DebugLevel > 2) msg->PrintToStream(); - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } } -void CanvasView::SimpleData (BMessage *message) +void +CanvasView::SimpleData(BMessage* message) { - verbose (1, "SimpleData dropped\n"); - BBitmap *bitmap_ptr = NULL; - BBitmap *drop_map = NULL; + verbose(1, "SimpleData dropped\n"); + BBitmap* bitmap_ptr = NULL; + BBitmap* drop_map = NULL; BRect fr; BPoint pt = B_ORIGIN; int w, h; @@ -4033,276 +3972,255 @@ void CanvasView::SimpleData (BMessage *message) bool fromBecasso = false; extern int DebugLevel; - if (message->FindBool ("becasso", &fromBecasso) != B_OK && DebugLevel >= 2) - { - printf ("Not Becasso-originated.\n"); - message->PrintToStream (); + if (message->FindBool("becasso", &fromBecasso) != B_OK && DebugLevel >= 2) { + printf("Not Becasso-originated.\n"); + message->PrintToStream(); } - const void *dataPtr; + const void* dataPtr; ssize_t numBytes; - if (message->FindData ("image/x-becasso", B_RAW_TYPE, &dataPtr, &numBytes) == B_OK - || message->FindData ("image/x-becasso", B_MIME_TYPE, &dataPtr, &numBytes) == B_OK - || message->FindData ("image/png", B_RAW_TYPE, &dataPtr, &numBytes) == B_OK - || message->FindData ("image/png", B_MIME_TYPE, &dataPtr, &numBytes) == B_OK - || message->FindData ("image/x-png", B_RAW_TYPE, &dataPtr, &numBytes) == B_OK - || message->FindData ("image/x-png", B_MIME_TYPE, &dataPtr, &numBytes) == B_OK - || message->FindData ("image/targa", B_RAW_TYPE, &dataPtr, &numBytes) == B_OK - || message->FindData ("image/targa", B_MIME_TYPE, &dataPtr, &numBytes) == B_OK - || message->FindData ("image/x-targa", B_RAW_TYPE, &dataPtr, &numBytes) == B_OK - || message->FindData ("image/x-targa", B_MIME_TYPE, &dataPtr, &numBytes) == B_OK) - { + if (message->FindData("image/x-becasso", B_RAW_TYPE, &dataPtr, &numBytes) == B_OK || + message->FindData("image/x-becasso", B_MIME_TYPE, &dataPtr, &numBytes) == B_OK || + message->FindData("image/png", B_RAW_TYPE, &dataPtr, &numBytes) == B_OK || + message->FindData("image/png", B_MIME_TYPE, &dataPtr, &numBytes) == B_OK || + message->FindData("image/x-png", B_RAW_TYPE, &dataPtr, &numBytes) == B_OK || + message->FindData("image/x-png", B_MIME_TYPE, &dataPtr, &numBytes) == B_OK || + message->FindData("image/targa", B_RAW_TYPE, &dataPtr, &numBytes) == B_OK || + message->FindData("image/targa", B_MIME_TYPE, &dataPtr, &numBytes) == B_OK || + message->FindData("image/x-targa", B_RAW_TYPE, &dataPtr, &numBytes) == B_OK || + message->FindData("image/x-targa", B_MIME_TYPE, &dataPtr, &numBytes) == B_OK) { // Looks like we got a data message! - verbose (2, "Data message\n"); -// message->PrintToStream(); + verbose(2, "Data message\n"); + // message->PrintToStream(); BBitmapStream bstr; - BMemoryIO *mstr = new BMemoryIO (dataPtr, numBytes); - if (BTranslatorRoster::Default()->Translate (mstr, NULL, NULL, &bstr, B_TRANSLATOR_BITMAP) != B_OK) - { - fprintf (stderr, "CanvasView: Data Message translation error...\n"); + BMemoryIO* mstr = new BMemoryIO(dataPtr, numBytes); + if (BTranslatorRoster::Default()->Translate(mstr, NULL, NULL, &bstr, B_TRANSLATOR_BITMAP) != + B_OK) { + fprintf(stderr, "CanvasView: Data Message translation error...\n"); delete mstr; return; } - bstr.DetachBitmap (&drop_map); + bstr.DetachBitmap(&drop_map); delete mstr; - BMessage *prev = (BMessage *) message->Previous()->Previous(); + BMessage* prev = (BMessage*)message->Previous()->Previous(); // (the cast is to get rid of a const compiler warning). - if (!prev) - { - SetupUndo (M_DRAW); + if (!prev) { + SetupUndo(M_DRAW); currentLayer()->Lock(); - drawView->SetDrawingMode (B_OP_ALPHA); - drawView->DrawBitmap (drop_map, fr.LeftTop()); + drawView->SetDrawingMode(B_OP_ALPHA); + drawView->DrawBitmap(drop_map, fr.LeftTop()); currentLayer()->Unlock(); Invalidate(); return; } -// printf ("\nPrevious:\n"); -// prev->PrintToStream(); + // printf ("\nPrevious:\n"); + // prev->PrintToStream(); // DON'T !! delete message; message = prev; } - if (message->FindRect ("be:_frame", &fr) != B_OK) - { - fr.Set (0, 0, 0, 0); + if (message->FindRect("be:_frame", &fr) != B_OK) { + fr.Set(0, 0, 0, 0); } - if (message->WasDropped()) - { - verbose (2, "Dropped...\n"); + if (message->WasDropped()) { + verbose(2, "Dropped...\n"); BPoint offset = B_ORIGIN; - if (fromBecasso && !message->FindPoint ("_drop_offset_", &offset)) - { -// printf ("Offset by (%f, %f)\n", offset.x, offset.y); + if (fromBecasso && !message->FindPoint("_drop_offset_", &offset)) { + // printf ("Offset by (%f, %f)\n", offset.x, offset.y); } - //target = message->DropPoint (&pt); <= doesn't seem to work OK in R4 + // target = message->DropPoint (&pt); <= doesn't seem to work OK in R4 target = message->DropPoint(); - ConvertFromScreen (&target); + ConvertFromScreen(&target); target.x -= offset.x; target.y -= offset.y; - if (!message->FindPoint ("be:_source_point", &pt)) - { + if (!message->FindPoint("be:_source_point", &pt)) { pt.x -= fr.left; pt.y -= fr.top; } - } - else if (!message->FindPoint ("be:destination_point", &target)) - { + } else if (!message->FindPoint("be:destination_point", &target)) { /* target is OK */ - } - else - { + } else { target = B_ORIGIN; } target.x -= pt.x; target.y -= pt.y; - if (target.x < 0) - { + if (target.x < 0) { fr.left -= target.x; target.x = 0; } - if (target.y < 0) - { + if (target.y < 0) { fr.top -= target.y; target.y = 0; } - //fr.PrintToStream(); + // fr.PrintToStream(); if ((fr.left > fr.right) || (fr.top > fr.bottom)) goto outside; - if (!drop_map && !message->IsSourceRemote() && !message->FindPointer ("be:_bitmap_ptr", (void**) &bitmap_ptr)) - { -// printf ("SourceRemote && FindPointer\n"); + if (!drop_map && !message->IsSourceRemote() && + !message->FindPointer("be:_bitmap_ptr", (void**)&bitmap_ptr)) { + // printf ("SourceRemote && FindPointer\n"); /* this is one big race condition -- what if the source window went away? */ /* make sure we have bitmap in our color space */ - if (message->FindRect ("be:_frame", &fr)) - { + if (message->FindRect("be:_frame", &fr)) { fr = bitmap_ptr->Bounds(); } BRect temp(fr); - fr.OffsetTo (B_ORIGIN); - drop_map = new BBitmap (fr, B_RGBA32, true); - BView *v = new BView (fr, "_", B_FOLLOW_NONE, B_WILL_DRAW); + fr.OffsetTo(B_ORIGIN); + drop_map = new BBitmap(fr, B_RGBA32, true); + BView* v = new BView(fr, "_", B_FOLLOW_NONE, B_WILL_DRAW); drop_map->Lock(); - drop_map->AddChild (v); - v->DrawBitmap (bitmap_ptr, temp, fr); + drop_map->AddChild(v); + v->DrawBitmap(bitmap_ptr, temp, fr); v->Sync(); - drop_map->RemoveChild (v); + drop_map->RemoveChild(v); drop_map->Unlock(); -// printf ("Filled in drop_map from local ptr\n"); + // printf ("Filled in drop_map from local ptr\n"); delete v; - } - else if (!drop_map) - { - if (message->what == B_ARCHIVED_OBJECT) - { - verbose (2, "B_ARCHIVED_OBJECT\n"); - if (!validate_instantiation (message, "BBitmap")) + } else if (!drop_map) { + if (message->what == B_ARCHIVED_OBJECT) { + verbose(2, "B_ARCHIVED_OBJECT\n"); + if (!validate_instantiation(message, "BBitmap")) goto err; - drop_map = dynamic_cast (instantiate_object (message)); + drop_map = dynamic_cast(instantiate_object(message)); if (!drop_map) goto err; - } - else if (message->HasRef ("refs")) - { - verbose (2, "HasRef\n"); + } else if (message->HasRef("refs")) { + verbose(2, "HasRef\n"); BBitmapStream output; entry_ref ref; - if (message->FindRef ("refs", &ref)) + if (message->FindRef("refs", &ref)) goto err; BFile input; - if (input.SetTo (&ref, O_RDONLY)) + if (input.SetTo(&ref, O_RDONLY)) goto err; - if (BTranslatorRoster::Default()->Translate (&input, NULL, NULL, &output, B_TRANSLATOR_BITMAP)) + if (BTranslatorRoster::Default()->Translate( + &input, NULL, NULL, &output, B_TRANSLATOR_BITMAP + )) goto err; - if (output.DetachBitmap (&drop_map)) + if (output.DetachBitmap(&drop_map)) goto err; myWindow->Lock(); - myWindow->setPaste (true); + myWindow->setPaste(true); myWindow->Unlock(); - extern BBitmap *clip; - if (clip) - { + extern BBitmap* clip; + if (clip) { clip->Lock(); delete clip; } clip = drop_map; - SetupUndo (M_DRAW); - Paste (true); + SetupUndo(M_DRAW); + Paste(true); return; - } - else - { + } else { // Extended DnD protocol. The message probably contains "promises" only. - verbose (1, "Extended DnD\n"); + verbose(1, "Extended DnD\n"); extern int DebugLevel; if (DebugLevel > 2) message->PrintToStream(); - BMessage reply (B_COPY_TARGET); + BMessage reply(B_COPY_TARGET); int32 numTypes; type_code typeFound; - message->GetInfo ("be:types", &typeFound, &numTypes); - const char **types = new const char *[numTypes]; + message->GetInfo("be:types", &typeFound, &numTypes); + const char** types = new const char*[numTypes]; int32 i; for (i = 0; i < numTypes; i++) - message->FindString ("be:types", i, &(types[i])); + message->FindString("be:types", i, &(types[i])); // Look for types we like, in the order Becasso, PNG, Targa. int32 iBecasso = -1; int32 iPNG = -1; int32 iTarga = -1; - for (i = 0; i < numTypes; i++) - { - if (!strcasecmp (types[i], "image/x-becasso")) + for (i = 0; i < numTypes; i++) { + if (!strcasecmp(types[i], "image/x-becasso")) iBecasso = i; - if (!strcasecmp (types[i], "image/x-png") - || !strcasecmp (types[i], "image/png")) - iPNG = i; - if (!strcasecmp (types[i], "image/targa") - || !strcasecmp (types[i], "image/x-targa")) - iTarga = i; + if (!strcasecmp(types[i], "image/x-png") || !strcasecmp(types[i], "image/png")) + iPNG = i; + if (!strcasecmp(types[i], "image/targa") || !strcasecmp(types[i], "image/x-targa")) + iTarga = i; } if (iBecasso != -1) - reply.AddString ("be:types", types[iBecasso]); + reply.AddString("be:types", types[iBecasso]); else if (iPNG != -1) - reply.AddString ("be:types", types[iPNG]); + reply.AddString("be:types", types[iPNG]); else if (iTarga != -1) - reply.AddString ("be:types", types[iTarga]); - else - { - fprintf (stderr, "Neither image/x-becasso, image/(x-)png nor image/(x-)targa supported!\n"); - delete [] types; + reply.AddString("be:types", types[iTarga]); + else { + fprintf( + stderr, + "Neither image/x-becasso, image/(x-)png nor image/(x-)targa supported!\n" + ); + delete[] types; return; } - if (DebugLevel >= 2) - { - printf ("Sending reply:\n"); + if (DebugLevel >= 2) { + printf("Sending reply:\n"); reply.PrintToStream(); } - message->SendReply (&reply, this); - delete [] types; + message->SendReply(&reply, this); + delete[] types; return; } - if (message->FindRect ("be:_frame", &fr)) - { + if (message->FindRect("be:_frame", &fr)) { fr = drop_map->Bounds(); } } - w = (int) fr.Width(); - if (w + target.x > fCanvasFrame.right) - { + w = (int)fr.Width(); + if (w + target.x > fCanvasFrame.right) { w = (int)(fCanvasFrame.right - target.x); } - h = (int) fr.Height(); - if (h + target.y > fCanvasFrame.bottom) - { + h = (int)fr.Height(); + if (h + target.y > fCanvasFrame.bottom) { h = (int)(fCanvasFrame.bottom - target.y); } if (drop_map) // We finally have our dropped bitmap { - //printf ("We're here!\n"); - fr.Set (target.x, target.y, target.x + w, target.y + h); -// SetSelection (fr, drop_map); -// delete fDithered; -// fDithered = NULL; - SetupUndo (M_DRAW); + // printf ("We're here!\n"); + fr.Set(target.x, target.y, target.x + w, target.y + h); + // SetSelection (fr, drop_map); + // delete fDithered; + // fDithered = NULL; + SetupUndo(M_DRAW); currentLayer()->Lock(); -// drawView->SetDrawingMode (B_OP_ALPHA); -// drawView->DrawBitmap (drop_map, fr.LeftTop()); - AddWithAlpha (drop_map, currentLayer(), int (target.x), int (target.y)); + // drawView->SetDrawingMode (B_OP_ALPHA); + // drawView->DrawBitmap (drop_map, fr.LeftTop()); + AddWithAlpha(drop_map, currentLayer(), int(target.x), int(target.y)); currentLayer()->Unlock(); - Invalidate (/*fr*/); + Invalidate(/*fr*/); } -outside: - ; +outside:; err: delete drop_map; } -void CanvasView::CopyTarget (BMessage *message) +void +CanvasView::CopyTarget(BMessage* message) { extern int DebugLevel; - if (DebugLevel) - { - printf ("B_COPY_TARGET\n"); + if (DebugLevel) { + printf("B_COPY_TARGET\n"); message->PrintToStream(); } extern int gGlobalAlpha; - if (!gGlobalAlpha) - { + if (!gGlobalAlpha) { #if SAVE_DISABLED int32 result; - BAlert *alert = new BAlert ("Disabled", - lstring (158, "Saving is disabled in this demo version of Becasso.\nOn http://www.sumware.demon.nl you can find information on obtaining the full version.\n\nThanks for your interest in Becasso!"), - lstring (131, "Cancel"), lstring (159, "Visit URL"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); + BAlert* alert = new BAlert( + "Disabled", + lstring( + 158, "Saving is disabled in this demo version of Becasso.\nOn " + "http://www.sumware.demon.nl you can find information on obtaining the full " + "version.\n\nThanks for your interest in Becasso!" + ), + lstring(131, "Cancel"), lstring(159, "Visit URL"), NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT + ); result = alert->Go(); if (result == 1) - system ("NetPositive http://www.sumware.demon.nl &"); + system("NetPositive http://www.sumware.demon.nl &"); return; #else LockLooper(); @@ -4313,147 +4231,136 @@ void CanvasView::CopyTarget (BMessage *message) rect.right = rect.left + 340; rect.bottom = rect.top + 80; Window()->Hide(); - (new NagWindow (rect))->Go(); + (new NagWindow(rect))->Go(); Window()->Show(); Invalidate(); #endif } - extern BBitmap *clip; - const char *type = NULL; - if (!message->FindString ("be:types", &type) && clip) - { - BBitmapStream strm (clip); - if (!strcasecmp (type, B_FILE_MIME_TYPE)) - { - const char *name; + extern BBitmap* clip; + const char* type = NULL; + if (!message->FindString("be:types", &type) && clip) { + BBitmapStream strm(clip); + if (!strcasecmp(type, B_FILE_MIME_TYPE)) { + const char* name; entry_ref dir; - if (!message->FindString ("be:filetypes", &type) && - !message->FindString ("name", &name) && - !message->FindRef ("directory", &dir)) - { + if (!message->FindString("be:filetypes", &type) && + !message->FindString("name", &name) && !message->FindRef("directory", &dir)) { // write file - uint32 type_code = TypeCodeForMIME (type); - BDirectory d (&dir); - BFile f (&d, name, O_RDWR | O_TRUNC); - BTranslatorRoster::Default()->Translate (&strm, NULL, NULL, &f, type_code); - BNodeInfo ni (&f); - ni.SetType (type); + uint32 type_code = TypeCodeForMIME(type); + BDirectory d(&dir); + BFile f(&d, name, O_RDWR | O_TRUNC); + BTranslatorRoster::Default()->Translate(&strm, NULL, NULL, &f, type_code); + BNodeInfo ni(&f); + ni.SetType(type); } - } - else if (!message->FindString ("be:types", &type)) - { + } else if (!message->FindString("be:types", &type)) { // put in message - uint32 type_code = TypeCodeForMIME (type); - BMessage msg (B_MIME_DATA); + uint32 type_code = TypeCodeForMIME(type); + BMessage msg(B_MIME_DATA); BMallocIO f; - BTranslatorRoster::Default()->Translate (&strm, NULL, NULL, &f, type_code); - msg.AddData (type, B_MIME_TYPE, f.Buffer(), f.BufferLength()); - message->SendReply (&msg); + BTranslatorRoster::Default()->Translate(&strm, NULL, NULL, &f, type_code); + msg.AddData(type, B_MIME_TYPE, f.Buffer(), f.BufferLength()); + message->SendReply(&msg); + } else { + BMessage msg(B_MESSAGE_NOT_UNDERSTOOD); + message->SendReply(&msg); } - else - { - BMessage msg (B_MESSAGE_NOT_UNDERSTOOD); - message->SendReply (&msg); - } - strm.DetachBitmap (&clip); + strm.DetachBitmap(&clip); } } -void CanvasView::TrashTarget (BMessage *message) +void +CanvasView::TrashTarget(BMessage* message) { - printf ("B_TRASH_TARGET\n"); + printf("B_TRASH_TARGET\n"); message->PrintToStream(); } -void CanvasView::MouseDown (BPoint point) +void +CanvasView::MouseDown(BPoint point) { -// printf ("MouseDown\n"); + // printf ("MouseDown\n"); if (!fTranslating && !fRotating) - SetMouseEventMask (B_POINTER_EVENTS, B_SUSPEND_VIEW_FOCUS | B_NO_POINTER_HISTORY); - // Hmmm, ik krijg toch een pointer history zo! + SetMouseEventMask(B_POINTER_EVENTS, B_SUSPEND_VIEW_FOCUS | B_NO_POINTER_HISTORY); + // Hmmm, ik krijg toch een pointer history zo! - uint32 buttons = Window()->CurrentMessage()->FindInt32 ("buttons"); -// printf ("buttons = %lx\n", buttons); + uint32 buttons = Window()->CurrentMessage()->FindInt32("buttons"); + // printf ("buttons = %lx\n", buttons); Position position; - position.fPoint = point; - position.fButtons = buttons; - position.fTilt = B_ORIGIN; + position.fPoint = point; + position.fButtons = buttons; + position.fTilt = B_ORIGIN; position.fProximity = false; - position.fPressure = 255; - MouseOrTablet (&position); + position.fPressure = 255; + MouseOrTablet(&position); // Remove all waiting MouseMoved messages - if (myWindow->LockWithTimeout (50000) == B_OK) - { - BMessageQueue *queue = myWindow->MessageQueue(); - BMessage *msg = NULL; + if (myWindow->LockWithTimeout(50000) == B_OK) { + BMessageQueue* queue = myWindow->MessageQueue(); + BMessage* msg = NULL; int count = 0; do { - msg = queue->FindMessage (B_MOUSE_MOVED, 0); - if (msg) - { + msg = queue->FindMessage(B_MOUSE_MOVED, 0); + if (msg) { count++; - queue->RemoveMessage (msg); + queue->RemoveMessage(msg); } } while (msg); -// printf ("Removed %d MouseMoved messages\n", count); + // printf ("Removed %d MouseMoved messages\n", count); myWindow->Unlock(); - } - else - printf ("Hah! Couldn't get lock!\n"); + } else + printf("Hah! Couldn't get lock!\n"); } -void CanvasView::MouseUp (BPoint /*point*/) +void +CanvasView::MouseUp(BPoint /*point*/) { -// printf ("MouseUp\n"); + // printf ("MouseUp\n"); fMouseDown = false; if (!entry) - myWindow->posview->SetPoint (-1, -1); + myWindow->posview->SetPoint(-1, -1); - extern PicMenuButton *tool; - extern Becasso *mainapp; + extern PicMenuButton* tool; + extern Becasso* mainapp; int32 currentTool = tool->selected(); - if (currentTool == T_CLONE) - { + if (currentTool == T_CLONE) { mainapp->setCross(); - BPoint sp = ConvertToScreen (BPoint (fCC.pos.x*fScale, fCC.pos.y*fScale)); - set_mouse_position (int (sp.x), int (sp.y)); + BPoint sp = ConvertToScreen(BPoint(fCC.pos.x * fScale, fCC.pos.y * fScale)); + set_mouse_position(int(sp.x), int(sp.y)); Invalidate(); } } -void CanvasView::MouseMoved (BPoint point, uint32 transit, const BMessage *msg) +void +CanvasView::MouseMoved(BPoint point, uint32 transit, const BMessage* msg) { // clock_t start, end; // start = clock(); point.x /= fScale; point.y /= fScale; - extern Becasso *mainapp; -// extern bool inDrag, inPaste; + extern Becasso* mainapp; + // extern bool inDrag, inPaste; int32 buttons; - Window()->CurrentMessage()->FindInt32 ("buttons", &buttons); - if (transit == B_EXITED_VIEW) - { + Window()->CurrentMessage()->FindInt32("buttons", &buttons); + if (transit == B_EXITED_VIEW) { mainapp->setHand(); mouse_on_canvas = false; Invalidate(); - } - else if (transit == B_ENTERED_VIEW && Window()->IsActive() && !msg) - { + } else if (transit == B_ENTERED_VIEW && Window()->IsActive() && !msg) { // Fix for the fact that we don't get MouseUp()s outside our view -// BPoint point; -// uint32 buttons; -// GetMouse (&point, &buttons, false); + // BPoint point; + // uint32 buttons; + // GetMouse (&point, &buttons, false); -// fMouseDown = false; + // fMouseDown = false; -// printf ("%sinDrag, %sinPaste\n", inDrag ? "" : "!", inPaste ? "" : "!"); - extern PicMenuButton *tool; + // printf ("%sinDrag, %sinPaste\n", inDrag ? "" : "!", inPaste ? "" : "!"); + extern PicMenuButton* tool; int32 currentTool = tool->selected(); - if ((transformerOpen && !(transformerOpen->DoesPreview() & PREVIEW_MOUSE)) - || (generatorOpen && !(generatorOpen->DoesPreview() & PREVIEW_MOUSE))) + if ((transformerOpen && !(transformerOpen->DoesPreview() & PREVIEW_MOUSE)) || + (generatorOpen && !(generatorOpen->DoesPreview() & PREVIEW_MOUSE))) mainapp->setCCross(); else if (fTranslating) mainapp->setMover(); @@ -4462,90 +4369,88 @@ void CanvasView::MouseMoved (BPoint point, uint32 transit, const BMessage *msg) else mainapp->setCross(); mouse_on_canvas = true; - if (currentTool != prevTool) - { + if (currentTool != prevTool) { entry = 0; prevTool = currentTool; } - if (buttons && !fMouseDown) - { -// printf ("Drawing started outside...\n"); -// MouseDown (point); + if (buttons && !fMouseDown) { + // printf ("Drawing started outside...\n"); + // MouseDown (point); } Invalidate(); - } - else - { - if (buttons && !fMouseDown) // MouseDown missed! (This happens a LOT!) + } else { + if (buttons && !fMouseDown) // MouseDown missed! (This happens a LOT!) { return; } -// MouseDown (point); + // MouseDown (point); fMouseDown = buttons; - if (fMouseDown && Window()->IsActive() - && !msg // Don't draw inside a drag! - // The following disables spraycan and brush to be used when - // a previewing add-on is open (to fix a bug - this is _not_ ideal!!) - && (!( //(filterOpen && filterOpen->DoesPreview()) - (generatorOpen)// && (generatorOpen->DoesPreview() & PREVIEW_MOUSE)) - || (transformerOpen))))// && (transformerOpen->DoesPreview() & PREVIEW_MOUSE))))) + if (fMouseDown && Window()->IsActive() && + !msg // Don't draw inside a drag! + // The following disables spraycan and brush to be used when + // a previewing add-on is open (to fix a bug - this is _not_ ideal!!) + && (!( //(filterOpen && filterOpen->DoesPreview()) + (generatorOpen) // && (generatorOpen->DoesPreview() & PREVIEW_MOUSE)) + || (transformerOpen) + ))) // && (transformerOpen->DoesPreview() & PREVIEW_MOUSE))))) { currentLayer()->Lock(); selection->Lock(); - if (modifiers() & B_OPTION_KEY) // Color Picker / DragScroll + if (modifiers() & B_OPTION_KEY) // Color Picker / DragScroll { - if (modifiers() & B_SHIFT_KEY) // DragScroll + if (modifiers() & B_SHIFT_KEY) // DragScroll { - mainapp->setGrab (true, true); + mainapp->setGrab(true, true); fDragScroll = true; fPicking = false; - BPoint p = ConvertToScreen (BPoint (point.x*fScale, point.y*fScale)); + BPoint p = ConvertToScreen(BPoint(point.x * fScale, point.y * fScale)); // printf ("new pos = %f, %f\n", fPoint.x - p.x, fPoint.y - p.y); - fBGView->ScrollTo (BPoint (fPoint.x - p.x, fPoint.y - p.y)); - } - else // Color Picker + fBGView->ScrollTo(BPoint(fPoint.x - p.x, fPoint.y - p.y)); + } else // Color Picker { extern ColorMenuButton *hicolor, *locolor; if (buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) - hicolor->set (getColor (point)); + hicolor->set(getColor(point)); if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - locolor->set (getColor (point)); + locolor->set(getColor(point)); fPicking = true; fDragScroll = false; } - } - else if (!fPicking) - { - extern PicMenuButton *tool; + } else if (!fPicking) { + extern PicMenuButton* tool; int32 currentTool = tool->selected(); - if (currentTool == T_BRUSH) - { - extern PicMenuButton *mode; + if (currentTool == T_BRUSH) { + extern PicMenuButton* mode; Position position; - GetPosition (&position); + GetPosition(&position); if (DebugLevel > 6) - printf ("P = %d\n", position.fPressure); - tBrushM (mode->selected(), point, position.fButtons, position.fPressure, position.fTilt); + printf("P = %d\n", position.fPressure); + tBrushM( + mode->selected(), point, position.fButtons, position.fPressure, + position.fTilt + ); fMouseDown = position.fButtons; // Sometimes MouseUp() is missed! - } - else if (currentTool == T_CLONE) - { - extern PicMenuButton *mode; + } else if (currentTool == T_CLONE) { + extern PicMenuButton* mode; Position position; - GetPosition (&position); + GetPosition(&position); if (DebugLevel > 6) - printf ("P = %d\n", position.fPressure); - tCloneM (mode->selected(), point, position.fButtons, position.fPressure, position.fTilt); + printf("P = %d\n", position.fPressure); + tCloneM( + mode->selected(), point, position.fButtons, position.fPressure, + position.fTilt + ); fMouseDown = position.fButtons; // Sometimes MouseUp() is missed! - } - else if (currentTool == T_SPRAYCAN) - { - extern PicMenuButton *mode; + } else if (currentTool == T_SPRAYCAN) { + extern PicMenuButton* mode; Position position; - GetPosition (&position); - tSpraycanM (mode->selected(), point, position.fButtons, position.fPressure, position.fTilt); + GetPosition(&position); + tSpraycanM( + mode->selected(), point, position.fButtons, position.fPressure, + position.fTilt + ); fMouseDown = position.fButtons; // Sometimes MouseUp() is missed! } } @@ -4557,136 +4462,119 @@ void CanvasView::MouseMoved (BPoint point, uint32 transit, const BMessage *msg) // printf ("MouseMoved took %d ms\n", end - start); } - -void CanvasView::MouseOrTablet (Position *position) +void +CanvasView::MouseOrTablet(Position* position) { fMouseDown = true; - BPoint point = position->fPoint; + BPoint point = position->fPoint; uint32 buttons = position->fButtons; point.x /= fScale; point.y /= fScale; extern bool inPaste; extern PicMenuButton *tool, *mode; extern ColorMenuButton *locolor, *hicolor; - extern Becasso *mainapp; + extern Becasso* mainapp; int32 currentMode = mode->selected(); int32 currentTool = tool->selected(); currentLayer()->Lock(); selection->Lock(); - if (fTranslating) - { - do_translateLayer (fTranslating - 1, currentMode); + if (fTranslating) { + do_translateLayer(fTranslating - 1, currentMode); fTranslating = 0; mainapp->setCross(); - } - else if (fRotating) - { - do_rotateLayer (fRotating - 1, currentMode); + } else if (fRotating) { + do_rotateLayer(fRotating - 1, currentMode); fRotating = 0; mainapp->setCross(); - } - else if (modifiers() & B_OPTION_KEY) // Color Picker / DragScroll + } else if (modifiers() & B_OPTION_KEY) // Color Picker / DragScroll { - if (modifiers() & B_SHIFT_KEY) // DragScroll + if (modifiers() & B_SHIFT_KEY) // DragScroll { fDragScroll = true; BPoint lt = Frame().LeftTop(); - BPoint p = ConvertToScreen (BPoint (point.x*fScale, point.y*fScale)); - fPoint = BPoint (p.x - lt.x, p.y - lt.y); -// printf ("New drag: "); -// fPoint.PrintToStream(); - } - else - { + BPoint p = ConvertToScreen(BPoint(point.x * fScale, point.y * fScale)); + fPoint = BPoint(p.x - lt.x, p.y - lt.y); + // printf ("New drag: "); + // fPoint.PrintToStream(); + } else { if (buttons & B_PRIMARY_MOUSE_BUTTON) - hicolor->set (getColor (point)); + hicolor->set(getColor(point)); if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - locolor->set (getColor (point)); + locolor->set(getColor(point)); } - } - else if ((modifiers() & B_SHIFT_KEY) & selchanged) // Cut/Copy/Paste + } else if ((modifiers() & B_SHIFT_KEY) & selchanged) // Cut/Copy/Paste { - if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { + if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { Cut(); - eDrag (point, buttons); - } - else if (buttons & B_PRIMARY_MOUSE_BUTTON) - { + eDrag(point, buttons); + } else if (buttons & B_PRIMARY_MOUSE_BUTTON) { Copy(); - eDrag (point, buttons); - } - } - else if ((modifiers() & B_COMMAND_KEY) && filterOpen && filterOpen->DoesPreview()) // AddOn Preview - { - eFilter (point, buttons); - } - else if (generatorOpen && (generatorOpen->DoesPreview() & PREVIEW_MOUSE)) - { - eGenerate (point, buttons); - } - else if (transformerOpen && (transformerOpen->DoesPreview() & PREVIEW_MOUSE)) - { - eTransform (point, buttons); - } - else if (inPaste) - ePaste (point, buttons); - else if (!transformerOpen && !generatorOpen) - { - switch (currentTool) - { + eDrag(point, buttons); + } + } else if ((modifiers() & B_COMMAND_KEY) && filterOpen && filterOpen->DoesPreview()) // AddOn + // Preview + { + eFilter(point, buttons); + } else if (generatorOpen && (generatorOpen->DoesPreview() & PREVIEW_MOUSE)) { + eGenerate(point, buttons); + } else if (transformerOpen && (transformerOpen->DoesPreview() & PREVIEW_MOUSE)) { + eTransform(point, buttons); + } else if (inPaste) + ePaste(point, buttons); + else if (!transformerOpen && !generatorOpen) { + switch (currentTool) { case T_BRUSH: - tBrush (currentMode, point, buttons); + tBrush(currentMode, point, buttons); break; case T_ERASER: - tEraser (currentMode, point, buttons); + tEraser(currentMode, point, buttons); break; case T_FILL: - tFill (currentMode, point, buttons); + tFill(currentMode, point, buttons); break; case T_TEXT: - tText (currentMode, point, buttons); + tText(currentMode, point, buttons); break; case T_SPRAYCAN: - tSpraycan (currentMode, point, buttons); + tSpraycan(currentMode, point, buttons); break; case T_CLONE: - tClone (currentMode, point, buttons); + tClone(currentMode, point, buttons); break; case T_FREEHAND: - tFreehand (currentMode, point, buttons); + tFreehand(currentMode, point, buttons); break; case T_LINES: - myWindow->posview->SetPoint (point.x, point.y); - myWindow->posview->DoRadius (true); - tLines (currentMode, point, buttons); + myWindow->posview->SetPoint(point.x, point.y); + myWindow->posview->DoRadius(true); + tLines(currentMode, point, buttons); break; case T_POLYBLOB: - tPolyblob (currentMode, point, buttons); + tPolyblob(currentMode, point, buttons); break; case T_POLYGON: - myWindow->posview->SetPoint (point.x, point.y); - tPolygon (currentMode, point, buttons); + myWindow->posview->SetPoint(point.x, point.y); + tPolygon(currentMode, point, buttons); break; case T_RECT: - myWindow->posview->SetPoint (point.x, point.y); - tRect (currentMode, point, buttons); + myWindow->posview->SetPoint(point.x, point.y); + tRect(currentMode, point, buttons); break; case T_RRECT: - myWindow->posview->SetPoint (point.x, point.y); - tRoundRect (currentMode, point, buttons); + myWindow->posview->SetPoint(point.x, point.y); + tRoundRect(currentMode, point, buttons); break; case T_CIRCLE: - myWindow->posview->SetPoint (point.x, point.y); - myWindow->posview->DoRadius (true); - tCircle (currentMode, point, buttons); + myWindow->posview->SetPoint(point.x, point.y); + myWindow->posview->DoRadius(true); + tCircle(currentMode, point, buttons); break; case T_ELLIPSE: - myWindow->posview->SetPoint (point.x, point.y); - tEllipse (currentMode, point, buttons); + myWindow->posview->SetPoint(point.x, point.y); + tEllipse(currentMode, point, buttons); break; default: - fprintf (stderr, "Unknown Tool selected...\n"); + fprintf(stderr, "Unknown Tool selected...\n"); break; } } @@ -4694,162 +4582,148 @@ void CanvasView::MouseOrTablet (Position *position) drawView->Sync(); selection->Unlock(); currentLayer()->Unlock(); -// printf ("MoT done\n"); + // printf ("MoT done\n"); } -void CanvasView::KeyDown (const char *bytes, int32 numBytes) -{ - if (numBytes == 1 && !myWindow->MenuOnScreen()) - { - switch (*bytes) - { - case B_TAB: // Switch mode +void +CanvasView::KeyDown(const char* bytes, int32 numBytes) +{ + if (numBytes == 1 && !myWindow->MenuOnScreen()) { + switch (*bytes) { + case B_TAB: // Switch mode { - extern PicMenuButton *mode; + extern PicMenuButton* mode; if (mode->selected() == M_DRAW) - mode->set (M_SELECT); + mode->set(M_SELECT); else - mode->set (M_DRAW); + mode->set(M_DRAW); Invalidate(); break; } - case B_ENTER: // "Attach" clip to mouse cursor or keep initial distance + case B_ENTER: // "Attach" clip to mouse cursor or keep initial distance { extern bool inPaste; - if (inPaste) - { + if (inPaste) { extern long pasteX, pasteY, fPasteX, fPasteY; - if (pasteX || pasteY) - { + if (pasteX || pasteY) { pasteX = 0; pasteY = 0; - } - else - { + } else { pasteX = fPasteX; pasteY = fPasteY; } BPoint point; uint32 buttons; - GetMouse (&point, &buttons); - ePasteM (point); + GetMouse(&point, &buttons); + ePasteM(point); } break; } - case B_ESCAPE: // Bail out of whatever you're doing + case B_ESCAPE: // Bail out of whatever you're doing { extern bool inPaste; - if (inPaste) - { + if (inPaste) { currentLayer()->Lock(); - drawView->DrawBitmap (cutbg, prevPaste.LeftTop()); + drawView->DrawBitmap(cutbg, prevPaste.LeftTop()); currentLayer()->Unlock(); - cutbg->RemoveChild (cutView); + cutbg->RemoveChild(cutView); delete cutbg; delete cutView; cutbg = NULL; inPaste = false; Invalidate(); - } - else if (entry) - { + } else if (entry) { entry = 0; Invalidate(); } fTranslating = 0; fRotating = 0; - extern Becasso *mainapp; + extern Becasso* mainapp; mainapp->setCross(); mainapp->setReady(); break; } - case B_LEFT_ARROW: - { + case B_LEFT_ARROW: { uint32 buttons; BPoint sp; - GetMouse (&sp, &buttons); - sp = ConvertToScreen (BPoint (sp.x*fScale, sp.y*fScale)); + GetMouse(&sp, &buttons); + sp = ConvertToScreen(BPoint(sp.x * fScale, sp.y * fScale)); float add = modifiers() & B_CONTROL_KEY ? 10 : 1; - set_mouse_position (int (sp.x - fScale*add), int (sp.y)); + set_mouse_position(int(sp.x - fScale * add), int(sp.y)); break; } - case B_RIGHT_ARROW: - { + case B_RIGHT_ARROW: { uint32 buttons; BPoint sp; - GetMouse (&sp, &buttons); - sp = ConvertToScreen (BPoint (sp.x*fScale, sp.y*fScale)); + GetMouse(&sp, &buttons); + sp = ConvertToScreen(BPoint(sp.x * fScale, sp.y * fScale)); float add = modifiers() & B_CONTROL_KEY ? 10 : 1; - set_mouse_position (int (sp.x + (fScale >= 1 ? fScale : 1)*add), int (sp.y)); + set_mouse_position(int(sp.x + (fScale >= 1 ? fScale : 1) * add), int(sp.y)); break; } - case B_UP_ARROW: - { + case B_UP_ARROW: { uint32 buttons; BPoint sp; - GetMouse (&sp, &buttons); - sp = ConvertToScreen (BPoint (sp.x*fScale, sp.y*fScale)); + GetMouse(&sp, &buttons); + sp = ConvertToScreen(BPoint(sp.x * fScale, sp.y * fScale)); float add = modifiers() & B_CONTROL_KEY ? 10 : 1; - set_mouse_position (int (sp.x), int (sp.y - fScale*add)); + set_mouse_position(int(sp.x), int(sp.y - fScale * add)); break; } - case B_DOWN_ARROW: - { + case B_DOWN_ARROW: { uint32 buttons; BPoint sp; - GetMouse (&sp, &buttons); - sp = ConvertToScreen (BPoint (sp.x*fScale, sp.y*fScale)); + GetMouse(&sp, &buttons); + sp = ConvertToScreen(BPoint(sp.x * fScale, sp.y * fScale)); float add = modifiers() & B_CONTROL_KEY ? 10 : 1; - set_mouse_position (int (sp.x), int (sp.y + (fScale >= 1 ? fScale : 1)*add)); + set_mouse_position(int(sp.x), int(sp.y + (fScale >= 1 ? fScale : 1) * add)); break; } - case B_SPACE: - { + case B_SPACE: { uint32 buttons; BPoint point; - GetMouse (&point, &buttons); + GetMouse(&point, &buttons); Position position; - position.fPoint = BPoint (point.x*fScale, point.y*fScale); - position.fButtons = (modifiers() & B_SHIFT_KEY) ? B_SECONDARY_MOUSE_BUTTON : B_PRIMARY_MOUSE_BUTTON; - position.fTilt = B_ORIGIN; + position.fPoint = BPoint(point.x * fScale, point.y * fScale); + position.fButtons = + (modifiers() & B_SHIFT_KEY) ? B_SECONDARY_MOUSE_BUTTON : B_PRIMARY_MOUSE_BUTTON; + position.fTilt = B_ORIGIN; position.fProximity = false; - position.fPressure = 255; - MouseOrTablet (&position); - MouseUp (point); + position.fPressure = 255; + MouseOrTablet(&position); + MouseUp(point); break; } default: - inherited::KeyDown (bytes, numBytes); + inherited::KeyDown(bytes, numBytes); } - } - else - inherited::KeyDown (bytes, numBytes); + } else + inherited::KeyDown(bytes, numBytes); } - -void CanvasView::SetupUndo (int32 mode) +void +CanvasView::SetupUndo(int32 mode) { -// if (didPreview == 2) -// { -// // This means we're in a preview-train (the user is sliding a slider on an -// // add-on window, for instance). We don't want to flood the undo buffer... -// return; -// } -// else if (didPreview == 2) -// { -// // This means "something else" has happened since the last preview. -// // We'd better save now, and next time the add-on does something too! -// didPreview = 0; -// } + // if (didPreview == 2) + // { + // // This means we're in a preview-train (the user is sliding a slider on an + // // add-on window, for instance). We don't want to flood the undo buffer... + // return; + // } + // else if (didPreview == 2) + // { + // // This means "something else" has happened since the last preview. + // // We'd better save now, and next time the add-on does something too! + // didPreview = 0; + // } Sync(); currentLayer()->Lock(); drawView->Sync(); currentLayer()->Unlock(); - extern Becasso *mainapp; + extern Becasso* mainapp; int32 type; - switch (mode) - { + switch (mode) { case M_SELECT: type = UNDO_SELECT; break; @@ -4862,190 +4736,171 @@ void CanvasView::SetupUndo (int32 mode) case M_DELLAYER: type = UNDO_LDEL; break; - case M_RESIZE: // For the time being, just flush the undo array. - // Should I warn the user about this? + case M_RESIZE: // For the time being, just flush the undo array. + // Should I warn the user about this? indexUndo = -1; maxUndo = 0; - for (int i = 0; i < MAX_UNDO; i++) - { + for (int i = 0; i < MAX_UNDO; i++) { delete undo[i].bitmap; delete undo[i].sbitmap; - undo[i].bitmap = NULL; + undo[i].bitmap = NULL; undo[i].sbitmap = NULL; } myWindow->Lock(); - myWindow->setMenuItem (B_UNDO, false); - myWindow->setMenuItem ('redo', false); + myWindow->setMenuItem(B_UNDO, false); + myWindow->setMenuItem('redo', false); myWindow->Unlock(); return; case M_DRAW_SELECT: type = UNDO_BOTH; break; default: - fprintf (stderr, "SetupUndo: Unknown mode [%li]...\n", mode); + fprintf(stderr, "SetupUndo: Unknown mode [%li]...\n", mode); return; } - if (type == UNDO_SELECT || type == UNDO_BOTH) - { + if (type == UNDO_SELECT || type == UNDO_BOTH) { selchanged = true; myWindow->Lock(); - myWindow->setMenuItem (B_CUT, true); - myWindow->setMenuItem (B_COPY, true); - myWindow->setMenuItem ('csel', true); - myWindow->setMenuItem ('sund', true); - myWindow->setMenuItem ('sinv', true); + myWindow->setMenuItem(B_CUT, true); + myWindow->setMenuItem(B_COPY, true); + myWindow->setMenuItem('csel', true); + myWindow->setMenuItem('sund', true); + myWindow->setMenuItem('sinv', true); myWindow->Unlock(); sel = true; } mainapp->setBusy(); changed = true; -// extern AttribDraw *mAttribDraw; + // extern AttribDraw *mAttribDraw; maxUndo = max_undo(); int32 prevtype = undo[indexUndo].type; - if ((prevtype == UNDO_DRAW && type == UNDO_SELECT) || (prevtype == UNDO_SELECT && type == UNDO_DRAW)) - { + if ((prevtype == UNDO_DRAW && type == UNDO_SELECT) || + (prevtype == UNDO_SELECT && type == UNDO_DRAW)) { type = UNDO_SWITCH; } - if (indexUndo + 1 == maxUndo - 1) - { -// printf ("Deleting undo[0]: %p, %p (indexUndo = %d)\n", undo[0].bitmap, undo[0].sbitmap, indexUndo); + if (indexUndo + 1 == maxUndo - 1) { + // printf ("Deleting undo[0]: %p, %p (indexUndo = %d)\n", undo[0].bitmap, + // undo[0].sbitmap, indexUndo); delete undo[0].bitmap; delete undo[0].sbitmap; - for (int i = 1; i < maxUndo; i++) - { + for (int i = 1; i < maxUndo; i++) { undo[i - 1] = undo[i]; } undo[maxUndo - 1].bitmap = 0; undo[maxUndo - 1].sbitmap = 0; - } - else + } else indexUndo++; -// printf ("Killing the redo buffer...\n"); - for (int i = indexUndo; i < MAX_UNDO; i++) - { + // printf ("Killing the redo buffer...\n"); + for (int i = indexUndo; i < MAX_UNDO; i++) { delete undo[i].bitmap; delete undo[i].sbitmap; - undo[i].bitmap = NULL; + undo[i].bitmap = NULL; undo[i].sbitmap = NULL; } maxIndexUndo = indexUndo; - undo_entry &u = undo[indexUndo]; // alias to save typing. -// printf ("Copying the data\n"); - if (type == UNDO_SELECT) - { + undo_entry& u = undo[indexUndo]; // alias to save typing. + // printf ("Copying the data\n"); + if (type == UNDO_SELECT) { selection->Lock(); - u.sbitmap = new SBitmap (selection); + u.sbitmap = new SBitmap(selection); u.bitmap = NULL; -// printf ("Setup undo: selection -> undo[%i]\n", indexUndo); + // printf ("Setup undo: selection -> undo[%i]\n", indexUndo); selection->Unlock(); u.layer = -1; - } - else if (type == UNDO_DRAW) - { + } else if (type == UNDO_DRAW) { currentLayer()->Lock(); - u.bitmap = new SBitmap (currentLayer()); + u.bitmap = new SBitmap(currentLayer()); u.sbitmap = NULL; -// printf ("Setup undo: layer[%i] -> undo[%i]\n", fCurrentLayer, indexUndo); + // printf ("Setup undo: layer[%i] -> undo[%i]\n", fCurrentLayer, indexUndo); currentLayer()->Unlock(); u.layer = fCurrentLayer; - } - else if (type == UNDO_BOTH) - { + } else if (type == UNDO_BOTH) { selection->Lock(); - u.sbitmap = new SBitmap (selection); - u.bitmap = new SBitmap (currentLayer()); -// printf ("Setup undo: selection -> undo[%i]\n", indexUndo); + u.sbitmap = new SBitmap(selection); + u.bitmap = new SBitmap(currentLayer()); + // printf ("Setup undo: selection -> undo[%i]\n", indexUndo); selection->Unlock(); currentLayer()->Lock(); -// printf ("Setup undo: layer[%i] -> undo[%i]\n", fCurrentLayer, indexUndo); + // printf ("Setup undo: layer[%i] -> undo[%i]\n", fCurrentLayer, indexUndo); currentLayer()->Unlock(); u.layer = fCurrentLayer; - } - else if (type == UNDO_SWITCH) - { + } else if (type == UNDO_SWITCH) { currentLayer()->Lock(); - u.bitmap = new SBitmap (currentLayer()); -// printf ("Setup undo: layer[%i] & selection -> undo[%i]\n", fCurrentLayer, indexUndo); + u.bitmap = new SBitmap(currentLayer()); + // printf ("Setup undo: layer[%i] & selection -> undo[%i]\n", fCurrentLayer, + // indexUndo); currentLayer()->Unlock(); u.layer = fCurrentLayer; - u.sbitmap = new SBitmap (selection); + u.sbitmap = new SBitmap(selection); selection->Lock(); selection->Unlock(); - } - else if (type == UNDO_MERGE) - { + } else if (type == UNDO_MERGE) { layer[fIndex1]->Lock(); - u.bitmap = new SBitmap (layer[fIndex1]); + u.bitmap = new SBitmap(layer[fIndex1]); layer[fIndex1]->Unlock(); layer[fIndex2]->Lock(); - u.sbitmap = new SBitmap (layer[fIndex2]); + u.sbitmap = new SBitmap(layer[fIndex2]); layer[fIndex2]->Unlock(); - u.layer = fIndex1; - u.next = fIndex2; - u.fMode = layer[fIndex2]->getMode(); + u.layer = fIndex1; + u.next = fIndex2; + u.fMode = layer[fIndex2]->getMode(); u.fGlobalAlpha = layer[fIndex2]->getGlobalAlpha(); - u.fHide = layer[fIndex2]->IsHidden(); - strcpy (u.fName, layer[fIndex2]->getName()); - } - else if (type == UNDO_LDEL) - { + u.fHide = layer[fIndex2]->IsHidden(); + strcpy(u.fName, layer[fIndex2]->getName()); + } else if (type == UNDO_LDEL) { layer[fIndex2]->Lock(); - u.bitmap = new SBitmap (layer[fIndex2]); + u.bitmap = new SBitmap(layer[fIndex2]); layer[fIndex2]->Unlock(); - u.layer = fIndex2; - u.fMode = layer[fIndex2]->getMode(); + u.layer = fIndex2; + u.fMode = layer[fIndex2]->getMode(); u.fGlobalAlpha = layer[fIndex2]->getGlobalAlpha(); - u.fHide = layer[fIndex2]->IsHidden(); - strcpy (u.fName, layer[fIndex2]->getName()); + u.fHide = layer[fIndex2]->IsHidden(); + strcpy(u.fName, layer[fIndex2]->getName()); } u.type = type; myWindow->Lock(); - myWindow->setMenuItem (B_UNDO, true); - myWindow->setMenuItem ('redo', false); + myWindow->setMenuItem(B_UNDO, true); + myWindow->setMenuItem('redo', false); myWindow->Unlock(); mainapp->setReady(); } -void CanvasView::Undo (bool advance, bool menu) +void +CanvasView::Undo(bool advance, bool menu) { - if (menu) - { - if (filterOpen || transformerOpen || generatorOpen) - { + if (menu) { + if (filterOpen || transformerOpen || generatorOpen) { beep(); return; } } - extern PicMenuButton *mode; + extern PicMenuButton* mode; int32 currentmode = mode->selected(); - if (entry) - { + if (entry) { entry = 0; - Draw (fCanvasFrame); + Draw(fCanvasFrame); return; } changed = true; - extern Becasso *mainapp; -// extern AttribDraw *mAttribDraw; + extern Becasso* mainapp; + // extern AttribDraw *mAttribDraw; mainapp->setBusy(); maxUndo = max_undo(); - if (indexUndo < 0) - { - fprintf (stderr, "Empty undo buffer!\n"); + if (indexUndo < 0) { + fprintf(stderr, "Empty undo buffer!\n"); indexUndo = -1; - return; // Sorry, undo buffer is empty... + return; // Sorry, undo buffer is empty... } - if (indexUndo == maxIndexUndo && advance) // First undo + if (indexUndo == maxIndexUndo && advance) // First undo { -// printf ("First undo - saving current state\n"); + // printf ("First undo - saving current state\n"); int32 prevtype = undo[indexUndo].type; int32 type = 0; - switch (currentmode) - { + switch (currentmode) { case M_DRAW: type = UNDO_DRAW; break; @@ -5053,21 +4908,19 @@ void CanvasView::Undo (bool advance, bool menu) type = UNDO_SELECT; break; default: - fprintf (stderr, "Undo: Unknown mode [%li]...\n", currentmode); + fprintf(stderr, "Undo: Unknown mode [%li]...\n", currentmode); } - if ((prevtype == UNDO_DRAW && type == UNDO_SELECT) || (prevtype == UNDO_SELECT && type == UNDO_DRAW)) - { + if ((prevtype == UNDO_DRAW && type == UNDO_SELECT) || + (prevtype == UNDO_SELECT && type == UNDO_DRAW)) { type = UNDO_SWITCH; } indexUndo++; maxIndexUndo++; - if (indexUndo == maxUndo) - { -// printf ("Shifting the undo buffer\n"); + if (indexUndo == maxUndo) { + // printf ("Shifting the undo buffer\n"); delete undo[0].bitmap; delete undo[0].sbitmap; - for (int i = 1; i < maxUndo; i++) - { + for (int i = 1; i < maxUndo; i++) { undo[i - 1] = undo[i]; } indexUndo--; @@ -5075,27 +4928,23 @@ void CanvasView::Undo (bool advance, bool menu) } // Copy the bitmap into the undo buffer - undo_entry &u = undo[indexUndo]; // Alias to save typing - if (type == UNDO_SELECT) - { -// printf ("Current selection -> undo[%i]\n", indexUndo); - u.sbitmap = new SBitmap (selection); + undo_entry& u = undo[indexUndo]; // Alias to save typing + if (type == UNDO_SELECT) { + // printf ("Current selection -> undo[%i]\n", indexUndo); + u.sbitmap = new SBitmap(selection); u.bitmap = NULL; u.layer = -1; - } - else if (type == UNDO_DRAW) - { -// printf ("Current layer[%i] -> undo[%i]\n", fCurrentLayer, indexUndo); - u.bitmap = new SBitmap (currentLayer()); + } else if (type == UNDO_DRAW) { + // printf ("Current layer[%i] -> undo[%i]\n", fCurrentLayer, indexUndo); + u.bitmap = new SBitmap(currentLayer()); u.sbitmap = NULL; u.layer = fCurrentLayer; - } - else if (type == UNDO_SWITCH) - { -// printf ("Current layer[%i] & selection -> undo[%i]\n", fCurrentLayer, indexUndo); - u.bitmap = new SBitmap (currentLayer()); + } else if (type == UNDO_SWITCH) { + // printf ("Current layer[%i] & selection -> undo[%i]\n", fCurrentLayer, + // indexUndo); + u.bitmap = new SBitmap(currentLayer()); u.layer = fCurrentLayer; - u.sbitmap = new SBitmap (selection); + u.sbitmap = new SBitmap(selection); } // N.B. UNDO_MERGE can't happen here... u.type = type; @@ -5103,77 +4952,65 @@ void CanvasView::Undo (bool advance, bool menu) } // Copy the undo buffer into the bitmap -// printf ("Restoring from undo[%i];\n", indexUndo); - undo_entry &u = undo[indexUndo]; // Alias to save typing - if (u.type == UNDO_DRAW) - { -// printf ("undo[%i] -> layer[%i]\n", indexUndo, u.layer); + // printf ("Restoring from undo[%i];\n", indexUndo); + undo_entry& u = undo[indexUndo]; // Alias to save typing + if (u.type == UNDO_DRAW) { + // printf ("undo[%i] -> layer[%i]\n", indexUndo, u.layer); layer[u.layer]->Lock(); - memcpy (layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); + memcpy(layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); layer[u.layer]->Unlock(); - } - else if (u.type == UNDO_SELECT) - { -// printf ("undo[%i] -> selection\n", indexUndo); + } else if (u.type == UNDO_SELECT) { + // printf ("undo[%i] -> selection\n", indexUndo); selection->Lock(); - memcpy (selection->Bits(), u.sbitmap->Bits(), selection->BitsLength()); + memcpy(selection->Bits(), u.sbitmap->Bits(), selection->BitsLength()); selection->Unlock(); selchanged = true; sel = true; - } - else if (u.type == UNDO_BOTH) - { + } else if (u.type == UNDO_BOTH) { layer[u.layer]->Lock(); - memcpy (layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); + memcpy(layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); layer[u.layer]->Unlock(); selection->Lock(); - memcpy (selection->Bits(), u.sbitmap->Bits(), selection->BitsLength()); + memcpy(selection->Bits(), u.sbitmap->Bits(), selection->BitsLength()); selection->Unlock(); selchanged = true; sel = true; - } - else if (u.type == UNDO_SWITCH) - { -// printf ("undo[%i] -> layer[%i] & selection\n", indexUndo, u.layer); + } else if (u.type == UNDO_SWITCH) { + // printf ("undo[%i] -> layer[%i] & selection\n", indexUndo, u.layer); selection->Lock(); - memcpy (selection->Bits(), u.sbitmap->Bits(), selection->BitsLength()); + memcpy(selection->Bits(), u.sbitmap->Bits(), selection->BitsLength()); selection->Unlock(); layer[u.layer]->Lock(); - memcpy (layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); + memcpy(layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); layer[u.layer]->Unlock(); selchanged = true; sel = true; - } - else if (u.type == UNDO_MERGE) - { + } else if (u.type == UNDO_MERGE) { layer[u.layer]->Lock(); - memcpy (layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); + memcpy(layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); layer[u.layer]->Unlock(); - insertLayer (u.next, "Restored"); + insertLayer(u.next, "Restored"); layer[u.next]->Lock(); - memcpy (layer[u.next]->Bits(), u.sbitmap->Bits(), layer[u.next]->BitsLength()); - layer[u.next]->setName (u.fName); - layer[u.next]->Hide (u.fHide); - layer[u.next]->setGlobalAlpha (u.fGlobalAlpha); - layer[u.next]->setMode (u.fMode); + memcpy(layer[u.next]->Bits(), u.sbitmap->Bits(), layer[u.next]->BitsLength()); + layer[u.next]->setName(u.fName); + layer[u.next]->Hide(u.fHide); + layer[u.next]->setGlobalAlpha(u.fGlobalAlpha); + layer[u.next]->setMode(u.fMode); layer[u.next]->Unlock(); - } - else if (u.type == UNDO_LDEL) - { - insertLayer (u.layer, "Restored"); + } else if (u.type == UNDO_LDEL) { + insertLayer(u.layer, "Restored"); layer[u.layer]->Lock(); - memcpy (layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); - layer[u.layer]->setName (u.fName); - layer[u.layer]->Hide (u.fHide); - layer[u.layer]->setGlobalAlpha (u.fGlobalAlpha); - layer[u.layer]->setMode (u.fMode); + memcpy(layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); + layer[u.layer]->setName(u.fName); + layer[u.layer]->Hide(u.fHide); + layer[u.layer]->setGlobalAlpha(u.fGlobalAlpha); + layer[u.layer]->setMode(u.fMode); layer[u.layer]->Unlock(); } - if (advance) - { + if (advance) { myWindow->Lock(); - myWindow->setMenuItem (B_UNDO, indexUndo > 0); - myWindow->setMenuItem ('redo', true); + myWindow->setMenuItem(B_UNDO, indexUndo > 0); + myWindow->setMenuItem('redo', true); myWindow->Unlock(); Invalidate(); indexUndo--; @@ -5181,319 +5018,288 @@ void CanvasView::Undo (bool advance, bool menu) mainapp->setReady(); } -void CanvasView::Redo (bool menu) +void +CanvasView::Redo(bool menu) { - if (menu) - { - if (filterOpen || transformerOpen || generatorOpen) - { + if (menu) { + if (filterOpen || transformerOpen || generatorOpen) { beep(); return; } } - if (indexUndo + 1 >= maxIndexUndo) - { - fprintf (stderr, "Nothing to redo!\n"); - return; // Nothing to redo! + if (indexUndo + 1 >= maxIndexUndo) { + fprintf(stderr, "Nothing to redo!\n"); + return; // Nothing to redo! } indexUndo++; changed = true; - extern Becasso *mainapp; + extern Becasso* mainapp; mainapp->setBusy(); // Copy the redo buffer into the bitmap -// printf ("Restoring from undo[%i];\n", indexUndo); - undo_entry &u = undo[indexUndo + 1]; // Alias to save typing - if (u.type == UNDO_DRAW) - { + // printf ("Restoring from undo[%i];\n", indexUndo); + undo_entry& u = undo[indexUndo + 1]; // Alias to save typing + if (u.type == UNDO_DRAW) { layer[u.layer]->Lock(); - memcpy (layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); -// printf ("undo[%i] -> layer[%i]\n", indexUndo + 1, u.layer); + memcpy(layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); + // printf ("undo[%i] -> layer[%i]\n", indexUndo + 1, u.layer); layer[u.layer]->Unlock(); - } - else if (u.type == UNDO_SELECT) - { + } else if (u.type == UNDO_SELECT) { selection->Lock(); - memcpy (selection->Bits(), u.sbitmap->Bits(), selection->BitsLength()); -// printf ("undo[%i] -> selection\n", indexUndo + 1); + memcpy(selection->Bits(), u.sbitmap->Bits(), selection->BitsLength()); + // printf ("undo[%i] -> selection\n", indexUndo + 1); selection->Unlock(); selchanged = true; sel = true; - } - else if (u.type == UNDO_BOTH) - { + } else if (u.type == UNDO_BOTH) { layer[u.layer]->Lock(); - memcpy (layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); -// printf ("undo[%i] -> layer[%i]\n", indexUndo + 1, u.layer); + memcpy(layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); + // printf ("undo[%i] -> layer[%i]\n", indexUndo + 1, u.layer); layer[u.layer]->Unlock(); selection->Lock(); - memcpy (selection->Bits(), u.sbitmap->Bits(), selection->BitsLength()); -// printf ("undo[%i] -> selection\n", indexUndo + 1); + memcpy(selection->Bits(), u.sbitmap->Bits(), selection->BitsLength()); + // printf ("undo[%i] -> selection\n", indexUndo + 1); selection->Unlock(); selchanged = true; sel = true; - } - else if (u.type == UNDO_SWITCH) - { + } else if (u.type == UNDO_SWITCH) { layer[u.layer]->Lock(); - memcpy (layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); -// printf ("undo[%i] -> layer[%i] & selection\n", indexUndo + 1, u.layer); + memcpy(layer[u.layer]->Bits(), u.bitmap->Bits(), layer[u.layer]->BitsLength()); + // printf ("undo[%i] -> layer[%i] & selection\n", indexUndo + 1, u.layer); layer[u.layer]->Unlock(); selection->Lock(); - memcpy (selection->Bits(), u.sbitmap->Bits(), selection->BitsLength()); + memcpy(selection->Bits(), u.sbitmap->Bits(), selection->BitsLength()); selection->Unlock(); - } - else if (u.type == UNDO_MERGE) - { - Merge (layer[u.layer], layer[u.next], fCanvasFrame, false); - do_removeLayer (u.next); - } - else if (u.type == UNDO_LDEL) - { - do_removeLayer (u.layer); + } else if (u.type == UNDO_MERGE) { + Merge(layer[u.layer], layer[u.next], fCanvasFrame, false); + do_removeLayer(u.next); + } else if (u.type == UNDO_LDEL) { + do_removeLayer(u.layer); } myWindow->Lock(); - myWindow->setMenuItem (B_UNDO, true); - myWindow->setMenuItem ('redo', indexUndo + 1 < maxIndexUndo); + myWindow->setMenuItem(B_UNDO, true); + myWindow->setMenuItem('redo', indexUndo + 1 < maxIndexUndo); myWindow->Unlock(); Invalidate(); mainapp->setReady(); } - -void CanvasView::Cut () +void +CanvasView::Cut() { extern long pasteX, pasteY, fPasteX, fPasteY; - extern Becasso *mainapp; - extern BBitmap *clip; + extern Becasso* mainapp; + extern BBitmap* clip; mainapp->setBusy(); - SetupUndo (M_DRAW); - if (clip) - { + SetupUndo(M_DRAW); + if (clip) { clip->Lock(); delete clip; } uint32 buttons; BPoint point; - GetMouse (&point, &buttons, true); - BRect selectrect = GetSmallestRect (selection); - fPasteX = long (selectrect.left - point.x); - fPasteY = long (selectrect.top - point.y); + GetMouse(&point, &buttons, true); + BRect selectrect = GetSmallestRect(selection); + fPasteX = long(selectrect.left - point.x); + fPasteY = long(selectrect.top - point.y); pasteX = 0; pasteY = 0; BRect cutrect = selectrect; - cutrect.OffsetTo (B_ORIGIN); - clip = new BBitmap (cutrect, B_RGBA32); + cutrect.OffsetTo(B_ORIGIN); + clip = new BBitmap(cutrect, B_RGBA32); - CutOrCopy (currentLayer(), clip, selection, int (selectrect.left), int (selectrect.top), true); + CutOrCopy(currentLayer(), clip, selection, int(selectrect.left), int(selectrect.top), true); myWindow->Lock(); - myWindow->setPaste (true); + myWindow->setPaste(true); myWindow->Unlock(); - BMessage *clipmsg = new BMessage ('bits'); - clip->Archive (clipmsg, false); - if (be_clipboard->Lock()) - { + BMessage* clipmsg = new BMessage('bits'); + clip->Archive(clipmsg, false); + if (be_clipboard->Lock()) { be_clipboard->Clear(); - BMessage *clipper = be_clipboard->Data(); - clipper->AddMessage ("image/x-be-bitmap", clipmsg); + BMessage* clipper = be_clipboard->Data(); + clipper->AddMessage("image/x-be-bitmap", clipmsg); be_clipboard->Commit(); be_clipboard->Unlock(); } delete clipmsg; - //UndoSelection(); + // UndoSelection(); Invalidate(); mainapp->setReady(); } -void CanvasView::Copy () +void +CanvasView::Copy() { extern long pasteX, pasteY, fPasteX, fPasteY; - extern Becasso *mainapp; - extern BBitmap *clip; + extern Becasso* mainapp; + extern BBitmap* clip; mainapp->setBusy(); - //SetupUndo (M_DRAW); - if (clip) - { + // SetupUndo (M_DRAW); + if (clip) { clip->Lock(); delete clip; } uint32 buttons; BPoint point; - GetMouse (&point, &buttons, true); - BRect selectrect = GetSmallestRect (selection); - fPasteX = long (selectrect.left - point.x); - fPasteY = long (selectrect.top - point.y); + GetMouse(&point, &buttons, true); + BRect selectrect = GetSmallestRect(selection); + fPasteX = long(selectrect.left - point.x); + fPasteY = long(selectrect.top - point.y); pasteX = 0; pasteY = 0; BRect cutrect = selectrect; - cutrect.OffsetTo (B_ORIGIN); - clip = new BBitmap (cutrect, B_RGBA32); + cutrect.OffsetTo(B_ORIGIN); + clip = new BBitmap(cutrect, B_RGBA32); - CutOrCopy (currentLayer(), clip, selection, int (selectrect.left), int (selectrect.top), false); + CutOrCopy(currentLayer(), clip, selection, int(selectrect.left), int(selectrect.top), false); myWindow->Lock(); - myWindow->setPaste (true); + myWindow->setPaste(true); myWindow->Unlock(); - BMessage *clipmsg = new BMessage ('bits'); - clip->Archive (clipmsg, false); - if (be_clipboard->Lock()) - { + BMessage* clipmsg = new BMessage('bits'); + clip->Archive(clipmsg, false); + if (be_clipboard->Lock()) { be_clipboard->Clear(); - BMessage *clipper = be_clipboard->Data(); - clipper->AddMessage ("image/x-be-bitmap", clipmsg); + BMessage* clipper = be_clipboard->Data(); + clipper->AddMessage("image/x-be-bitmap", clipmsg); be_clipboard->Commit(); be_clipboard->Unlock(); } delete clipmsg; - //UndoSelection(); + // UndoSelection(); mainapp->setReady(); } -void CanvasView::CopyToNewLayer () +void +CanvasView::CopyToNewLayer() { -// Copy(); + // Copy(); char name[256]; - strcpy (name, currentLayer()->getName()); - strcat (name, lstring (405, " (detail)")); - addLayer (name); + strcpy(name, currentLayer()->getName()); + strcat(name, lstring(405, " (detail)")); + addLayer(name); extern long pasteX, pasteY, fPasteX, fPasteY; pasteX = fPasteX; pasteY = fPasteY; Paste(); } -void CanvasView::Paste (bool winAct) +void +CanvasView::Paste(bool winAct) { extern bool inPaste, inDrag; extern int DebugLevel; - if (DebugLevel) - { - printf ("%s: Paste (%s); inPaste = %s, inDrag = %s\n", - Window()->Title(), - winAct ? "true" : "false", - inPaste ? "true" : "false", - inDrag ? "true" : "false"); + if (DebugLevel) { + printf( + "%s: Paste (%s); inPaste = %s, inDrag = %s\n", Window()->Title(), + winAct ? "true" : "false", inPaste ? "true" : "false", inDrag ? "true" : "false" + ); } BPoint point; uint32 buttons; - GetMouse (&point, &buttons, true); - if (inPaste) - { - if (winAct) - { - verbose (1, "Window Activated while in Paste()\n"); - } - else - { - ePaste (point, buttons); // Note: These are dummies! + GetMouse(&point, &buttons, true); + if (inPaste) { + if (winAct) { + verbose(1, "Window Activated while in Paste()\n"); + } else { + ePaste(point, buttons); // Note: These are dummies! return; } } - extern BBitmap *clip; + extern BBitmap* clip; extern long pasteX, pasteY; - if (!clip) - { - if (be_clipboard->Lock()) - { - BMessage *clipper = be_clipboard->Data(); + if (!clip) { + if (be_clipboard->Lock()) { + BMessage* clipper = be_clipboard->Data(); BMessage clipmsg; - if (clipper->FindMessage ("image/x-be-bitmap", &clipmsg) == B_OK) - { - clip = (BBitmap *) BBitmap::Instantiate (&clipmsg); - if (!clip) - { + if (clipper->FindMessage("image/x-be-bitmap", &clipmsg) == B_OK) { + clip = (BBitmap*)BBitmap::Instantiate(&clipmsg); + if (!clip) { be_clipboard->Unlock(); return; } - } - else - { + } else { be_clipboard->Unlock(); return; } } } -// if (!winAct) // dunno why I did this. Hmmm. It breaks cross-window pastes - // and drops from Tracker - 1dec2000 - SetupUndo (M_DRAW); + // if (!winAct) // dunno why I did this. Hmmm. It breaks cross-window pastes + // and drops from Tracker - 1dec2000 + SetupUndo(M_DRAW); currentLayer()->Lock(); clip->Lock(); prevPaste = clip->Bounds(); delete cutbg; - cutbg = new BBitmap (prevPaste, B_RGBA32, true); - cutView = new SView (prevPaste, "CutView", uint32 (NULL), uint32 (NULL)); + cutbg = new BBitmap(prevPaste, B_RGBA32, true); + cutView = new SView(prevPaste, "CutView", uint32(NULL), uint32(NULL)); cutbg->Lock(); - cutbg->AddChild (cutView); - cutView->DrawBitmap (currentLayer(), BPoint (-point.x - pasteX, -point.y - pasteY)); + cutbg->AddChild(cutView); + cutView->DrawBitmap(currentLayer(), BPoint(-point.x - pasteX, -point.y - pasteY)); cutbg->Unlock(); clip->Unlock(); inPaste = true; - prevPaste.OffsetTo (point.x + pasteX, point.y + pasteY); + prevPaste.OffsetTo(point.x + pasteX, point.y + pasteY); Invalidate(); Window()->UpdateIfNeeded(); - if (inDrag && !winAct) - { - verbose (1, "Drag in window\n"); + if (inDrag && !winAct) { + verbose(1, "Drag in window\n"); currentLayer()->Lock(); - AddWithAlpha (clip, currentLayer(), int (point.x + pasteX), int (point.y + pasteY)); + AddWithAlpha(clip, currentLayer(), int(point.x + pasteX), int(point.y + pasteY)); inPaste = false; - //ePaste (point, buttons); - } - else if (inDrag) - { + // ePaste (point, buttons); + } else if (inDrag) { extern int DebugLevel; if (DebugLevel >= 1) - printf ("%s... Drag to ext. window\n", Window()->Title()); + printf("%s... Drag to ext. window\n", Window()->Title()); currentLayer()->Lock(); - AddWithAlpha (clip, currentLayer(), int (point.x + pasteX), int (point.y + pasteY)); - ePaste (point, buttons); + AddWithAlpha(clip, currentLayer(), int(point.x + pasteX), int(point.y + pasteY)); + ePaste(point, buttons); inPaste = false; - } - else if (winAct) - { - verbose (2, "WinAct\n"); - } - else - { + } else if (winAct) { + verbose(2, "WinAct\n"); + } else { // printf ("Copy/Paste\n"); - ePasteM (point); + ePasteM(point); } inDrag = false; currentLayer()->Unlock(); } -void CanvasView::ePaste (BPoint /* point */, uint32 buttons) +void +CanvasView::ePaste(BPoint /* point */, uint32 buttons) { - verbose (1, "ePaste\n"); + verbose(1, "ePaste\n"); extern bool inPaste; inPaste = false; fMouseDown = false; -// SetupUndo (M_DRAW); - if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) // Bail out! + // SetupUndo (M_DRAW); + if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) // Bail out! { - //FastCopy (cutbg, currentLayer()); - //memcpy (currentLayer()->Bits(), cutbg->Bits(), currentLayer()->BitsLength()); + // FastCopy (cutbg, currentLayer()); + // memcpy (currentLayer()->Bits(), cutbg->Bits(), currentLayer()->BitsLength()); currentLayer()->Lock(); - drawView->DrawBitmap (cutbg, prevPaste.LeftTop()); + drawView->DrawBitmap(cutbg, prevPaste.LeftTop()); currentLayer()->Unlock(); } - cutbg->RemoveChild (cutView); + cutbg->RemoveChild(cutView); delete cutbg; cutbg = NULL; delete cutView; Invalidate(); } -void CanvasView::ePasteM (BPoint point) +void +CanvasView::ePasteM(BPoint point) { extern long pasteX, pasteY; - extern BBitmap *clip; + extern BBitmap* clip; if (!cutbg) return; cutbg->Lock(); @@ -5501,45 +5307,44 @@ void CanvasView::ePasteM (BPoint point) currentLayer()->Lock(); // printf ("cutbg = %p, clip = %p\n", cutbg, clip); // printf ("point = (%.3f, %.3f), paste = (%li, %li)\n", point.x, point.y, pasteX, pasteY); - //FastCopy (cutbg, currentLayer()); - //memcpy (currentLayer()->Bits(), cutbg->Bits(), currentLayer()->BitsLength()); - drawView->DrawBitmap (cutbg, prevPaste.LeftTop()); - cutView->DrawBitmap (currentLayer(), BPoint (-point.x - pasteX, -point.y - pasteY)); - AddWithAlpha (clip, currentLayer(), int (point.x + pasteX), int (point.y + pasteY)); - BRect pasteRect = BRect (int (point.x + pasteX), int (point.y + pasteY), - int (point.x + pasteX + clip->Bounds().right), int (point.y + pasteY + clip->Bounds().bottom)); - Invalidate (prevPaste | pasteRect); + // FastCopy (cutbg, currentLayer()); + // memcpy (currentLayer()->Bits(), cutbg->Bits(), currentLayer()->BitsLength()); + drawView->DrawBitmap(cutbg, prevPaste.LeftTop()); + cutView->DrawBitmap(currentLayer(), BPoint(-point.x - pasteX, -point.y - pasteY)); + AddWithAlpha(clip, currentLayer(), int(point.x + pasteX), int(point.y + pasteY)); + BRect pasteRect = BRect( + int(point.x + pasteX), int(point.y + pasteY), int(point.x + pasteX + clip->Bounds().right), + int(point.y + pasteY + clip->Bounds().bottom) + ); + Invalidate(prevPaste | pasteRect); prevPaste = pasteRect; currentLayer()->Unlock(); clip->Unlock(); cutbg->Unlock(); } -status_t GetExportingTranslators (BMessage *inHere) +status_t +GetExportingTranslators(BMessage* inHere) { - BTranslatorRoster *r = BTranslatorRoster::Default(); - translator_id *trans; + BTranslatorRoster* r = BTranslatorRoster::Default(); + translator_id* trans; int32 count; - if (r->GetAllTranslators (&trans, &count)) - { + if (r->GetAllTranslators(&trans, &count)) { return B_ERROR; } /* find out which of them can export for us */ int32 actuals = 0; - for (int ix = 0; ix < count; ix++) - { + for (int ix = 0; ix < count; ix++) { /* they have to have B_TRANSLATOR_BITMAP among inputs */ - const translation_format *formats; + const translation_format* formats; int32 nInput; - if (r->GetInputFormats (trans[ix], &formats, &nInput)) - { + if (r->GetInputFormats(trans[ix], &formats, &nInput)) { continue; } - for (int iy = 0; iy < nInput; iy++) - { - if (formats[iy].type == B_TRANSLATOR_BITMAP) - { /* using goto avoids pesky flag variables! */ + for (int iy = 0; iy < nInput; iy++) { + if (formats[iy].type == + B_TRANSLATOR_BITMAP) { /* using goto avoids pesky flag variables! */ goto do_this_translator; } } @@ -5548,21 +5353,18 @@ status_t GetExportingTranslators (BMessage *inHere) do_this_translator: /* figure out what the Translator can write */ int32 nOutput; - if (r->GetOutputFormats (trans[ix], &formats, &nOutput)) - { + if (r->GetOutputFormats(trans[ix], &formats, &nOutput)) { continue; } /* add everything besides B_TRANSLATOR_BITMAP to outputs */ - inHere->AddInt32 ("be:_translator", trans[ix]); - for (int iy = 0; iy < nOutput; iy++) - { - if (formats[iy].type != B_TRANSLATOR_BITMAP) - { - inHere->AddString ("be:types", formats[iy].MIME); - inHere->AddString ("be:filetypes", formats[iy].MIME); - inHere->AddString ("be:type_descriptions", formats[iy].name); - inHere->AddInt32 ("be:_format", formats[iy].type); + inHere->AddInt32("be:_translator", trans[ix]); + for (int iy = 0; iy < nOutput; iy++) { + if (formats[iy].type != B_TRANSLATOR_BITMAP) { + inHere->AddString("be:types", formats[iy].MIME); + inHere->AddString("be:filetypes", formats[iy].MIME); + inHere->AddString("be:type_descriptions", formats[iy].name); + inHere->AddInt32("be:_format", formats[iy].type); actuals++; } } @@ -5574,29 +5376,26 @@ status_t GetExportingTranslators (BMessage *inHere) return B_OK; } -uint32 TypeCodeForMIME (const char *MIME) +uint32 +TypeCodeForMIME(const char* MIME) { - BTranslatorRoster *r = BTranslatorRoster::Default(); - translator_id *trans; + BTranslatorRoster* r = BTranslatorRoster::Default(); + translator_id* trans; int32 count; - if (r->GetAllTranslators (&trans, &count)) - { + if (r->GetAllTranslators(&trans, &count)) { return B_ERROR; } - for (int ix = 0; ix < count; ix++) - { - const translation_format *format_list = NULL; + for (int ix = 0; ix < count; ix++) { + const translation_format* format_list = NULL; int32 fmt_count; - if (B_OK <= BTranslatorRoster::Default()->GetInputFormats (trans[ix], &format_list, &fmt_count)) - { - for (int iy = 0; iy < fmt_count; iy++) - { - if (!strcasecmp (format_list[iy].MIME, MIME)) - { + if (B_OK <= + BTranslatorRoster::Default()->GetInputFormats(trans[ix], &format_list, &fmt_count)) { + for (int iy = 0; iy < fmt_count; iy++) { + if (!strcasecmp(format_list[iy].MIME, MIME)) { uint32 type_code = format_list[iy].type; // delete [] format_list; - delete [] trans; + delete[] trans; return type_code; } } @@ -5604,86 +5403,88 @@ uint32 TypeCodeForMIME (const char *MIME) // delete [] format_list; } - delete [] trans; + delete[] trans; return 0; } -#if defined (OLD_DRAG) +#if defined(OLD_DRAG) -void CanvasView::eDrag (BPoint point, uint32 buttons) +void +CanvasView::eDrag(BPoint point, uint32 buttons) { - extern BBitmap *clip; + extern BBitmap* clip; extern long pasteX, pasteY; extern bool inPaste, inDrag; if (!cutbg) - cutbg = new BBitmap (currentLayer()->Bounds(), B_RGBA32); + cutbg = new BBitmap(currentLayer()->Bounds(), B_RGBA32); inPaste = true; cutbg->Lock(); clip->Lock(); BRect clipBounds = clip->Bounds(); - bbits = (uchar *) currentLayer()->Bits(); + bbits = (uchar*)currentLayer()->Bits(); bbpr = currentLayer()->BytesPerRow(); - tbits = (uchar *) clip->Bits(); + tbits = (uchar*)clip->Bits(); tbpr = clip->BytesPerRow(); bwi = fCanvasFrame.Width(); bhi = fCanvasFrame.Height(); twi = clipBounds.Width(); thi = clipBounds.Height(); - uchar *bgbits = (uchar *) cutbg->Bits(); + uchar* bgbits = (uchar*)cutbg->Bits(); ulong len = currentLayer()->BitsLength(); - memcpy (bgbits, bbits, len); + memcpy(bgbits, bbits, len); BPoint prevpoint = point; BRect frame = fCanvasFrame; BRect dragRect = clipBounds; - dragRect.OffsetTo (point.x + pasteX + 8/fScale, point.y + pasteY + 8/fScale); // + 8 ?! + dragRect.OffsetTo(point.x + pasteX + 8 / fScale, point.y + pasteY + 8 / fScale); // + 8 ?! dragRect.left *= fScale; dragRect.top *= fScale; dragRect.right *= fScale; dragRect.bottom *= fScale; inDrag = true; -/* BBitmap *dragmap = new BBitmap (clipBounds, B_RGBA32); - uint32 *dbits = ((uint32 *) dragmap->Bits()) - 1; - uint32 *cbits = ((uint32 *) clip->Bits()) - 1; - uint32 transparent = (B_TRANSPARENT_32_BIT.red << 24) + (B_TRANSPARENT_32_BIT.green << 16) - + (B_TRANSPARENT_32_BIT.blue << 8) + (B_TRANSPARENT_32_BIT.alpha); - for (uint32 i = 0; i < clip->BitsLength()/4; i++) - { - uint32 pixel = *(++cbits); - if (pixel & 0xFF) - *(++dbits) = pixel; - else - *(++dbits) = transparent; - } - SetDrawingMode (B_OP_OVER); - DragMessage (new BMessage ('drag'), dragmap, BPoint (pasteX, pasteY)); -*/ DragMessage (new BMessage ('drag'), dragRect); - while (buttons) - { - if (point != prevpoint) - { - memcpy (bbits, bgbits, len); - Invalidate (prevPaste); - FastAddWithAlpha (point.x + pasteX, point.y + pasteY); - prevPaste = BRect (point.x + pasteX, point.y + pasteY, - point.x + pasteX + clipBounds.right, point.y + pasteY + clipBounds.bottom); + /* BBitmap *dragmap = new BBitmap (clipBounds, B_RGBA32); + uint32 *dbits = ((uint32 *) dragmap->Bits()) - 1; + uint32 *cbits = ((uint32 *) clip->Bits()) - 1; + uint32 transparent = (B_TRANSPARENT_32_BIT.red << 24) + (B_TRANSPARENT_32_BIT.green << 16) + + (B_TRANSPARENT_32_BIT.blue << 8) + (B_TRANSPARENT_32_BIT.alpha); + for (uint32 i = 0; i < clip->BitsLength()/4; i++) + { + uint32 pixel = *(++cbits); + if (pixel & 0xFF) + *(++dbits) = pixel; + else + *(++dbits) = transparent; + } + SetDrawingMode (B_OP_OVER); + DragMessage (new BMessage ('drag'), dragmap, BPoint (pasteX, pasteY)); + */ + DragMessage(new BMessage('drag'), dragRect); + while (buttons) { + if (point != prevpoint) { + memcpy(bbits, bgbits, len); + Invalidate(prevPaste); + FastAddWithAlpha(point.x + pasteX, point.y + pasteY); + prevPaste = BRect( + point.x + pasteX, point.y + pasteY, point.x + pasteX + clipBounds.right, + point.y + pasteY + clipBounds.bottom + ); drawView->Sync(); - Invalidate (prevPaste); + Invalidate(prevPaste); myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); } BRect bounds = Bounds(); if (point.x > bounds.right && bounds.right < frame.right) - ScrollBy (point.x - bounds.right, 0); + ScrollBy(point.x - bounds.right, 0); if (point.x < bounds.left && bounds.left > 0) - ScrollBy (point.x - bounds.left, 0); + ScrollBy(point.x - bounds.left, 0); if (point.y > bounds.bottom && bounds.bottom < frame.bottom) - ScrollBy (0, point.y - bounds.bottom); + ScrollBy(0, point.y - bounds.bottom); if (point.y < bounds.top && bounds.top > 0) - ScrollBy (0, point.y - bounds.top); - snooze (20000); + ScrollBy(0, point.y - bounds.top); + snooze(20000); prevpoint = point; - GetMouse (&point, &buttons, true); + GetMouse(&point, &buttons, true); } clip->Unlock(); cutbg->Unlock(); @@ -5693,13 +5494,14 @@ void CanvasView::eDrag (BPoint point, uint32 buttons) #else -void CanvasView::eDrag (BPoint point, uint32 buttons) +void +CanvasView::eDrag(BPoint point, uint32 buttons) { - extern BBitmap *clip; + extern BBitmap* clip; clip->Lock(); extern long pasteX, pasteY; BRect dragRect = clip->Bounds(); - dragRect.OffsetTo (point.x + pasteX + 8/fScale, point.y + pasteY + 8/fScale); // + 8 ?! + dragRect.OffsetTo(point.x + pasteX + 8 / fScale, point.y + pasteY + 8 / fScale); // + 8 ?! dragRect.left *= fScale; dragRect.top *= fScale; dragRect.right *= fScale; @@ -5708,317 +5510,286 @@ void CanvasView::eDrag (BPoint point, uint32 buttons) { // Otherwise: Few pixels off!! (BeOS bug...) - extern Becasso *mainapp; + extern Becasso* mainapp; mainapp->setHand(); - BPoint sp = ConvertToScreen (BPoint (point.x*fScale, point.y*fScale)); - set_mouse_position (int (sp.x + 1), int (sp.y)); - set_mouse_position (int (sp.x), int (sp.y)); + BPoint sp = ConvertToScreen(BPoint(point.x * fScale, point.y * fScale)); + set_mouse_position(int(sp.x + 1), int(sp.y)); + set_mouse_position(int(sp.x), int(sp.y)); } - BMessage *dragMessage = new BMessage (B_SIMPLE_DATA); + BMessage* dragMessage = new BMessage(B_SIMPLE_DATA); bool tmp = true; - dragMessage->AddBool ("becasso", tmp); - BBitmap *dragmap = new BBitmap (clipBounds, B_RGBA32, false); - memcpy (dragmap->Bits(), clip->Bits(), clip->BitsLength()); - //dragMessage->AddRect ("be:_frame", clip->Bounds()); - dragMessage->AddPointer ("be:_bitmap_ptr", clip); - dragMessage->AddInt32 ("be:actions", B_COPY_TARGET); - dragMessage->AddInt32 ("be:actions", B_TRASH_TARGET); + dragMessage->AddBool("becasso", tmp); + BBitmap* dragmap = new BBitmap(clipBounds, B_RGBA32, false); + memcpy(dragmap->Bits(), clip->Bits(), clip->BitsLength()); + // dragMessage->AddRect ("be:_frame", clip->Bounds()); + dragMessage->AddPointer("be:_bitmap_ptr", clip); + dragMessage->AddInt32("be:actions", B_COPY_TARGET); + dragMessage->AddInt32("be:actions", B_TRASH_TARGET); char clipname[B_FILE_NAME_LENGTH]; - CanvasWindow *myWindow = dynamic_cast (Window()); - strcpy (clipname, myWindow->FileName()); - strcat (clipname, " Clip"); - dragMessage->AddString ("be:clip_name", clipname); - dragMessage->AddString ("be:types", B_FILE_MIME_TYPE); - GetExportingTranslators (dragMessage); + CanvasWindow* myWindow = dynamic_cast(Window()); + strcpy(clipname, myWindow->FileName()); + strcat(clipname, " Clip"); + dragMessage->AddString("be:clip_name", clipname); + dragMessage->AddString("be:types", B_FILE_MIME_TYPE); + GetExportingTranslators(dragMessage); - extern long fPasteX, fPasteY; // These names suck, I know. -// printf ("(%ld, %ld), (%ld, %ld)\n", pasteX, pasteY, fPasteX, fPasteY); + extern long fPasteX, fPasteY; // These names suck, I know. + // printf ("(%ld, %ld), (%ld, %ld)\n", pasteX, pasteY, fPasteX, fPasteY); extern int DebugLevel; - if (DebugLevel > 2) - { - printf ("Dragging Message:\n"); + if (DebugLevel > 2) { + printf("Dragging Message:\n"); dragMessage->PrintToStream(); } - if ((fCurrentLayer == fNumLayers - 1) // i.e. Top layer is active - && (fScale == 1)) - { + if ((fCurrentLayer == fNumLayers - 1) // i.e. Top layer is active + && (fScale == 1)) { // printf ("Top layer active...\n"); - DragMessage (dragMessage, dragmap, B_OP_ALPHA, BPoint (-fPasteX, -fPasteY)); - } - else - { - SetupUndo (M_DRAW); + DragMessage(dragMessage, dragmap, B_OP_ALPHA, BPoint(-fPasteX, -fPasteY)); + } else { + SetupUndo(M_DRAW); extern bool inPaste, inDrag; delete cutbg; - cutbg = new BBitmap (clipBounds, B_RGBA32, true); - BView *cutView = new BView (clipBounds, "CutView", uint32 (NULL), uint32 (NULL)); - cutbg->AddChild (cutView); + cutbg = new BBitmap(clipBounds, B_RGBA32, true); + BView* cutView = new BView(clipBounds, "CutView", uint32(NULL), uint32(NULL)); + cutbg->AddChild(cutView); cutbg->Lock(); // Setup stuff for FastAddWithAlpha - bbits = (uchar *) currentLayer()->Bits(); + bbits = (uchar*)currentLayer()->Bits(); bbpr = currentLayer()->BytesPerRow(); - tbits = (uchar *) clip->Bits(); + tbits = (uchar*)clip->Bits(); tbpr = clip->BytesPerRow(); bwi = fCanvasFrame.IntegerWidth(); bhi = fCanvasFrame.IntegerHeight(); twi = clipBounds.IntegerWidth(); thi = clipBounds.IntegerHeight(); - dragMessage->AddBool ("not_top", tmp); - DragMessage (dragMessage, dragRect); + dragMessage->AddBool("not_top", tmp); + DragMessage(dragMessage, dragRect); inPaste = true; inDrag = true; - BBitmap *cl = currentLayer(); - cutView->DrawBitmap (cl, BPoint (-point.x - pasteX, -point.y - pasteY)); - drawView->SetDrawingMode (B_OP_COPY); - // drawView->DrawBitmap (cutbg, BPoint (point.x + pasteX, point.y + pasteY)); - // Invalidate(); + BBitmap* cl = currentLayer(); + cutView->DrawBitmap(cl, BPoint(-point.x - pasteX, -point.y - pasteY)); + drawView->SetDrawingMode(B_OP_COPY); + // drawView->DrawBitmap (cutbg, BPoint (point.x + pasteX, point.y + pasteY)); + // Invalidate(); BRect pasteRect; prevPaste = fCanvasFrame; BPoint prevpoint = point; bool invalidate = false; - while (buttons) - { - if (point != prevpoint) - { - drawView->DrawBitmap (cutbg, BPoint (prevpoint.x + pasteX, prevpoint.y + pasteY)); + while (buttons) { + if (point != prevpoint) { + drawView->DrawBitmap(cutbg, BPoint(prevpoint.x + pasteX, prevpoint.y + pasteY)); drawView->Sync(); - cutView->DrawBitmap (cl, BPoint (-point.x - pasteX, -point.y - pasteY)); + cutView->DrawBitmap(cl, BPoint(-point.x - pasteX, -point.y - pasteY)); cutView->Sync(); - FastAddWithAlpha (int (point.x + pasteX), int (point.y + pasteY)); - pasteRect = BRect (int (point.x + pasteX), int (point.y + pasteY), - int (point.x + pasteX + clipBounds.right), int (point.y + pasteY + clipBounds.bottom)); - Invalidate (prevPaste | prevPaste); + FastAddWithAlpha(int(point.x + pasteX), int(point.y + pasteY)); + pasteRect = BRect( + int(point.x + pasteX), int(point.y + pasteY), + int(point.x + pasteX + clipBounds.right), + int(point.y + pasteY + clipBounds.bottom) + ); + Invalidate(prevPaste | prevPaste); prevPaste = pasteRect; myWindow->Lock(); myWindow->posview->Pulse(); myWindow->Unlock(); invalidate = true; - } - else if (invalidate) - { + } else if (invalidate) { Invalidate(); invalidate = false; } - ScrollIfNeeded (point); - snooze (20000); + ScrollIfNeeded(point); + snooze(20000); prevpoint = point; - GetMouse (&point, &buttons, true); + GetMouse(&point, &buttons, true); } - cutbg->RemoveChild (cutView); + cutbg->RemoveChild(cutView); delete cutView; delete cutbg; cutbg = NULL; clip->Unlock(); inPaste = false; - // inDrag = false; + // inDrag = false; Invalidate(); } } #endif -void CanvasView::SelectAll (bool menu) +void +CanvasView::SelectAll(bool menu) { - if (menu) - { - if (filterOpen || transformerOpen || generatorOpen) - { + if (menu) { + if (filterOpen || transformerOpen || generatorOpen) { beep(); return; } } - SetupUndo (M_SELECT); + SetupUndo(M_SELECT); selection->Lock(); - selectionView->SetDrawingMode (B_OP_COPY); - selectionView->SetHighColor (SELECT_FULL); - selectionView->FillRect (selection->Bounds()); + selectionView->SetDrawingMode(B_OP_COPY); + selectionView->SetHighColor(SELECT_FULL); + selectionView->FillRect(selection->Bounds()); selectionView->Sync(); selection->Unlock(); Invalidate(); Window()->UpdateIfNeeded(); } -void CanvasView::UndoSelection (bool menu) +void +CanvasView::UndoSelection(bool menu) // Note: This is `Deselect All'. { - if (menu) - { - if (filterOpen || transformerOpen || generatorOpen) - { + if (menu) { + if (filterOpen || transformerOpen || generatorOpen) { beep(); return; } } - SetupUndo (M_SELECT); + SetupUndo(M_SELECT); selection->Lock(); - selectionView->SetDrawingMode (B_OP_COPY); - selectionView->SetLowColor (SELECT_NONE); - selectionView->FillRect (selection->Bounds(), B_SOLID_LOW); + selectionView->SetDrawingMode(B_OP_COPY); + selectionView->SetLowColor(SELECT_NONE); + selectionView->FillRect(selection->Bounds(), B_SOLID_LOW); selectionView->Sync(); selection->Unlock(); selchanged = false; sel = false; myWindow->Lock(); - myWindow->setMenuItem (B_CUT, false); - myWindow->setMenuItem (B_COPY, false); - myWindow->setMenuItem ('csel', false); - myWindow->setMenuItem ('sund', false); - myWindow->setMenuItem ('sinv', false); + myWindow->setMenuItem(B_CUT, false); + myWindow->setMenuItem(B_COPY, false); + myWindow->setMenuItem('csel', false); + myWindow->setMenuItem('sund', false); + myWindow->setMenuItem('sinv', false); myWindow->Unlock(); Invalidate(); Window()->UpdateIfNeeded(); } ////////////////////////////// -#if defined (__POWERPC__) -# pragma optimization_level 4 +#if defined(__POWERPC__) +#pragma optimization_level 4 #endif -void CanvasView::ChannelToSelection (uint32 what, bool menu) +void +CanvasView::ChannelToSelection(uint32 what, bool menu) { - if (menu) - { - if (filterOpen || transformerOpen || generatorOpen) - { + if (menu) { + if (filterOpen || transformerOpen || generatorOpen) { beep(); return; } } - SetupUndo (M_SELECT); + SetupUndo(M_SELECT); selection->Lock(); currentLayer()->Lock(); - grey_pixel *s_data = (grey_pixel *) selection->Bits() - 1; - bgra_pixel *c_data = (bgra_pixel *) currentLayer()->Bits() - 1; + grey_pixel* s_data = (grey_pixel*)selection->Bits() - 1; + bgra_pixel* c_data = (bgra_pixel*)currentLayer()->Bits() - 1; uint32 h = fCanvasFrame.IntegerHeight() + 1; uint32 w = fCanvasFrame.IntegerWidth() + 1; uint32 sbpr = selection->BytesPerRow(); uint32 sdif = sbpr - w; - switch (what) - { + switch (what) { case 'ctsA': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { *(++s_data) = ALPHA(*(++c_data)); } s_data += sdif; } break; case 'ctsR': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { *(++s_data) = RED(*(++c_data)); } s_data += sdif; } break; case 'ctsG': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { *(++s_data) = GREEN(*(++c_data)); } s_data += sdif; } break; case 'ctsB': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { *(++s_data) = BLUE(*(++c_data)); } s_data += sdif; } break; case 'ctsC': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { - *(++s_data) = CYAN(bgra2cmyk (*(++c_data))); + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { + *(++s_data) = CYAN(bgra2cmyk(*(++c_data))); } s_data += sdif; } break; case 'ctsM': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { - *(++s_data) = MAGENTA(bgra2cmyk (*(++c_data))); + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { + *(++s_data) = MAGENTA(bgra2cmyk(*(++c_data))); } s_data += sdif; } break; case 'ctsY': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { - *(++s_data) = YELLOW(bgra2cmyk (*(++c_data))); + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { + *(++s_data) = YELLOW(bgra2cmyk(*(++c_data))); } s_data += sdif; } break; case 'ctsK': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { - *(++s_data) = BLACK(bgra2cmyk (*(++c_data))); + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { + *(++s_data) = BLACK(bgra2cmyk(*(++c_data))); } s_data += sdif; } break; case 'ctsH': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { - hsv_color h = bgra2hsv (*(++c_data)); - *(++s_data) = uchar (h.hue*255/360); + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { + hsv_color h = bgra2hsv(*(++c_data)); + *(++s_data) = uchar(h.hue * 255 / 360); } s_data += sdif; } break; case 'ctsS': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { - hsv_color h = bgra2hsv (*(++c_data)); + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { + hsv_color h = bgra2hsv(*(++c_data)); if (h.hue != HUE_UNDEF) - *(++s_data) = uchar (h.saturation*255); + *(++s_data) = uchar(h.saturation * 255); else - *(++s_data) = uchar (h.value); + *(++s_data) = uchar(h.value); } s_data += sdif; } break; case 'ctsV': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { - hsv_color h = bgra2hsv (*(++c_data)); - *(++s_data) = uchar (h.value*255); + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { + hsv_color h = bgra2hsv(*(++c_data)); + *(++s_data) = uchar(h.value * 255); } s_data += sdif; } break; default: - fprintf (stderr, "ChannelToSelection: Invalid channel\n"); + fprintf(stderr, "ChannelToSelection: Invalid channel\n"); } currentLayer()->Unlock(); selection->Unlock(); @@ -6026,144 +5797,133 @@ void CanvasView::ChannelToSelection (uint32 what, bool menu) Window()->UpdateIfNeeded(); } -void CanvasView::SelectionToChannel (uint32 what) +void +CanvasView::SelectionToChannel(uint32 what) { - SetupUndo (M_DRAW); + SetupUndo(M_DRAW); selection->Lock(); currentLayer()->Lock(); - grey_pixel *s_data = (grey_pixel *) selection->Bits() - 1; - bgra_pixel *c_data = (bgra_pixel *) currentLayer()->Bits() - 1; + grey_pixel* s_data = (grey_pixel*)selection->Bits() - 1; + bgra_pixel* c_data = (bgra_pixel*)currentLayer()->Bits() - 1; uint32 h = fCanvasFrame.IntegerHeight() + 1; uint32 w = fCanvasFrame.IntegerWidth() + 1; uint32 sbpr = selection->BytesPerRow(); uint32 sdif = sbpr - w; - switch (what) - { + switch (what) { case 'stcA': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { *(c_data) = (*(++c_data) & COLOR_MASK) | (*(++s_data) << ALPHA_BPOS); } s_data += sdif; } break; case 'stcR': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { *(c_data) = (*(++c_data) & IRED_MASK) | (*(++s_data) << RED_BPOS); } s_data += sdif; } break; case 'stcG': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { *(c_data) = (*(++c_data) & IGREEN_MASK) | (*(++s_data) << GREEN_BPOS); } s_data += sdif; } break; case 'stcB': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { *(c_data) = (*(++c_data) & IBLUE_MASK) | (*(++s_data) << BLUE_BPOS); } s_data += sdif; } break; case 'stcC': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { bgra_pixel p = *(++c_data); - *(c_data) = ((cmyk2bgra ((bgra2cmyk (p) & ICYAN_MASK) | (*(++s_data) << CYAN_BPOS))) & COLOR_MASK) | (p & ALPHA_MASK); + *(c_data) = ((cmyk2bgra((bgra2cmyk(p) & ICYAN_MASK) | (*(++s_data) << CYAN_BPOS))) & + COLOR_MASK) | + (p & ALPHA_MASK); } s_data += sdif; } break; case 'stcM': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { bgra_pixel p = *(++c_data); - *(c_data) = ((cmyk2bgra ((bgra2cmyk (p) & IMAGENTA_MASK) | (*(++s_data) << MAGENTA_BPOS))) & COLOR_MASK) | (p & ALPHA_MASK); + *(c_data) = + ((cmyk2bgra((bgra2cmyk(p) & IMAGENTA_MASK) | (*(++s_data) << MAGENTA_BPOS))) & + COLOR_MASK) | + (p & ALPHA_MASK); } s_data += sdif; } break; case 'stcY': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { bgra_pixel p = *(++c_data); - *(c_data) = ((cmyk2bgra ((bgra2cmyk (p) & IYELLOW_MASK) | (*(++s_data) << YELLOW_BPOS))) & COLOR_MASK) | (p & ALPHA_MASK); + *(c_data) = + ((cmyk2bgra((bgra2cmyk(p) & IYELLOW_MASK) | (*(++s_data) << YELLOW_BPOS))) & + COLOR_MASK) | + (p & ALPHA_MASK); } s_data += sdif; } break; case 'stcK': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { bgra_pixel p = *(++c_data); - *(c_data) = ((cmyk2bgra ((bgra2cmyk (p) & IBLACK_MASK) | (*(++s_data) << BLACK_BPOS))) & COLOR_MASK) | (p & ALPHA_MASK); - } + *(c_data) = + ((cmyk2bgra((bgra2cmyk(p) & IBLACK_MASK) | (*(++s_data) << BLACK_BPOS))) & + COLOR_MASK) | + (p & ALPHA_MASK); + } s_data += sdif; } break; case 'stcH': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { - hsv_color h = bgra2hsv (*(++c_data)); - h.hue = 360.0*(*(++s_data))/255; - *(c_data) = hsv2bgra (h); + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { + hsv_color h = bgra2hsv(*(++c_data)); + h.hue = 360.0 * (*(++s_data)) / 255; + *(c_data) = hsv2bgra(h); } s_data += sdif; } break; case 'stcS': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { - hsv_color h = bgra2hsv (*(++c_data)); + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { + hsv_color h = bgra2hsv(*(++c_data)); if (h.hue != HUE_UNDEF) - h.saturation = *(++s_data)/255.0; + h.saturation = *(++s_data) / 255.0; else ++s_data; - *(c_data) = hsv2bgra (h); + *(c_data) = hsv2bgra(h); } s_data += sdif; } break; case 'stcV': - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { - hsv_color h = bgra2hsv (*(++c_data)); - h.value = *(++s_data)/255.0; - *(c_data) = hsv2bgra (h); + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { + hsv_color h = bgra2hsv(*(++c_data)); + h.value = *(++s_data) / 255.0; + *(c_data) = hsv2bgra(h); } s_data += sdif; } break; default: - fprintf (stderr, "SelectionToChannel: Invalid channel\n"); + fprintf(stderr, "SelectionToChannel: Invalid channel\n"); } currentLayer()->Unlock(); selection->Unlock(); @@ -6171,25 +5931,24 @@ void CanvasView::SelectionToChannel (uint32 what) Window()->UpdateIfNeeded(); } -rgb_color CanvasView::GuessBackgroundColor () +rgb_color +CanvasView::GuessBackgroundColor() { uint32 r, g, b, a, n; r = g = b = a = 0; currentLayer()->Lock(); - bgra_pixel *c_data = (bgra_pixel *) currentLayer()->Bits() - 1; + bgra_pixel* c_data = (bgra_pixel*)currentLayer()->Bits() - 1; uint32 h = fCanvasFrame.IntegerHeight() + 1; uint32 w = fCanvasFrame.IntegerWidth() + 1; bgra_pixel p; - for (uint32 j = 0; j < w; j++) - { + for (uint32 j = 0; j < w; j++) { p = *(++c_data); b += BLUE(p); g += GREEN(p); r += RED(p); a += ALPHA(p); } - for (uint32 i = 1; i < h - 1; i++) - { + for (uint32 i = 1; i < h - 1; i++) { p = *(++c_data); b += BLUE(p); g += GREEN(p); @@ -6202,8 +5961,7 @@ rgb_color CanvasView::GuessBackgroundColor () r += RED(p); a += ALPHA(p); } - for (uint32 j = 0; j < w; j++) - { + for (uint32 j = 0; j < w; j++) { p = *(++c_data); b += BLUE(p); g += GREEN(p); @@ -6212,39 +5970,36 @@ rgb_color CanvasView::GuessBackgroundColor () } currentLayer()->Unlock(); rgb_color c; - n = 2*w + 2*h - 4; - c.red = r/n; - c.green = g/n; - c.blue = b/n; - c.alpha = a/n; + n = 2 * w + 2 * h - 4; + c.red = r / n; + c.green = g / n; + c.blue = b / n; + c.alpha = a / n; return (c); } -void CanvasView::SelectByColor (rgb_color c, bool menu) +void +CanvasView::SelectByColor(rgb_color c, bool menu) { - if (menu) - { - if (filterOpen || transformerOpen || generatorOpen) - { + if (menu) { + if (filterOpen || transformerOpen || generatorOpen) { beep(); return; } } - SetupUndo (M_SELECT); + SetupUndo(M_SELECT); selection->Lock(); currentLayer()->Lock(); - grey_pixel *s_data = (grey_pixel *) selection->Bits() - 1; - bgra_pixel *c_data = (bgra_pixel *) currentLayer()->Bits() - 1; + grey_pixel* s_data = (grey_pixel*)selection->Bits() - 1; + bgra_pixel* c_data = (bgra_pixel*)currentLayer()->Bits() - 1; uint32 h = fCanvasFrame.IntegerHeight() + 1; uint32 w = fCanvasFrame.IntegerWidth() + 1; uint32 sbpr = selection->BytesPerRow(); uint32 sdif = sbpr - w; - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { bgra_pixel b = *(++c_data); - *(++s_data) = uchar ((255 - diff (c, bgra2rgb (b)))*(ALPHA(b))/255); + *(++s_data) = uchar((255 - diff(c, bgra2rgb(b))) * (ALPHA(b)) / 255); } s_data += sdif; } @@ -6254,50 +6009,54 @@ void CanvasView::SelectByColor (rgb_color c, bool menu) Window()->UpdateIfNeeded(); } -void CanvasView::ColorizeSelection (rgb_color c) +void +CanvasView::ColorizeSelection(rgb_color c) { - SetupUndo (M_DRAW); + SetupUndo(M_DRAW); selection->Lock(); currentLayer()->Lock(); - grey_pixel *s_data = (grey_pixel *) selection->Bits() - 1; - bgra_pixel *c_data = (bgra_pixel *) currentLayer()->Bits() - 1; + grey_pixel* s_data = (grey_pixel*)selection->Bits() - 1; + bgra_pixel* c_data = (bgra_pixel*)currentLayer()->Bits() - 1; uint32 h = fCanvasFrame.IntegerHeight() + 1; uint32 w = fCanvasFrame.IntegerWidth() + 1; uint32 sbpr = selection->BytesPerRow(); uint32 sdif = sbpr - w; - bgra_pixel b = rgb2bgra (c); - for (uint32 i = 0; i < h; i++) - { - for (uint32 j = 0; j < w; j++) - { + bgra_pixel b = rgb2bgra(c); + for (uint32 i = 0; i < h; i++) { + for (uint32 j = 0; j < w; j++) { register bgra_pixel d = *(++c_data); register int sa = *(++s_data); -// register int da = 255 - sa; + // register int da = 255 - sa; b &= COLOR_MASK; b |= (sa << ALPHA_BPOS); -// if (da == 0) // Fully opaque pixel -// { -// *c_data = b; -// } -// else if (da == 255) // Fully transparent pixel -// { -// } -// else -// { -// #if defined (__POWERPC__) -// *c_data = (((((d>>24) *da + (b>>24) *sa)<<16)) & 0xFF000000) | -// (((((d>>16) & 0xFF)*da + ((b>>16) & 0xFF)*sa)<< 8) & 0x00FF0000) | -// ((((d>> 8) & 0xFF)*da + ((b>> 8) & 0xFF)*sa) & 0x0000FF00) | -// //(sa & 0xFF);//(max_c (sa, da) & 0xFF); -// clipchar (sa + int (d & 0xFF)); -// #else -// *c_data = (((((d>>16) & 0xFF)*da + ((b>>16) & 0xFF)*sa)<<16) & 0x00FF0000) | -// (((((d>> 8) & 0xFF)*da + ((b>> 8) & 0xFF)*sa)<< 8) & 0x0000FF00) | -// (((((d ) & 0xFF)*da + ((b ) & 0xFF)*sa) ) & 0x000000FF) | -// (clipchar (sa + int (d >> 24)) << 24); -// #endif -// } - *c_data = pixelblend (d, b); + // if (da == 0) // Fully opaque pixel + // { + // *c_data = b; + // } + // else if (da == 255) // Fully transparent pixel + // { + // } + // else + // { + // #if defined (__POWERPC__) + // *c_data = (((((d>>24) *da + (b>>24) *sa)<<16)) & + // 0xFF000000) | + // (((((d>>16) & 0xFF)*da + ((b>>16) & 0xFF)*sa)<< 8) & + // 0x00FF0000) | + // ((((d>> 8) & 0xFF)*da + ((b>> 8) & 0xFF)*sa) & + // 0x0000FF00) | + // //(sa & 0xFF);//(max_c (sa, da) & 0xFF); + // clipchar (sa + int (d & 0xFF)); + // #else + // *c_data = (((((d>>16) & 0xFF)*da + ((b>>16) & 0xFF)*sa)<<16) & + // 0x00FF0000) | + // (((((d>> 8) & 0xFF)*da + ((b>> 8) & 0xFF)*sa)<< 8) & + // 0x0000FF00) | + // (((((d ) & 0xFF)*da + ((b ) & 0xFF)*sa) ) & + // 0x000000FF) | (clipchar (sa + int (d >> 24)) << 24); + // #endif + // } + *c_data = pixelblend(d, b); } s_data += sdif; } @@ -6307,12 +6066,11 @@ void CanvasView::ColorizeSelection (rgb_color c) Window()->UpdateIfNeeded(); } -void CanvasView::InvertSelection (bool menu) +void +CanvasView::InvertSelection(bool menu) { - if (menu) - { - if (filterOpen || transformerOpen || generatorOpen) - { + if (menu) { + if (filterOpen || transformerOpen || generatorOpen) { beep(); return; } @@ -6320,7 +6078,7 @@ void CanvasView::InvertSelection (bool menu) // SetupUndo (M_SELECT); // Note: This is _so_ easily undone, it's a waste of a valuable undo buffer... selection->Lock(); - uchar *sbits = (uchar *) selection->Bits(); + uchar* sbits = (uchar*)selection->Bits(); for (int i = 0; i < selection->BitsLength(); i++) *sbits++ = 255 - *sbits; sel = true; @@ -6329,7 +6087,8 @@ void CanvasView::InvertSelection (bool menu) Window()->UpdateIfNeeded(); } -void CanvasView::FastAddWithAlpha (long x, long y, int strength) +void +CanvasView::FastAddWithAlpha(long x, long y, int strength) // Note: Setup tbits, tbpr, bbits, bbpr, twi, thi, bwi and bhi before you enter here! // tbits = source->Bits(); // (32bit brush/clip bitmap) // tbpr = source->BytesPerRow(); @@ -6343,199 +6102,204 @@ void CanvasView::FastAddWithAlpha (long x, long y, int strength) // Alpha = opacity! { // fprintf (stderr, "CanvasView::FastAddWithAlpha... "); fflush (stderr); - clock_t start, end; + clock_t start, end; start = clock(); - uint32 *src_data = (uint32 *) tbits; - uint32 *dest_data = (uint32 *) bbits; - uint32 tlpr = tbpr/4; - uint32 blpr = bbpr/4; - if ((x + twi <= 0) || (x > bwi) || (y + thi <= 0) || (y > bhi) || !strength) - { + uint32* src_data = (uint32*)tbits; + uint32* dest_data = (uint32*)bbits; + uint32 tlpr = tbpr / 4; + uint32 blpr = bbpr / 4; + if ((x + twi <= 0) || (x > bwi) || (y + thi <= 0) || (y > bhi) || !strength) { // printf ("Totally out of bounds - returning\n"); return; } // Clipping - int minx = max_c (x, 0); - int maxx = min_c (x + twi + 1, bwi + 1); - int miny = max_c (y, 0); - int maxy = min_c (y + thi + 1, bhi + 1); + int minx = max_c(x, 0); + int maxx = min_c(x + twi + 1, bwi + 1); + int miny = max_c(y, 0); + int maxy = min_c(y + thi + 1, bhi + 1); ulong src_bprdiff = tlpr - (maxx - minx); ulong dest_bprdiff = blpr - (maxx - minx); if (y < 0) - src_data -= y*tlpr; + src_data -= y * tlpr; if (x < 0) src_data -= x; - dest_data += miny*blpr + minx; + dest_data += miny * blpr + minx; -// printf ("Alpha_src = %i, Alpha_dest = %i\n", src_data[3], dest_data[3]); // ON PPC! - dest_data--; // Note: On PPC, pre-increment is faster. + // printf ("Alpha_src = %i, Alpha_dest = %i\n", src_data[3], dest_data[3]); // ON PPC! + dest_data--; // Note: On PPC, pre-increment is faster. src_data--; - if (strength == 255) - { - for (int j = miny; j < maxy; j++) - { - for (int i = minx; i < maxx; i++) - { -#if defined (__POWERPC__) + if (strength == 255) { + for (int j = miny; j < maxy; j++) { + for (int i = minx; i < maxx; i++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); register int sa = srcpixel & 0xFF; register int da = /*destpixel & 0xFF;*/ 255 - sa; register int ta = /*sa + da;*/ 255; - if (sa == 255 || /*da == 0*/ !(destpixel & 0xFF)) // Fully opaque + if (sa == 255 || /*da == 0*/ !(destpixel & 0xFF)) // Fully opaque { *dest_data = srcpixel; - } - else if (sa == 0) // Fully transparent - { - } - else + } else if (sa == 0) // Fully transparent { -// *dest_data = ((((((destpixel>>24) )*da + ((srcpixel>>24) )*sa)/ta)<<24) & 0xFF000000) | -// ((((((destpixel>>16) & 0xFF)*da + ((srcpixel>>16) & 0xFF)*sa)/ta)<<16) & 0x00FF0000) | -// ((((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> 8) & 0xFF)*sa)/ta)<< 8) & 0x0000FF00) | -// clipchar (sa + int (destpixel & 0xFF)); - *dest_data = ((((destpixel & 0xFF000000)/ta)*da + ((srcpixel & 0xFF000000)/ta)*sa) & 0xFF000000) | - ((((destpixel & 0x00FF0000)/ta)*da + ((srcpixel & 0x00FF0000)/ta)*sa) & 0x00FF0000) | - (((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa))/ta) & 0x0000FF00) | - clipchar (sa + int (destpixel & 0xFF)); - //clipchar (ta); + } else { + // *dest_data = ((((((destpixel>>24) )*da + + //((srcpixel>>24) )*sa)/ta)<<24) & 0xFF000000) | + // ((((((destpixel>>16) & 0xFF)*da + + //((srcpixel>>16) & 0xFF)*sa)/ta)<<16) & 0x00FF0000) | + // ((((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> + // 8) & 0xFF)*sa)/ta)<< 8) & 0x0000FF00) | + // clipchar (sa + int (destpixel & 0xFF)); + *dest_data = + ((((destpixel & 0xFF000000) / ta) * da + ((srcpixel & 0xFF000000) / ta) * sa + ) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) / ta) * da + ((srcpixel & 0x00FF0000) / ta) * sa + ) & + 0x00FF0000) | + (((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa)) / ta) & + 0x0000FF00) | + clipchar(sa + int(destpixel & 0xFF)); + // clipchar (ta); } #else register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); register int sa = srcpixel >> 24; - register int da = destpixel >> 24; // 255 - sa; - register int ta = sa + da; // ta = 255; - if (sa == 255 || da == 0 /* !(destpixel & 0xFF000000) */ ) // Fully opaque + register int da = destpixel >> 24; // 255 - sa; + register int ta = sa + da; // ta = 255; + if (sa == 255 || da == 0 /* !(destpixel & 0xFF000000) */) // Fully opaque { *dest_data = srcpixel; - } - else if (sa == 0) // Fully transparent - { - } - else + } else if (sa == 0) // Fully transparent { - -// *dest_data = ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/255) & 0x0000FF00) | -// ((((destpixel & 0x00FF00FF)*da + (srcpixel & 0x00FF00FF)*sa)/255) & 0x00FF00FF) | -// (clipchar (sa + int (destpixel >> 24)) << 24); - - *dest_data = ((((((destpixel & 0x00FF0000) >> 1)*da + ((srcpixel & 0x00FF0000) >> 1)*sa)/ta) << 1) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/ta) & 0x0000FF00) | - ((((destpixel & 0x000000FF)*da + (srcpixel & 0x000000FF)*sa)/ta) & 0x000000FF) | - // (clipchar (ta) << 24); - (clipchar (sa + int (destpixel >> 24)) << 24); -// ((max_c (sa, destpixel >> 24)) << 24); + } else { + + // *dest_data = ((((destpixel & 0x0000FF00)*da + (srcpixel & + // 0x0000FF00)*sa)/255) & 0x0000FF00) | + // ((((destpixel & 0x00FF00FF)*da + (srcpixel & + // 0x00FF00FF)*sa)/255) & 0x00FF00FF) | + // (clipchar (sa + int (destpixel >> 24)) << 24); + + *dest_data = + ((((((destpixel & 0x00FF0000) >> 1) * da + + ((srcpixel & 0x00FF0000) >> 1) * sa) / + ta) + << 1) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) / ta) & + 0x0000FF00) | + ((((destpixel & 0x000000FF) * da + (srcpixel & 0x000000FF) * sa) / ta) & + 0x000000FF) | + // (clipchar (ta) << 24); + (clipchar(sa + int(destpixel >> 24)) << 24); + // ((max_c (sa, destpixel >> 24)) << 24); } #endif } src_data += src_bprdiff; dest_data += dest_bprdiff; } - } - else if (strength > 0) - { - for (int j = miny; j < maxy; j++) - { - for (int i = minx; i < maxx; i++) - { -#if defined (__POWERPC__) + } else if (strength > 0) { + for (int j = miny; j < maxy; j++) { + for (int i = minx; i < maxx; i++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); - register int sa = (srcpixel & 0xFF)*strength/255; + register int sa = (srcpixel & 0xFF) * strength / 255; register int da = /*destpixel & 0xFF;*/ 255 - sa; register int ta = /*sa + da;*/ 255; - if (sa == 255 || /*da == 0*/ !(destpixel & 0xFF) ) // Fully opaque + if (sa == 255 || /*da == 0*/ !(destpixel & 0xFF)) // Fully opaque { *dest_data = srcpixel; - } - else if (sa == 0) // Fully transparent - { - } - else + } else if (sa == 0) // Fully transparent { -// *dest_data = ((((((destpixel>>24) )*da + ((srcpixel>>24) )*sa)/ta)<<24) & 0xFF000000) | -// ((((((destpixel>>16) & 0xFF)*da + ((srcpixel>>16) & 0xFF)*sa)/ta)<<16) & 0x00FF0000) | -// ((((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> 8) & 0xFF)*sa)/ta)<< 8) & 0x0000FF00) | -// clipchar (sa + int (destpixel & 0xFF)); - *dest_data = ((((destpixel & 0xFF000000)/ta)*da + ((srcpixel & 0xFF000000)/ta)*sa) & 0xFF000000) | - ((((destpixel & 0x00FF0000)/ta)*da + ((srcpixel & 0x00FF0000)/ta)*sa) & 0x00FF0000) | - ((((destpixel & 0x0000FF00) *da + (srcpixel & 0x0000FF00)*sa)/ta) & 0x0000FF00) | - clipchar (sa + int (destpixel & 0xFF)); - //clipchar (ta); + } else { + // *dest_data = ((((((destpixel>>24) )*da + + //((srcpixel>>24) )*sa)/ta)<<24) & 0xFF000000) | + // ((((((destpixel>>16) & 0xFF)*da + + //((srcpixel>>16) & 0xFF)*sa)/ta)<<16) & 0x00FF0000) | + // ((((((destpixel>> 8) & 0xFF)*da + ((srcpixel>> + // 8) & 0xFF)*sa)/ta)<< 8) & 0x0000FF00) | + // clipchar (sa + int (destpixel & 0xFF)); + *dest_data = + ((((destpixel & 0xFF000000) / ta) * da + ((srcpixel & 0xFF000000) / ta) * sa + ) & + 0xFF000000) | + ((((destpixel & 0x00FF0000) / ta) * da + ((srcpixel & 0x00FF0000) / ta) * sa + ) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) / ta) & + 0x0000FF00) | + clipchar(sa + int(destpixel & 0xFF)); + // clipchar (ta); } #else register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); - register int sa = (srcpixel >> 24)*strength/255; + register int sa = (srcpixel >> 24) * strength / 255; register int da = /*destpixel >> 24; */ 255 - sa; register int ta = /*sa + da;*/ 255; - if (sa == 255 || /*da == 0*/ !(destpixel & 0xFF000000)) // Fully opaque + if (sa == 255 || /*da == 0*/ !(destpixel & 0xFF000000)) // Fully opaque { *dest_data = srcpixel; - } - else if (sa == 0) // Fully transparent - { - } - else + } else if (sa == 0) // Fully transparent { - *dest_data = ((((((destpixel & 0x00FF0000) >> 1)*da + ((srcpixel & 0x00FF0000) >> 1)*sa)/ta) << 1) & 0x00FF0000) | - ((((destpixel & 0x0000FF00)*da + (srcpixel & 0x0000FF00)*sa)/ta) & 0x0000FF00) | - ((((destpixel & 0x000000FF)*da + (srcpixel & 0x000000FF)*sa)/ta) & 0x000000FF) | -// (clipchar (ta) << 24); -// ((max_c (sa, destpixel >> 24)) << 24); - (clipchar (sa + int (destpixel >> 24)) << 24); + } else { + *dest_data = + ((((((destpixel & 0x00FF0000) >> 1) * da + + ((srcpixel & 0x00FF0000) >> 1) * sa) / + ta) + << 1) & + 0x00FF0000) | + ((((destpixel & 0x0000FF00) * da + (srcpixel & 0x0000FF00) * sa) / ta) & + 0x0000FF00) | + ((((destpixel & 0x000000FF) * da + (srcpixel & 0x000000FF) * sa) / ta) & + 0x000000FF) | + // (clipchar (ta) << 24); + // ((max_c (sa, destpixel >> 24)) << 24); + (clipchar(sa + int(destpixel >> 24)) << 24); } #endif } src_data += src_bprdiff; dest_data += dest_bprdiff; } - } - else // Very special case: Only "erase" transparency. + } else // Very special case: Only "erase" transparency. { - for (int j = miny; j < maxy; j++) - { - for (int i = minx; i < maxx; i++) - { -#if defined (__POWERPC__) + for (int j = miny; j < maxy; j++) { + for (int i = minx; i < maxx; i++) { +#if defined(__POWERPC__) register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); - register int sa = (srcpixel & 0xFF)*(-strength)/255; + register int sa = (srcpixel & 0xFF) * (-strength) / 255; register int da = (destpixel & 0xFF); register int ta = 255; - if (sa == 255 || !(destpixel & 0xFF)) // Fully opaque + if (sa == 255 || !(destpixel & 0xFF)) // Fully opaque { *dest_data = destpixel & 0xFFFFFF00; - } - else if (sa == 0) // Fully transparent + } else if (sa == 0) // Fully transparent { - } - else - { - *dest_data = (destpixel & 0xFFFFFF00) | clipchar (da - sa); + } else { + *dest_data = (destpixel & 0xFFFFFF00) | clipchar(da - sa); } #else register uint32 srcpixel = *(++src_data); register uint32 destpixel = *(++dest_data); - register int sa = (srcpixel >> 24)*(-strength)/255; + register int sa = (srcpixel >> 24) * (-strength) / 255; register int da = (destpixel >> 24); -// register int ta = 255; - if (sa == 255 || !(destpixel & 0xFF000000)) // Fully opaque + // register int ta = 255; + if (sa == 255 || !(destpixel & 0xFF000000)) // Fully opaque { *dest_data = destpixel & 0x00FFFFFF; - } - else if (sa == 0) // Fully transparent + } else if (sa == 0) // Fully transparent { - } - else - { - *dest_data = (destpixel & 0x00FFFFFF) | ((clipchar (da - sa)) << 24); + } else { + *dest_data = (destpixel & 0x00FFFFFF) | ((clipchar(da - sa)) << 24); } #endif } @@ -6548,13 +6312,14 @@ void CanvasView::FastAddWithAlpha (long x, long y, int strength) end = clock(); extern int DebugLevel; if (DebugLevel > 7) - printf ("FastAddWithAlpha took %ld ms\n", end - start); + printf("FastAddWithAlpha took %ld ms\n", end - start); } // The following function isn't used anymore, and hence isn't made IA ready! // -void CanvasView::FastBlendWithAlpha (long x, long y, int /* strength */) +void +CanvasView::FastBlendWithAlpha(long x, long y, int /* strength */) // Note: Setup tbits, tbpr, bbits, bbpr, twi, thi, bwi and bhi before you enter here! // tbits = (uchar *) source->Bits(); // (32bit brush/clip bitmap) // tbpr = source->BytesPerRow(); @@ -6567,57 +6332,49 @@ void CanvasView::FastBlendWithAlpha (long x, long y, int /* strength */) // // Alpha = opacity! { - uchar *src_data = tbits; - uchar *dest_data = bbits; - if ((x + twi <= 0) || (x > bwi) || (y + thi <= 0) || (y > bhi)) - { + uchar* src_data = tbits; + uchar* dest_data = bbits; + if ((x + twi <= 0) || (x > bwi) || (y + thi <= 0) || (y > bhi)) { return; } // Clipping - int minx = max_c (x, 0); - int maxx = min_c (x + twi + 1, bwi + 1); - int miny = max_c (y, 0); - int maxy = min_c (y + thi + 1, bhi + 1); + int minx = max_c(x, 0); + int maxx = min_c(x + twi + 1, bwi + 1); + int miny = max_c(y, 0); + int maxy = min_c(y + thi + 1, bhi + 1); - ulong src_bprdiff = tbpr - 4*(maxx - minx); - ulong dest_bprdiff = bbpr - 4*(maxx - minx); + ulong src_bprdiff = tbpr - 4 * (maxx - minx); + ulong dest_bprdiff = bbpr - 4 * (maxx - minx); if (y < 0) - src_data -= y*tbpr; + src_data -= y * tbpr; if (x < 0) - src_data -= x*4; + src_data -= x * 4; - dest_data += miny*bbpr + 4*minx; + dest_data += miny * bbpr + 4 * minx; -// printf ("Alpha_src = %i, Alpha_dest = %i\n", src_data[3], dest_data[3]); - dest_data--; // Note: On PPC, pre-increment is faster. + // printf ("Alpha_src = %i, Alpha_dest = %i\n", src_data[3], dest_data[3]); + dest_data--; // Note: On PPC, pre-increment is faster. src_data--; - for (int j = miny; j < maxy; j++) - { - for (int i = minx; i < maxx; i++) - { - register int sa = src_data[4]; // Yes, 4. *_data are pre-decremented. + for (int j = miny; j < maxy; j++) { + for (int i = minx; i < maxx; i++) { + register int sa = src_data[4]; // Yes, 4. *_data are pre-decremented. register int da = dest_data[4]; register int ta = sa + da; - if (da == 0) - { + if (da == 0) { *(++dest_data) = *(++src_data); *(++dest_data) = *(++src_data); *(++dest_data) = *(++src_data); - *(++dest_data) = *(++src_data); // new alpha channel - } - else if (sa == 0) - { + *(++dest_data) = *(++src_data); // new alpha channel + } else if (sa == 0) { dest_data += 4; src_data += 4; - } - else - { - *dest_data = (*(++dest_data)*da + *(++src_data)*sa)/ta; - *dest_data = (*(++dest_data)*da + *(++src_data)*sa)/ta; - *dest_data = (*(++dest_data)*da + *(++src_data)*sa)/ta; - *dest_data = clipchar (int (*(++dest_data) + *(++src_data))); // new alpha channel + } else { + *dest_data = (*(++dest_data) * da + *(++src_data) * sa) / ta; + *dest_data = (*(++dest_data) * da + *(++src_data) * sa) / ta; + *dest_data = (*(++dest_data) * da + *(++src_data) * sa) / ta; + *dest_data = clipchar(int(*(++dest_data) + *(++src_data))); // new alpha channel } } src_data += src_bprdiff; @@ -6625,54 +6382,49 @@ void CanvasView::FastBlendWithAlpha (long x, long y, int /* strength */) } } -void CanvasView::WindowActivated (bool active) +void +CanvasView::WindowActivated(bool active) { // Apparently, views get multiple activate- and deactivate-calls in a row // This sounds like a bug to me, but this will work around it by treating it // as "switch ringing". extern bool inPaste; - extern BLocker *clipLock; + extern BLocker* clipLock; - if (clipLock->LockWithTimeout (500000) != B_OK) - { - printf ("Couldn't get clipLock to %sactivate %s\n", active ? "" : "in", myWindow->Name()); + if (clipLock->LockWithTimeout(500000) != B_OK) { + printf("Couldn't get clipLock to %sactivate %s\n", active ? "" : "in", myWindow->Name()); return; } -// printf ("WindowActivated - %s ", myWindow->Name()); - inherited::WindowActivated (active); - if (active && !windowLock) - { -// printf ("Activating."); + // printf ("WindowActivated - %s ", myWindow->Name()); + inherited::WindowActivated(active); + if (active && !windowLock) { + // printf ("Activating."); windowLock = true; BPoint point; uint32 buttons; - GetMouse (&point, &buttons, true); - if (inPaste && !newWin) - { -// extern long pasteX, pasteY; -// extern BBitmap *clip; -// BRect clipRect = clip->Bounds(); -// printf ("Deleting old cutbg\n"); -// delete cutbg; -// printf ("Creating new one\n"); -// cutbg = new BBitmap (clipRect, B_RGBA32, true); -// cutbg->Lock(); -// cutView->DrawBitmap (currentLayer(), BPoint (-point.x - pasteX, -point.y - pasteY)); -// cutbg->Unlock(); -// prevPaste = BRect (point.x + pasteX, point.y + pasteY, -// point.x + pasteX + clip->Bounds().right, point.y + pasteY + clip->Bounds().bottom); -// printf ("prevPaste set\n"); -// ePasteM (point); - //printf ("Calling Paste from WindowActivated()\n"); - Paste (true); - } - if (Bounds().Contains (point)) - { - extern Becasso *mainapp; - if ((transformerOpen && !(transformerOpen->DoesPreview() & PREVIEW_MOUSE)) - || (generatorOpen && !(generatorOpen->DoesPreview() & PREVIEW_MOUSE))) + GetMouse(&point, &buttons, true); + if (inPaste && !newWin) { + // extern long pasteX, pasteY; + // extern BBitmap *clip; + // BRect clipRect = clip->Bounds(); + // printf ("Deleting old cutbg\n"); + // delete cutbg; + // printf ("Creating new one\n"); + // cutbg = new BBitmap (clipRect, B_RGBA32, true); + // cutbg->Lock(); + // cutView->DrawBitmap (currentLayer(), BPoint (-point.x - pasteX, -point.y - + // pasteY)); cutbg->Unlock(); prevPaste = BRect (point.x + pasteX, + // point.y + pasteY, point.x + pasteX + clip->Bounds().right, point.y + + // pasteY + clip->Bounds().bottom); printf ("prevPaste set\n"); + // ePasteM (point); printf ("Calling Paste from WindowActivated()\n"); + Paste(true); + } + if (Bounds().Contains(point)) { + extern Becasso* mainapp; + if ((transformerOpen && !(transformerOpen->DoesPreview() & PREVIEW_MOUSE)) || + (generatorOpen && !(generatorOpen->DoesPreview() & PREVIEW_MOUSE))) mainapp->setCCross(); else mainapp->setCross(); @@ -6680,17 +6432,14 @@ void CanvasView::WindowActivated (bool active) Invalidate(); } newWin = false; - } - else if (!active && windowLock) - { -// printf ("Inactivating."); - if (inPaste) - { -// printf ("(inPaste)"); -// extern long pasteX, pasteY; + } else if (!active && windowLock) { + // printf ("Inactivating."); + if (inPaste) { + // printf ("(inPaste)"); + // extern long pasteX, pasteY; currentLayer()->Lock(); cutbg->Lock(); - drawView->DrawBitmap (cutbg, prevPaste.LeftTop()); + drawView->DrawBitmap(cutbg, prevPaste.LeftTop()); delete cutbg; cutbg = NULL; currentLayer()->Unlock(); @@ -6700,14 +6449,15 @@ void CanvasView::WindowActivated (bool active) mouse_on_canvas = false; windowLock = false; } -// printf ("\n"); -// else -// printf ("spurious %s call.\n", active ? "activate" : "inactivate"); -// printf ("End of WindowActivated - %s\n", myWindow->Name()); + // printf ("\n"); + // else + // printf ("spurious %s call.\n", active ? "activate" : "inactivate"); + // printf ("End of WindowActivated - %s\n", myWindow->Name()); clipLock->Unlock(); } -void CanvasView::ScrollIfNeeded (BPoint point) +void +CanvasView::ScrollIfNeeded(BPoint point) { // fprintf (stderr, "CanvasView::ScrollIfNeeded... "); fflush (stderr); BRect bounds = fBGView->Bounds(); @@ -6715,76 +6465,78 @@ void CanvasView::ScrollIfNeeded (BPoint point) bounds.top /= fScale; bounds.right /= fScale; bounds.bottom /= fScale; -// printf ("%f %f %f\n", point.x, bounds.right, fCanvasFrame.right); + // printf ("%f %f %f\n", point.x, bounds.right, fCanvasFrame.right); if (point.x > bounds.right && bounds.right < fCanvasFrame.right) - fBGView->ScrollBy ((point.x - bounds.right)*fScale, 0); + fBGView->ScrollBy((point.x - bounds.right) * fScale, 0); if (point.x < bounds.left && bounds.left > 0) - fBGView->ScrollBy ((point.x - bounds.left)*fScale, 0); + fBGView->ScrollBy((point.x - bounds.left) * fScale, 0); if (point.y > bounds.bottom && bounds.bottom < fCanvasFrame.bottom) - fBGView->ScrollBy (0, (point.y - bounds.bottom)*fScale); + fBGView->ScrollBy(0, (point.y - bounds.bottom) * fScale); if (point.y < bounds.top && bounds.top > 0) - fBGView->ScrollBy (0, (point.y - bounds.top)*fScale); + fBGView->ScrollBy(0, (point.y - bounds.top) * fScale); // fprintf (stderr, "Done.\n"); } -BRect CanvasView::makePositive (BRect r) +BRect +CanvasView::makePositive(BRect r) { BRect res; - res.left = min_c (r.left, r.right); - res.right = max_c (r.left, r.right); - res.top = min_c (r.top, r.bottom); - res.bottom = max_c (r.top, r.bottom); + res.left = min_c(r.left, r.right); + res.right = max_c(r.left, r.right); + res.top = min_c(r.top, r.bottom); + res.bottom = max_c(r.top, r.bottom); return res; } -BRect CanvasView::PRect (float l, float t, float r, float b) +BRect +CanvasView::PRect(float l, float t, float r, float b) { BRect res; - res.left = min_c (l, r); - res.right = max_c (l, r); - res.top = min_c (t, b); - res.bottom = max_c (t, b); + res.left = min_c(l, r); + res.right = max_c(l, r); + res.top = min_c(t, b); + res.bottom = max_c(t, b); return res; } -void CanvasView::WriteAsHex (const char *fname) +void +CanvasView::WriteAsHex(const char* fname) { BScreen screen; - FILE *f = fopen (fname, "wb"); - for (int i = 0; i <= fCanvasFrame.Height(); i++) - { + FILE* f = fopen(fname, "wb"); + for (int i = 0; i <= fCanvasFrame.Height(); i++) { int j; - for (j = 0; j <= fCanvasFrame.Width(); j++) - { - rgb_color c = getColor (BPoint (j, i)); - fprintf (f, "%c%c%c", c.red, c.green, c.blue); + for (j = 0; j <= fCanvasFrame.Width(); j++) { + rgb_color c = getColor(BPoint(j, i)); + fprintf(f, "%c%c%c", c.red, c.green, c.blue); } } - fclose (f); + fclose(f); } -void CanvasView::ExportCstruct (const char *fname) +void +CanvasView::ExportCstruct(const char* fname) { BScreen screen; bool last = false; - FILE *f = fopen (fname, "wb"); - printf ("Dumping to %s\n", fname); - fprintf (f, "/* C array for %s */\n", fname); - fprintf (f, "uchar data[%ld*%ld] = {\n ", fCanvasFrame.IntegerHeight() + 1, fCanvasFrame.IntegerWidth() + 1); - for (int i = 0; i <= fCanvasFrame.IntegerHeight(); i++) - { - for (int j = 0; j <= fCanvasFrame.IntegerWidth(); j++) - { + FILE* f = fopen(fname, "wb"); + printf("Dumping to %s\n", fname); + fprintf(f, "/* C array for %s */\n", fname); + fprintf( + f, "uchar data[%ld*%ld] = {\n ", fCanvasFrame.IntegerHeight() + 1, + fCanvasFrame.IntegerWidth() + 1 + ); + for (int i = 0; i <= fCanvasFrame.IntegerHeight(); i++) { + for (int j = 0; j <= fCanvasFrame.IntegerWidth(); j++) { last = (i == fCanvasFrame.IntegerHeight() && j == fCanvasFrame.IntegerWidth()); - rgb_color c = getColor (BPoint (j, i)); + rgb_color c = getColor(BPoint(j, i)); if (c.alpha == 0) c = B_TRANSPARENT_32_BIT; - uint8 val = screen.IndexForColor (c); - fprintf (f, "0x%02x%s", val, last ? "" : ", "); + uint8 val = screen.IndexForColor(c); + fprintf(f, "0x%02x%s", val, last ? "" : ", "); } - fprintf (f, "\n%s", last ? "" : " "); + fprintf(f, "\n%s", last ? "" : " "); } - fprintf (f, "};\n"); - fclose (f); - + fprintf(f, "};\n"); + fclose(f); } diff --git a/source/CanvasView.h b/source/CanvasView.h index 27b71d4..c95e18c 100644 --- a/source/CanvasView.h +++ b/source/CanvasView.h @@ -6,8 +6,8 @@ #include #include #include -#if defined (DATATYPES) -# include +#if defined(DATATYPES) +#include #endif #include #include @@ -22,293 +22,316 @@ #include "Position.h" #include "Settings.h" #include "Colors.h" +#include -#define STRETCH_TO_FIT 0 +#define STRETCH_TO_FIT 0 class Brush; class Layer; class Selection; class BGView; -typedef struct +typedef struct { - float cx, cy; - float Spacing; - int pstrength; - Brush *b; - BBitmap *brushbm; - BPoint pos; + float cx, cy; + float Spacing; + int pstrength; + Brush* b; + BBitmap* brushbm; + BPoint pos; } brush_cache; -typedef struct +typedef struct { - float cx, cy; - float Spacing; - int pstrength; - Brush *b; - BPoint pos; - BPoint offset; - BPoint prevctr; + float cx, cy; + float Spacing; + int pstrength; + Brush* b; + BPoint pos; + BPoint offset; + BPoint prevctr; } clone_cache; typedef struct { - const color_map *cmap; - rgb_color hi, lo, hit, lot; - bool lighten; - float flowrate; - float color_ratio; - float sigma; - float ssq; - int strength; - Position position; + const color_map* cmap; + rgb_color hi, lo, hit, lot; + bool lighten; + float flowrate; + float color_ratio; + float sigma; + float ssq; + int strength; + Position position; } spraycan_cache; class CanvasView : public SView { -public: - CanvasView (const BRect frame, const char *name, BBitmap *map = NULL, rgb_color color = White); - CanvasView (const BRect frame, const char *name, FILE *fp); -void RestOfCtor (); -virtual ~CanvasView (); -virtual void FrameResized (float width, float height); -virtual void Draw (BRect updateRect); -virtual void Invalidate (const BRect rect); -virtual void Invalidate (); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *msg); -virtual void MouseDown (BPoint point); -virtual void MouseUp (BPoint point); -virtual void MouseOrTablet (Position *position); -virtual void KeyDown (const char *bytes, int32 numBytes); -virtual void Pulse (); -virtual void WindowActivated (bool active); -virtual void AttachedToWindow (); -virtual void ScreenChanged (BRect rect, color_space mode); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual void MessageReceived (BMessage *msg); -void SetupUndo (int32 mode); -void Undo (bool advance = true, bool menu = false); -void Redo (bool menu = false); -void Cut (); -void Copy (); -void CopyToNewLayer (); -void Paste (bool winAct = false); -void SelectAll (bool menu = false); -void UndoSelection (bool menu = false); -void ChannelToSelection (uint32 what, bool menu = false); -void SelectionToChannel (uint32 what); -rgb_color GuessBackgroundColor (); -void SelectByColor (rgb_color c, bool menu = false); -void ColorizeSelection (rgb_color c); -void InvertSelection (bool menu = false); - -rgb_color getColor (long x, long y); -rgb_color getColor (BPoint p); -rgb_color getColor (LPoint p); -uint32 get_and_plot (BPoint p, rgb_color c = Black); -void plot (BPoint p, rgb_color c = Black); -void plot_alpha (BPoint p, rgb_color c = Black); -void fplot (BPoint p, rgb_color c = Black); -void fplot_alpha (BPoint p, rgb_color c = Black); -void tplot32 (BPoint p, rgb_color c = Black); -void tplot8 (LPoint p, uchar c = 255); -void setScrollBars (BScrollBar *_h, BScrollBar *_v); -BRect canvasFrame () { return fCanvasFrame; }; -BBitmap *canvas (bool do_export = false); -Selection *getSelection () { return selection; }; -void ConstructCanvas (BBitmap *cvCanvas, BRect rect, bool doselect = true, bool do_export = false); -void Print (); -void Merge (BBitmap *a, Layer *b, BRect update, bool doselect = false, bool preserve_alpha = true); -Layer *currentLayer () { return layer[fCurrentLayer]; }; -Layer *getLayer (int index) { return layer[index]; }; -int numLayers () { return fNumLayers; }; -int currentLayerIndex () { return fCurrentLayer; }; -void addLayer (const char *name); -void insertLayer (int index, const char *name); -void duplicateLayer (int index); -void moveLayers (int a, int b); -void removeLayer (int index); -void makeCurrentLayer (int index); -void mergeLayers (int bottom, int top); -void translateLayer (int index); -void rotateLayer (int index); -void flipLayer (int hv, int index); -void checkMetaLayer (); - -void setChannelOperation (int index, int newmode); -void setGlobalAlpha (int index, int ga); -void setLayerContentsToBitmap (int index, BBitmap *map, int32 resize = STRETCH_TO_FIT); -void invertAlpha (); -bool changed; -void tTextD (); -void Save (BEntry entry); -void setScale (float s, bool invalidate = true); -float getScale () { return fScale; }; -void ZoomIn (); -void ZoomOut (); - -void setBGView (BGView *bg) { fBGView = bg; }; -BGView *getBGView () { return fBGView; }; -status_t Crop (BRect rect); -void CenterMouse (); -void CropToWindow (); -void CropToSelection (); -void AutoCrop (); -void Pad (uint32 what); -void resizeTo (int32 w, int32 h); -void ResizeToWindow (uint32 what); -void RotateCanvas (uint32 what); -void ReplaceCurrentLayer (BBitmap *newlayer); -void InvalidateAddons (); -void OpenAddon (AddOn *addon, const char *name); -void CloseAddon (AddOn *addon); -void Filter (AddOn *addon, uint8 preview = 0); -void Transform (AddOn *addon, uint8 preview = 0); -void Generate (AddOn *addon, uint8 preview = 0); -void WriteAsHex (const char *fname); -AddOn *FilterOpen () { return filterOpen; }; -AddOn *TransformerOpen () { return transformerOpen; }; -AddOn *GeneratorOpen () { return generatorOpen; }; -void Fill (int32 mode, BPoint point, rgb_color *c); - -void SimpleData (BMessage *msg); -void CopyTarget (BMessage *msg); -void TrashTarget (BMessage *msg); - -void ExportCstruct (const char *fname); - -//////// -private: -typedef SView inherited; -void FastAddWithAlpha (long x, long y, int strength = 255); -void FastBlendWithAlpha (long x, long y, int strength = 255); -void ePaste (BPoint point, uint32 buttons); -void ePasteM (BPoint point); -void eDrag (BPoint point, uint32 buttons); -void eFilter (BPoint point, uint32 buttons); -void eGenerate (BPoint point, uint32 buttons); -void eTransform (BPoint point, uint32 buttons); -void tBrush (int32 mode, BPoint point, uint32 buttons); -void tBrushM (int32 mode, BPoint point, uint32 buttons, int pressure, BPoint tilt); -void tClone (int32 mode, BPoint point, uint32 buttons); -void tCloneM (int32 mode, BPoint point, uint32 buttons, int pressure, BPoint tilt); -void tTablet (int32 mode); -void tEraser (int32 mode, BPoint point, uint32 buttons); -void tEraserM (int32 mode, BPoint point); -void tText (int32 mode, BPoint point, uint32 buttons); -void tTextM (int32 mode, BPoint point); -void tSpraycan (int32 mode, BPoint point, uint32 buttons); -void tSpraycanM (int32 mode, BPoint point, uint32 buttons, int pressure, BPoint tilt); -void tFreehand (int32 mode, BPoint point, uint32 buttons); -void tLines (int32 mode, BPoint point, uint32 buttons); -void tLinesM (int32 mode, BPoint point); -void tPolyblob (int32 mode, BPoint point, uint32 buttons); -void tPolygon (int32 mode, BPoint point, uint32 buttons); -void tPolygonM (int32 mode, BPoint point); -void tRect (int32 mode, BPoint point, uint32 buttons); -void tRectM (int32 mode, BPoint point); -void tRoundRect (int32 mode, BPoint point, uint32 buttons); -void tRoundRectM (int32 mode, BPoint point); -void tCircle (int32 mode, BPoint point, uint32 buttons); -void tCircleM (int32 mode, BPoint point); -void tEllipse (int32 mode, BPoint point, uint32 buttons); -void tEllipseM (int32 mode, BPoint point); -void tFill (int32 mode, BPoint point, uint32 buttons, rgb_color *c = NULL); -void tSetColors (uint32 buttons); - -bool isfillcolor0 (LPoint point); -bool isfillcolorrgb (LPoint point, uchar *t); -bool isfillcolort (LPoint point, uchar *t); -bool inbounds (LPoint point); -bool istransparent8 (LPoint point); - -void ScrollIfNeeded (BPoint point); -BRect makePositive (BRect r); -BRect PRect (float l, float t, float r, float b); - -void DetachCurrentLayer (); -void AttachCurrentLayer (); -void DetachSelection (); -void AttachSelection (); -void CloseOpenAddons (); - -void do_removeLayer (int index); -void do_translateLayer (int index, int32 mode); -void do_rotateLayer (int index, int32 mode); - -class CanvasWindow *myWindow; -BGView *fBGView; -int32 entry; -int32 prevTool; -bool mouse_on_canvas; -BScrollBar *hSB; -BScrollBar *vSB; -BRect fCanvasFrame; -BBitmap *screenbitmap; -BBitmap *screenbitmap32; -int bwi, bhi; -ulong *bbitsl; -uchar *bbits; -ulong bbprl, bbpr; -uint32 *sbptr; -uint32 sblpr; -undo_entry undo[MAX_UNDO]; -int fIndex1, fIndex2; -int indexUndo, maxIndexUndo, maxUndo; -Layer *layer[MAX_LAYERS]; -int fCurrentLayer, fNumLayers; -Layer *previewLayer; -Selection *previewSelection; -Layer *tr2x2Layer; -Selection *tr2x2Selection; -int didPreview; -bool transformerSaved, generatorSaved; -Selection *selection; -BBitmap *cutbg; -SView *cutView; -BRect prevPaste, prev_eraser; -SView *selectionView; -bool sel, selchanged, firstDrag, first, inAddOn; -BBitmap *temp; -uchar *tbits; -ulong tbprl, tbpr; -float tw, th; -int twi, thi; -SView *drawView; -BPolygon *polygon; -BPoint polypoint; -rgb_color fillcolor; -uint32 fill32; -rgb_color toleranceRGB; -float tolerance; -BPoint prev; -float pradius; -BTextControl *text; -uint32 fButtons; -int32 fMode; -BPoint fPoint; -float fScale; -bool leftfirst; -bool windowLock; // I don't believe this either! -bool newWin; -BRect fPreviewRect; -BRect fPrevpreviewRect; -AddOn *filterOpen; -AddOn *transformerOpen; -AddOn *generatorOpen; -//AddOn *addonInQueue; -int32 fCurrentProperty; -int32 fLayerSpecifier; -float fTreshold; -bool fMouseDown; -bool fPicking; -bool fDragScroll; -int fTranslating; -int fRotating; -brush_cache fBC; -spraycan_cache fSC; -clone_cache fCC; -BPoint fLastCenter; + public: + CanvasView(const BRect frame, const char* name, BBitmap* map = NULL, rgb_color color = White); + CanvasView(const BRect frame, const char* name, FILE* fp); + void RestOfCtor(); + virtual ~CanvasView(); + virtual void FrameResized(float width, float height); + virtual void Draw(BRect updateRect); + virtual void Invalidate(const BRect rect); + virtual void Invalidate(); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg); + virtual void MouseDown(BPoint point); + virtual void MouseUp(BPoint point); + virtual void MouseOrTablet(Position* position); + virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void Pulse(); + virtual void WindowActivated(bool active); + virtual void AttachedToWindow(); + virtual void ScreenChanged(BRect rect, color_space mode); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual void MessageReceived(BMessage* msg); + void SetupUndo(int32 mode); + void Undo(bool advance = true, bool menu = false); + void Redo(bool menu = false); + void Cut(); + void Copy(); + void CopyToNewLayer(); + void Paste(bool winAct = false); + void SelectAll(bool menu = false); + void UndoSelection(bool menu = false); + void ChannelToSelection(uint32 what, bool menu = false); + void SelectionToChannel(uint32 what); + rgb_color GuessBackgroundColor(); + void SelectByColor(rgb_color c, bool menu = false); + void ColorizeSelection(rgb_color c); + void InvertSelection(bool menu = false); + + rgb_color getColor(long x, long y); + rgb_color getColor(BPoint p); + rgb_color getColor(LPoint p); + uint32 get_and_plot(BPoint p, rgb_color c = Black); + void plot(BPoint p, rgb_color c = Black); + void plot_alpha(BPoint p, rgb_color c = Black); + void fplot(BPoint p, rgb_color c = Black); + void fplot_alpha(BPoint p, rgb_color c = Black); + void tplot32(BPoint p, rgb_color c = Black); + void tplot8(LPoint p, uchar c = 255); + void setScrollBars(BScrollBar* _h, BScrollBar* _v); + + BRect canvasFrame() { return fCanvasFrame; }; + + BBitmap* canvas(bool do_export = false); + + Selection* getSelection() { return selection; }; + + void + ConstructCanvas(BBitmap* cvCanvas, BRect rect, bool doselect = true, bool do_export = false); + void Print(); + void + Merge(BBitmap* a, Layer* b, BRect update, bool doselect = false, bool preserve_alpha = true); + + Layer* currentLayer() { return layer[fCurrentLayer]; }; + + Layer* getLayer(int index) { return layer[index]; }; + + int numLayers() { return fNumLayers; }; + + int currentLayerIndex() { return fCurrentLayer; }; + + void addLayer(const char* name); + void insertLayer(int index, const char* name); + void duplicateLayer(int index); + void moveLayers(int a, int b); + void removeLayer(int index); + void makeCurrentLayer(int index); + void mergeLayers(int bottom, int top); + void translateLayer(int index); + void rotateLayer(int index); + void flipLayer(int hv, int index); + void checkMetaLayer(); + + void setChannelOperation(int index, int newmode); + void setGlobalAlpha(int index, int ga); + void setLayerContentsToBitmap(int index, BBitmap* map, int32 resize = STRETCH_TO_FIT); + void invertAlpha(); + bool changed; + void tTextD(); + void Save(BEntry entry); + void setScale(float s, bool invalidate = true); + + float getScale() { return fScale; }; + + void ZoomIn(); + void ZoomOut(); + + void setBGView(BGView* bg) { fBGView = bg; }; + + BGView* getBGView() { return fBGView; }; + + status_t Crop(BRect rect); + void CenterMouse(); + void CropToWindow(); + void CropToSelection(); + void AutoCrop(); + void Pad(uint32 what); + void resizeTo(int32 w, int32 h); + void ResizeToWindow(uint32 what); + void RotateCanvas(uint32 what); + void ReplaceCurrentLayer(BBitmap* newlayer); + void InvalidateAddons(); + void OpenAddon(AddOn* addon, const char* name); + void CloseAddon(AddOn* addon); + void Filter(AddOn* addon, uint8 preview = 0); + void Transform(AddOn* addon, uint8 preview = 0); + void Generate(AddOn* addon, uint8 preview = 0); + void WriteAsHex(const char* fname); + + AddOn* FilterOpen() { return filterOpen; }; + + AddOn* TransformerOpen() { return transformerOpen; }; + + AddOn* GeneratorOpen() { return generatorOpen; }; + + void Fill(int32 mode, BPoint point, rgb_color* c); + + void SimpleData(BMessage* msg); + void CopyTarget(BMessage* msg); + void TrashTarget(BMessage* msg); + + void ExportCstruct(const char* fname); + + //////// + private: + typedef SView inherited; + void FastAddWithAlpha(long x, long y, int strength = 255); + void FastBlendWithAlpha(long x, long y, int strength = 255); + void ePaste(BPoint point, uint32 buttons); + void ePasteM(BPoint point); + void eDrag(BPoint point, uint32 buttons); + void eFilter(BPoint point, uint32 buttons); + void eGenerate(BPoint point, uint32 buttons); + void eTransform(BPoint point, uint32 buttons); + void tBrush(int32 mode, BPoint point, uint32 buttons); + void tBrushM(int32 mode, BPoint point, uint32 buttons, int pressure, BPoint tilt); + void tClone(int32 mode, BPoint point, uint32 buttons); + void tCloneM(int32 mode, BPoint point, uint32 buttons, int pressure, BPoint tilt); + void tTablet(int32 mode); + void tEraser(int32 mode, BPoint point, uint32 buttons); + void tEraserM(int32 mode, BPoint point); + void tText(int32 mode, BPoint point, uint32 buttons); + void tTextM(int32 mode, BPoint point); + void tSpraycan(int32 mode, BPoint point, uint32 buttons); + void tSpraycanM(int32 mode, BPoint point, uint32 buttons, int pressure, BPoint tilt); + void tFreehand(int32 mode, BPoint point, uint32 buttons); + void tLines(int32 mode, BPoint point, uint32 buttons); + void tLinesM(int32 mode, BPoint point); + void tPolyblob(int32 mode, BPoint point, uint32 buttons); + void tPolygon(int32 mode, BPoint point, uint32 buttons); + void tPolygonM(int32 mode, BPoint point); + void tRect(int32 mode, BPoint point, uint32 buttons); + void tRectM(int32 mode, BPoint point); + void tRoundRect(int32 mode, BPoint point, uint32 buttons); + void tRoundRectM(int32 mode, BPoint point); + void tCircle(int32 mode, BPoint point, uint32 buttons); + void tCircleM(int32 mode, BPoint point); + void tEllipse(int32 mode, BPoint point, uint32 buttons); + void tEllipseM(int32 mode, BPoint point); + void tFill(int32 mode, BPoint point, uint32 buttons, rgb_color* c = NULL); + void tSetColors(uint32 buttons); + + bool isfillcolor0(LPoint point); + bool isfillcolorrgb(LPoint point, uchar* t); + bool isfillcolort(LPoint point, uchar* t); + bool inbounds(LPoint point); + bool istransparent8(LPoint point); + + void ScrollIfNeeded(BPoint point); + BRect makePositive(BRect r); + BRect PRect(float l, float t, float r, float b); + + void DetachCurrentLayer(); + void AttachCurrentLayer(); + void DetachSelection(); + void AttachSelection(); + void CloseOpenAddons(); + + void do_removeLayer(int index); + void do_translateLayer(int index, int32 mode); + void do_rotateLayer(int index, int32 mode); + + class CanvasWindow* myWindow; + BGView* fBGView; + int32 entry; + int32 prevTool; + bool mouse_on_canvas; + BScrollBar* hSB; + BScrollBar* vSB; + BRect fCanvasFrame; + BBitmap* screenbitmap; + BBitmap* screenbitmap32; + int bwi, bhi; + ulong* bbitsl; + uchar* bbits; + ulong bbprl, bbpr; + uint32* sbptr; + uint32 sblpr; + undo_entry undo[MAX_UNDO]; + int fIndex1, fIndex2; + int indexUndo, maxIndexUndo, maxUndo; + Layer* layer[MAX_LAYERS]; + int fCurrentLayer, fNumLayers; + Layer* previewLayer; + Selection* previewSelection; + Layer* tr2x2Layer; + Selection* tr2x2Selection; + int didPreview; + bool transformerSaved, generatorSaved; + Selection* selection; + BBitmap* cutbg; + SView* cutView; + BRect prevPaste, prev_eraser; + SView* selectionView; + bool sel, selchanged, firstDrag, first, inAddOn; + BBitmap* temp; + uchar* tbits; + ulong tbprl, tbpr; + float tw, th; + int twi, thi; + SView* drawView; + BPolygon* polygon; + BPoint polypoint; + rgb_color fillcolor; + uint32 fill32; + rgb_color toleranceRGB; + float tolerance; + BPoint prev; + float pradius; + BTextControl* text; + uint32 fButtons; + int32 fMode; + BPoint fPoint; + float fScale; + bool leftfirst; + bool windowLock; // I don't believe this either! + bool newWin; + BRect fPreviewRect; + BRect fPrevpreviewRect; + AddOn* filterOpen; + AddOn* transformerOpen; + AddOn* generatorOpen; + // AddOn *addonInQueue; + int32 fCurrentProperty; + int32 fLayerSpecifier; + float fTreshold; + bool fMouseDown; + bool fPicking; + bool fDragScroll; + int fTranslating; + int fRotating; + brush_cache fBC; + spraycan_cache fSC; + clone_cache fCC; + BPoint fLastCenter; + BNumberFormat fNumberFormat; }; -#endif \ No newline at end of file +#endif diff --git a/source/CanvasWindow.cpp b/source/CanvasWindow.cpp index aba99c0..3c3437f 100644 --- a/source/CanvasWindow.cpp +++ b/source/CanvasWindow.cpp @@ -29,15 +29,30 @@ extern bool DataTypes; -#if defined (__POWERPC__) -# pragma optimization_level 1 +#if defined(__POWERPC__) +#pragma optimization_level 1 #endif -#define GET_AND_SET {B_GET_PROPERTY, B_SET_PROPERTY, 0} -#define GET {B_GET_PROPERTY, 0} -#define SET {B_SET_PROPERTY, 0} -#define DIRECT_AND_INDEX {B_DIRECT_SPECIFIER, B_INDEX_SPECIFIER, 0} -#define DIRECT {B_DIRECT_SPECIFIER, 0} +#define GET_AND_SET \ + { \ + B_GET_PROPERTY, B_SET_PROPERTY, 0 \ + } +#define GET \ + { \ + B_GET_PROPERTY, 0 \ + } +#define SET \ + { \ + B_SET_PROPERTY, 0 \ + } +#define DIRECT_AND_INDEX \ + { \ + B_DIRECT_SPECIFIER, B_INDEX_SPECIFIER, 0 \ + } +#define DIRECT \ + { \ + B_DIRECT_SPECIFIER, 0 \ + } static property_info prop_list[] = { {"Name", GET, DIRECT, "Get Canvas name"}, @@ -53,503 +68,552 @@ static value_info value_list[] = { 0 }; +float zoomLevels[] = {0.125, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 16.0}; +char aspectLevels[][7] = {"(1:8)", "(1:4)", "(1:2)", "(1:1)", "(2:1)", "(4:1)", "(8:1)", "(16:1)"}; -CanvasWindow::CanvasWindow (BRect frame, const char *name, BBitmap *map, BMessenger *target, bool AskForAlpha, rgb_color color) -: BWindow (frame, name, B_DOCUMENT_WINDOW, B_PULSE_NEEDED) +CanvasWindow::CanvasWindow( + BRect frame, const char* name, BBitmap* map, BMessenger* target, bool AskForAlpha, + rgb_color color +) + : BWindow(frame, name, B_DOCUMENT_WINDOW, B_PULSE_NEEDED) { - BEntry entry = BEntry (name); - entry.GetRef (&myRef); + BEntry entry = BEntry(name); + entry.GetRef(&myRef); fromRef = false; char fname[MAX_FNAME]; - strcpy (fName, name); - strcpy (fname, name); - strcat (fname, " (100%)"); - SetTitle (fname); - if (target) - { + strcpy(fName, name); + strcpy(fname, name); + fNumberFormat.FormatPercent(fPercentData, 1.0); + fTitleString.SetToFormat("%s (%s)", fname, fPercentData.String()); + SetTitle(fTitleString.String()); + if (target) { // printf ("Target found\n"); - myTarget = new BMessenger (*target); - } - else + myTarget = new BMessenger(*target); + } else myTarget = NULL; - restOfCtor (frame, map, NULL, AskForAlpha, color); + restOfCtor(frame, map, NULL, AskForAlpha, color); } -CanvasWindow::CanvasWindow (BRect frame, entry_ref ref, bool AskForAlpha, BMessenger *target) -: BWindow (frame, "", B_DOCUMENT_WINDOW, uint32 (NULL)) +CanvasWindow::CanvasWindow(BRect frame, entry_ref ref, bool AskForAlpha, BMessenger* target) + : BWindow(frame, "", B_DOCUMENT_WINDOW, uint32(NULL)) { - extern const char *Version; + extern const char* Version; myRef = ref; fromRef = true; - if (target) - { + if (target) { // printf ("Target found\n"); - myTarget = new BMessenger (*target); - } - else + myTarget = new BMessenger(*target); + } else myTarget = NULL; - BBitmap *map = NULL; + BBitmap* map = NULL; char fname[MAX_FNAME]; BEntry entry; - entry.SetTo (&ref, true); - BFile file = BFile (&ref, B_READ_ONLY); - entry.GetName (fname); - strcpy (fName, fname); - strcat (fname, " (100%)"); - SetTitle (fname); + entry.SetTo(&ref, true); + BFile file = BFile(&ref, B_READ_ONLY); + entry.GetName(fname); + strcpy(fName, fname); + fNumberFormat.FormatPercent(fPercentData, 1.0); + fTitleString.SetToFormat("%s (%s)", fname, fPercentData.String()); + SetTitle(fTitleString.String()); char type[80]; - BNode node = BNode (&entry); + BNode node = BNode(&entry); ssize_t s; - FILE *fp = NULL; - verbose (2, "Checking file type\n"); - if ((s = node.ReadAttr ("BEOS:TYPE", B_STRING_TYPE, 0, type, 79)) > 0) - { - if (!strcmp (type, "image/becasso") || !strcmp (type, "image/x-becasso")) - { - verbose (2, "Becasso native!\n"); + FILE* fp = NULL; + verbose(2, "Checking file type\n"); + if ((s = node.ReadAttr("BEOS:TYPE", B_STRING_TYPE, 0, type, 79)) > 0) { + if (!strcmp(type, "image/becasso") || !strcmp(type, "image/x-becasso")) { + verbose(2, "Becasso native!\n"); BPath path; - entry.GetPath (&path); - fp = fopen (path.Path(), "r"); + entry.GetPath(&path); + fp = fopen(path.Path(), "r"); char line[81]; - do - { - fgets (line, 80, fp); - } while (line[0] == '#'); - char *endp = line; - float tvers = atof (Version); - float cvers = strtod (endp, &endp); + do { + fgets(line, 80, fp); + } while (line[0] == '#'); + char* endp = line; + float tvers = atof(Version); + float cvers = strtod(endp, &endp); *endp = 0; - if (int (cvers) > int (tvers)) // Check major version + if (int(cvers) > int(tvers)) // Check major version { char string[B_FILE_NAME_LENGTH + 128]; - sprintf (string, lstring (130, "‘%s’ is an image from a newer Becasso version (%s).\nYou can't load these files with this Becasso version."), fName, line); - BAlert *alert = new BAlert ("", string, lstring (131, "Cancel"), NULL, NULL, - B_WIDTH_AS_USUAL, B_WARNING_ALERT); + sprintf( + string, + lstring( + 130, "‘%s’ is an image from a newer Becasso version (%s).\nYou can't load " + "these files with this Becasso version." + ), + fName, line + ); + BAlert* alert = new BAlert( + "", string, lstring(131, "Cancel"), NULL, NULL, B_WIDTH_AS_USUAL, + B_WARNING_ALERT + ); alert->Go(); - fclose (fp); - throw (1); + fclose(fp); + throw(1); } - if (int (cvers) == int (tvers) && cvers - int (cvers) > tvers - int (tvers)) // Check release + if (int(cvers) == int(tvers) && + cvers - int(cvers) > tvers - int(tvers)) // Check release { char string[B_FILE_NAME_LENGTH + 128]; - sprintf (string, lstring (132, "‘%s’ is an image from a newer release of Becasso (%s).\nTry to load anyway?"), fName, line); - BAlert *alert = new BAlert ("", string, lstring (131, "Cancel"), lstring (133, "Proceed"), NULL, - B_WIDTH_AS_USUAL, B_WARNING_ALERT); + sprintf( + string, + lstring( + 132, "‘%s’ is an image from a newer release of Becasso (%s).\nTry to load " + "anyway?" + ), + fName, line + ); + BAlert* alert = new BAlert( + "", string, lstring(131, "Cancel"), lstring(133, "Proceed"), NULL, + B_WIDTH_AS_USUAL, B_WARNING_ALERT + ); ulong res = alert->Go(); - if (res == 0) - { - fclose (fp); - throw (2); + if (res == 0) { + fclose(fp); + throw(2); } } - fgets (line, 80, fp); + fgets(line, 80, fp); endp = line; - frame.left = strtod (endp, &endp); - frame.top = strtod (endp, &endp); - frame.right = strtod (endp, &endp); - frame.bottom = strtod (endp, &endp); - add_to_recent (ref); - restOfCtor (frame, NULL, fp, AskForAlpha); + frame.left = strtod(endp, &endp); + frame.top = strtod(endp, &endp); + frame.right = strtod(endp, &endp); + frame.bottom = strtod(endp, &endp); + add_to_recent(ref); + restOfCtor(frame, NULL, fp, AskForAlpha); return; } } - if (DataTypes) - { - ProgressiveBitmapStream *bms = new ProgressiveBitmapStream(); -// bms->DisplayProgressBar (BPoint (200, 200), "Reading Image…"); - BFile inStream (file); -#if defined (DATATYPES) - if (DATATranslate (inStream, NULL, NULL, *bms, DATA_BITMAP)) - { + if (DataTypes) { + ProgressiveBitmapStream* bms = new ProgressiveBitmapStream(); + // bms->DisplayProgressBar (BPoint (200, 200), "Reading Image…"); + BFile inStream(file); +#if defined(DATATYPES) + if (DATATranslate(inStream, NULL, NULL, *bms, DATA_BITMAP)) { char string[B_FILE_NAME_LENGTH + 64]; - sprintf (string, "Datatype error:\nCouldn't translate `%s'", fName); - BAlert *alert = new BAlert ("", string, "OK", NULL, NULL, - B_WIDTH_AS_USUAL, B_WARNING_ALERT); + sprintf(string, "Datatype error:\nCouldn't translate `%s'", fName); + BAlert* alert = + new BAlert("", string, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->Go(); - throw (0); - } - else - { - map = bms->/*Get*/Bitmap(); - bms->SetDispose (false); + throw(0); + } else { + map = bms->/*Get*/ Bitmap(); + bms->SetDispose(false); } delete bms; #else BPath path; - entry.GetPath (&path); + entry.GetPath(&path); long err = B_ERROR; - const char *mimeStr = NULL; + const char* mimeStr = NULL; char str[B_FILE_NAME_LENGTH]; translator_info info; - - if (file.ReadAttr ("BOES:TYPE", B_STRING_TYPE, 0, str, B_FILE_NAME_LENGTH) == B_OK) + + if (file.ReadAttr("BEOS:TYPE", B_STRING_TYPE, 0, str, B_FILE_NAME_LENGTH) == B_OK) mimeStr = str; - + if (mimeStr) - err = BTranslatorRoster::Default()->Identify (&inStream, NULL, &info, 0, mimeStr); + err = BTranslatorRoster::Default()->Identify(&inStream, NULL, &info, 0, mimeStr); - if (err) // try without a hint - err = BTranslatorRoster::Default()->Identify (&inStream, NULL, &info); - - if (!err) - { - err = BTranslatorRoster::Default()->Translate (&inStream, &info, NULL, bms, B_TRANSLATOR_BITMAP); - if (!err) - { + if (err) // try without a hint + err = BTranslatorRoster::Default()->Identify(&inStream, NULL, &info); + + if (!err) { + err = BTranslatorRoster::Default()->Translate( + &inStream, &info, NULL, bms, B_TRANSLATOR_BITMAP + ); + if (!err) { map = bms->Bitmap(); - bms->SetDispose (false); + bms->SetDispose(false); } } delete bms; - - if (err || !map) - { + + if (err || !map) { char errstring[B_FILE_NAME_LENGTH + 64]; - sprintf (errstring, lstring (134, "Translation Kit error:\nCouldn't translate `%s'"), fName); - BAlert *alert = new BAlert ("", errstring, lstring (135, "Help"), lstring (136, "OK"), NULL, - B_WIDTH_AS_USUAL, B_WARNING_ALERT); + sprintf( + errstring, lstring(134, "Translation Kit error:\nCouldn't translate `%s'"), fName + ); + BAlert* alert = new BAlert( + "", errstring, lstring(135, "Help"), lstring(136, "OK"), NULL, B_WIDTH_AS_USUAL, + B_WARNING_ALERT + ); uint32 button = alert->Go(); - if (button == 0) - { - BNode node (&entry); + if (button == 0) { + BNode node(&entry); char filetype[80]; - filetype [node.ReadAttr ("BEOS:TYPE", 0, 0, filetype, 80)] = 0; - if (!strncmp (filetype, "image/", 6)) - { - sprintf (errstring, - lstring (137, "The file '%s' is of type '%s'.\nThis does look like an image format to me.\nMaybe you haven't installed the corresponding Translator?"), - fName, filetype); + filetype[node.ReadAttr("BEOS:TYPE", 0, 0, filetype, 80)] = 0; + if (!strncmp(filetype, "image/", 6)) { + sprintf( + errstring, + lstring( + 137, + "The file '%s' is of type '%s'.\nThis does look like an image format " + "to me.\nMaybe you haven't installed the corresponding Translator?" + ), + fName, filetype + ); + } else { + sprintf( + errstring, + lstring( + 138, + "The file '%s' is of type '%s'.\nI don't think this is an image at all." + ), + fName, filetype + ); } - else - { - sprintf (errstring, - lstring (138, "The file '%s' is of type '%s'.\nI don't think this is an image at all."), - fName, filetype); - } - alert = new BAlert ("", errstring, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT); + alert = new BAlert("", errstring, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT); alert->Go(); } - throw (0); + throw(0); } #endif - } - else - { - printf ("No DataTypes (?!)\n"); + } else { + printf("No DataTypes (?!)\n"); // No DataTypes... - throw (0); + throw(0); } -// add_to_recent (ref); - restOfCtor (frame, map, fp, AskForAlpha); + // add_to_recent (ref); + restOfCtor(frame, map, fp, AskForAlpha); } -void CanvasWindow::restOfCtor (BRect canvasFrame, BBitmap *map, FILE *fp, bool AskForAlpha, rgb_color color) +void +CanvasWindow::restOfCtor( + BRect canvasFrame, BBitmap* map, FILE* fp, bool AskForAlpha, rgb_color color +) { - SetPulseRate (50000); + SetPulseRate(50000); magWindow = NULL; layerOpen = false; menuIsOn = false; scripted = false; BRect frame, hFrame, vFrame, menubarFrame, posFrame; - menubarFrame.Set (0, 0, 0, 0); - menubar = new BMenuBar (menubarFrame, "CanvasMenubar"); - fileMenu = new BMenu (lstring (10, "File")); - BMenu *captureMenu = new BMenu (lstring (14, "Capture")); - captureMenu->SetEnabled (false); - fileMenu->AddItem (new BMenuItem (lstring (11, "New Canvas…"), new BMessage ('newc'), 'N')); -// fileMenu->AddItem (new BMenuItem (lstring (12, "Open File…"), new BMessage ('open'), 'O')); - BMenuItem *recent = make_recent_menu(); - recent->SetTarget (be_app); - fileMenu->AddItem (recent);// new BMenu (lstring (13, "Open Recent")); - fileMenu->AddItem (captureMenu); + menubarFrame.Set(0, 0, 0, 0); + menubar = new BMenuBar(menubarFrame, "CanvasMenubar"); + fileMenu = new BMenu(lstring(10, "File")); + BMenu* captureMenu = new BMenu(lstring(14, "Capture")); + captureMenu->SetEnabled(false); + fileMenu->AddItem(new BMenuItem(lstring(11, "New Canvas…"), new BMessage('newc'), 'N')); + // fileMenu->AddItem (new BMenuItem (lstring (12, "Open File…"), new BMessage ('open'), 'O')); + BMenuItem* recent = make_recent_menu(); + recent->SetTarget(be_app); + fileMenu->AddItem(recent); // new BMenu (lstring (13, "Open Recent")); + fileMenu->AddItem(captureMenu); fileMenu->AddSeparatorItem(); - fileMenu->AddItem (new BMenuItem (lstring (50, "Save"), new BMessage ('save'), 'S')); - fileMenu->AddItem (new BMenuItem (lstring (51, "Save As…"), new BMessage ('savs'), 'S', B_SHIFT_KEY)); - fileMenu->AddItem (new BMenuItem (lstring (52, "Export…"), new BMessage ('Expt'), 'S', B_CONTROL_KEY)); + fileMenu->AddItem(new BMenuItem(lstring(50, "Save"), new BMessage('save'), 'S')); + fileMenu->AddItem(new BMenuItem(lstring(51, "Save As…"), new BMessage('savs'), 'S', B_SHIFT_KEY) + ); + fileMenu->AddItem( + new BMenuItem(lstring(52, "Export…"), new BMessage('Expt'), 'S', B_CONTROL_KEY) + ); extern bool ExportCstruct; if (ExportCstruct) - fileMenu->AddItem (new BMenuItem ("Export as C struct", new BMessage ('ExpC'))); + fileMenu->AddItem(new BMenuItem("Export as C struct", new BMessage('ExpC'))); fileMenu->AddSeparatorItem(); - BMenuItem *item = new BMenuItem (lstring (15, "Print Setup…"), new BMessage ('PrSU')); - item->SetTarget (be_app); - fileMenu->AddItem (item); - fileMenu->AddItem (new BMenuItem (lstring (53, "Print"), new BMessage ('PrPP'))); + BMenuItem* item = new BMenuItem(lstring(15, "Print Setup…"), new BMessage('PrSU')); + item->SetTarget(be_app); + fileMenu->AddItem(item); + fileMenu->AddItem(new BMenuItem(lstring(53, "Print"), new BMessage('PrPP'))); fileMenu->AddSeparatorItem(); - item = new BMenuItem (lstring (16, "About Becasso"), new BMessage (B_ABOUT_REQUESTED)); - item->SetTarget (be_app); - fileMenu->AddItem (item); + item = new BMenuItem(lstring(16, "About Becasso"), new BMessage(B_ABOUT_REQUESTED)); + item->SetTarget(be_app); + fileMenu->AddItem(item); fileMenu->AddSeparatorItem(); - fileMenu->AddItem (new BMenuItem (lstring (54, "Close"), new BMessage (B_QUIT_REQUESTED), 'W')); - fileMenu->AddItem (new BMenuItem (lstring (55, "Quit"), new BMessage (B_QUIT_REQUESTED), 'Q')); - menubar->AddItem (fileMenu); - fileMenu->FindItem('newc')->SetTarget (be_app); + fileMenu->AddItem(new BMenuItem(lstring(54, "Close"), new BMessage(B_QUIT_REQUESTED), 'W')); + fileMenu->AddItem(new BMenuItem(lstring(55, "Quit"), new BMessage(B_QUIT_REQUESTED), 'Q')); + menubar->AddItem(fileMenu); + fileMenu->FindItem('newc')->SetTarget(be_app); #ifndef BE_RECENT_MENU - fileMenu->FindItem('open')->SetTarget (be_app); + fileMenu->FindItem('open')->SetTarget(be_app); #endif - fileMenu->FindItem(lstring (55, "Quit"))->SetTarget (be_app); + fileMenu->FindItem(lstring(55, "Quit"))->SetTarget(be_app); // N.B. FindItem(Q_QUIT_REQUESTED) doesn't work!? - editMenu = new BMenu (lstring (60, "Edit")); - editMenu->AddItem (new BMenuItem (lstring (61, "Undo"), new BMessage (B_UNDO), 'Z')); - editMenu->AddItem (new BMenuItem (lstring (62, "Redo"), new BMessage ('redo'), 'Z', B_SHIFT_KEY)); + editMenu = new BMenu(lstring(60, "Edit")); + editMenu->AddItem(new BMenuItem(lstring(61, "Undo"), new BMessage(B_UNDO), 'Z')); + editMenu->AddItem(new BMenuItem(lstring(62, "Redo"), new BMessage('redo'), 'Z', B_SHIFT_KEY)); editMenu->AddSeparatorItem(); - editMenu->AddItem (new BMenuItem (lstring (63, "Cut"), new BMessage (B_CUT), 'X')); - editMenu->AddItem (new BMenuItem (lstring (64, "Copy"), new BMessage (B_COPY), 'C')); - editMenu->AddItem (new BMenuItem (lstring (65, "Paste"), new BMessage (B_PASTE), 'V')); - editMenu->AddItem (new BMenuItem (lstring (403, "Paste to New Layer"), new BMessage ('psNL'), 'V', B_SHIFT_KEY)); - editMenu->AddItem (new BMenuItem (lstring (404, "Paste to New Canvas"), new BMessage ('psNC'), 'V', B_CONTROL_KEY)); - editMenu->AddItem (new BMenuItem (lstring (66, "Select All"), new BMessage (B_SELECT_ALL), 'A')); - editMenu->AddItem (new BMenuItem (lstring (67, "Deselect All"), new BMessage ('sund'), 'D')); - editMenu->AddItem (new BMenuItem (lstring (68, "Invert Selection"), new BMessage ('sinv'))); - BMenu *ktsMenu = new BMenu (lstring (69, "Select by Color")); - ktsMenu->AddItem (new BMenuItem (lstring (70, "Foreground"), new BMessage ('ktsF'))); - ktsMenu->AddItem (new BMenuItem (lstring (71, "Background"), new BMessage ('ktsB'))); - ktsMenu->AddItem (new BMenuItem (lstring (72, "Automatic"), new BMessage ('ktsA'))); - editMenu->AddItem (ktsMenu); - BMenu *stkMenu = new BMenu (lstring (73, "Colorize Selection")); - stkMenu->AddItem (new BMenuItem (lstring (70, "Foreground"), new BMessage ('stkF'))); - stkMenu->AddItem (new BMenuItem (lstring (71, "Background"), new BMessage ('stkB'))); - editMenu->AddItem (stkMenu); - editMenu->AddItem (new BMenuItem (lstring (74, "Extract Palette…"), new BMessage ('xpal'))); - BMenu *ctsMenu = new BMenu (lstring (75, "Channel to Selection")); - ctsMenu->AddItem (new BMenuItem (lstring (76, "Alpha"), new BMessage ('ctsA'))); - ctsMenu->AddItem (new BMenuItem (lstring (77, "Red"), new BMessage ('ctsR'))); - ctsMenu->AddItem (new BMenuItem (lstring (78, "Green"), new BMessage ('ctsG'))); - ctsMenu->AddItem (new BMenuItem (lstring (79, "Blue"), new BMessage ('ctsB'))); + editMenu->AddItem(new BMenuItem(lstring(63, "Cut"), new BMessage(B_CUT), 'X')); + editMenu->AddItem(new BMenuItem(lstring(64, "Copy"), new BMessage(B_COPY), 'C')); + editMenu->AddItem(new BMenuItem(lstring(65, "Paste"), new BMessage(B_PASTE), 'V')); + editMenu->AddItem( + new BMenuItem(lstring(403, "Paste to New Layer"), new BMessage('psNL'), 'V', B_SHIFT_KEY) + ); + editMenu->AddItem( + new BMenuItem(lstring(404, "Paste to New Canvas"), new BMessage('psNC'), 'V', B_CONTROL_KEY) + ); + editMenu->AddItem(new BMenuItem(lstring(66, "Select All"), new BMessage(B_SELECT_ALL), 'A')); + editMenu->AddItem(new BMenuItem(lstring(67, "Deselect All"), new BMessage('sund'), 'D')); + editMenu->AddItem(new BMenuItem(lstring(68, "Invert Selection"), new BMessage('sinv'))); + BMenu* ktsMenu = new BMenu(lstring(69, "Select by Color")); + ktsMenu->AddItem(new BMenuItem(lstring(70, "Foreground"), new BMessage('ktsF'))); + ktsMenu->AddItem(new BMenuItem(lstring(71, "Background"), new BMessage('ktsB'))); + ktsMenu->AddItem(new BMenuItem(lstring(72, "Automatic"), new BMessage('ktsA'))); + editMenu->AddItem(ktsMenu); + BMenu* stkMenu = new BMenu(lstring(73, "Colorize Selection")); + stkMenu->AddItem(new BMenuItem(lstring(70, "Foreground"), new BMessage('stkF'))); + stkMenu->AddItem(new BMenuItem(lstring(71, "Background"), new BMessage('stkB'))); + editMenu->AddItem(stkMenu); + editMenu->AddItem(new BMenuItem(lstring(74, "Extract Palette…"), new BMessage('xpal'))); + BMenu* ctsMenu = new BMenu(lstring(75, "Channel to Selection")); + ctsMenu->AddItem(new BMenuItem(lstring(76, "Alpha"), new BMessage('ctsA'))); + ctsMenu->AddItem(new BMenuItem(lstring(77, "Red"), new BMessage('ctsR'))); + ctsMenu->AddItem(new BMenuItem(lstring(78, "Green"), new BMessage('ctsG'))); + ctsMenu->AddItem(new BMenuItem(lstring(79, "Blue"), new BMessage('ctsB'))); ctsMenu->AddSeparatorItem(); - ctsMenu->AddItem (new BMenuItem (lstring (80, "Cyan"), new BMessage ('ctsC'))); - ctsMenu->AddItem (new BMenuItem (lstring (81, "Magenta"), new BMessage ('ctsM'))); - ctsMenu->AddItem (new BMenuItem (lstring (82, "Yellow"), new BMessage ('ctsY'))); - ctsMenu->AddItem (new BMenuItem (lstring (83, "Black"), new BMessage ('ctsK'))); + ctsMenu->AddItem(new BMenuItem(lstring(80, "Cyan"), new BMessage('ctsC'))); + ctsMenu->AddItem(new BMenuItem(lstring(81, "Magenta"), new BMessage('ctsM'))); + ctsMenu->AddItem(new BMenuItem(lstring(82, "Yellow"), new BMessage('ctsY'))); + ctsMenu->AddItem(new BMenuItem(lstring(83, "Black"), new BMessage('ctsK'))); ctsMenu->AddSeparatorItem(); - ctsMenu->AddItem (new BMenuItem (lstring (84, "Hue"), new BMessage ('ctsH'))); - ctsMenu->AddItem (new BMenuItem (lstring (85, "Saturation"), new BMessage ('ctsS'))); - ctsMenu->AddItem (new BMenuItem (lstring (86, "Value"), new BMessage ('ctsV'))); - editMenu->AddItem (ctsMenu); - BMenu *stcMenu = new BMenu (lstring (87, "Selection to Channel")); - stcMenu->AddItem (new BMenuItem (lstring (76, "Alpha"), new BMessage ('stcA'))); - stcMenu->AddItem (new BMenuItem (lstring (77, "Red"), new BMessage ('stcR'))); - stcMenu->AddItem (new BMenuItem (lstring (78, "Green"), new BMessage ('stcG'))); - stcMenu->AddItem (new BMenuItem (lstring (79, "Blue"), new BMessage ('stcB'))); + ctsMenu->AddItem(new BMenuItem(lstring(84, "Hue"), new BMessage('ctsH'))); + ctsMenu->AddItem(new BMenuItem(lstring(85, "Saturation"), new BMessage('ctsS'))); + ctsMenu->AddItem(new BMenuItem(lstring(86, "Value"), new BMessage('ctsV'))); + editMenu->AddItem(ctsMenu); + BMenu* stcMenu = new BMenu(lstring(87, "Selection to Channel")); + stcMenu->AddItem(new BMenuItem(lstring(76, "Alpha"), new BMessage('stcA'))); + stcMenu->AddItem(new BMenuItem(lstring(77, "Red"), new BMessage('stcR'))); + stcMenu->AddItem(new BMenuItem(lstring(78, "Green"), new BMessage('stcG'))); + stcMenu->AddItem(new BMenuItem(lstring(79, "Blue"), new BMessage('stcB'))); stcMenu->AddSeparatorItem(); - stcMenu->AddItem (new BMenuItem (lstring (80, "Cyan"), new BMessage ('stcC'))); - stcMenu->AddItem (new BMenuItem (lstring (81, "Magenta"), new BMessage ('stcM'))); - stcMenu->AddItem (new BMenuItem (lstring (82, "Yellow"), new BMessage ('stcY'))); - stcMenu->AddItem (new BMenuItem (lstring (83, "Black"), new BMessage ('stcK'))); + stcMenu->AddItem(new BMenuItem(lstring(80, "Cyan"), new BMessage('stcC'))); + stcMenu->AddItem(new BMenuItem(lstring(81, "Magenta"), new BMessage('stcM'))); + stcMenu->AddItem(new BMenuItem(lstring(82, "Yellow"), new BMessage('stcY'))); + stcMenu->AddItem(new BMenuItem(lstring(83, "Black"), new BMessage('stcK'))); stcMenu->AddSeparatorItem(); - stcMenu->AddItem (new BMenuItem (lstring (84, "Hue"), new BMessage ('stcH'))); - stcMenu->AddItem (new BMenuItem (lstring (85, "Saturation"), new BMessage ('stcS'))); - stcMenu->AddItem (new BMenuItem (lstring (86, "Value"), new BMessage ('stcV'))); - editMenu->AddItem (stcMenu); + stcMenu->AddItem(new BMenuItem(lstring(84, "Hue"), new BMessage('stcH'))); + stcMenu->AddItem(new BMenuItem(lstring(85, "Saturation"), new BMessage('stcS'))); + stcMenu->AddItem(new BMenuItem(lstring(86, "Value"), new BMessage('stcV'))); + editMenu->AddItem(stcMenu); editMenu->AddSeparatorItem(); - BMenu *imageMenu = new BMenu (lstring (90, "Entire Canvas")); - imageMenu->AddItem (new BMenuItem (lstring (91, "Crop to Window"), new BMessage ('cwin'))); - imageMenu->AddItem (new BMenuItem (lstring (92, "Crop to Selection"), new BMessage ('csel'))); - imageMenu->AddItem (new BMenuItem (lstring (93, "Autocrop"), new BMessage ('caut'))); - BMenu *padMenu = new BMenu (lstring (94, "Pad to Window")); - padMenu->AddItem (new BMenuItem (lstring (95, "Left Top"), new BMessage ('pwlt'))); - padMenu->AddItem (new BMenuItem (lstring (96, "Right Top"), new BMessage ('pwrt'))); - padMenu->AddItem (new BMenuItem (lstring (97, "Left Bottom"), new BMessage ('pwlb'))); - padMenu->AddItem (new BMenuItem (lstring (98, "Right Bottom"), new BMessage ('pwrb'))); - padMenu->AddItem (new BMenuItem (lstring (99, "Center"), new BMessage ('pwct'))); - imageMenu->AddItem (padMenu); - BMenu *resizeMenu = new BMenu (lstring (100, "Resize to Window")); - resizeMenu->AddItem (new BMenuItem (lstring (101, "Preserve Ratio"), new BMessage ('rwkr'))); - resizeMenu->AddItem (new BMenuItem (lstring (102, "Adapt Ratio"), new BMessage ('rwar'))); - imageMenu->AddItem (resizeMenu); - imageMenu->AddItem (new BMenuItem (lstring (107, "Resize To…"), new BMessage ('rszT'))); - BMenu *rotateMenu = new BMenu (lstring (89, "Rotate")); - rotateMenu->AddItem (new BMenuItem ("90°", new BMessage ('r90'))); - rotateMenu->AddItem (new BMenuItem ("180°", new BMessage ('r180'))); - rotateMenu->AddItem (new BMenuItem ("270°", new BMessage ('r270'))); - imageMenu->AddItem (rotateMenu); - editMenu->AddItem (imageMenu); - BMenu *filters = new BMenu (lstring (103, "Filter")); - BMenu *transformers = new BMenu (lstring (104, "Transform")); - BMenu *generators = new BMenu (lstring (105, "Generate")); - extern BList *AddOns; - AddOn *addon; - for (long i = 0; addon = (AddOn *) AddOns->ItemAt (i), addon; i++) - { - BMessage *m = new BMessage ('adon'); - m->AddInt32 ("index", i); - switch (addon->Type()) - { - case BECASSO_FILTER: - { - filters->AddItem (new BMenuItem (addon->Name(), m)); + BMenu* imageMenu = new BMenu(lstring(90, "Entire Canvas")); + imageMenu->AddItem(new BMenuItem(lstring(91, "Crop to Window"), new BMessage('cwin'))); + imageMenu->AddItem(new BMenuItem(lstring(92, "Crop to Selection"), new BMessage('csel'))); + imageMenu->AddItem(new BMenuItem(lstring(93, "Autocrop"), new BMessage('caut'))); + BMenu* padMenu = new BMenu(lstring(94, "Pad to Window")); + padMenu->AddItem(new BMenuItem(lstring(95, "Left Top"), new BMessage('pwlt'))); + padMenu->AddItem(new BMenuItem(lstring(96, "Right Top"), new BMessage('pwrt'))); + padMenu->AddItem(new BMenuItem(lstring(97, "Left Bottom"), new BMessage('pwlb'))); + padMenu->AddItem(new BMenuItem(lstring(98, "Right Bottom"), new BMessage('pwrb'))); + padMenu->AddItem(new BMenuItem(lstring(99, "Center"), new BMessage('pwct'))); + imageMenu->AddItem(padMenu); + BMenu* resizeMenu = new BMenu(lstring(100, "Resize to Window")); + resizeMenu->AddItem(new BMenuItem(lstring(101, "Preserve Ratio"), new BMessage('rwkr'))); + resizeMenu->AddItem(new BMenuItem(lstring(102, "Adapt Ratio"), new BMessage('rwar'))); + imageMenu->AddItem(resizeMenu); + imageMenu->AddItem(new BMenuItem(lstring(107, "Resize To…"), new BMessage('rszT'))); + BMenu* rotateMenu = new BMenu(lstring(89, "Rotate")); + rotateMenu->AddItem(new BMenuItem("90°", new BMessage('r90'))); + rotateMenu->AddItem(new BMenuItem("180°", new BMessage('r180'))); + rotateMenu->AddItem(new BMenuItem("270°", new BMessage('r270'))); + imageMenu->AddItem(rotateMenu); + editMenu->AddItem(imageMenu); + BMenu* filters = new BMenu(lstring(103, "Filter")); + BMenu* transformers = new BMenu(lstring(104, "Transform")); + BMenu* generators = new BMenu(lstring(105, "Generate")); + extern BList* AddOns; + AddOn* addon; + for (long i = 0; addon = (AddOn*)AddOns->ItemAt(i), addon; i++) { + BMessage* m = new BMessage('adon'); + m->AddInt32("index", i); + switch (addon->Type()) { + case BECASSO_FILTER: { + filters->AddItem(new BMenuItem(addon->Name(), m)); break; } - case BECASSO_TRANSFORMER: - { - transformers->AddItem (new BMenuItem (addon->Name(), m)); + case BECASSO_TRANSFORMER: { + transformers->AddItem(new BMenuItem(addon->Name(), m)); break; } - case BECASSO_GENERATOR: - { - generators->AddItem (new BMenuItem (addon->Name(), m)); + case BECASSO_GENERATOR: { + generators->AddItem(new BMenuItem(addon->Name(), m)); break; } - case BECASSO_CAPTURE: - { + case BECASSO_CAPTURE: { delete m; - BMessage *ms = new BMessage ('capt'); - ms->AddInt32 ("index", i); -// BMenuItem *it = new BMenuItem (addon->Name(), ms); - captureMenu->AddItem (new BMenuItem (addon->Name(), ms)); - captureMenu->SetEnabled (true); + BMessage* ms = new BMessage('capt'); + ms->AddInt32("index", i); + // BMenuItem *it = new BMenuItem (addon->Name(), ms); + captureMenu->AddItem(new BMenuItem(addon->Name(), ms)); + captureMenu->SetEnabled(true); break; } default: - fprintf (stderr, "Unknown Add-On type! (%li: %i)\n", i, addon->Type()); + fprintf(stderr, "Unknown Add-On type! (%li: %i)\n", i, addon->Type()); break; } } - editMenu->AddItem (filters); - editMenu->AddItem (transformers); - editMenu->AddItem (generators); + editMenu->AddItem(filters); + editMenu->AddItem(transformers); + editMenu->AddItem(generators); editMenu->AddSeparatorItem(); - editMenu->AddItem (new BMenuItem (lstring (106, "Center Mouse"), new BMessage ('cmus'), 'M')); - menubar->AddItem (editMenu); - windowMenu = new BMenu (lstring (110, "Window")); - windowMenu->AddItem (new BMenuItem (lstring (111, "Layers"), new BMessage ('layr'), 'L')); - windowMenu->AddItem (new BMenuItem (lstring (116, "Magnify"), new BMessage ('mwin'))); - BMenu *magnifyMenu = new BMenu (lstring (112, "Scale")); - magnifyMenu->AddItem (new BMenuItem (lstring (113, "Zoom In"), new BMessage ('Min'), '+')); - magnifyMenu->AddItem (new BMenuItem (lstring (114, "Zoom Out"), new BMessage ('Mout'), '-')); - magnifyMenu->AddItem (new BMenuItem ("12.5% (1:8)", new BMessage ('M-8'))); - magnifyMenu->AddItem (new BMenuItem ("25% (1:4)", new BMessage ('M-4'))); - magnifyMenu->AddItem (new BMenuItem ("50% (1:2)", new BMessage ('M-2'))); - magnifyMenu->AddItem (new BMenuItem ("100% (1:1)", new BMessage ('M1'), '=')); - magnifyMenu->AddItem (new BMenuItem ("200% (2:1)", new BMessage ('M2'))); - magnifyMenu->AddItem (new BMenuItem ("400% (4:1)", new BMessage ('M4'))); - magnifyMenu->AddItem (new BMenuItem ("800% (8:1)", new BMessage ('M8'))); - magnifyMenu->AddItem (new BMenuItem ("1600% (16:1)", new BMessage ('M16'))); - windowMenu->AddItem (magnifyMenu); - windowMenu->AddItem (new BMenuItem (lstring (115, "Resize to Fit"), new BMessage ('rstf'), 'Y')); - menubar->AddItem (windowMenu); - layerMenu = new BMenu (lstring (120, "Layer")); - layerMenu->AddItem (new BMenuItem (lstring (121, "Add New"), new BMessage ('newL'))); - layerMenu->AddItem (new BMenuItem (lstring (122, "Insert New"), new BMessage ('insL'))); - layerMenu->AddItem (new BMenuItem (lstring (123, "Duplicate"), new BMessage ('dupL'))); - layerMenu->AddItem (new BMenuItem (lstring (124, "Remove"), new BMessage ('delL'))); - layerMenu->AddItem (new BMenuItem (lstring (125, "Merge"), new BMessage ('mrgL'))); + editMenu->AddItem(new BMenuItem(lstring(106, "Center Mouse"), new BMessage('cmus'), 'M')); + menubar->AddItem(editMenu); + windowMenu = new BMenu(lstring(110, "Window")); + windowMenu->AddItem(new BMenuItem(lstring(111, "Layers"), new BMessage('layr'), 'L')); + windowMenu->AddItem(new BMenuItem(lstring(116, "Magnify"), new BMessage('mwin'))); + + BMenu* magnifyMenu = new BMenu(lstring(112, "Scale")); + magnifyMenu->AddItem(new BMenuItem(lstring(113, "Zoom In"), new BMessage('Min'), '+')); + magnifyMenu->AddItem(new BMenuItem(lstring(114, "Zoom Out"), new BMessage('Mout'), '-')); + + for (int i = 0; i < B_COUNT_OF(zoomLevels) && i < B_COUNT_OF(aspectLevels); ++i) { + fNumberFormat.FormatPercent(fPercentData, zoomLevels[i]); + BMessage* message = new BMessage('M_S'); + message->AddFloat("scale", zoomLevels[i]); + message->AddInt32("index", 1); + + if (zoomLevels[i] >= 10.0) { + BString separator(fNumberFormat.GetSeparator(B_GROUPING_SEPARATOR)); + fPercentData.RemoveFirst(separator); + } + + BString label; + label.SetToFormat("%s %s", fPercentData.String(), aspectLevels[i]); + magnifyMenu->AddItem(new BMenuItem(label.String(), message)); + } + + windowMenu->AddItem(magnifyMenu); + + windowMenu->AddItem(new BMenuItem(lstring(115, "Resize to Fit"), new BMessage('rstf'), 'Y')); + menubar->AddItem(windowMenu); + layerMenu = new BMenu(lstring(120, "Layer")); + layerMenu->AddItem(new BMenuItem(lstring(121, "Add New"), new BMessage('newL'))); + layerMenu->AddItem(new BMenuItem(lstring(122, "Insert New"), new BMessage('insL'))); + layerMenu->AddItem(new BMenuItem(lstring(123, "Duplicate"), new BMessage('dupL'))); + layerMenu->AddItem(new BMenuItem(lstring(124, "Remove"), new BMessage('delL'))); + layerMenu->AddItem(new BMenuItem(lstring(125, "Merge"), new BMessage('mrgL'))); layerMenu->AddSeparatorItem(); - layerMenu->AddItem (new BMenuItem (lstring (88, "Translate"), new BMessage ('trsL'))); - layerMenu->AddItem (new BMenuItem (lstring (89, "Rotate"), new BMessage ('rotL'))); - BMenu *flipMenu = new BMenu (lstring (108, "Flip")); - flipMenu->AddItem (new BMenuItem (lstring (400, "Horizontal"), new BMessage ('flpH'))); - flipMenu->AddItem (new BMenuItem (lstring (401, "Vertical"), new BMessage ('flpV'))); - layerMenu->AddItem (flipMenu); + layerMenu->AddItem(new BMenuItem(lstring(88, "Translate"), new BMessage('trsL'))); + layerMenu->AddItem(new BMenuItem(lstring(89, "Rotate"), new BMessage('rotL'))); + BMenu* flipMenu = new BMenu(lstring(108, "Flip")); + flipMenu->AddItem(new BMenuItem(lstring(400, "Horizontal"), new BMessage('flpH'))); + flipMenu->AddItem(new BMenuItem(lstring(401, "Vertical"), new BMessage('flpV'))); + layerMenu->AddItem(flipMenu); layerMenu->AddSeparatorItem(); - layerMenu->AddItem (new BMenuItem (lstring (126, "Up One"), new BMessage ('Loup'), '[')); - layerMenu->AddItem (new BMenuItem (lstring (127, "Down One"), new BMessage ('Lodn'), ']')); - layerNamesMenu = new BMenu (lstring (128, "Select")); - layerMenu->AddItem (layerNamesMenu); - menubar->AddItem (layerMenu); - AddChild (menubar); + layerMenu->AddItem(new BMenuItem(lstring(126, "Up One"), new BMessage('Loup'), '[')); + layerMenu->AddItem(new BMenuItem(lstring(127, "Down One"), new BMessage('Lodn'), ']')); + layerNamesMenu = new BMenu(lstring(128, "Select")); + layerMenu->AddItem(layerNamesMenu); + menubar->AddItem(layerMenu); + AddChild(menubar); menubar->ResizeToPreferred(); menubarFrame = menubar->Frame(); if (map) canvasFrame = map->Bounds(); -// canvasFrame.PrintToStream(); - frame.Set (0, 0, - max_c (canvasFrame.Width() + B_V_SCROLL_BAR_WIDTH, MIN_WIDTH), - max_c (canvasFrame.Height() + B_H_SCROLL_BAR_HEIGHT + menubarFrame.Height() + 1, MIN_HEIGHT)); -// frame.PrintToStream(); + // canvasFrame.PrintToStream(); + frame.Set( + 0, 0, max_c(canvasFrame.Width() + B_V_SCROLL_BAR_WIDTH, MIN_WIDTH), + max_c(canvasFrame.Height() + B_H_SCROLL_BAR_HEIGHT + menubarFrame.Height() + 1, MIN_HEIGHT) + ); + // frame.PrintToStream(); { BScreen screen; - SetZoomLimits (screen.Frame().Width(), screen.Frame().Height()); - } - SetSizeLimits (MIN_WIDTH, 9999, MIN_HEIGHT, 9999); - ResizeTo (frame.Width(), frame.Height()); - BRect bgFrame = BRect (0, 0, max_c (MIN_WIDTH - B_V_SCROLL_BAR_WIDTH, canvasFrame.Width()), - max_c (MIN_HEIGHT - B_H_SCROLL_BAR_HEIGHT - menubarFrame.Height() - 1, canvasFrame.Height())); - bgFrame.OffsetTo (menubarFrame.left, menubarFrame.bottom + 1); -// bgFrame.PrintToStream(); - frame.OffsetTo (menubarFrame.left, menubarFrame.bottom + 1); - bg = new BGView (bgFrame, "Background View", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS); - AddChild (bg); - canvasFrame.OffsetTo (B_ORIGIN); - + SetZoomLimits(screen.Frame().Width(), screen.Frame().Height()); + } + SetSizeLimits(MIN_WIDTH, 9999, MIN_HEIGHT, 9999); + ResizeTo(frame.Width(), frame.Height()); + BRect bgFrame = BRect( + 0, 0, max_c(MIN_WIDTH - B_V_SCROLL_BAR_WIDTH, canvasFrame.Width()), + max_c(MIN_HEIGHT - B_H_SCROLL_BAR_HEIGHT - menubarFrame.Height() - 1, canvasFrame.Height()) + ); + bgFrame.OffsetTo(menubarFrame.left, menubarFrame.bottom + 1); + // bgFrame.PrintToStream(); + frame.OffsetTo(menubarFrame.left, menubarFrame.bottom + 1); + bg = new BGView(bgFrame, "Background View", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS); + AddChild(bg); + canvasFrame.OffsetTo(B_ORIGIN); + ////////////////// if (fp) - canvas = new CanvasView (canvasFrame, "Canvas", fp); + canvas = new CanvasView(canvasFrame, "Canvas", fp); else - canvas = new CanvasView (canvasFrame, "Canvas", map, color); + canvas = new CanvasView(canvasFrame, "Canvas", map, color); ////////////////// - if (map && AskForAlpha) // AskForAlpha check added here as optimization + if (map && AskForAlpha) // AskForAlpha check added here as optimization { //////////////////////////////////////// - float avg = AverageAlpha (map); - if (avg < 128) - { - if (AskForAlpha) - { + float avg = AverageAlpha(map); + if (avg < 128) { + if (AskForAlpha) { char alert[2048]; - sprintf (alert, lstring (139, "%s the image `%s' uses alpha as transparency instead of opacity.\n%s inverting the alpha channel."), - (avg < 10) ? lstring (140, "I'm pretty sure") : lstring (141, "I suspect"), - fName, - (avg < 10) ? lstring (142, "If you're seeing only a checkered pattern,\nI suggest ") : lstring (143, "Either that, or this image has an awful lot of transparent pixels. If it looks strange, try ")); - BAlert *alphalert = new BAlert ("alphalert", alert, lstring (144, "Keep As-Is"), lstring (145, "Invert")); - /* int32 button_index = */ alphalert->Go (new BInvoker (new BMessage ('aliv'), this)); - } - else // Changed in 1.5: Don't invert without asking. + sprintf( + alert, + lstring( + 139, "%s the image `%s' uses alpha as transparency instead of opacity.\n%s " + "inverting the alpha channel." + ), + (avg < 10) ? lstring(140, "I'm pretty sure") : lstring(141, "I suspect"), fName, + (avg < 10) + ? lstring(142, "If you're seeing only a checkered pattern,\nI suggest ") + : lstring( + 143, "Either that, or this image has an awful lot of transparent " + "pixels. If it looks strange, try " + ) + ); + BAlert* alphalert = new BAlert( + "alphalert", alert, lstring(144, "Keep As-Is"), lstring(145, "Invert") + ); + /* int32 button_index = */ alphalert->Go(new BInvoker(new BMessage('aliv'), this)); + } else // Changed in 1.5: Don't invert without asking. { -// verbose (1, "Inverting alpha channel\n"); -// BMessage invert ('aliv'); -// invert.AddMessenger ("canvas", this); -// be_app->PostMessage (&invert); + // verbose (1, "Inverting alpha channel\n"); + // BMessage invert ('aliv'); + // invert.AddMessenger ("canvas", this); + // be_app->PostMessage (&invert); } } //////////////////////////////////////// delete map; map = NULL; } - posFrame.Set (-1, frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1, - POSWIDTH - 1, frame.Height() + 1); - posview = new PosView (posFrame, "PosView", canvas); - hFrame.Set (POSWIDTH, frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1, - frame.Width() - B_V_SCROLL_BAR_WIDTH + 1, - frame.Height() + 1); - h = new BScrollBar (hFrame, "sbH", bg, 0, canvasFrame.Width(), B_HORIZONTAL); - vFrame.Set (frame.Width() - B_V_SCROLL_BAR_WIDTH + 1, - menubarFrame.Height(), frame.Width() + 1, - frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1); - v = new BScrollBar (vFrame, "sbV", bg, 0, canvasFrame.Height(), B_VERTICAL); - AddChild (h); - AddChild (v); - bg->AddChild (canvas); - bg->FrameResized (bgFrame.Width(), bgFrame.Height()); - canvas->setBGView (bg); - AddChild (posview); + posFrame.Set(-1, frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1, POSWIDTH - 1, frame.Height() + 1); + posview = new PosView(posFrame, "PosView", canvas); + hFrame.Set( + POSWIDTH, frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1, + frame.Width() - B_V_SCROLL_BAR_WIDTH + 1, frame.Height() + 1 + ); + h = new BScrollBar(hFrame, "sbH", bg, 0, canvasFrame.Width(), B_HORIZONTAL); + vFrame.Set( + frame.Width() - B_V_SCROLL_BAR_WIDTH + 1, menubarFrame.Height(), frame.Width() + 1, + frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1 + ); + v = new BScrollBar(vFrame, "sbV", bg, 0, canvasFrame.Height(), B_VERTICAL); + AddChild(h); + AddChild(v); + bg->AddChild(canvas); + bg->FrameResized(bgFrame.Width(), bgFrame.Height()); + canvas->setBGView(bg); + AddChild(posview); quitting = false; - savePanel = new BFilePanel (B_SAVE_PANEL, new BMessenger (this), NULL, - B_FILE_NODE, false); + savePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this), NULL, B_FILE_NODE, false); extern entry_ref gSaveRef; // Make this a preference! - savePanel->SetPanelDirectory (&gSaveRef); + savePanel->SetPanelDirectory(&gSaveRef); outputFormatWindow = NULL; bitmapStream = NULL; - of_selected = new BInvoker (new BMessage ('oFsl'), this); + of_selected = new BInvoker(new BMessage('oFsl'), this); out_type = 0; fScale = 1; setLayerMenu(); fCurrentProperty = 0; - ieTarget = NULL; // BeDC hack for interaction with ImageElements + ieTarget = NULL; // BeDC hack for interaction with ImageElements extractWindow = NULL; - + // Notify the main app so it can add us to its canvases list. BMessage notify('creg'); - notify.AddPointer ("looper", Looper()); - notify.AddString ("name", fName); - be_app->PostMessage (¬ify); - strcpy (fCanvasName, fName); // fName can change due to "save as" and exporting. - -// printf ("CanvasWindow::ctor done\n"); + notify.AddPointer("looper", Looper()); + notify.AddString("name", fName); + be_app->PostMessage(¬ify); + strcpy(fCanvasName, fName); // fName can change due to "save as" and exporting. + + // printf ("CanvasWindow::ctor done\n"); } -CanvasWindow::~CanvasWindow () +CanvasWindow::~CanvasWindow() { delete bitmapStream; delete of_selected; @@ -557,291 +621,285 @@ CanvasWindow::~CanvasWindow () delete myTarget; // Notify the main app so it can remove us from its canvases list. - BMessage notify ('cdel'); - notify.AddPointer ("looper", Looper()); - be_app->PostMessage (¬ify); + BMessage notify('cdel'); + notify.AddPointer("looper", Looper()); + be_app->PostMessage(¬ify); } -void CanvasWindow::MenusBeginning () +void +CanvasWindow::MenusBeginning() { -// make_recent_menu (recentMenu); + // make_recent_menu (recentMenu); menuIsOn = true; } -void CanvasWindow::MenusEnded () +void +CanvasWindow::MenusEnded() { menuIsOn = false; } - -void CanvasWindow::CanvasResized (float /* width */, float /* height */) +void +CanvasWindow::CanvasResized(float /* width */, float /* height */) { -// printf ("width = %f, height = %f\n", width, height); -// BRect canvasFrame = BRect (0, 0, width, height); -// BRect menubarFrame = menubar->Frame(); -// BRect frame = Frame(); -// frame.Set (0, 0, -// max_c (frame.Width() + B_V_SCROLL_BAR_WIDTH, MIN_WIDTH), -// max_c (frame.Height() + B_H_SCROLL_BAR_HEIGHT + menubarFrame.Height() + 1, MIN_HEIGHT)); -// frame.PrintToStream(); -// ResizeTo (frame.Width(), frame.Height()); + // printf ("width = %f, height = %f\n", width, height); + // BRect canvasFrame = BRect (0, 0, width, height); + // BRect menubarFrame = menubar->Frame(); + // BRect frame = Frame(); + // frame.Set (0, 0, + // max_c (frame.Width() + B_V_SCROLL_BAR_WIDTH, MIN_WIDTH), + // max_c (frame.Height() + B_H_SCROLL_BAR_HEIGHT + menubarFrame.Height() + 1, MIN_HEIGHT)); + // frame.PrintToStream(); + // ResizeTo (frame.Width(), frame.Height()); } -#if defined (__POWERPC__) -# pragma optimization_level 4 +#if defined(__POWERPC__) +#pragma optimization_level 4 #endif -void CanvasWindow::setLayerMenu () +void +CanvasWindow::setLayerMenu() { - layerMenu->RemoveItem (layerNamesMenu); + layerMenu->RemoveItem(layerNamesMenu); delete layerNamesMenu; - layerNamesMenu = new BMenu (lstring (129, "Select Layer")); - for (int i = canvas->numLayers() - 1; i >= 0; i--) - { - BMessage *lmsg = new BMessage ('lSel'); - lmsg->AddInt32 ("index", i); - BMenuItem *item = new BMenuItem (canvas->getLayer(i)->getName(), lmsg); + layerNamesMenu = new BMenu(lstring(129, "Select Layer")); + for (int i = canvas->numLayers() - 1; i >= 0; i--) { + BMessage* lmsg = new BMessage('lSel'); + lmsg->AddInt32("index", i); + BMenuItem* item = new BMenuItem(canvas->getLayer(i)->getName(), lmsg); if (i == canvas->currentLayerIndex()) - item->SetMarked (true); - layerNamesMenu->AddItem (item); - } - layerMenu->AddItem (layerNamesMenu); - if (canvas->currentLayerIndex() == 0) - { - layerMenu->FindItem('delL')->SetEnabled (false); - layerMenu->FindItem('mrgL')->SetEnabled (false); - layerMenu->FindItem('Lodn')->SetEnabled (false); + item->SetMarked(true); + layerNamesMenu->AddItem(item); } - else - { - layerMenu->FindItem('delL')->SetEnabled (true); - layerMenu->FindItem('mrgL')->SetEnabled (true); - layerMenu->FindItem('Lodn')->SetEnabled (true); + layerMenu->AddItem(layerNamesMenu); + if (canvas->currentLayerIndex() == 0) { + layerMenu->FindItem('delL')->SetEnabled(false); + layerMenu->FindItem('mrgL')->SetEnabled(false); + layerMenu->FindItem('Lodn')->SetEnabled(false); + } else { + layerMenu->FindItem('delL')->SetEnabled(true); + layerMenu->FindItem('mrgL')->SetEnabled(true); + layerMenu->FindItem('Lodn')->SetEnabled(true); } if (canvas->currentLayerIndex() < canvas->numLayers() - 1) - layerMenu->FindItem('Loup')->SetEnabled (true); + layerMenu->FindItem('Loup')->SetEnabled(true); else - layerMenu->FindItem('Loup')->SetEnabled (false); + layerMenu->FindItem('Loup')->SetEnabled(false); } -void CanvasWindow::CanvasScaled (float s) +void +CanvasWindow::CanvasScaled(float s) { fScale = s; - char title[MAX_FNAME]; - sprintf (title, "%s (%.0f%%)", fName, 100*s); - SetTitle (title); - FrameResized (Bounds().Width(), Bounds().Height()); + fNumberFormat.FormatPercent(fPercentData, (double)s); + fTitleString.SetToFormat("%s (%s)", fName, fPercentData.String()); + SetTitle(fTitleString.String()); + FrameResized(Bounds().Width(), Bounds().Height()); } -void CanvasWindow::setName (char *s) +void +CanvasWindow::setName(char* s) { - strcpy (fName, s); - char title[MAX_FNAME]; - sprintf (title, "%s (%.0f%%)", fName, 100*fScale); - SetTitle (title); + strcpy(fName, s); + fNumberFormat.FormatPercent(fPercentData, (double)fScale); + fTitleString.SetToFormat("%s (%s)", fName, fPercentData.String()); + SetTitle(fTitleString.String()); } -void CanvasWindow::setMenuItem (uint32 command, bool v) +void +CanvasWindow::setMenuItem(uint32 command, bool v) { - BMenuItem *item = editMenu->FindItem(command); - if (item) - { -// char *cmd = (char *)(&command); -// printf ("Item '%c%c%c%c' %sabled\n", cmd[3], cmd[2], cmd[1], cmd[0], v ? "en" : "dis"); - item->SetEnabled (v); - } - else - printf ("Item not found\n"); + BMenuItem* item = editMenu->FindItem(command); + if (item) { + // char *cmd = (char *)(&command); + // printf ("Item '%c%c%c%c' %sabled\n", cmd[3], cmd[2], cmd[1], cmd[0], v ? "en" : + //"dis"); + item->SetEnabled(v); + } else + printf("Item not found\n"); } -void CanvasWindow::setPaste (bool v) +void +CanvasWindow::setPaste(bool v) { - BMessage *msg = new BMessage ('SPst'); - msg->AddBool ("status", v); - be_app->PostMessage (msg); + BMessage* msg = new BMessage('SPst'); + msg->AddBool("status", v); + be_app->PostMessage(msg); delete msg; } -void CanvasWindow::FrameResized (float width, float height) +void +CanvasWindow::FrameResized(float width, float height) { BRect canvasFrame = canvas->Frame(); width -= B_V_SCROLL_BAR_WIDTH; height -= B_H_SCROLL_BAR_HEIGHT + menubar->Frame().Height() + 1; -// printf ("%f, %f; %f, %f\n", width, canvasFrame.Width(), height, canvasFrame.Height()); - if (width < canvasFrame.Width() || height < canvasFrame.Height()) - { - setMenuItem ('cwin', true); - setMenuItem ('pwlt', false); - setMenuItem ('pwrt', false); - setMenuItem ('pwlb', false); - setMenuItem ('pwrb', false); - setMenuItem ('pwct', false); - } - else - { - setMenuItem ('cwin', false); - setMenuItem ('pwlt', true); - setMenuItem ('pwrt', true); - setMenuItem ('pwlb', true); - setMenuItem ('pwrb', true); - setMenuItem ('pwct', true); + // printf ("%f, %f; %f, %f\n", width, canvasFrame.Width(), height, canvasFrame.Height()); + if (width < canvasFrame.Width() || height < canvasFrame.Height()) { + setMenuItem('cwin', true); + setMenuItem('pwlt', false); + setMenuItem('pwrt', false); + setMenuItem('pwlb', false); + setMenuItem('pwrb', false); + setMenuItem('pwct', false); + } else { + setMenuItem('cwin', false); + setMenuItem('pwlt', true); + setMenuItem('pwrt', true); + setMenuItem('pwlb', true); + setMenuItem('pwrb', true); + setMenuItem('pwct', true); } } -void CanvasWindow::FrameMoved (BPoint screenpoint) +void +CanvasWindow::FrameMoved(BPoint screenpoint) { -// Align the window on an 8x8 grid to prevent pattern misalignment. -// if (MessageQueue()->FindMessage (B_WINDOW_MOVED, 1) == NULL) -// { -// double dx = fmod (screenpoint.x, 8.0); -// double dy = fmod (screenpoint.y, 8.0); -// if (dx || dy) -// MoveBy (dx, dy); -// } - inherited::FrameMoved (screenpoint); + // Align the window on an 8x8 grid to prevent pattern misalignment. + // if (MessageQueue()->FindMessage (B_WINDOW_MOVED, 1) == NULL) + // { + // double dx = fmod (screenpoint.x, 8.0); + // double dy = fmod (screenpoint.y, 8.0); + // if (dx || dy) + // MoveBy (dx, dy); + // } + inherited::FrameMoved(screenpoint); } -void CanvasWindow::ScreenChanged (BRect frame, color_space mode) +void +CanvasWindow::ScreenChanged(BRect frame, color_space mode) { Lock(); - canvas->ScreenChanged (frame, mode); + canvas->ScreenChanged(frame, mode); Unlock(); } -void CanvasWindow::Quit () +void +CanvasWindow::Quit() { extern bool inPaste; quitting = true; inPaste = false; - if (layerOpen) - { - #if defined (VERBOSEQUIT) - printf ("LayerWindow Open\n"); - #endif - if (layerWindow->Lock()) - { - #if defined (VERBOSEQUIT) - printf ("Closing...\n"); - #endif + if (layerOpen) { +#if defined(VERBOSEQUIT) + printf("LayerWindow Open\n"); +#endif + if (layerWindow->Lock()) { +#if defined(VERBOSEQUIT) + printf("Closing...\n"); +#endif layerWindow->Close(); } } - if (magWindow) - { - #if defined (VERBOSEQUIT) - printf ("MagWindow Open\n"); - #endif - if (magWindow->Lock()) - { - #if defined (VERBOSEQUIT) - printf ("Closing\n"); - #endif + if (magWindow) { +#if defined(VERBOSEQUIT) + printf("MagWindow Open\n"); +#endif + if (magWindow->Lock()) { +#if defined(VERBOSEQUIT) + printf("Closing\n"); +#endif magWindow->Close(); } } - if (canvas->FilterOpen()) - { -// printf ("FilterOpen\n"); + if (canvas->FilterOpen()) { + // printf ("FilterOpen\n"); canvas->FilterOpen()->Close(true); } - if (canvas->TransformerOpen()) - { -// printf ("TransformerOpen\n"); + if (canvas->TransformerOpen()) { + // printf ("TransformerOpen\n"); canvas->TransformerOpen()->Close(true); } - if (canvas->GeneratorOpen()) - { -// printf ("GeneratorOpen\n"); + if (canvas->GeneratorOpen()) { + // printf ("GeneratorOpen\n"); canvas->GeneratorOpen()->Close(true); } - if (myTarget) - { - BMessage *ie = new BMessage (BBP_BBITMAP_CLOSED); - myTarget->SendMessage (ie); + if (myTarget) { + BMessage* ie = new BMessage(BBP_BBITMAP_CLOSED); + myTarget->SendMessage(ie); delete ie; } inherited::Quit(); } -BMessage *CanvasWindow::sendbitmapreply () +BMessage* +CanvasWindow::sendbitmapreply() { - BMessage *ie = new BMessage (BBP_SEND_BBITMAP); + BMessage* ie = new BMessage(BBP_SEND_BBITMAP); BMessage ieb; - ie->AddMessenger ("target", this); - BBitmap *b = canvas->canvas (true); - if (b->Archive (&ieb, false) == B_OK) - { - ie->AddMessage ("BBitmap", &ieb); + ie->AddMessenger("target", this); + BBitmap* b = canvas->canvas(true); + if (b->Archive(&ieb, false) == B_OK) { + ie->AddMessage("BBitmap", &ieb); canvas->changed = false; - } - else - { + } else { // Error - fprintf (stderr, "Error archiving BBitmap for sending\n"); + fprintf(stderr, "Error archiving BBitmap for sending\n"); } delete b; return ie; } -bool CanvasWindow::QuitRequested () +bool +CanvasWindow::QuitRequested() { -// printf ("%s: QuitRequested\n", fName); - if (!(canvas->changed)) - { + // printf ("%s: QuitRequested\n", fName); + if (!(canvas->changed)) { return (true); } - if (savePanel->IsShowing()) - { + if (savePanel->IsShowing()) { while (savePanel->IsShowing()) - snooze (500000); // YUCK!!! + snooze(500000); // YUCK!!! return (!(canvas->changed)); } - + char question[MAX_ALERTSIZE]; - sprintf (question, lstring (146, "Save changes to ‘%s’?"), fName); + sprintf(question, lstring(146, "Save changes to ‘%s’?"), fName); - BAlert *alert = new BAlert ("", question, lstring (131, "Cancel"), lstring (147, "Abandon"), lstring (148, "Save"), - B_WIDTH_FROM_WIDEST, B_INFO_ALERT); - alert->SetShortcut (0, B_ESCAPE); + BAlert* alert = new BAlert( + "", question, lstring(131, "Cancel"), lstring(147, "Abandon"), lstring(148, "Save"), + B_WIDTH_FROM_WIDEST, B_INFO_ALERT + ); + alert->SetShortcut(0, B_ESCAPE); int32 result = alert->Go(); - switch (result) - { - case 2: // Save - if (myTarget && !fromRef) - { - myTarget->SendMessage (sendbitmapreply()); - return (true); - } - else - { - savePanel->Show(); - while (savePanel->IsShowing()) - snooze (500000); // YUCK!!! - return (!(canvas->changed)); - } - case 1: // Abandon + switch (result) { + case 2: // Save + if (myTarget && !fromRef) { + myTarget->SendMessage(sendbitmapreply()); return (true); - default: // Cancel - return (false); + } else { + savePanel->Show(); + while (savePanel->IsShowing()) + snooze(500000); // YUCK!!! + return (!(canvas->changed)); + } + case 1: // Abandon + return (true); + default: // Cancel + return (false); } } -status_t CanvasWindow::GetSupportedSuites (BMessage *message) +status_t +CanvasWindow::GetSupportedSuites(BMessage* message) { - message->AddString ("suites", "suite/x-sum-canvas"); - BPropertyInfo info (prop_list, value_list); - message->AddFlat ("messages", &info); - return inherited::GetSupportedSuites (message); + message->AddString("suites", "suite/x-sum-canvas"); + BPropertyInfo info(prop_list, value_list); + message->AddFlat("messages", &info); + return inherited::GetSupportedSuites(message); } -BHandler *CanvasWindow::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +CanvasWindow::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { -// printf ("CanvasWindow::ResolveSpecifier!! message:\n"); -// message->PrintToStream(); -// printf ("\nspecifier:\n"); -// specifier->PrintToStream(); -// printf ("command: %d, property: ""%s""\n", command, property); + // printf ("CanvasWindow::ResolveSpecifier!! message:\n"); + // message->PrintToStream(); + // printf ("\nspecifier:\n"); + // specifier->PrintToStream(); + // printf ("command: %d, property: ""%s""\n", command, property); #if 0 @@ -875,1368 +933,1268 @@ BHandler *CanvasWindow::ResolveSpecifier (BMessage *message, int32 index, BMessa #endif - if (!strcasecmp (property, "Size")) - { + if (!strcasecmp(property, "Size")) { fCurrentProperty = PROP_SIZE; return this; } - if (!strcasecmp (property, "Name")) - { + if (!strcasecmp(property, "Name")) { fCurrentProperty = PROP_NAME; return this; } -// if (!strcasecmp (property, "Canvas")) -// { -// fCurrentProperty = PROP_CANVAS; -// return this; -// } - if (!strcasecmp (property, "ActiveLayer")) - { + // if (!strcasecmp (property, "Canvas")) + // { + // fCurrentProperty = PROP_CANVAS; + // return this; + // } + if (!strcasecmp(property, "ActiveLayer")) { fCurrentProperty = PROP_ACTIVELAYER; return this; } - if (!strcasecmp (property, "Layer")) - { - if (message->what == B_CREATE_PROPERTY) - { + if (!strcasecmp(property, "Layer")) { + if (message->what == B_CREATE_PROPERTY) { fCurrentProperty = PROP_LAYER; return this; - } - else // We get here if "Layer" was a specifier. + } else // We get here if "Layer" was a specifier. { // Don't PopSpecifier()... The canvas still needs to find out which layer... return canvas; } } - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } -#if defined (__POWERPC__) -# pragma optimization_level 1 +#if defined(__POWERPC__) +#pragma optimization_level 1 #endif -void CanvasWindow::MessageReceived (BMessage *message) +void +CanvasWindow::MessageReceived(BMessage* message) { - switch (message->what) - { - case B_CREATE_PROPERTY: - { - // message->PrintToStream(); - switch (fCurrentProperty) - { - case PROP_LAYER: - { - char title[MAXLAYERNAME]; - const char *namestring; - if (message->FindString ("Name", &namestring) == B_OK - || message->FindString ("name", &namestring) == B_OK) - strcpy (title, namestring); - else - strcpy (title, lstring (149, "Untitled")); - - canvas->addLayer (title); - setLayerMenu(); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } - break; - } - default: - inherited::MessageReceived (message); - break; + switch (message->what) { + case B_CREATE_PROPERTY: { + // message->PrintToStream(); + switch (fCurrentProperty) { + case PROP_LAYER: { + char title[MAXLAYERNAME]; + const char* namestring; + if (message->FindString("Name", &namestring) == B_OK || + message->FindString("name", &namestring) == B_OK) + strcpy(title, namestring); + else + strcpy(title, lstring(149, "Untitled")); + + canvas->addLayer(title); + setLayerMenu(); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } - fCurrentProperty = 0; break; } - case B_DELETE_PROPERTY: - { - fCurrentProperty = 0; - inherited::MessageReceived (message); + default: + inherited::MessageReceived(message); break; } - case B_GET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_NAME: - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddString ("result", fCanvasName); - message->SendReply (&reply); - } - else - fprintf (stderr, "Canvas Name: \"%s\"\n", fCanvasName); - break; - case PROP_ACTIVELAYER: - if (message->IsSourceWaiting()) - { - BMessage reply (B_REPLY); - reply.AddInt32 ("error", B_NO_ERROR); - reply.AddSpecifier ("Layer", canvas->currentLayer()->getName()); - message->SendReply (&reply); - } - else - fprintf (stderr, "Current Layer: %d: \"%s\"\n", canvas->currentLayerIndex(), canvas->currentLayer()->getName()); - break; - default: - break; - } - fCurrentProperty = 0; - inherited::MessageReceived (message); + fCurrentProperty = 0; + break; + } + case B_DELETE_PROPERTY: { + fCurrentProperty = 0; + inherited::MessageReceived(message); + break; + } + case B_GET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_NAME: + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddString("result", fCanvasName); + message->SendReply(&reply); + } else + fprintf(stderr, "Canvas Name: \"%s\"\n", fCanvasName); + break; + case PROP_ACTIVELAYER: + if (message->IsSourceWaiting()) { + BMessage reply(B_REPLY); + reply.AddInt32("error", B_NO_ERROR); + reply.AddSpecifier("Layer", canvas->currentLayer()->getName()); + message->SendReply(&reply); + } else + fprintf( + stderr, "Current Layer: %d: \"%s\"\n", canvas->currentLayerIndex(), + canvas->currentLayer()->getName() + ); + break; + default: break; } - case B_SET_PROPERTY: - { - switch (fCurrentProperty) - { - case PROP_ACTIVELAYER: - { - const char *namedspecifier; - int32 indexspecifier; - if (message->FindString ("data", &namedspecifier) == B_OK) - { - int32 index; - int32 numlayers = canvas->numLayers(); - for (index = 0; index < numlayers; index++) - { - Layer *l = canvas->getLayer (index); - if (!strcmp (namedspecifier, l->getName())) - { - canvas->makeCurrentLayer (index); - setLayerMenu(); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } - break; - } - } - if (index == numlayers) - { - char errstring[256]; - sprintf (errstring, "Unknown Layer \"%s\"", namedspecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); - } - else - fprintf (stderr, "%s\n", errstring); - } - } - else if (message->FindInt32 ("data", &indexspecifier) == B_OK) - { - if (indexspecifier >= 0 && indexspecifier < canvas->numLayers()) - { - canvas->makeCurrentLayer (indexspecifier); + fCurrentProperty = 0; + inherited::MessageReceived(message); + break; + } + case B_SET_PROPERTY: { + switch (fCurrentProperty) { + case PROP_ACTIVELAYER: { + const char* namedspecifier; + int32 indexspecifier; + if (message->FindString("data", &namedspecifier) == B_OK) { + int32 index; + int32 numlayers = canvas->numLayers(); + for (index = 0; index < numlayers; index++) { + Layer* l = canvas->getLayer(index); + if (!strcmp(namedspecifier, l->getName())) { + canvas->makeCurrentLayer(index); setLayerMenu(); - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } - } - else - { - char errstring[256]; - sprintf (errstring, "Layer Index Out of Range [0..%d]: %ld", canvas->numLayers() - 1, indexspecifier); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } - else - fprintf (stderr, "%s\n", errstring); + break; } } - else - { + if (index == numlayers) { char errstring[256]; - sprintf (errstring, "Invalid Layer Type (either string or int32 please)"); - if (message->IsSourceWaiting()) - { - BMessage error (B_ERROR); - error.AddInt32 ("error", B_BAD_SCRIPT_SYNTAX); - error.AddString ("message", errstring); - message->SendReply (&error); + sprintf(errstring, "Unknown Layer \"%s\"", namedspecifier); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); + } + } else if (message->FindInt32("data", &indexspecifier) == B_OK) { + if (indexspecifier >= 0 && indexspecifier < canvas->numLayers()) { + canvas->makeCurrentLayer(indexspecifier); + setLayerMenu(); + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } - else - fprintf (stderr, "%s\n", errstring); + } else { + BString indexSpecifierData, numberOfLayersData, errorString; + fNumberFormat.Format(numberOfLayersData, canvas->numLayers() - 1); + fNumberFormat.Format(indexSpecifierData, indexspecifier); + errorString.SetToFormat( + "Layer index out of range [0..%s]: %s", numberOfLayersData.String(), + indexSpecifierData.String() + ); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errorString.String()); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errorString.String()); } - break; - } - case PROP_GLOBALALPHA: - { - printf ("PROP_GLOBALALPHA\n"); - break; - } - default: - break; + } else { + char errstring[256]; + sprintf(errstring, "Invalid Layer Type (either string or int32 please)"); + if (message->IsSourceWaiting()) { + BMessage error(B_ERROR); + error.AddInt32("error", B_BAD_SCRIPT_SYNTAX); + error.AddString("message", errstring); + message->SendReply(&error); + } else + fprintf(stderr, "%s\n", errstring); } - fCurrentProperty = 0; - inherited::MessageReceived (message); break; } - case 'aliv': - { - int32 button; - message->FindInt32 ("which", &button); - if (button == 1) - canvas->invertAlpha (); + case PROP_GLOBALALPHA: { + printf("PROP_GLOBALALPHA\n"); break; } - case BBP_REQUEST_BBITMAP: - // printf ("CanvasWindow got BBP_REQUEST_BBITMAP\n"); - if (myTarget || message->HasString ("hack")) // BeDC hack :-) - { - if (message->IsSourceWaiting()) // Sync - { - // printf ("Source is waiting\n"); - message->SendReply (sendbitmapreply()); - } - else // Async - { - // printf ("Async\n"); - myTarget->SendMessage (sendbitmapreply()); - } - } - else - beep(); + default: break; - case BBP_REPLACE_BBITMAP: + } + fCurrentProperty = 0; + inherited::MessageReceived(message); + break; + } + case 'aliv': { + int32 button; + message->FindInt32("which", &button); + if (button == 1) + canvas->invertAlpha(); + break; + } + case BBP_REQUEST_BBITMAP: + // printf ("CanvasWindow got BBP_REQUEST_BBITMAP\n"); + if (myTarget || message->HasString("hack")) // BeDC hack :-) { -// printf ("Got Replace message\n"); -// char title[MAXTITLE]; -// char *name; -// if (message->FindString ("name", &name) == B_OK) -// strcpy (title, name); -// else -// sprintf (title, "Untitled %i", newnum++); - BMessage archive; - if (message->FindMessage ("BBitmap", &archive) == B_OK) + if (message->IsSourceWaiting()) // Sync { - BBitmap *map = new BBitmap (&archive); - if (map->IsValid()) - { - BMessenger ie; - message->FindMessenger ("target", &ie); - // float newWidth = map->Bounds().Width(); - // float newHeight = map->Bounds().Height(); - canvas->ReplaceCurrentLayer (map); -// BRect canvasWindowFrame; -// canvasWindowFrame.Set (128 + newnum*16, 128 + newnum*16, -// 128 + newnum*16 + newWidth - 1, 128 + newnum*16 + newHeight - 1); -// CanvasWindow *canvasWindow = new CanvasWindow (canvasWindowFrame, title, map, &ie); -// canvasWindow->Show(); - BMessage *ok = new BMessage (BBP_BBITMAP_OPENED); - ok->AddMessenger ("target", BMessenger (this, NULL)); - if (message->IsSourceWaiting()) - { - message->SendReply (ok); - } - else - { - ie.SendMessage (ok); - } - delete ok; - float zoom; - if (message->FindFloat ("zoom", &zoom) == B_OK) - { - BMessage *m = new BMessage ('Mnnn'); - m->AddFloat ("zoom", zoom); - PostMessage (m); - delete m; - } + // printf ("Source is waiting\n"); + message->SendReply(sendbitmapreply()); + } else // Async + { + // printf ("Async\n"); + myTarget->SendMessage(sendbitmapreply()); + } + } else + beep(); + break; + case BBP_REPLACE_BBITMAP: { + // printf ("Got Replace message\n"); + // char title[MAXTITLE]; + // char *name; + // if (message->FindString ("name", &name) == B_OK) + // strcpy (title, name); + // else + // sprintf (title, "Untitled %i", newnum++); + BMessage archive; + if (message->FindMessage("BBitmap", &archive) == B_OK) { + BBitmap* map = new BBitmap(&archive); + if (map->IsValid()) { + BMessenger ie; + message->FindMessenger("target", &ie); + // float newWidth = map->Bounds().Width(); + // float newHeight = map->Bounds().Height(); + canvas->ReplaceCurrentLayer(map); + // BRect canvasWindowFrame; + // canvasWindowFrame.Set (128 + newnum*16, 128 + newnum*16, + // 128 + newnum*16 + newWidth - 1, 128 + newnum*16 + newHeight + //- 1); CanvasWindow *canvasWindow = new CanvasWindow + //(canvasWindowFrame, title, map, &ie); canvasWindow->Show(); + BMessage* ok = new BMessage(BBP_BBITMAP_OPENED); + ok->AddMessenger("target", BMessenger(this, NULL)); + if (message->IsSourceWaiting()) { + message->SendReply(ok); + } else { + ie.SendMessage(ok); } - else - { - fprintf (stderr, "Invalid BBitmap\n"); - // Error + delete ok; + float zoom; + if (message->FindFloat("zoom", &zoom) == B_OK) { + BMessage* m = new BMessage('Mnnn'); + m->AddFloat("zoom", zoom); + PostMessage(m); + delete m; } - } - else - { - fprintf (stderr, "Message didn't contain a valid BBitmap\n"); + } else { + fprintf(stderr, "Invalid BBitmap\n"); // Error } - -// BMessage *copymsg = new BMessage (BBP_REPLACE_BBITMAP); -// copymsg->AddMessage ("message", message); -// copymsg->AddMessenger ("target", *myTarget); -// myTarget = NULL; -// canvas->changed = false; -// be_app->PostMessage (copymsg); -// printf ("Sent it to the main app.\n"); -// Close(); - break; - } - case 'IErq': // BeDC hack to interact with ImageElements - { - printf ("CanvasWindow received IErq message\n"); - BMessage original; - message->FindMessage ("original", &original); -// original.FindMessenger ("target", ieTarget); -// ieTarget->SendMessage (sendbitmapreply()); - printf ("Sending Reply...\n"); - original.SendReply (sendbitmapreply()); - printf ("Got through\n"); - break; + } else { + fprintf(stderr, "Message didn't contain a valid BBitmap\n"); + // Error } - case 'save': - { - int32 button = 1; - if (myTarget && !fromRef) - myTarget->SendMessage (sendbitmapreply()); - else if (!strncmp (fName, lstring (149, "Untitled"), strlen (lstring (149, "Untitled")))) - savePanel->Show(); - else - { - if (myTarget && fromRef) - { - canvas->Save (BEntry (&myRef)); - BMessage *ie = new BMessage (BBP_SEND_BBITMAP); - BMessage ieb; - ie->AddMessenger ("target", this); - ie->AddRef ("ref", &myRef); - myTarget->SendMessage (ie); - } - else + // BMessage *copymsg = new BMessage (BBP_REPLACE_BBITMAP); + // copymsg->AddMessage ("message", message); + // copymsg->AddMessenger ("target", *myTarget); + // myTarget = NULL; + // canvas->changed = false; + // be_app->PostMessage (copymsg); + // printf ("Sent it to the main app.\n"); + // Close(); + break; + } + case 'IErq': // BeDC hack to interact with ImageElements + { + printf("CanvasWindow received IErq message\n"); + BMessage original; + message->FindMessage("original", &original); + // original.FindMessenger ("target", ieTarget); + // ieTarget->SendMessage (sendbitmapreply()); + printf("Sending Reply...\n"); + original.SendReply(sendbitmapreply()); + printf("Got through\n"); + break; + } + case 'save': { + int32 button = 1; + if (myTarget && !fromRef) + myTarget->SendMessage(sendbitmapreply()); + else if (!strncmp(fName, lstring(149, "Untitled"), strlen(lstring(149, "Untitled")))) + savePanel->Show(); + else { + if (myTarget && fromRef) { + canvas->Save(BEntry(&myRef)); + + BMessage* ie = new BMessage(BBP_SEND_BBITMAP); + BMessage ieb; + ie->AddMessenger("target", this); + ie->AddRef("ref", &myRef); + myTarget->SendMessage(ie); + } else { + BEntry entry(&myRef); + + if (entry.Exists()) //// *** NOT TRANSLATED - COPIED FROM OS!! { - BEntry entry (&myRef); - - if (entry.Exists()) //// *** NOT TRANSLATED - COPIED FROM OS!! - { - char exists[2048]; - BPath path (&entry); - sprintf (exists, "The file \"%s\" already exists in the specified folder. Do you want to replace it?", path.Leaf()); - button = (new BAlert ("", exists, "Cancel", "Replace", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(); - } - - if (button) - canvas->Save (entry); + char exists[2048]; + BPath path(&entry); + sprintf( + exists, + "The file \"%s\" already exists in the specified folder. Do you want to " + "replace it?", + path.Leaf() + ); + button = (new BAlert( + "", exists, "Cancel", "Replace", NULL, B_WIDTH_AS_USUAL, + B_WARNING_ALERT + )) + ->Go(); } + + if (button) + canvas->Save(entry); } - if (button) - break; - // else - fall through to "save as" below - // ************************************** - } - case 'savs': - savePanel->Show(); - break; - case 'ExpC': - { - char name[1024]; - sprintf (name, "%s.c", fName); - canvas->ExportCstruct (name); - break; } - case 'Expt': - delete bitmapStream; - bitmapStream = new ProgressiveBitmapStream (canvas->canvas (true)); - bitmapStream->SetDispose (true); -// if (outputFormatWindow) -// { -// printf ("Er was al een OutputFormatWindow\n"); -// outputFormatWindow->Lock(); -// outputFormatWindow->Quit(); -// } -// delete outputFormatWindow; - outputFormatWindow = new OutputFormatWindow (bitmapStream, of_selected); + if (button) break; - case 'oFsl': - { - message->FindInt32 ("type", (int32 *) &out_type); - message->FindInt32 ("translator", reinterpret_cast(&out_translator)); - extern translator_id def_out_translator; - def_out_translator = out_translator; - savePanel->Window()->Lock(); - BView *background = savePanel->Window()->ChildAt (0); - BTextControl *tv = dynamic_cast (background->FindView ("text view")); - if (tv) + // else - fall through to "save as" below + // ************************************** + } + case 'savs': + savePanel->Show(); + break; + case 'ExpC': { + char name[1024]; + sprintf(name, "%s.c", fName); + canvas->ExportCstruct(name); + break; + } + case 'Expt': + delete bitmapStream; + bitmapStream = new ProgressiveBitmapStream(canvas->canvas(true)); + bitmapStream->SetDispose(true); + // if (outputFormatWindow) + // { + // printf ("Er was al een OutputFormatWindow\n"); + // outputFormatWindow->Lock(); + // outputFormatWindow->Quit(); + // } + // delete outputFormatWindow; + outputFormatWindow = new OutputFormatWindow(bitmapStream, of_selected); + break; + case 'oFsl': { + message->FindInt32("type", (int32*)&out_type); + message->FindInt32("translator", reinterpret_cast(&out_translator)); + extern translator_id def_out_translator; + def_out_translator = out_translator; + savePanel->Window()->Lock(); + BView* background = savePanel->Window()->ChildAt(0); + BTextControl* tv = dynamic_cast(background->FindView("text view")); + if (tv) { + char suggestion[B_FILE_NAME_LENGTH]; + strcpy(suggestion, fName); + if (out_type != 'SBec') // Becasso files don't need an extension. + // (however, we shouldn't be _exporting_ to Becasso via the TK at all...) { - char suggestion[B_FILE_NAME_LENGTH]; - strcpy (suggestion, fName); - if (out_type != 'SBec') // Becasso files don't need an extension. - // (however, we shouldn't be _exporting_ to Becasso via the TK at all...) - { - int il = strlen (suggestion); - while (il > 0 && suggestion[il] != '.') // Yes >0; .dotfiles shouldn't have their entire name cut off... - il--; - - if (!il) - { - il = strlen (suggestion); - suggestion[il] = '.'; - } - suggestion[il + 1] = 0; // Cut off the existing extension - const translation_format *format_list = 0; - int32 format_count = 0; - - if (BTranslatorRoster::Default()->GetOutputFormats (out_translator, &format_list, &format_count) == B_NO_ERROR) - { - // printf ("%ld formats found\n", format_count); - for (int i = 0; i < format_count; ++i) - { - // printf ("Trying format %d...\n", i); - if (format_list[i].type == out_type) + int il = strlen(suggestion); + while (il > 0 && suggestion[il] != '.' + ) // Yes >0; .dotfiles shouldn't have their entire name cut off... + il--; + + if (!il) { + il = strlen(suggestion); + suggestion[il] = '.'; + } + suggestion[il + 1] = 0; // Cut off the existing extension + const translation_format* format_list = 0; + int32 format_count = 0; + + if (BTranslatorRoster::Default()->GetOutputFormats( + out_translator, &format_list, &format_count + ) == B_NO_ERROR) { + // printf ("%ld formats found\n", format_count); + for (int i = 0; i < format_count; ++i) { + // printf ("Trying format %d...\n", i); + if (format_list[i].type == out_type) { + // printf ("Match\n"); + BMimeType mime(format_list[i].MIME); + BMessage extensions; + extern bool PatronizeMIME; + char* ext; + if (mime.GetFileExtensions(&extensions) == B_OK && + extensions.FindString("extensions", 0, (const char**)&ext) == B_OK) + // Only look for the first one (if there are more) { - // printf ("Match\n"); - BMimeType mime (format_list[i].MIME); - BMessage extensions; - extern bool PatronizeMIME; - char *ext; - if (mime.GetFileExtensions (&extensions) == B_OK - && extensions.FindString ("extensions", 0, (const char **) &ext) == B_OK) - // Only look for the first one (if there are more) - { - // extensions.PrintToStream(); - //strcat (suggestion, ext); - } - else if (PatronizeMIME) + // extensions.PrintToStream(); + // strcat (suggestion, ext); + } else if (PatronizeMIME) { + // extensions.PrintToStream(); + char alertstring[1024]; + sprintf( + alertstring, + lstring( + 150, + "Excuse me for interrupting. I was trying to suggest an " + "appropriate extension for this file, " + "yet couldn't find any in your MIME database for '%s'.\n" + "You can add these extensions yourself with the FileTypes " + "preferences application, " + "or I would be happy to fill in my suggestions. You can " + "also simply forget about the " + "outdated concept of extensions alltogether, although many " + "other operating systems " + "still rely on them for file identification." + ), + format_list[i].MIME + ); + BAlert* alert = new BAlert( + lstring(151, "File Type"), alertstring, + lstring(152, "Update MIME"), lstring(153, "Don't Patronize Me"), + NULL, B_WIDTH_FROM_WIDEST + ); + uint32 button = alert->Go(); + if (button == 1) { + PatronizeMIME = false; + } else // Update the MIME database { - // extensions.PrintToStream(); - char alertstring[1024]; - sprintf (alertstring, - lstring (150, - "Excuse me for interrupting. I was trying to suggest an appropriate extension for this file, "\ - "yet couldn't find any in your MIME database for '%s'.\n"\ - "You can add these extensions yourself with the FileTypes preferences application, "\ - "or I would be happy to fill in my suggestions. You can also simply forget about the "\ - "outdated concept of extensions alltogether, although many other operating systems "\ - "still rely on them for file identification."), - format_list[i].MIME); - BAlert *alert = new BAlert (lstring (151, "File Type"), alertstring, lstring (152, "Update MIME"), lstring (153, "Don't Patronize Me"), NULL, B_WIDTH_FROM_WIDEST); - uint32 button = alert->Go(); - if (button == 1) - { - PatronizeMIME = false; - } - else // Update the MIME database - { - sprintf (alertstring, - lstring (154, - "I have a list of common image file types and their extension but you might have "\ - "some exotic types I don't know about. In that case, I will try to make an educated "\ - "guess, and if I can't think of anything, I'll simply skip that type. I will also "\ - "stay away from file types that do have any extensions set.\n"\ - "You can always manually change my suggestions using the FileTypes preferences application.")); - alert = new BAlert (lstring (152, "Update MIME"), alertstring, lstring (131, "Cancel"), lstring (133, "Proceed")); - button = alert->Go(); - if (button == 1) - { - // Do it... - BMessage types; - BMessage pmtext; - char *type; - int32 t = 0; - - // First, look for application/postscript as a special case - BMimeType psmt ("application/postscript"); - if (psmt.GetFileExtensions (&pmtext) != B_OK - || !pmtext.HasString ("extensions")) - { - pmtext.AddString ("extensions", "eps"); - pmtext.AddString ("extensions", "ps"); - psmt.SetFileExtensions (&pmtext); - } - - BMimeType::GetInstalledTypes ("image", &types); - t = 0; - while (types.FindString ("types", t++, (const char **) &type) == B_OK) - { - // printf ("Working on %s\n", type); - BMessage mtext; - BMimeType mt (type); - if (mt.InitCheck() != B_OK) - printf ("ALARM!\n"); - bool foundsomething = false; - if (mt.GetFileExtensions (&mtext) != B_OK - || !mtext.HasString ("extensions")) + sprintf( + alertstring, + lstring( + 154, "I have a list of common image file types and " + "their extension but you might have " + "some exotic types I don't know about. In that " + "case, I will try to make an educated " + "guess, and if I can't think of anything, I'll " + "simply skip that type. I will also " + "stay away from file types that do have any " + "extensions set.\n" + "You can always manually change my suggestions " + "using the FileTypes preferences application." + ) + ); + alert = new BAlert( + lstring(152, "Update MIME"), alertstring, + lstring(131, "Cancel"), lstring(133, "Proceed") + ); + button = alert->Go(); + if (button == 1) { + // Do it... + BMessage types; + BMessage pmtext; + char* type; + int32 t = 0; + + // First, look for application/postscript as a special case + BMimeType psmt("application/postscript"); + if (psmt.GetFileExtensions(&pmtext) != B_OK || + !pmtext.HasString("extensions")) { + pmtext.AddString("extensions", "eps"); + pmtext.AddString("extensions", "ps"); + psmt.SetFileExtensions(&pmtext); + } + + BMimeType::GetInstalledTypes("image", &types); + t = 0; + while (types.FindString( + "types", t++, (const char**)&type + ) == B_OK) { + // printf ("Working on %s\n", type); + BMessage mtext; + BMimeType mt(type); + if (mt.InitCheck() != B_OK) + printf("ALARM!\n"); + bool foundsomething = false; + if (mt.GetFileExtensions(&mtext) != B_OK || + !mtext.HasString("extensions")) { + char* ext = type + 6; // skip "image/" + if (strlen(ext) == 3) // Easy! { - char *ext = type + 6; // skip "image/" - if (strlen (ext) == 3) // Easy! - { - // printf ("Easy: %s\n", ext); - mtext.AddString ("extensions", ext); - foundsomething = true; - } - else if ((ext[0] == 'x') && (ext[1] == '-') && (strlen (ext + 2) == 3)) // x-foo? - { - // printf ("Easy: x-%s\n", ext + 2); - mtext.AddString ("extensions", ext + 2); - foundsomething = true; - } - else - { - char sd[B_MIME_TYPE_LENGTH]; - if (mt.GetShortDescription (sd) == B_OK) - { - // Maybe we can find a hint in the short description - // (often something like "PPM Image") - int spacep; - for (spacep = 0; spacep < strlen (sd); spacep++) - { - if (sd[spacep] == ' ') - break; - } - if (spacep == 3) // We're lucky! - { - sd[3] = 0; - for (spacep = 0; spacep < 3; spacep++) - sd[spacep] = tolower (sd[spacep]); - // printf ("From desc: %s\n", sd); - mtext.AddString ("extensions", sd); - foundsomething = true; - } - } - } - if (!foundsomething) // Well, the last resort. - { - if (!strcmp (ext, "jpeg")) - { - mtext.AddString ("extensions", "jpg"); - mtext.AddString ("extensions", "jpeg"); - foundsomething = true; - } - else if (!strcmp (ext, "targa") || !strcmp (ext, "x-targa")) - { - mtext.AddString ("extensions", "tga"); - foundsomething = true; + // printf ("Easy: %s\n", ext); + mtext.AddString("extensions", ext); + foundsomething = true; + } else if ((ext[0] == 'x') && (ext[1] == '-') && (strlen(ext + 2) == 3)) // x-foo? + { + // printf ("Easy: x-%s\n", ext + 2); + mtext.AddString("extensions", ext + 2); + foundsomething = true; + } else { + char sd[B_MIME_TYPE_LENGTH]; + if (mt.GetShortDescription(sd) == B_OK) { + // Maybe we can find a hint in the short + // description (often something like "PPM + // Image") + int spacep; + for (spacep = 0; spacep < strlen(sd); + spacep++) { + if (sd[spacep] == ' ') + break; } - else if (!strcmp (ext, "tiff")) + if (spacep == 3) // We're lucky! { - mtext.AddString ("extensions", "tif"); - mtext.AddString ("extensions", "tiff"); + sd[3] = 0; + for (spacep = 0; spacep < 3; spacep++) + sd[spacep] = tolower(sd[spacep]); + // printf ("From desc: %s\n", sd); + mtext.AddString("extensions", sd); foundsomething = true; } - // Add more File Types here when we learn about them... - } - if (foundsomething) - { - // char desc[256]; - // mt.GetShortDescription (desc); - // printf ("Setting extensions for %s to\n", desc); - // mtext.PrintToStream(); - mt.SetFileExtensions (&mtext); } } - else + if (!foundsomething) // Well, the last resort. { - // else: There already are extensions set. - // printf ("Already set\n"); - // mtext.PrintToStream(); + if (!strcmp(ext, "jpeg")) { + mtext.AddString("extensions", "jpg"); + mtext.AddString("extensions", "jpeg"); + foundsomething = true; + } else if (!strcmp(ext, "targa") || !strcmp(ext, "x-targa")) { + mtext.AddString("extensions", "tga"); + foundsomething = true; + } else if (!strcmp(ext, "tiff")) { + mtext.AddString("extensions", "tif"); + mtext.AddString("extensions", "tiff"); + foundsomething = true; + } + // Add more File Types here when we learn about + // them... + } + if (foundsomething) { + // char desc[256]; + // mt.GetShortDescription (desc); + // printf ("Setting extensions for %s to\n", + // desc); mtext.PrintToStream(); + mt.SetFileExtensions(&mtext); } + } else { + // else: There already are extensions set. + // printf ("Already set\n"); + // mtext.PrintToStream(); } } } } - PatronizeMIME = false; - // Try again now... - if (mime.GetFileExtensions (&extensions) == B_OK) + } + PatronizeMIME = false; + // Try again now... + if (mime.GetFileExtensions(&extensions) == B_OK) { + // printf ("Second try...\n"); + // extensions.PrintToStream(); + char* ext; + if (extensions.FindString("extensions", 0, (const char**)&ext) == + B_OK) + // Only look for the first one (if there are more) { - // printf ("Second try...\n"); - // extensions.PrintToStream(); - char *ext; - if (extensions.FindString ("extensions", 0, (const char **) &ext) == B_OK) - // Only look for the first one (if there are more) - { - //printf ("Adding extension %s\n", ext); - strcat (suggestion, ext); - } + // printf ("Adding extension %s\n", ext); + strcat(suggestion, ext); } - else - suggestion[il] = 0; - - break; // I.e. don't look for further out_types. - } + } else + suggestion[il] = 0; + + break; // I.e. don't look for further out_types. } } } - tv->SetText (suggestion); } - else - printf ("Hmmm, no 'text view'\n"); + tv->SetText(suggestion); + } else + printf("Hmmm, no 'text view'\n"); - savePanel->Window()->Unlock(); - savePanel->Show(); - // savePanel->Show(); // Don't ask. - outputFormatWindow = NULL; - break; - } - case 'expt': + savePanel->Window()->Unlock(); + savePanel->Show(); + // savePanel->Show(); // Don't ask. + outputFormatWindow = NULL; + break; + } + case 'expt': { + delete bitmapStream; + bitmapStream = new ProgressiveBitmapStream(canvas->canvas(true)); + bitmapStream->SetDispose(true); + extern int32 def_out_type; + extern translator_id def_out_translator; + out_translator = def_out_translator; + out_type = def_out_type; + // message->PrintToStream(); + if (message->HasString("filename")) + // Courtesy to the end user, the 'expt' message can contain a normal path string. + // We'll then split it up in a "directory" ref and a file name (leaf). { - delete bitmapStream; - bitmapStream = new ProgressiveBitmapStream (canvas->canvas (true)); - bitmapStream->SetDispose (true); - extern int32 def_out_type; - extern translator_id def_out_translator; - out_translator = def_out_translator; - out_type = def_out_type; - //message->PrintToStream(); - if (message->HasString ("filename")) - // Courtesy to the end user, the 'expt' message can contain a normal path string. - // We'll then split it up in a "directory" ref and a file name (leaf). - { - const char *pathname; - message->FindString ("filename", &pathname); - BPath path; - path.SetTo (pathname); - if (pathname[0] == '/') // Filename is an absolute path - { - BPath dir; - path.GetParent (&dir); - entry_ref lref; - get_ref_for_path (dir.Path(), &lref); - message->AddRef ("directory", &lref); - message->AddString ("name", path.Leaf()); - } - else - message->AddString ("name", pathname); - } - if (!message->HasRef ("directory")) - // We didn't get a directory; point it to $HOME. + const char* pathname; + message->FindString("filename", &pathname); + BPath path; + path.SetTo(pathname); + if (pathname[0] == '/') // Filename is an absolute path { + BPath dir; + path.GetParent(&dir); entry_ref lref; - BPath home; - find_directory (B_USER_DIRECTORY, &home); - get_ref_for_path (home.Path(), &lref); - message->AddRef ("directory", &lref); - //printf ("Path set to %s\n", home.Path()); - } - // If we didn't get a file name, no sweat. The following case block will - // default it to the canvas name. - - scripted = true; - } // Fall through to B_SAVE_REQUESTED - case B_SAVE_REQUESTED: - { - // savePanel->Hide(); - - // synchronize all other save panels... - // Make this a preference! - extern entry_ref gSaveRef; - savePanel->GetPanelDirectory (&gSaveRef); - - entry_ref lref; - char fname[B_FILE_NAME_LENGTH]; - message->FindRef ("directory", &lref); - BEntry entry = BEntry (&lref); - BDirectory dir = BDirectory (&lref); - if (message->FindString ("name")) - { // The Save Panel sends the name separately - strcpy (fName, message->FindString ("name")); - if (!out_type) - { - sprintf (fname, "%s (%.0f%%)", fName, 100*fScale); - SetTitle (fname); - } - } - entry.SetTo (&dir, fName, false); - if (out_type) // i.o.w. exporting - { - extern int SilentOperation; - if (SilentOperation < 3) - bitmapStream->DisplayProgressBar (BPoint (200, 200), lstring (155, "Writing Image…")); - BFile outStream; - if (outStream.SetTo (&entry, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE)) - printf ("Error opening %s!\n", fName); - bitmapStream->SetDispose (true); - #if defined (DATATYPES) - if (DATATranslate (*bitmapStream, &out_info, NULL, outStream, out_type)) - { - char errstring[B_FILE_NAME_LENGTH + 64]; - sprintf (errstring, "Datatype error:\nCouldn't translate `%s'", fName); - BAlert *alert = new BAlert ("", string, "OK", NULL, NULL, - B_WIDTH_AS_USUAL, B_WARNING_ALERT); - alert->Go(); - } - #else - BTranslatorRoster *roster = BTranslatorRoster::Default(); - if (roster->Translate (bitmapStream, NULL, NULL, &outStream, out_type)) - { - char errstring[B_FILE_NAME_LENGTH + 64]; - sprintf (errstring, lstring (134, "Translation Kit error:\nCouldn't translate `%s'"), fName); - BAlert *alert = new BAlert ("", errstring, "Help", "OK", NULL, - B_WIDTH_AS_USUAL, B_WARNING_ALERT); - uint32 button = alert->Go(); - if (button == 0) - { - alert = new BAlert ("", lstring (156, "This is a rare error. Something went wrong inside the Translator.\nIt could range from shared library conflicts to running out of hard disk space."), lstring (136, "OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT); - alert->Go(); - } - } - #endif - BPath path; - entry.GetPath (&path); - const translation_format *format_list = 0; - int32 format_count = 0; - if (BTranslatorRoster::Default()->GetOutputFormats (out_translator, &format_list, &format_count) == B_NO_ERROR) - { - for (int i = 0; i < format_count; ++i) - { - if (format_list[i].type == out_type) - { - outStream.RemoveAttr ("BEOS:TYPE"); - char mime[B_FILE_NAME_LENGTH]; - strcpy (mime, format_list[i].MIME); - mime[strlen (mime)] = 0; - mime[strlen (mime) + 1] = 0; - outStream.WriteAttr ("BEOS:TYPE", B_MIME_STRING_TYPE, 0L, mime, strlen (mime) + 1); - break; - } - } - } - extern int DebugLevel; - if (DebugLevel > 1) - printf ("Wrote: %s\n", path.Path()); - - delete bitmapStream; - bitmapStream = NULL; - outputFormatWindow = NULL; - out_type = 0; - } - else - { - canvas->Save (entry); - } - canvas->changed = false; - if (scripted) - { - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - error.AddInt32 ("error", B_NO_ERROR); - message->SendReply (&error); - } - } - scripted = false; - entry_ref ref; - entry.GetRef (&ref); - add_to_recent (ref); - if (myTarget && fromRef) - { - BMessage *ie = new BMessage (BBP_SEND_BBITMAP); - BMessage ieb; - ie->AddMessenger ("target", this); - ie->AddRef ("ref", &ref); - myTarget->SendMessage (ie); - } - break; - } - case 'tTed': - canvas->tTextD(); - break; - case 'M-8': - canvas->setScale (0.125); - break; - case 'M-4': - canvas->setScale (0.25); - break; - case 'M-2': - canvas->setScale (0.5); - break; - case 'M1': - canvas->setScale (1); - break; - case 'M2': - canvas->setScale (2); - break; - case 'M4': - canvas->setScale (4); - break; - case 'M8': - canvas->setScale (8); - break; - case 'M16': - canvas->setScale (16); - break; - case 'Mnnn': - { - float s; - if (message->FindFloat ("zoom", &s)) - canvas->setScale (s); - break; - } - case 'Min': - canvas->ZoomIn(); - break; - case 'Mout': - canvas->ZoomOut(); - break; - case 'mwin': - { - canvas->SetupUndo (M_DRAW); - if (!magWindow) - { - BRect frame = Frame(); - frame.OffsetBy (16, 16); - magWindow = new MagWindow (frame, FileName(), canvas); - magWindow->Show(); - } - else - magWindow->Activate(); - break; - } - case 'magQ': - if (magWindow->Lock()) - { - magWindow->Quit(); - magWindow = NULL; - } - break; - case 'cmus': - canvas->CenterMouse(); - break; - case 'clrX': // color changed - canvas->InvalidateAddons(); - break; - case 'xpal': - { - if (extractWindow) - { - extractWindow->Activate(); - } - else - { - extractWindow = new XpalWindow (BRect (100, 100, 300, 180), lstring (157, "Extract Palette"), new BMessenger (this)); - extractWindow->Show(); - // extractWindow->Quit(); - // extractWindow = NULL; - } - break; - } - case 'xclF': - { - int32 num = 256; - message->FindInt32 ("num_cols", &num); - bool clobber = false; - message->FindBool ("clobber", &clobber); - extern ColorMenuButton *hicolor; - hicolor->extractPalette (canvas->currentLayer(), num, clobber); - if (extractWindow) - { - extractWindow->Lock(); - extractWindow->Quit(); - extractWindow = NULL; - } - break; - } - case 'xclB': - { - int32 num = 256; - message->FindInt32 ("num_cols", &num); - bool clobber = false; - message->FindBool ("clobber", &clobber); - extern ColorMenuButton *locolor; - locolor->extractPalette (canvas->currentLayer(), num, clobber); - if (extractWindow) - { - extractWindow->Lock(); - extractWindow->Quit(); - extractWindow = NULL; - } - break; - } - case 'rstf': // MYSTERY!!! - { - Lock(); - BRect cf = canvas->Frame(); - BRect mf = menubar->Frame(); -// printf ("MIN_WIDTH = %f, MAX_HEIGHT = %f\n", MIN_WIDTH, MIN_HEIGHT); -// printf ("canvas->Frame().Width() = %f, Height() = %f\n", cf.Width(), cf.Height()); -// printf ("menubar->Frame().Height() = %f\n", mf.Height()); -// printf ("w = %f, h = %f\n", max_c (MIN_WIDTH, cf.Width() + B_V_SCROLL_BAR_WIDTH), max_c (MIN_HEIGHT, cf.Height() + B_H_SCROLL_BAR_HEIGHT + mf.Height())); - ResizeTo (max_c (MIN_WIDTH, cf.Width() + B_V_SCROLL_BAR_WIDTH), - max_c (MIN_HEIGHT, cf.Height() + B_H_SCROLL_BAR_HEIGHT + mf.Height() + 1)); - canvas->Invalidate(); - Unlock(); - break; - } - case 'rszT': // Resize To - { - char title[1024]; - sprintf (title, "%s %s", lstring (402, "Resize"), FileName()); - ResizeWindow *rw = new ResizeWindow (this, title, canvas->Frame().Height() + 1, canvas->Frame().Width() + 1); - rw->Show(); - break; - } - case 'rszt': - { - int32 w = canvas->Frame().IntegerWidth() + 1; - int32 h = canvas->Frame().IntegerHeight() + 1; - message->FindInt32 ("width", &w); - message->FindInt32 ("height", &h); - canvas->resizeTo (w, h); - break; + get_ref_for_path(dir.Path(), &lref); + message->AddRef("directory", &lref); + message->AddString("name", path.Leaf()); + } else + message->AddString("name", pathname); } - case 'flpH': // Flip Horizontal + if (!message->HasRef("directory")) + // We didn't get a directory; point it to $HOME. { - int32 index = -1; - message->FindInt32 ("layer", &index); - canvas->flipLayer (0, index); - break; - } - case 'flpV': // Flip Vertical - { - int32 index = -1; - message->FindInt32 ("layer", &index); - canvas->flipLayer (1, index); - break; - } - case 'layr': - if (layerOpen) - { -// layerWindow->Lock(); - layerWindow->Activate(); -// windowMenu->FindItem('layr')->SetMarked (false); -// layerOpen = false; - } - else - { - char title[B_FILE_NAME_LENGTH + 10]; - sprintf (title, lstring (160, "Layers in %s"), fName); - BRect layerFrame = BRect (100, 100, 310, 294); - layerWindow = new LayerWindow (layerFrame, title, canvas); - layerWindow->Show(); - windowMenu->FindItem('layr')->SetMarked (true); - layerOpen = true; - } - break; - case 'layQ': - windowMenu->FindItem('layr')->SetMarked (false); - layerOpen = false; - break; - case 'delL': - // printf ("CanvasWindow::MessageReceived ('delL');\n"); - canvas->removeLayer (canvas->currentLayerIndex()); -// setLayerMenu(); - break; - case 'newL': - if (LockWithTimeout (100000) == B_OK) - { - canvas->addLayer (lstring (161, "Untitled Layer")); - Unlock(); -// setLayerMenu(); - } - else - printf ("Hey, couldn't lock!!\n"); - break; - case 'insL': - canvas->insertLayer (canvas->currentLayerIndex(), lstring (161, "Untitled Layer")); -// setLayerMenu(); - break; - case 'trsL': - canvas->translateLayer (canvas->currentLayerIndex()); - break; - case 'rotL': - canvas->rotateLayer (canvas->currentLayerIndex()); - break; - case 'mrgL': - canvas->mergeLayers (canvas->currentLayerIndex() - 1, canvas->currentLayerIndex()); -// setLayerMenu(); - break; - case 'lNch': - { - int32 index; - message->FindInt32 ("index", &index); - BMessage *msg = new BMessage ('lNch'); - msg->AddInt32 ("index", index); - canvas->MessageReceived (msg); - delete msg; - setLayerMenu(); - break; - } - case 'dupL': -// canvas->WriteAsHex ("logo.dat"); - canvas->duplicateLayer (canvas->currentLayerIndex()); -// setLayerMenu(); - break; - case 'movL': - { - int32 a, b; - message->FindInt32 ("from", &a); - message->FindInt32 ("to", &b); - canvas->moveLayers (a, b); -// setLayerMenu(); - break; - } - case 'lChg': - if (isLayerOpen()) - layerWindow->PostMessage (message); - canvas->changed = true; - setLayerMenu(); - break; - case 'lSel': - { - int32 ind; - message->FindInt32 ("index", &ind); - canvas->makeCurrentLayer (ind); -// setLayerMenu(); - break; + entry_ref lref; + BPath home; + find_directory(B_USER_DIRECTORY, &home); + get_ref_for_path(home.Path(), &lref); + message->AddRef("directory", &lref); + // printf ("Path set to %s\n", home.Path()); } - case 'Loup': - { - int current = canvas->currentLayerIndex(); - if (current < canvas->numLayers() - 1) - { - canvas->makeCurrentLayer (current + 1); -// setLayerMenu(); + // If we didn't get a file name, no sweat. The following case block will + // default it to the canvas name. + + scripted = true; + } // Fall through to B_SAVE_REQUESTED + case B_SAVE_REQUESTED: { + // savePanel->Hide(); + + // synchronize all other save panels... + // Make this a preference! + extern entry_ref gSaveRef; + savePanel->GetPanelDirectory(&gSaveRef); + + entry_ref lref; + message->FindRef("directory", &lref); + BEntry entry = BEntry(&lref); + BString fName; + BString percentData; + BString title; + BDirectory dir = BDirectory(&lref); + if (message->FindString("name")) { // The Save Panel sends the name separately + fName.SetTo(message->FindString("name")); + if (!out_type) { + fNumberFormat.FormatPercent(percentData, (double)fScale); + title.SetToFormat("%s (%s)", fName, percentData.String()); + SetTitle(title.String()); } - break; } - case 'Lodn': + entry.SetTo(&dir, fName, false); + if (out_type) // i.o.w. exporting { - int current = canvas->currentLayerIndex(); - if (current > 0) - { - canvas->makeCurrentLayer (current - 1); -// setLayerMenu(); + extern int SilentOperation; + if (SilentOperation < 3) + bitmapStream->DisplayProgressBar(BPoint(200, 200), lstring(155, "Writing Image…")); + BFile outStream; + if (outStream.SetTo(&entry, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE)) + printf("Error opening %s!\n", fName); + bitmapStream->SetDispose(true); +#if defined(DATATYPES) + if (DATATranslate(*bitmapStream, &out_info, NULL, outStream, out_type)) { + char errstring[B_FILE_NAME_LENGTH + 64]; + sprintf(errstring, "Datatype error:\nCouldn't translate `%s'", fName); + BAlert* alert = + new BAlert("", string, "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); + alert->Go(); } - break; - } - case 'DMch': - { - int32 index, newmode; - message->FindInt32 ("index", &index); - message->FindInt32 ("newmode", &newmode); - canvas->setChannelOperation (index, newmode); - break; - } - case 'Liga': - { - int32 index, ga; - message->FindInt32 ("index", &index); - message->FindInt32 ("alpha", &ga); - canvas->setGlobalAlpha (index, ga); - break; - } - case B_UNDO: - canvas->Undo (true, true); - break; - case 'redo': - canvas->Redo (true); - break; - case B_CUT: - canvas->Cut(); - break; - case B_COPY: - canvas->Copy(); - break; - case B_PASTE: - if (message->WasDropped()) - { - rgb_color *dropped; - BPoint droppoint = message->DropPoint(); - canvas->SetScale (canvas->getScale()); // ? - droppoint = canvas->ConvertFromScreen (droppoint); - canvas->SetScale (1); - long dummy; - if (message->FindData ("RGBColor", B_RGB_COLOR_TYPE, (const void **) &dropped, &dummy) == B_OK) - canvas->Fill (M_DRAW, droppoint, dropped); +#else + BTranslatorRoster* roster = BTranslatorRoster::Default(); + if (roster->Translate(bitmapStream, NULL, NULL, &outStream, out_type)) { + char errstring[B_FILE_NAME_LENGTH + 64]; + sprintf( + errstring, lstring(134, "Translation Kit error:\nCouldn't translate `%s'"), + fName + ); + BAlert* alert = new BAlert( + "", errstring, "Help", "OK", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT + ); + uint32 button = alert->Go(); + if (button == 0) { + alert = new BAlert( + "", + lstring( + 156, "This is a rare error. Something went wrong inside the " + "Translator.\nIt could range from shared library conflicts to " + "running out of hard disk space." + ), + lstring(136, "OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT + ); + alert->Go(); + } } - else - canvas->Paste (false); - break; - case 'psNL': // copy to new layer - canvas->CopyToNewLayer(); - break; - case 'psNC': // copy to new canvas - { -// canvas->Copy(); - BRect canvasWindowFrame; - extern BBitmap *clip; - if (clip) - { - char title[256]; - strcpy (title, fName); - strcat (title, lstring (405, " (detail)")); - canvasWindowFrame = clip->Bounds(); - BBitmap *newClip = new BBitmap (clip); - canvasWindowFrame.OffsetTo (Frame().left + 16, Frame().top + 16); - CanvasWindow *canvasWindow = new CanvasWindow (canvasWindowFrame, title, newClip, NULL, false); - canvasWindow->Show(); // will register itself with the app +#endif + BPath path; + entry.GetPath(&path); + const translation_format* format_list = 0; + int32 format_count = 0; + if (BTranslatorRoster::Default()->GetOutputFormats( + out_translator, &format_list, &format_count + ) == B_NO_ERROR) { + for (int i = 0; i < format_count; ++i) { + if (format_list[i].type == out_type) { + outStream.RemoveAttr("BEOS:TYPE"); + char mime[B_FILE_NAME_LENGTH]; + strcpy(mime, format_list[i].MIME); + mime[strlen(mime)] = 0; + mime[strlen(mime) + 1] = 0; + outStream.WriteAttr( + "BEOS:TYPE", B_MIME_STRING_TYPE, 0L, mime, strlen(mime) + 1 + ); + break; + } + } } - break; + extern int DebugLevel; + if (DebugLevel > 1) + printf("Wrote: %s\n", path.Path()); + + delete bitmapStream; + bitmapStream = NULL; + outputFormatWindow = NULL; + out_type = 0; + } else { + canvas->Save(entry); } - case B_SELECT_ALL: - canvas->SelectAll (true); - break; - case 'sund': - canvas->UndoSelection (true); - break; - case 'sinv': - canvas->InvertSelection (true); - break; - case 'ctsA': - case 'ctsR': - case 'ctsG': - case 'ctsB': - case 'ctsC': - case 'ctsM': - case 'ctsY': - case 'ctsK': - case 'ctsH': - case 'ctsS': - case 'ctsV': - canvas->ChannelToSelection (message->what, true); - break; - case 'stcA': - case 'stcR': - case 'stcG': - case 'stcB': - case 'stcC': - case 'stcM': - case 'stcY': - case 'stcK': - case 'stcH': - case 'stcS': - case 'stcV': - canvas->SelectionToChannel (message->what); - break; - case 'ktsA': - { - rgb_color c = canvas->GuessBackgroundColor(); - if (c.alpha == 0) - { - canvas->ChannelToSelection ('ctsA', true); - canvas->InvertSelection (true); + canvas->changed = false; + if (scripted) { + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + error.AddInt32("error", B_NO_ERROR); + message->SendReply(&error); } - else - canvas->SelectByColor (c, true); - break; } - case 'ktsF': - { - extern ColorMenuButton *hicolor; - canvas->SelectByColor (hicolor->color(), true); - break; - } - case 'ktsB': - { - extern ColorMenuButton *locolor; - canvas->SelectByColor (locolor->color(), true); - break; + scripted = false; + entry_ref ref; + entry.GetRef(&ref); + add_to_recent(ref); + if (myTarget && fromRef) { + BMessage* ie = new BMessage(BBP_SEND_BBITMAP); + BMessage ieb; + ie->AddMessenger("target", this); + ie->AddRef("ref", &ref); + myTarget->SendMessage(ie); } - case 'stkF': - { - extern ColorMenuButton *hicolor; - canvas->ColorizeSelection (hicolor->color()); - break; + break; + } + case 'tTed': + canvas->tTextD(); + break; + case 'M_S': + float scale; + int32 index; + if (message->FindFloat("scale", &scale) == B_OK && + message->FindInt32("index", &index) == B_OK) { + canvas->setScale(scale); } - case 'stkB': - { - extern ColorMenuButton *locolor; - canvas->ColorizeSelection (locolor->color()); - break; + break; + case 'Mnnn': { + float s; + if (message->FindFloat("zoom", &s)) + canvas->setScale(s); + break; + } + case 'Min': + canvas->ZoomIn(); + break; + case 'Mout': + canvas->ZoomOut(); + break; + case 'mwin': { + canvas->SetupUndo(M_DRAW); + if (!magWindow) { + BRect frame = Frame(); + frame.OffsetBy(16, 16); + magWindow = new MagWindow(frame, FileName(), canvas); + magWindow->Show(); + } else + magWindow->Activate(); + break; + } + case 'magQ': + if (magWindow->Lock()) { + magWindow->Quit(); + magWindow = NULL; } - case 'SPst': - { - bool v; - message->FindBool ("status", &v); - editMenu->FindItem(B_PASTE)->SetEnabled (v); - editMenu->FindItem('psNL')->SetEnabled (v); - editMenu->FindItem('psNC')->SetEnabled (v); - break; + break; + case 'cmus': + canvas->CenterMouse(); + break; + case 'clrX': // color changed + canvas->InvalidateAddons(); + break; + case 'xpal': { + if (extractWindow) { + extractWindow->Activate(); + } else { + extractWindow = new XpalWindow( + BRect(100, 100, 300, 180), lstring(157, "Extract Palette"), new BMessenger(this) + ); + extractWindow->Show(); + // extractWindow->Quit(); + // extractWindow = NULL; } - case 'cbHd': - { - int32 ind; - message->FindInt32 ("index", &ind); - Layer *il = canvas->getLayer(ind); - il->Hide (!(il->IsHidden())); - canvas->Invalidate(); - UpdateIfNeeded(); - break; + break; + } + case 'xclF': { + int32 num = 256; + message->FindInt32("num_cols", &num); + bool clobber = false; + message->FindBool("clobber", &clobber); + extern ColorMenuButton* hicolor; + hicolor->extractPalette(canvas->currentLayer(), num, clobber); + if (extractWindow) { + extractWindow->Lock(); + extractWindow->Quit(); + extractWindow = NULL; } - case 'Crsd': - { - float width, height, scale; - message->FindFloat ("width", &width); - message->FindFloat ("height", &height); - message->FindFloat ("scale", &scale); - CanvasResized (width, height); - CanvasScaled (scale); - break; + break; + } + case 'xclB': { + int32 num = 256; + message->FindInt32("num_cols", &num); + bool clobber = false; + message->FindBool("clobber", &clobber); + extern ColorMenuButton* locolor; + locolor->extractPalette(canvas->currentLayer(), num, clobber); + if (extractWindow) { + extractWindow->Lock(); + extractWindow->Quit(); + extractWindow = NULL; } - case 'PrPP': - canvas->Print(); - break; - case 'cwin': - canvas->CropToWindow(); - break; - case 'Crop': - { - BRect cropRect; -// message->PrintToStream(); - status_t err = B_NO_ERROR; - if (message->FindRect ("data", &cropRect) == B_OK) - { - err = canvas->Crop (cropRect); - } - else - err = -4; - if (message->IsSourceWaiting()) - { - BMessage error (B_REPLY); - switch (err) - { - case -1: - error.AddString ("message", "Crop Rect == Canvas Rect"); - err = 0; // not really a problem - break; - case -2: - error.AddString ("message", "Crop Rect > Canvas Rect"); - break; - case -3: - error.AddString ("message", "Crop Rect outside Canvas Rect"); - break; - case -4: - error.AddString ("message", "No Crop Rect found in message"); - break; - } - error.AddInt32 ("error", err); - message->SendReply (&error); - } - break; + break; + } + case 'rstf': // MYSTERY!!! + { + Lock(); + BRect cf = canvas->Frame(); + BRect mf = menubar->Frame(); + // printf ("MIN_WIDTH = %f, MAX_HEIGHT = %f\n", MIN_WIDTH, MIN_HEIGHT); + // printf ("canvas->Frame().Width() = %f, Height() = %f\n", cf.Width(), + // cf.Height()); printf ("menubar->Frame().Height() = %f\n", mf.Height()); + // printf ("w = %f, h = %f\n", max_c (MIN_WIDTH, cf.Width() + B_V_SCROLL_BAR_WIDTH), max_c + //(MIN_HEIGHT, cf.Height() + B_H_SCROLL_BAR_HEIGHT + mf.Height())); + ResizeTo( + max_c(MIN_WIDTH, cf.Width() + B_V_SCROLL_BAR_WIDTH), + max_c(MIN_HEIGHT, cf.Height() + B_H_SCROLL_BAR_HEIGHT + mf.Height() + 1) + ); + canvas->Invalidate(); + Unlock(); + break; + } + case 'rszT': // Resize To + { + char title[1024]; + sprintf(title, "%s %s", lstring(402, "Resize"), FileName()); + ResizeWindow* rw = new ResizeWindow( + this, title, canvas->Frame().Height() + 1, canvas->Frame().Width() + 1 + ); + rw->Show(); + break; + } + case 'rszt': { + int32 w = canvas->Frame().IntegerWidth() + 1; + int32 h = canvas->Frame().IntegerHeight() + 1; + message->FindInt32("width", &w); + message->FindInt32("height", &h); + canvas->resizeTo(w, h); + break; + } + case 'flpH': // Flip Horizontal + { + int32 index = -1; + message->FindInt32("layer", &index); + canvas->flipLayer(0, index); + break; + } + case 'flpV': // Flip Vertical + { + int32 index = -1; + message->FindInt32("layer", &index); + canvas->flipLayer(1, index); + break; + } + case 'layr': + if (layerOpen) { + // layerWindow->Lock(); + layerWindow->Activate(); + // windowMenu->FindItem('layr')->SetMarked (false); + // layerOpen = false; + } else { + char title[B_FILE_NAME_LENGTH + 10]; + sprintf(title, lstring(160, "Layers in %s"), fName); + BRect layerFrame = BRect(100, 100, 310, 294); + layerWindow = new LayerWindow(layerFrame, title, canvas); + layerWindow->Show(); + windowMenu->FindItem('layr')->SetMarked(true); + layerOpen = true; } - case 'csel': - canvas->CropToSelection(); - break; - case 'caut': - canvas->AutoCrop(); - break; - case 'pwlt': - case 'pwrt': - case 'pwlb': - case 'pwrb': - case 'pwct': - canvas->Pad (message->what); - break; - case 'rwkr': - case 'rwar': - canvas->ResizeToWindow (message->what); - break; - case 'r90': - case 'r180': - case 'r270': - canvas->RotateCanvas (message->what); - break; - case 'adon': - { - extern BList *AddOns; - AddOn *addon; - int32 index; - message->FindInt32 ("index", &index); -// printf ("%i\n", index); - addon = (AddOn *) AddOns->ItemAt (index); - canvas->OpenAddon (addon, fName); - break; + break; + case 'layQ': + windowMenu->FindItem('layr')->SetMarked(false); + layerOpen = false; + break; + case 'delL': + // printf ("CanvasWindow::MessageReceived ('delL');\n"); + canvas->removeLayer(canvas->currentLayerIndex()); + // setLayerMenu(); + break; + case 'newL': + if (LockWithTimeout(100000) == B_OK) { + canvas->addLayer(lstring(161, "Untitled Layer")); + Unlock(); + // setLayerMenu(); + } else + printf("Hey, couldn't lock!!\n"); + break; + case 'insL': + canvas->insertLayer(canvas->currentLayerIndex(), lstring(161, "Untitled Layer")); + // setLayerMenu(); + break; + case 'trsL': + canvas->translateLayer(canvas->currentLayerIndex()); + break; + case 'rotL': + canvas->rotateLayer(canvas->currentLayerIndex()); + break; + case 'mrgL': + canvas->mergeLayers(canvas->currentLayerIndex() - 1, canvas->currentLayerIndex()); + // setLayerMenu(); + break; + case 'lNch': { + int32 index; + message->FindInt32("index", &index); + BMessage* msg = new BMessage('lNch'); + msg->AddInt32("index", index); + canvas->MessageReceived(msg); + delete msg; + setLayerMenu(); + break; + } + case 'dupL': + // canvas->WriteAsHex ("logo.dat"); + canvas->duplicateLayer(canvas->currentLayerIndex()); + // setLayerMenu(); + break; + case 'movL': { + int32 a, b; + message->FindInt32("from", &a); + message->FindInt32("to", &b); + canvas->moveLayers(a, b); + // setLayerMenu(); + break; + } + case 'lChg': + if (isLayerOpen()) + layerWindow->PostMessage(message); + canvas->changed = true; + setLayerMenu(); + break; + case 'lSel': { + int32 ind; + message->FindInt32("index", &ind); + canvas->makeCurrentLayer(ind); + // setLayerMenu(); + break; + } + case 'Loup': { + int current = canvas->currentLayerIndex(); + if (current < canvas->numLayers() - 1) { + canvas->makeCurrentLayer(current + 1); + // setLayerMenu(); } - case 'adcl': - { - extern BList *AddOns; - AddOn *addon; - int32 index; - message->FindInt32 ("index", &index); -// printf ("Saying goodbye to AddOn %i\n", index); - addon = (AddOn *) AddOns->ItemAt (index); - canvas->CloseAddon (addon); - if (message->IsSourceWaiting()) - { -// printf ("Sending Reply...\n"); - message->SendReply (new BMessage ('cack')); - } - break; + break; + } + case 'Lodn': { + int current = canvas->currentLayerIndex(); + if (current > 0) { + canvas->makeCurrentLayer(current - 1); + // setLayerMenu(); } - case 'capt': - { - extern BList *AddOns; - AddOn *addon; - int32 index; - message->FindInt32 ("index", &index); - addon = (AddOn *) AddOns->ItemAt (index); - addon->Open (NULL, NULL); - break; + break; + } + case 'DMch': { + int32 index, newmode; + message->FindInt32("index", &index); + message->FindInt32("newmode", &newmode); + canvas->setChannelOperation(index, newmode); + break; + } + case 'Liga': { + int32 index, ga; + message->FindInt32("index", &index); + message->FindInt32("alpha", &ga); + canvas->setGlobalAlpha(index, ga); + break; + } + case B_UNDO: + canvas->Undo(true, true); + break; + case 'redo': + canvas->Redo(true); + break; + case B_CUT: + canvas->Cut(); + break; + case B_COPY: + canvas->Copy(); + break; + case B_PASTE: + if (message->WasDropped()) { + rgb_color* dropped; + BPoint droppoint = message->DropPoint(); + canvas->SetScale(canvas->getScale()); // ? + droppoint = canvas->ConvertFromScreen(droppoint); + canvas->SetScale(1); + long dummy; + if (message->FindData("RGBColor", B_RGB_COLOR_TYPE, (const void**)&dropped, &dummy) == + B_OK) + canvas->Fill(M_DRAW, droppoint, dropped); + } else + canvas->Paste(false); + break; + case 'psNL': // copy to new layer + canvas->CopyToNewLayer(); + break; + case 'psNC': // copy to new canvas + { + // canvas->Copy(); + BRect canvasWindowFrame; + extern BBitmap* clip; + if (clip) { + char title[256]; + strcpy(title, fName); + strcat(title, lstring(405, " (detail)")); + canvasWindowFrame = clip->Bounds(); + BBitmap* newClip = new BBitmap(clip); + canvasWindowFrame.OffsetTo(Frame().left + 16, Frame().top + 16); + CanvasWindow* canvasWindow = + new CanvasWindow(canvasWindowFrame, title, newClip, NULL, false); + canvasWindow->Show(); // will register itself with the app } - case ADDON_PREVIEW: - { - extern BList *AddOns; - AddOn *addon; - int32 index, type; - message->FindInt32 ("index", &index); - message->FindInt32 ("type", &type); -// printf ("%i\n", index); - addon = (AddOn *) AddOns->ItemAt (index); - switch (type) - { - case BECASSO_FILTER: - canvas->Filter (addon, true); + break; + } + case B_SELECT_ALL: + canvas->SelectAll(true); + break; + case 'sund': + canvas->UndoSelection(true); + break; + case 'sinv': + canvas->InvertSelection(true); + break; + case 'ctsA': + case 'ctsR': + case 'ctsG': + case 'ctsB': + case 'ctsC': + case 'ctsM': + case 'ctsY': + case 'ctsK': + case 'ctsH': + case 'ctsS': + case 'ctsV': + canvas->ChannelToSelection(message->what, true); + break; + case 'stcA': + case 'stcR': + case 'stcG': + case 'stcB': + case 'stcC': + case 'stcM': + case 'stcY': + case 'stcK': + case 'stcH': + case 'stcS': + case 'stcV': + canvas->SelectionToChannel(message->what); + break; + case 'ktsA': { + rgb_color c = canvas->GuessBackgroundColor(); + if (c.alpha == 0) { + canvas->ChannelToSelection('ctsA', true); + canvas->InvertSelection(true); + } else + canvas->SelectByColor(c, true); + break; + } + case 'ktsF': { + extern ColorMenuButton* hicolor; + canvas->SelectByColor(hicolor->color(), true); + break; + } + case 'ktsB': { + extern ColorMenuButton* locolor; + canvas->SelectByColor(locolor->color(), true); + break; + } + case 'stkF': { + extern ColorMenuButton* hicolor; + canvas->ColorizeSelection(hicolor->color()); + break; + } + case 'stkB': { + extern ColorMenuButton* locolor; + canvas->ColorizeSelection(locolor->color()); + break; + } + case 'SPst': { + bool v; + message->FindBool("status", &v); + editMenu->FindItem(B_PASTE)->SetEnabled(v); + editMenu->FindItem('psNL')->SetEnabled(v); + editMenu->FindItem('psNC')->SetEnabled(v); + break; + } + case 'cbHd': { + int32 ind; + message->FindInt32("index", &ind); + Layer* il = canvas->getLayer(ind); + il->Hide(!(il->IsHidden())); + canvas->Invalidate(); + UpdateIfNeeded(); + break; + } + case 'Crsd': { + float width, height, scale; + message->FindFloat("width", &width); + message->FindFloat("height", &height); + message->FindFloat("scale", &scale); + CanvasResized(width, height); + CanvasScaled(scale); + break; + } + case 'PrPP': + canvas->Print(); + break; + case 'cwin': + canvas->CropToWindow(); + break; + case 'Crop': { + BRect cropRect; + // message->PrintToStream(); + status_t err = B_NO_ERROR; + if (message->FindRect("data", &cropRect) == B_OK) { + err = canvas->Crop(cropRect); + } else + err = -4; + if (message->IsSourceWaiting()) { + BMessage error(B_REPLY); + switch (err) { + case -1: + error.AddString("message", "Crop Rect == Canvas Rect"); + err = 0; // not really a problem break; - case BECASSO_TRANSFORMER: - canvas->Transform (addon, true); + case -2: + error.AddString("message", "Crop Rect > Canvas Rect"); break; - case BECASSO_GENERATOR: - canvas->Generate (addon, true); + case -3: + error.AddString("message", "Crop Rect outside Canvas Rect"); + break; + case -4: + error.AddString("message", "No Crop Rect found in message"); break; - default: - fprintf (stderr, "Unknown addon requested preview: %li, type: %li\n", index, type); } - break; + error.AddInt32("error", err); + message->SendReply(&error); } - case ADDON_FILTER: - { - extern BList *AddOns; - AddOn *addon; - int32 index; - message->FindInt32 ("index", &index); -// printf ("%i\n", index); - addon = (AddOn *) AddOns->ItemAt (index); - canvas->Filter (addon); - break; + break; + } + case 'csel': + canvas->CropToSelection(); + break; + case 'caut': + canvas->AutoCrop(); + break; + case 'pwlt': + case 'pwrt': + case 'pwlb': + case 'pwrb': + case 'pwct': + canvas->Pad(message->what); + break; + case 'rwkr': + case 'rwar': + canvas->ResizeToWindow(message->what); + break; + case 'r90': + case 'r180': + case 'r270': + canvas->RotateCanvas(message->what); + break; + case 'adon': { + extern BList* AddOns; + AddOn* addon; + int32 index; + message->FindInt32("index", &index); + // printf ("%i\n", index); + addon = (AddOn*)AddOns->ItemAt(index); + canvas->OpenAddon(addon, fName); + break; + } + case 'adcl': { + extern BList* AddOns; + AddOn* addon; + int32 index; + message->FindInt32("index", &index); + // printf ("Saying goodbye to AddOn %i\n", index); + addon = (AddOn*)AddOns->ItemAt(index); + canvas->CloseAddon(addon); + if (message->IsSourceWaiting()) { + // printf ("Sending Reply...\n"); + message->SendReply(new BMessage('cack')); } - case ADDON_TRANSFORMER: - { - extern BList *AddOns; - AddOn *addon; - int32 index; - message->FindInt32 ("index", &index); -// printf ("%i\n", index); - addon = (AddOn *) AddOns->ItemAt (index); - canvas->Transform (addon); + break; + } + case 'capt': { + extern BList* AddOns; + AddOn* addon; + int32 index; + message->FindInt32("index", &index); + addon = (AddOn*)AddOns->ItemAt(index); + addon->Open(NULL, NULL); + break; + } + case ADDON_PREVIEW: { + extern BList* AddOns; + AddOn* addon; + int32 index, type; + message->FindInt32("index", &index); + message->FindInt32("type", &type); + // printf ("%i\n", index); + addon = (AddOn*)AddOns->ItemAt(index); + switch (type) { + case BECASSO_FILTER: + canvas->Filter(addon, true); break; - } - case ADDON_GENERATOR: - { - extern BList *AddOns; - AddOn *addon; - int32 index; - message->FindInt32 ("index", &index); -// printf ("%i\n", index); - addon = (AddOn *) AddOns->ItemAt (index); - canvas->Generate (addon); + case BECASSO_TRANSFORMER: + canvas->Transform(addon, true); break; - } - default: - //printf ("CanvasWindow::MessageReceived:\n"); - //message->PrintToStream(); - inherited::MessageReceived (message); + case BECASSO_GENERATOR: + canvas->Generate(addon, true); break; + default: + fprintf(stderr, "Unknown addon requested preview: %li, type: %li\n", index, type); + } + break; + } + case ADDON_FILTER: { + extern BList* AddOns; + AddOn* addon; + int32 index; + message->FindInt32("index", &index); + // printf ("%i\n", index); + addon = (AddOn*)AddOns->ItemAt(index); + canvas->Filter(addon); + break; + } + case ADDON_TRANSFORMER: { + extern BList* AddOns; + AddOn* addon; + int32 index; + message->FindInt32("index", &index); + // printf ("%i\n", index); + addon = (AddOn*)AddOns->ItemAt(index); + canvas->Transform(addon); + break; + } + case ADDON_GENERATOR: { + extern BList* AddOns; + AddOn* addon; + int32 index; + message->FindInt32("index", &index); + // printf ("%i\n", index); + addon = (AddOn*)AddOns->ItemAt(index); + canvas->Generate(addon); + break; + } + default: + // printf ("CanvasWindow::MessageReceived:\n"); + // message->PrintToStream(); + inherited::MessageReceived(message); + break; } } -#if defined (__POWERPC__) -# pragma optimization_level 4 +#if defined(__POWERPC__) +#pragma optimization_level 4 #endif diff --git a/source/CanvasWindow.h b/source/CanvasWindow.h index c568791..d71614a 100644 --- a/source/CanvasWindow.h +++ b/source/CanvasWindow.h @@ -13,11 +13,12 @@ #include #include #include -#if defined (DATATYPES) -# include +#include +#if defined(DATATYPES) +#include #else -# include -# define DATAInfo translator_info +#include +#define DATAInfo translator_info #endif #include #include @@ -40,82 +41,99 @@ class XpalWindow; class CanvasWindow : public BWindow { -friend class CanvasView; -public: - CanvasWindow (BRect frame, const char *name, BBitmap *map = NULL, BMessenger *target = NULL, bool AskForAlpha = true, rgb_color color = White); - CanvasWindow (BRect frame, entry_ref ref, bool AskForAlpha = true, BMessenger *target = NULL); -virtual ~CanvasWindow (); -virtual void Quit (); -virtual bool QuitRequested (); -virtual void MenusBeginning (); -virtual void MenusEnded (); - bool MenuOnScreen () { return menuIsOn; }; -virtual void MessageReceived (BMessage *message); -virtual void FrameMoved (BPoint screenpoint); -virtual void FrameResized (float width, float height); -virtual void ScreenChanged (BRect frame, color_space mode); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual status_t GetSupportedSuites (BMessage *message); - - - void save (entry_ref *ref, char *file, int fd); - void setMenuItem (uint32 command, bool v); - void setPaste (bool v); - void setLayerMenu (); - - bool isLayerOpen () { return layerOpen; } -MagWindow *TheMagWindow () { return magWindow; } - - void CanvasResized (float width, float height); - void CanvasScaled (float scale); - -float getScale () { return fScale; } -char *FileName () { return fName; } -char *CanvasName () { return fCanvasName; } -void setName (char *n); - -bool IsQuitting () { return quitting; } - -entry_ref MyRef () { return myRef; } - -private: -typedef BWindow inherited; -void restOfCtor (BRect frame, BBitmap *map, FILE *fp = NULL, bool AskForAlpha = true, rgb_color color = White); -BMessage *sendbitmapreply (); - -char fName[B_FILE_NAME_LENGTH]; -char fCanvasName[B_FILE_NAME_LENGTH]; -float fScale; -BMenuBar *menubar; -BMenu *fileMenu; -BMenu *editMenu; -BMenu *windowMenu; -BMenu *layerMenu; -BMenu *layerNamesMenu; -BScrollBar *h; -BScrollBar *v; -BGView *bg; -CanvasView *canvas; -PosView *posview; -BFilePanel *savePanel; -LayerWindow *layerWindow; -MagWindow *magWindow; -XpalWindow *extractWindow; -ProgressiveBitmapStream *bitmapStream; -OutputFormatWindow *outputFormatWindow; -uint32 out_type; -//DATAInfo out_info; -translator_id out_translator; -bool layerOpen; -bool quitting; -bool scripted; -int fCurrentProperty; -BInvoker *of_selected; -entry_ref myRef; -bool fromRef; -BMessenger *myTarget; // InterfaceElements -BMessenger *ieTarget; // ImageElements -bool menuIsOn; + friend class CanvasView; + + public: + CanvasWindow( + BRect frame, const char* name, BBitmap* map = NULL, BMessenger* target = NULL, + bool AskForAlpha = true, rgb_color color = White + ); + CanvasWindow(BRect frame, entry_ref ref, bool AskForAlpha = true, BMessenger* target = NULL); + virtual ~CanvasWindow(); + virtual void Quit(); + virtual bool QuitRequested(); + virtual void MenusBeginning(); + virtual void MenusEnded(); + + bool MenuOnScreen() { return menuIsOn; }; + + virtual void MessageReceived(BMessage* message); + virtual void FrameMoved(BPoint screenpoint); + virtual void FrameResized(float width, float height); + virtual void ScreenChanged(BRect frame, color_space mode); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual status_t GetSupportedSuites(BMessage* message); + + + void save(entry_ref* ref, char* file, int fd); + void setMenuItem(uint32 command, bool v); + void setPaste(bool v); + void setLayerMenu(); + + bool isLayerOpen() { return layerOpen; } + + MagWindow* TheMagWindow() { return magWindow; } + + void CanvasResized(float width, float height); + void CanvasScaled(float scale); + + float getScale() { return fScale; } + + char* FileName() { return fName; } + + char* CanvasName() { return fCanvasName; } + + void setName(char* n); + + bool IsQuitting() { return quitting; } + + entry_ref MyRef() { return myRef; } + + private: + typedef BWindow inherited; + void restOfCtor( + BRect frame, BBitmap* map, FILE* fp = NULL, bool AskForAlpha = true, rgb_color color = White + ); + BMessage* sendbitmapreply(); + + char fName[B_FILE_NAME_LENGTH]; + char fCanvasName[B_FILE_NAME_LENGTH]; + float fScale; + BMenuBar* menubar; + BMenu* fileMenu; + BMenu* editMenu; + BMenu* windowMenu; + BMenu* layerMenu; + BMenu* layerNamesMenu; + BScrollBar* h; + BScrollBar* v; + BString fPercentData; + BString fTitleString; + BNumberFormat fNumberFormat; + BGView* bg; + CanvasView* canvas; + PosView* posview; + BFilePanel* savePanel; + LayerWindow* layerWindow; + MagWindow* magWindow; + XpalWindow* extractWindow; + ProgressiveBitmapStream* bitmapStream; + OutputFormatWindow* outputFormatWindow; + uint32 out_type; + // DATAInfo out_info; + translator_id out_translator; + bool layerOpen; + bool quitting; + bool scripted; + int fCurrentProperty; + BInvoker* of_selected; + entry_ref myRef; + bool fromRef; + BMessenger* myTarget; // InterfaceElements + BMessenger* ieTarget; // ImageElements + bool menuIsOn; }; -#endif \ No newline at end of file +#endif diff --git a/source/CaptureTestApplication.cpp b/source/CaptureTestApplication.cpp index d7ae8b5..ef9fcf3 100644 --- a/source/CaptureTestApplication.cpp +++ b/source/CaptureTestApplication.cpp @@ -1,120 +1,104 @@ #include "Datatypes.h" #include - -class MyWindow : - public BWindow +class MyWindow : public BWindow { -public: - MyWindow(); - ~MyWindow(); - - bool QuitRequested(); -static status_t RecordThread( - void * data); - void MessageReceived( - BMessage * message); - - DATAID fHandler; - thread_id fRecordThread; - BView * fCapture; -}; + public: + MyWindow(); + ~MyWindow(); + bool QuitRequested(); + static status_t RecordThread(void* data); + void MessageReceived(BMessage* message); -class TestApplication: public BApplication + DATAID fHandler; + thread_id fRecordThread; + BView* fCapture; +}; + +class TestApplication : public BApplication { -public: + public: TestApplication(); void preRun(void); - MyWindow *mw; + MyWindow* mw; }; -void main() +void +main() { - TestApplication *app; - app=new TestApplication(); + TestApplication* app; + app = new TestApplication(); app->preRun(); app->Run(); DATAShutdown(); - delete(app); + delete (app); } -const char * SIGNATURE = "application/x-redrackam-testCaptureHandler"; - -TestApplication::TestApplication():BApplication(SIGNATURE) -{ -} +const char* SIGNATURE = "application/x-redrackam-testCaptureHandler"; +TestApplication::TestApplication() : BApplication(SIGNATURE) {} -class BitmapView: public BView +class BitmapView : public BView { -public: + public: BitmapView(BRect a); void Draw(BRect area); - void Decode(BPositionIO *stream); - void MouseDown(BPoint point); -private: - BBitmap *bitmap; -}; - - - - + void Decode(BPositionIO* stream); + void MouseDown(BPoint point); + private: + BBitmap* bitmap; +}; -BitmapView ::BitmapView(BRect a):BView(a,"BitmapInput", B_FOLLOW_NONE, B_WILL_DRAW) -{ -} +BitmapView ::BitmapView(BRect a) : BView(a, "BitmapInput", B_FOLLOW_NONE, B_WILL_DRAW) {} -void BitmapView ::Draw(BRect area) +void +BitmapView ::Draw(BRect area) { // Si la view est en train d'imprimer // Alors on dessine la bitmap au centre, la plus grande possible - if (IsPrinting() == true) - { + if (IsPrinting() == true) { // Calcul de la taille de l'image en pixels (12 x 9 cm) - float w_pixel = (12.0 / 2.54) * 72.0; - float h_pixel = ( 9.0 / 2.54) * 72.0; - BRect rect(0.0, 0.0, w_pixel-1.0, h_pixel-1.0); + float w_pixel = (12.0 / 2.54) * 72.0; + float h_pixel = (9.0 / 2.54) * 72.0; + BRect rect(0.0, 0.0, w_pixel - 1.0, h_pixel - 1.0); - // Centrer l'image - rect.OffsetTo(0.5*(Bounds().Width() - rect.Width()),0.5*(Bounds().Height() - rect.Height())); + // Centrer l'image + rect.OffsetTo( + 0.5 * (Bounds().Width() - rect.Width()), 0.5 * (Bounds().Height() - rect.Height()) + ); // dessine l'image DrawBitmap(bitmap, rect); - } - else - { - DrawBitmap(bitmap, BPoint(0,0)); + } else { + DrawBitmap(bitmap, BPoint(0, 0)); } } - -void BitmapView::MouseDown(BPoint point) +void +BitmapView::MouseDown(BPoint point) { - BMenuItem *selected; - int32 buttons = 0; - Window()->CurrentMessage()->FindInt32("buttons", &buttons); - if (buttons&B_SECONDARY_MOUSE_BUTTON) - { - BMessage *msg; - BMenuItem *item; - BPopUpMenu *menu=new BPopUpMenu("Print"); - msg=new BMessage('prnt'); - item=new BMenuItem("print", - msg); + BMenuItem* selected; + int32 buttons = 0; + Window()->CurrentMessage()->FindInt32("buttons", &buttons); + if (buttons & B_SECONDARY_MOUSE_BUTTON) { + BMessage* msg; + BMenuItem* item; + BPopUpMenu* menu = new BPopUpMenu("Print"); + msg = new BMessage('prnt'); + item = new BMenuItem("print", msg); menu->AddItem(item); - ConvertToScreen(&point); - selected =menu->Go(point); - if ( selected ) - { - // POUR MATHIAS:: METTRE ICI TON PRINT - // LA VIEW A DESSINER, c'est THIS - // TU PEUX MEME ENVOYER LE MESSAGE GENERE PAR LE BOUTON DIRECTEMENT AU PRINT SERVEUR - // (avec un SetTarget et en completant le message pour qu'il contienne ce qu'il faut) - + ConvertToScreen(&point); + selected = menu->Go(point); + if (selected) { + // POUR MATHIAS:: METTRE ICI TON PRINT + // LA VIEW A DESSINER, c'est THIS + // TU PEUX MEME ENVOYER LE MESSAGE GENERE PAR LE BOUTON DIRECTEMENT AU PRINT SERVEUR + // (avec un SetTarget et en completant le message pour qu'il contienne ce qu'il faut) + // Quelques variables utiles - BMessage *setup = NULL; // normalement, c'est le message de configuration + BMessage* setup = NULL; // normalement, c'est le message de configuration status_t err; // On cree un print job avec un nom pour le spool @@ -125,179 +109,159 @@ void BitmapView::MouseDown(BPoint point) // D'abord parametrer le format de la page // Normalement, ca se fait sur demande de l'utilisateur job.ConfigPage(); - - // Si on a une conf par defaut (par ex. sauvee avec le document) - // Alors il faut la passer au print server - if (setup) + + // Si on a une conf par defaut (par ex. sauvee avec le document) + // Alors il faut la passer au print server + if (setup) job.SetSettings(new BMessage(setup)); - - // Dans tous les cas, on affiche la page de reglage - if ( (err = job.ConfigJob()) == B_OK ) - { + + // Dans tous les cas, on affiche la page de reglage + if ((err = job.ConfigJob()) == B_OK) { if (setup != NULL) - delete setup; + delete setup; // On recupere les choix de l'utilisateur - setup = job.Settings(); + setup = job.Settings(); } - + // Ouvrir le fichier de spool job.BeginJob(); - + // Dessiner la page BRect rect = job.PrintableRect(); BPoint pointOnPage(B_ORIGIN); job.DrawView(this, rect, pointOnPage); - + // Envoyer la page job.SpoolPage(); - - // On a fini + + // On a fini job.CommitJob(); } } } -void BitmapView::Decode(BPositionIO *stream) +void +BitmapView::Decode(BPositionIO* stream) { - char *bits; + char* bits; DATABitmap header; - stream->Seek(0,SEEK_SET); + stream->Seek(0, SEEK_SET); stream->Read(&header, sizeof(header)); - this->ResizeTo(header.bounds.Width(), - header.bounds.Height()); - Window()->ResizeTo(header.bounds.Width(), - header.bounds.Height()); - if (header.magic!=DATA_BITMAP) - { + this->ResizeTo(header.bounds.Width(), header.bounds.Height()); + Window()->ResizeTo(header.bounds.Width(), header.bounds.Height()); + if (header.magic != DATA_BITMAP) { return; } - - bitmap=new BBitmap( header.bounds, - header.colors, - true); - bits=(char *)bitmap->Bits(); -// bits=(char *)malloc(header.dataSize);; -// printf("length (bitmap)=%lx header=%lx\n",bitmap->BitsLength(),header.dataSize); - stream->Read( bits, - header.dataSize); - //view->OffsetTo(B_ORIGIN); -// bitmap->SetBits(bits,header.dataSize,0,header.colors); -// free(bits); -// view->AddChild(bitmap); + + bitmap = new BBitmap(header.bounds, header.colors, true); + bits = (char*)bitmap->Bits(); + // bits=(char *)malloc(header.dataSize);; + // printf("length (bitmap)=%lx header=%lx\n",bitmap->BitsLength(),header.dataSize); + stream->Read(bits, header.dataSize); + // view->OffsetTo(B_ORIGIN); + // bitmap->SetBits(bits,header.dataSize,0,header.colors); + // free(bits); + // view->AddChild(bitmap); } -void TestApplication::preRun(void) +void +TestApplication::preRun(void) { status_t res; DATAInit("application/x-redrakam-CaptureTestHandler"); mw = new MyWindow; mw->Show(); - BitmapView *view; + BitmapView* view; BMallocIO stream; - BMessage message; - do - { - res=DATACapture(mw->fHandler, - mw->fCapture, // can be NULL - &message, // can be NULL - stream, - DATA_BITMAP); - if (mw) - { + BMessage message; + do { + res = DATACapture( + mw->fHandler, + mw->fCapture, // can be NULL + &message, // can be NULL + stream, DATA_BITMAP + ); + if (mw) { mw->Lock(); - BRect area=mw->fCapture->Frame(); + BRect area = mw->fCapture->Frame(); mw->Unlock(); - view=new BitmapView(area); - area.OffsetTo(100,100); - BWindow *new_bw= new BWindow(area,"Capture", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE); - + view = new BitmapView(area); + area.OffsetTo(100, 100); + BWindow* new_bw = + new BWindow(area, "Capture", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE); + new_bw->AddChild(view); view->Decode(&stream); new_bw->Show(); - DATAGetConfigMessage(mw->fHandler, - &message); - // message.PrintToStream(); + DATAGetConfigMessage(mw->fHandler, &message); + // message.PrintToStream(); } - } while (res==B_OK); -} - -MyWindow::~MyWindow() -{ - be_app->PostMessage(B_QUIT_REQUESTED); + } while (res == B_OK); } +MyWindow::~MyWindow() { be_app->PostMessage(B_QUIT_REQUESTED); } -MyWindow::MyWindow() : BWindow(BRect(200,200,400,400), "Capture", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) +MyWindow::MyWindow() + : BWindow( + BRect(200, 200, 400, 400), "Capture", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE + ) { - DATAID * list = NULL; + DATAID* list = NULL; int32 count = 0; int32 ix; BRect x; - if (DATAListCaptures(DATA_BITMAP, list, count) || (count < 1)) - { - BAlert *alrt = new BAlert("Not!", "There are no bitmap capture datatypes installed.", "Quit"); + if (DATAListCaptures(DATA_BITMAP, list, count) || (count < 1)) { + BAlert* alrt = + new BAlert("Not!", "There are no bitmap capture datatypes installed.", "Quit"); alrt->Go(); PostMessage(B_QUIT_REQUESTED); return; } - BMessage *new_message=new BMessage('test'); - - for (ix=0; (ix < count) && DATAMakeCapturePanel( list[ix], - new_message, - fCapture, - x); - ix++) - { + BMessage* new_message = new BMessage('test'); + + for (ix = 0; (ix < count) && DATAMakeCapturePanel(list[ix], new_message, fCapture, x); ix++) { fCapture = NULL; } - if (!fCapture) - { - BAlert *alrt = new BAlert("Not!", "None of the installed btmap capture datatypes liked me.", "Quit"); + if (!fCapture) { + BAlert* alrt = + new BAlert("Not!", "None of the installed btmap capture datatypes liked me.", "Quit"); alrt->Go(); PostMessage(B_QUIT_REQUESTED); delete[] list; return; - } - else - { - char *name,*info; + } else { + char *name, *info; int32 version; fHandler = list[ix]; - DATAGetHandlerInfo(fHandler, - name, - info, - version); - // printf("name:%s info %s version %ld\n",name,info,version); - DATAGetConfigMessage(fHandler, - new_message); - // new_message->PrintToStream(); - + DATAGetHandlerInfo(fHandler, name, info, version); + // printf("name:%s info %s version %ld\n",name,info,version); + DATAGetConfigMessage(fHandler, new_message); + // new_message->PrintToStream(); } - + delete[] list; ResizeTo(x.Width(), x.Height()); - x.top = x.bottom+3; - x.bottom = x.top+20; + x.top = x.bottom + 3; + x.bottom = x.top + 20; x.left += 10; x.right -= 10; AddChild(fCapture); } void -MyWindow::MessageReceived( - BMessage * message) +MyWindow::MessageReceived(BMessage* message) { char a[5]; - *(long *)a=message->what; - //printf("message recu %s\n",a); - inherited::MessageReceived(message); + *(long*)a = message->what; + // printf("message recu %s\n",a); + inherited::MessageReceived(message); } bool MyWindow::QuitRequested() { - ((TestApplication *)be_app)->mw=NULL; + ((TestApplication*)be_app)->mw = NULL; be_app->PostMessage(B_QUIT_REQUESTED); return true; } diff --git a/source/ColorItem.cpp b/source/ColorItem.cpp index 2326b02..c4a4ac4 100644 --- a/source/ColorItem.cpp +++ b/source/ColorItem.cpp @@ -2,53 +2,49 @@ #include "ColorMenuButton.h" #include "Colors.h" -ColorItem::ColorItem (const rgb_color _color) -: BMenuItem ("", NULL) -{ - color = _color; -} +ColorItem::ColorItem(const rgb_color _color) : BMenuItem("", NULL) { color = _color; } -ColorItem::~ColorItem () -{ -} +ColorItem::~ColorItem() {} -rgb_color ColorItem::getColor () +rgb_color +ColorItem::getColor() { -// printf ("r = %i, g = %i, b = %i\n", color.red, color.green, color.blue); + // printf ("r = %i, g = %i, b = %i\n", color.red, color.green, color.blue); return (color); } -void ColorItem::setColor (rgb_color _color) +void +ColorItem::setColor(rgb_color _color) { color = _color; } -void ColorItem::Draw () +void +ColorItem::Draw() { BRect frame = Frame(); frame.right -= 1; frame.bottom -= 1; rgb_color oldLo = Menu()->LowColor(); - Menu()->SetLowColor (color); - if (IsSelected() || IsMarked()) - { + Menu()->SetLowColor(color); + if (IsSelected() || IsMarked()) { rgb_color oldHi = Menu()->HighColor(); - Menu()->SetHighColor (White); - Menu()->StrokeRect (frame); - frame.InsetBy (1, 1); - Menu()->SetHighColor (Black); - Menu()->StrokeRect (frame); - Menu()->SetHighColor (oldHi); - frame.InsetBy (1, 1); - Menu()->FillRect (frame, B_SOLID_LOW); - } - else - Menu()->FillRect (frame, B_SOLID_LOW); + Menu()->SetHighColor(White); + Menu()->StrokeRect(frame); + frame.InsetBy(1, 1); + Menu()->SetHighColor(Black); + Menu()->StrokeRect(frame); + Menu()->SetHighColor(oldHi); + frame.InsetBy(1, 1); + Menu()->FillRect(frame, B_SOLID_LOW); + } else + Menu()->FillRect(frame, B_SOLID_LOW); - Menu()->SetLowColor (oldLo); + Menu()->SetLowColor(oldLo); } -void ColorItem::GetContentSize (float *width, float *height) +void +ColorItem::GetContentSize(float* width, float* height) { *width = 0; *height = C_SIZE; diff --git a/source/ColorItem.h b/source/ColorItem.h index 9b317f0..cbb3977 100644 --- a/source/ColorItem.h +++ b/source/ColorItem.h @@ -5,19 +5,20 @@ class ColorItem : public BMenuItem { -public: - ColorItem (const rgb_color _color); -virtual ~ColorItem (); -rgb_color getColor (); -void setColor (rgb_color _color); + public: + ColorItem(const rgb_color _color); + virtual ~ColorItem(); + rgb_color getColor(); + void setColor(rgb_color _color); -virtual void Draw (); -protected: -virtual void GetContentSize (float *width, float *height); + virtual void Draw(); -private: -typedef BMenuItem inherited; -rgb_color color; + protected: + virtual void GetContentSize(float* width, float* height); + + private: + typedef BMenuItem inherited; + rgb_color color; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/ColorMenu.cpp b/source/ColorMenu.cpp index 37cb340..3d37ab8 100644 --- a/source/ColorMenu.cpp +++ b/source/ColorMenu.cpp @@ -2,7 +2,7 @@ #include "ColorItem.h" #include "Colors.h" #include "ColorMenuView.h" -#include "BecassoAddOn.h" // for some defines +#include "BecassoAddOn.h" // for some defines #include #include #include @@ -11,221 +11,219 @@ #include #include "Settings.h" -ColorMenu::ColorMenu (const char *name, BView *_view, int h, int v, float s) -: BMenu (name, h*s, v*s) +ColorMenu::ColorMenu(const char* name, BView* _view, int h, int v, float s) + : BMenu(name, h * s, v * s) { index = 0; for (int i = 0; i < v; i++) - for (int j = 0; j < h; j++) - { - BRect cframe = BRect (j*s, i*s, (j + 1)*s, (i + 1)*s); - AddItem (new ColorItem (system_colors()->color_list[index]), cframe); + for (int j = 0; j < h; j++) { + BRect cframe = BRect(j * s, i * s, (j + 1) * s, (i + 1) * s); + AddItem(new ColorItem(system_colors()->color_list[index]), cframe); } - Mark (0); + Mark(0); view = _view; - hs = h*s; - vs = v*s; + hs = h * s; + vs = v * s; parent = NULL; fWindow = NULL; } -ColorMenu::~ColorMenu () -{ -} +ColorMenu::~ColorMenu() {} -void ColorMenu::setParent (ColorMenuButton *pmb) +void +ColorMenu::setParent(ColorMenuButton* pmb) { parent = pmb; - + // Now is also a good time to put the tear-off window on screen // (if the app last quit that way) - if (!fWindow) - { + if (!fWindow) { BPoint origin; BRect place = Bounds(); - if (!strcmp (Name(), "fg")) - origin = get_window_origin (numFGColorTO); - else if (!strcmp (Name(), "bg")) - origin = get_window_origin (numBGColorTO); - if (origin != InvalidPoint) - { - place.OffsetTo (origin); - TearDone (place, true); + if (!strcmp(Name(), "fg")) + origin = get_window_origin(numFGColorTO); + else if (!strcmp(Name(), "bg")) + origin = get_window_origin(numBGColorTO); + if (origin != InvalidPoint) { + place.OffsetTo(origin); + TearDone(place, true); } } } -void ColorMenu::AddItem (ColorItem *item, BRect frame) +void +ColorMenu::AddItem(ColorItem* item, BRect frame) { if (index < MAX_COLORS - 1) items[index++] = item; else items[index] = item; - inherited::AddItem (item, frame); + inherited::AddItem(item, frame); } -ColorItem *ColorMenu::FindMarked () +ColorItem* +ColorMenu::FindMarked() { return (items[index]); } -class colorTearInfo +class colorTearInfo { -public: - colorTearInfo (BRect r, ColorMenu *p, BView *s) : dragRect (r), parent (p), someView (s) {}; + public: + colorTearInfo(BRect r, ColorMenu* p, BView* s) : dragRect(r), parent(p), someView(s){}; BRect dragRect; - ColorMenu *parent; - BView *someView; + ColorMenu* parent; + BView* someView; }; -int32 color_tear_drag (void *data); +int32 +color_tear_drag(void* data); -int32 color_tear_drag (void *data) +int32 +color_tear_drag(void* data) { - colorTearInfo *tearInfo = (colorTearInfo *) data; + colorTearInfo* tearInfo = (colorTearInfo*)data; uint32 buttons = 1; BPoint point; - ColorMenu *menu = tearInfo->parent; + ColorMenu* menu = tearInfo->parent; BRect place = tearInfo->dragRect; - BView *view = tearInfo->someView; + BView* view = tearInfo->someView; // It might seem a good idea to use `menu' as the view, but // this gave errors: `Method requires owner but doesn't have one'. - delete tearInfo; // The caller doesn't do this (race condition otherwise) + delete tearInfo; // The caller doesn't do this (race condition otherwise) // printf ("Entering loop; view = %p\n", view); - while (buttons) - { + while (buttons) { view->Window()->Lock(); - view->GetMouse (&point, &buttons); + view->GetMouse(&point, &buttons); view->Window()->Unlock(); - snooze (50000); + snooze(50000); } // printf ("Exited loop\n"); view->Window()->Lock(); - point = view->ConvertToScreen (point); + point = view->ConvertToScreen(point); view->Window()->Unlock(); // printf ("Released at (%.0f, %.0f)\n", point.x, point.y); - place.OffsetTo (point); - + place.OffsetTo(point); + menu->getParent()->lock->Lock(); - menu->TearDone (place, !menu->getParent()->MenuWinOnScreen); + menu->TearDone(place, !menu->getParent()->MenuWinOnScreen); menu->getParent()->lock->Unlock(); return B_NO_ERROR; } -void ColorMenu::MouseMoved (BPoint point, uint32 transit, const BMessage *msg) +void +ColorMenu::MouseMoved(BPoint point, uint32 transit, const BMessage* msg) { msg = msg; uint32 buttons; if (!Parent()) return; -// printf ("("); fflush (stdout); - GetMouse (&point, &buttons); -// printf (")"); fflush (stdout); - if (transit == B_EXITED_VIEW && buttons) // Do the tear off thing! + // printf ("("); fflush (stdout); + GetMouse(&point, &buttons); + // printf (")"); fflush (stdout); + if (transit == B_EXITED_VIEW && buttons) // Do the tear off thing! { -#if defined (EASTER_EGG_SFX) +#if defined(EASTER_EGG_SFX) extern bool EasterEgg; - if (modifiers() & B_SHIFT_KEY && EasterEgg) - { - extern EffectsPlayer *easterEgg; + if (modifiers() & B_SHIFT_KEY && EasterEgg) { + extern EffectsPlayer* easterEgg; easterEgg->StartEffect(); } #endif - BMessage *tearmsg = new BMessage ('tear'); - BBitmap *dragmap = new BBitmap (Bounds(), B_RGBA32, true); + BMessage* tearmsg = new BMessage('tear'); + BBitmap* dragmap = new BBitmap(Bounds(), B_RGBA32, true); dragmap->Lock(); - BView *dragview = new BView (Bounds(), "temp dragmap view", B_FOLLOW_ALL, B_WILL_DRAW); - dragmap->AddChild (dragview); - //dragview->SetLowColor (LightGrey); - //dragview->FillRect (Bounds(), B_SOLID_LOW); - for (int i = 0; i < MAX_COLORS; i++) - { - dragview->SetHighColor (items[i]->getColor()); - dragview->FillRect (items[i]->Frame()); + BView* dragview = new BView(Bounds(), "temp dragmap view", B_FOLLOW_ALL, B_WILL_DRAW); + dragmap->AddChild(dragview); + // dragview->SetLowColor (LightGrey); + // dragview->FillRect (Bounds(), B_SOLID_LOW); + for (int i = 0; i < MAX_COLORS; i++) { + dragview->SetHighColor(items[i]->getColor()); + dragview->FillRect(items[i]->Frame()); dragview->Sync(); } - dragview->SetHighColor (DarkGrey); - dragview->StrokeRect (Bounds()); - dragmap->RemoveChild (dragview); - bgra_pixel *bits = (bgra_pixel *) dragmap->Bits(); - for (bgra_pixel p = 0; p < dragmap->BitsLength()/4; p++) - { + dragview->SetHighColor(DarkGrey); + dragview->StrokeRect(Bounds()); + dragmap->RemoveChild(dragview); + bgra_pixel* bits = (bgra_pixel*)dragmap->Bits(); + for (bgra_pixel p = 0; p < dragmap->BitsLength() / 4; p++) { bgra_pixel pixel = *bits; *bits++ = (pixel & COLOR_MASK) | (127 << ALPHA_BPOS); } dragmap->Unlock(); delete dragview; - DragMessage (tearmsg, dragmap, B_OP_ALPHA, B_ORIGIN); + DragMessage(tearmsg, dragmap, B_OP_ALPHA, B_ORIGIN); delete tearmsg; BRect place = Bounds(); - + // Send a fake Esc keydown to the popup char kbuf[2]; - BMessage kmsg (B_KEY_DOWN); - kmsg.AddInt64 ("when", system_time()); - kmsg.AddInt32 ("modifiers", 0); - kmsg.AddInt32 ("key", B_ESCAPE); - kmsg.AddInt8 ("byte", B_ESCAPE); + BMessage kmsg(B_KEY_DOWN); + kmsg.AddInt64("when", system_time()); + kmsg.AddInt32("modifiers", 0); + kmsg.AddInt32("key", B_ESCAPE); + kmsg.AddInt8("byte", B_ESCAPE); kbuf[0] = B_ESCAPE; kbuf[1] = '\0'; - kmsg.AddString ("bytes", kbuf); - Window()->PostMessage (&kmsg, this); + kmsg.AddString("bytes", kbuf); + Window()->PostMessage(&kmsg, this); // This makes the original popup go away. // We can't use Hide() since that crashes. - - colorTearInfo *tearInfo = new colorTearInfo (place, this, parent); - resume_thread (spawn_thread (color_tear_drag, "Menu Tear Thread", B_NORMAL_PRIORITY, tearInfo)); + + colorTearInfo* tearInfo = new colorTearInfo(place, this, parent); + resume_thread(spawn_thread(color_tear_drag, "Menu Tear Thread", B_NORMAL_PRIORITY, tearInfo) + ); } } -void ColorMenu::TearDone (BRect place, bool newwin) +void +ColorMenu::TearDone(BRect place, bool newwin) { // printf ("CM::TearDone\n"); - if (newwin) - { - fWindow = new DragWindow (Name(), place, parent->Name()); + if (newwin) { + fWindow = new DragWindow(Name(), place, parent->Name()); BRect mvRect = Bounds(); // mvRect.OffsetBy (0, PW_TABSIZE + 1); - ColorMenuView *mv = new ColorMenuView (mvRect, "MenuView", parent); - fWindow->AddChild (mv); + ColorMenuView* mv = new ColorMenuView(mvRect, "MenuView", parent); + fWindow->AddChild(mv); fWindow->Show(); - } - else - { - fWindow->MoveTo (place.LeftTop()); + } else { + fWindow->MoveTo(place.LeftTop()); fWindow->Activate(); } } -void ColorMenu::Mark (int _index) +void +ColorMenu::Mark(int _index) { if (_index >= MAX_COLORS) return; - items[index]->SetMarked (false); + items[index]->SetMarked(false); index = _index; - items[index]->SetMarked (true); + items[index]->SetMarked(true); } -BPoint ColorMenu::ScreenLocation () +BPoint +ColorMenu::ScreenLocation() { BScreen screen; - BPoint currentpoint = BPoint (0, 0); + BPoint currentpoint = BPoint(0, 0); view->Window()->Lock(); - view->ConvertToScreen (¤tpoint); + view->ConvertToScreen(¤tpoint); view->Window()->Unlock(); - currentpoint.y = min_c (currentpoint.y, screen.Frame().bottom - vs - 4); - currentpoint.x = min_c (currentpoint.x, screen.Frame().right - hs - 4); + currentpoint.y = min_c(currentpoint.y, screen.Frame().bottom - vs - 4); + currentpoint.x = min_c(currentpoint.x, screen.Frame().right - hs - 4); return (currentpoint); } -void ColorMenu::InvalidateWindow () +void +ColorMenu::InvalidateWindow() { - if (fWindow) - { + if (fWindow) { fWindow->Lock(); fWindow->ChildAt(0)->Invalidate(); fWindow->UpdateIfNeeded(); diff --git a/source/ColorMenu.h b/source/ColorMenu.h index 51a3e1e..b5fc7fa 100644 --- a/source/ColorMenu.h +++ b/source/ColorMenu.h @@ -15,31 +15,36 @@ class ColorMenuButton; class ColorMenu : public BMenu { -friend class ColorMenuButton; -public: - ColorMenu (const char *name, BView *_view, int h, int v, float s); -virtual ~ColorMenu (); -virtual void AddItem (ColorItem *item, BRect frame); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *msg); -ColorItem *FindMarked (); -ColorItem *ItemAt (int ind) { return items[ind]; }; -virtual void Mark (int _index); -void setParent (ColorMenuButton *cmb); -ColorMenuButton *getParent () { return parent; }; -void TearDone (BRect place, bool newwin); -void InvalidateWindow (); - -protected: -virtual BPoint ScreenLocation (); - -private: -typedef BMenu inherited; -DragWindow *fWindow; -ColorMenuButton *parent; -ColorItem *items[MAX_COLORS]; -int index; -BView *view; -float hs, vs; + friend class ColorMenuButton; + + public: + ColorMenu(const char* name, BView* _view, int h, int v, float s); + virtual ~ColorMenu(); + virtual void AddItem(ColorItem* item, BRect frame); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg); + ColorItem* FindMarked(); + + ColorItem* ItemAt(int ind) { return items[ind]; }; + + virtual void Mark(int _index); + void setParent(ColorMenuButton* cmb); + + ColorMenuButton* getParent() { return parent; }; + + void TearDone(BRect place, bool newwin); + void InvalidateWindow(); + + protected: + virtual BPoint ScreenLocation(); + + private: + typedef BMenu inherited; + DragWindow* fWindow; + ColorMenuButton* parent; + ColorItem* items[MAX_COLORS]; + int index; + BView* view; + float hs, vs; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/ColorMenuButton.cpp b/source/ColorMenuButton.cpp index 6f9b534..ef8729f 100644 --- a/source/ColorMenuButton.cpp +++ b/source/ColorMenuButton.cpp @@ -3,7 +3,7 @@ #include "ColorMenuButton.h" #include "ColorMenu.h" #include "Colors.h" -#include "PatternMenuButton.h" // I'm not too happy about this. +#include "PatternMenuButton.h" // I'm not too happy about this. #include "ColorWindow.h" #include "BitmapStuff.h" #include "hsv.h" @@ -17,14 +17,14 @@ #define OPEN_RAD 4 -ColorMenuButton::ColorMenuButton (const char *ident, BRect frame, const char *name) -: BView (frame, name, B_FOLLOW_LEFT, B_WILL_DRAW) +ColorMenuButton::ColorMenuButton(const char* ident, BRect frame, const char* name) + : BView(frame, name, B_FOLLOW_LEFT, B_WILL_DRAW) { - SetViewColor (B_TRANSPARENT_32_BIT); + SetViewColor(B_TRANSPARENT_32_BIT); index = 0; - strcpy (_name, name); - menu = new ColorMenu (ident, this, C_H_NUM, C_V_NUM, C_SIZE); - + strcpy(_name, name); + menu = new ColorMenu(ident, this, C_H_NUM, C_V_NUM, C_SIZE); + rgb_tolerance.red = 10; rgb_tolerance.green = 10; rgb_tolerance.blue = 10; @@ -32,77 +32,75 @@ ColorMenuButton::ColorMenuButton (const char *ident, BRect frame, const char *na tolerance = 18; editorshowing = false; // Note: No way to react to bit depth changes this way yet... - frame.OffsetTo (B_ORIGIN); + frame.OffsetTo(B_ORIGIN); { BScreen screen; - button = new BBitmap (frame, (screen.ColorSpace() == B_COLOR_8_BIT) ? B_COLOR_8_BIT : B_RGBA32); - // This is because we can't store 16 bit bitmaps, and 32 bit bitmaps don't look too bad on 16 bit screens. + button = + new BBitmap(frame, (screen.ColorSpace() == B_COLOR_8_BIT) ? B_COLOR_8_BIT : B_RGBA32); + // This is because we can't store 16 bit bitmaps, and 32 bit bitmaps don't look too bad on + // 16 bit screens. } fW = frame.IntegerWidth(); fH = frame.IntegerWidth(); - alpha = 255; // Note: alpha = opacity! - get_click_speed (&dcspeed); + alpha = 255; // Note: alpha = opacity! + get_click_speed(&dcspeed); click = 1; lock = new BLocker(); MenuWinOnScreen = false; - menu->setParent (this); -// printf ("CMB: ctor done\n"); + menu->setParent(this); + // printf ("CMB: ctor done\n"); } -ColorMenuButton::~ColorMenuButton () +ColorMenuButton::~ColorMenuButton() { delete menu; delete lock; } -void ColorMenuButton::editorSaysBye () +void +ColorMenuButton::editorSaysBye() { editorshowing = false; } -void ColorMenuButton::MouseDown (BPoint point) +void +ColorMenuButton::MouseDown(BPoint point) { Window()->Lock(); - uint32 buttons = Window()->CurrentMessage()->FindInt32 ("buttons"); + uint32 buttons = Window()->CurrentMessage()->FindInt32("buttons"); // uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); - BMenuItem *mselected; - point = BPoint (0, 0); - ConvertToScreen (&point); - if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) - { + BMenuItem* mselected; + point = BPoint(0, 0); + ConvertToScreen(&point); + if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) { BPoint bp, pbp; uint32 bt; - GetMouse (&pbp, &bt, true); + GetMouse(&pbp, &bt, true); bigtime_t start = system_time(); - while (system_time() - start < dcspeed) - { - snooze (20000); - GetMouse (&bp, &bt, true); - if (!bt && click != 2) - { + while (system_time() - start < dcspeed) { + snooze(20000); + GetMouse(&bp, &bt, true); + if (!bt && click != 2) { click = 0; } - if (bt && !click) - { + if (bt && !click) { click = 2; } if (bp != pbp) break; } - if (click != 2) - { - BRect openRect = BRect (point.x - OPEN_RAD, point.y - OPEN_RAD, - point.x + OPEN_RAD, point.y + OPEN_RAD); + if (click != 2) { + BRect openRect = BRect( + point.x - OPEN_RAD, point.y - OPEN_RAD, point.x + OPEN_RAD, point.y + OPEN_RAD + ); menu->Show(); - if ((mselected = menu->Track (true, &openRect)) != NULL) - { - index = menu->IndexOf (mselected); - menu->Mark (index); + if ((mselected = menu->Track(true, &openRect)) != NULL) { + index = menu->IndexOf(mselected); + menu->Mark(index); if (MenuWinOnScreen) menu->InvalidateWindow(); - extern PatternMenuButton *pat; - if (pat && pat->Window()) - { + extern PatternMenuButton* pat; + if (pat && pat->Window()) { pat->Window()->Lock(); pat->Invalidate(); pat->lock->Lock(); @@ -110,38 +108,33 @@ void ColorMenuButton::MouseDown (BPoint point) pat->getMenu()->InvalidateWindow(); pat->lock->Unlock(); pat->Window()->Unlock(); - be_app->PostMessage ('clrX'); + be_app->PostMessage('clrX'); } } menu->Hide(); - if (editorshowing) - { + if (editorshowing) { rgb_color c = color(); - BMessage *msg = new BMessage ('SetC'); - msg->AddInt32 ("color", c.red); - msg->AddInt32 ("color", c.green); - msg->AddInt32 ("color", c.blue); - editor->PostMessage (msg); + BMessage* msg = new BMessage('SetC'); + msg->AddInt32("color", c.red); + msg->AddInt32("color", c.green); + msg->AddInt32("color", c.blue); + editor->PostMessage(msg); delete msg; } click = 1; } } - if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { + if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { click = 1; - if (editorshowing) - { + if (editorshowing) { rgb_color c = color(); - BMessage *msg = new BMessage ('SetC'); - msg->AddInt32 ("color", c.red); - msg->AddInt32 ("color", c.green); - msg->AddInt32 ("color", c.blue); - editor->PostMessage (msg); + BMessage* msg = new BMessage('SetC'); + msg->AddInt32("color", c.red); + msg->AddInt32("color", c.green); + msg->AddInt32("color", c.blue); + editor->PostMessage(msg); delete msg; - } - else - { + } else { ShowEditor(); } } @@ -149,94 +142,95 @@ void ColorMenuButton::MouseDown (BPoint point) Window()->Unlock(); } -void ColorMenuButton::ShowEditor () +void +ColorMenuButton::ShowEditor() { - editor = new ColorWindow (BRect (100, 180, 300, 300), _name, this); + editor = new ColorWindow(BRect(100, 180, 300, 300), _name, this); editorshowing = true; editor->Show(); } -void ColorMenuButton::MouseMoved (BPoint point, uint32 transit, const BMessage *msg) +void +ColorMenuButton::MouseMoved(BPoint point, uint32 transit, const BMessage* msg) { point = point; msg = msg; - if (transit == B_ENTERED_VIEW) - { - BMessage *hlp = new BMessage ('chlp'); - hlp->AddString ("View", _name); - Window()->PostMessage (hlp); + if (transit == B_ENTERED_VIEW) { + BMessage* hlp = new BMessage('chlp'); + hlp->AddString("View", _name); + Window()->PostMessage(hlp); delete hlp; - } - else if (transit == B_EXITED_VIEW) - { - BMessage *hlp = new BMessage ('chlp'); - hlp->AddString ("View", ""); - Window()->PostMessage (hlp); + } else if (transit == B_EXITED_VIEW) { + BMessage* hlp = new BMessage('chlp'); + hlp->AddString("View", ""); + Window()->PostMessage(hlp); delete hlp; } } -void ColorMenuButton::Draw (BRect update) +void +ColorMenuButton::Draw(BRect update) { // printf ("CMB::Draw\n"); - BBitmap *b32 = new BBitmap (button->Bounds(), B_RGBA32, true); - BView *v = new BView (button->Bounds(), "tmp colorbutton view", 0, 0); + BBitmap* b32 = new BBitmap(button->Bounds(), B_RGBA32, true); + BView* v = new BView(button->Bounds(), "tmp colorbutton view", 0, 0); b32->Lock(); - b32->AddChild (v); - v->SetHighColor (color()); + b32->AddChild(v); + v->SetHighColor(color()); update = Bounds(); - v->FillRect (update); - b32->RemoveChild (v); + v->FillRect(update); + b32->RemoveChild(v); delete v; - - switch (button->ColorSpace()) - { - case B_COLOR_8_BIT: - { - FSDither (b32, button, update); - delete b32; - break; - } - default: - { - button->Lock(); - delete button; - button = b32; - break; - } + + switch (button->ColorSpace()) { + case B_COLOR_8_BIT: { + FSDither(b32, button, update); + delete b32; + break; + } + default: { + button->Lock(); + delete button; + button = b32; + break; + } } update.right--; - DrawBitmap (button, B_ORIGIN); - SetHighColor (Grey8); - SetDrawingMode (B_OP_ADD); - StrokeLine (update.LeftBottom(), update.LeftTop()); - StrokeLine (update.RightTop()); - SetDrawingMode (B_OP_SUBTRACT); - StrokeLine (update.RightBottom()); - StrokeLine (update.LeftBottom()); + DrawBitmap(button, B_ORIGIN); + SetHighColor(Grey8); + SetDrawingMode(B_OP_ADD); + StrokeLine(update.LeftBottom(), update.LeftTop()); + StrokeLine(update.RightTop()); + SetDrawingMode(B_OP_SUBTRACT); + StrokeLine(update.RightBottom()); + StrokeLine(update.LeftBottom()); } -bool ColorMenuButton::approx (rgb_color a, rgb_color b) +bool +ColorMenuButton::approx(rgb_color a, rgb_color b) // Note: Doesn't check for alpha. { - return ((abs (int (a.red) - b.red) <= rgb_tolerance.red) - && (abs (int (a.green) - b.green) <= rgb_tolerance.green) - && (abs (int (a.blue) - b.blue) <= rgb_tolerance.blue)); + return ( + (abs(int(a.red) - b.red) <= rgb_tolerance.red) && + (abs(int(a.green) - b.green) <= rgb_tolerance.green) && + (abs(int(a.blue) - b.blue) <= rgb_tolerance.blue) + ); } -float ColorMenuButton::cdiff (rgb_color a) +float +ColorMenuButton::cdiff(rgb_color a) { - return (diff (a, color())); + return (diff(a, color())); } -rgb_color *ColorMenuButton::palette () +rgb_color* +ColorMenuButton::palette() // Note: Caller should free the palette! { - rgb_color *p = new rgb_color [numColors()]; - for (int i = 0; i < numColors(); i++) - { - p[i] = ColorForIndex (i); + rgb_color* p = new rgb_color[numColors()]; + for (int i = 0; i < numColors(); i++) { + p[i] = ColorForIndex(i); } return p; } @@ -247,18 +241,18 @@ rgb_color *ColorMenuButton::palette () #define NEW_WEIGHTS 1 -#if defined (NEW_WEIGHTS) -# define RED_WEIGHT 0.2125 -# define GREEN_WEIGHT 0.7154 -# define BLUE_WEIGHT 0.0721 -#elif defined (USE_WEIGHTS) -# define RED_WEIGHT 0.299 -# define GREEN_WEIGHT 0.587 -# define BLUE_WEIGHT 0.114 +#if defined(NEW_WEIGHTS) +#define RED_WEIGHT 0.2125 +#define GREEN_WEIGHT 0.7154 +#define BLUE_WEIGHT 0.0721 +#elif defined(USE_WEIGHTS) +#define RED_WEIGHT 0.299 +#define GREEN_WEIGHT 0.587 +#define BLUE_WEIGHT 0.114 #else -# define RED_WEIGHT 2 -# define GREEN_WEIGHT 3 -# define BLUE_WEIGHT 1 +#define RED_WEIGHT 2 +#define GREEN_WEIGHT 3 +#define BLUE_WEIGHT 1 #endif typedef struct @@ -270,390 +264,374 @@ typedef struct uint32 num_colors; } CMB_box; -void trim_box (CMB_box *b, uint32 *histogram); -CMB_box *biggest_population (CMB_box *b, int boxindex); -CMB_box *biggest_volume (CMB_box *b, int boxindex); +void +trim_box(CMB_box* b, uint32* histogram); +CMB_box* +biggest_population(CMB_box* b, int boxindex); +CMB_box* +biggest_volume(CMB_box* b, int boxindex); -void trim_box (CMB_box *box, uint32 *histogram) +void +trim_box(CMB_box* box, uint32* histogram) { uint32 r, g, b; if (box->rmax > box->rmin) for (r = box->rmin; r <= box->rmax; r++) for (g = box->gmin; g <= box->gmax; g++) for (b = box->bmin; b <= box->bmax; b++) - if (histogram[r*(CMB_G*CMB_B) + g*CMB_B + b] != 0) - { + if (histogram[r * (CMB_G * CMB_B) + g * CMB_B + b] != 0) { box->rmin = r; goto have_rmin; } - have_rmin: +have_rmin: if (box->rmax > box->rmin) for (r = box->rmax; r >= box->rmin; r--) for (g = box->gmin; g <= box->gmax; g++) for (b = box->bmin; b <= box->bmax; b++) - if (histogram[r*(CMB_G*CMB_B) + g*CMB_B + b] != 0) - { + if (histogram[r * (CMB_G * CMB_B) + g * CMB_B + b] != 0) { box->rmax = r; goto have_rmax; } - have_rmax: +have_rmax: if (box->gmax > box->gmin) for (g = box->gmin; g <= box->gmax; g++) for (r = box->rmin; r <= box->rmax; r++) for (b = box->bmin; b <= box->bmax; b++) - if (histogram[r*(CMB_G*CMB_B) + g*CMB_B + b] != 0) - { + if (histogram[r * (CMB_G * CMB_B) + g * CMB_B + b] != 0) { box->gmin = g; goto have_gmin; } - have_gmin: +have_gmin: if (box->gmax > box->gmin) for (g = box->gmax; g >= box->gmin; g--) for (r = box->rmin; r <= box->rmax; r++) for (b = box->bmin; b <= box->bmax; b++) - if (histogram[r*(CMB_G*CMB_B) + g*CMB_B + b] != 0) - { + if (histogram[r * (CMB_G * CMB_B) + g * CMB_B + b] != 0) { box->gmax = g; goto have_gmax; } - have_gmax: +have_gmax: if (box->bmax > box->bmin) for (b = box->bmin; b <= box->bmax; b++) for (g = box->gmin; g <= box->gmax; g++) for (r = box->rmin; r <= box->rmax; r++) - if (histogram[r*(CMB_G*CMB_B) + g*CMB_B + b] != 0) - { + if (histogram[r * (CMB_G * CMB_B) + g * CMB_B + b] != 0) { box->bmin = b; goto have_bmin; } - have_bmin: +have_bmin: if (box->bmax > box->bmin) for (b = box->bmax; b >= box->bmin; b--) for (g = box->gmin; g <= box->gmax; g++) for (r = box->rmin; r <= box->rmax; r++) - if (histogram[r*(CMB_G*CMB_B) + g*CMB_B + b] != 0) - { + if (histogram[r * (CMB_G * CMB_B) + g * CMB_B + b] != 0) { box->bmax = b; goto have_bmax; } - have_bmax: +have_bmax: // Count colors int32 count = 0; for (b = box->bmin; b <= box->bmax; b++) for (g = box->gmin; g <= box->gmax; g++) for (r = box->rmin; r <= box->rmax; r++) - if (histogram[r*(CMB_G*CMB_B) + g*CMB_B + b] != 0) + if (histogram[r * (CMB_G * CMB_B) + g * CMB_B + b] != 0) count++; - + box->num_colors = count; // Use 2-norm; scaled distances (i.e. green weighs in more) // Note: Maybe the factors should be squared too, but IMHO this puts // too much emphasis on green. - box->volume = (uint32) (RED_WEIGHT*(box->rmax - box->rmin)*(box->rmax - box->rmin) + - GREEN_WEIGHT*(box->gmax - box->gmin)*(box->gmax - box->gmin) + - BLUE_WEIGHT*(box->bmax - box->bmin)*(box->bmax - box->bmin)); + box->volume = (uint32)(RED_WEIGHT * (box->rmax - box->rmin) * (box->rmax - box->rmin) + + GREEN_WEIGHT * (box->gmax - box->gmin) * (box->gmax - box->gmin) + + BLUE_WEIGHT * (box->bmax - box->bmin) * (box->bmax - box->bmin)); } -CMB_box *biggest_population (CMB_box *b, int boxindex) +CMB_box* +biggest_population(CMB_box* b, int boxindex) { int32 maxv = 0; int i; - - CMB_box *thebiggest = NULL; + + CMB_box* thebiggest = NULL; for (i = 0; i < boxindex; i++) - if (b[i].volume > maxv) - { + if (b[i].volume > maxv) { thebiggest = &b[i]; maxv = b[i].volume; } return thebiggest; } -CMB_box *biggest_volume (CMB_box *b, int boxindex) +CMB_box* +biggest_volume(CMB_box* b, int boxindex) { int32 maxv = 0; int i; - - CMB_box *thebiggest = NULL; + + CMB_box* thebiggest = NULL; for (i = 0; i < boxindex; i++) - if (b[i].volume > maxv) - { + if (b[i].volume > maxv) { thebiggest = &b[i]; maxv = b[i].volume; } return thebiggest; } -void ColorMenuButton::extractPalette (Layer *l, int max_col, bool clobber) +void +ColorMenuButton::extractPalette(Layer* l, int max_col, bool clobber) { if (max_col > numColors()) max_col = numColors(); - + // uint32 histogram[CMB_R][CMB_G][CMB_B]; - uint32 *histogram = new uint32 [CMB_R*CMB_G*CMB_B]; - memset (histogram, 0, CMB_R*CMB_G*CMB_B*4); // otherwise strange errors with MALLOC_DEBUG! - - uint32 dtable[C_V_NUM*C_H_NUM]; + uint32* histogram = new uint32[CMB_R * CMB_G * CMB_B]; + memset(histogram, 0, CMB_R * CMB_G * CMB_B * 4); // otherwise strange errors with MALLOC_DEBUG! + + uint32 dtable[C_V_NUM * C_H_NUM]; int cindex = 0; int b16count = 0; bool needtoquantize = false; - bgra_pixel *s = (bgra_pixel *) l->Bits() - 1; + bgra_pixel* s = (bgra_pixel*)l->Bits() - 1; // Iterate over all the pixels - for (uint32 p = (l->Bounds().IntegerWidth() + 1)*(l->Bounds().IntegerHeight() + 1); p > 0; p--) - { + for (uint32 p = (l->Bounds().IntegerWidth() + 1) * (l->Bounds().IntegerHeight() + 1); p > 0; + p--) { bgra_pixel pixel = *(++s); - if (!needtoquantize) // Maybe we can get away with the existing colors... + if (!needtoquantize) // Maybe we can get away with the existing colors... { int j = 0; while (pixel != dtable[j] && j < cindex) j++; - if (j == cindex) // New color + if (j == cindex) // New color { dtable[cindex++] = pixel; if (cindex >= max_col) - needtoquantize = true; // Too many colors. + needtoquantize = true; // Too many colors. } } - + uint8 r, g, b; - r = ((RED(pixel)) >> 3) & 0x1F; + r = ((RED(pixel)) >> 3) & 0x1F; g = ((GREEN(pixel)) >> 2) & 0x3F; - b = ((BLUE(pixel)) >> 3) & 0x1F; - if (!histogram[r*(CMB_G*CMB_B) + g*CMB_B + b]) + b = ((BLUE(pixel)) >> 3) & 0x1F; + if (!histogram[r * (CMB_G * CMB_B) + g * CMB_B + b]) b16count++; - histogram[r*(CMB_G*CMB_B) + g*CMB_B + b]++; + histogram[r * (CMB_G * CMB_B) + g * CMB_B + b]++; } extern int DebugLevel; if (DebugLevel) - fprintf (stderr, "Found at least %d colors\n", cindex); + fprintf(stderr, "Found at least %d colors\n", cindex); - if (needtoquantize && b16count <= max_col) - { + if (needtoquantize && b16count <= max_col) { // Special case: There are too many colors, but during // quantization to 16bit there were too few again. // This can happen in images with very subtle color differences // (e.g. with shallow gradients). if (DebugLevel) - fprintf (stderr, "Shallow palette: %d entries\n", b16count); - + fprintf(stderr, "Shallow palette: %d entries\n", b16count); + // What we'll do is replace b16count colors of the original palette, // and leave the rest in place. uint8 r, g, b; for (g = 0; g < CMB_G; g++) for (r = 0; r < CMB_R; r++) for (b = 0; b < CMB_B; b++) - if (histogram[r*(CMB_G*CMB_B) + g*CMB_B + b] && b16count) - dtable[--b16count] = PIXEL ((r << 3), (g << 2), (b << 4), 255); - + if (histogram[r * (CMB_G * CMB_B) + g * CMB_B + b] && b16count) + dtable[--b16count] = PIXEL((r << 3), (g << 2), (b << 4), 255); + needtoquantize = false; } - - if (needtoquantize) - { + + if (needtoquantize) { if (DebugLevel) - fprintf (stderr, "Quantizing: %d unique 16 bit colors\n", b16count); - CMB_box *boxes = new CMB_box[max_col]; + fprintf(stderr, "Quantizing: %d unique 16 bit colors\n", b16count); + CMB_box* boxes = new CMB_box[max_col]; int32 boxindex = 1; - + // Set up the first box boxes[0].rmin = boxes[0].gmin = boxes[0].bmin = 0; boxes[0].rmax = CMB_R - 1; boxes[0].gmax = CMB_G - 1; boxes[0].bmax = CMB_B - 1; - trim_box (&boxes[0], histogram); - - for (int j = 1; j < max_col; j++) - { + trim_box(&boxes[0], histogram); + + for (int j = 1; j < max_col; j++) { // Find the largest box and split it - CMB_box *biggest; - if (j*2 <= max_col) - biggest = biggest_population (boxes, boxindex); + CMB_box* biggest; + if (j * 2 <= max_col) + biggest = biggest_population(boxes, boxindex); else - biggest = biggest_volume (boxes, boxindex); - + biggest = biggest_volume(boxes, boxindex); + if (!biggest) - break; // No more splittable boxes left... - // (This shouldn't happen, because we test for #colors <= max_col first) - + break; // No more splittable boxes left... + // (This shouldn't happen, because we test for #colors <= max_col first) + if (DebugLevel > 2) - printf ("Biggest: %ld colors R[%d - %d] G[%d - %d] B[%d - %d]\n", - biggest->num_colors, - biggest->rmin, biggest->rmax, - biggest->gmin, biggest->gmax, - biggest->bmin, biggest->bmax); + printf( + "Biggest: %ld colors R[%d - %d] G[%d - %d] B[%d - %d]\n", biggest->num_colors, + biggest->rmin, biggest->rmax, biggest->gmin, biggest->gmax, biggest->bmin, + biggest->bmax + ); - CMB_box *n = &boxes[boxindex++]; + CMB_box* n = &boxes[boxindex++]; n->rmin = biggest->rmin; n->rmax = biggest->rmax; n->gmin = biggest->gmin; n->gmax = biggest->gmax; n->bmin = biggest->bmin; n->bmax = biggest->bmax; - + // Decide how to split the box int rd = n->rmax - n->rmin; int gd = n->gmax - n->gmin; int bd = n->bmax - n->bmin; - float sr = rd*RED_WEIGHT; - float sg = gd*GREEN_WEIGHT; - float sb = gd*BLUE_WEIGHT; - - if (sr > sg) - { - if (sr > sb) // red wins + float sr = rd * RED_WEIGHT; + float sg = gd * GREEN_WEIGHT; + float sb = gd * BLUE_WEIGHT; + + if (sr > sg) { + if (sr > sb) // red wins { if (DebugLevel > 2) - printf ("Split on red\n"); - n->rmin = n->rmax - rd/2; + printf("Split on red\n"); + n->rmin = n->rmax - rd / 2; biggest->rmax = n->rmin - 1; - } - else // blue wins + } else // blue wins { if (DebugLevel > 2) - printf ("Split on blue\n"); - n->bmin = n->bmax - bd/2; + printf("Split on blue\n"); + n->bmin = n->bmax - bd / 2; biggest->bmax = n->bmin - 1; } - } - else - { - if (sg > sb) // green wins + } else { + if (sg > sb) // green wins { if (DebugLevel > 2) - printf ("Split on green\n"); - n->gmin = n->gmax - gd/2; + printf("Split on green\n"); + n->gmin = n->gmax - gd / 2; biggest->gmax = n->gmin - 1; - } - else // blue wins + } else // blue wins { if (DebugLevel > 2) - printf ("Split on blue\n"); - n->bmin = n->bmax - bd/2; + printf("Split on blue\n"); + n->bmin = n->bmax - bd / 2; biggest->bmax = n->bmin - 1; } } - trim_box (n, histogram); - trim_box (biggest, histogram); + trim_box(n, histogram); + trim_box(biggest, histogram); if (DebugLevel > 2) - printf (" After split: %ld colors R[%d - %d] G[%d - %d] B[%d - %d]\n", - biggest->num_colors, - biggest->rmin, biggest->rmax, - biggest->gmin, biggest->gmax, - biggest->bmin, biggest->bmax); + printf( + " After split: %ld colors R[%d - %d] G[%d - %d] B[%d - %d]\n", + biggest->num_colors, biggest->rmin, biggest->rmax, biggest->gmin, biggest->gmax, + biggest->bmin, biggest->bmax + ); if (DebugLevel > 2) - printf (" And: %ld colors R[%d - %d] G[%d - %d] B[%d - %d]\n", - n->num_colors, - n->rmin, n->rmax, - n->gmin, n->gmax, - n->bmin, n->bmax); + printf( + " And: %ld colors R[%d - %d] G[%d - %d] B[%d - %d]\n", n->num_colors, + n->rmin, n->rmax, n->gmin, n->gmax, n->bmin, n->bmax + ); } - + if (DebugLevel) - fprintf (stderr, "Found %ld boxes. Calculating averages...\n", boxindex); - + fprintf(stderr, "Found %ld boxes. Calculating averages...\n", boxindex); + // Next, iterate over all the boxes and fill the color table with // reasonable averages for the box colors. - for (int j = 0; j < max_col; j++) - { + for (int j = 0; j < max_col; j++) { if (DebugLevel > 2) - printf ("Box %i: %ld colors R[%d - %d] G[%d - %d] B[%d - %d]\n", - j, boxes[j].num_colors, - boxes[j].rmin, boxes[j].rmax, - boxes[j].gmin, boxes[j].gmax, - boxes[j].bmin, boxes[j].bmax); + printf( + "Box %i: %ld colors R[%d - %d] G[%d - %d] B[%d - %d]\n", j, boxes[j].num_colors, + boxes[j].rmin, boxes[j].rmax, boxes[j].gmin, boxes[j].gmax, boxes[j].bmin, + boxes[j].bmax + ); uint32 fr, fg, fb; fr = fg = fb = 0; uint32 tot = 0; uint8 r, g, b; for (r = boxes[j].rmin; r <= boxes[j].rmax; r++) for (b = boxes[j].bmin; b <= boxes[j].bmax; b++) - for (g = boxes[j].gmin; g <= boxes[j].gmax; g++) - { - uint32 w = histogram[r*(CMB_G*CMB_B) + g*CMB_B + b]; + for (g = boxes[j].gmin; g <= boxes[j].gmax; g++) { + uint32 w = histogram[r * (CMB_G * CMB_B) + g * CMB_B + b]; tot += w; - fr += w*(r << 3); - fg += w*(g << 2); - fb += w*(b << 3); + fr += w * (r << 3); + fg += w * (g << 2); + fb += w * (b << 3); } r = g = b = 0; - if (tot != 0) // This shouldn't fail, actually. + if (tot != 0) // This shouldn't fail, actually. { - r = fr/tot; - g = fg/tot; - b = fb/tot; + r = fr / tot; + g = fg / tot; + b = fb / tot; } - - dtable[j] = PIXEL (r, g, b, 255); + + dtable[j] = PIXEL(r, g, b, 255); } - + if (DebugLevel) - fprintf (stderr, "Done calculating averages.\n"); - delete [] boxes; + fprintf(stderr, "Done calculating averages.\n"); + delete[] boxes; } - delete [] histogram; - - for (int i = 0; i < cindex; i++) - { - menu->ItemAt(i)->setColor (bgra2rgb (dtable[i])); + delete[] histogram; + + for (int i = 0; i < cindex; i++) { + menu->ItemAt(i)->setColor(bgra2rgb(dtable[i])); } - if (clobber) - { - for (int i = cindex; i < numColors(); i++) - { - menu->ItemAt(i)->setColor (menu->ItemAt(cindex - 1)->getColor()); + if (clobber) { + for (int i = cindex; i < numColors(); i++) { + menu->ItemAt(i)->setColor(menu->ItemAt(cindex - 1)->getColor()); } } Window()->Lock(); Invalidate(); - extern PatternMenuButton *pat; + extern PatternMenuButton* pat; pat->Invalidate(); Window()->Unlock(); if (MenuWinOnScreen) menu->InvalidateWindow(); } -int ColorMenuButton::getIndexOfClosest (rgb_color c) +int +ColorMenuButton::getIndexOfClosest(rgb_color c) { - float minc = 255; // Worst case... + float minc = 255; // Worst case... float cd; int i = 0; int ind = 0; - while (i < MAX_COLORS - 1) - { - if ((cd = diff (c, menu->ItemAt(i)->getColor())) < minc) - { - minc = cd; - ind = i; + while (i < MAX_COLORS - 1) { + if ((cd = diff(c, menu->ItemAt(i)->getColor())) < minc) { + minc = cd; + ind = i; } i++; } return (ind); } -rgb_color ColorMenuButton::getClosest (rgb_color c) +rgb_color +ColorMenuButton::getClosest(rgb_color c) { - return (menu->ItemAt(getIndexOfClosest (c))->getColor()); + return (menu->ItemAt(getIndexOfClosest(c))->getColor()); } -void ColorMenuButton::set (int _index, bool via_win) +void +ColorMenuButton::set(int _index, bool via_win) { index = _index; - menu->Mark (index); - if (Window()) - { + menu->Mark(index); + if (Window()) { Window()->Lock(); Invalidate(); Window()->Unlock(); } if (MenuWinOnScreen && !via_win) menu->InvalidateWindow(); - - extern PatternMenuButton *pat; - if (pat && pat->Window()) - { + + extern PatternMenuButton* pat; + if (pat && pat->Window()) { pat->Window()->Lock(); pat->Invalidate(); pat->lock->Lock(); @@ -662,21 +640,21 @@ void ColorMenuButton::set (int _index, bool via_win) pat->lock->Unlock(); pat->Window()->Unlock(); } - if (editorshowing) - { + if (editorshowing) { rgb_color c = color(); - BMessage *msg = new BMessage ('SetC'); - msg->AddInt32 ("color", c.red); - msg->AddInt32 ("color", c.green); - msg->AddInt32 ("color", c.blue); - msg->AddInt32 ("alpha", c.alpha); - editor->PostMessage (msg); + BMessage* msg = new BMessage('SetC'); + msg->AddInt32("color", c.red); + msg->AddInt32("color", c.green); + msg->AddInt32("color", c.blue); + msg->AddInt32("alpha", c.alpha); + editor->PostMessage(msg); delete msg; } - be_app->PostMessage ('clrX'); + be_app->PostMessage('clrX'); } -bool ColorMenuButton::set (rgb_color c, bool anyway) +bool +ColorMenuButton::set(rgb_color c, bool anyway) // Returns true if no match was found within the tolerance. // If anyway == true (false by default), the best match is set to c, // regardless of the tolerance. @@ -684,19 +662,17 @@ bool ColorMenuButton::set (rgb_color c, bool anyway) rgb_color now = color(); if (c.red == now.red && c.green == now.green && c.blue == now.blue && c.alpha == alpha) return true; - + alpha = c.alpha; bool ret = false; float minc = 255; float cd; int i = 0; int ind = 0; - while (i < MAX_COLORS - 1) - { - if ((cd = diff (c, menu->ItemAt(i)->getColor())) < minc) - { - minc = cd; - ind = i; + while (i < MAX_COLORS - 1) { + if ((cd = diff(c, menu->ItemAt(i)->getColor())) < minc) { + minc = cd; + ind = i; } i++; } @@ -704,14 +680,13 @@ bool ColorMenuButton::set (rgb_color c, bool anyway) ret = true; if (!anyway) ind = selected(); - menu->ItemAt(ind)->setColor (c); - menu->Mark (ind); + menu->ItemAt(ind)->setColor(c); + menu->Mark(ind); Window()->Lock(); Invalidate(); Window()->Unlock(); - extern PatternMenuButton *pat; - if (pat && pat->Window()) - { + extern PatternMenuButton* pat; + if (pat && pat->Window()) { pat->Window()->Lock(); pat->Invalidate(); pat->lock->Lock(); @@ -722,229 +697,219 @@ bool ColorMenuButton::set (rgb_color c, bool anyway) } if (MenuWinOnScreen) menu->InvalidateWindow(); - if (editorshowing) - { - BMessage *msg = new BMessage ('SetC'); - msg->AddInt32 ("color", c.red); - msg->AddInt32 ("color", c.green); - msg->AddInt32 ("color", c.blue); - msg->AddInt32 ("alpha", c.alpha); - editor->PostMessage (msg); + if (editorshowing) { + BMessage* msg = new BMessage('SetC'); + msg->AddInt32("color", c.red); + msg->AddInt32("color", c.green); + msg->AddInt32("color", c.blue); + msg->AddInt32("alpha", c.alpha); + editor->PostMessage(msg); delete msg; } - be_app->PostMessage ('clrX'); + be_app->PostMessage('clrX'); return (ret); } -void ColorMenuButton::setTolerance (rgb_color _t) +void +ColorMenuButton::setTolerance(rgb_color _t) { rgb_tolerance = _t; } -void ColorMenuButton::setTolerance (float _t) +void +ColorMenuButton::setTolerance(float _t) { tolerance = _t; } -void ColorMenuButton::setAlpha (uchar a) +void +ColorMenuButton::setAlpha(uchar a) { - alpha = a; // Note: The Color Editor gives us opacity (of course!) + alpha = a; // Note: The Color Editor gives us opacity (of course!) } -float ColorMenuButton::getTolerance () +float +ColorMenuButton::getTolerance() { return tolerance; } -int32 ColorMenuButton::selected () +int32 +ColorMenuButton::selected() { return (index); } -rgb_color ColorMenuButton::color () +rgb_color +ColorMenuButton::color() { rgb_color c = menu->FindMarked()->getColor(); c.alpha = alpha; return (c); } -rgb_color ColorMenuButton::ColorForIndex (int ind) +rgb_color +ColorMenuButton::ColorForIndex(int ind) { rgb_color c = menu->ItemAt(ind)->getColor(); c.alpha = alpha; return (c); } -void ColorMenuButton::Save (BEntry entry) +void +ColorMenuButton::Save(BEntry entry) { - FILE *fp; + FILE* fp; char line[81]; - BFile file = BFile (&entry, B_CREATE_FILE | B_READ_WRITE | B_ERASE_FILE); + BFile file = BFile(&entry, B_CREATE_FILE | B_READ_WRITE | B_ERASE_FILE); BPath path; - entry.GetPath (&path); - BNode node = BNode (&entry); - node.WriteAttr ("BEOS:TYPE", B_STRING_TYPE, 0, "application/x-sum-becasso.palette\0", 34); - fp = fopen (path.Path(), "w"); - fputs ("# Becasso Palette file\n", fp); - fputs ("# R G B triplets, separated by whitespace, ranging from 0 - 255.\n", fp); - fputs ("# Lines starting with # are comments.\n", fp); - for (int i = 0; i < C_V_NUM*C_H_NUM; i++) - { + entry.GetPath(&path); + BNode node = BNode(&entry); + node.WriteAttr("BEOS:TYPE", B_STRING_TYPE, 0, "application/x-sum-becasso.palette\0", 34); + fp = fopen(path.Path(), "w"); + fputs("# Becasso Palette file\n", fp); + fputs("# R G B triplets, separated by whitespace, ranging from 0 - 255.\n", fp); + fputs("# Lines starting with # are comments.\n", fp); + BString redS, greenS, blueS, lineS; + for (int i = 0; i < C_V_NUM * C_H_NUM; i++) { rgb_color c = menu->ItemAt(i)->getColor(); - sprintf (line, "%i %i %i\n", int (c.red), int (c.green), int (c.blue)); - fputs (line, fp); + fNumberFormat.Format(redS, int(c.red)); + fNumberFormat.Format(greenS, int(c.green)); + fNumberFormat.Format(blueS, int(c.blue)); + lineS.SetToFormat("%s %s %s\n", redS.String(), greenS.String(), blueS.String()); + fputs(lineS.String(), fp); } - fclose (fp); + fclose(fp); } -void ColorMenuButton::Load (BEntry entry) +void +ColorMenuButton::Load(BEntry entry) { - FILE *fp; + FILE* fp; char line[81]; - BFile file = BFile (&entry, B_READ_ONLY); + BFile file = BFile(&entry, B_READ_ONLY); BPath path; - entry.GetPath (&path); - fp = fopen (path.Path(), "r"); - for (int i = 0; i < C_V_NUM*C_H_NUM; i++) - { + entry.GetPath(&path); + fp = fopen(path.Path(), "r"); + for (int i = 0; i < C_V_NUM * C_H_NUM; i++) { rgb_color c; - if (fgets (line, 80, fp)) - { - if (line[0] != '#') // Comment line + if (fgets(line, 80, fp)) { + if (line[0] != '#') // Comment line { - char *endp = line; - c.red = clipchar (int (strtol (endp, &endp, 0))); - c.green = clipchar (int (strtol (endp, &endp, 0))); - c.blue = clipchar (int (strtol (endp, &endp, 0))); + char* endp = line; + c.red = clipchar(int(strtol(endp, &endp, 0))); + c.green = clipchar(int(strtol(endp, &endp, 0))); + c.blue = clipchar(int(strtol(endp, &endp, 0))); c.alpha = 255; - menu->ItemAt(i)->setColor (c); - } - else + menu->ItemAt(i)->setColor(c); + } else i--; - } - else - { + } else { c.red = 0; c.green = 0; c.blue = 0; c.alpha = 255; - menu->ItemAt(i)->setColor (c); + menu->ItemAt(i)->setColor(c); } } - fclose (fp); + fclose(fp); Window()->Lock(); Invalidate(); - extern PatternMenuButton *pat; + extern PatternMenuButton* pat; pat->Invalidate(); Window()->Unlock(); if (MenuWinOnScreen) menu->InvalidateWindow(); } -void ColorMenuButton::Generate (ulong w) -{ - if (w == 'PGdf') - { +void +ColorMenuButton::Generate(ulong w) +{ + if (w == 'PGdf') { for (int i = 0; i < 256; i++) - menu->ItemAt(i)->setColor (system_colors()->color_list[i]); - } - else if (w == 'PGht') - { + menu->ItemAt(i)->setColor(system_colors()->color_list[i]); + } else if (w == 'PGht') { rgb_color c; - for (int i = 0; i <= 43; i++) - { + for (int i = 0; i <= 43; i++) { c.red = 0; c.green = 0; - c.blue = 255*i/43; - menu->ItemAt(i)->setColor (c); + c.blue = 255 * i / 43; + menu->ItemAt(i)->setColor(c); - c.green = 255*i/51; + c.green = 255 * i / 51; c.blue = 255; - menu->ItemAt(i + 42)->setColor (c); + menu->ItemAt(i + 42)->setColor(c); c.red = 0; c.green = 255; - c.blue = 255 - 255*i/43; - menu->ItemAt(i + 85)->setColor (c); - - c.red = 255*i/43; + c.blue = 255 - 255 * i / 43; + menu->ItemAt(i + 85)->setColor(c); + + c.red = 255 * i / 43; c.green = 255; c.blue = 0; - menu->ItemAt(i + 128)->setColor (c); - + menu->ItemAt(i + 128)->setColor(c); + c.red = 255; - c.green = 255 - 255*i/43; + c.green = 255 - 255 * i / 43; c.blue = 0; - menu->ItemAt(i + 170)->setColor (c); - - c.green = 255*i/43; - c.blue = 255*i/43; - menu->ItemAt(i + 212)->setColor (c); + menu->ItemAt(i + 170)->setColor(c); + + c.green = 255 * i / 43; + c.blue = 255 * i / 43; + menu->ItemAt(i + 212)->setColor(c); } - } - else if (w == 'PGsp') - { - for (int i = 0; i < 256; i++) - { + } else if (w == 'PGsp') { + for (int i = 0; i < 256; i++) { hsv_color h; - h.hue = 315*(255 - i)/255; + h.hue = 315 * (255 - i) / 255; h.saturation = 1.0; h.value = 1.0; - menu->ItemAt(i)->setColor (hsv2rgb (h)); + menu->ItemAt(i)->setColor(hsv2rgb(h)); } - } - else - { - for (int i = 0; i < 256; i++) - { + } else { + for (int i = 0; i < 256; i++) { rgb_color c; c.red = (w == 'PGG' || w == 'PGr' || w == 'PGrg' || w == 'PGrb') ? i : 0; c.green = (w == 'PGG' || w == 'PGg' || w == 'PGrg' || w == 'PGgb') ? i : 0; c.blue = (w == 'PGG' || w == 'PGb' || w == 'PGrb' || w == 'PGgb') ? i : 0; - menu->ItemAt(i)->setColor (c); + menu->ItemAt(i)->setColor(c); } } Window()->Lock(); Invalidate(); - extern PatternMenuButton *pat; + extern PatternMenuButton* pat; pat->Invalidate(); Window()->Unlock(); if (MenuWinOnScreen) menu->InvalidateWindow(); } -void ColorMenuButton::MessageReceived (BMessage *msg) +void +ColorMenuButton::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_PASTE: - { - if (msg->WasDropped()) - { - rgb_color *dropped; + switch (msg->what) { + case B_PASTE: { + if (msg->WasDropped()) { + rgb_color* dropped; long dummy; - msg->FindData ("RGBColor", B_RGB_COLOR_TYPE, (const void **) &dropped, &dummy); - set (*dropped, false); - } - else - fprintf (stderr, "ColorMenuButton just received a non-dropped B_PASTE?!\n"); + msg->FindData("RGBColor", B_RGB_COLOR_TYPE, (const void**)&dropped, &dummy); + set(*dropped, false); + } else + fprintf(stderr, "ColorMenuButton just received a non-dropped B_PASTE?!\n"); break; } - case B_SIMPLE_DATA: - { + case B_SIMPLE_DATA: { entry_ref ref; - if (msg->FindRef ("refs", &ref) == B_NO_ERROR) - { - BNode node = BNode (&ref); + if (msg->FindRef("refs", &ref) == B_NO_ERROR) { + BNode node = BNode(&ref); ssize_t s; char buffer[1024]; - if ((s = node.ReadAttr ("BEOS:TYPE", B_STRING_TYPE, 0, buffer, 1022)) > 0) - { + if ((s = node.ReadAttr("BEOS:TYPE", B_STRING_TYPE, 0, buffer, 1022)) > 0) { buffer[s] = 0; - if (!strcmp (buffer, "application/x-sum-becasso.palette")) - { - BEntry entry = BEntry (&ref); - Load (entry); + if (!strcmp(buffer, "application/x-sum-becasso.palette")) { + BEntry entry = BEntry(&ref); + Load(entry); break; } } @@ -952,7 +917,7 @@ void ColorMenuButton::MessageReceived (BMessage *msg) // Note: Fall through to default! } default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } -} \ No newline at end of file +} diff --git a/source/ColorMenuButton.h b/source/ColorMenuButton.h index 675e401..eff284c 100644 --- a/source/ColorMenuButton.h +++ b/source/ColorMenuButton.h @@ -6,65 +6,73 @@ #include #include #include +#include #include "ColorMenu.h" #include "Layer.h" -//#include "ColorWindow.h" +// #include "ColorWindow.h" #include "HelpView.h" #define C_V_NUM 8 #define C_H_NUM 32 -#define C_SIZE 12 +#define C_SIZE 12 class ColorMenuButton : public BView { -public: - ColorMenuButton (const char *ident, BRect frame, const char *name); -virtual ~ColorMenuButton (); -virtual void MouseDown (BPoint point); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *msg); -virtual void MessageReceived (BMessage *msg); -virtual void Draw (BRect update); -int32 selected (); -void editorSaysBye (); -bool approx (rgb_color a, rgb_color b); -float cdiff (rgb_color a); -void set (int _index, bool via_win = false); -bool set (rgb_color c, bool anyway = false); -void setTolerance (rgb_color _t); -void setTolerance (float _t); -void setAlpha (uchar a); -float getTolerance (); -int getIndexOfClosest (rgb_color c); -void extractPalette (Layer *l, int max_col = C_V_NUM*C_H_NUM, bool clobber = true); -rgb_color getClosest (rgb_color c); -rgb_color color (); -rgb_color ColorForIndex (int ind); -void Save (BEntry entry); -void Load (BEntry entry); -void Generate (ulong w); -int numColors () { return (C_V_NUM*C_H_NUM); }; -rgb_color *palette (); -ColorMenu *getMenu () { return (menu); }; -bool IsEditorShowing () { return (editorshowing); }; -class ColorWindow *Editor () { return (editor); }; -void ShowEditor (); -BLocker *lock; -bool MenuWinOnScreen; + public: + ColorMenuButton(const char* ident, BRect frame, const char* name); + virtual ~ColorMenuButton(); + virtual void MouseDown(BPoint point); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg); + virtual void MessageReceived(BMessage* msg); + virtual void Draw(BRect update); + int32 selected(); + void editorSaysBye(); + bool approx(rgb_color a, rgb_color b); + float cdiff(rgb_color a); + void set(int _index, bool via_win = false); + bool set(rgb_color c, bool anyway = false); + void setTolerance(rgb_color _t); + void setTolerance(float _t); + void setAlpha(uchar a); + float getTolerance(); + int getIndexOfClosest(rgb_color c); + void extractPalette(Layer* l, int max_col = C_V_NUM * C_H_NUM, bool clobber = true); + rgb_color getClosest(rgb_color c); + rgb_color color(); + rgb_color ColorForIndex(int ind); + void Save(BEntry entry); + void Load(BEntry entry); + void Generate(ulong w); -private: -typedef BView inherited; -class ColorWindow *editor; -char _name[MAX_HLPNAME]; -BBitmap *button; -ulong fW, fH; -ColorMenu *menu; -int index; -rgb_color rgb_tolerance; -uchar alpha; -float tolerance; -bool editorshowing; -int click; -bigtime_t dcspeed; + int numColors() { return (C_V_NUM * C_H_NUM); }; + + rgb_color* palette(); + + ColorMenu* getMenu() { return (menu); }; + + bool IsEditorShowing() { return (editorshowing); }; + + class ColorWindow* Editor() { return (editor); }; + + void ShowEditor(); + BLocker* lock; + bool MenuWinOnScreen; + + private: + typedef BView inherited; + class ColorWindow* editor; + char _name[MAX_HLPNAME]; + BBitmap* button; + ulong fW, fH; + ColorMenu* menu; + int index; + rgb_color rgb_tolerance; + uchar alpha; + float tolerance; + bool editorshowing; + int click; + bigtime_t dcspeed; + BNumberFormat fNumberFormat; }; -#endif \ No newline at end of file +#endif diff --git a/source/ColorMenuView.cpp b/source/ColorMenuView.cpp index 6ea17f6..1745902 100644 --- a/source/ColorMenuView.cpp +++ b/source/ColorMenuView.cpp @@ -3,112 +3,100 @@ #include "ColorMenu.h" #include "ColorWindow.h" -ColorMenuView::ColorMenuView (BRect frame, const char *name, ColorMenuButton *cmb) -: BView (frame, name, B_FOLLOW_ALL, B_WILL_DRAW) +ColorMenuView::ColorMenuView(BRect frame, const char* name, ColorMenuButton* cmb) + : BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW) { - SetViewColor (B_TRANSPARENT_32_BIT); + SetViewColor(B_TRANSPARENT_32_BIT); fCMB = cmb; cmb->lock->Lock(); cmb->MenuWinOnScreen = true; cmb->lock->Unlock(); - SetViewColor (LightGrey); + SetViewColor(LightGrey); index = -1; - get_click_speed (&dcspeed); + get_click_speed(&dcspeed); click = 1; } -ColorMenuView::~ColorMenuView () +ColorMenuView::~ColorMenuView() { fCMB->lock->Lock(); fCMB->MenuWinOnScreen = false; fCMB->lock->Unlock(); } -void ColorMenuView::Draw (BRect /*updateRect*/) +void +ColorMenuView::Draw(BRect /*updateRect*/) { - if (fCMB) - { - ColorMenu *pm = fCMB->getMenu(); + if (fCMB) { + ColorMenu* pm = fCMB->getMenu(); int numitems = pm->CountItems(); - //printf ("numitems = %i, index = %i\n", numitems, index); - for (int i = 0; i < numitems; i++) - { - ColorItem *pmi = pm->ItemAt(i); - SetHighColor (pmi->getColor()); + // printf ("numitems = %i, index = %i\n", numitems, index); + for (int i = 0; i < numitems; i++) { + ColorItem* pmi = pm->ItemAt(i); + SetHighColor(pmi->getColor()); BRect frame = pmi->Frame(); frame.right -= 1; frame.bottom -= 1; - FillRect (frame); - if (pmi->IsMarked() || index == i) - { - SetHighColor (White); - StrokeRect (frame); - frame.InsetBy (1, 1); - SetHighColor (Black); - StrokeRect (frame); + FillRect(frame); + if (pmi->IsMarked() || index == i) { + SetHighColor(White); + StrokeRect(frame); + frame.InsetBy(1, 1); + SetHighColor(Black); + StrokeRect(frame); } Sync(); } - } - else - { + } else { } } -void ColorMenuView::MouseDown (BPoint point) +void +ColorMenuView::MouseDown(BPoint point) { Window()->Lock(); - uint32 buttons = Window()->CurrentMessage()->FindInt32 ("buttons"); -// uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); - if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) - { + uint32 buttons = Window()->CurrentMessage()->FindInt32("buttons"); + // uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); + if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) { int previndex = fCMB->selected(); - index = int (point.y/C_SIZE)*C_H_NUM + int (point.x/C_SIZE); - fCMB->set (index, true); - Invalidate (RectForIndex (previndex)); + index = int(point.y / C_SIZE) * C_H_NUM + int(point.x / C_SIZE); + fCMB->set(index, true); + Invalidate(RectForIndex(previndex)); BPoint bp, pbp; uint32 bt; - GetMouse (&pbp, &bt, true); + GetMouse(&pbp, &bt, true); bigtime_t start = system_time(); - while (system_time() - start < dcspeed) - { - snooze (20000); - GetMouse (&bp, &bt, true); - if (!bt && click != 2) - { + while (system_time() - start < dcspeed) { + snooze(20000); + GetMouse(&bp, &bt, true); + if (!bt && click != 2) { click = 0; } - if (bt && !click) - { + if (bt && !click) { click = 2; } if (bp != pbp) break; } - if (click != 2) - { + if (click != 2) { click = 1; } } - if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { - index = int (point.y/C_SIZE)*C_H_NUM + int (point.x/C_SIZE); - fCMB->set (index); -// ColorMenu *menu = fCMB->getMenu(); + if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { + index = int(point.y / C_SIZE) * C_H_NUM + int(point.x / C_SIZE); + fCMB->set(index); + // ColorMenu *menu = fCMB->getMenu(); click = 1; - if (fCMB->IsEditorShowing()) - { - rgb_color c = fCMB->ColorForIndex (index); - BMessage *msg = new BMessage ('SetC'); - msg->AddInt32 ("color", c.red); - msg->AddInt32 ("color", c.green); - msg->AddInt32 ("color", c.blue); - fCMB->Editor()->PostMessage (msg); + if (fCMB->IsEditorShowing()) { + rgb_color c = fCMB->ColorForIndex(index); + BMessage* msg = new BMessage('SetC'); + msg->AddInt32("color", c.red); + msg->AddInt32("color", c.green); + msg->AddInt32("color", c.blue); + fCMB->Editor()->PostMessage(msg); delete msg; - } - else - { + } else { fCMB->ShowEditor(); Invalidate(); } @@ -116,29 +104,27 @@ void ColorMenuView::MouseDown (BPoint point) Window()->Unlock(); } -BRect ColorMenuView::RectForIndex (int ind) +BRect +ColorMenuView::RectForIndex(int ind) { - BRect rect = BRect (0, 0, C_SIZE - 1, C_SIZE - 1); - rect.OffsetBy (int (ind % C_H_NUM)*C_SIZE, int (ind/C_H_NUM)*C_SIZE); + BRect rect = BRect(0, 0, C_SIZE - 1, C_SIZE - 1); + rect.OffsetBy(int(ind % C_H_NUM) * C_SIZE, int(ind / C_H_NUM) * C_SIZE); return (rect); } -void ColorMenuView::MouseMoved (BPoint point, uint32 transit, const BMessage * /* msg */) +void +ColorMenuView::MouseMoved(BPoint point, uint32 transit, const BMessage* /* msg */) { int previndex = index; - if (transit == B_EXITED_VIEW) - { + if (transit == B_EXITED_VIEW) { index = -1; + } else { + index = int(point.y / C_SIZE) * C_H_NUM + int(point.x / C_SIZE); } - else - { - index = int (point.y/C_SIZE)*C_H_NUM + int (point.x/C_SIZE); - } - if (previndex != index) - { + if (previndex != index) { if (previndex != -1) - Invalidate (RectForIndex (previndex)); + Invalidate(RectForIndex(previndex)); if (index != -1) - Invalidate (RectForIndex (index)); + Invalidate(RectForIndex(index)); } } \ No newline at end of file diff --git a/source/ColorMenuView.h b/source/ColorMenuView.h index 542f9b5..cbd454f 100644 --- a/source/ColorMenuView.h +++ b/source/ColorMenuView.h @@ -6,20 +6,20 @@ class ColorMenuView : public BView { -public: - ColorMenuView (BRect rect, const char *name, ColorMenuButton *pmb); -virtual ~ColorMenuView (); -virtual void Draw (BRect updateRect); -virtual void MouseDown (BPoint point); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *msg); -BRect RectForIndex (int ind); + public: + ColorMenuView(BRect rect, const char* name, ColorMenuButton* pmb); + virtual ~ColorMenuView(); + virtual void Draw(BRect updateRect); + virtual void MouseDown(BPoint point); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg); + BRect RectForIndex(int ind); -private: -typedef BView inherited; -ColorMenuButton *fCMB; -int index; -int click; -bigtime_t dcspeed; + private: + typedef BView inherited; + ColorMenuButton* fCMB; + int index; + int click; + bigtime_t dcspeed; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/ColorView.cpp b/source/ColorView.cpp index 14c0c62..ad10148 100644 --- a/source/ColorView.cpp +++ b/source/ColorView.cpp @@ -6,10 +6,10 @@ #include "hsv.h" #include -ColorView::ColorView (BRect frame, const char *name, rgb_color c) -: BView (frame, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW) +ColorView::ColorView(BRect frame, const char* name, rgb_color c) + : BView(frame, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW) { - SetViewColor (B_TRANSPARENT_32_BIT); + SetViewColor(B_TRANSPARENT_32_BIT); color_space cs = B_RGB32; { BScreen screen; @@ -17,93 +17,90 @@ ColorView::ColorView (BRect frame, const char *name, rgb_color c) cs = B_COLOR_8_BIT; } BRect bitFrame = frame; - bitFrame.OffsetTo (B_ORIGIN); - bitmap = new BBitmap (bitFrame, cs); - SetColor (c); + bitFrame.OffsetTo(B_ORIGIN); + bitmap = new BBitmap(bitFrame, cs); + SetColor(c); } -ColorView::~ColorView () -{ - delete bitmap; -} +ColorView::~ColorView() { delete bitmap; } -void ColorView::ScreenChanged (BRect /* frame */, color_space cs) +void +ColorView::ScreenChanged(BRect /* frame */, color_space cs) { - if (bitmap->ColorSpace() == B_COLOR_8_BIT && cs != B_COLOR_8_BIT) - { + if (bitmap->ColorSpace() == B_COLOR_8_BIT && cs != B_COLOR_8_BIT) { BRect bitFrame = bitmap->Bounds(); delete bitmap; - bitmap = new BBitmap (bitFrame, B_RGB32); - SetColor (color); - } - else if (bitmap->ColorSpace() != B_COLOR_8_BIT && cs == B_COLOR_8_BIT) - { + bitmap = new BBitmap(bitFrame, B_RGB32); + SetColor(color); + } else if (bitmap->ColorSpace() != B_COLOR_8_BIT && cs == B_COLOR_8_BIT) { BRect bitFrame = bitmap->Bounds(); delete bitmap; - bitmap = new BBitmap (bitFrame, B_COLOR_8_BIT); - SetColor (color); + bitmap = new BBitmap(bitFrame, B_COLOR_8_BIT); + SetColor(color); } } -void ColorView::Draw (BRect /* update */) +void +ColorView::Draw(BRect /* update */) { - DrawBitmap (bitmap, B_ORIGIN); + DrawBitmap(bitmap, B_ORIGIN); } -void ColorView::SetColor (rgb_color c) +void +ColorView::SetColor(rgb_color c) { - int h = int (Bounds().Height() + 1); - int w = int (Bounds().Width() + 1); - uchar *data = new uchar[h*w*3]; + int h = int(Bounds().Height() + 1); + int w = int(Bounds().Width() + 1); + uchar* data = new uchar[h * w * 3]; for (int i = 0; i < h; i++) - for (int j = 0; j < w; j++) - { - data[i*w*3 + j*3] = c.red; - data[i*w*3 + j*3 + 1] = c.green; - data[i*w*3 + j*3 + 2] = c.blue; + for (int j = 0; j < w; j++) { + data[i * w * 3 + j * 3] = c.red; + data[i * w * 3 + j * 3 + 1] = c.green; + data[i * w * 3 + j * 3 + 2] = c.blue; } - bitmap->SetBits (data, h*w*3, 0, B_RGB32); + bitmap->SetBits(data, h * w * 3, 0, B_RGB32); color = c; Invalidate(); - delete [] data; + delete[] data; } -rgb_color ColorView::GetColor () +rgb_color +ColorView::GetColor() { return color; } -void ColorView::MouseDown (BPoint /* point */) +void +ColorView::MouseDown(BPoint /* point */) { - BBitmap *screenBitmap; + BBitmap* screenBitmap; color_space cs = B_RGB32; { BScreen screen; if (screen.ColorSpace() == B_COLOR_8_BIT) cs = B_COLOR_8_BIT; } - screenBitmap = new BBitmap (BRect (0, 0, 15, 15), cs); - char data[16*16*3]; - for (int i = 0; i < 16*16; i++) - { - data[3*i] = color.red; - data[3*i + 1] = color.green; - data[3*i + 2] = color.blue; + screenBitmap = new BBitmap(BRect(0, 0, 15, 15), cs); + char data[16 * 16 * 3]; + for (int i = 0; i < 16 * 16; i++) { + data[3 * i] = color.red; + data[3 * i + 1] = color.green; + data[3 * i + 2] = color.blue; } - screenBitmap->SetBits (data, 16*16*3, 0, B_RGB32); + screenBitmap->SetBits(data, 16 * 16 * 3, 0, B_RGB32); roSColor colorData; char htmlString[8]; - hsv_color h = rgb2hsv (color); - colorData.m_Red = float (color.red)/255; - colorData.m_Green = float (color.green)/255; - colorData.m_Blue = float (color.blue)/255; - colorData.m_Alpha = float (color.alpha)/255; - colorData.m_Hue = float (h.hue)/360; - sprintf (htmlString, "#%02X%02X%02X", color.red, color.green, color.blue); - BMessage *drag = new BMessage (B_PASTE); - drag->AddData ("roColour", RO_COLOR_STRUCT_128_TYPE, &colorData, sizeof (struct roSColor)); - drag->AddData ("RGBColor", B_RGB_COLOR_TYPE, &color, sizeof (struct rgb_color)); - drag->AddData ("text/plain", B_MIME_TYPE, htmlString, 7); - DragMessage (drag, screenBitmap, B_OP_COPY, BPoint (7, 7)); + hsv_color h = rgb2hsv(color); + colorData.m_Red = float(color.red) / 255; + colorData.m_Green = float(color.green) / 255; + colorData.m_Blue = float(color.blue) / 255; + colorData.m_Alpha = float(color.alpha) / 255; + colorData.m_Hue = float(h.hue) / 360; + sprintf(htmlString, "#%02X%02X%02X", color.red, color.green, color.blue); + BMessage* drag = new BMessage(B_PASTE); + drag->AddData("roColour", RO_COLOR_STRUCT_128_TYPE, &colorData, sizeof(struct roSColor)); + drag->AddData("RGBColor", B_RGB_COLOR_TYPE, &color, sizeof(struct rgb_color)); + drag->AddData("text/plain", B_MIME_TYPE, htmlString, 7); + DragMessage(drag, screenBitmap, B_OP_COPY, BPoint(7, 7)); delete drag; } \ No newline at end of file diff --git a/source/ColorView.h b/source/ColorView.h index 6a54f73..54f78b3 100644 --- a/source/ColorView.h +++ b/source/ColorView.h @@ -7,19 +7,19 @@ class ColorView : public BView { -public: - ColorView (BRect frame, const char *name, rgb_color c); -virtual ~ColorView (); -virtual void Draw (BRect update); -virtual void MouseDown (BPoint point); -virtual void ScreenChanged (BRect frame, color_space cs); -void SetColor (rgb_color c); -rgb_color GetColor (); + public: + ColorView(BRect frame, const char* name, rgb_color c); + virtual ~ColorView(); + virtual void Draw(BRect update); + virtual void MouseDown(BPoint point); + virtual void ScreenChanged(BRect frame, color_space cs); + void SetColor(rgb_color c); + rgb_color GetColor(); -private: -typedef BView inherited; -BBitmap *bitmap; -rgb_color color; + private: + typedef BView inherited; + BBitmap* bitmap; + rgb_color color; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/ColorWindow.cpp b/source/ColorWindow.cpp index 97658ce..52e5d27 100644 --- a/source/ColorWindow.cpp +++ b/source/ColorWindow.cpp @@ -13,380 +13,384 @@ #include #include "Settings.h" -ColorWindow::ColorWindow (BRect frame, const char *name, ColorMenuButton *but) -: BWindow (frame, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) +ColorWindow::ColorWindow(BRect frame, const char* name, ColorMenuButton* but) + : BWindow(frame, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) { button = but; ob = 0; BRect menubarFrame, bgFrame, bg2Frame, squareFrame; BRect rFrame, gFrame, bFrame, hFrame, sFrame, vFrame, tFrame; BRect setFrame, curFrame, matchFrame, distFrame; - menubarFrame.Set (0, 0, 0, 0); - menubar = new BMenuBar (menubarFrame, "ColorMenuBar"); - BMenu *fileMenu = new BMenu (lstring (10, "File")); - fileMenu->AddItem (new BMenuItem (lstring (190, "Save Palette…"), new BMessage ('Csav'))); - fileMenu->AddItem (new BMenuItem (lstring (191, "Load Palette…"), new BMessage ('Clod'))); - BMenu *generateMenu = new BMenu (lstring (192, "Generate Palette")); - generateMenu->AddItem (new BMenuItem (lstring (193, "Default"), new BMessage ('PGdf'))); - generateMenu->AddItem (new BMenuItem (lstring (194, "Grey"), new BMessage ('PGG'))); - generateMenu->AddItem (new BMenuItem (lstring (77, "Red"), new BMessage ('PGr'))); - generateMenu->AddItem (new BMenuItem (lstring (78, "Green"), new BMessage ('PGg'))); - generateMenu->AddItem (new BMenuItem (lstring (79, "Blue"), new BMessage ('PGb'))); - generateMenu->AddItem (new BMenuItem (lstring (80, "Cyan"), new BMessage ('PGgb'))); - generateMenu->AddItem (new BMenuItem (lstring (81, "Magenta"), new BMessage ('PGrb'))); - generateMenu->AddItem (new BMenuItem (lstring (82, "Yellow"), new BMessage ('PGrg'))); - generateMenu->AddItem (new BMenuItem (lstring (195, "Spectrum"), new BMessage ('PGsp'))); - generateMenu->AddItem (new BMenuItem (lstring (196, "Heat Scale"), new BMessage ('PGht'))); - fileMenu->AddItem (generateMenu, (int32) NULL); - - menubar->AddItem (fileMenu); - AddChild (menubar); + menubarFrame.Set(0, 0, 0, 0); + menubar = new BMenuBar(menubarFrame, "ColorMenuBar"); + BMenu* fileMenu = new BMenu(lstring(10, "File")); + fileMenu->AddItem(new BMenuItem(lstring(190, "Save Palette…"), new BMessage('Csav'))); + fileMenu->AddItem(new BMenuItem(lstring(191, "Load Palette…"), new BMessage('Clod'))); + BMenu* generateMenu = new BMenu(lstring(192, "Generate Palette")); + generateMenu->AddItem(new BMenuItem(lstring(193, "Default"), new BMessage('PGdf'))); + generateMenu->AddItem(new BMenuItem(lstring(194, "Grey"), new BMessage('PGG'))); + generateMenu->AddItem(new BMenuItem(lstring(77, "Red"), new BMessage('PGr'))); + generateMenu->AddItem(new BMenuItem(lstring(78, "Green"), new BMessage('PGg'))); + generateMenu->AddItem(new BMenuItem(lstring(79, "Blue"), new BMessage('PGb'))); + generateMenu->AddItem(new BMenuItem(lstring(80, "Cyan"), new BMessage('PGgb'))); + generateMenu->AddItem(new BMenuItem(lstring(81, "Magenta"), new BMessage('PGrb'))); + generateMenu->AddItem(new BMenuItem(lstring(82, "Yellow"), new BMessage('PGrg'))); + generateMenu->AddItem(new BMenuItem(lstring(195, "Spectrum"), new BMessage('PGsp'))); + generateMenu->AddItem(new BMenuItem(lstring(196, "Heat Scale"), new BMessage('PGht'))); + fileMenu->AddItem(generateMenu, (int32)NULL); + + menubar->AddItem(fileMenu); + AddChild(menubar); menubar->ResizeToPreferred(); menubarFrame = menubar->Frame(); - bg2Frame.Set (0, menubarFrame.Height() + CE_HEIGHT - 145, CE_WIDTH, menubarFrame.Height() + CE_HEIGHT); - BView *bg2 = new BView (bg2Frame, "CE bg2", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); - bg2->SetViewColor (LightGrey); - AddChild (bg2); - bgFrame.Set (0, menubarFrame.Height() + 1, CE_WIDTH, menubarFrame.Height() + CE_HEIGHT - 146); - TabView *bgTab = new TabView (bgFrame, "Color Editor bg"); - AddChild (bgTab); - bgFrame.OffsetTo (B_ORIGIN); - ResizeTo (CE_WIDTH, CE_HEIGHT + menubarFrame.Height()); - bgFrame.InsetBy (2, 2); + bg2Frame.Set( + 0, menubarFrame.Height() + CE_HEIGHT - 145, CE_WIDTH, menubarFrame.Height() + CE_HEIGHT + ); + BView* bg2 = new BView(bg2Frame, "CE bg2", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); + bg2->SetViewColor(LightGrey); + AddChild(bg2); + bgFrame.Set(0, menubarFrame.Height() + 1, CE_WIDTH, menubarFrame.Height() + CE_HEIGHT - 146); + TabView* bgTab = new TabView(bgFrame, "Color Editor bg"); + AddChild(bgTab); + bgFrame.OffsetTo(B_ORIGIN); + ResizeTo(CE_WIDTH, CE_HEIGHT + menubarFrame.Height()); + bgFrame.InsetBy(2, 2); bgFrame.top += TAB_HEIGHT; - BView *rgbV = new BView (bgFrame, "RGB View", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); - rgbV->SetViewColor (LightGrey); - bgTab->AddView (rgbV, lstring (197, "RGB Model")); - BView *hsvV = new BView (bgFrame, "HSV View", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); - hsvV->SetViewColor (LightGrey); - bgTab->AddView (hsvV, lstring (198, "HSV Model")); + BView* rgbV = new BView(bgFrame, "RGB View", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); + rgbV->SetViewColor(LightGrey); + bgTab->AddView(rgbV, lstring(197, "RGB Model")); + BView* hsvV = new BView(bgFrame, "HSV View", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); + hsvV->SetViewColor(LightGrey); + bgTab->AddView(hsvV, lstring(198, "HSV Model")); - squareFrame.Set (8, 8, 311, 263); + squareFrame.Set(8, 8, 311, 263); c = button->color(); - rgbSquare = new RGBSquare (squareFrame, 0, this); - rgbV->AddChild (rgbSquare); - rFrame.Set (16, 270, 70, 288); - gFrame.Set (16, 292, 70, 310); - bFrame.Set (16, 314, 70, 332); - BRadioButton *rRB = new BRadioButton (rFrame, "rRB", lstring (77, "Red"), new BMessage ('BrbR')); - BRadioButton *gRB = new BRadioButton (gFrame, "gRB", lstring (78, "Green"), new BMessage ('BrbG')); - BRadioButton *bRB = new BRadioButton (bFrame, "bRB", lstring (79, "Blue"), new BMessage ('BrbB')); - rRB->SetValue (1); - rgbV->AddChild (rRB); - rgbV->AddChild (gRB); - rgbV->AddChild (bRB); - char rS[16]; - char gS[16]; - char bS[16]; - sprintf (rS, "%i", c.red); - sprintf (gS, "%i", c.green); - sprintf (bS, "%i", c.blue); - rFrame.Set (72, 268, 150, 286); - gFrame.Set (72, 290, 150, 308); - bFrame.Set (72, 312, 150, 330); - rTC = new BTextControl (rFrame, "rTC", "(0–255)", rS, new BMessage ('TrbR')); - gTC = new BTextControl (gFrame, "gTC", "(0–255)", gS, new BMessage ('TrbG')); - bTC = new BTextControl (bFrame, "bTC", "(0–255)", bS, new BMessage ('TrbB')); - rgbV->AddChild (rTC); - rgbV->AddChild (gTC); - rgbV->AddChild (bTC); + rgbSquare = new RGBSquare(squareFrame, 0, this); + rgbV->AddChild(rgbSquare); + rFrame.Set(16, 270, 70, 288); + gFrame.Set(16, 292, 70, 310); + bFrame.Set(16, 314, 70, 332); + BRadioButton* rRB = new BRadioButton(rFrame, "rRB", lstring(77, "Red"), new BMessage('BrbR')); + BRadioButton* gRB = new BRadioButton(gFrame, "gRB", lstring(78, "Green"), new BMessage('BrbG')); + BRadioButton* bRB = new BRadioButton(bFrame, "bRB", lstring(79, "Blue"), new BMessage('BrbB')); + rRB->SetValue(1); + rgbV->AddChild(rRB); + rgbV->AddChild(gRB); + rgbV->AddChild(bRB); + BString rS, gS, bS; + fNumberFormat.Format(rS, c.red); + fNumberFormat.Format(gS, c.green); + fNumberFormat.Format(bS, c.blue); + rFrame.Set(72, 268, 150, 286); + gFrame.Set(72, 290, 150, 308); + bFrame.Set(72, 312, 150, 330); + rTC = new BTextControl(rFrame, "rTC", "(0–255)", rS, new BMessage('TrbR')); + gTC = new BTextControl(gFrame, "gTC", "(0–255)", gS, new BMessage('TrbG')); + bTC = new BTextControl(bFrame, "bTC", "(0–255)", bS, new BMessage('TrbB')); + rgbV->AddChild(rTC); + rgbV->AddChild(gTC); + rgbV->AddChild(bTC); + + hsvSquare = new HSVSquare(squareFrame, this); + hsvV->AddChild(hsvSquare); + hsv_color h = rgb2hsv(c); + BString hS, sS, vS; + fNumberFormat.Format(hS, h.hue); + fNumberFormat.SetPrecision(3); + fNumberFormat.Format(sS, h.saturation); + fNumberFormat.Format(vS, h.value); + hFrame.Set(16, 268, 160, 286); + sFrame.Set(16, 290, 160, 308); + vFrame.Set(16, 312, 160, 330); + hTC = new BTextControl(hFrame, "hTC", lstring(199, "Hue (0–360)"), hS, new BMessage('TrbH')); + sTC = + new BTextControl(sFrame, "sTC", lstring(200, "Saturation (0–1)"), sS, new BMessage('TrbS')); + vTC = new BTextControl(vFrame, "vTC", lstring(201, "Value (0–1)"), vS, new BMessage('TrbV')); + hTC->SetDivider(90); + sTC->SetDivider(90); + vTC->SetDivider(90); + hsvV->AddChild(hTC); + hsvV->AddChild(sTC); + hsvV->AddChild(vTC); + + tFrame.Set(8, 3, 316, 41); + BBox* slidBox2 = new BBox(tFrame, "slidBox2"); + slidBox2->SetLabel(lstring(202, "Alpha Channel")); + bg2->AddChild(slidBox2); + tFrame.Set(8, 13, 296, 29); + aSlid = new Slider( + tFrame, 84, lstring(203, "Opacity"), 0, 255, 1, new BMessage('CXac'), B_HORIZONTAL, 0 + ); + aSlid->SetValue(c.alpha); + slidBox2->AddChild(aSlid); + + tFrame.Set(8, 42, 316, 80); + BBox* slidBox = new BBox(tFrame, "slidBox"); + slidBox->SetLabel(lstring(204, "Color Picker")); + bg2->AddChild(slidBox); + tFrame.Set(8, 13, 296, 29); + Slider* tSlid = new Slider( + tFrame, 84, lstring(205, "RGB Tolerance"), 0, 255, 1, new BMessage('CXtc'), B_HORIZONTAL, 0, + "%3.1f" + ); + tSlid->SetValue(button->getTolerance()); + slidBox->AddChild(tSlid); + + setFrame.Set(bg2Frame.Width() - 92, 84, bg2Frame.Width() - 8, 109); + BButton* setCurrent = + new BButton(setFrame, "CE Setbutton", lstring(206, "Current"), new BMessage('CXSc')); + bg2->AddChild(setCurrent); + setCurrent->MakeDefault(true); + + setFrame.Set(bg2Frame.Width() - 92, 115, bg2Frame.Width() - 8, 140); + BButton* setMatch = + new BButton(setFrame, "CE Matchbutton", lstring(207, "Best Match"), new BMessage('CXSm')); + bg2->AddChild(setMatch); + + // cancFrame = setFrame; + // cancFrame.OffsetBy (-64, 0); + // BButton *cancel = new BButton (cancFrame, "CE Cancelbutton", "Cancel", new BMessage + //('CXcn')); bg2->AddChild (cancel); + + curFrame.Set(8, 84, 39, 109); + cur = new ColorView(curFrame, "Current", c); + bg2->AddChild(cur); - hsvSquare = new HSVSquare (squareFrame, this); - hsvV->AddChild (hsvSquare); - hsv_color h = rgb2hsv (c); - char hS[16]; - char sS[16]; - char vS[16]; - sprintf (hS, "%.0f", h.hue); - sprintf (sS, "%1.3f", h.saturation); - sprintf (vS, "%1.3f", h.value); - hFrame.Set (16, 268, 160, 286); - sFrame.Set (16, 290, 160, 308); - vFrame.Set (16, 312, 160, 330); - hTC = new BTextControl (hFrame, "hTC", lstring (199, "Hue (0–360)"), hS, new BMessage ('TrbH')); - sTC = new BTextControl (sFrame, "sTC", lstring (200, "Saturation (0–1)"), sS, new BMessage ('TrbS')); - vTC = new BTextControl (vFrame, "vTC", lstring (201, "Value (0–1)"), vS, new BMessage ('TrbV')); - hTC->SetDivider (90); - sTC->SetDivider (90); - vTC->SetDivider (90); - hsvV->AddChild (hTC); - hsvV->AddChild (sTC); - hsvV->AddChild (vTC); + matchFrame.Set(8, 112, 39, 137); + match = new ColorView(matchFrame, "Match", c); + bg2->AddChild(match); - tFrame.Set (8, 3, 316, 41); - BBox *slidBox2 = new BBox (tFrame, "slidBox2"); - slidBox2->SetLabel (lstring (202, "Alpha Channel")); - bg2->AddChild (slidBox2); - tFrame.Set (8, 13, 296, 29); - aSlid = new Slider (tFrame, 84, lstring (203, "Opacity"), 0, 255, 1, new BMessage ('CXac'), B_HORIZONTAL, 0); - aSlid->SetValue (c.alpha); - slidBox2->AddChild (aSlid); + distFrame.Set(42, 84, 200, 100); + BStringView* selText = new BStringView(distFrame, "SelText", lstring(208, "Current Selection")); + bg2->AddChild(selText); - tFrame.Set (8, 42, 316, 80); - BBox *slidBox = new BBox (tFrame, "slidBox"); - slidBox->SetLabel (lstring (204, "Color Picker")); - bg2->AddChild (slidBox); - tFrame.Set (8, 13, 296, 29); - Slider *tSlid = new Slider (tFrame, 84, lstring (205, "RGB Tolerance"), 0, 255, 1, new BMessage ('CXtc'), B_HORIZONTAL, 0, "%3.1f"); - tSlid->SetValue (button->getTolerance()); - slidBox->AddChild (tSlid); + distFrame.Set(42, 108, 200, 124); + BStringView* matchText = + new BStringView(distFrame, "MatchText", lstring(209, "Closest Match in Palette")); + bg2->AddChild(matchText); - setFrame.Set (bg2Frame.Width() - 92, 84, bg2Frame.Width() - 8, 109); - BButton *setCurrent = new BButton (setFrame, "CE Setbutton", lstring (206, "Current"), new BMessage ('CXSc')); - bg2->AddChild (setCurrent); - setCurrent->MakeDefault (true); - - setFrame.Set (bg2Frame.Width() - 92, 115, bg2Frame.Width() - 8, 140); - BButton *setMatch = new BButton (setFrame, "CE Matchbutton", lstring (207, "Best Match"), new BMessage ('CXSm')); - bg2->AddChild (setMatch); - -// cancFrame = setFrame; -// cancFrame.OffsetBy (-64, 0); -// BButton *cancel = new BButton (cancFrame, "CE Cancelbutton", "Cancel", new BMessage ('CXcn')); -// bg2->AddChild (cancel); + distFrame.Set(42, 124, 200, 138); + dist = new BStringView(distFrame, "DistText", lstring(210, "(RGB distance XXX)")); + bg2->AddChild(dist); - curFrame.Set (8, 84, 39, 109); - cur = new ColorView (curFrame, "Current", c); - bg2->AddChild (cur); - - matchFrame.Set (8, 112, 39, 137); - match = new ColorView (matchFrame, "Match", c); - bg2->AddChild (match); - - distFrame.Set (42, 84, 200, 100); - BStringView *selText = new BStringView (distFrame, "SelText", lstring (208, "Current Selection")); - bg2->AddChild (selText); - - distFrame.Set (42, 108, 200, 124); - BStringView *matchText = new BStringView (distFrame, "MatchText", lstring (209, "Closest Match in Palette")); - bg2->AddChild (matchText); - - distFrame.Set (42, 124, 200, 138); - dist = new BStringView (distFrame, "DistText", lstring (210, "(RGB distance XXX)")); - bg2->AddChild (dist); - - SetColor (c); - savePanel = new BFilePanel (B_SAVE_PANEL, new BMessenger (this), NULL, - B_FILE_NODE, false); - openPanel = new BFilePanel (B_OPEN_PANEL, new BMessenger (this), NULL, - B_FILE_NODE, false); + SetColor(c); + savePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this), NULL, B_FILE_NODE, false); + openPanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this), NULL, B_FILE_NODE, false); } -ColorWindow::~ColorWindow () +ColorWindow::~ColorWindow() { delete savePanel; delete openPanel; } -void ColorWindow::Quit () +void +ColorWindow::Quit() { button->editorSaysBye(); inherited::Quit(); } -void ColorWindow::ScreenChanged (BRect frame, color_space cs) +void +ColorWindow::ScreenChanged(BRect frame, color_space cs) { - rgbSquare->ScreenChanged (frame, cs); - hsvSquare->ScreenChanged (frame, cs); - cur->ScreenChanged (frame, cs); - match->ScreenChanged (frame, cs); - inherited::ScreenChanged (frame, cs); + rgbSquare->ScreenChanged(frame, cs); + hsvSquare->ScreenChanged(frame, cs); + cur->ScreenChanged(frame, cs); + match->ScreenChanged(frame, cs); + inherited::ScreenChanged(frame, cs); } -void ColorWindow::SetColor (rgb_color _c) +void +ColorWindow::SetColor(rgb_color _c) { - char s[128]; + BString data; + BString string; c = _c; - cur->SetColor (c); - rgb_color d = button->getClosest (c); - float distance = diff (c, d); - match->SetColor (d); - sprintf (s, lstring (211, "(RGB distance: %3.1f)"), distance); - dist->SetText (s); + cur->SetColor(c); + rgb_color d = button->getClosest(c); + float distance = diff(c, d); + match->SetColor(d); + fNumberFormat.SetPrecision(1); + fNumberFormat.Format(data, distance); + string.SetToFormat("RGB distance: %s", data.String()); + dist->SetText(string.String()); } -void ColorWindow::MessageReceived (BMessage *msg) +void +ColorWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_PASTE: - { - rgb_color *dropped; + switch (msg->what) { + case B_PASTE: { + rgb_color* dropped; long dummy; - if (msg->FindData ("RGBColor", B_RGB_COLOR_TYPE, (const void **) &dropped, &dummy) == B_OK) - { - BMessage *cdrop = new BMessage ('SetC'); - cdrop->AddInt32 ("color", dropped->red); - cdrop->AddInt32 ("color", dropped->green); - cdrop->AddInt32 ("color", dropped->blue); - PostMessage (cdrop); + if (msg->FindData("RGBColor", B_RGB_COLOR_TYPE, (const void**)&dropped, &dummy) == B_OK) { + BMessage* cdrop = new BMessage('SetC'); + cdrop->AddInt32("color", dropped->red); + cdrop->AddInt32("color", dropped->green); + cdrop->AddInt32("color", dropped->blue); + PostMessage(cdrop); delete cdrop; - aSlid->SetValue (dropped->alpha); - button->setAlpha (dropped->alpha); + aSlid->SetValue(dropped->alpha); + button->setAlpha(dropped->alpha); } -// char *htmlString; -// if (msg->FindData ("text/plain", B_MIME_TYPE, (void **) &htmlString, &dummy) == B_OK) -// { -// printf ("HTML: <%s>\n", htmlString); -// } -// else -// printf ("HTML string not found...\n"); -// break; + // char *htmlString; + // if (msg->FindData ("text/plain", B_MIME_TYPE, (void **) &htmlString, &dummy) == + // B_OK) + // { + // printf ("HTML: <%s>\n", htmlString); + // } + // else + // printf ("HTML string not found...\n"); + // break; } - case 'SetC': - { - char s[16]; - c.red = msg->FindInt32 ("color", (int32)0); - c.green = msg->FindInt32 ("color", (int32)1); - c.blue = msg->FindInt32 ("color", (int32)2); + case 'SetC': { + BString s; + c.red = msg->FindInt32("color", (int32)0); + c.green = msg->FindInt32("color", (int32)1); + c.blue = msg->FindInt32("color", (int32)2); int32 alpha; - if (msg->FindInt32 ("alpha", &alpha) == B_OK) - { + if (msg->FindInt32("alpha", &alpha) == B_OK) { c.alpha = alpha; } - SetColor (c); - hsv_color h = rgb2hsv (c); - rgbSquare->SetColor (c); - hsvSquare->SetColor (h); - sprintf (s, "%i", c.red); - rTC->SetText (s); - sprintf (s, "%i", c.green); - gTC->SetText (s); - sprintf (s, "%i", c.blue); - bTC->SetText (s); - sprintf (s, "%3.0f", h.hue); - hTC->SetText (s); - sprintf (s, "%1.3f", h.saturation); - sTC->SetText (s); - sprintf (s, "%1.3f", h.value); - vTC->SetText (s); - aSlid->SetValue (c.alpha); - button->setAlpha (c.alpha); + SetColor(c); + hsv_color h = rgb2hsv(c); + rgbSquare->SetColor(c); + hsvSquare->SetColor(h); + fNumberFormat.Format(s, c.red); + rTC->SetText(s.String()); + fNumberFormat.Format(s, c.green); + gTC->SetText(s.String()); + fNumberFormat.Format(s, c.blue); + bTC->SetText(s.String()); + fNumberFormat.Format(s, h.hue); + hTC->SetText(s.String()); + fNumberFormat.SetPrecision(3); + fNumberFormat.Format(s, h.saturation); + sTC->SetText(s.String()); + fNumberFormat.SetPrecision(3); + fNumberFormat.Format(s, h.value); + vTC->SetText(s.String()); + aSlid->SetValue(c.alpha); + button->setAlpha(c.alpha); break; } case 'BrbR': - rgbSquare->SetNotColor (0); + rgbSquare->SetNotColor(0); break; case 'BrbG': - rgbSquare->SetNotColor (1); + rgbSquare->SetNotColor(1); break; case 'BrbB': - rgbSquare->SetNotColor (2); + rgbSquare->SetNotColor(2); break; - case 'TrbR': - { - char s[16]; - int r = atoi (rTC->Text()); - r = clipchar (r); - sprintf (s, "%i", r); - rTC->SetText (s); + case 'TrbR': { + BString s; + int r = atoi(rTC->Text()); + r = clipchar(r); + fNumberFormat.Format(s, r); + rTC->SetText(s.String()); c.red = r; - rgbSquare->SetColor (c); - SetColor (c); + rgbSquare->SetColor(c); + SetColor(c); break; } - case 'TrbG': - { - char s[16]; - int g = atoi (gTC->Text()); - g = clipchar (g); - sprintf (s, "%i", g); - gTC->SetText (s); + case 'TrbG': { + BString s; + int g = atoi(gTC->Text()); + g = clipchar(g); + fNumberFormat.Format(s, g); + gTC->SetText(s.String()); c.green = g; - rgbSquare->SetColor (c); - SetColor (c); + rgbSquare->SetColor(c); + SetColor(c); break; } - case 'TrbB': - { - char s[16]; - int b = atoi (bTC->Text()); - b = clipchar (b); - sprintf (s, "%i", b); - bTC->SetText (s); + case 'TrbB': { + BString s; + int b = atoi(bTC->Text()); + b = clipchar(b); + fNumberFormat.Format(s, b); + bTC->SetText(s.String()); c.blue = b; - rgbSquare->SetColor (c); - SetColor (c); + rgbSquare->SetColor(c); + SetColor(c); break; } - case 'CSQc': - { - char s[16]; - c.red = msg->FindInt32 ("color", (int32)0); - c.green = msg->FindInt32 ("color", (int32)1); - c.blue = msg->FindInt32 ("color", (int32)2); - sprintf (s, "%i", c.red); - rTC->SetText (s); - sprintf (s, "%i", c.green); - gTC->SetText (s); - sprintf (s, "%i", c.blue); - bTC->SetText (s); - SetColor (c); + case 'CSQc': { + BString s; + c.red = msg->FindInt32("color", (int32)0); + c.green = msg->FindInt32("color", (int32)1); + c.blue = msg->FindInt32("color", (int32)2); + fNumberFormat.Format(s, c.red); + rTC->SetText(s.String()); + fNumberFormat.Format(s, c.green); + gTC->SetText(s.String()); + fNumberFormat.Format(s, c.blue); + bTC->SetText(s.String()); + SetColor(c); break; } - case 'CSQh': - { - char s[16]; + case 'CSQh': { + BString s; hsv_color h; - h.hue = msg->FindFloat ("color", (int32)0); - h.saturation = msg->FindFloat ("color", (int32)1); - h.value = msg->FindFloat ("color", (int32)2); - sprintf (s, "%3.0f", h.hue); - hTC->SetText (s); - sprintf (s, "%1.3f", h.saturation); - sTC->SetText (s); - sprintf (s, "%1.3f", h.value); - vTC->SetText (s); - c = hsv2rgb (h); - SetColor (c); + h.hue = msg->FindFloat("color", (int32)0); + h.saturation = msg->FindFloat("color", (int32)1); + h.value = msg->FindFloat("color", (int32)2); + fNumberFormat.Format(s, h.hue); + hTC->SetText(s.String()); + fNumberFormat.SetPrecision(3); + fNumberFormat.Format(s, h.saturation); + sTC->SetText(s.String()); + fNumberFormat.SetPrecision(3); + fNumberFormat.Format(s, h.value); + vTC->SetText(s.String()); + c = hsv2rgb(h); + SetColor(c); break; } - case 'HSVc': // MouseDown on column + case 'HSVc': // MouseDown on column case 'RGBc': ob = 1; break; - case 'HSVs': // MouseDown on square + case 'HSVs': // MouseDown on square case 'RGBs': ob = 2; break; - case 'HSVu': // Mouse Up + case 'HSVu': // Mouse Up case 'RGBu': ob = 0; break; - case 'HSVm': - { - if (ob) - { + case 'HSVm': { + if (ob) { BPoint point; - point.x = msg->FindFloat ("x"); - point.y = msg->FindFloat ("y"); - hsvSquare->mouseDown (point, ob); + point.x = msg->FindFloat("x"); + point.y = msg->FindFloat("y"); + hsvSquare->mouseDown(point, ob); } break; } - case 'RGBm': - { - if (ob) - { + case 'RGBm': { + if (ob) { BPoint point; - point.x = msg->FindFloat ("x"); - point.y = msg->FindFloat ("y"); - rgbSquare->mouseDown (point, ob); + point.x = msg->FindFloat("x"); + point.y = msg->FindFloat("y"); + rgbSquare->mouseDown(point, ob); } break; } case 'CXSc': - button->set (c); + button->set(c); break; case 'CXSm': - button->set (c, true); + button->set(c, true); break; - case 'CXtc': // This is not nice. Change this to take effect after a button press. - button->setTolerance (msg->FindFloat ("value")); + case 'CXtc': // This is not nice. Change this to take effect after a button press. + button->setTolerance(msg->FindFloat("value")); break; case 'CXac': // printf ("Alpha set!\n"); - button->setAlpha (msg->FindFloat ("value")); + button->setAlpha(msg->FindFloat("value")); break; case 'Csav': savePanel->Show(); @@ -394,29 +398,26 @@ void ColorWindow::MessageReceived (BMessage *msg) case 'Clod': openPanel->Show(); break; - case B_SAVE_REQUESTED: - { + case B_SAVE_REQUESTED: { entry_ref lref; char name[B_FILE_NAME_LENGTH]; - msg->FindRef ("directory", &lref); - BEntry entry = BEntry (&lref); - if (msg->FindString ("name")) - { + msg->FindRef("directory", &lref); + BEntry entry = BEntry(&lref); + if (msg->FindString("name")) { // The Save Panel returns the name separately - BDirectory dir = BDirectory (&lref); - strcpy (name, msg->FindString ("name")); - entry.SetTo (&dir, name, false); + BDirectory dir = BDirectory(&lref); + strcpy(name, msg->FindString("name")); + entry.SetTo(&dir, name, false); } - button->Save (entry); + button->Save(entry); break; } case B_REFS_RECEIVED: - case B_SIMPLE_DATA: - { + case B_SIMPLE_DATA: { entry_ref lref; - msg->FindRef ("refs", &lref); - BEntry entry = BEntry (&lref); - button->Load (entry); + msg->FindRef("refs", &lref); + BEntry entry = BEntry(&lref); + button->Load(entry); break; } case 'PGdf': @@ -429,10 +430,10 @@ void ColorWindow::MessageReceived (BMessage *msg) case 'PGgb': case 'PGht': case 'PGsp': - button->Generate (msg->what); + button->Generate(msg->what); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } diff --git a/source/ColorWindow.h b/source/ColorWindow.h index 9f56771..ca48166 100644 --- a/source/ColorWindow.h +++ b/source/ColorWindow.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "ColorMenuButton.h" #include "Slider.h" #include "RGBSquare.h" @@ -14,34 +15,37 @@ #include "hsv.h" #include "ColorView.h" -#define CE_WIDTH 320 +#define CE_WIDTH 320 #define CE_HEIGHT 502 class ColorWindow : public BWindow { -public: - ColorWindow (BRect frame, const char *name, ColorMenuButton *but); -virtual ~ColorWindow (); -virtual void MessageReceived (BMessage *msg); -virtual void Quit (); -virtual void ScreenChanged (BRect rect, color_space cs); -rgb_color rgb() { return c; }; -hsv_color hsv() { return rgb2hsv (c); }; + public: + ColorWindow(BRect frame, const char* name, ColorMenuButton* but); + virtual ~ColorWindow(); + virtual void MessageReceived(BMessage* msg); + virtual void Quit(); + virtual void ScreenChanged(BRect rect, color_space cs); -private: -typedef BWindow inherited; -void SetColor (rgb_color _c); -ColorMenuButton *button; -BMenuBar *menubar; -class RGBSquare *rgbSquare; -class HSVSquare *hsvSquare; -BTextControl *rTC, *gTC, *bTC, *hTC, *sTC, *vTC; -ColorView *cur, *match; -BStringView *dist; -rgb_color c; -int ob; -BFilePanel *savePanel, *openPanel; -Slider *aSlid; + rgb_color rgb() { return c; }; + + hsv_color hsv() { return rgb2hsv(c); }; + + private: + typedef BWindow inherited; + void SetColor(rgb_color _c); + ColorMenuButton* button; + BMenuBar* menubar; + BNumberFormat fNumberFormat; + class RGBSquare* rgbSquare; + class HSVSquare* hsvSquare; + BTextControl *rTC, *gTC, *bTC, *hTC, *sTC, *vTC; + ColorView *cur, *match; + BStringView* dist; + rgb_color c; + int ob; + BFilePanel *savePanel, *openPanel; + Slider* aSlid; }; -#endif \ No newline at end of file +#endif diff --git a/source/Colors.h b/source/Colors.h index a84d863..c632510 100644 --- a/source/Colors.h +++ b/source/Colors.h @@ -8,14 +8,11 @@ extern IMPEXP rgb_color Black, LightGrey, DarkGrey, White, Transparent; extern IMPEXP rgb_color Red, Green, Blue; -extern IMPEXP rgb_color Grey0, Grey1, Grey2, Grey3, Grey4, Grey5, - Grey6, Grey7, Grey8, Grey9, Grey10, Grey11, - Grey12, Grey13, Grey14, Grey15, Grey16, Grey17, - Grey18, Grey19, Grey20, Grey21, Grey22, Grey23, - Grey24, Grey25, Grey26, Grey27, Grey28, Grey29, - Grey30, Grey31; +extern IMPEXP rgb_color Grey0, Grey1, Grey2, Grey3, Grey4, Grey5, Grey6, Grey7, Grey8, Grey9, + Grey10, Grey11, Grey12, Grey13, Grey14, Grey15, Grey16, Grey17, Grey18, Grey19, Grey20, Grey21, + Grey22, Grey23, Grey24, Grey25, Grey26, Grey27, Grey28, Grey29, Grey30, Grey31; #define SELECT_FULL B_TRANSPARENT_32_BIT #define SELECT_NONE Black -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/Credits.h b/source/Credits.h index 5133cd8..0d73c55 100644 --- a/source/Credits.h +++ b/source/Credits.h @@ -1,7 +1,7 @@ /* Credits - William Bull (advice on GUI and architecture) -- BeDevTalk, esp. Jon Wãtte (Datatypes and many tips) and Chris Herborth +- BeDevTalk, esp. Jon Wãtte (Datatypes and many tips) and Chris Herborth (color tips, beta testing), - Raphael Moll (beta testing and many tips) - Thomas Fletcher diff --git a/source/DModes.h b/source/DModes.h index 382c6b7..baa480a 100644 --- a/source/DModes.h +++ b/source/DModes.h @@ -3,9 +3,9 @@ #ifndef _DMODES_H #define _DMODES_H -#define DM_BLEND 0 -#define DM_MULTIPLY 1 -#define DM_DIFFERENCE 2 -#define DM_ALPHAMASK 3 +#define DM_BLEND 0 +#define DM_MULTIPLY 1 +#define DM_DIFFERENCE 2 +#define DM_ALPHAMASK 3 #endif diff --git a/source/Dial.cpp b/source/Dial.cpp index 37d602e..fb2d13d 100644 --- a/source/Dial.cpp +++ b/source/Dial.cpp @@ -4,28 +4,29 @@ #include "Colors.h" public: - EnterFilter (BHandler *handler); -virtual filter_result Filter (BMessage *message, BHandler **target); +EnterFilter(BHandler* handler); +virtual filter_result +Filter(BMessage* message, BHandler** target); private: -BHandler *fHandler; -}; +BHandler* fHandler; +} +; -EnterFilter::EnterFilter (BHandler *handler) -: BMessageFilter (B_PROGRAMMED_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN) +EnterFilter::EnterFilter(BHandler* handler) + : BMessageFilter(B_PROGRAMMED_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN) { fHandler = handler; } -filter_result EnterFilter::Filter (BMessage *message, BHandler **target) +filter_result +EnterFilter::Filter(BMessage* message, BHandler** target) { - //message->PrintToStream(); - //printf ("to: %s\n", (*target)->Name()); + // message->PrintToStream(); + // printf ("to: %s\n", (*target)->Name()); int32 raw_char; - if (message->FindInt32 ("raw_char", &raw_char) == B_OK) - { - if (raw_char == B_ENTER || raw_char == B_TAB) - { + if (message->FindInt32("raw_char", &raw_char) == B_OK) { + if (raw_char == B_ENTER || raw_char == B_TAB) { // printf ("ENTER or TAB\n"); *target = fHandler; } @@ -33,75 +34,78 @@ filter_result EnterFilter::Filter (BMessage *message, BHandler **target) return B_DISPATCH_MESSAGE; } -Dial::Dial (BRect frame, const char *name, int type, BMessage *msg) +Dial::Dial(BRect frame, const char* name, int type, BMessage* msg) { - get_click_speed (&dcspeed); + get_click_speed(&dcspeed); click = 1; tc = NULL; - strcpy (fName, name); + strcpy(fName, name); fType = type; } -Dial::~Dial () -{ - delete msg; -} +Dial::~Dial() { delete msg; } -void Dial::MouseDown (BPoint point) +void +Dial::MouseDown(BPoint point) { } -void Dial::Draw (BRect update) +void +Dial::Draw(BRect update) { - SetLowColor (LightGrey); - SetHighColor (DarkGrey); - FillRect (Bounds(), B_SOLID_LOW); - if (fType == DIAL_360) - { - StrokeEllipse (bounds) - } - else - { + SetLowColor(LightGrey); + SetHighColor(DarkGrey); + FillRect(Bounds(), B_SOLID_LOW); + if (fType == DIAL_360) { + StrokeEllipse(bounds) + } else { } } -void Dial::AttachedToWindow () +void +Dial::AttachedToWindow() { inherited::AttachedToWindow(); } -void Dial::MessageReceived (BMessage *msg) +void +Dial::MessageReceived(BMessage* msg) { } -void Dial::KeyDown (const char *bytes, int32 numBytes) +void +Dial::KeyDown(const char* bytes, int32 numBytes) { } -void Dial::MakeFocus (bool focused) +void +Dial::MakeFocus(bool focused) { - inherited::MakeFocus (focused); + inherited::MakeFocus(focused); Invalidate(); } -float Dial::Value () +float +Dial::Value() { return fValue; } -void Dial::SetValue (float _v) +void +Dial::SetValue(float _v) { fValue = _v; Invalidate(); } -void Dial::NotifyTarget () +void +Dial::NotifyTarget() { - BMessage *changed = new BMessage (fMsg); - changed->AddFloat ("value", value); - //printf ("%f\n", value); + BMessage* changed = new BMessage(fMsg); + changed->AddFloat("value", value); + // printf ("%f\n", value); Window()->Lock(); - Parent()->MessageReceived (changed); + Parent()->MessageReceived(changed); Window()->Unlock(); delete changed; } \ No newline at end of file diff --git a/source/Dial.h b/source/Dial.h index cee7dbe..6ec057f 100644 --- a/source/Dial.h +++ b/source/Dial.h @@ -7,33 +7,33 @@ #include #include -#define DIAL_90 90 +#define DIAL_90 90 #define DIAL_360 360 class IMPEXP Dial : public BView { -public: - Dial (BRect frame, const char *name, int type, BMessage *msg); - ~Dial (); -virtual void MouseDown (BPoint point); -virtual void Draw (BRect update); -virtual void AttachedToWindow (); -virtual void MessageReceived (BMessage *msg); -virtual void KeyDown (const char *bytes, int32 numBytes); -virtual void MakeFocus (bool focused = true); -float Value (); -void SetValue (float _v); + public: + Dial(BRect frame, const char* name, int type, BMessage* msg); + ~Dial(); + virtual void MouseDown(BPoint point); + virtual void Draw(BRect update); + virtual void AttachedToWindow(); + virtual void MessageReceived(BMessage* msg); + virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void MakeFocus(bool focused = true); + float Value(); + void SetValue(float _v); -private: -typedef BView inherited; -void NotifyTarget (); -BMessage *fMsg; -char fName[64]; -bigtime_t dcspeed; -int click; -BTextControl *tc; -float fValue; -int fType; + private: + typedef BView inherited; + void NotifyTarget(); + BMessage* fMsg; + char fName[64]; + bigtime_t dcspeed; + int click; + BTextControl* tc; + float fValue; + int fType; }; #endif \ No newline at end of file diff --git a/source/DragView.cpp b/source/DragView.cpp index e0104bb..2a09b11 100644 --- a/source/DragView.cpp +++ b/source/DragView.cpp @@ -4,64 +4,67 @@ const ulong _GO_AWAY = 0; const ulong _DRAG = 1; -long MouseThread(void* data); +long +MouseThread(void* data); -long MouseThread(void* data) { +long +MouseThread(void* data) +{ DragView* This = (DragView*)data; // Curly braces there due to a bug in mwcc (??) BRect goAwayRect; - if (This->orientation == 0) goAwayRect.Set(3,3,16,14); - else goAwayRect.Set(3,3,16,14); + if (This->orientation == 0) + goAwayRect.Set(3, 3, 16, 14); + else + goAwayRect.Set(3, 3, 16, 14); ulong mouseDown; BPoint where, old_where; - while(1) { + while (1) { // printf("Thread Resumed...\n"); This->Window()->Lock(); - This->GetMouse(&where,&mouseDown); - + This->GetMouse(&where, &mouseDown); + // If going away switch (This->mouse_status) { - case _GO_AWAY: - - while (mouseDown) { - This->GetMouse(&where,&mouseDown); - if (goAwayRect.Contains(where)) { - if (This->goAwayState == 1) { - This->goAwayState = 0; - This->Draw(goAwayRect); - } - } - else if (This->goAwayState != 1) { - This->goAwayState = 1; + case _GO_AWAY: + + while (mouseDown) { + This->GetMouse(&where, &mouseDown); + if (goAwayRect.Contains(where)) { + if (This->goAwayState == 1) { + This->goAwayState = 0; This->Draw(goAwayRect); } - snooze(20000); + } else if (This->goAwayState != 1) { + This->goAwayState = 1; + This->Draw(goAwayRect); } - break; - - case _DRAG: - - old_where = where; - while (mouseDown) { - This->GetMouse(&where, &mouseDown); - if (old_where != where) { - This->Window()->MoveBy(where.x - old_where.x, where.y - old_where.y); - This->Draw(BRect(0,0,15,13)); - BView *contents = This->NextSibling(); - if (contents) - { - contents->Draw (contents->Bounds()); - } + snooze(20000); + } + break; + + case _DRAG: + + old_where = where; + while (mouseDown) { + This->GetMouse(&where, &mouseDown); + if (old_where != where) { + This->Window()->MoveBy(where.x - old_where.x, where.y - old_where.y); + This->Draw(BRect(0, 0, 15, 13)); + BView* contents = This->NextSibling(); + if (contents) { + contents->Draw(contents->Bounds()); } - snooze(20000); } - break; + snooze(20000); + } + break; - default: - - break; + default: + + break; } This->Window()->Unlock(); if (This->goAwayState == 0) @@ -70,106 +73,120 @@ long MouseThread(void* data) { } } -DragView::DragView(BRect frame, const char* Title, int Orientation = DV_HORZ) +DragView::DragView(BRect frame, const char* Title, int Orientation = DV_HORZ) : BView(frame, Title, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW) { thMouseID = -1; active = 1; - - BRect goAwayRect(0,0,10,10); + + BRect goAwayRect(0, 0, 10, 10); goAwayUp = new BBitmap(goAwayRect, B_COLOR_8_BIT); goAwayDown = new BBitmap(goAwayRect, B_COLOR_8_BIT); - - goAwayUp->SetBits(goAway_raw,144,0,B_COLOR_8_BIT); - goAwayDown->SetBits(goAway_raw2,144,0,B_COLOR_8_BIT); + + goAwayUp->SetBits(goAway_raw, 144, 0, B_COLOR_8_BIT); + goAwayDown->SetBits(goAway_raw2, 144, 0, B_COLOR_8_BIT); orientation = Orientation; goAwayState = 1; } -DragView::~DragView() -{ - suspend_thread (thMouseID); -} +DragView::~DragView() { suspend_thread(thMouseID); } -void DragView::Draw(BRect updateRect) +void +DragView::Draw(BRect updateRect) { - #pragma unused (updateRect) - if (orientation == DV_HORZ) DrawHorz(); - else DrawVert(); +#pragma unused(updateRect) + if (orientation == DV_HORZ) + DrawHorz(); + else + DrawVert(); } -void DragView::DrawHorz() { +void +DragView::DrawHorz() +{ Window()->Lock(); - - rgb_color Gold = {255,203,0,255}; - rgb_color Yellow = {255,255,0,255}; - rgb_color DkGrey = {176,176,176,255}; - rgb_color LtGrey = {230,230,230,255}; + + rgb_color Gold = {255, 203, 0, 255}; + rgb_color Yellow = {255, 255, 0, 255}; + rgb_color DkGrey = {176, 176, 176, 255}; + rgb_color LtGrey = {230, 230, 230, 255}; BRect bounds; bounds = Bounds(); - + SetHighColor(Gold); - FillRect(BRect(1,1,bounds.right,bounds.bottom-4)); + FillRect(BRect(1, 1, bounds.right, bounds.bottom - 4)); - if (goAwayState == 1) DrawBitmap(goAwayUp, BPoint(0,1)); - else DrawBitmap(goAwayDown, BPoint(0,1)); + if (goAwayState == 1) + DrawBitmap(goAwayUp, BPoint(0, 1)); + else + DrawBitmap(goAwayDown, BPoint(0, 1)); SetHighColor(Yellow); - StrokeLine(BPoint(0,0), BPoint(bounds.right-1,0)); - StrokeLine(BPoint(0,1), BPoint(0,bounds.bottom-3)); + StrokeLine(BPoint(0, 0), BPoint(bounds.right - 1, 0)); + StrokeLine(BPoint(0, 1), BPoint(0, bounds.bottom - 3)); SetHighColor(LtGrey); - FillRect(BRect(0,bounds.bottom-3,bounds.right,bounds.bottom-1)); + FillRect(BRect(0, bounds.bottom - 3, bounds.right, bounds.bottom - 1)); SetHighColor(DkGrey); - StrokeLine(BPoint(0,bounds.bottom),BPoint(bounds.right,bounds.bottom)); + StrokeLine(BPoint(0, bounds.bottom), BPoint(bounds.right, bounds.bottom)); Window()->Unlock(); } -void DragView::DrawVert() { +void +DragView::DrawVert() +{ Window()->Lock(); - rgb_color Gold = {255,203,0}; - rgb_color Yellow = {255,255,0}; - rgb_color DkGrey = {176,176,176}; - rgb_color LtGrey = {230,230,230,0}; + rgb_color Gold = {255, 203, 0}; + rgb_color Yellow = {255, 255, 0}; + rgb_color DkGrey = {176, 176, 176}; + rgb_color LtGrey = {230, 230, 230, 0}; BRect bounds = Bounds(); SetHighColor(Gold); - FillRect(BRect(1,1,bounds.right-4,bounds.bottom)); + FillRect(BRect(1, 1, bounds.right - 4, bounds.bottom)); - if (goAwayState == 1) DrawBitmap(goAwayUp, BPoint(0,1)); - else DrawBitmap(goAwayDown, BPoint(0,1)); + if (goAwayState == 1) + DrawBitmap(goAwayUp, BPoint(0, 1)); + else + DrawBitmap(goAwayDown, BPoint(0, 1)); SetHighColor(Yellow); - StrokeLine(BPoint(0,0), BPoint(bounds.right-3,0)); - StrokeLine(BPoint(0,1), BPoint(0,bounds.bottom-1)); + StrokeLine(BPoint(0, 0), BPoint(bounds.right - 3, 0)); + StrokeLine(BPoint(0, 1), BPoint(0, bounds.bottom - 1)); SetHighColor(LtGrey); - FillRect(BRect(bounds.right-3,0,bounds.right-1,bounds.bottom)); + FillRect(BRect(bounds.right - 3, 0, bounds.right - 1, bounds.bottom)); SetHighColor(DkGrey); - StrokeLine(BPoint(bounds.right,0),BPoint(bounds.right,bounds.bottom)); + StrokeLine(BPoint(bounds.right, 0), BPoint(bounds.right, bounds.bottom)); Window()->Unlock(); } -void DragView::MouseDown(BPoint where) +void +DragView::MouseDown(BPoint where) { - BRect goAwayBounds; + BRect goAwayBounds; - if (orientation == 0) goAwayBounds.Set(3,3,16,14); - else goAwayBounds.Set(3,3,16,14); + if (orientation == 0) + goAwayBounds.Set(3, 3, 16, 14); + else + goAwayBounds.Set(3, 3, 16, 14); - if (thMouseID < 0) thMouseID = spawn_thread(MouseThread,"BecassoDVMC",B_DISPLAY_PRIORITY,(void*)this); + if (thMouseID < 0) + thMouseID = spawn_thread(MouseThread, "BecassoDVMC", B_DISPLAY_PRIORITY, (void*)this); // Set a flag for clicking in the goAway or the menuBar - if (goAwayBounds.Contains(where)) mouse_status = _GO_AWAY; - else mouse_status = _DRAG; - + if (goAwayBounds.Contains(where)) + mouse_status = _GO_AWAY; + else + mouse_status = _DRAG; + resume_thread(thMouseID); } \ No newline at end of file diff --git a/source/DragView.h b/source/DragView.h index 8968bf1..0ebe763 100644 --- a/source/DragView.h +++ b/source/DragView.h @@ -16,46 +16,45 @@ const int DV_HORZ = 0; const int DV_VERT = 1; -class DragView : public BView { -public: - DragView(BRect frame, - const char* name, - int Orientation); -virtual ~DragView(); -virtual void Draw(BRect updateRect); -virtual void DrawHorz(); -virtual void DrawVert(); - - BBitmap *goAwayUp; - BBitmap *goAwayDown; - ulong orientation; - int mouse_status; - int goAwayState; - int active; - thread_id thMouseID; - -virtual void MouseDown(BPoint where); -/* -virtual void WindowActivated(bool state); -virtual void AttachedToWindow(); -virtual void AllAttached(); -virtual void DetachedFromWindow(); -virtual void AllDetached(); - -virtual void AddChild(BView *aView); -virtual bool RemoveChild(BView *childView); - - -virtual void MouseMoved( BPoint where, - ulong code, - BMessage *a_message); -virtual void KeyDown(ulong aKey); -virtual void Pulse(); -virtual void FrameMoved(BPoint new_position); -virtual void FrameResized(float new_width, float new_height); -virtual void Show(); -virtual void Hide(); -*/ +class DragView : public BView +{ + public: + DragView(BRect frame, const char* name, int Orientation); + virtual ~DragView(); + virtual void Draw(BRect updateRect); + virtual void DrawHorz(); + virtual void DrawVert(); + + BBitmap* goAwayUp; + BBitmap* goAwayDown; + ulong orientation; + int mouse_status; + int goAwayState; + int active; + thread_id thMouseID; + + virtual void MouseDown(BPoint where); + /* + virtual void WindowActivated(bool state); + virtual void AttachedToWindow(); + virtual void AllAttached(); + virtual void DetachedFromWindow(); + virtual void AllDetached(); + + virtual void AddChild(BView *aView); + virtual bool RemoveChild(BView *childView); + + + virtual void MouseMoved( BPoint where, + ulong code, + BMessage *a_message); + virtual void KeyDown(ulong aKey); + virtual void Pulse(); + virtual void FrameMoved(BPoint new_position); + virtual void FrameResized(float new_width, float new_height); + virtual void Show(); + virtual void Hide(); + */ }; #endif diff --git a/source/DragWindow.h b/source/DragWindow.h index 073ff2c..ed49d48 100644 --- a/source/DragWindow.h +++ b/source/DragWindow.h @@ -8,39 +8,43 @@ class DragWindow : public BWindow { -public: - DragWindow (const char *kind, BRect frame, const char *title) - : BWindow (frame, title, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_WILL_ACCEPT_FIRST_CLICK | B_NOT_RESIZABLE | B_NOT_ZOOMABLE) - // Do not add B_AVOID_FOCUS since you then can't close it using the closer widget anymore - { - strcpy (fKind, kind); - } -virtual ~DragWindow () {} - -virtual bool QuitRequested () - { - SavePos (false); - return true; - } - -void SavePos (bool v = true) - { - BPoint origin = Frame().LeftTop(); - if (!strcmp (fKind, "modePU")) - set_window_origin (numModeTO, v ? origin : InvalidPoint); - else if (!strcmp (fKind, "toolPU")) - set_window_origin (numToolTO, v ? origin : InvalidPoint); - else if (!strcmp (fKind, "fg")) - set_window_origin (numFGColorTO, v ? origin : InvalidPoint); - else if (!strcmp (fKind, "bg")) - set_window_origin (numBGColorTO, v ? origin : InvalidPoint); - else if (!strcmp (fKind, "pat")) - set_window_origin (numPatternTO, v ? origin : InvalidPoint); - } - - -private: -char fKind[64]; + public: + DragWindow(const char* kind, BRect frame, const char* title) + : BWindow( + frame, title, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, + B_WILL_ACCEPT_FIRST_CLICK | B_NOT_RESIZABLE | B_NOT_ZOOMABLE + ) + // Do not add B_AVOID_FOCUS since you then can't close it using the closer widget anymore + { + strcpy(fKind, kind); + } + + virtual ~DragWindow() {} + + virtual bool QuitRequested() + { + SavePos(false); + return true; + } + + void SavePos(bool v = true) + { + BPoint origin = Frame().LeftTop(); + if (!strcmp(fKind, "modePU")) + set_window_origin(numModeTO, v ? origin : InvalidPoint); + else if (!strcmp(fKind, "toolPU")) + set_window_origin(numToolTO, v ? origin : InvalidPoint); + else if (!strcmp(fKind, "fg")) + set_window_origin(numFGColorTO, v ? origin : InvalidPoint); + else if (!strcmp(fKind, "bg")) + set_window_origin(numBGColorTO, v ? origin : InvalidPoint); + else if (!strcmp(fKind, "pat")) + set_window_origin(numPatternTO, v ? origin : InvalidPoint); + } + + + private: + char fKind[64]; }; #endif diff --git a/source/HSVSquare.cpp b/source/HSVSquare.cpp index 4f48e7b..8dba7ca 100644 --- a/source/HSVSquare.cpp +++ b/source/HSVSquare.cpp @@ -4,297 +4,278 @@ #include #include "BecassoAddOn.h" -HSVSquare::HSVSquare (BRect frame, ColorWindow *ed) -: BView (frame, "RGBSquare", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW) +HSVSquare::HSVSquare(BRect frame, ColorWindow* ed) + : BView(frame, "RGBSquare", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW) { - SetViewColor (B_TRANSPARENT_32_BIT); + SetViewColor(B_TRANSPARENT_32_BIT); color_space cs = B_RGB32; { BScreen screen; if (screen.ColorSpace() == B_COLOR_8_BIT) cs = B_COLOR_8_BIT; } - colorsquare = new BBitmap (BRect (0, 0, 255, 255), cs); - colorcol = new BBitmap (BRect (0, 0, 31, 255), cs); + colorsquare = new BBitmap(BRect(0, 0, 255, 255), cs); + colorcol = new BBitmap(BRect(0, 0, 31, 255), cs); editor = ed; prevy = -1; for (int x = -127; x <= 128; x++) - for (int y = -127; y <= 128; y++) - { - if (x*x + y*y < 16129 && (x || y)) - { - float hue = atan2 (x, y)/M_PI*180 - 90; + for (int y = -127; y <= 128; y++) { + if (x * x + y * y < 16129 && (x || y)) { + float hue = atan2(x, y) / M_PI * 180 - 90; if (hue < 0) hue += 360; hs[y + 127][x + 127][0] = hue; - hs[y + 127][x + 127][1] = sqrt (x*x + y*y)/127; - } - else if (!x && !y) + hs[y + 127][x + 127][1] = sqrt(x * x + y * y) / 127; + } else if (!x && !y) hs[y + 127][x + 127][0] = -1; else hs[y + 127][x + 127][0] = -2; } - + prev = B_ORIGIN; clicks = 0; fFirst = true; } -HSVSquare::~HSVSquare () +HSVSquare::~HSVSquare() { delete colorsquare; delete colorcol; } -void HSVSquare::AttachedToWindow () +void +HSVSquare::AttachedToWindow() { for (int s = 0; s < 256; s++) - for (int x = 0; x < 32; x++) - { + for (int x = 0; x < 32; x++) { col[s][x][0] = s; col[s][x][1] = s; col[s][x][2] = s; } - colorcol->SetBits (col, 256*32*3, 0, B_RGB32); + colorcol->SetBits(col, 256 * 32 * 3, 0, B_RGB32); currentHSV.value = 0.5; - SetColor (rgb2hsv (editor->rgb())); + SetColor(rgb2hsv(editor->rgb())); inherited::AttachedToWindow(); } -void HSVSquare::ScreenChanged (BRect /* frame */, color_space cs) +void +HSVSquare::ScreenChanged(BRect /* frame */, color_space cs) { // Note: Only changes from 8 <-> {16, 32} are interesting. // 16 bit screens won't use dithering. - if (colorsquare->ColorSpace() == B_COLOR_8_BIT && cs != B_COLOR_8_BIT) - { + if (colorsquare->ColorSpace() == B_COLOR_8_BIT && cs != B_COLOR_8_BIT) { delete colorsquare; delete colorcol; - colorsquare = new BBitmap (BRect (0, 0, 255, 255), B_RGB32); - colorcol = new BBitmap (BRect (0, 0, 31, 255), B_RGB32); + colorsquare = new BBitmap(BRect(0, 0, 255, 255), B_RGB32); + colorcol = new BBitmap(BRect(0, 0, 31, 255), B_RGB32); AttachedToWindow(); Invalidate(); - } - else if (colorsquare->ColorSpace() != B_COLOR_8_BIT && cs == B_COLOR_8_BIT) - { + } else if (colorsquare->ColorSpace() != B_COLOR_8_BIT && cs == B_COLOR_8_BIT) { delete colorsquare; delete colorcol; - colorsquare = new BBitmap (BRect (0, 0, 255, 255), B_COLOR_8_BIT); - colorcol = new BBitmap (BRect (0, 0, 31, 255), B_COLOR_8_BIT); + colorsquare = new BBitmap(BRect(0, 0, 255, 255), B_COLOR_8_BIT); + colorcol = new BBitmap(BRect(0, 0, 31, 255), B_COLOR_8_BIT); AttachedToWindow(); Invalidate(); } } -void HSVSquare::DrawLines () +void +HSVSquare::DrawLines() { - SetDrawingMode (B_OP_COPY); - SetHighColor (Red); - StrokeLine (BPoint (0, currentHSV.value*255), BPoint (31, currentHSV.value*255)); - SetDrawingMode (B_OP_INVERT); - float x = 40 + 127 + 127*currentHSV.saturation*cos (currentHSV.hue*M_PI/180); - float y = 127 - 127*currentHSV.saturation*sin (currentHSV.hue*M_PI/180); - StrokeEllipse (BPoint (x, y), 3, 3); + SetDrawingMode(B_OP_COPY); + SetHighColor(Red); + StrokeLine(BPoint(0, currentHSV.value * 255), BPoint(31, currentHSV.value * 255)); + SetDrawingMode(B_OP_INVERT); + float x = 40 + 127 + 127 * currentHSV.saturation * cos(currentHSV.hue * M_PI / 180); + float y = 127 - 127 * currentHSV.saturation * sin(currentHSV.hue * M_PI / 180); + StrokeEllipse(BPoint(x, y), 3, 3); } -void HSVSquare::Draw (BRect /* update */) +void +HSVSquare::Draw(BRect /* update */) { BRect middle, right; - middle.Set (32, 0, 39, 256); - right.Set (295, 0, Bounds().Width(), 256); - SetDrawingMode (B_OP_COPY); - DrawBitmapAsync (colorsquare, BPoint (40, 0)); - DrawBitmap (colorcol, BPoint (0, 0)); - SetHighColor (LightGrey); - FillRect (middle); - FillRect (right); + middle.Set(32, 0, 39, 256); + right.Set(295, 0, Bounds().Width(), 256); + SetDrawingMode(B_OP_COPY); + DrawBitmapAsync(colorsquare, BPoint(40, 0)); + DrawBitmap(colorcol, BPoint(0, 0)); + SetHighColor(LightGrey); + FillRect(middle); + FillRect(right); Sync(); DrawLines(); } -void HSVSquare::MouseDown (BPoint point) +void +HSVSquare::MouseDown(BPoint point) { if (point == prev) clicks++; else clicks = 0; prev = point; - - if (clicks > 1) - { + + if (clicks > 1) { uint32 buttons; - GetMouse (&point, &buttons); // flush the buffer - if (buttons & B_PRIMARY_MOUSE_BUTTON) - { - BMessage set ('CXSm'); - Window()->PostMessage (&set); + GetMouse(&point, &buttons); // flush the buffer + if (buttons & B_PRIMARY_MOUSE_BUTTON) { + BMessage set('CXSm'); + Window()->PostMessage(&set); } - if (buttons & B_SECONDARY_MOUSE_BUTTON) - { - BMessage set ('CXSc'); - Window()->PostMessage (&set); + if (buttons & B_SECONDARY_MOUSE_BUTTON) { + BMessage set('CXSc'); + Window()->PostMessage(&set); } - } - else - { - thread_id id = spawn_thread (HSV_track_mouse, "HSV tracker", B_DISPLAY_PRIORITY, this); - resume_thread (id); + } else { + thread_id id = spawn_thread(HSV_track_mouse, "HSV tracker", B_DISPLAY_PRIORITY, this); + resume_thread(id); } } -void HSVSquare::mouseDown (BPoint point, int ob) +void +HSVSquare::mouseDown(BPoint point, int ob) { float x = point.x - 127 - 40; float y = point.y - 127; - - if (ob == 1) - { - if (prevy != point.y) - { + + if (ob == 1) { + if (prevy != point.y) { DrawLines(); hsv_color newc; newc.hue = currentHSV.hue; newc.saturation = currentHSV.saturation; - newc.value = clipone (point.y/255); - BMessage *msg = new BMessage ('CSQh'); - msg->AddFloat ("color", newc.hue); - msg->AddFloat ("color", newc.saturation); - msg->AddFloat ("color", newc.value); - Window()->PostMessage (msg); + newc.value = clipone(point.y / 255); + BMessage* msg = new BMessage('CSQh'); + msg->AddFloat("color", newc.hue); + msg->AddFloat("color", newc.saturation); + msg->AddFloat("color", newc.value); + Window()->PostMessage(msg); delete msg; - SetColor (newc); + SetColor(newc); DrawLines(); } prevy = point.y; - } - else if (ob == 2) - { - if (x == 0 && y == 0) - { + } else if (ob == 2) { + if (x == 0 && y == 0) { DrawLines(); currentHSV.hue = HUE_UNDEF; currentHSV.saturation = 0; DrawLines(); - BMessage *msg = new BMessage ('CSQh'); - msg->AddFloat ("color", currentHSV.hue); - msg->AddFloat ("color", currentHSV.saturation); - msg->AddFloat ("color", currentHSV.value); - Window()->PostMessage (msg); + BMessage* msg = new BMessage('CSQh'); + msg->AddFloat("color", currentHSV.hue); + msg->AddFloat("color", currentHSV.saturation); + msg->AddFloat("color", currentHSV.value); + Window()->PostMessage(msg); delete msg; - } - else - { + } else { DrawLines(); - currentHSV.hue = clipdegr (atan2 (x, y)/M_PI*180 - 90); - currentHSV.saturation = clipone (sqrt (x*x + y*y)/127); + currentHSV.hue = clipdegr(atan2(x, y) / M_PI * 180 - 90); + currentHSV.saturation = clipone(sqrt(x * x + y * y) / 127); DrawLines(); - BMessage *msg = new BMessage ('CSQh'); - msg->AddFloat ("color", currentHSV.hue); - msg->AddFloat ("color", currentHSV.saturation); - msg->AddFloat ("color", currentHSV.value); - Window()->PostMessage (msg); + BMessage* msg = new BMessage('CSQh'); + msg->AddFloat("color", currentHSV.hue); + msg->AddFloat("color", currentHSV.saturation); + msg->AddFloat("color", currentHSV.value); + Window()->PostMessage(msg); delete msg; } } } -int32 HSV_track_mouse (void *data) +int32 +HSV_track_mouse(void* data) { - BRect colRect = BRect (0, 0, 31, 255); - BRect squareRect = BRect (40, 0, 295, 255); - BMessage *msg; - HSVSquare *obj = (HSVSquare *)data; + BRect colRect = BRect(0, 0, 31, 255); + BRect squareRect = BRect(40, 0, 295, 255); + BMessage* msg; + HSVSquare* obj = (HSVSquare*)data; uint32 buttons; BPoint point; - BPoint prev = BPoint (-1, -1); + BPoint prev = BPoint(-1, -1); obj->Window()->Lock(); - obj->GetMouse (&point, &buttons, true); - if (colRect.Contains (point)) - { - msg = new BMessage ('HSVc'); - obj->Window()->PostMessage (msg); + obj->GetMouse(&point, &buttons, true); + if (colRect.Contains(point)) { + msg = new BMessage('HSVc'); + obj->Window()->PostMessage(msg); delete msg; - } - else if (squareRect.Contains (point)) - { + } else if (squareRect.Contains(point)) { float x = point.x - 127 - 40; float y = point.y - 127; - if (x*x + y*y < 16129) - { - msg = new BMessage ('HSVs'); - obj->Window()->PostMessage (msg); + if (x * x + y * y < 16129) { + msg = new BMessage('HSVs'); + obj->Window()->PostMessage(msg); delete msg; } } - while (buttons) - { - if (prev != point) - { - msg = new BMessage ('HSVm'); - msg->AddFloat ("x", point.x); - msg->AddFloat ("y", point.y); - obj->Window()->PostMessage (msg); + while (buttons) { + if (prev != point) { + msg = new BMessage('HSVm'); + msg->AddFloat("x", point.x); + msg->AddFloat("y", point.y); + obj->Window()->PostMessage(msg); delete msg; prev = point; } obj->Window()->Unlock(); - snooze (50000); + snooze(50000); obj->Window()->Lock(); - obj->GetMouse (&point, &buttons, true); + obj->GetMouse(&point, &buttons, true); } - msg = new BMessage ('HSVu'); - obj->Window()->PostMessage (msg); + msg = new BMessage('HSVu'); + obj->Window()->PostMessage(msg); delete msg; obj->Window()->Unlock(); return 0; } -void HSVSquare::SetColor (rgb_color c) +void +HSVSquare::SetColor(rgb_color c) { - SetColor (rgb2hsv (c)); + SetColor(rgb2hsv(c)); } -void HSVSquare::SetColor (hsv_color h) +void +HSVSquare::SetColor(hsv_color h) { float value = currentHSV.value; currentHSV = h; - current = hsv2rgb (h); - if (value != currentHSV.value) - { + current = hsv2rgb(h); + if (value != currentHSV.value) { for (int x = -127; x <= 128; x++) - for (int y = -127; y <= 128; y++) - { - if (hs[y + 127][x + 127][0] >= 0) - { + for (int y = -127; y <= 128; y++) { + if (hs[y + 127][x + 127][0] >= 0) { hsv_color c; c.hue = hs[y + 127][x + 127][0]; c.saturation = hs[y + 127][x + 127][1]; c.value = currentHSV.value; - rgb_color d = hsv2rgb (c); + rgb_color d = hsv2rgb(c); square[y + 127][x + 127][0] = d.red; square[y + 127][x + 127][1] = d.green; square[y + 127][x + 127][2] = d.blue; - } - else - { + } else { square[y + 127][x + 127][0] = LightGrey.red; square[y + 127][x + 127][1] = LightGrey.green; square[y + 127][x + 127][2] = LightGrey.blue; } - square[127][127][0] = uint8 (currentHSV.value*255); - square[127][127][1] = uint8 (currentHSV.value*255); - square[127][127][2] = uint8 (currentHSV.value*255); + square[127][127][0] = uint8(currentHSV.value * 255); + square[127][127][1] = uint8(currentHSV.value * 255); + square[127][127][2] = uint8(currentHSV.value * 255); } - colorsquare->SetBits (square, 256*256*3, 0, B_RGB32); + colorsquare->SetBits(square, 256 * 256 * 3, 0, B_RGB32); } Invalidate(); } -rgb_color HSVSquare::GetColor () +rgb_color +HSVSquare::GetColor() { return current; } -hsv_color HSVSquare::GetColorHSV () +hsv_color +HSVSquare::GetColorHSV() { return currentHSV; } diff --git a/source/HSVSquare.h b/source/HSVSquare.h index 2ac860c..fbb6014 100644 --- a/source/HSVSquare.h +++ b/source/HSVSquare.h @@ -9,37 +9,38 @@ class HSVSquare : public BView { -public: - HSVSquare (BRect frame, ColorWindow *ed); -virtual ~HSVSquare (); -virtual void Draw (BRect update); -virtual void MouseDown (BPoint point); -virtual void mouseDown (BPoint point, int ob); -virtual void AttachedToWindow (); -virtual void ScreenChanged (BRect frame, color_space cs); -void SetColor (rgb_color c); -void SetColor (hsv_color c); -rgb_color GetColor (); -hsv_color GetColorHSV (); + public: + HSVSquare(BRect frame, ColorWindow* ed); + virtual ~HSVSquare(); + virtual void Draw(BRect update); + virtual void MouseDown(BPoint point); + virtual void mouseDown(BPoint point, int ob); + virtual void AttachedToWindow(); + virtual void ScreenChanged(BRect frame, color_space cs); + void SetColor(rgb_color c); + void SetColor(hsv_color c); + rgb_color GetColor(); + hsv_color GetColorHSV(); -private: -typedef BView inherited; -void DrawLines(); -BBitmap *colorsquare; -BBitmap *colorcol; -uchar square[256][256][3]; -float hs[256][256][2]; -uchar col[256][32][3]; -rgb_color current; -hsv_color currentHSV; -int notcolor; -class ColorWindow *editor; -float prevy; -int clicks; -BPoint prev; -bool fFirst; + private: + typedef BView inherited; + void DrawLines(); + BBitmap* colorsquare; + BBitmap* colorcol; + uchar square[256][256][3]; + float hs[256][256][2]; + uchar col[256][32][3]; + rgb_color current; + hsv_color currentHSV; + int notcolor; + class ColorWindow* editor; + float prevy; + int clicks; + BPoint prev; + bool fFirst; }; -int32 HSV_track_mouse (void *data); +int32 +HSV_track_mouse(void* data); -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/HelpView.cpp b/source/HelpView.cpp index cc871fa..c9fa0f2 100644 --- a/source/HelpView.cpp +++ b/source/HelpView.cpp @@ -1,33 +1,34 @@ #include "HelpView.h" #include -HelpView::HelpView (const BRect frame, const char *name) -: BView (frame, name, B_FOLLOW_LEFT, B_WILL_DRAW) +HelpView::HelpView(const BRect frame, const char* name) + : BView(frame, name, B_FOLLOW_LEFT, B_WILL_DRAW) { - SetViewColor (B_TRANSPARENT_32_BIT); - SetFont (be_plain_font); - SetFontSize (10); + SetViewColor(B_TRANSPARENT_32_BIT); + SetFont(be_plain_font); + SetFontSize(10); } -void HelpView::Draw (BRect /* updaterect */) +void +HelpView::Draw(BRect /* updaterect */) { -// printf ("HelpView::Draw\n"); - SetLowColor (LightGrey); - SetHighColor (DarkGrey); - FillRect (Bounds(), B_SOLID_LOW); - StrokeLine (Bounds().LeftBottom(), Bounds().RightBottom()); - SetHighColor (Grey30); - StrokeLine (Bounds().LeftBottom() + BPoint (0, -2), Bounds().LeftTop()); - StrokeLine (Bounds().RightTop()); - SetHighColor (Grey24); - StrokeLine (Bounds().LeftBottom() + BPoint (0, -1), - Bounds().RightBottom() + BPoint (0, -1)); - SetHighColor (Grey10); - DrawString (text, BPoint (Bounds().Width() - StringWidth (text) - 4, 13)); + // printf ("HelpView::Draw\n"); + SetLowColor(LightGrey); + SetHighColor(DarkGrey); + FillRect(Bounds(), B_SOLID_LOW); + StrokeLine(Bounds().LeftBottom(), Bounds().RightBottom()); + SetHighColor(Grey30); + StrokeLine(Bounds().LeftBottom() + BPoint(0, -2), Bounds().LeftTop()); + StrokeLine(Bounds().RightTop()); + SetHighColor(Grey24); + StrokeLine(Bounds().LeftBottom() + BPoint(0, -1), Bounds().RightBottom() + BPoint(0, -1)); + SetHighColor(Grey10); + DrawString(text, BPoint(Bounds().Width() - StringWidth(text) - 4, 13)); } -void HelpView::setText (const char *t) +void +HelpView::setText(const char* t) { - strcpy (text, t); + strcpy(text, t); Invalidate(); } diff --git a/source/HelpView.h b/source/HelpView.h index e94120b..5014991 100644 --- a/source/HelpView.h +++ b/source/HelpView.h @@ -11,15 +11,15 @@ class HelpView : public BView { -public: - HelpView (const BRect frame, const char *name); -virtual void Draw (BRect updaterect); + public: + HelpView(const BRect frame, const char* name); + virtual void Draw(BRect updaterect); -void setText (const char *t); + void setText(const char* t); -private: -typedef BView inherited; -char text[MAX_HLPNAME]; + private: + typedef BView inherited; + char text[MAX_HLPNAME]; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/Ideas.h b/source/Ideas.h index a791a49..75cfc9a 100644 --- a/source/Ideas.h +++ b/source/Ideas.h @@ -149,7 +149,8 @@ BUGS IN 1.3: * Revisited all the translators * Fixed problem with Gobe translators -* Some new strings (6, 7, 8, 4, 108, 305, 306, 400, 401, 403, 404, 116), as well as fixing some forgotten ones +* Some new strings (6, 7, 8, 4, 108, 305, 306, 400, 401, 403, 404, 116), as well as fixing some +forgotten ones * Moved Translate/Rotate to Layers menu * Added Flip Horizontal/Vertical * Added Resize To… @@ -256,7 +257,7 @@ TODO/IDEAS * Drops to ShowImage? * Scripting documentation (command strings) * Document Gobe Productive external editing -* IMPORTANT NOTE: When burning a CD-ROM, make sure its volume name is BECASSO and +* IMPORTANT NOTE: When burning a CD-ROM, make sure its volume name is BECASSO and it contains a file README (the registration checks for that). * Color Editor window too large for small screen * Crash when using tools in Generator mode @@ -265,7 +266,7 @@ TODO/IDEAS * ADDON_RESIZE * -mpentium compilation flag default? * NOTE: File loading routines in three places: CanvasView, BitmapStuff and Translator. -* Pre-render and cache all layers below and above (separately) the current layer for +* Pre-render and cache all layers below and above (separately) the current layer for quicker updates during editing * Dragging a selection can crash? <--- * Ability to track lines or polygons with the brush tool (Christian Wulff) diff --git a/source/Layer.cpp b/source/Layer.cpp index 8d1bf6b..9b0fd68 100644 --- a/source/Layer.cpp +++ b/source/Layer.cpp @@ -4,48 +4,46 @@ #include #include -Layer::Layer (BRect bounds, const char *name) -: BBitmap (bounds, B_BITMAP_ACCEPTS_VIEWS, B_RGBA32) +Layer::Layer(BRect bounds, const char* name) : BBitmap(bounds, B_BITMAP_ACCEPTS_VIEWS, B_RGBA32) { fRect = bounds; fMode = DM_BLEND; fHide = false; - strcpy (fName, name); + strcpy(fName, name); fGlobalAlpha = 255; fAlphaMap = NULL; - bzero (Bits(), BitsLength()); -// uint32 *bits = ((uint32 *) Bits()) - 1; -// for (uint32 i = 0; i < BitsLength()/4; i++) -// *(++bits) = COLOR_MASK; + bzero(Bits(), BitsLength()); + // uint32 *bits = ((uint32 *) Bits()) - 1; + // for (uint32 i = 0; i < BitsLength()/4; i++) + // *(++bits) = COLOR_MASK; } -Layer::Layer (const Layer& layer) -: BBitmap (layer.fRect, B_BITMAP_ACCEPTS_VIEWS, B_RGBA32) +Layer::Layer(const Layer& layer) : BBitmap(layer.fRect, B_BITMAP_ACCEPTS_VIEWS, B_RGBA32) { fRect = layer.fRect; fMode = layer.fMode; fHide = layer.fHide; - strcpy (fName, layer.fName); + strcpy(fName, layer.fName); fGlobalAlpha = layer.fGlobalAlpha; fAlphaMap = NULL; - bzero (Bits(), BitsLength()); -// uint32 *bits = ((uint32 *) Bits()) - 1; -// for (uint32 i = 0; i < BitsLength()/4; i++) -// *(++bits) = COLOR_MASK; + bzero(Bits(), BitsLength()); + // uint32 *bits = ((uint32 *) Bits()) - 1; + // for (uint32 i = 0; i < BitsLength()/4; i++) + // *(++bits) = COLOR_MASK; } -Layer::~Layer () -{ -} +Layer::~Layer() {} -void Layer::setName (const char *name) +void +Layer::setName(const char* name) { - strcpy (fName, name); + strcpy(fName, name); } -void Layer::ClearTo (bgra_pixel p) +void +Layer::ClearTo(bgra_pixel p) { - bgra_pixel *d = (bgra_pixel *) Bits() - 1; - for (int32 i = 0; i < BitsLength()/4; i++) + bgra_pixel* d = (bgra_pixel*)Bits() - 1; + for (int32 i = 0; i < BitsLength() / 4; i++) *(++d) = p; } diff --git a/source/Layer.h b/source/Layer.h index 0c5516a..3db7644 100644 --- a/source/Layer.h +++ b/source/Layer.h @@ -12,31 +12,43 @@ class IMPEXP Layer : public BBitmap { -public: - Layer (BRect bounds, const char *name); - Layer (const Layer& layer); -virtual ~Layer (); -int getMode () { return fMode; }; -void setMode (const int mode) { fMode = mode; }; -char *getName () { return fName; }; -void setName (const char *name); -uchar getGlobalAlpha () { return fGlobalAlpha; }; -void setGlobalAlpha (const uchar a) { fGlobalAlpha = a; }; -BBitmap *getAlphaMap () { return fAlphaMap; }; -void setAlphaMap (BBitmap *a) { fAlphaMap = a; }; -BRect Bounds () { return fRect; }; -void Hide (bool h) { fHide = h; }; -bool IsHidden () { return fHide; }; -void ClearTo (bgra_pixel p); - -private: -typedef BBitmap inherited; -BBitmap *fAlphaMap; -uchar fGlobalAlpha; -BRect fRect; -int fMode; -bool fHide; -char fName[MAXLAYERNAME]; + public: + Layer(BRect bounds, const char* name); + Layer(const Layer& layer); + virtual ~Layer(); + + int getMode() { return fMode; }; + + void setMode(const int mode) { fMode = mode; }; + + char* getName() { return fName; }; + + void setName(const char* name); + + uchar getGlobalAlpha() { return fGlobalAlpha; }; + + void setGlobalAlpha(const uchar a) { fGlobalAlpha = a; }; + + BBitmap* getAlphaMap() { return fAlphaMap; }; + + void setAlphaMap(BBitmap* a) { fAlphaMap = a; }; + + BRect Bounds() { return fRect; }; + + void Hide(bool h) { fHide = h; }; + + bool IsHidden() { return fHide; }; + + void ClearTo(bgra_pixel p); + + private: + typedef BBitmap inherited; + BBitmap* fAlphaMap; + uchar fGlobalAlpha; + BRect fRect; + int fMode; + bool fHide; + char fName[MAXLAYERNAME]; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/LayerItem.cpp b/source/LayerItem.cpp index fcd7fd4..b2d834c 100644 --- a/source/LayerItem.cpp +++ b/source/LayerItem.cpp @@ -8,314 +8,308 @@ #include #include "Settings.h" - -LayerItem::LayerItem (BRect frame, const char *name, int layerIndex, CanvasView *_myView) -: BView (frame, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS) +LayerItem::LayerItem(BRect frame, const char* name, int layerIndex, CanvasView* _myView) + : BView(frame, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS) { index = layerIndex; fMyView = _myView; - fLayer = fMyView->getLayer (index); + fLayer = fMyView->getLayer(index); BRect canvasRect = fMyView->canvasFrame(); - BMessage *msg = new BMessage ('cbHd'); - msg->AddInt32 ("index", index); - fThumbVSize = min_c (THUMBLAYERMAXHEIGHT, canvasRect.Height()); - fThumbHSize = min_c (canvasRect.Width()/canvasRect.Height() * fThumbVSize, THUMBLAYERMAXWIDTH); - hide = new BCheckBox (BRect (fThumbHSize + 8, 2, fThumbHSize + 50, 24), "hide", lstring (164, "Hide"), msg); - AddChild (hide); - hide->SetTarget (fMyView->Window()); + BMessage* msg = new BMessage('cbHd'); + msg->AddInt32("index", index); + fThumbVSize = min_c(THUMBLAYERMAXHEIGHT, canvasRect.Height()); + fThumbHSize = min_c(canvasRect.Width() / canvasRect.Height() * fThumbVSize, THUMBLAYERMAXWIDTH); + hide = new BCheckBox( + BRect(fThumbHSize + 8, 2, fThumbHSize + 50, 24), "hide", lstring(164, "Hide"), msg + ); + AddChild(hide); + hide->SetTarget(fMyView->Window()); // hide->SetDrawingMode (B_OP_OVER); - hide->SetValue (fLayer->IsHidden()); - msg = new BMessage ('LIga'); - msg->AddInt32 ("index", index); - Slider *ga = new Slider (BRect (fThumbHSize + 54, 4, LAYERITEMWIDTH - 4, 20), 0, "", 0, 255, 1, msg, B_HORIZONTAL); - ga->SetValue (fLayer->getGlobalAlpha()); - AddChild (ga); - SetHighColor (Black); + hide->SetValue(fLayer->IsHidden()); + msg = new BMessage('LIga'); + msg->AddInt32("index", index); + Slider* ga = new Slider( + BRect(fThumbHSize + 54, 4, LAYERITEMWIDTH - 4, 20), 0, "", 0, 255, 1, msg, B_HORIZONTAL + ); + ga->SetValue(fLayer->getGlobalAlpha()); + AddChild(ga); + SetHighColor(Black); if (index == fMyView->currentLayerIndex()) - SetLowColor (DarkGrey); - else - SetLowColor (LightGrey); - SetViewColor (LowColor()); - hide->SetViewColor (LowColor()); - fModePU = new BPopUpMenu (""); - msg = new BMessage ('DMch'); - msg->AddInt32 ("index", index); - msg->AddInt32 ("newmode", DM_BLEND); - BMenuItem *item = new BMenuItem (lstring (165, "Blend"), msg); - item->SetTarget (fMyView->Window()); - fModePU->AddItem (item); - msg = new BMessage ('DMch'); - msg->AddInt32 ("index", index); - msg->AddInt32 ("newmode", DM_MULTIPLY); - item = new BMenuItem (lstring (166, "Multiply"), msg); - item->SetTarget (fMyView->Window()); - fModePU->AddItem (item); - BMenuField *mode = new BMenuField (BRect (fThumbHSize + 8, 22, fThumbHSize + 140, 34), "mode", lstring (167, "Operation:"), fModePU); - fModePU->ItemAt(fLayer->getMode())->SetMarked (true); - mode->SetDivider (58); - AddChild (mode); + SetLowColor(DarkGrey); + else + SetLowColor(LightGrey); + SetViewColor(LowColor()); + hide->SetViewColor(LowColor()); + fModePU = new BPopUpMenu(""); + msg = new BMessage('DMch'); + msg->AddInt32("index", index); + msg->AddInt32("newmode", DM_BLEND); + BMenuItem* item = new BMenuItem(lstring(165, "Blend"), msg); + item->SetTarget(fMyView->Window()); + fModePU->AddItem(item); + msg = new BMessage('DMch'); + msg->AddInt32("index", index); + msg->AddInt32("newmode", DM_MULTIPLY); + item = new BMenuItem(lstring(166, "Multiply"), msg); + item->SetTarget(fMyView->Window()); + fModePU->AddItem(item); + BMenuField* mode = new BMenuField( + BRect(fThumbHSize + 8, 22, fThumbHSize + 140, 34), "mode", lstring(167, "Operation:"), + fModePU + ); + fModePU->ItemAt(fLayer->getMode())->SetMarked(true); + mode->SetDivider(58); + AddChild(mode); click = 1; - get_click_speed (&dcspeed); + get_click_speed(&dcspeed); } -LayerItem::~LayerItem () -{ -} +LayerItem::~LayerItem() {} -void LayerItem::Refresh (Layer *layer) +void +LayerItem::Refresh(Layer* layer) { fLayer = layer; DrawThumbOnly(); } -void LayerItem::MouseMoved (BPoint point, uint32 transit, const BMessage *message) +void +LayerItem::MouseMoved(BPoint point, uint32 transit, const BMessage* message) { - if (message && message->what == 'ldrg') - { - int16 to = int16 (point.y/LAYERITEMHEIGHT + 0.5); - if (transit == B_EXITED_VIEW) - { - SetHighColor (Black); - StrokeLine (Bounds().LeftTop(), Bounds().RightTop()); - StrokeLine (Bounds().LeftBottom(), Bounds().RightBottom()); - } - else if (to == 0) - { - SetHighColor (Blue); - StrokeLine (Bounds().LeftTop(), Bounds().RightTop()); - SetHighColor (Black); - StrokeLine (Bounds().LeftBottom(), Bounds().RightBottom()); - } - else - { - SetHighColor (Black); - StrokeLine (Bounds().LeftTop(), Bounds().RightTop()); - SetHighColor (Blue); - StrokeLine (Bounds().LeftBottom(), Bounds().RightBottom()); + if (message && message->what == 'ldrg') { + int16 to = int16(point.y / LAYERITEMHEIGHT + 0.5); + if (transit == B_EXITED_VIEW) { + SetHighColor(Black); + StrokeLine(Bounds().LeftTop(), Bounds().RightTop()); + StrokeLine(Bounds().LeftBottom(), Bounds().RightBottom()); + } else if (to == 0) { + SetHighColor(Blue); + StrokeLine(Bounds().LeftTop(), Bounds().RightTop()); + SetHighColor(Black); + StrokeLine(Bounds().LeftBottom(), Bounds().RightBottom()); + } else { + SetHighColor(Black); + StrokeLine(Bounds().LeftTop(), Bounds().RightTop()); + SetHighColor(Blue); + StrokeLine(Bounds().LeftBottom(), Bounds().RightBottom()); } Window()->UpdateIfNeeded(); } } -void LayerItem::select (bool sel) +void +LayerItem::select(bool sel) { - SetLowColor (sel ? DarkGrey : LightGrey); - SetViewColor (sel ? DarkGrey : LightGrey); - Draw (Bounds()); - for (int i = 0; i < CountChildren(); i++) - { - BView *v = ChildAt (i); - v->SetLowColor (sel ? DarkGrey : LightGrey); - v->SetViewColor (sel ? DarkGrey : LightGrey); - v->FillRect (Bounds(), B_SOLID_LOW); - v->Draw (Bounds()); - for (int j = 0; j < v->CountChildren(); j++) - { - v->ChildAt(j)->SetLowColor (sel ? DarkGrey : LightGrey); - v->ChildAt(j)->Draw (Bounds()); + SetLowColor(sel ? DarkGrey : LightGrey); + SetViewColor(sel ? DarkGrey : LightGrey); + Draw(Bounds()); + for (int i = 0; i < CountChildren(); i++) { + BView* v = ChildAt(i); + v->SetLowColor(sel ? DarkGrey : LightGrey); + v->SetViewColor(sel ? DarkGrey : LightGrey); + v->FillRect(Bounds(), B_SOLID_LOW); + v->Draw(Bounds()); + for (int j = 0; j < v->CountChildren(); j++) { + v->ChildAt(j)->SetLowColor(sel ? DarkGrey : LightGrey); + v->ChildAt(j)->Draw(Bounds()); } } Sync(); } -void LayerItem::MouseDown (BPoint point) +void +LayerItem::MouseDown(BPoint point) { -// extern Becasso *mainapp; - uint32 buttons = Window()->CurrentMessage()->FindInt32 ("buttons"); -// BPoint prevpoint = point; -// uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); - if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) - { + // extern Becasso *mainapp; + uint32 buttons = Window()->CurrentMessage()->FindInt32("buttons"); + // BPoint prevpoint = point; + // uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); + if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) { // Immediate feedback: Draw selected state - select (true); - if (LayerView *lv = dynamic_cast (Parent())) - { - LayerItem *sibling = lv->getLayerItem (fMyView->currentLayerIndex()); - sibling->select (false); + select(true); + if (LayerView* lv = dynamic_cast(Parent())) { + LayerItem* sibling = lv->getLayerItem(fMyView->currentLayerIndex()); + sibling->select(false); } - BMessage msg ('lSel'); - msg.AddInt32 ("index", index); - fMyView->Window()->PostMessage (&msg); - + BMessage msg('lSel'); + msg.AddInt32("index", index); + fMyView->Window()->PostMessage(&msg); + BPoint bp, pbp; uint32 bt; - GetMouse (&pbp, &bt, true); + GetMouse(&pbp, &bt, true); bigtime_t start = system_time(); - while (system_time() - start < dcspeed) - { - snooze (20000); - GetMouse (&bp, &bt, true); - if (!bt && click != 2) - { + while (system_time() - start < dcspeed) { + snooze(20000); + GetMouse(&bp, &bt, true); + if (!bt && click != 2) { click = 0; } - if (bt && !click) - { + if (bt && !click) { click = 2; } if (bp != pbp) break; } - if (!bt && click != 2) - { + if (!bt && click != 2) { click = 1; - } - else if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) - { - BMessage *dragmessage = new BMessage ('ldrg'); - dragmessage->AddInt32 ("startingindex", index); - BBitmap *dragbitmap = new BBitmap (Bounds(), B_RGBA32, true); + } else if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) { + BMessage* dragmessage = new BMessage('ldrg'); + dragmessage->AddInt32("startingindex", index); + BBitmap* dragbitmap = new BBitmap(Bounds(), B_RGBA32, true); dragbitmap->Lock(); BPoint origin = Frame().LeftTop(); LockLooper(); - BView *parent = Parent(); - parent->RemoveChild (this); - dragbitmap->AddChild (this); - MoveTo (B_ORIGIN); - select (true); - dragbitmap->RemoveChild (this); - MoveTo (origin); - parent->AddChild (this); + BView* parent = Parent(); + parent->RemoveChild(this); + dragbitmap->AddChild(this); + MoveTo(B_ORIGIN); + select(true); + dragbitmap->RemoveChild(this); + MoveTo(origin); + parent->AddChild(this); UnlockLooper(); - uint32 *bits = (uint32 *) dragbitmap->Bits(); - for (uint32 i = 0; i < dragbitmap->BitsLength()/4; i++) - { + uint32* bits = (uint32*)dragbitmap->Bits(); + for (uint32 i = 0; i < dragbitmap->BitsLength() / 4; i++) { uint32 pixel = *bits; *bits++ = (pixel & COLOR_MASK) | (127 << ALPHA_BPOS); } - DragMessage (dragmessage, dragbitmap, B_OP_ALPHA, point); + DragMessage(dragmessage, dragbitmap, B_OP_ALPHA, point); delete dragmessage; click = 1; } - if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { + if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { click = 1; - BPoint lnwpos = ConvertToScreen (Bounds().LeftTop()); + BPoint lnwpos = ConvertToScreen(Bounds().LeftTop()); Window()->Unlock(); - LayerNameWindow *lnw = new LayerNameWindow (fLayer->getName()); - lnw->MoveTo (lnwpos); - if (lnw->Go()) - { - fLayer->setName (lnw->name()); - BMessage *msg = new BMessage ('lNch'); - msg->AddInt32 ("index", index); - fMyView->Window()->PostMessage (msg); + LayerNameWindow* lnw = new LayerNameWindow(fLayer->getName()); + lnw->MoveTo(lnwpos); + if (lnw->Go()) { + fLayer->setName(lnw->name()); + BMessage* msg = new BMessage('lNch'); + msg->AddInt32("index", index); + fMyView->Window()->PostMessage(msg); delete msg; } lnw->Lock(); lnw->Quit(); Window()->Lock(); - Draw (Bounds()); + Draw(Bounds()); return; } } } -void LayerItem::Draw (BRect /* update */) -// Note: I'm not happy with this implementation. LayerItems should definitaly +void +LayerItem::Draw(BRect /* update */) +// Note: I'm not happy with this implementation. LayerItems should definitaly // cache the thumbnail bitmaps. However, this works and updates in realtime. { BRect canvasRect = fMyView->canvasFrame(); - BRect thumbRect = BRect (0, 0, fThumbHSize, fThumbVSize); - BBitmap *thumbnail = new BBitmap (thumbRect, B_RGBA32, true); - BView *thumbView = new BView (thumbRect, "Layer Thumbnail", uint32 (NULL), uint32 (NULL)); + BRect thumbRect = BRect(0, 0, fThumbHSize, fThumbVSize); + BBitmap* thumbnail = new BBitmap(thumbRect, B_RGBA32, true); + BView* thumbView = new BView(thumbRect, "Layer Thumbnail", uint32(NULL), uint32(NULL)); thumbnail->Lock(); - thumbnail->AddChild (thumbView); - thumbView->DrawBitmap (fLayer, canvasRect, thumbRect); + thumbnail->AddChild(thumbView); + thumbView->DrawBitmap(fLayer, canvasRect, thumbRect); thumbView->Sync(); - uint32 *bits = ((uint32 *) thumbnail->Bits()) - 1; - for (int i = 0; i < thumbnail->BitsLength()/4; i++) - { + uint32* bits = ((uint32*)thumbnail->Bits()) - 1; + for (int i = 0; i < thumbnail->BitsLength() / 4; i++) { register uint32 pixel = *(++bits); -#if defined (__POWERPC__) +#if defined(__POWERPC__) register uint32 a = pixel & 0x000000FF; - register uint32 b = (((pixel & 0xFF000000) >> 8)*a - (a << 24) + (255 << 24)) & 0xFF000000; - register uint32 g = (((pixel & 0x00FF0000) >> 8)*a - (a << 16) + (255 << 16)) & 0x00FF0000; - register uint32 r = (((pixel & 0x0000FF00) >> 8)*a - (a << 8) + (255 << 8)) & 0x0000FF00; + register uint32 b = + (((pixel & 0xFF000000) >> 8) * a - (a << 24) + (255 << 24)) & 0xFF000000; + register uint32 g = + (((pixel & 0x00FF0000) >> 8) * a - (a << 16) + (255 << 16)) & 0x00FF0000; + register uint32 r = (((pixel & 0x0000FF00) >> 8) * a - (a << 8) + (255 << 8)) & 0x0000FF00; *bits = (b | g | r | a); #else register uint32 a = pixel >> 24; - register uint32 b = ((((pixel & 0x000000FF)*a) >> 8) - (a ) + (255 )) & 0x000000FF; - register uint32 g = ((((pixel & 0x0000FF00)*a) >> 8) - (a << 8) + (255 << 8)) & 0x0000FF00; - register uint32 r = ((((pixel & 0x00FF0000)*a) >> 8) - (a << 16) + (255 << 16)) & 0x00FF0000; + register uint32 b = ((((pixel & 0x000000FF) * a) >> 8) - (a) + (255)) & 0x000000FF; + register uint32 g = + ((((pixel & 0x0000FF00) * a) >> 8) - (a << 8) + (255 << 8)) & 0x0000FF00; + register uint32 r = + ((((pixel & 0x00FF0000) * a) >> 8) - (a << 16) + (255 << 16)) & 0x00FF0000; *bits = (b | g | r | (a << 24)); #endif } - thumbRect.OffsetTo (4, 4); - FillRect (Bounds(), B_SOLID_LOW); - DrawBitmapAsync (thumbnail, thumbRect.LeftTop()); - DrawString (fLayer->getName(), BPoint (thumbRect.right + 8, thumbRect.bottom - 4)); // Should be dynamic... - StrokeRect (Bounds()); + thumbRect.OffsetTo(4, 4); + FillRect(Bounds(), B_SOLID_LOW); + DrawBitmapAsync(thumbnail, thumbRect.LeftTop()); + DrawString( + fLayer->getName(), BPoint(thumbRect.right + 8, thumbRect.bottom - 4) + ); // Should be dynamic... + StrokeRect(Bounds()); Sync(); - thumbnail->RemoveChild (thumbView); + thumbnail->RemoveChild(thumbView); delete thumbView; delete thumbnail; } -void LayerItem::DrawThumbOnly () +void +LayerItem::DrawThumbOnly() { BRect canvasRect = fMyView->canvasFrame(); - fThumbVSize = min_c (THUMBLAYERMAXHEIGHT, canvasRect.Height()); - fThumbHSize = min_c (canvasRect.Width()/canvasRect.Height() * fThumbVSize, THUMBLAYERMAXWIDTH); - BRect thumbRect = BRect (0, 0, fThumbHSize, fThumbVSize); - BBitmap *thumbnail = new BBitmap (thumbRect, B_RGBA32, true); - BView *thumbView = new BView (thumbRect, "Layer Thumbnail", uint32 (NULL), uint32 (NULL)); + fThumbVSize = min_c(THUMBLAYERMAXHEIGHT, canvasRect.Height()); + fThumbHSize = min_c(canvasRect.Width() / canvasRect.Height() * fThumbVSize, THUMBLAYERMAXWIDTH); + BRect thumbRect = BRect(0, 0, fThumbHSize, fThumbVSize); + BBitmap* thumbnail = new BBitmap(thumbRect, B_RGBA32, true); + BView* thumbView = new BView(thumbRect, "Layer Thumbnail", uint32(NULL), uint32(NULL)); thumbnail->Lock(); - thumbnail->AddChild (thumbView); - thumbView->DrawBitmap (fLayer, canvasRect, thumbRect); + thumbnail->AddChild(thumbView); + thumbView->DrawBitmap(fLayer, canvasRect, thumbRect); thumbView->Sync(); - uint32 *bits = ((uint32 *) thumbnail->Bits()) - 1; - for (int i = 0; i < thumbnail->BitsLength()/4; i++) - { + uint32* bits = ((uint32*)thumbnail->Bits()) - 1; + for (int i = 0; i < thumbnail->BitsLength() / 4; i++) { register uint32 pixel = *(++bits); -#if defined (__POWERPC__) +#if defined(__POWERPC__) register uint32 a = pixel & 0x000000FF; - register uint32 b = (((pixel & 0xFF000000) >> 8)*a - (a << 24) + (255 << 24)) & 0xFF000000; - register uint32 g = (((pixel & 0x00FF0000) >> 8)*a - (a << 16) + (255 << 16)) & 0x00FF0000; - register uint32 r = (((pixel & 0x0000FF00) >> 8)*a - (a << 8) + (255 << 8)) & 0x0000FF00; + register uint32 b = + (((pixel & 0xFF000000) >> 8) * a - (a << 24) + (255 << 24)) & 0xFF000000; + register uint32 g = + (((pixel & 0x00FF0000) >> 8) * a - (a << 16) + (255 << 16)) & 0x00FF0000; + register uint32 r = (((pixel & 0x0000FF00) >> 8) * a - (a << 8) + (255 << 8)) & 0x0000FF00; *bits = (b | g | r | a); #else register uint32 a = pixel >> 24; - register uint32 b = (((pixel & 0x000000FF)*a >> 8) - (a ) + (255 )) & 0x000000FF; - register uint32 g = (((pixel & 0x0000FF00)*a >> 8) - (a << 8) + (255 << 8)) & 0x0000FF00; - register uint32 r = (((pixel & 0x00FF0000)*a >> 8) - (a << 16) + (255 << 16)) & 0x00FF0000; + register uint32 b = (((pixel & 0x000000FF) * a >> 8) - (a) + (255)) & 0x000000FF; + register uint32 g = (((pixel & 0x0000FF00) * a >> 8) - (a << 8) + (255 << 8)) & 0x0000FF00; + register uint32 r = + (((pixel & 0x00FF0000) * a >> 8) - (a << 16) + (255 << 16)) & 0x00FF0000; *bits = (b | g | r | (a << 24)); #endif } - thumbRect.OffsetTo (4, 4); - DrawBitmap (thumbnail, thumbRect.LeftTop()); + thumbRect.OffsetTo(4, 4); + DrawBitmap(thumbnail, thumbRect.LeftTop()); Sync(); - thumbnail->RemoveChild (thumbView); + thumbnail->RemoveChild(thumbView); delete thumbView; delete thumbnail; } -void LayerItem::MessageReceived (BMessage *message) +void +LayerItem::MessageReceived(BMessage* message) { - if (message->WasDropped() && message->what == 'ldrg') - { + if (message->WasDropped() && message->what == 'ldrg') { BPoint point; - point = ConvertFromScreen (message->DropPoint()); + point = ConvertFromScreen(message->DropPoint()); int32 sindex; - message->FindInt32 ("startingindex", &sindex); - if (sindex == index) - { - BMessage *msg = new BMessage ('lSel'); - msg->AddInt32 ("index", index); - fMyView->Window()->PostMessage (msg); + message->FindInt32("startingindex", &sindex); + if (sindex == index) { + BMessage* msg = new BMessage('lSel'); + msg->AddInt32("index", index); + fMyView->Window()->PostMessage(msg); delete msg; - } - else - { - BMessage *msg = new BMessage ('movL'); - int16 to = int16 (floor (point.y/LAYERITEMHEIGHT - 0.5) + (sindex > index ? 0 : 1)); - msg->AddInt32 ("from", sindex); - msg->AddInt32 ("to", index - to); - fMyView->Window()->PostMessage (msg); + } else { + BMessage* msg = new BMessage('movL'); + int16 to = int16(floor(point.y / LAYERITEMHEIGHT - 0.5) + (sindex > index ? 0 : 1)); + msg->AddInt32("from", sindex); + msg->AddInt32("to", index - to); + fMyView->Window()->PostMessage(msg); delete msg; } - } - else - inherited::MessageReceived (message); + } else + inherited::MessageReceived(message); } \ No newline at end of file diff --git a/source/LayerItem.h b/source/LayerItem.h index 6de4c89..94f0644 100644 --- a/source/LayerItem.h +++ b/source/LayerItem.h @@ -10,36 +10,39 @@ #include "CanvasView.h" #include -#define LAYERITEMHEIGHT 64 -#define LAYERITEMWIDTH 256 +#define LAYERITEMHEIGHT 64 +#define LAYERITEMWIDTH 256 #define THUMBLAYERMAXHEIGHT 56 -#define THUMBLAYERMAXWIDTH 90 +#define THUMBLAYERMAXWIDTH 90 class LayerItem : public BView { -public: - LayerItem (BRect frame, const char *name, int layerIndex, CanvasView *_myView); -virtual ~LayerItem (); -virtual void Refresh (Layer *layer); -virtual void Draw (BRect updateRect); -virtual void MouseDown (BPoint point); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *message); -virtual void MessageReceived (BMessage *message); -void DrawThumbOnly (); -CanvasView *getCanvasView () { return (fMyView); }; -void setCanvasView (CanvasView *_myView) { fMyView = _myView; }; -void select (bool sel = true); - -private: -typedef BView inherited; -int index; -Layer *fLayer; -CanvasView *fMyView; -float fThumbHSize, fThumbVSize; -BCheckBox *hide; -BPopUpMenu *fModePU; -int click; -bigtime_t dcspeed; + public: + LayerItem(BRect frame, const char* name, int layerIndex, CanvasView* _myView); + virtual ~LayerItem(); + virtual void Refresh(Layer* layer); + virtual void Draw(BRect updateRect); + virtual void MouseDown(BPoint point); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* message); + virtual void MessageReceived(BMessage* message); + void DrawThumbOnly(); + + CanvasView* getCanvasView() { return (fMyView); }; + + void setCanvasView(CanvasView* _myView) { fMyView = _myView; }; + + void select(bool sel = true); + + private: + typedef BView inherited; + int index; + Layer* fLayer; + CanvasView* fMyView; + float fThumbHSize, fThumbVSize; + BCheckBox* hide; + BPopUpMenu* fModePU; + int click; + bigtime_t dcspeed; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/LayerNameWindow.cpp b/source/LayerNameWindow.cpp index 6888657..787b126 100644 --- a/source/LayerNameWindow.cpp +++ b/source/LayerNameWindow.cpp @@ -3,64 +3,64 @@ #include #include "Settings.h" -LayerNameWindow::LayerNameWindow (const char *_name) -: BWindow (BRect (100, 100, 260, 170), "", B_MODAL_WINDOW, B_NOT_RESIZABLE) +LayerNameWindow::LayerNameWindow(const char* _name) + : BWindow(BRect(100, 100, 260, 170), "", B_MODAL_WINDOW, B_NOT_RESIZABLE) { - wait_sem = create_sem (0, "wait_sem"); + wait_sem = create_sem(0, "wait_sem"); BRect bgFrame, cancelFrame, okFrame, textFrame; - bgFrame.Set (0, 0, 160, 70); - BView *bg = new BView (bgFrame, "LNW bg", B_FOLLOW_ALL, B_WILL_DRAW); - bg->SetViewColor (LightGrey); - AddChild (bg); - - textFrame.Set (8, 8, 152, 26); - fName = new BTextControl (textFrame, "fName", lstring (176, "Name: "), _name, new BMessage ('LNWc')); - fName->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT); - fName->SetDivider (40); - bg->AddChild (fName); - - cancelFrame.Set (38, 36, 90, 60); - okFrame.Set (98, 36, 150, 60); - BButton *cancel = new BButton (cancelFrame, "LNW cancel", lstring (131, "Cancel"), new BMessage ('LNcn')); - BButton *ok = new BButton (okFrame, "LNW open", lstring (136, "OK"), new BMessage ('LNok')); - ok->MakeDefault (true); - bg->AddChild (cancel); - bg->AddChild (ok); - + bgFrame.Set(0, 0, 160, 70); + BView* bg = new BView(bgFrame, "LNW bg", B_FOLLOW_ALL, B_WILL_DRAW); + bg->SetViewColor(LightGrey); + AddChild(bg); + + textFrame.Set(8, 8, 152, 26); + fName = + new BTextControl(textFrame, "fName", lstring(176, "Name: "), _name, new BMessage('LNWc')); + fName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); + fName->SetDivider(40); + bg->AddChild(fName); + + cancelFrame.Set(38, 36, 90, 60); + okFrame.Set(98, 36, 150, 60); + BButton* cancel = + new BButton(cancelFrame, "LNW cancel", lstring(131, "Cancel"), new BMessage('LNcn')); + BButton* ok = new BButton(okFrame, "LNW open", lstring(136, "OK"), new BMessage('LNok')); + ok->MakeDefault(true); + bg->AddChild(cancel); + bg->AddChild(ok); + fStatus = 0; } -LayerNameWindow::~LayerNameWindow () -{ - delete_sem (wait_sem); -} +LayerNameWindow::~LayerNameWindow() { delete_sem(wait_sem); } -int32 LayerNameWindow::Go () +int32 +LayerNameWindow::Go() { -// status_t err; - BWindow *w = dynamic_cast (BLooper::LooperForThread (find_thread (NULL))); -// bigtime_t timeout = w ? 200000 : B_INFINITE_TIMEOUT; + // status_t err; + BWindow* w = dynamic_cast(BLooper::LooperForThread(find_thread(NULL))); + // bigtime_t timeout = w ? 200000 : B_INFINITE_TIMEOUT; bool ishidden = false; Show(); - while (!ishidden) - { + while (!ishidden) { Lock(); ishidden = IsHidden(); Unlock(); - snooze (50000); -// while ((((err = acquire_sem_etc (wait_sem, 1, B_TIMEOUT, timeout)) == B_TIMED_OUT) || (err == B_INTERRUPTED)) && !ishidden) -// { - if (w) - w->UpdateIfNeeded(); -// } + snooze(50000); + // while ((((err = acquire_sem_etc (wait_sem, 1, B_TIMEOUT, timeout)) == B_TIMED_OUT) + //|| (err == B_INTERRUPTED)) && !ishidden) + // { + if (w) + w->UpdateIfNeeded(); + // } } return (fStatus); } -void LayerNameWindow::MessageReceived (BMessage *message) +void +LayerNameWindow::MessageReceived(BMessage* message) { - switch (message->what) - { + switch (message->what) { case 'LNcn': fStatus = 0; Hide(); diff --git a/source/LayerNameWindow.h b/source/LayerNameWindow.h index 8e290bd..c7a7c53 100644 --- a/source/LayerNameWindow.h +++ b/source/LayerNameWindow.h @@ -6,20 +6,20 @@ class LayerNameWindow : public BWindow { -public: - LayerNameWindow (const char *name); -virtual ~LayerNameWindow (); + public: + LayerNameWindow(const char* name); + virtual ~LayerNameWindow(); -virtual void MessageReceived (BMessage *message); -virtual int32 Go (); + virtual void MessageReceived(BMessage* message); + virtual int32 Go(); -const char *name () { return fName->Text(); }; + const char* name() { return fName->Text(); }; -private: -typedef BWindow inherited; -sem_id wait_sem; -BTextControl *fName; -int32 fStatus; + private: + typedef BWindow inherited; + sem_id wait_sem; + BTextControl* fName; + int32 fStatus; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/LayerView.cpp b/source/LayerView.cpp index d91d35f..a321e7f 100644 --- a/source/LayerView.cpp +++ b/source/LayerView.cpp @@ -2,8 +2,8 @@ #include "LayerWindow.h" #include "LayerItem.h" -LayerView::LayerView (BRect frame, const char *name, CanvasView *_myView) -: BView (frame, name, B_FOLLOW_ALL_SIDES, B_FRAME_EVENTS | B_WILL_DRAW) +LayerView::LayerView(BRect frame, const char* name, CanvasView* _myView) + : BView(frame, name, B_FOLLOW_ALL_SIDES, B_FRAME_EVENTS | B_WILL_DRAW) { fMyView = _myView; fFrame = frame; @@ -11,55 +11,55 @@ LayerView::LayerView (BRect frame, const char *name, CanvasView *_myView) layerItem[i] = NULL; } -LayerView::~LayerView () +LayerView::~LayerView() { -// printf ("~LayerView\n"); + // printf ("~LayerView\n"); } -void LayerView::setScrollBars (BScrollBar *_h, BScrollBar *_v) +void +LayerView::setScrollBars(BScrollBar* _h, BScrollBar* _v) { mh = _h; mv = _v; - mh->SetTarget (this); - mv->SetTarget (this); + mh->SetTarget(this); + mv->SetTarget(this); } -void LayerView::Draw (BRect updateRect) +void +LayerView::Draw(BRect updateRect) { - inherited::Draw (updateRect); + inherited::Draw(updateRect); } -void LayerView::AttachedToWindow () +void +LayerView::AttachedToWindow() { // Yes I know this is rather blunt. Let's call this RAD and all is well. - for (int i = 0; i < MAX_LAYERS; i++) - { - if (layerItem[i]) - { - RemoveChild (layerItem[i]); + for (int i = 0; i < MAX_LAYERS; i++) { + if (layerItem[i]) { + RemoveChild(layerItem[i]); delete layerItem[i]; layerItem[i] = NULL; } } - FrameResized (Bounds().Width(), Bounds().Height()); - SetViewColor (B_TRANSPARENT_32_BIT); - BRect layerItemRect = BRect (0, 0, LAYERITEMWIDTH, LAYERITEMHEIGHT); - for (int i = fMyView->numLayers() - 1; i >= 0; i--) - { - layerItem[i] = new LayerItem (layerItemRect, "Layer Item", i, fMyView); - AddChild (layerItem[i]); - layerItemRect.OffsetBy (0, LAYERITEMHEIGHT); + FrameResized(Bounds().Width(), Bounds().Height()); + SetViewColor(B_TRANSPARENT_32_BIT); + BRect layerItemRect = BRect(0, 0, LAYERITEMWIDTH, LAYERITEMHEIGHT); + for (int i = fMyView->numLayers() - 1; i >= 0; i--) { + layerItem[i] = new LayerItem(layerItemRect, "Layer Item", i, fMyView); + AddChild(layerItem[i]); + layerItemRect.OffsetBy(0, LAYERITEMHEIGHT); } } -void LayerView::FrameResized (float width, float height) +void +LayerView::FrameResized(float width, float height) { float hmin, hmax, vmin, vmax; - mh->GetRange (&hmin, &hmax); - mv->GetRange (&vmin, &vmax); - mh->SetRange (hmin, fFrame.Width() - width); - mv->SetRange (vmin, fFrame.Height() - height); - mh->SetProportion (width/fFrame.Width()); - mv->SetProportion (height/fFrame.Height()); + mh->GetRange(&hmin, &hmax); + mv->GetRange(&vmin, &vmax); + mh->SetRange(hmin, fFrame.Width() - width); + mv->SetRange(vmin, fFrame.Height() - height); + mh->SetProportion(width / fFrame.Width()); + mv->SetProportion(height / fFrame.Height()); } - diff --git a/source/LayerView.h b/source/LayerView.h index 979d540..3fe1454 100644 --- a/source/LayerView.h +++ b/source/LayerView.h @@ -7,30 +7,29 @@ #include #include "CanvasView.h" #include "LayerItem.h" -#include "AttribDraw.h" // For MAX_LAYERS +#include "AttribDraw.h" // For MAX_LAYERS class LayerView : public BView { -public: - LayerView (BRect frame, const char *name, CanvasView *_myView); -virtual ~LayerView (); -virtual void Draw (BRect updateRect); -virtual void FrameResized (float width, float height); -virtual void AttachedToWindow (); + public: + LayerView(BRect frame, const char* name, CanvasView* _myView); + virtual ~LayerView(); + virtual void Draw(BRect updateRect); + virtual void FrameResized(float width, float height); + virtual void AttachedToWindow(); -void setScrollBars (BScrollBar *_h, BScrollBar *_v); -LayerItem *getLayerItem (int index) { return layerItem[index]; }; -void setCanvasView (CanvasView *_myView) - { - fMyView = _myView; - }; + void setScrollBars(BScrollBar* _h, BScrollBar* _v); -private: -typedef BView inherited; -BScrollBar *mh, *mv; -CanvasView *fMyView; -LayerItem *layerItem[MAX_LAYERS + 1]; -BRect fFrame; + LayerItem* getLayerItem(int index) { return layerItem[index]; }; + + void setCanvasView(CanvasView* _myView) { fMyView = _myView; }; + + private: + typedef BView inherited; + BScrollBar *mh, *mv; + CanvasView* fMyView; + LayerItem* layerItem[MAX_LAYERS + 1]; + BRect fFrame; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/LayerWindow.cpp b/source/LayerWindow.cpp index d833bfc..5a4af4f 100644 --- a/source/LayerWindow.cpp +++ b/source/LayerWindow.cpp @@ -7,221 +7,211 @@ #include #include "Settings.h" -LayerWindow::LayerWindow (BRect frame, char *name, CanvasView *_myView) -: BWindow (frame, name, B_DOCUMENT_WINDOW, B_WILL_ACCEPT_FIRST_CLICK) +LayerWindow::LayerWindow(BRect frame, char* name, CanvasView* _myView) + : BWindow(frame, name, B_DOCUMENT_WINDOW, B_WILL_ACCEPT_FIRST_CLICK) { BRect menubarFrame, viewFrame, hFrame, vFrame; - menubarFrame.Set (0, 0, 0, 0); - menubar = new BMenuBar (menubarFrame, "LayerMenubar"); - layerM = new BMenu (lstring (170, "Layer")); - layerM->AddItem (new BMenuItem (lstring (171, "Add New Layer"), new BMessage ('newl'), 'N')); - layerM->AddItem (new BMenuItem (lstring (172, "Insert New Layer"), new BMessage ('insl'), 'I')); - layerM->AddItem (new BMenuItem (lstring (173, "Duplicate Layer"), new BMessage ('dupl'), 'D')); - layerM->AddItem (new BMenuItem (lstring (174, "Merge Layers"), new BMessage ('mrgl'))); - layerM->AddItem (new BMenuItem (lstring (175, "Remove Layer"), new BMessage ('dell'))); - menubar->AddItem (layerM); - AddChild (menubar); + menubarFrame.Set(0, 0, 0, 0); + menubar = new BMenuBar(menubarFrame, "LayerMenubar"); + layerM = new BMenu(lstring(170, "Layer")); + layerM->AddItem(new BMenuItem(lstring(171, "Add New Layer"), new BMessage('newl'), 'N')); + layerM->AddItem(new BMenuItem(lstring(172, "Insert New Layer"), new BMessage('insl'), 'I')); + layerM->AddItem(new BMenuItem(lstring(173, "Duplicate Layer"), new BMessage('dupl'), 'D')); + layerM->AddItem(new BMenuItem(lstring(174, "Merge Layers"), new BMessage('mrgl'))); + layerM->AddItem(new BMenuItem(lstring(175, "Remove Layer"), new BMessage('dell'))); + menubar->AddItem(layerM); + AddChild(menubar); menubar->ResizeToPreferred(); menubarFrame = menubar->Frame(); - viewFrame.Set (0, 0, LAYERITEMWIDTH, _myView->numLayers()*LAYERITEMHEIGHT); - viewFrame.OffsetTo (menubarFrame.left, menubarFrame.bottom + 1); - layerView = new LayerView (viewFrame, "Layer View", _myView); - ResizeTo (viewFrame.right + B_V_SCROLL_BAR_WIDTH, viewFrame.bottom + B_H_SCROLL_BAR_HEIGHT); - hFrame.Set (0, viewFrame.bottom + 1, viewFrame.right + 1, - viewFrame.bottom + B_H_SCROLL_BAR_HEIGHT + 1); - h = new BScrollBar (hFrame, NULL, layerView, 0, 0, B_HORIZONTAL); - vFrame.Set (viewFrame.right + 1, viewFrame.top, - viewFrame.right + B_V_SCROLL_BAR_WIDTH + 1, viewFrame.bottom + 1); - v = new BScrollBar (vFrame, NULL, layerView, 0, 0, B_VERTICAL); - AddChild (h); - AddChild (v); - layerView->setScrollBars (h, v); - AddChild (layerView); + viewFrame.Set(0, 0, LAYERITEMWIDTH, _myView->numLayers() * LAYERITEMHEIGHT); + viewFrame.OffsetTo(menubarFrame.left, menubarFrame.bottom + 1); + layerView = new LayerView(viewFrame, "Layer View", _myView); + ResizeTo(viewFrame.right + B_V_SCROLL_BAR_WIDTH, viewFrame.bottom + B_H_SCROLL_BAR_HEIGHT); + hFrame.Set( + 0, viewFrame.bottom + 1, viewFrame.right + 1, viewFrame.bottom + B_H_SCROLL_BAR_HEIGHT + 1 + ); + h = new BScrollBar(hFrame, NULL, layerView, 0, 0, B_HORIZONTAL); + vFrame.Set( + viewFrame.right + 1, viewFrame.top, viewFrame.right + B_V_SCROLL_BAR_WIDTH + 1, + viewFrame.bottom + 1 + ); + v = new BScrollBar(vFrame, NULL, layerView, 0, 0, B_VERTICAL); + AddChild(h); + AddChild(v); + layerView->setScrollBars(h, v); + AddChild(layerView); myView = _myView; myWindow = _myView->Window(); - SetSizeLimits (128, Frame().Width(), 80, Frame().Height()); - if (myView->currentLayerIndex() == 0) - { - layerM->FindItem('mrgl')->SetEnabled (false); - layerM->FindItem('dell')->SetEnabled (false); + SetSizeLimits(128, Frame().Width(), 80, Frame().Height()); + if (myView->currentLayerIndex() == 0) { + layerM->FindItem('mrgl')->SetEnabled(false); + layerM->FindItem('dell')->SetEnabled(false); } } -LayerWindow::~LayerWindow () +LayerWindow::~LayerWindow() { - RemoveChild (menubar); + RemoveChild(menubar); delete menubar; - RemoveChild (h); + RemoveChild(h); delete h; - RemoveChild (v); + RemoveChild(v); delete v; - RemoveChild (layerView); + RemoveChild(layerView); delete layerView; } -void LayerWindow::doChanges (int index) +void +LayerWindow::doChanges(int index) { - if (index == -1) - { - //printf ("LayerWindow::doChanges (-1)\n"); + if (index == -1) { + // printf ("LayerWindow::doChanges (-1)\n"); BRect viewFrame, menubarFrame; menubarFrame = menubar->Frame(); - viewFrame.Set (0, 0, LAYERITEMWIDTH, myView->numLayers()*LAYERITEMHEIGHT); - viewFrame.OffsetTo (menubarFrame.left, menubarFrame.bottom + 1); - RemoveChild (layerView); + viewFrame.Set(0, 0, LAYERITEMWIDTH, myView->numLayers() * LAYERITEMHEIGHT); + viewFrame.OffsetTo(menubarFrame.left, menubarFrame.bottom + 1); + RemoveChild(layerView); delete layerView; - layerView = new LayerView (viewFrame, "Layer View", myView); - SetSizeLimits (0, 1000, 0, 2000); - ResizeTo (viewFrame.right + B_V_SCROLL_BAR_WIDTH, viewFrame.bottom + B_H_SCROLL_BAR_HEIGHT); - SetSizeLimits (128, Frame().Width(), 80, Frame().Height()); - layerView->setScrollBars (h, v); - AddChild (layerView); - //printf ("Current Layer: %i\n", myView->currentLayerIndex()); - if (myView->currentLayerIndex() == 0) - { - layerM->FindItem('dell')->SetEnabled (false); - layerM->FindItem('mrgl')->SetEnabled (false); + layerView = new LayerView(viewFrame, "Layer View", myView); + SetSizeLimits(0, 1000, 0, 2000); + ResizeTo(viewFrame.right + B_V_SCROLL_BAR_WIDTH, viewFrame.bottom + B_H_SCROLL_BAR_HEIGHT); + SetSizeLimits(128, Frame().Width(), 80, Frame().Height()); + layerView->setScrollBars(h, v); + AddChild(layerView); + // printf ("Current Layer: %i\n", myView->currentLayerIndex()); + if (myView->currentLayerIndex() == 0) { + layerM->FindItem('dell')->SetEnabled(false); + layerM->FindItem('mrgl')->SetEnabled(false); + } else { + layerM->FindItem('dell')->SetEnabled(true); + layerM->FindItem('mrgl')->SetEnabled(true); } - else - { - layerM->FindItem('dell')->SetEnabled (true); - layerM->FindItem('mrgl')->SetEnabled (true); - } - } - else - { + } else { // printf ("Refresh %i\n", index); - layerView->getLayerItem(index)->Refresh (myView->getLayer (index)); + layerView->getLayerItem(index)->Refresh(myView->getLayer(index)); } } -void LayerWindow::MessageReceived (BMessage *msg) +void +LayerWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'draw': - layerView->Invalidate (); + layerView->Invalidate(); break; case 'layO': Show(); break; - case 'newl': - { - BMessage *message = new BMessage ('newL'); - myWindow->PostMessage (message); + case 'newl': { + BMessage* message = new BMessage('newL'); + myWindow->PostMessage(message); delete message; break; } - case 'dell': - { - BMessage *message = new BMessage ('delL'); - myWindow->PostMessage (message); + case 'dell': { + BMessage* message = new BMessage('delL'); + myWindow->PostMessage(message); delete message; break; } - case 'dupl': - { - BMessage *message = new BMessage ('dupL'); - myWindow->PostMessage (message); + case 'dupl': { + BMessage* message = new BMessage('dupL'); + myWindow->PostMessage(message); delete message; break; } - case 'insl': - { - BMessage *message = new BMessage ('insL'); - myWindow->PostMessage (message); + case 'insl': { + BMessage* message = new BMessage('insL'); + myWindow->PostMessage(message); delete message; break; } - case 'mrgl': - { - BMessage *message = new BMessage ('mrgL'); - myWindow->PostMessage (message); + case 'mrgl': { + BMessage* message = new BMessage('mrgL'); + myWindow->PostMessage(message); delete message; break; } - case 'movl': // Redundant. The LayerItem sends the message to the window itself. + case 'movl': // Redundant. The LayerItem sends the message to the window itself. { int32 from, to; - BMessage *message = new BMessage ('movL'); - msg->FindInt32 ("from", &from); - msg->FindInt32 ("to", &to); - message->AddInt32 ("from", from); - message->AddInt32 ("to", to); - myWindow->PostMessage (message); + BMessage* message = new BMessage('movL'); + msg->FindInt32("from", &from); + msg->FindInt32("to", &to); + message->AddInt32("from", from); + message->AddInt32("to", to); + myWindow->PostMessage(message); delete message; break; } - case 'lChg': - { + case 'lChg': { int32 prev, current; - if (!msg->FindInt32 ("prev", &prev) && !msg->FindInt32 ("current", ¤t)) - { + if (!msg->FindInt32("prev", &prev) && !msg->FindInt32("current", ¤t)) { // We can get away by just selecting and deselecting. // This saves a lot of flicker - and selecting layers is the // most common operation anyway. - layerView->getLayerItem(prev)->select (false); - layerView->getLayerItem(current)->select (true); - } - else // ugh - rebuild the entire menu. Bad bad bad. + layerView->getLayerItem(prev)->select(false); + layerView->getLayerItem(current)->select(true); + } else // ugh - rebuild the entire menu. Bad bad bad. { BRect viewFrame, menubarFrame; menubarFrame = menubar->Frame(); - viewFrame.Set (0, 0, LAYERITEMWIDTH, myView->numLayers()*LAYERITEMHEIGHT); - viewFrame.OffsetTo (menubarFrame.left, menubarFrame.bottom + 1); - RemoveChild (layerView); + viewFrame.Set(0, 0, LAYERITEMWIDTH, myView->numLayers() * LAYERITEMHEIGHT); + viewFrame.OffsetTo(menubarFrame.left, menubarFrame.bottom + 1); + RemoveChild(layerView); delete layerView; - layerView = new LayerView (viewFrame, "Layer View", myView); - SetSizeLimits (0, 1000, 0, 2000); - ResizeTo (viewFrame.right + B_V_SCROLL_BAR_WIDTH, viewFrame.bottom + B_H_SCROLL_BAR_HEIGHT); - SetSizeLimits (128, Frame().Width(), 80, Frame().Height()); - layerView->setScrollBars (h, v); - AddChild (layerView); + layerView = new LayerView(viewFrame, "Layer View", myView); + SetSizeLimits(0, 1000, 0, 2000); + ResizeTo( + viewFrame.right + B_V_SCROLL_BAR_WIDTH, viewFrame.bottom + B_H_SCROLL_BAR_HEIGHT + ); + SetSizeLimits(128, Frame().Width(), 80, Frame().Height()); + layerView->setScrollBars(h, v); + AddChild(layerView); } if (myView->currentLayerIndex() == 0) - layerM->FindItem('dell')->SetEnabled (false); + layerM->FindItem('dell')->SetEnabled(false); else - layerM->FindItem('dell')->SetEnabled (true); + layerM->FindItem('dell')->SetEnabled(true); break; } - case 'lSel': - { + case 'lSel': { break; } - case 'LIga': - { - int16 index = msg->FindInt32 ("index"); - uchar ga = uchar (msg->FindFloat ("value")); -// BMessage *message = new BMessage ('Liga'); -// message->AddInt32 ("index", index); -// message->AddInt32 ("alpha", ga); -// myWindow->PostMessage (message); -// delete message; -// printf ("Trying to get the lock... "); fflush (stdout); - if (myView->Window()->LockWithTimeout (100000) == B_OK) - { -// printf ("Got it\n"); - myView->setGlobalAlpha (index, ga); + case 'LIga': { + int16 index = msg->FindInt32("index"); + uchar ga = uchar(msg->FindFloat("value")); + // BMessage *message = new BMessage ('Liga'); + // message->AddInt32 ("index", index); + // message->AddInt32 ("alpha", ga); + // myWindow->PostMessage (message); + // delete message; + // printf ("Trying to get the lock... "); fflush (stdout); + if (myView->Window()->LockWithTimeout(100000) == B_OK) { + // printf ("Got it\n"); + myView->setGlobalAlpha(index, ga); myView->Window()->Unlock(); } -// else -// printf ("Failed\n"); + // else + // printf ("Failed\n"); break; } default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } -void LayerWindow::Quit () +void +LayerWindow::Quit() { - myWindow->PostMessage ('layQ'); + myWindow->PostMessage('layQ'); inherited::Quit(); } -void LayerWindow::WindowActivated (bool /* active */) +void +LayerWindow::WindowActivated(bool /* active */) { -// if (active) -// doChanges (-1); + // if (active) + // doChanges (-1); } \ No newline at end of file diff --git a/source/LayerWindow.h b/source/LayerWindow.h index 4ec0dee..440fab2 100644 --- a/source/LayerWindow.h +++ b/source/LayerWindow.h @@ -10,23 +10,24 @@ class LayerWindow : public BWindow { -friend class CanvasView; -public: - LayerWindow (BRect frame, char *name, CanvasView *_MyView); -virtual ~LayerWindow (); -virtual void MessageReceived (BMessage *msg); -virtual void Quit (); -virtual void WindowActivated (bool active); -void doChanges (int index = -1); + friend class CanvasView; -private: -typedef BWindow inherited; -LayerView *layerView; -BScrollBar *h, *v; -BWindow *myWindow; -CanvasView *myView; -BMenuBar *menubar; -BMenu *layerM; + public: + LayerWindow(BRect frame, char* name, CanvasView* _MyView); + virtual ~LayerWindow(); + virtual void MessageReceived(BMessage* msg); + virtual void Quit(); + virtual void WindowActivated(bool active); + void doChanges(int index = -1); + + private: + typedef BWindow inherited; + LayerView* layerView; + BScrollBar *h, *v; + BWindow* myWindow; + CanvasView* myView; + BMenuBar* menubar; + BMenu* layerM; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/LibImageManipWrapper/Addon.cpp b/source/LibImageManipWrapper/Addon.cpp index a591279..deeb1ef 100644 --- a/source/LibImageManipWrapper/Addon.cpp +++ b/source/LibImageManipWrapper/Addon.cpp @@ -19,66 +19,73 @@ #include "ImageManip.h" #include "BBitmapAccessor.h" -#define MSG_FILTER_SELECTED 'fsel' -#define MSG_FILTER_PREVIEW 'prev' -#define MSG_APPLY_TO_SELECTION 'aply' +#define MSG_FILTER_SELECTED 'fsel' +#define MSG_FILTER_PREVIEW 'prev' +#define MSG_APPLY_TO_SELECTION 'aply' #ifdef MANIPULATOR -#define WINDOW_TITLE "Manipulate %s" -#define NAME "Filter" -#define MENU_FIELD "Filter:" -#define POPUP_NAME "Select Filter" -#define WRAPPER_TYPE BECASSO_FILTER -#define PREVIEW PREVIEW_2x2 +#define WINDOW_TITLE "Manipulate %s" +#define NAME "Filter" +#define MENU_FIELD "Filter:" +#define POPUP_NAME "Select Filter" +#define WRAPPER_TYPE BECASSO_FILTER +#define PREVIEW PREVIEW_2x2 #define APPLY_TO_SELECTION "Apply filter to selection too" #endif #ifdef CONVERTER -#define WINDOW_TITLE "Convert %s" -#define NAME "Generator" -#define MENU_FIELD "Generator:" -#define POPUP_NAME "Select Generator" -#define WRAPPER_TYPE BECASSO_TRANSFORMER -#define PREVIEW PREVIEW_2x2 +#define WINDOW_TITLE "Convert %s" +#define NAME "Generator" +#define MENU_FIELD "Generator:" +#define POPUP_NAME "Select Generator" +#define WRAPPER_TYPE BECASSO_TRANSFORMER +#define PREVIEW PREVIEW_2x2 #define APPLY_TO_SELECTION "Apply transformer to selection too" #endif class WrapperWindow; -static WrapperWindow *window = NULL; -static int32 mAddonId = -1; -static bool mApplyToSelection = false; +static WrapperWindow* window = NULL; +static int32 mAddonId = -1; +static bool mApplyToSelection = false; class WrapperWindow : public AddOnWindow { void SetupFilters(BMenu* sub_menu); - BView *mView; - BMenuField *mMenuField; - int mHeight, mWidth; + BView* mView; + BMenuField* mMenuField; + int mHeight, mWidth; void SetupConfigView(int32 addon, const char* name); - BStringView *mStatus; - -public: - WrapperWindow (BRect rect, becasso_addon_info *info); - virtual ~WrapperWindow (); + BStringView* mStatus; + + public: + WrapperWindow(BRect rect, becasso_addon_info* info); + virtual ~WrapperWindow(); void MessageReceived(BMessage* msg); void RemoveView(); void SetStatus(const char* text); }; - -WrapperWindow::WrapperWindow (BRect rect, becasso_addon_info *info) : AddOnWindow (rect, info) { +WrapperWindow::WrapperWindow(BRect rect, becasso_addon_info* info) : AddOnWindow(rect, info) +{ mView = NULL; - BMenu *sub_menu = new BPopUpMenu(POPUP_NAME); - mHeight = rect.IntegerHeight(); mWidth = rect.IntegerWidth(); + BMenu* sub_menu = new BPopUpMenu(POPUP_NAME); + mHeight = rect.IntegerHeight(); + mWidth = rect.IntegerWidth(); SetupFilters(sub_menu); - mMenuField = new BMenuField(BRect(5, mHeight, 200, mHeight+30), NAME, MENU_FIELD, sub_menu); + mMenuField = new BMenuField(BRect(5, mHeight, 200, mHeight + 30), NAME, MENU_FIELD, sub_menu); mMenuField->SetDivider(70); Background()->AddChild(mMenuField); - Background()->AddChild(new BButton(BRect(205, mHeight, 265, mHeight + 20), "", "Preview", new BMessage(MSG_FILTER_PREVIEW))); - mHeight += 32; mWidth = 270; - Background()->AddChild(new BCheckBox(BRect(5, mHeight, 265, mHeight + 20), "", APPLY_TO_SELECTION, new BMessage(MSG_APPLY_TO_SELECTION))); + Background()->AddChild(new BButton( + BRect(205, mHeight, 265, mHeight + 20), "", "Preview", new BMessage(MSG_FILTER_PREVIEW) + )); + mHeight += 32; + mWidth = 270; + Background()->AddChild(new BCheckBox( + BRect(5, mHeight, 265, mHeight + 20), "", APPLY_TO_SELECTION, + new BMessage(MSG_APPLY_TO_SELECTION) + )); mHeight += 20; mStatus = new BStringView(BRect(5, mHeight, 265, mHeight + 20), "", "Status"); Background()->AddChild(mStatus); @@ -86,81 +93,82 @@ WrapperWindow::WrapperWindow (BRect rect, becasso_addon_info *info) : AddOnWindo ResizeTo(mWidth, mHeight); }; +WrapperWindow::~WrapperWindow() { window = NULL; } -WrapperWindow::~WrapperWindow() { - window = NULL; -} - - -void WrapperWindow::SetupFilters(BMenu* sub_menu) { +void +WrapperWindow::SetupFilters(BMenu* sub_menu) +{ // Create bitmap accessor object to pass along, so that we // only get the add-ons that support this bitmap in the menu BBitmap bitmap(BRect(0, 0, 100, 20), B_RGB32); BBitmapAccessor* accessor = Image_CreateBBitmapAccessor(&bitmap); if (accessor == NULL) { - sub_menu->SetEnabled(false); return; + sub_menu->SetEnabled(false); + return; } accessor->SetDispose(false); // Create sub menu with image manipulators - const char *addonName; - const char *addonInfo; - const char *addonCategory; + const char* addonName; + const char* addonInfo; + const char* addonCategory; int32 addonVersion; - image_addon_id *outList; + image_addon_id* outList; int32 outCount = 0; - BMenuItem *item; + BMenuItem* item; #ifdef MANIPULATOR if (Image_GetManipulators(accessor, NULL, &outList, &outCount) == B_OK) #endif #ifdef CONVERTER - if (Image_GetConverters(accessor, NULL, &outList, &outCount) == B_OK) + if (Image_GetConverters(accessor, NULL, &outList, &outCount) == B_OK) #endif - { - mAddonId = outList[0]; - - for (int i = outCount-1; i >= 0; --i) { - if (Image_GetAddonInfo(outList[i], &addonName, &addonInfo, - &addonCategory, &addonVersion) == B_OK) - { - BMessage *msg = new BMessage(MSG_FILTER_SELECTED); - msg->AddInt32("addon_id", outList[i]); - msg->AddString("addon_name", addonName); - item = new BMenuItem(addonName, msg); - sub_menu->AddItem(item); - if (i == outCount-1) PostMessage(msg); + mAddonId = outList[0]; + + for (int i = outCount - 1; i >= 0; --i) { + if (Image_GetAddonInfo( + outList[i], &addonName, &addonInfo, &addonCategory, &addonVersion + ) == B_OK) { + BMessage* msg = new BMessage(MSG_FILTER_SELECTED); + msg->AddInt32("addon_id", outList[i]); + msg->AddString("addon_name", addonName); + item = new BMenuItem(addonName, msg); + sub_menu->AddItem(item); + if (i == outCount - 1) + PostMessage(msg); + } } + delete[] outList; } - delete[] outList; - } if (outCount == 0) sub_menu->SetEnabled(false); - else - { + else { sub_menu->ItemAt((int32)0)->SetMarked(true); } delete accessor; } - -void WrapperWindow::RemoveView() { +void +WrapperWindow::RemoveView() +{ if (mView) { Background()->RemoveChild(mView); - delete mView; mView = NULL; + delete mView; + mView = NULL; } } - -void WrapperWindow::SetupConfigView(int32 addon, const char* name) { +void +WrapperWindow::SetupConfigView(int32 addon, const char* name) +{ mAddonId = addon; RemoveView(); int width; BMessage dummy; if (Image_MakeConfigurationView(mAddonId, &dummy, &mView) == 0 && mView) { - Background()->AddChild(mView); + Background()->AddChild(mView); int width = max_c(mWidth, mView->Bounds().Width()) + 10; - mView->MoveTo((width-mView->Bounds().Width()) / 2, mHeight); + mView->MoveTo((width - mView->Bounds().Width()) / 2, mHeight); ResizeTo(width, mHeight + mView->Bounds().Height()); } else { ResizeTo(mWidth, mHeight); @@ -168,49 +176,51 @@ void WrapperWindow::SetupConfigView(int32 addon, const char* name) { } } - -void WrapperWindow::MessageReceived(BMessage* msg) { - switch(msg->what) { - case MSG_FILTER_SELECTED: { - BString name; - SetStatus("Status"); - msg->FindString("addon_name", &name); - SetupConfigView(msg->FindInt32("addon_id"), name.String()); - break; } - case MSG_FILTER_PREVIEW: - aPreview(); - break; - case MSG_APPLY_TO_SELECTION: { - int32 s; - if (B_OK == msg->FindInt32("be:value", &s)) { - mApplyToSelection = (bool)s; - } - } - break; - default: - AddOnWindow::MessageReceived(msg); +void +WrapperWindow::MessageReceived(BMessage* msg) +{ + switch (msg->what) { + case MSG_FILTER_SELECTED: { + BString name; + SetStatus("Status"); + msg->FindString("addon_name", &name); + SetupConfigView(msg->FindInt32("addon_id"), name.String()); + break; + } + case MSG_FILTER_PREVIEW: + aPreview(); + break; + case MSG_APPLY_TO_SELECTION: { + int32 s; + if (B_OK == msg->FindInt32("be:value", &s)) { + mApplyToSelection = (bool)s; + } + } break; + default: + AddOnWindow::MessageReceived(msg); } } - -void WrapperWindow::SetStatus(const char* text) { +void +WrapperWindow::SetStatus(const char* text) +{ mStatus->SetText(text); } - -int addon_init (uint32 index, becasso_addon_info *info) +int +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "LibImageManip Wrapper"); - strcpy (info->author, "Michael Pfeiffer"); - strcpy (info->copyright, "© 2001 under GPL"); - strcpy (info->description, "Wrapper to LibImageManip"); - info->type = WRAPPER_TYPE; - info->index = index; - info->version = 0; - info->release = 1; - info->becasso_version = 1; - info->becasso_release = 0; - info->does_preview = PREVIEW; + strcpy(info->name, "LibImageManip Wrapper"); + strcpy(info->author, "Michael Pfeiffer"); + strcpy(info->copyright, "© 2001 under GPL"); + strcpy(info->description, "Wrapper to LibImageManip"); + info->type = WRAPPER_TYPE; + info->index = index; + info->version = 0; + info->release = 1; + info->becasso_version = 1; + info->becasso_release = 0; + info->does_preview = PREVIEW; #if defined(MANIPULATOR) || defined(IMAGEMANIP_WEAK_LINKAGE) // Note: We assume that the filter is loaded first by Becasso, // then the transformer is loaded and both are loaded @@ -223,39 +233,37 @@ int addon_init (uint32 index, becasso_addon_info *info) // will crash when the add-ons are exited (addon_exit). // // When IMAGEMANIP_WEAK_LINKAGE is defined we solve this problem - // as Imagelibmanip is loaded in each wrapper add-on. + // as Imagelibmanip is loaded in each wrapper add-on. // Check the library's version int32 curVersion; int32 minVersion; // Initialize the image manipulation library - if (Image_Init(NULL) != B_OK) - { + if (Image_Init(NULL) != B_OK) { puts("Cannot initialize libimagemanip.so"); return B_ERROR; } // Check the library's version puts(Image_Version(&curVersion, &minVersion)); - if (curVersion < IMAGE_LIB_MIN_VERSION) - { + if (curVersion < IMAGE_LIB_MIN_VERSION) { puts("Need a newer version of libimagemanip.so"); return B_ERROR; } - if (minVersion > IMAGE_LIB_CUR_VERSION) - { + if (minVersion > IMAGE_LIB_CUR_VERSION) { puts("Need an older version of libimagemanip.so"); return B_ERROR; } #endif - window = new WrapperWindow (BRect (100, 180, 100 + 188, 180 + 72), info); + window = new WrapperWindow(BRect(100, 180, 100 + 188, 180 + 72), info); window->Run(); return (0); } -int addon_exit (void) +int +addon_exit(void) { // We have to remove the config view from Imagelibmanip otherwise we // crash when the destructor of this window is called! @@ -267,219 +275,220 @@ int addon_exit (void) // Note: We assume that the addon_exit of the transformer is called // after the filter add-on. Image_Shutdown(); -#endif +#endif return (0); } -int addon_open (BWindow *client, const char *name) +int +addon_open(BWindow* client, const char* name) { char title[B_FILE_NAME_LENGTH]; - sprintf (title, WINDOW_TITLE, name); + sprintf(title, WINDOW_TITLE, name); window->Lock(); - window->SetTitle (title); + window->SetTitle(title); if (window->IsHidden()) - window->aShow (client); + window->aShow(client); else - window->aActivate (client); + window->aActivate(client); window->SetStatus("Status"); window->Unlock(); return (0); } -int addon_close () +int +addon_close() { window->aClose(); return (0); } -int process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * frame, bool final, BPoint /* point */, uint32 /* buttons */) +int +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* frame, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); -// printf ("Bounds: "); -// bounds.PrintToStream(); -// printf ("Frame: "); -// frame->PrintToStream(); -// fprintf(stderr, "mode = %d final = %d\n", mode, final); -// fprintf(stderr, "in %x out %x in %x out %x\n", inLayer, *outLayer, inSelection, *outSelection); + // printf ("Bounds: "); + // bounds.PrintToStream(); + // printf ("Frame: "); + // frame->PrintToStream(); + // fprintf(stderr, "mode = %d final = %d\n", mode, final); + // fprintf(stderr, "in %x out %x in %x out %x\n", inLayer, *outLayer, inSelection, + //*outSelection); -#ifdef MANIPULATOR +#ifdef MANIPULATOR if (*outLayer == NULL && mode == M_DRAW) { - *outLayer = new Layer (*inLayer); + *outLayer = new Layer(*inLayer); } if (*outSelection == NULL && mode == M_DRAW) { *outSelection = inSelection; } - - if (mode == M_SELECT) - { - if (inSelection) - { - if (*outSelection == NULL) - *outSelection = new Selection (*inSelection); - } - else // No Selection to filter! + + if (mode == M_SELECT) { + if (inSelection) { + if (*outSelection == NULL) + *outSelection = new Selection(*inSelection); + } else // No Selection to filter! return (0); } if (*outLayer) (*outLayer)->Lock(); - + if (*outSelection) (*outSelection)->Lock(); #endif -// fprintf(stderr, "in %x out %x in %x out %x\n", inLayer, *outLayer, inSelection, *outSelection); - + // fprintf(stderr, "in %x out %x in %x out %x\n", inLayer, *outLayer, inSelection, + //*outSelection); + uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - if (final) - { + if (final) { window->Lock(); window->Start(); window->Unlock(); - } - else - { -// return error; - } - - - switch (mode) - { - #ifdef MANIPULATOR // Becasso Filter - case M_DRAW: - { - // Create bitmap accessor object - memcpy((*outLayer)->Bits(), inLayer->Bits(), inLayer->BitsLength()); - Layer* layer; - if (inSelection) { - layer = new Layer(*inLayer); - memcpy(layer->Bits(), inLayer->Bits(), inLayer->BitsLength()); - } else { - layer = *outLayer; - } - BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(layer); - if (src_accessor == NULL) { - error = ADDON_ABORT;; - if (inSelection) delete layer; - break; - } + } else { + // return error; + } + + + switch (mode) { +#ifdef MANIPULATOR // Becasso Filter + case M_DRAW: { + // Create bitmap accessor object + memcpy((*outLayer)->Bits(), inLayer->Bits(), inLayer->BitsLength()); + Layer* layer; + if (inSelection) { + layer = new Layer(*inLayer); + memcpy(layer->Bits(), inLayer->Bits(), inLayer->BitsLength()); + } else { + layer = *outLayer; + } + BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(layer); + if (src_accessor == NULL) { + error = ADDON_ABORT; + ; + if (inSelection) + delete layer; + break; + } + src_accessor->SetDispose(false); + + if (Image_Manipulate(mAddonId, src_accessor, 0) < 0) { + window->Lock(); + window->SetStatus("Error"); + window->Unlock(); + } + delete src_accessor; + + if (mApplyToSelection && inSelection) { + memcpy((*outSelection)->Bits(), inSelection->Bits(), inSelection->BitsLength()); + src_accessor = Image_CreateBBitmapAccessor(*outSelection); src_accessor->SetDispose(false); - if (Image_Manipulate(mAddonId, src_accessor, 0) < 0) { window->Lock(); - window->SetStatus("Error"); + window->SetStatus("Selection not supported"); window->Unlock(); } delete src_accessor; - - if (mApplyToSelection && inSelection) { - memcpy((*outSelection)->Bits(), inSelection->Bits(), inSelection->BitsLength()); - src_accessor = Image_CreateBBitmapAccessor(*outSelection); - src_accessor->SetDispose(false); - if (Image_Manipulate(mAddonId, src_accessor, 0) < 0) { - window->Lock(); - window->SetStatus("Selection not supported"); - window->Unlock(); - } - delete src_accessor; - } + } - if (inSelection && *outSelection) { - CutOrCopy(layer, layer, *outSelection, 0, 0, false); - AddWithAlpha(layer, *outLayer, 0, 0); - } + if (inSelection && *outSelection) { + CutOrCopy(layer, layer, *outSelection, 0, 0, false); + AddWithAlpha(layer, *outLayer, 0, 0); + } - if (inSelection) { - delete layer; - } + if (inSelection) { + delete layer; + } break; + } + case M_SELECT: { + // Create bitmap accessor object + memcpy((*outSelection)->Bits(), inSelection->Bits(), inSelection->BitsLength()); + BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(*outSelection); + if (src_accessor == NULL) { + error = ADDON_ABORT; + ; + break; } - case M_SELECT: - { + src_accessor->SetDispose(false); + + if (Image_Manipulate(mAddonId, src_accessor, 0) < 0) { + window->Lock(); + window->SetStatus("Error"); + window->Unlock(); + } + delete src_accessor; + break; + } +#endif + + +#ifdef CONVERTER // Becasso Transformer + case M_SELECT: + case M_DRAW: { + if (mode == M_DRAW && *outLayer == NULL || mode == M_SELECT && *outSelection == NULL) { // Create bitmap accessor object - memcpy((*outSelection)->Bits(), inSelection->Bits(), inSelection->BitsLength()); - BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(*outSelection); + BBitmapAccessor* src_accessor = + Image_CreateBBitmapAccessor(mode == M_DRAW ? inLayer : inSelection); if (src_accessor == NULL) { - error = ADDON_ABORT;; + error = ADDON_ABORT; + ; break; } src_accessor->SetDispose(false); - if (Image_Manipulate(mAddonId, src_accessor, 0) < 0) { + // Create empty bitmap accessor object for the destination + BBitmapAccessor* dest_accessor = Image_CreateBBitmapAccessor(); + + // Do image conversion + if (Image_Convert(mAddonId, src_accessor, dest_accessor, NULL) < 0) { window->Lock(); window->SetStatus("Error"); window->Unlock(); } - delete src_accessor; - break; - } - #endif - - - #ifdef CONVERTER // Becasso Transformer - case M_SELECT: - case M_DRAW: - { - if (mode == M_DRAW && *outLayer == NULL || mode == M_SELECT && *outSelection == NULL) { - // Create bitmap accessor object - BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(mode == M_DRAW ? inLayer : inSelection); - if (src_accessor == NULL) { - error = ADDON_ABORT;; - break; - } - src_accessor->SetDispose(false); - - // Create empty bitmap accessor object for the destination - BBitmapAccessor* dest_accessor = Image_CreateBBitmapAccessor(); - - // Do image conversion - if (Image_Convert(mAddonId, src_accessor, dest_accessor, NULL) < 0) { - window->Lock(); - window->SetStatus("Error"); - window->Unlock(); + + // Got valid new bitmap? + if (dest_accessor->IsValid()) { + BBitmap* dest = dest_accessor->Bitmap(); + dest->Lock(); + fprintf(stderr, "ColorSpace %d\n", inLayer->ColorSpace()); + fprintf(stderr, "ColorSpace %d\n", dest->ColorSpace()); + if (mode == M_DRAW && dest->ColorSpace() == B_RGBA32) { + fprintf(stderr, "new Layer\n"); + *frame = dest->Bounds(); + frame->PrintToStream(); + *outLayer = new Layer(*frame, "Transformed"); + (*outLayer)->Bounds().PrintToStream(); + memcpy((*outLayer)->Bits(), dest->Bits(), dest->BitsLength()); } - - // Got valid new bitmap? - if (dest_accessor->IsValid()) - { - BBitmap* dest = dest_accessor->Bitmap(); - dest->Lock(); - fprintf(stderr, "ColorSpace %d\n", inLayer->ColorSpace()); - fprintf(stderr, "ColorSpace %d\n", dest->ColorSpace()); - if (mode == M_DRAW && dest->ColorSpace() == B_RGBA32) { - fprintf(stderr, "new Layer\n"); - *frame = dest->Bounds(); - frame->PrintToStream(); - *outLayer = new Layer(*frame, "Transformed"); - (*outLayer)->Bounds().PrintToStream(); - memcpy((*outLayer)->Bits(), dest->Bits(), dest->BitsLength()); - } - if (mode == M_SELECT && dest->ColorSpace() == B_GRAY8) { - fprintf(stderr, "new Selection\n"); - *frame = dest->Bounds(); - frame->PrintToStream(); - *outSelection = new Selection(*frame); - (*outSelection)->Bounds().PrintToStream(); - memcpy((*outSelection)->Bits(), dest->Bits(), dest->BitsLength()); - } - dest->Unlock(); + if (mode == M_SELECT && dest->ColorSpace() == B_GRAY8) { + fprintf(stderr, "new Selection\n"); + *frame = dest->Bounds(); + frame->PrintToStream(); + *outSelection = new Selection(*frame); + (*outSelection)->Bounds().PrintToStream(); + memcpy((*outSelection)->Bits(), dest->Bits(), dest->BitsLength()); } - delete dest_accessor; delete src_accessor; - } else { - fprintf(stderr, "Wrapper: outLayer must be null\n"); + dest->Unlock(); } - break; + delete dest_accessor; + delete src_accessor; + } else { + fprintf(stderr, "Wrapper: outLayer must be null\n"); } -#endif - + break; + } +#endif + default: - fprintf (stderr, "Wrapper: Unknown mode\n"); + fprintf(stderr, "Wrapper: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -489,9 +498,8 @@ int process (Layer *inLayer, Selection *inSelection, if (*outLayer) (*outLayer)->Unlock(); #endif - - if (final) - { + + if (final) { window->Lock(); window->Stopped(); window->Unlock(); diff --git a/source/LibImageManipWrapper2/LibImageManip/Source/BBitmapAccessor.cpp b/source/LibImageManipWrapper2/LibImageManip/Source/BBitmapAccessor.cpp index cc2a94c..c1002d7 100644 --- a/source/LibImageManipWrapper2/LibImageManip/Source/BBitmapAccessor.cpp +++ b/source/LibImageManipWrapper2/LibImageManip/Source/BBitmapAccessor.cpp @@ -18,33 +18,23 @@ #include "BitmapAccessor.h" #include "BBitmapAccessor.h" +BBitmapAccessor::BBitmapAccessor(BBitmap* bitmap, const BRect* section) -BBitmapAccessor::BBitmapAccessor( - BBitmap *bitmap, - const BRect *section) - - : BitmapAccessor() - , mBitmap(bitmap) - , mDispose(true) - , mLastAreaChanged(false) - , mCreateInvoker(NULL) - , mUpdateInvoker(NULL) + : BitmapAccessor(), mBitmap(bitmap), mDispose(true), mLastAreaChanged(false), + mCreateInvoker(NULL), mUpdateInvoker(NULL) { - if (bitmap) - { + if (bitmap) { mBounds = bitmap->Bounds(); - if (section) + if (section) mBounds = mBounds & (*section); mPixelSize = BytesPerPixel(); } } - BBitmapAccessor::~BBitmapAccessor() { - if (mUpdateInvoker && mLastAreaChanged) - { + if (mUpdateInvoker && mLastAreaChanged) { BMessage msg(*mUpdateInvoker->Message()); msg.AddRect("rect", mLastArea); mUpdateInvoker->Invoke(&msg); @@ -56,18 +46,14 @@ BBitmapAccessor::~BBitmapAccessor() delete mBitmap; } - bool BBitmapAccessor::IsValid() { return mBitmap && mBitmap->IsValid() && mBounds.IsValid(); } - bool -BBitmapAccessor::CreateBitmap( - BRect bounds, - color_space space) +BBitmapAccessor::CreateBitmap(BRect bounds, color_space space) { if (mDispose) delete mBitmap; @@ -76,8 +62,7 @@ BBitmapAccessor::CreateBitmap( mBounds = mBitmap->Bounds(); mPixelSize = BytesPerPixel(); - if (mCreateInvoker) - { + if (mCreateInvoker) { BMessage msg(*mCreateInvoker->Message()); msg.AddPointer("bitmap", mBitmap); mCreateInvoker->Invoke(&msg); @@ -86,28 +71,22 @@ BBitmapAccessor::CreateBitmap( return IsValid(); } - BRect BBitmapAccessor::Bounds() { return mBounds; } - color_space BBitmapAccessor::ColorSpace() { return mBitmap->ColorSpace(); } - -void * -BBitmapAccessor::AccessBits( - BRect area, - int32 *rowBytes) +void* +BBitmapAccessor::AccessBits(BRect area, int32* rowBytes) { - if (mUpdateInvoker && mLastAreaChanged && mLastArea.IsValid()) - { + if (mUpdateInvoker && mLastAreaChanged && mLastArea.IsValid()) { BMessage msg(*mUpdateInvoker->Message()); msg.AddRect("rect", mLastArea); mUpdateInvoker->Invoke(&msg); @@ -118,45 +97,36 @@ BBitmapAccessor::AccessBits( if (rowBytes) *rowBytes = mBitmap->BytesPerRow(); - return static_cast(mBitmap->Bits()) + - int(area.top) * *rowBytes + - int(floor(area.left) * mPixelSize); + return static_cast(mBitmap->Bits()) + int(area.top) * *rowBytes + + int(floor(area.left) * mPixelSize); } - void BBitmapAccessor::BitsNotChanged() { mLastAreaChanged = false; } - -BBitmap * +BBitmap* BBitmapAccessor::Bitmap() const { return mBitmap; } - bool BBitmapAccessor::Dispose() const { return mDispose; } - void -BBitmapAccessor::SetDispose( - bool flag) +BBitmapAccessor::SetDispose(bool flag) { mDispose = flag; } - void -BBitmapAccessor::SetInvokers( - BInvoker *bitmapCreated, - BInvoker *bitmapUpdated) +BBitmapAccessor::SetInvokers(BInvoker* bitmapCreated, BInvoker* bitmapUpdated) { delete mCreateInvoker; mCreateInvoker = bitmapCreated; @@ -165,18 +135,25 @@ BBitmapAccessor::SetInvokers( mUpdateInvoker = bitmapUpdated; } - // For possible future expansion -void BBitmapAccessor::_ReservedBBitmapAccessor1() {} -void BBitmapAccessor::_ReservedBBitmapAccessor2() {} -void BBitmapAccessor::_ReservedBBitmapAccessor3() {} +void +BBitmapAccessor::_ReservedBBitmapAccessor1() +{ +} +void +BBitmapAccessor::_ReservedBBitmapAccessor2() +{ +} + +void +BBitmapAccessor::_ReservedBBitmapAccessor3() +{ +} // Create a new BBitmapAccessor object; mimics the contructor -BBitmapAccessor * -Image_CreateBBitmapAccessor( - BBitmap *bitmap, - const BRect *section) +BBitmapAccessor* +Image_CreateBBitmapAccessor(BBitmap* bitmap, const BRect* section) { return new BBitmapAccessor(bitmap, section); } diff --git a/source/LibImageManipWrapper2/LibImageManip/Source/BBitmapAccessor.h b/source/LibImageManipWrapper2/LibImageManip/Source/BBitmapAccessor.h index e4b08a3..3200956 100644 --- a/source/LibImageManipWrapper2/LibImageManip/Source/BBitmapAccessor.h +++ b/source/LibImageManipWrapper2/LibImageManip/Source/BBitmapAccessor.h @@ -24,14 +24,13 @@ class BBitmap; class BInvoker; - // All functions are virtual for weak linkage to work class _IMPEXP_IMAGEMANIP BBitmapAccessor : public BitmapAccessor { -public: + public: // Constructor - BBitmapAccessor(BBitmap *bitmap = NULL, const BRect *section = NULL); + BBitmapAccessor(BBitmap* bitmap = NULL, const BRect* section = NULL); // Overriden BitmapAccessor functions virtual ~BBitmapAccessor(); @@ -39,11 +38,11 @@ class _IMPEXP_IMAGEMANIP BBitmapAccessor : public BitmapAccessor virtual bool CreateBitmap(BRect bounds, color_space space); virtual BRect Bounds(); virtual color_space ColorSpace(); - virtual void *AccessBits(BRect area, int32 *rowBytes); + virtual void* AccessBits(BRect area, int32* rowBytes); virtual void BitsNotChanged(); // Get pointer to the BBitmap - virtual BBitmap *Bitmap() const; + virtual BBitmap* Bitmap() const; // Get/set if the BBitmap should be deleted at destruction time virtual bool Dispose() const; @@ -51,31 +50,28 @@ class _IMPEXP_IMAGEMANIP BBitmapAccessor : public BitmapAccessor // Set invokers for automatically sending messages when a bitmap // is created and/or when it is updated - virtual void SetInvokers(BInvoker *bitmapCreated, BInvoker *bitmapUpdated); + virtual void SetInvokers(BInvoker* bitmapCreated, BInvoker* bitmapUpdated); -private: + private: virtual void _ReservedBBitmapAccessor1(); virtual void _ReservedBBitmapAccessor2(); virtual void _ReservedBBitmapAccessor3(); - BBitmap *mBitmap; + BBitmap* mBitmap; BRect mBounds; float mPixelSize; bool mDispose; BRect mLastArea; bool mLastAreaChanged; - BInvoker *mCreateInvoker; - BInvoker *mUpdateInvoker; + BInvoker* mCreateInvoker; + BInvoker* mUpdateInvoker; int32 _reserved[3]; }; - // Create a new BBitmapAccessor object; mimics the contructor -extern "C" _IMPEXP_IMAGEMANIP BBitmapAccessor * -Image_CreateBBitmapAccessor( - BBitmap *bitmap = NULL, - const BRect *section = NULL); +extern "C" _IMPEXP_IMAGEMANIP BBitmapAccessor* +Image_CreateBBitmapAccessor(BBitmap* bitmap = NULL, const BRect* section = NULL); -#endif // _BBITMAP_ACCESSOR_H_ +#endif // _BBITMAP_ACCESSOR_H_ diff --git a/source/LibImageManipWrapper2/LibImageManip/Source/BitmapAccessor.cpp b/source/LibImageManipWrapper2/LibImageManip/Source/BitmapAccessor.cpp index d04c8dc..b95a4b0 100644 --- a/source/LibImageManipWrapper2/LibImageManip/Source/BitmapAccessor.cpp +++ b/source/LibImageManipWrapper2/LibImageManip/Source/BitmapAccessor.cpp @@ -14,26 +14,32 @@ #include "BitmapAccessor.h" - BitmapAccessor::~BitmapAccessor() {} - float BitmapAccessor::BytesPerPixel() { size_t pixelChunk; size_t rowAlignment; size_t pixelsPerChunk; - if (get_pixel_size_for(ColorSpace(), - &pixelChunk, &rowAlignment, &pixelsPerChunk) != B_OK) - { + if (get_pixel_size_for(ColorSpace(), &pixelChunk, &rowAlignment, &pixelsPerChunk) != B_OK) { return 0.0; } - - return (float) pixelChunk / (float) pixelsPerChunk; + + return (float)pixelChunk / (float)pixelsPerChunk; +} + +void +BitmapAccessor::_ReservedBitmapAccessor1() +{ } +void +BitmapAccessor::_ReservedBitmapAccessor2() +{ +} -void BitmapAccessor::_ReservedBitmapAccessor1() {} -void BitmapAccessor::_ReservedBitmapAccessor2() {} -void BitmapAccessor::_ReservedBitmapAccessor3() {} +void +BitmapAccessor::_ReservedBitmapAccessor3() +{ +} diff --git a/source/LibImageManipWrapper2/LibImageManip/Source/BitmapAccessor.h b/source/LibImageManipWrapper2/LibImageManip/Source/BitmapAccessor.h index a01a9a5..238f2e4 100644 --- a/source/LibImageManipWrapper2/LibImageManip/Source/BitmapAccessor.h +++ b/source/LibImageManipWrapper2/LibImageManip/Source/BitmapAccessor.h @@ -26,20 +26,20 @@ #define _IMPEXP_IMAGEMANIP __declspec(dllexport) #else #define _IMPEXP_IMAGEMANIP __declspec(dllimport) -#endif // _BUILDING_imagemanip -#endif // _IMPEXP_IMAGEMANIP +#endif // _BUILDING_imagemanip +#endif // _IMPEXP_IMAGEMANIP // This is the abstract base class that is used for the interface class _IMPEXP_IMAGEMANIP BitmapAccessor { -public: + public: virtual ~BitmapAccessor(); virtual bool IsValid() = 0; virtual bool CreateBitmap(BRect bounds, color_space space) = 0; virtual BRect Bounds() = 0; virtual color_space ColorSpace() = 0; - virtual float BytesPerPixel(); + virtual float BytesPerPixel(); // With the AccessBits() function you gain access to the raw bytes of a // certain area of the bitmap. The number of bytes to skip to get to the @@ -47,14 +47,14 @@ class _IMPEXP_IMAGEMANIP BitmapAccessor // AccessBits() is only valid as long as no other calls to AccessBits() // (or to the destructor) have been made. For efficiency reasons you // should keep the requested area small. - virtual void *AccessBits(BRect area, int32 *rowBytes) = 0; + virtual void* AccessBits(BRect area, int32* rowBytes) = 0; // If you haven't changed the bits accessed through AccessBits() then // you should call BitsNotChanged() before accessing a new area. // Unchanged areas don't need to be updated, which is more efficient. virtual void BitsNotChanged() = 0; -private: + private: // For possible future expansion virtual void _ReservedBitmapAccessor1(); virtual void _ReservedBitmapAccessor2(); @@ -63,4 +63,4 @@ class _IMPEXP_IMAGEMANIP BitmapAccessor }; -#endif // _BITMAP_ACCESSOR_H_ +#endif // _BITMAP_ACCESSOR_H_ diff --git a/source/LibImageManipWrapper2/LibImageManip/Source/DitherFloydSteinberg/DitherFloydSteinberg.cpp b/source/LibImageManipWrapper2/LibImageManip/Source/DitherFloydSteinberg/DitherFloydSteinberg.cpp index 49d3e19..be1bb60 100644 --- a/source/LibImageManipWrapper2/LibImageManip/Source/DitherFloydSteinberg/DitherFloydSteinberg.cpp +++ b/source/LibImageManipWrapper2/LibImageManip/Source/DitherFloydSteinberg/DitherFloydSteinberg.cpp @@ -13,17 +13,16 @@ const char addonName[] = "Dither Floyd-Steinberg"; -const char addonInfo[] = "Dither a 32-bit bitmap to 8-bit. By Edmund Vermeulen ."; +const char addonInfo[] = + "Dither a 32-bit bitmap to 8-bit. By Edmund Vermeulen ."; const char addonCategory[] = "Color"; int32 addonVersion = 150; - status_t Convert( - BitmapAccessor *sourceBitmap, - BitmapAccessor *destBitmap, - BMessage * /*ioExtension*/, - bool checkOnly) + BitmapAccessor* sourceBitmap, BitmapAccessor* destBitmap, BMessage* /*ioExtension*/, + bool checkOnly +) { // We only support 32-bit bitmaps color_space cs = sourceBitmap->ColorSpace(); @@ -35,7 +34,7 @@ Convert( // Get source pixel size; // we only use the first three bytes, and skip the rest - int source_pixel_size = (int) sourceBitmap->BytesPerPixel(); + int source_pixel_size = (int)sourceBitmap->BytesPerPixel(); if (source_pixel_size < 3) return B_ERROR; @@ -49,52 +48,59 @@ Convert( // Get destination pixel size; // we only use the first byte, and skip the rest - int dest_pixel_size = (int) destBitmap->BytesPerPixel(); + int dest_pixel_size = (int)destBitmap->BytesPerPixel(); if (dest_pixel_size < 1) return B_ERROR; // Get colour palette for 8-bit screens - const rgb_color *palette = system_colors()->color_list; - const uchar *index_list = system_colors()->index_map; + const rgb_color* palette = system_colors()->color_list; + const uchar* index_list = system_colors()->index_map; // Create the delta buffer int32 size = 3 * (int(destBitmap->Bounds().Width()) + 3); - float *delta_buffer = new float[size]; + float* delta_buffer = new float[size]; for (int32 i = 0; i < size; ++i) delta_buffer[i] = 0.0; // Work our way through the data row by row - for (float y = 0.0; y <= height; ++y) - { + for (float y = 0.0; y <= height; ++y) { int32 source_row_bytes; - uchar *src = static_cast(sourceBitmap->AccessBits( + uchar* src = static_cast(sourceBitmap->AccessBits( BRect( - source_bounds.left, - source_bounds.top + y, - source_bounds.right, - source_bounds.top + y), - &source_row_bytes)); + source_bounds.left, source_bounds.top + y, source_bounds.right, + source_bounds.top + y + ), + &source_row_bytes + )); - sourceBitmap->BitsNotChanged(); // read-only + sourceBitmap->BitsNotChanged(); // read-only int32 dest_row_bytes; - uchar *in_bitmap = static_cast(destBitmap->AccessBits( - BRect(0.0, y, width, y), &dest_row_bytes)); + uchar* in_bitmap = + static_cast(destBitmap->AccessBits(BRect(0.0, y, width, y), &dest_row_bytes)); - float *deltas = delta_buffer; + float* deltas = delta_buffer; float r_delta = 0.0; float g_delta = 0.0; float b_delta = 0.0; // Do all pixels on one row - for (float x = 0.0; x <= width; ++x) - { + for (float x = 0.0; x <= width; ++x) { // Get a pixel from the input buffer and add corrections // from the pixels around it through Floyd-Steinberg diffusion - int32 r = int32(src[2]) + int32(r_delta * 0.4375 + deltas[0] * 0.0625 + deltas[3] * 0.3125 + deltas[6] * 0.1875); - int32 g = int32(src[1]) + int32(g_delta * 0.4375 + deltas[1] * 0.0625 + deltas[4] * 0.3125 + deltas[7] * 0.1875); - int32 b = int32(src[0]) + int32(b_delta * 0.4375 + deltas[2] * 0.0625 + deltas[5] * 0.3125 + deltas[8] * 0.1875); + int32 r = int32(src[2]) + int32( + r_delta * 0.4375 + deltas[0] * 0.0625 + + deltas[3] * 0.3125 + deltas[6] * 0.1875 + ); + int32 g = int32(src[1]) + int32( + g_delta * 0.4375 + deltas[1] * 0.0625 + + deltas[4] * 0.3125 + deltas[7] * 0.1875 + ); + int32 b = int32(src[0]) + int32( + b_delta * 0.4375 + deltas[2] * 0.0625 + + deltas[5] * 0.3125 + deltas[8] * 0.1875 + ); // Store deltas for the current pixel deltas[0] = r_delta; @@ -104,11 +110,11 @@ Convert( // Fix high and low values r = r > 255 ? 255 : r; - r = r < 0 ? 0 : r; + r = r < 0 ? 0 : r; g = g > 255 ? 255 : g; - g = g < 0 ? 0 : g; + g = g < 0 ? 0 : g; b = b > 255 ? 255 : b; - b = b < 0 ? 0 : b; + b = b < 0 ? 0 : b; // Let's see which colour we get from the BeOS palette uchar colour = index_list[((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3)]; @@ -125,7 +131,7 @@ Convert( src += source_pixel_size; } } - + delete[] delta_buffer; return B_OK; diff --git a/source/LibImageManipWrapper2/LibImageManip/Source/ExampleApp/ExampleApp.cpp b/source/LibImageManipWrapper2/LibImageManip/Source/ExampleApp/ExampleApp.cpp index 9952536..4f30831 100644 --- a/source/LibImageManipWrapper2/LibImageManip/Source/ExampleApp/ExampleApp.cpp +++ b/source/LibImageManipWrapper2/LibImageManip/Source/ExampleApp/ExampleApp.cpp @@ -33,12 +33,12 @@ // Defines -#define WINDOW_CLOSED 'winc' -#define SHOW_FILE_PANEL 'shfp' -#define IMAGE_MANIP 'mnip' -#define IMAGE_CONV 'conv' +#define WINDOW_CLOSED 'winc' +#define SHOW_FILE_PANEL 'shfp' +#define IMAGE_MANIP 'mnip' +#define IMAGE_CONV 'conv' #define IMAGE_CONF_MANIP 'cnfm' -#define IMAGE_CONF_CONV 'cnfc' +#define IMAGE_CONF_CONV 'cnfc' // MyFilePanel class class MyFilePanel : public BFilePanel @@ -50,120 +50,118 @@ class MyFilePanel : public BFilePanel }; }; - // ExampleApp class class ExampleApp : public BApplication { -public: + public: ExampleApp(); virtual void ReadyToRun(void); virtual void AboutRequested(); virtual bool QuitRequested(void); - virtual void MessageReceived(BMessage *msg); - virtual void RefsReceived(BMessage *message); + virtual void MessageReceived(BMessage* msg); + virtual void RefsReceived(BMessage* message); -private: - MyFilePanel *mOpenPanel; + private: + MyFilePanel* mOpenPanel; }; - // BitmapView class class BitmapView : public BView { -public: - BitmapView(BBitmap *bitmap); + public: + BitmapView(BBitmap* bitmap); ~BitmapView(); virtual void Draw(BRect update); virtual void AttachedToWindow(); - virtual void FrameResized(float width, float height); - BBitmap *Bitmap() const; + virtual void FrameResized(float width, float height); + BBitmap* Bitmap() const; -private: - BBitmap *mBitmap; + private: + BBitmap* mBitmap; float mBitmapWidth; float mBitmapHeight; - BScrollBar *mHorBar; - BScrollBar *mVerBar; + BScrollBar* mHorBar; + BScrollBar* mVerBar; }; - // ImageWindow class class ImageWindow : public BWindow { -public: - ImageWindow(const char *title, BBitmap *bitmap); + public: + ImageWindow(const char* title, BBitmap* bitmap); virtual bool QuitRequested(void); - virtual void MessageReceived(BMessage *msg); + virtual void MessageReceived(BMessage* msg); static int sWindowCount; -private: - BMenu *CreateFileMenu(BBitmap *bitmap); - static void ImageManip_entry(ImageWindow *obj); + private: + BMenu* CreateFileMenu(BBitmap* bitmap); + static void ImageManip_entry(ImageWindow* obj); void ImageManip(); - static void ImageConvert_entry(ImageWindow *obj); + static void ImageConvert_entry(ImageWindow* obj); void ImageConvert(); void PrintAddonInfo(); - BitmapView *mBitmapView; + BitmapView* mBitmapView; bool mBitmapInUse; image_addon_id mAddonId; }; // ConfigWindow class -class ConfigWindow : public BWindow { +class ConfigWindow : public BWindow +{ BMessenger* mWindow; int mAddonId; int32 mWhat; - -public: + + public: ConfigWindow(int addonId, int32 what, const char* title, ImageWindow* win); ~ConfigWindow(); void MessageReceived(BMessage* msg); }; -ConfigWindow::ConfigWindow(int addonId, int32 what, const char* title, ImageWindow* win) : - BWindow(BRect(40, 40, 400, 600), "", B_TITLED_WINDOW, B_NOT_RESIZABLE), - mAddonId(addonId), - mWhat(what) { +ConfigWindow::ConfigWindow(int addonId, int32 what, const char* title, ImageWindow* win) + : BWindow(BRect(40, 40, 400, 600), "", B_TITLED_WINDOW, B_NOT_RESIZABLE), mAddonId(addonId), + mWhat(what) +{ BString s("Configure "); s += title; SetTitle(s.String()); mWindow = new BMessenger(win); - BView *view; + BView* view; Image_MakeConfigurationView(addonId, NULL, &view); AddChild(view); BRect r(view->Bounds()); - BButton* apply = new BButton(BRect(0, r.bottom+5, 40, r.bottom+25), "apply", "Apply", new BMessage('aply')); + BButton* apply = new BButton( + BRect(0, r.bottom + 5, 40, r.bottom + 25), "apply", "Apply", new BMessage('aply') + ); AddChild(apply); - ResizeTo(r.Width(), r.Height()+40); + ResizeTo(r.Width(), r.Height() + 40); Show(); } -ConfigWindow::~ConfigWindow() { - delete mWindow; -} +ConfigWindow::~ConfigWindow() { delete mWindow; } -void ConfigWindow::MessageReceived(BMessage* msg) { - switch(msg->what) { - case 'aply': - { - BMessage m(mWhat); - m.AddInt32("addon_id", mAddonId); - mWindow->SendMessage(&m); - } - break; - default: - BWindow::MessageReceived(msg); - } +void +ConfigWindow::MessageReceived(BMessage* msg) +{ + switch (msg->what) { + case 'aply': { + BMessage m(mWhat); + m.AddInt32("addon_id", mAddonId); + mWindow->SendMessage(&m); + } break; + default: + BWindow::MessageReceived(msg); + } } // Where it all starts -int main() -{ +int +main() +{ // Initialize the image manipulation library - if (Image_Init(NULL) != B_OK) - { + if (Image_Init(NULL) != B_OK) { puts("Cannot initialize libimagemanip.so"); return B_ERROR; } @@ -172,13 +170,11 @@ int main() int32 curVersion; int32 minVersion; puts(Image_Version(&curVersion, &minVersion)); - if (curVersion < IMAGE_LIB_MIN_VERSION) - { + if (curVersion < IMAGE_LIB_MIN_VERSION) { puts("Need a newer version of libimagemanip.so"); return B_ERROR; } - if (minVersion > IMAGE_LIB_CUR_VERSION) - { + if (minVersion > IMAGE_LIB_CUR_VERSION) { puts("Need an older version of libimagemanip.so"); return B_ERROR; } @@ -193,45 +189,44 @@ int main() return B_OK; } - // Application constructor -ExampleApp::ExampleApp() : BApplication("application/x-vnd.imagemanip-exampleapp") - , mOpenPanel(NULL) +ExampleApp::ExampleApp() : BApplication("application/x-vnd.imagemanip-exampleapp"), mOpenPanel(NULL) { } - // Ready to run -void ExampleApp::ReadyToRun(void) +void +ExampleApp::ReadyToRun(void) { // Open file panel if there are no windows open if (ImageWindow::sWindowCount == 0) PostMessage(SHOW_FILE_PANEL); } - // About requested -void ExampleApp::AboutRequested() +void +ExampleApp::AboutRequested() { (new BAlert( - "About", - "ImageManipExample 1.0.0 (Oct 24th, 1999)\n\n" - "Example application for using the image manipulation library " - "'libimagemanip.so'\n\n" - "Public domain\n\n" - "Written by Edmund Vermeulen\n" - "E-mail: edmundv@xs4all.nl\n" - "Home: http://www.xs4all.nl/~edmundv/", - "OK"))->Go(NULL); + "About", + "ImageManipExample 1.0.0 (Oct 24th, 1999)\n\n" + "Example application for using the image manipulation library " + "'libimagemanip.so'\n\n" + "Public domain\n\n" + "Written by Edmund Vermeulen\n" + "E-mail: edmundv@xs4all.nl\n" + "Home: http://www.xs4all.nl/~edmundv/", + "OK" + )) + ->Go(NULL); } - // Quit requested -bool ExampleApp::QuitRequested(void) +bool +ExampleApp::QuitRequested(void) { // Make sure that the windows close first - if (BApplication::QuitRequested()) - { + if (BApplication::QuitRequested()) { delete mOpenPanel; return true; } @@ -239,57 +234,50 @@ bool ExampleApp::QuitRequested(void) return false; } - // Handle messages -void ExampleApp::MessageReceived(BMessage *msg) +void +ExampleApp::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case SHOW_FILE_PANEL: - if (!mOpenPanel) - mOpenPanel = new MyFilePanel(); - mOpenPanel->Show(); - break; - - case B_SIMPLE_DATA: // drag and drop - if (msg->HasRef("refs")) - RefsReceived(msg); - break; - - case WINDOW_CLOSED: - // Last window closed? - if (ImageWindow::sWindowCount == 0 && - (!mOpenPanel || !mOpenPanel->IsShowing())) - { - PostMessage(B_QUIT_REQUESTED); - } - break; + switch (msg->what) { + case SHOW_FILE_PANEL: + if (!mOpenPanel) + mOpenPanel = new MyFilePanel(); + mOpenPanel->Show(); + break; + + case B_SIMPLE_DATA: // drag and drop + if (msg->HasRef("refs")) + RefsReceived(msg); + break; + + case WINDOW_CLOSED: + // Last window closed? + if (ImageWindow::sWindowCount == 0 && (!mOpenPanel || !mOpenPanel->IsShowing())) { + PostMessage(B_QUIT_REQUESTED); + } + break; - default: - BApplication::MessageReceived(msg); - break; + default: + BApplication::MessageReceived(msg); + break; } } - // Handle opened files -void ExampleApp::RefsReceived(BMessage *msg) +void +ExampleApp::RefsReceived(BMessage* msg) { entry_ref the_ref; - for (int32 i = 0; msg->FindRef("refs", i, &the_ref) == B_OK; ++i) - { + for (int32 i = 0; msg->FindRef("refs", i, &the_ref) == B_OK; ++i) { char file_name[B_FILE_NAME_LENGTH]; strncpy(file_name, the_ref.name, B_FILE_NAME_LENGTH); - BFile *the_file = new BFile(&the_ref, B_READ_ONLY); - BBitmap *mBitmap = BTranslationUtils::GetBitmap(the_file); - if (mBitmap) - { + BFile* the_file = new BFile(&the_ref, B_READ_ONLY); + BBitmap* mBitmap = BTranslationUtils::GetBitmap(the_file); + if (mBitmap) { // Open new window with bitmap new ImageWindow(file_name, mBitmap); - } - else - { + } else { char alert_string[256]; sprintf(alert_string, "Couldn't get bitmap for '%s'.", file_name); (new BAlert("Error", alert_string, "OK"))->Go(); @@ -297,11 +285,10 @@ void ExampleApp::RefsReceived(BMessage *msg) } } - // Bitmap view constructor -BitmapView::BitmapView(BBitmap *bitmap) - : BView(bitmap->Bounds(), "bitmap", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS) - , mBitmap(bitmap) +BitmapView::BitmapView(BBitmap* bitmap) + : BView(bitmap->Bounds(), "bitmap", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS), + mBitmap(bitmap) { // No stinkin' background colour fills! SetViewColor(B_TRANSPARENT_32_BIT); @@ -310,7 +297,6 @@ BitmapView::BitmapView(BBitmap *bitmap) mBitmapHeight = mBitmap->Bounds().Height(); } - // Bitmap view destructor BitmapView::~BitmapView() { @@ -318,16 +304,16 @@ BitmapView::~BitmapView() delete mBitmap; } - // Blit bitmap -void BitmapView::Draw(BRect update) +void +BitmapView::Draw(BRect update) { DrawBitmap(mBitmap, update, update); } - // Find scroll bars -void BitmapView::AttachedToWindow() +void +BitmapView::AttachedToWindow() { mHorBar = ScrollBar(B_HORIZONTAL); mVerBar = ScrollBar(B_VERTICAL); @@ -335,9 +321,9 @@ void BitmapView::AttachedToWindow() BView::AttachedToWindow(); } - // Adjust scroll bars -void BitmapView::FrameResized(float width, float height) +void +BitmapView::FrameResized(float width, float height) { mHorBar->SetProportion(width / mBitmapWidth); mVerBar->SetProportion(height / mBitmapHeight); @@ -351,23 +337,21 @@ void BitmapView::FrameResized(float width, float height) BView::FrameResized(width, height); } - // Get pointer to bitmap -BBitmap *BitmapView::Bitmap() const +BBitmap* +BitmapView::Bitmap() const { return mBitmap; } - // Window constructor -ImageWindow::ImageWindow(const char *title, BBitmap *bitmap) - : BWindow(BRect(80.0, 26.0, 80.0, 26.0), title, B_DOCUMENT_WINDOW, 0) - , mBitmapInUse(false) +ImageWindow::ImageWindow(const char* title, BBitmap* bitmap) + : BWindow(BRect(80.0, 26.0, 80.0, 26.0), title, B_DOCUMENT_WINDOW, 0), mBitmapInUse(false) { ++sWindowCount; // Create menu bar - BMenuBar *menu_bar = new BMenuBar(BRect(0.0, 0.0, 0.0, 0.0), "menu"); + BMenuBar* menu_bar = new BMenuBar(BRect(0.0, 0.0, 0.0, 0.0), "menu"); menu_bar->AddItem(CreateFileMenu(bitmap)); // Add menu bar to window @@ -377,13 +361,14 @@ ImageWindow::ImageWindow(const char *title, BBitmap *bitmap) mBitmapView = new BitmapView(bitmap); // Create scrolling view - BScrollView *scroll_view = new BScrollView("scroll", mBitmapView, - B_FOLLOW_ALL_SIDES, B_WILL_DRAW, true, true, B_NO_BORDER); + BScrollView* scroll_view = new BScrollView( + "scroll", mBitmapView, B_FOLLOW_ALL_SIDES, B_WILL_DRAW, true, true, B_NO_BORDER + ); scroll_view->MoveTo(0.0, menu_bar->Frame().bottom + 1.0); // Set initial window size BRect win_rect = menu_bar->Frame() | scroll_view->Frame(); - float width = win_rect.Width() - 1.0; + float width = win_rect.Width() - 1.0; float height = win_rect.Height() - 1.0; // Set window size limits @@ -394,7 +379,7 @@ ImageWindow::ImageWindow(const char *title, BBitmap *bitmap) float min_height = 65.0; if (height < min_height) min_height = height; - + SetSizeLimits(min_width, width, min_height, height); ResizeTo(width, height); @@ -421,9 +406,9 @@ ImageWindow::ImageWindow(const char *title, BBitmap *bitmap) ResizeTo(width, height); } - // Quit requested -bool ImageWindow::QuitRequested(void) +bool +ImageWindow::QuitRequested(void) { // Bitmap still in use? if (mBitmapInUse) @@ -435,71 +420,65 @@ bool ImageWindow::QuitRequested(void) return true; } - // Handle messages to the window -void ImageWindow::MessageReceived(BMessage *msg) +void +ImageWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case B_SIMPLE_DATA: // drag and drop - if (msg->HasRef("refs")) - be_app->RefsReceived(msg); - break; - - case IMAGE_CONF_MANIP: - case IMAGE_CONF_CONV: - if (!mBitmapInUse) - { - BString name; - msg->FindString("addon_name", &name); - mAddonId = msg->FindInt32("addon_id"); - new ConfigWindow(mAddonId, msg->what == IMAGE_CONF_MANIP ? IMAGE_MANIP : IMAGE_CONV, name.String(), this); - } - break; - - case IMAGE_MANIP: - if (!mBitmapInUse) - { - mAddonId = msg->FindInt32("addon_id"); - - resume_thread(spawn_thread( - (thread_entry) ImageManip_entry, - "ImageManip", - B_NORMAL_PRIORITY, - this)); - } - break; - - case IMAGE_CONV: - if (!mBitmapInUse) - { - mAddonId = msg->FindInt32("addon_id"); - - resume_thread(spawn_thread( - (thread_entry) ImageConvert_entry, - "ImageConvert", - B_NORMAL_PRIORITY, - this)); - } - break; + switch (msg->what) { + case B_SIMPLE_DATA: // drag and drop + if (msg->HasRef("refs")) + be_app->RefsReceived(msg); + break; + + case IMAGE_CONF_MANIP: + case IMAGE_CONF_CONV: + if (!mBitmapInUse) { + BString name; + msg->FindString("addon_name", &name); + mAddonId = msg->FindInt32("addon_id"); + new ConfigWindow( + mAddonId, msg->what == IMAGE_CONF_MANIP ? IMAGE_MANIP : IMAGE_CONV, name.String(), + this + ); + } + break; + + case IMAGE_MANIP: + if (!mBitmapInUse) { + mAddonId = msg->FindInt32("addon_id"); + + resume_thread( + spawn_thread((thread_entry)ImageManip_entry, "ImageManip", B_NORMAL_PRIORITY, this) + ); + } + break; + + case IMAGE_CONV: + if (!mBitmapInUse) { + mAddonId = msg->FindInt32("addon_id"); + + resume_thread(spawn_thread( + (thread_entry)ImageConvert_entry, "ImageConvert", B_NORMAL_PRIORITY, this + )); + } + break; - default: - BWindow::MessageReceived(msg); - break; + default: + BWindow::MessageReceived(msg); + break; } } - // Initialise instance counter int ImageWindow::sWindowCount = 0; - // Create file menu -BMenu *ImageWindow::CreateFileMenu(BBitmap *bitmap) +BMenu* +ImageWindow::CreateFileMenu(BBitmap* bitmap) { - BMenu *menu = new BMenu("File"); + BMenu* menu = new BMenu("File"); - BMenuItem *item = new BMenuItem("About", new BMessage(B_ABOUT_REQUESTED)); + BMenuItem* item = new BMenuItem("About", new BMessage(B_ABOUT_REQUESTED)); item->SetTarget(be_app); menu->AddItem(item); menu->AddSeparatorItem(); @@ -515,21 +494,19 @@ BMenu *ImageWindow::CreateFileMenu(BBitmap *bitmap) accessor.SetDispose(false); // Create sub menu with image manipulators - BMenu *sub_menu = new BMenu("Manipulate Image"); - const char *addonName; - const char *addonInfo; - const char *addonCategory; + BMenu* sub_menu = new BMenu("Manipulate Image"); + const char* addonName; + const char* addonInfo; + const char* addonCategory; int32 addonVersion; - image_addon_id *outList; + image_addon_id* outList; int32 outCount = 0; - if (Image_GetManipulators(&accessor, NULL, &outList, &outCount) == B_OK) - { - for (int i = 0; i < outCount; ++i) - { - if (Image_GetAddonInfo(outList[i], &addonName, &addonInfo, - &addonCategory, &addonVersion) == B_OK) - { - BMessage *msg = new BMessage(IMAGE_CONF_MANIP); + if (Image_GetManipulators(&accessor, NULL, &outList, &outCount) == B_OK) { + for (int i = 0; i < outCount; ++i) { + if (Image_GetAddonInfo( + outList[i], &addonName, &addonInfo, &addonCategory, &addonVersion + ) == B_OK) { + BMessage* msg = new BMessage(IMAGE_CONF_MANIP); msg->AddInt32("addon_id", outList[i]); msg->AddString("addon_name", addonName); item = new BMenuItem(addonName, msg); @@ -546,14 +523,12 @@ BMenu *ImageWindow::CreateFileMenu(BBitmap *bitmap) // Create sub menu with image converters sub_menu = new BMenu("Convert Image"); outCount = 0; - if (Image_GetConverters(&accessor, NULL, &outList, &outCount) == B_OK) - { - for (int i = 0; i < outCount; ++i) - { - if (Image_GetAddonInfo(outList[i], &addonName, &addonInfo, - &addonCategory, &addonVersion) == B_OK) - { - BMessage *msg = new BMessage(IMAGE_CONF_CONV); + if (Image_GetConverters(&accessor, NULL, &outList, &outCount) == B_OK) { + for (int i = 0; i < outCount; ++i) { + if (Image_GetAddonInfo( + outList[i], &addonName, &addonInfo, &addonCategory, &addonVersion + ) == B_OK) { + BMessage* msg = new BMessage(IMAGE_CONF_CONV); msg->AddInt32("addon_id", outList[i]); msg->AddString("addon_name", addonName); item = new BMenuItem(addonName, msg); @@ -573,18 +548,19 @@ BMenu *ImageWindow::CreateFileMenu(BBitmap *bitmap) item = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'); item->SetTarget(be_app); menu->AddItem(item); - + return menu; } - // Image manipulate -void ImageWindow::ImageManip_entry(ImageWindow *obj) +void +ImageWindow::ImageManip_entry(ImageWindow* obj) { obj->ImageManip(); } -void ImageWindow::ImageManip() +void +ImageWindow::ImageManip() { mBitmapInUse = true; @@ -605,14 +581,15 @@ void ImageWindow::ImageManip() mBitmapInUse = false; } - // Image convert -void ImageWindow::ImageConvert_entry(ImageWindow *obj) +void +ImageWindow::ImageConvert_entry(ImageWindow* obj) { obj->ImageConvert(); } -void ImageWindow::ImageConvert() +void +ImageWindow::ImageConvert() { mBitmapInUse = true; @@ -629,8 +606,7 @@ void ImageWindow::ImageConvert() Image_Convert(mAddonId, &src_accessor, &dest_accessor, NULL); // Got valid new bitmap? - if (dest_accessor.IsValid()) - { + if (dest_accessor.IsValid()) { // Open it in a new window new ImageWindow(Title(), dest_accessor.Bitmap()); @@ -641,22 +617,23 @@ void ImageWindow::ImageConvert() mBitmapInUse = false; } - // Print add-on info -void ImageWindow::PrintAddonInfo() +void +ImageWindow::PrintAddonInfo() { - const char *addonName; - const char *addonInfo; - const char *addonCategory; + const char* addonName; + const char* addonInfo; + const char* addonCategory; int32 addonVersion; - if (Image_GetAddonInfo(mAddonId, &addonName, &addonInfo, - &addonCategory, &addonVersion) == B_OK) - { + if (Image_GetAddonInfo(mAddonId, &addonName, &addonInfo, &addonCategory, &addonVersion) == + B_OK) { int32 ver = addonVersion / 100; int32 rev1 = (addonVersion % 100) / 10; int32 rev2 = addonVersion % 10; - printf("Using '%s' version %ld.%ld.%ld\nCategory: %s\n%s\n", - addonName, ver, rev1, rev2, addonCategory, addonInfo); + printf( + "Using '%s' version %ld.%ld.%ld\nCategory: %s\n%s\n", addonName, ver, rev1, rev2, + addonCategory, addonInfo + ); } } diff --git a/source/LibImageManipWrapper2/LibImageManip/Source/GammaCorrect/GammaCorrect.cpp b/source/LibImageManipWrapper2/LibImageManip/Source/GammaCorrect/GammaCorrect.cpp index 6402416..f8300d0 100644 --- a/source/LibImageManipWrapper2/LibImageManip/Source/GammaCorrect/GammaCorrect.cpp +++ b/source/LibImageManipWrapper2/LibImageManip/Source/GammaCorrect/GammaCorrect.cpp @@ -21,12 +21,8 @@ const char addonInfo[] = "Make an image brighter. By Edmund Vermeulen ColorSpace(); @@ -37,7 +33,7 @@ Manipulate( return B_OK; // Get pixel size; we only use the first three bytes, and skip the rest - int pixel_size = (int) sourceBitmap->BytesPerPixel(); + int pixel_size = (int)sourceBitmap->BytesPerPixel(); if (pixel_size < 3) return B_ERROR; @@ -55,20 +51,19 @@ Manipulate( for (int i = 1; i < 256; i++) gamma_table[i] = uchar(beta * log(float(i) / alpha + 1.0)); - for (float y = sel_rect.top; y <= sel_rect.bottom; ++y) - { + for (float y = sel_rect.top; y <= sel_rect.bottom; ++y) { int32 rowBytes; - uchar *pixel = static_cast(sourceBitmap->AccessBits( - BRect(sel_rect.left, y, sel_rect.right, y), &rowBytes)); + uchar* pixel = static_cast( + sourceBitmap->AccessBits(BRect(sel_rect.left, y, sel_rect.right, y), &rowBytes) + ); - for (float x = sel_rect.left; x <= sel_rect.right; ++x) - { + for (float x = sel_rect.left; x <= sel_rect.right; ++x) { // Gamma correct pixel[0] = gamma_table[pixel[0]]; pixel[1] = gamma_table[pixel[1]]; pixel[2] = gamma_table[pixel[2]]; - - // Go to the next pixel + + // Go to the next pixel pixel += pixel_size; } } @@ -76,11 +71,8 @@ Manipulate( return B_OK; } - status_t -GetConfigMessage( - BMessage * /*ioExtension*/, - BMessage *ioCapability) +GetConfigMessage(BMessage* /*ioExtension*/, BMessage* ioCapability) { // Let them know that we support the selection rect extension ioCapability->AddInt32("selection_rect", B_RECT_TYPE); diff --git a/source/LibImageManipWrapper2/LibImageManip/Source/ImageManip.cpp b/source/LibImageManipWrapper2/LibImageManip/Source/ImageManip.cpp index 3f7bd17..a832ffe 100644 --- a/source/LibImageManipWrapper2/LibImageManip/Source/ImageManip.cpp +++ b/source/LibImageManipWrapper2/LibImageManip/Source/ImageManip.cpp @@ -35,19 +35,18 @@ static int debug = 0; // Multiple search paths are separated by colons (':') -static const char *defaultAddonPath = "/boot/home/config/add-ons/ImageManip"; +static const char* defaultAddonPath = "/boot/home/config/add-ons/ImageManip"; // Default string for 'no category' -static const char *noCategory = ""; +static const char* noCategory = ""; // File path for storing add-on settings -static const char *settingsPath = "/boot/home/config/settings/ImageManip Settings"; - +static const char* settingsPath = "/boot/home/config/settings/ImageManip Settings"; // Struct for keeping add-on info together struct AddonInfo { - AddonInfo *next; // linked list + AddonInfo* next; // linked list char name[NAME_MAX]; char path[PATH_MAX]; @@ -62,69 +61,56 @@ struct AddonInfo BString addonCategory; int32 addonVersion; - status_t (*Manipulate)( - BitmapAccessor *sourceBitmap, - BMessage *ioExtension, - bool checkOnly); + status_t (*Manipulate)(BitmapAccessor* sourceBitmap, BMessage* ioExtension, bool checkOnly); status_t (*Convert)( - BitmapAccessor *sourceBitmap, - BitmapAccessor *destBitmap, - BMessage *ioExtension, - bool checkOnly); - - status_t (*MakeConfig)( - BMessage *ioExtension, - BView **configView); - - status_t (*GetConfigMessage)( - BMessage *ioExtension, - BMessage *ioCapability); -}; + BitmapAccessor* sourceBitmap, BitmapAccessor* destBitmap, BMessage* ioExtension, + bool checkOnly + ); + + status_t (*MakeConfig)(BMessage* ioExtension, BView** configView); + status_t (*GetConfigMessage)(BMessage* ioExtension, BMessage* ioCapability); +}; class StAcquire { -private: + private: sem_id fSem; -public: + public: StAcquire(sem_id sem) { acquire_sem(sem); fSem = sem; } - ~StAcquire() - { - release_sem(fSem); - } -}; + ~StAcquire() { release_sem(fSem); } +}; // Global data -static AddonInfo *firstInfo = NULL; +static AddonInfo* firstInfo = NULL; static sem_id sSem = 0; static BMessage settings; - /* Get the current version of the library and the minimum version with which it is still compatible */ -const char * +const char* Image_Version( - int32 *curVersion, /* will receive the current version */ - int32 *minVersion) /* will receive the minimum version */ + int32* curVersion, /* will receive the current version */ + int32* minVersion +) /* will receive the minimum version */ { static char vString[80]; static char vDate[] = __DATE__; - if (!vString[0]) - { - sprintf(vString, "Image manipulation library, Release %d.%d.%d (%s)", - IMAGE_LIB_CUR_VERSION / 100, - (IMAGE_LIB_CUR_VERSION / 10) % 10, - IMAGE_LIB_CUR_VERSION % 10, - vDate); + if (!vString[0]) { + sprintf( + vString, "Image manipulation library, Release %d.%d.%d (%s)", + IMAGE_LIB_CUR_VERSION / 100, (IMAGE_LIB_CUR_VERSION / 10) % 10, + IMAGE_LIB_CUR_VERSION % 10, vDate + ); } - + if (curVersion) *curVersion = IMAGE_LIB_CUR_VERSION; if (minVersion) @@ -133,13 +119,12 @@ Image_Version( return vString; } - // Load add-on image for real -static AddonInfo * +static AddonInfo* LoadAddonImage(image_addon_id imageAddon) { - AddonInfo *info = (AddonInfo *) imageAddon; // dumb cast - + AddonInfo* info = (AddonInfo*)imageAddon; // dumb cast + StAcquire lock(sSem); // Already loaded? @@ -147,65 +132,69 @@ LoadAddonImage(image_addon_id imageAddon) return info; image_id image = load_add_on(info->path); - if (debug) printf("load_add_on(%s) = %ld\n", info->path, image); + if (debug) + printf("load_add_on(%s) = %ld\n", info->path, image); if (image <= 0) return NULL; // Find all symbols in the add-on const char* string = 0; - if (get_image_symbol(image, "addonName", B_SYMBOL_TYPE_DATA, (void **) &string) != B_OK) - return NULL; // required + if (get_image_symbol(image, "addonName", B_SYMBOL_TYPE_DATA, (void**)&string) != B_OK) + return NULL; // required info->addonName = string; - if (get_image_symbol(image, "addonInfo", B_SYMBOL_TYPE_DATA, (void **) &string) != B_OK) - return NULL; // required + if (get_image_symbol(image, "addonInfo", B_SYMBOL_TYPE_DATA, (void**)&string) != B_OK) + return NULL; // required info->addonInfo = string; - if (get_image_symbol(image, "addonCategory", B_SYMBOL_TYPE_DATA, (void **) &string) != B_OK) - info->addonCategory = noCategory; // not found + if (get_image_symbol(image, "addonCategory", B_SYMBOL_TYPE_DATA, (void**)&string) != B_OK) + info->addonCategory = noCategory; // not found else info->addonCategory = string; - long *vptr; - if (get_image_symbol(image, "addonVersion", B_SYMBOL_TYPE_DATA, (void **) &vptr) != B_OK) - return NULL; // required + long* vptr; + if (get_image_symbol(image, "addonVersion", B_SYMBOL_TYPE_DATA, (void**)&vptr) != B_OK) + return NULL; // required info->addonVersion = *vptr; info->canManipulate = - get_image_symbol(image, "Manipulate", B_SYMBOL_TYPE_TEXT, (void **) &info->Manipulate) == B_OK; + get_image_symbol(image, "Manipulate", B_SYMBOL_TYPE_TEXT, (void**)&info->Manipulate) == + B_OK; if (!info->canManipulate) info->Manipulate = NULL; info->canConvert = - get_image_symbol(image, "Convert", B_SYMBOL_TYPE_TEXT, (void **) &info->Convert) == B_OK; + get_image_symbol(image, "Convert", B_SYMBOL_TYPE_TEXT, (void**)&info->Convert) == B_OK; if (!info->canConvert) info->Convert = NULL; if (!info->canManipulate && !info->canConvert) - return NULL; // at least one required + return NULL; // at least one required - if (get_image_symbol(image, "MakeConfig", B_SYMBOL_TYPE_TEXT, (void **) &info->MakeConfig) != B_OK) - info->MakeConfig = NULL; // not found + if (get_image_symbol(image, "MakeConfig", B_SYMBOL_TYPE_TEXT, (void**)&info->MakeConfig) != + B_OK) + info->MakeConfig = NULL; // not found - if (get_image_symbol(image, "GetConfigMessage", B_SYMBOL_TYPE_TEXT, (void **) &info->GetConfigMessage) != B_OK) - info->GetConfigMessage = NULL; // not found + if (get_image_symbol( + image, "GetConfigMessage", B_SYMBOL_TYPE_TEXT, (void**)&info->GetConfigMessage + ) != B_OK) + info->GetConfigMessage = NULL; // not found info->image = image; return info; } - static status_t -LoadAddon(const char *path, time_t mtime) +LoadAddon(const char* path, time_t mtime) { - const char *name = strrchr(path, '/'); + const char* name = strrchr(path, '/'); if (name) ++name; else name = path; // Create a temporary add-on info struct on the stack - AddonInfo *info = new AddonInfo; + AddonInfo* info = new AddonInfo; strcpy(info->name, name); strcpy(info->path, path); info->mtime = mtime; @@ -214,8 +203,7 @@ LoadAddon(const char *path, time_t mtime) // Check if add-on is the same as last time BMessage addon_settings; if (settings.FindMessage(info->name, &addon_settings) == B_OK && - addon_settings.FindInt32("mtime") == mtime) - { + addon_settings.FindInt32("mtime") == mtime) { // Use the stored info; load on demand info->addonName = addon_settings.FindString("addonName"); info->addonInfo = addon_settings.FindString("addonInfo"); @@ -223,69 +211,63 @@ LoadAddon(const char *path, time_t mtime) info->addonVersion = addon_settings.FindInt32("addonVersion"); info->canManipulate = addon_settings.FindBool("canManipulate"); info->canConvert = addon_settings.FindBool("canConvert"); - } - else - { + } else { // Add-on is new or modified; load now - if (!LoadAddonImage((image_addon_id) info)) - { + if (!LoadAddonImage((image_addon_id)info)) { delete info; return B_ERROR; } } // Add to global list - info->next = firstInfo; - firstInfo = info; + info->next = firstInfo; + firstInfo = info; return B_NO_ERROR; } - static void -LoadDir(const char *path, int32& loadErr, int32& nLoaded) +LoadDir(const char* path, int32& loadErr, int32& nLoaded) { loadErr = B_OK; - DIR *dir = opendir(path); - if (debug) printf("LoadDir(%s) opendir() = %p\n", path, dir); + DIR* dir = opendir(path); + if (debug) + printf("LoadDir(%s) opendir() = %p\n", path, dir); - if (!dir) - { + if (!dir) { loadErr = B_FILE_NOT_FOUND; return; } - struct dirent *dent; + struct dirent* dent; struct stat stbuf; char cwd[PATH_MAX] = ""; - while ((dent = readdir(dir)) != NULL) - { + while ((dent = readdir(dir)) != NULL) { strcpy(cwd, path); strcat(cwd, "/"); strcat(cwd, dent->d_name); status_t err = stat(cwd, &stbuf); - if (debug) printf("stat(%s) = %08lx\n", cwd, err); - if (!err && - S_ISREG(stbuf.st_mode) && - strcmp(dent->d_name, ".") && strcmp(dent->d_name, "..")) - { + if (debug) + printf("stat(%s) = %08lx\n", cwd, err); + if (!err && S_ISREG(stbuf.st_mode) && strcmp(dent->d_name, ".") && + strcmp(dent->d_name, "..")) { err = LoadAddon(cwd, stbuf.st_mtime); if (err != B_OK) loadErr = err; else ++nLoaded; - if (debug) printf("LoadAddon(%s) = %ld (%ld/%08lx)\n", cwd, err, nLoaded, loadErr); + if (debug) + printf("LoadAddon(%s) = %ld (%ld/%08lx)\n", cwd, err, nLoaded, loadErr); } } closedir(dir); } - /* Initialize the library before usage */ status_t -Image_Init(const char *path) /* NULL for the default */ +Image_Init(const char* path) /* NULL for the default */ { if (getenv("IMAGEMANIP_DEBUG") != NULL) debug = 1; @@ -308,43 +290,38 @@ Image_Init(const char *path) /* NULL for the default */ // Parse path syntax; load folders and files char pathbuf[PATH_MAX]; - const char *ptr = path; - const char *end = ptr; + const char* ptr = path; + const char* end = ptr; struct stat stbuf; - while (*ptr != 0) - { + while (*ptr != 0) { // Find segments specified by colons end = strchr(ptr, ':'); if (end == NULL) end = ptr + strlen(ptr); - if (end-ptr > PATH_MAX - 1) - { + if (end - ptr > PATH_MAX - 1) { loadErr = B_BAD_VALUE; - if (debug) printf("too long path!\n"); - } - else - { + if (debug) + printf("too long path!\n"); + } else { // Copy this segment of the path into a path, and load it memcpy(pathbuf, ptr, end - ptr); pathbuf[end - ptr] = 0; - if (debug) printf("load path: %s\n", pathbuf); - if (!stat(pathbuf, &stbuf)) - { + if (debug) + printf("load path: %s\n", pathbuf); + if (!stat(pathbuf, &stbuf)) { // Files are loaded as add-ons - if (S_ISREG(stbuf.st_mode)) - { + if (S_ISREG(stbuf.st_mode)) { status_t err = LoadAddon(pathbuf, stbuf.st_mtime); if (err != B_OK) loadErr = err; else ++nLoaded; - } - else - { + } else { // Directories are scanned LoadDir(pathbuf, loadErr, nLoaded); } - } else if (debug) printf("cannot stat()!\n"); + } else if (debug) + printf("cannot stat()!\n"); } ptr = end + 1; if (*end == 0) @@ -358,13 +335,12 @@ Image_Init(const char *path) /* NULL for the default */ return loadErr; } - /* Shutdown the library after usage */ status_t Image_Shutdown() { if (sSem <= 0) - return B_NO_INIT; + return B_NO_INIT; acquire_sem(sSem); @@ -373,10 +349,9 @@ Image_Shutdown() settings.AddString("libVersion", Image_Version(NULL, NULL)); // Work through the linked list with add-on info - AddonInfo *info = firstInfo; - while (info != NULL) - { - AddonInfo *cur = info; + AddonInfo* info = firstInfo; + while (info != NULL) { + AddonInfo* cur = info; info = info->next; // Each add-on's settings go into a separate BMessage @@ -396,7 +371,7 @@ Image_Shutdown() unload_add_on(cur->image); delete cur; } - firstInfo = NULL; // list is now empty + firstInfo = NULL; // list is now empty // Flatten the settings to disk BFile settings_file(settingsPath, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); @@ -409,15 +384,13 @@ Image_Shutdown() return B_NO_ERROR; } - // Private function to get all image manipulators static status_t -GetAllManipulators(image_addon_id **outList, int32 *outCount) +GetAllManipulators(image_addon_id** outList, int32* outCount) { // Count the manipulator add-ons - AddonInfo *info; - for (info = firstInfo; info != NULL; info = info->next) - { + AddonInfo* info; + for (info = firstInfo; info != NULL; info = info->next) { if (info->canManipulate) ++(*outCount); } @@ -425,11 +398,9 @@ GetAllManipulators(image_addon_id **outList, int32 *outCount) // Create an array of them *outList = new image_addon_id[*outCount]; *outCount = 0; - for (info = firstInfo; info != NULL; info = info->next) - { - if (info->canManipulate) - { - (*outList)[*outCount] = (image_addon_id) info; + for (info = firstInfo; info != NULL; info = info->next) { + if (info->canManipulate) { + (*outList)[*outCount] = (image_addon_id)info; ++(*outCount); } } @@ -437,14 +408,14 @@ GetAllManipulators(image_addon_id **outList, int32 *outCount) return B_NO_ERROR; } - /* Get all image manipulators that support a given source bitmap */ status_t Image_GetManipulators( - BitmapAccessor *sourceBitmap, /* NULL to get all manipulators */ - BMessage *ioExtension, /* can be NULL */ - image_addon_id **outList, /* call delete[] on it when done */ - int32 *outCount) /* will receive number in list */ + BitmapAccessor* sourceBitmap, /* NULL to get all manipulators */ + BMessage* ioExtension, /* can be NULL */ + image_addon_id** outList, /* call delete[] on it when done */ + int32* outCount +) /* will receive number in list */ { *outList = NULL; *outCount = 0; @@ -462,22 +433,17 @@ Image_GetManipulators( *outList = new image_addon_id[physCount]; *outCount = 0; - AddonInfo *info = firstInfo; - while (info) - { - image_addon_id imageAddon = (image_addon_id) info; - + AddonInfo* info = firstInfo; + while (info) { + image_addon_id imageAddon = (image_addon_id)info; + // Ask the add-on if it supports it - if (info->canManipulate && - LoadAddonImage(imageAddon) && - info->Manipulate && - info->Manipulate(sourceBitmap, ioExtension, true) == B_OK) - { - if (*outCount == physCount) - { + if (info->canManipulate && LoadAddonImage(imageAddon) && info->Manipulate && + info->Manipulate(sourceBitmap, ioExtension, true) == B_OK) { + if (*outCount == physCount) { // Resize the array dynamically physCount *= 2; - image_addon_id *newList = new image_addon_id[physCount]; + image_addon_id* newList = new image_addon_id[physCount]; for (int i = 0; i < *outCount; ++i) newList[i] = (*outList)[i]; delete[] *outList; @@ -491,8 +457,7 @@ Image_GetManipulators( info = info->next; } - if (*outCount == 0) - { + if (*outCount == 0) { delete[] *outList; *outList = NULL; } @@ -500,15 +465,13 @@ Image_GetManipulators( return B_NO_ERROR; } - // Private function to get all image converters static status_t -GetAllConverters(image_addon_id **outList, int32 *outCount) +GetAllConverters(image_addon_id** outList, int32* outCount) { // Count the converter add-ons - AddonInfo *info; - for (info = firstInfo; info != NULL; info = info->next) - { + AddonInfo* info; + for (info = firstInfo; info != NULL; info = info->next) { if (info->canConvert) ++(*outCount); } @@ -516,11 +479,9 @@ GetAllConverters(image_addon_id **outList, int32 *outCount) // Create an array of them *outList = new image_addon_id[*outCount]; *outCount = 0; - for (info = firstInfo; info != NULL; info = info->next) - { - if (info->canConvert) - { - (*outList)[*outCount] = (image_addon_id) info; + for (info = firstInfo; info != NULL; info = info->next) { + if (info->canConvert) { + (*outList)[*outCount] = (image_addon_id)info; ++(*outCount); } } @@ -528,14 +489,14 @@ GetAllConverters(image_addon_id **outList, int32 *outCount) return B_NO_ERROR; } - /* Get all image converters that support a given source bitmap */ status_t Image_GetConverters( - BitmapAccessor *sourceBitmap, /* NULL to get all converters */ - BMessage *ioExtension, /* can be NULL */ - image_addon_id **outList, /* call delete[] on it when done */ - int32 *outCount) /* will receive number in list */ + BitmapAccessor* sourceBitmap, /* NULL to get all converters */ + BMessage* ioExtension, /* can be NULL */ + image_addon_id** outList, /* call delete[] on it when done */ + int32* outCount +) /* will receive number in list */ { *outList = NULL; *outCount = 0; @@ -553,22 +514,17 @@ Image_GetConverters( *outList = new image_addon_id[physCount]; *outCount = 0; - AddonInfo *info = firstInfo; - while (info) - { - image_addon_id imageAddon = (image_addon_id) info; + AddonInfo* info = firstInfo; + while (info) { + image_addon_id imageAddon = (image_addon_id)info; // Check with the add-on if it supports it - if (info->canConvert && - LoadAddonImage(imageAddon) && - info->Convert && - info->Convert(sourceBitmap, NULL, ioExtension, true) == B_OK) - { - if (*outCount == physCount) - { + if (info->canConvert && LoadAddonImage(imageAddon) && info->Convert && + info->Convert(sourceBitmap, NULL, ioExtension, true) == B_OK) { + if (*outCount == physCount) { // Resize the array dynamically physCount *= 2; - image_addon_id *newList = new image_addon_id[physCount]; + image_addon_id* newList = new image_addon_id[physCount]; for (int i = 0; i < *outCount; ++i) newList[i] = (*outList)[i]; delete[] *outList; @@ -582,8 +538,7 @@ Image_GetConverters( info = info->next; } - if (*outCount == 0) - { + if (*outCount == 0) { delete[] *outList; *outList = NULL; } @@ -591,22 +546,21 @@ Image_GetConverters( return B_NO_ERROR; } - /* Get info on an image manipulator or image convertor add-on */ status_t Image_GetAddonInfo( - image_addon_id imageAddon, - const char **addonName, /* will receive pointer to the name */ - const char **addonInfo, /* will receive pointer to the info */ - const char **addonCategory, /* will receive pointer to the category */ - int32 *addonVersion) /* will receive the version */ + image_addon_id imageAddon, const char** addonName, /* will receive pointer to the name */ + const char** addonInfo, /* will receive pointer to the info */ + const char** addonCategory, /* will receive pointer to the category */ + int32* addonVersion +) /* will receive the version */ { if (!imageAddon) return B_BAD_VALUE; if (sSem <= 0) return B_NO_INIT; - AddonInfo *info = (AddonInfo *) imageAddon; + AddonInfo* info = (AddonInfo*)imageAddon; *addonName = info->addonName.String(); *addonInfo = info->addonInfo.String(); @@ -616,14 +570,13 @@ Image_GetAddonInfo( return B_NO_ERROR; } - /* Let an add-on manipulate a bitmap */ status_t Image_Manipulate( - image_addon_id imageManipulator, - BitmapAccessor *sourceBitmap, - BMessage *ioExtension, /* can be NULL */ - bool checkOnly) + image_addon_id imageManipulator, BitmapAccessor* sourceBitmap, + BMessage* ioExtension, /* can be NULL */ + bool checkOnly +) { if (!imageManipulator || !sourceBitmap) return B_BAD_VALUE; @@ -634,7 +587,7 @@ Image_Manipulate( if (sSem <= 0) return B_NO_INIT; - AddonInfo *info = LoadAddonImage(imageManipulator); + AddonInfo* info = LoadAddonImage(imageManipulator); if (!info) return B_ERROR; @@ -644,15 +597,14 @@ Image_Manipulate( return info->Manipulate(sourceBitmap, ioExtension, checkOnly); } - /* Let an add-on convert a bitmap to another bitmap */ status_t Image_Convert( - image_addon_id imageConverter, - BitmapAccessor *sourceBitmap, - BitmapAccessor *destBitmap, /* will be called CreateBitmap() on */ - BMessage *ioExtension, /* can be NULL */ - bool checkOnly) + image_addon_id imageConverter, BitmapAccessor* sourceBitmap, + BitmapAccessor* destBitmap, /* will be called CreateBitmap() on */ + BMessage* ioExtension, /* can be NULL */ + bool checkOnly +) { if (!imageConverter || !sourceBitmap || !destBitmap) return B_BAD_VALUE; @@ -663,24 +615,22 @@ Image_Convert( if (sSem <= 0) return B_NO_INIT; - AddonInfo *info = LoadAddonImage(imageConverter); + AddonInfo* info = LoadAddonImage(imageConverter); if (!info) return B_ERROR; if (!info->Convert) return B_BAD_TYPE; - return info->Convert( - sourceBitmap, destBitmap, ioExtension, checkOnly); + return info->Convert(sourceBitmap, destBitmap, ioExtension, checkOnly); } - /* Let an add-on make a BView that allows the user to configure it */ status_t Image_MakeConfigurationView( - image_addon_id imageAddon, - BMessage *ioExtension, /* can be NULL */ - BView **configView) /* will receive pointer to the new BView */ + image_addon_id imageAddon, BMessage* ioExtension, /* can be NULL */ + BView** configView +) /* will receive pointer to the new BView */ { *configView = NULL; @@ -690,7 +640,7 @@ Image_MakeConfigurationView( if (sSem <= 0) return B_NO_INIT; - AddonInfo *info = LoadAddonImage(imageAddon); + AddonInfo* info = LoadAddonImage(imageAddon); if (!info) return B_ERROR; @@ -700,13 +650,12 @@ Image_MakeConfigurationView( return info->MakeConfig(ioExtension, configView); } - /* Get configuration and capabilities from an add-on */ status_t Image_GetConfigurationMessage( - image_addon_id imageAddon, - BMessage *ioExtension, /* message to add config info to */ - BMessage *ioCapability) /* message to add capability info to */ + image_addon_id imageAddon, BMessage* ioExtension, /* message to add config info to */ + BMessage* ioCapability +) /* message to add capability info to */ { if (!imageAddon || !ioExtension || !ioCapability) return B_BAD_VALUE; @@ -714,7 +663,7 @@ Image_GetConfigurationMessage( if (sSem <= 0) return B_NO_INIT; - AddonInfo *info = LoadAddonImage(imageAddon); + AddonInfo* info = LoadAddonImage(imageAddon); if (!info) return B_ERROR; diff --git a/source/LibImageManipWrapper2/LibImageManip/Source/ImageManip.h b/source/LibImageManipWrapper2/LibImageManip/Source/ImageManip.h index 89015be..f0c3da1 100644 --- a/source/LibImageManipWrapper2/LibImageManip/Source/ImageManip.h +++ b/source/LibImageManipWrapper2/LibImageManip/Source/ImageManip.h @@ -46,78 +46,70 @@ extern "C" { /* Get the current version of the library and the minimum version with which it is still compatible */ - _IMPEXP_IMAGEMANIP const char * - Image_Version( - int32 *curVersion, /* will receive the current version */ - int32 *minVersion); /* will receive the minimum version */ + _IMPEXP_IMAGEMANIP const char* Image_Version( + int32* curVersion, /* will receive the current version */ + int32* minVersion + ); /* will receive the minimum version */ /* Initialize the library before usage */ - _IMPEXP_IMAGEMANIP status_t - Image_Init( - const char *loadPath); /* NULL for the default */ + _IMPEXP_IMAGEMANIP status_t Image_Init(const char* loadPath); /* NULL for the default */ /* Shutdown the library after usage */ - _IMPEXP_IMAGEMANIP status_t - Image_Shutdown(); + _IMPEXP_IMAGEMANIP status_t Image_Shutdown(); /* Get all image manipulators that support a given source bitmap and io extension */ - _IMPEXP_IMAGEMANIP status_t - Image_GetManipulators( - BitmapAccessor *sourceBitmap, /* NULL to get all manipulators */ - BMessage *ioExtension, /* can be NULL */ - image_addon_id **outList, /* call delete[] on it when done */ - int32 *outCount); /* will receive amount in list */ + _IMPEXP_IMAGEMANIP status_t Image_GetManipulators( + BitmapAccessor* sourceBitmap, /* NULL to get all manipulators */ + BMessage* ioExtension, /* can be NULL */ + image_addon_id** outList, /* call delete[] on it when done */ + int32* outCount + ); /* will receive amount in list */ /* Get all image converters that support a given source bitmap and io extension */ - _IMPEXP_IMAGEMANIP status_t - Image_GetConverters( - BitmapAccessor *sourceBitmap, /* NULL to get all converters */ - BMessage *ioExtension, /* can be NULL */ - image_addon_id **outList, /* call delete[] on it when done */ - int32 *outCount); /* will receive amount in list */ + _IMPEXP_IMAGEMANIP status_t Image_GetConverters( + BitmapAccessor* sourceBitmap, /* NULL to get all converters */ + BMessage* ioExtension, /* can be NULL */ + image_addon_id** outList, /* call delete[] on it when done */ + int32* outCount + ); /* will receive amount in list */ /* Get info on an image manipulator or image converter add-on */ - _IMPEXP_IMAGEMANIP status_t - Image_GetAddonInfo( - image_addon_id imageAddon, - const char **addonName, /* will receive pointer to the name */ - const char **addonInfo, /* will receive pointer to the info */ - const char **addonCategory, /* will receive pointer to the category */ - int32 *addonVersion); /* will receive the version */ + _IMPEXP_IMAGEMANIP status_t Image_GetAddonInfo( + image_addon_id imageAddon, const char** addonName, /* will receive pointer to the name */ + const char** addonInfo, /* will receive pointer to the info */ + const char** addonCategory, /* will receive pointer to the category */ + int32* addonVersion + ); /* will receive the version */ /* Let an add-on manipulate a bitmap */ - _IMPEXP_IMAGEMANIP status_t - Image_Manipulate( - image_addon_id imageManipulator, - BitmapAccessor *sourceBitmap, - BMessage *ioExtension, /* can be NULL */ - bool checkOnly = false); + _IMPEXP_IMAGEMANIP status_t Image_Manipulate( + image_addon_id imageManipulator, BitmapAccessor* sourceBitmap, + BMessage* ioExtension, /* can be NULL */ + bool checkOnly = false + ); /* Let an add-on convert a bitmap to another bitmap */ - _IMPEXP_IMAGEMANIP status_t - Image_Convert( - image_addon_id imageConverter, - BitmapAccessor *sourceBitmap, - BitmapAccessor *destBitmap, /* will be called CreateBitmap() on */ - BMessage *ioExtension, /* can be NULL */ - bool checkOnly = false); + _IMPEXP_IMAGEMANIP status_t Image_Convert( + image_addon_id imageConverter, BitmapAccessor* sourceBitmap, + BitmapAccessor* destBitmap, /* will be called CreateBitmap() on */ + BMessage* ioExtension, /* can be NULL */ + bool checkOnly = false + ); /* Let an add-on make a BView that allows the user to configure it */ - _IMPEXP_IMAGEMANIP status_t - Image_MakeConfigurationView( - image_addon_id imageAddon, - BMessage *ioExtension, /* can be NULL */ - BView **configView); /* will receive pointer to the new BView */ + _IMPEXP_IMAGEMANIP status_t Image_MakeConfigurationView( + image_addon_id imageAddon, BMessage* ioExtension, /* can be NULL */ + BView** configView + ); /* will receive pointer to the new BView */ /* Get configuration and capabilities from an add-on */ - _IMPEXP_IMAGEMANIP status_t - Image_GetConfigurationMessage( - image_addon_id imageAddon, - BMessage *ioExtension, /* message to add config info to */ - BMessage *ioCapability); /* message to add capability info to */ + _IMPEXP_IMAGEMANIP status_t Image_GetConfigurationMessage( + image_addon_id imageAddon, BMessage* ioExtension, /* message to add config info to */ + BMessage* ioCapability + ); /* message to add capability info to */ } -#endif /* _IMAGE_MANIP_H_ */ +#endif /* _IMAGE_MANIP_H_ */ diff --git a/source/LibImageManipWrapper2/LibImageManip/Source/ImageManipAddon.h b/source/LibImageManipWrapper2/LibImageManip/Source/ImageManipAddon.h index df531f3..ea6fb73 100644 --- a/source/LibImageManipWrapper2/LibImageManip/Source/ImageManipAddon.h +++ b/source/LibImageManipWrapper2/LibImageManip/Source/ImageManipAddon.h @@ -2,9 +2,9 @@ * ImageManipAddon.h * Release 1.0.0 (Nov 18th 1999) * - * This header file defines the interface that should be + * This header file defines the interface that should be * implemented and exported by an image manipulation add-on. - * You will only need to include this header when building + * You will only need to include this header when building * an actual add-on, not when just using the library. * * Written by Edmund Vermeulen @@ -28,26 +28,27 @@ class BitmapAccessor; extern "C" { -_EXPORT extern const char addonName[]; /* required, C string, ex "Gamma Correct" */ -_EXPORT extern const char addonInfo[]; /* required, descriptive C string, ex "Makes images brighter. Written by Slartibardfast." */ -_EXPORT extern const char addonCategory[]; /* optional, C string, ex "Color" */ -_EXPORT extern int32 addonVersion; /* required, integer, ex 100 */ + _EXPORT extern const char addonName[]; /* required, C string, ex "Gamma Correct" */ + _EXPORT extern const char addonInfo[]; /* required, descriptive C string, ex "Makes images + brighter. Written by Slartibardfast." */ + _EXPORT extern const char addonCategory[]; /* optional, C string, ex "Color" */ + _EXPORT extern int32 addonVersion; /* required, integer, ex 100 */ /* At least one of the following two functions is required. If called with checkOnly set to true, only check if you support the supplied source bitmap and io extension. Return B_NOT_ALLOWED if you don't. */ -_EXPORT extern status_t Manipulate( - BitmapAccessor *sourceBitmap, - BMessage *ioExtension, /* can be NULL */ - bool checkOnly); + _EXPORT extern status_t Manipulate( + BitmapAccessor* sourceBitmap, BMessage* ioExtension, /* can be NULL */ + bool checkOnly + ); -_EXPORT extern status_t Convert( - BitmapAccessor *sourceBitmap, - BitmapAccessor *destBitmap, /* call CreateBitmap() on this */ - BMessage *ioExtension, /* can be NULL */ - bool checkOnly); + _EXPORT extern status_t Convert( + BitmapAccessor* sourceBitmap, BitmapAccessor* destBitmap, /* call CreateBitmap() on this */ + BMessage* ioExtension, /* can be NULL */ + bool checkOnly + ); /* The view will get resized to what the parent thinks is reasonable. However, it will still receive MouseDowns etc. @@ -58,9 +59,10 @@ _EXPORT extern status_t Convert( as a local when image manipulation starts. Store your settings wherever you feel like it. */ -_EXPORT extern status_t MakeConfig( /* optional */ - BMessage *ioExtension, /* can be NULL */ - BView **outView); + _EXPORT extern status_t MakeConfig( /* optional */ + BMessage* ioExtension, /* can be NULL */ + BView** outView + ); /* Add the current settings to the ioExtension message, which may be passed to the Manipulate() or Convert() function at some later time @@ -70,9 +72,9 @@ _EXPORT extern status_t MakeConfig( /* optional */ can be used by an application to check if an add-on supports a certain extension. */ -_EXPORT extern status_t GetConfigMessage( /* optional */ - BMessage *ioExtension, - BMessage *ioCapability); + _EXPORT extern status_t GetConfigMessage(/* optional */ + BMessage* ioExtension, BMessage* ioCapability + ); } diff --git a/source/LibImageManipWrapper2/LibImageManip/Source/ImportImageManip.cpp b/source/LibImageManipWrapper2/LibImageManip/Source/ImportImageManip.cpp index f25b55e..18a9a1d 100644 --- a/source/LibImageManipWrapper2/LibImageManip/Source/ImportImageManip.cpp +++ b/source/LibImageManipWrapper2/LibImageManip/Source/ImportImageManip.cpp @@ -28,60 +28,41 @@ static image_id image = -1; -static const char *no_lib = "libimagemanip.so not found"; +static const char* no_lib = "libimagemanip.so not found"; // Pointers to the real functions in the library -static const char *(*_Image_Version)( - int32 *curVersion, - int32 *minVersion); -static status_t (*_Image_Init)( - const char *loadPath); -static status_t (*_Image_Shutdown)(); -static status_t (*_Image_GetManipulators)( - BitmapAccessor *sourceBitmap, - BMessage *ioExtension, - image_addon_id **outList, - int32 *outCount); -static status_t (*_Image_GetConverters)( - BitmapAccessor *sourceBitmap, - BMessage *ioExtension, - image_addon_id **outList, - int32 *outCount); +static const char* (*_Image_Version)(int32* curVersion, int32* minVersion); +static status_t (*_Image_Init)(const char* loadPath); +static status_t (*_Image_Shutdown)(); +static status_t (*_Image_GetManipulators)( + BitmapAccessor* sourceBitmap, BMessage* ioExtension, image_addon_id** outList, int32* outCount +); +static status_t (*_Image_GetConverters)( + BitmapAccessor* sourceBitmap, BMessage* ioExtension, image_addon_id** outList, int32* outCount +); static status_t (*_Image_GetAddonInfo)( - image_addon_id imageAddon, - const char **addonName, - const char **addonInfo, - const char **addonCategory, - int32 *addonVersion); + image_addon_id imageAddon, const char** addonName, const char** addonInfo, + const char** addonCategory, int32* addonVersion +); static status_t (*_Image_Manipulate)( - image_addon_id imageManipulator, - BitmapAccessor *sourceBitmap, - BMessage *ioExtension, - bool checkOnly); + image_addon_id imageManipulator, BitmapAccessor* sourceBitmap, BMessage* ioExtension, + bool checkOnly +); static status_t (*_Image_Convert)( - image_addon_id imageConverter, - BitmapAccessor *sourceBitmap, - BitmapAccessor *destBitmap, - BMessage *ioExtension, - bool checkOnly); + image_addon_id imageConverter, BitmapAccessor* sourceBitmap, BitmapAccessor* destBitmap, + BMessage* ioExtension, bool checkOnly +); static status_t (*_Image_MakeConfigurationView)( - image_addon_id imageAddon, - BMessage *ioExtension, - BView **configView); + image_addon_id imageAddon, BMessage* ioExtension, BView** configView +); static status_t (*_Image_GetConfigurationMessage)( - image_addon_id imageAddon, - BMessage *ioExtension, - BMessage *ioCapability); -static BBitmapAccessor *(*_Image_CreateBBitmapAccessor)( - BBitmap *bitmap, - const BRect *section); - - -const char * -Image_Version( - int32 *curVersion, - int32 *minVersion) + image_addon_id imageAddon, BMessage* ioExtension, BMessage* ioCapability +); +static BBitmapAccessor* (*_Image_CreateBBitmapAccessor)(BBitmap* bitmap, const BRect* section); + +const char* +Image_Version(int32* curVersion, int32* minVersion) { if (Image_Init(0) != B_OK) return no_lib; @@ -89,11 +70,8 @@ Image_Version( return _Image_Version(curVersion, minVersion); } - static int -getappdir( - char * dir, - size_t size) +getappdir(char* dir, size_t size) { image_info info; thread_info tinfo; @@ -102,23 +80,21 @@ getappdir( return B_BAD_VALUE; if ((err = get_thread_info(find_thread(NULL), &tinfo)) != B_OK) return err; - for (int32 ix=0; !get_next_image_info(tinfo.team, &ix, &info); ) - { - if (info.type == B_APP_IMAGE) - { + for (int32 ix = 0; !get_next_image_info(tinfo.team, &ix, &info);) { + if (info.type == B_APP_IMAGE) { strncpy(dir, info.name, size); - dir[size-1] = 0; - char * ptr = strrchr(dir, '/'); - if (ptr) ptr[1] = 0; + dir[size - 1] = 0; + char* ptr = strrchr(dir, '/'); + if (ptr) + ptr[1] = 0; return B_OK; } } return B_ERROR; } - status_t -Image_Init(const char *loadPath) +Image_Init(const char* loadPath) { // Already initialised? if (image >= 0) @@ -126,40 +102,32 @@ Image_Init(const char *loadPath) // Load the library as an add-on image = load_add_on(LIBIMAGEMANIP_NAME); - if (image < 0) - { - char * env = getenv("LIBRARY_PATH"); - char * end, * temp, * str; + if (image < 0) { + char* env = getenv("LIBRARY_PATH"); + char *end, *temp, *str; if (!env) return image; env = strdup(env); temp = env; - while (1) - { + while (1) { end = strchr(temp, ':'); if (end) *end = 0; - if (!strncmp(temp, "%A/", 3)) - { - str = (char *)malloc(1024); - if (!str) - { + if (!strncmp(temp, "%A/", 3)) { + str = (char*)malloc(1024); + if (!str) { free(env); return B_NO_MEMORY; } - if ((errno = getappdir(str, 1023)) != B_OK) - { + if ((errno = getappdir(str, 1023)) != B_OK) { free(env); free(str); return errno; } - strcat(str, temp+2); /* include slash we know is there */ - } - else - { - str = (char *)malloc(strlen(temp)+40); - if (!str) - { + strcat(str, temp + 2); /* include slash we know is there */ + } else { + str = (char*)malloc(strlen(temp) + 40); + if (!str) { free(env); return B_NO_MEMORY; } @@ -173,7 +141,7 @@ Image_Init(const char *loadPath) break; if (!end) break; - temp = end+1; + temp = end + 1; } free(env); if (image < 0) @@ -181,19 +149,38 @@ Image_Init(const char *loadPath) } // Import the functions in the library - if (get_image_symbol(image, "Image_Version", B_SYMBOL_TYPE_TEXT, (void **) &_Image_Version) != B_OK || - get_image_symbol(image, "Image_Init", B_SYMBOL_TYPE_TEXT, (void **) &_Image_Init) != B_OK || - get_image_symbol(image, "Image_Shutdown", B_SYMBOL_TYPE_TEXT, (void **) &_Image_Shutdown) != B_OK || - get_image_symbol(image, "Image_GetManipulators", B_SYMBOL_TYPE_TEXT, (void **) &_Image_GetManipulators) != B_OK || - get_image_symbol(image, "Image_GetConverters", B_SYMBOL_TYPE_TEXT, (void **) &_Image_GetConverters) != B_OK || - get_image_symbol(image, "Image_GetAddonInfo", B_SYMBOL_TYPE_TEXT, (void **) &_Image_GetAddonInfo) != B_OK || - get_image_symbol(image, "Image_Manipulate", B_SYMBOL_TYPE_TEXT, (void **) &_Image_Manipulate) != B_OK || - get_image_symbol(image, "Image_Convert", B_SYMBOL_TYPE_TEXT, (void **) &_Image_Convert) != B_OK || - get_image_symbol(image, "Image_MakeConfigurationView", B_SYMBOL_TYPE_TEXT, (void **) &_Image_MakeConfigurationView) != B_OK || - get_image_symbol(image, "Image_GetConfigurationMessage", B_SYMBOL_TYPE_TEXT, (void **) &_Image_GetConfigurationMessage) != B_OK || - get_image_symbol(image, "Image_CreateBBitmapAccessor", B_SYMBOL_TYPE_TEXT, (void **) &_Image_CreateBBitmapAccessor) != B_OK || - _Image_Init(loadPath) != B_OK) - { + if (get_image_symbol(image, "Image_Version", B_SYMBOL_TYPE_TEXT, (void**)&_Image_Version) != + B_OK || + get_image_symbol(image, "Image_Init", B_SYMBOL_TYPE_TEXT, (void**)&_Image_Init) != B_OK || + get_image_symbol(image, "Image_Shutdown", B_SYMBOL_TYPE_TEXT, (void**)&_Image_Shutdown) != + B_OK || + get_image_symbol( + image, "Image_GetManipulators", B_SYMBOL_TYPE_TEXT, (void**)&_Image_GetManipulators + ) != B_OK || + get_image_symbol( + image, "Image_GetConverters", B_SYMBOL_TYPE_TEXT, (void**)&_Image_GetConverters + ) != B_OK || + get_image_symbol( + image, "Image_GetAddonInfo", B_SYMBOL_TYPE_TEXT, (void**)&_Image_GetAddonInfo + ) != B_OK || + get_image_symbol( + image, "Image_Manipulate", B_SYMBOL_TYPE_TEXT, (void**)&_Image_Manipulate + ) != B_OK || + get_image_symbol(image, "Image_Convert", B_SYMBOL_TYPE_TEXT, (void**)&_Image_Convert) != + B_OK || + get_image_symbol( + image, "Image_MakeConfigurationView", B_SYMBOL_TYPE_TEXT, + (void**)&_Image_MakeConfigurationView + ) != B_OK || + get_image_symbol( + image, "Image_GetConfigurationMessage", B_SYMBOL_TYPE_TEXT, + (void**)&_Image_GetConfigurationMessage + ) != B_OK || + get_image_symbol( + image, "Image_CreateBBitmapAccessor", B_SYMBOL_TYPE_TEXT, + (void**)&_Image_CreateBBitmapAccessor + ) != B_OK || + _Image_Init(loadPath) != B_OK) { unload_add_on(image); image = -1; return B_ERROR; @@ -202,7 +189,6 @@ Image_Init(const char *loadPath) return B_OK; } - status_t Image_Shutdown() { @@ -215,13 +201,10 @@ Image_Shutdown() return rc; } - status_t Image_GetManipulators( - BitmapAccessor *sourceBitmap, - BMessage *ioExtension, - image_addon_id **outList, - int32 *outCount) + BitmapAccessor* sourceBitmap, BMessage* ioExtension, image_addon_id** outList, int32* outCount +) { if (image < 0) return B_NO_INIT; @@ -231,10 +214,8 @@ Image_GetManipulators( status_t Image_GetConverters( - BitmapAccessor *sourceBitmap, - BMessage *ioExtension, - image_addon_id **outList, - int32 *outCount) + BitmapAccessor* sourceBitmap, BMessage* ioExtension, image_addon_id** outList, int32* outCount +) { if (image < 0) return B_NO_INIT; @@ -244,11 +225,9 @@ Image_GetConverters( status_t Image_GetAddonInfo( - image_addon_id imageAddon, - const char **addonName, - const char **addonInfo, - const char **addonCategory, - int32 *addonVersion) + image_addon_id imageAddon, const char** addonName, const char** addonInfo, + const char** addonCategory, int32* addonVersion +) { if (image < 0) return B_NO_INIT; @@ -258,10 +237,9 @@ Image_GetAddonInfo( status_t Image_Manipulate( - image_addon_id imageManipulator, - BitmapAccessor *sourceBitmap, - BMessage *ioExtension, - bool checkOnly) + image_addon_id imageManipulator, BitmapAccessor* sourceBitmap, BMessage* ioExtension, + bool checkOnly +) { if (image < 0) return B_NO_INIT; @@ -269,14 +247,11 @@ Image_Manipulate( return (*_Image_Manipulate)(imageManipulator, sourceBitmap, ioExtension, checkOnly); } - status_t Image_Convert( - image_addon_id imageConverter, - BitmapAccessor *sourceBitmap, - BitmapAccessor *destBitmap, - BMessage *ioExtension, - bool checkOnly) + image_addon_id imageConverter, BitmapAccessor* sourceBitmap, BitmapAccessor* destBitmap, + BMessage* ioExtension, bool checkOnly +) { if (image < 0) return B_NO_INIT; @@ -284,12 +259,8 @@ Image_Convert( return (*_Image_Convert)(imageConverter, sourceBitmap, destBitmap, ioExtension, checkOnly); } - status_t -Image_MakeConfigurationView( - image_addon_id imageAddon, - BMessage *ioExtension, - BView **configView) +Image_MakeConfigurationView(image_addon_id imageAddon, BMessage* ioExtension, BView** configView) { if (image < 0) return B_NO_INIT; @@ -297,12 +268,10 @@ Image_MakeConfigurationView( return (*_Image_MakeConfigurationView)(imageAddon, ioExtension, configView); } - status_t Image_GetConfigurationMessage( - image_addon_id imageAddon, - BMessage *ioExtension, - BMessage *ioCapability) + image_addon_id imageAddon, BMessage* ioExtension, BMessage* ioCapability +) { if (image < 0) return B_NO_INIT; @@ -310,11 +279,8 @@ Image_GetConfigurationMessage( return (*_Image_GetConfigurationMessage)(imageAddon, ioExtension, ioCapability); } - -BBitmapAccessor * -Image_CreateBBitmapAccessor( - BBitmap *bitmap, - const BRect *section) +BBitmapAccessor* +Image_CreateBBitmapAccessor(BBitmap* bitmap, const BRect* section) { if (image < 0) return NULL; diff --git a/source/LibImageManipWrapper2/LibImageManip/Source/MakeGray/MakeGray.cpp b/source/LibImageManipWrapper2/LibImageManip/Source/MakeGray/MakeGray.cpp index e1755fd..e4059b9 100644 --- a/source/LibImageManipWrapper2/LibImageManip/Source/MakeGray/MakeGray.cpp +++ b/source/LibImageManipWrapper2/LibImageManip/Source/MakeGray/MakeGray.cpp @@ -17,12 +17,8 @@ const char addonInfo[] = "Make an image grayscale. By Edmund Vermeulen ColorSpace(); @@ -33,7 +29,7 @@ Manipulate( return B_OK; // Get pixel size; we only use the first three bytes, and skip the rest - int pixel_size = (int) sourceBitmap->BytesPerPixel(); + int pixel_size = (int)sourceBitmap->BytesPerPixel(); if (pixel_size < 3) return B_ERROR; @@ -42,24 +38,20 @@ Manipulate( if (!ioExtension || ioExtension->FindRect("selection_rect", &sel_rect) != B_OK) sel_rect = sourceBitmap->Bounds(); - for (float y = sel_rect.top; y <= sel_rect.bottom; ++y) - { + for (float y = sel_rect.top; y <= sel_rect.bottom; ++y) { int32 rowBytes; - uchar *pixel = (uchar *) sourceBitmap->AccessBits( - BRect(sel_rect.left, y, sel_rect.right, y), &rowBytes); + uchar* pixel = + (uchar*)sourceBitmap->AccessBits(BRect(sel_rect.left, y, sel_rect.right, y), &rowBytes); - for (float x = sel_rect.left; x <= sel_rect.right; ++x) - { + for (float x = sel_rect.left; x <= sel_rect.right; ++x) { // Calculate gray - uchar gray = uchar( - float(pixel[0]) * 0.11 + - float(pixel[1]) * 0.59 + - float(pixel[2]) * 0.30); - + uchar gray = + uchar(float(pixel[0]) * 0.11 + float(pixel[1]) * 0.59 + float(pixel[2]) * 0.30); + // Set all colour components to the same gray level pixel[2] = pixel[1] = pixel[0] = gray; - - // Go to the next pixel + + // Go to the next pixel pixel += pixel_size; } } @@ -67,11 +59,8 @@ Manipulate( return B_OK; } - status_t -GetConfigMessage( - BMessage * /*ioExtension*/, - BMessage *ioCapability) +GetConfigMessage(BMessage* /*ioExtension*/, BMessage* ioCapability) { // Let them know that we support the selection rect extension ioCapability->AddInt32("selection_rect", B_RECT_TYPE); diff --git a/source/LibImageManipWrapper2/LibImageManipWrapper/src/Addon.cpp b/source/LibImageManipWrapper2/LibImageManipWrapper/src/Addon.cpp index 9405834..2858b91 100644 --- a/source/LibImageManipWrapper2/LibImageManipWrapper/src/Addon.cpp +++ b/source/LibImageManipWrapper2/LibImageManipWrapper/src/Addon.cpp @@ -30,49 +30,49 @@ #include "ImageManip.h" #include "BBitmapAccessor.h" -#define MSG_FILTER_SELECTED 'fsel' -#define MSG_FILTER_PREVIEW 'prev' -#define MSG_APPLY_TO_SELECTION 'aply' +#define MSG_FILTER_SELECTED 'fsel' +#define MSG_FILTER_PREVIEW 'prev' +#define MSG_APPLY_TO_SELECTION 'aply' #ifdef MANIPULATOR -#define WINDOW_TITLE "Manipulate %s" -#define NAME "Filter" -#define MENU_FIELD "Filter:" -#define POPUP_NAME "Select Filter" -#define WRAPPER_TYPE BECASSO_FILTER -#define PREVIEW PREVIEW_2x2 +#define WINDOW_TITLE "Manipulate %s" +#define NAME "Filter" +#define MENU_FIELD "Filter:" +#define POPUP_NAME "Select Filter" +#define WRAPPER_TYPE BECASSO_FILTER +#define PREVIEW PREVIEW_2x2 #define APPLY_TO_SELECTION "Apply filter to selection too" #endif #ifdef CONVERTER -#define WINDOW_TITLE "Convert %s" -#define NAME "Generator" -#define MENU_FIELD "Generator:" -#define POPUP_NAME "Select Generator" -#define WRAPPER_TYPE BECASSO_TRANSFORMER -#define PREVIEW PREVIEW_2x2 +#define WINDOW_TITLE "Convert %s" +#define NAME "Generator" +#define MENU_FIELD "Generator:" +#define POPUP_NAME "Select Generator" +#define WRAPPER_TYPE BECASSO_TRANSFORMER +#define PREVIEW PREVIEW_2x2 #define APPLY_TO_SELECTION "Apply transformer to selection too" #endif class WrapperView; -static int32 mAddonId = -1; -static bool mApplyToSelection = false; -static WrapperView *mView = NULL; +static int32 mAddonId = -1; +static bool mApplyToSelection = false; +static WrapperView* mView = NULL; #define STATUS_TEXT_HEIGHT 20 class WrapperView : public BView { void SetupFilters(BMenu* sub_menu); - BView *mView; - BMenuField *mMenuField; - int mTop, mWidth; - BStringView *mStatus; + BView* mView; + BMenuField* mMenuField; + int mTop, mWidth; + BStringView* mStatus; -public: - WrapperView (BRect rect); - virtual ~WrapperView () {}; + public: + WrapperView(BRect rect); + virtual ~WrapperView(){}; void MessageReceived(BMessage* msg); void RemoveView(); @@ -80,100 +80,111 @@ class WrapperView : public BView void SetupConfigView(int32 addon, const char* name); }; -WrapperView::WrapperView (BRect rect) : BView(rect, "", B_FOLLOW_NONE, 0) { +WrapperView::WrapperView(BRect rect) : BView(rect, "", B_FOLLOW_NONE, 0) +{ mView = NULL; - BMenu *sub_menu = new BPopUpMenu(POPUP_NAME); - // mHeight = rect.IntegerHeight(); + BMenu* sub_menu = new BPopUpMenu(POPUP_NAME); + // mHeight = rect.IntegerHeight(); mWidth = rect.IntegerWidth(); mWidth = 270; mTop = 0; - mMenuField = new BMenuField(BRect(5, mTop, 200, mTop+30), NAME, MENU_FIELD, sub_menu); + mMenuField = new BMenuField(BRect(5, mTop, 200, mTop + 30), NAME, MENU_FIELD, sub_menu); mMenuField->SetDivider(70); AddChild(mMenuField); - AddChild(new BButton(BRect(205, mTop, 265, mTop + 20), "", "Preview", new BMessage(MSG_FILTER_PREVIEW))); - mTop += 32; - AddChild(new BCheckBox(BRect(5, mTop, 265, mTop + 20), "", APPLY_TO_SELECTION, new BMessage(MSG_APPLY_TO_SELECTION))); + AddChild(new BButton( + BRect(205, mTop, 265, mTop + 20), "", "Preview", new BMessage(MSG_FILTER_PREVIEW) + )); + mTop += 32; + AddChild(new BCheckBox( + BRect(5, mTop, 265, mTop + 20), "", APPLY_TO_SELECTION, new BMessage(MSG_APPLY_TO_SELECTION) + )); mTop += 22; ResizeTo(mWidth, mTop + STATUS_TEXT_HEIGHT); - mStatus = new BStringView(BRect(5, mTop, 265, mTop + 16), "", "Status", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); + mStatus = new BStringView( + BRect(5, mTop, 265, mTop + 16), "", "Status", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM + ); AddChild(mStatus); - - SetupFilters(sub_menu); -}; + SetupFilters(sub_menu); +}; -void WrapperView::SetupFilters(BMenu* sub_menu) { +void +WrapperView::SetupFilters(BMenu* sub_menu) +{ // Create bitmap accessor object to pass along, so that we // only get the add-ons that support this bitmap in the menu BBitmap bitmap(BRect(0, 0, 100, 20), B_RGB32); BBitmapAccessor* accessor = Image_CreateBBitmapAccessor(&bitmap); if (accessor == NULL) { - sub_menu->SetEnabled(false); return; + sub_menu->SetEnabled(false); + return; } accessor->SetDispose(false); // Create sub menu with image manipulators - const char *addonName; - const char *addonInfo; - const char *addonCategory; + const char* addonName; + const char* addonInfo; + const char* addonCategory; int32 addonVersion; - image_addon_id *outList; + image_addon_id* outList; int32 outCount = 0; - BMenuItem *item; + BMenuItem* item; #ifdef MANIPULATOR if (Image_GetManipulators(accessor, NULL, &outList, &outCount) == B_OK) #endif #ifdef CONVERTER - if (Image_GetConverters(accessor, NULL, &outList, &outCount) == B_OK) + if (Image_GetConverters(accessor, NULL, &outList, &outCount) == B_OK) #endif - { - mAddonId = outList[0]; - - for (int i = outCount-1; i >= 0; --i) { - if (Image_GetAddonInfo(outList[i], &addonName, &addonInfo, - &addonCategory, &addonVersion) == B_OK) - { - BMessage *msg = new BMessage(MSG_FILTER_SELECTED); - msg->AddInt32("addon_id", outList[i]); - msg->AddString("addon_name", addonName); - item = new BMenuItem(addonName, msg); - sub_menu->AddItem(item); - if (i == outCount-1) SetupConfigView(outList[i], addonName); + mAddonId = outList[0]; + + for (int i = outCount - 1; i >= 0; --i) { + if (Image_GetAddonInfo( + outList[i], &addonName, &addonInfo, &addonCategory, &addonVersion + ) == B_OK) { + BMessage* msg = new BMessage(MSG_FILTER_SELECTED); + msg->AddInt32("addon_id", outList[i]); + msg->AddString("addon_name", addonName); + item = new BMenuItem(addonName, msg); + sub_menu->AddItem(item); + if (i == outCount - 1) + SetupConfigView(outList[i], addonName); + } } + delete[] outList; } - delete[] outList; - } if (outCount == 0) sub_menu->SetEnabled(false); - else - { + else { sub_menu->ItemAt((int32)0)->SetMarked(true); } delete accessor; } - -void WrapperView::RemoveView() { +void +WrapperView::RemoveView() +{ if (mView) { RemoveChild(mView); - delete mView; mView = NULL; + delete mView; + mView = NULL; } } - -void WrapperView::SetupConfigView(int32 addon, const char* name) { +void +WrapperView::SetupConfigView(int32 addon, const char* name) +{ mAddonId = addon; RemoveView(); int width; BMessage ioExt, cap; status_t s = Image_GetConfigurationMessage(mAddonId, &ioExt, &cap); if (Image_MakeConfigurationView(mAddonId, &ioExt, &mView) == 0 && mView) { - AddChild(mView); + AddChild(mView); int width = max_c(mWidth, mView->Bounds().Width()) + 10; - mView->MoveTo((width-mView->Bounds().Width()) / 2, mTop); + mView->MoveTo((width - mView->Bounds().Width()) / 2, mTop); ResizeTo(width, mTop + STATUS_TEXT_HEIGHT + mView->Bounds().Height()); } else { ResizeTo(mWidth, mTop + STATUS_TEXT_HEIGHT); @@ -181,59 +192,62 @@ void WrapperView::SetupConfigView(int32 addon, const char* name) { } } - -void WrapperView::MessageReceived(BMessage* msg) { - switch(msg->what) { - case MSG_FILTER_SELECTED: { - BString name; - SetStatus("Status"); - msg->FindString("addon_name", &name); - SetupConfigView(msg->FindInt32("addon_id"), name.String()); - BWindow* window = Window(); - window->Lock(); - window->PostMessage(ADDON_RESIZED); - window->Unlock(); - break; } - case MSG_FILTER_PREVIEW: - addon_preview(); - break; - case MSG_APPLY_TO_SELECTION: { - int32 s; - if (B_OK == msg->FindInt32("be:value", &s)) { - mApplyToSelection = (bool)s; - } - } - break; - default: - BView::MessageReceived(msg); +void +WrapperView::MessageReceived(BMessage* msg) +{ + switch (msg->what) { + case MSG_FILTER_SELECTED: { + BString name; + SetStatus("Status"); + msg->FindString("addon_name", &name); + SetupConfigView(msg->FindInt32("addon_id"), name.String()); + BWindow* window = Window(); + window->Lock(); + window->PostMessage(ADDON_RESIZED); + window->Unlock(); + break; + } + case MSG_FILTER_PREVIEW: + addon_preview(); + break; + case MSG_APPLY_TO_SELECTION: { + int32 s; + if (B_OK == msg->FindInt32("be:value", &s)) { + mApplyToSelection = (bool)s; + } + } break; + default: + BView::MessageReceived(msg); } } - -void WrapperView::SetStatus(const char* text) { +void +WrapperView::SetStatus(const char* text) +{ mStatus->SetText(text); } - -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = mView = new WrapperView(rect); + *view = mView = new WrapperView(rect); return B_OK; } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "LibImageManip Wrapper"); - strcpy (info->author, "Michael Pfeiffer"); - strcpy (info->copyright, "© 2001 under GPL"); - strcpy (info->description, "Wrapper to LibImageManip"); - info->type = WRAPPER_TYPE; - info->index = index; - info->version = 0; - info->release = 4; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW; + strcpy(info->name, "LibImageManip Wrapper"); + strcpy(info->author, "Michael Pfeiffer"); + strcpy(info->copyright, "© 2001 under GPL"); + strcpy(info->description, "Wrapper to LibImageManip"); + info->type = WRAPPER_TYPE; + info->index = index; + info->version = 0; + info->release = 4; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW; #if defined(MANIPULATOR) || defined(IMAGEMANIP_WEAK_LINKAGE) // Note: We assume that the filter is loaded first by Becasso, // then the transformer is loaded and both are loaded @@ -246,28 +260,25 @@ status_t addon_init (uint32 index, becasso_addon_info *info) // will crash when the add-ons are exited (addon_exit). // // When IMAGEMANIP_WEAK_LINKAGE is defined we solve this problem - // as Imagelibmanip is loaded in each wrapper add-on. + // as Imagelibmanip is loaded in each wrapper add-on. // Check the library's version int32 curVersion; int32 minVersion; // Initialize the image manipulation library - if (Image_Init(NULL) != B_OK) - { + if (Image_Init(NULL) != B_OK) { puts("Cannot initialize libimagemanip.so"); return B_ERROR; } // Check the library's version puts(Image_Version(&curVersion, &minVersion)); - if (curVersion < IMAGE_LIB_MIN_VERSION) - { + if (curVersion < IMAGE_LIB_MIN_VERSION) { puts("Need a newer version of libimagemanip.so"); return B_ERROR; } - if (minVersion > IMAGE_LIB_CUR_VERSION) - { + if (minVersion > IMAGE_LIB_CUR_VERSION) { puts("Need an older version of libimagemanip.so"); return B_ERROR; } @@ -275,24 +286,25 @@ status_t addon_init (uint32 index, becasso_addon_info *info) return (0); } -status_t addon_exit (void) +status_t +addon_exit(void) { // We have to remove the config view from Imagelibmanip otherwise we // crash when the destructor of this window is called! - // When IMAGE_WEAK_LINKAGE is defined this is no issue and the - // Imagelibmanip is always shutdown! + // When IMAGE_WEAK_LINKAGE is defined this is no issue and the + // Imagelibmanip is always shutdown! // Shutdown the image manipulation library #if defined(MANIPULATOR) || defined(IMAGEMANIP_WEAK_LINKAGE) // Note: We assume that the addon_exit of the transformer is called // after the filter add-on. Image_Shutdown(); -#endif +#endif return (0); } - -status_t addon_close () +status_t +addon_close() { BWindow* window = mView->Window(); window->Lock(); @@ -301,15 +313,18 @@ status_t addon_close () return (0); } -static void SetStatus(const char* text) { +static void +SetStatus(const char* text) +{ BWindow* window = mView->Window(); window->Lock(); mView->SetStatus(text); window->Unlock(); } - -static void CopySelection(BBitmap* src, BBitmap* dst, int x, int y) { +static void +CopySelection(BBitmap* src, BBitmap* dst, int x, int y) +{ dst->Lock(); BView* view = new BView(dst->Bounds(), "tmp", 0, 0); dst->AddChild(view); @@ -320,245 +335,243 @@ static void CopySelection(BBitmap* src, BBitmap* dst, int x, int y) { dst->Unlock(); } - -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * frame, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* frame, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); -// printf ("Bounds: "); -// bounds.PrintToStream(); -// printf ("Frame: "); -// frame->PrintToStream(); -// fprintf(stderr, "mode = %d final = %d\n", mode, final); -// fprintf(stderr, "in %x out %x in %x out %x\n", inLayer, *outLayer, inSelection, *outSelection); + // printf ("Bounds: "); + // bounds.PrintToStream(); + // printf ("Frame: "); + // frame->PrintToStream(); + // fprintf(stderr, "mode = %d final = %d\n", mode, final); + // fprintf(stderr, "in %x out %x in %x out %x\n", inLayer, *outLayer, inSelection, + //*outSelection); -// #ifdef MANIPULATOR + // #ifdef MANIPULATOR if (*outLayer == NULL && mode == M_DRAW) { - *outLayer = new Layer (*inLayer); + *outLayer = new Layer(*inLayer); } if (*outSelection == NULL && mode == M_DRAW) { *outSelection = inSelection; } - - if (mode == M_SELECT) - { - if (inSelection) - { - if (*outSelection == NULL) - *outSelection = new Selection (*inSelection); - } - else // No Selection to filter! + + if (mode == M_SELECT) { + if (inSelection) { + if (*outSelection == NULL) + *outSelection = new Selection(*inSelection); + } else // No Selection to filter! return (0); } if (*outLayer) (*outLayer)->Lock(); - + if (*outSelection) (*outSelection)->Lock(); -// #endif + // #endif + + // fprintf(stderr, "in %x out %x in %x out %x\n", inLayer, *outLayer, inSelection, + //*outSelection); -// fprintf(stderr, "in %x out %x in %x out %x\n", inLayer, *outLayer, inSelection, *outSelection); - uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - if (final) - { -// addon_start(); - } - else - { -// return error; - } - + if (final) { + // addon_start(); + } else { + // return error; + } + BMessage ioExt, m; Image_GetConfigurationMessage(mAddonId, &ioExt, &m); -// ioExt.PrintToStream(); -// m.PrintToStream(); + // ioExt.PrintToStream(); + // m.PrintToStream(); if (frame->IntegerWidth() == 0 || frame->IntegerHeight() == 0) { ioExt.AddRect("selection_rect", bounds); } else { // frame->PrintToStream(); ioExt.AddRect("selection_rect", *frame); } - switch (mode) - { - #ifdef MANIPULATOR // Becasso Filter - case M_DRAW: - { - // Create bitmap accessor object - memcpy((*outLayer)->Bits(), inLayer->Bits(), inLayer->BitsLength()); - Layer* layer; - if (inSelection) { - layer = new Layer(*inLayer); - memcpy(layer->Bits(), inLayer->Bits(), inLayer->BitsLength()); - } else { - layer = *outLayer; - } - BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(layer); - if (src_accessor == NULL) { - error = ADDON_ABORT;; - if (inSelection) delete layer; - break; - } + switch (mode) { +#ifdef MANIPULATOR // Becasso Filter + case M_DRAW: { + // Create bitmap accessor object + memcpy((*outLayer)->Bits(), inLayer->Bits(), inLayer->BitsLength()); + Layer* layer; + if (inSelection) { + layer = new Layer(*inLayer); + memcpy(layer->Bits(), inLayer->Bits(), inLayer->BitsLength()); + } else { + layer = *outLayer; + } + BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(layer); + if (src_accessor == NULL) { + error = ADDON_ABORT; + ; + if (inSelection) + delete layer; + break; + } + src_accessor->SetDispose(false); + + // manipulate layer + if (Image_Manipulate(mAddonId, src_accessor, &ioExt, false) != B_OK) { + SetStatus("Error: Could not manipulate layer!"); + error = ADDON_UNKNOWN; + } + delete src_accessor; + + // manipulate selection + if (error == ADDON_OK && mApplyToSelection && inSelection) { + memcpy((*outSelection)->Bits(), inSelection->Bits(), inSelection->BitsLength()); + src_accessor = Image_CreateBBitmapAccessor(*outSelection); src_accessor->SetDispose(false); - - // manipulate layer if (Image_Manipulate(mAddonId, src_accessor, &ioExt, false) != B_OK) { - SetStatus("Error: Could not manipulate layer!"); - error = ADDON_UNKNOWN; + SetStatus("Error: Could not manipulate selection!"); } delete src_accessor; - - // manipulate selection - if (error == ADDON_OK && mApplyToSelection && inSelection) { - memcpy((*outSelection)->Bits(), inSelection->Bits(), inSelection->BitsLength()); - src_accessor = Image_CreateBBitmapAccessor(*outSelection); - src_accessor->SetDispose(false); - if (Image_Manipulate(mAddonId, src_accessor, &ioExt, false) != B_OK) { - SetStatus("Error: Could not manipulate selection!"); - } - delete src_accessor; - } + } - // return selection of layer only - if (error == ADDON_OK && inSelection && *outSelection) { - CutOrCopy(layer, layer, *outSelection, 0, 0, false); - AddWithAlpha(layer, *outLayer, 0, 0); - } + // return selection of layer only + if (error == ADDON_OK && inSelection && *outSelection) { + CutOrCopy(layer, layer, *outSelection, 0, 0, false); + AddWithAlpha(layer, *outLayer, 0, 0); + } - if (inSelection) { - delete layer; - } + if (inSelection) { + delete layer; + } break; + } + case M_SELECT: { + // Create bitmap accessor object + memcpy((*outSelection)->Bits(), inSelection->Bits(), inSelection->BitsLength()); + BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(*outSelection); + if (src_accessor == NULL) { + error = ADDON_ABORT; + ; + break; } - case M_SELECT: - { - // Create bitmap accessor object - memcpy((*outSelection)->Bits(), inSelection->Bits(), inSelection->BitsLength()); - BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(*outSelection); - if (src_accessor == NULL) { - error = ADDON_ABORT;; - break; - } - src_accessor->SetDispose(false); + src_accessor->SetDispose(false); - if (Image_Manipulate(mAddonId, src_accessor, &ioExt, false) < 0) { - //window->Lock(); - //window->SetStatus("Error: Could not manipulate selection!"); - //window->Unlock(); - } - delete src_accessor; + if (Image_Manipulate(mAddonId, src_accessor, &ioExt, false) < 0) { + // window->Lock(); + // window->SetStatus("Error: Could not manipulate selection!"); + // window->Unlock(); + } + delete src_accessor; break; + } +#endif + + +#ifdef CONVERTER // Becasso Transformer + case M_DRAW: { + // Create bitmap accessor object + Layer* layer; + if (inSelection) { + layer = new Layer(*inLayer); + memcpy((*outLayer)->Bits(), inLayer->Bits(), inLayer->BitsLength()); + } else { + layer = *outLayer; } - #endif - - - #ifdef CONVERTER // Becasso Transformer - case M_DRAW: - { - // Create bitmap accessor object - Layer* layer; - if (inSelection) { - layer = new Layer(*inLayer); - memcpy((*outLayer)->Bits(), inLayer->Bits(), inLayer->BitsLength()); - } else { - layer = *outLayer; - } - BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(inLayer); - if (src_accessor == NULL) { - error = ADDON_ABORT;; - break; - } - src_accessor->SetDispose(false); + BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(inLayer); + if (src_accessor == NULL) { + error = ADDON_ABORT; + ; + break; + } + src_accessor->SetDispose(false); + + BBitmapAccessor* dst_accessor = Image_CreateBBitmapAccessor(); + dst_accessor->SetDispose(true); - BBitmapAccessor* dst_accessor = Image_CreateBBitmapAccessor(); + // convert layer + if (Image_Convert(mAddonId, src_accessor, dst_accessor, &ioExt, false) != B_OK) { + SetStatus("Error: Could not convert layer!"); + error = ADDON_UNKNOWN; + } + delete src_accessor; + + int dx = -(bounds.IntegerWidth() - dst_accessor->Bounds().IntegerWidth()) / 2; + int dy = -(bounds.IntegerHeight() - dst_accessor->Bounds().IntegerHeight()) / 2; + CutOrCopy(dst_accessor->Bitmap(), layer, NULL, dx, dy, false); + delete dst_accessor; + + // manipulate selection + if (error == ADDON_OK && mApplyToSelection && inSelection) { + src_accessor = Image_CreateBBitmapAccessor(inSelection); + src_accessor->SetDispose(false); + dst_accessor = Image_CreateBBitmapAccessor(); dst_accessor->SetDispose(true); - - // convert layer if (Image_Convert(mAddonId, src_accessor, dst_accessor, &ioExt, false) != B_OK) { - SetStatus("Error: Could not convert layer!"); - error = ADDON_UNKNOWN; + SetStatus("Error: Could not manipulate selection!"); } delete src_accessor; - - int dx = -(bounds.IntegerWidth() - dst_accessor->Bounds().IntegerWidth()) / 2; - int dy = -(bounds.IntegerHeight() - dst_accessor->Bounds().IntegerHeight()) / 2; - CutOrCopy(dst_accessor->Bitmap(), layer, NULL, dx, dy, false); + CopySelection(dst_accessor->Bitmap(), *outSelection, dx, dy); delete dst_accessor; - - // manipulate selection - if (error == ADDON_OK && mApplyToSelection && inSelection) { - src_accessor = Image_CreateBBitmapAccessor(inSelection); - src_accessor->SetDispose(false); - dst_accessor = Image_CreateBBitmapAccessor(); - dst_accessor->SetDispose(true); - if (Image_Convert(mAddonId, src_accessor, dst_accessor, &ioExt, false) != B_OK) { - SetStatus("Error: Could not manipulate selection!"); - } - delete src_accessor; - CopySelection(dst_accessor->Bitmap(), *outSelection,dx, dy); - delete dst_accessor; - } + } - // return selection of layer only - if (error == ADDON_OK && inSelection && *outSelection) { - CutOrCopy(layer, layer, *outSelection, 0, 0, false); - AddWithAlpha(layer, *outLayer, 0, 0); - } + // return selection of layer only + if (error == ADDON_OK && inSelection && *outSelection) { + CutOrCopy(layer, layer, *outSelection, 0, 0, false); + AddWithAlpha(layer, *outLayer, 0, 0); + } - if (inSelection) { - delete layer; - } + if (inSelection) { + delete layer; + } break; + } + case M_SELECT: { + // Create bitmap accessor object + BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(inSelection); + if (src_accessor == NULL) { + error = ADDON_ABORT; + ; + break; } - case M_SELECT: - { - // Create bitmap accessor object - BBitmapAccessor* src_accessor = Image_CreateBBitmapAccessor(inSelection); - if (src_accessor == NULL) { - error = ADDON_ABORT;; - break; - } - src_accessor->SetDispose(false); - BBitmapAccessor* dst_accessor = Image_CreateBBitmapAccessor(); - dst_accessor->SetDispose(true); - - if (Image_Convert(mAddonId, src_accessor, dst_accessor, &ioExt, false) != B_OK) { - SetStatus("Error: Could not convert selection!"); - error = ADDON_ABORT;; - } else { - int dx = -(bounds.IntegerWidth() - dst_accessor->Bounds().IntegerWidth()) / 2; - int dy = -(bounds.IntegerHeight() - dst_accessor->Bounds().IntegerHeight()) / 2; - CopySelection(dst_accessor->Bitmap(), *outSelection, dx, dy); - } - delete src_accessor; delete dst_accessor; - break; + src_accessor->SetDispose(false); + BBitmapAccessor* dst_accessor = Image_CreateBBitmapAccessor(); + dst_accessor->SetDispose(true); + + if (Image_Convert(mAddonId, src_accessor, dst_accessor, &ioExt, false) != B_OK) { + SetStatus("Error: Could not convert selection!"); + error = ADDON_ABORT; + ; + } else { + int dx = -(bounds.IntegerWidth() - dst_accessor->Bounds().IntegerWidth()) / 2; + int dy = -(bounds.IntegerHeight() - dst_accessor->Bounds().IntegerHeight()) / 2; + CopySelection(dst_accessor->Bitmap(), *outSelection, dx, dy); } -#endif - + delete src_accessor; + delete dst_accessor; + break; + } +#endif + default: - fprintf (stderr, "Wrapper: Unknown mode\n"); + fprintf(stderr, "Wrapper: Unknown mode\n"); error = ADDON_UNKNOWN; } -// #ifdef MANIPULATOR + // #ifdef MANIPULATOR if (*outSelection) (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); -// #endif - - if (final) - { -// addon_done(); + // #endif + + if (final) { + // addon_done(); } return (error); } diff --git a/source/MagView.cpp b/source/MagView.cpp index 084a92e..6e016be 100644 --- a/source/MagView.cpp +++ b/source/MagView.cpp @@ -5,11 +5,11 @@ #include "Becasso.h" #include -MagView::MagView (BRect frame, const char *name, CanvasView *_myView) - : BView (frame, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED) +MagView::MagView(BRect frame, const char* name, CanvasView* _myView) + : BView(frame, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED) { grid_visible = 1; - pos = BPoint (0, 0); + pos = BPoint(0, 0); myView = _myView; undoIndex = -1; redoIndex = 0; @@ -17,333 +17,323 @@ MagView::MagView (BRect frame, const char *name, CanvasView *_myView) fPicking = false; } -MagView::~MagView () -{ -} +MagView::~MagView() {} -bool MagView::contains (BPoint p) const +bool +MagView::contains(BPoint p) const { - BPoint r = BPoint (p.x*zoom, p.y*zoom); - return (Bounds().Contains (r)); + BPoint r = BPoint(p.x * zoom, p.y * zoom); + return (Bounds().Contains(r)); } -void MagView::Draw (BRect update) +void +MagView::Draw(BRect update) { // You won't believe how simple this is. // I know about the one-pixel-off bug. - SetDrawingMode (B_OP_COPY); + SetDrawingMode(B_OP_COPY); BRect source, ibounds; - BBitmap *canvas = new BBitmap (myView->canvasFrame(), B_RGBA32); - source.Set (int (update.left/zoom), int (update.top/zoom), - int (update.right/zoom) + 1, int (update.bottom/zoom) + 1); - ibounds.Set (int (source.left)*zoom, int (source.top)*zoom, - int (source.right + 1)*zoom, int (source.bottom + 1)*zoom); - myView->ConstructCanvas (canvas, source, false); - DrawBitmapAsync (canvas, source, ibounds); + BBitmap* canvas = new BBitmap(myView->canvasFrame(), B_RGBA32); + source.Set( + int(update.left / zoom), int(update.top / zoom), int(update.right / zoom) + 1, + int(update.bottom / zoom) + 1 + ); + ibounds.Set( + int(source.left) * zoom, int(source.top) * zoom, int(source.right + 1) * zoom, + int(source.bottom + 1) * zoom + ); + myView->ConstructCanvas(canvas, source, false); + DrawBitmapAsync(canvas, source, ibounds); - if (grid_visible) - { + if (grid_visible) { rgb_color Hi; if (grid_visible == 1) Hi = Black; else Hi = White; - BeginLineArray ((update.right - update.left - + update.bottom - update.top)/zoom + 8); - for (long x = long (update.left/zoom - 1); x <= long (update.right/zoom + 1); x++) - AddLine (BPoint (x*zoom, update.top), - BPoint (x*zoom, update.bottom), Hi); - for (long y = long (update.top/zoom - 1); y <= long (update.bottom/zoom + 1); y++) - AddLine (BPoint (update.left, y*zoom), - BPoint (update.right, y*zoom), Hi); + BeginLineArray((update.right - update.left + update.bottom - update.top) / zoom + 8); + for (long x = long(update.left / zoom - 1); x <= long(update.right / zoom + 1); x++) + AddLine(BPoint(x * zoom, update.top), BPoint(x * zoom, update.bottom), Hi); + for (long y = long(update.top / zoom - 1); y <= long(update.bottom / zoom + 1); y++) + AddLine(BPoint(update.left, y * zoom), BPoint(update.right, y * zoom), Hi); EndLineArray(); } Sync(); delete canvas; } -void MagView::MouseDown (BPoint point) +void +MagView::MouseDown(BPoint point) { extern ColorMenuButton *locolor, *hicolor; - BPoint p = BPoint (int (point.x/zoom), int (point.y/zoom)); + BPoint p = BPoint(int(point.x / zoom), int(point.y / zoom)); BRect pix; - uint32 buttons = Window()->CurrentMessage()->FindInt32 ("buttons"); + uint32 buttons = Window()->CurrentMessage()->FindInt32("buttons"); rgb_color hi; - if (modifiers() & B_OPTION_KEY) - { + if (modifiers() & B_OPTION_KEY) { if (buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) - hicolor->set (myView->getColor (p.x, p.y)); + hicolor->set(myView->getColor(p.x, p.y)); if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - locolor->set (myView->getColor (p.x, p.y)); + locolor->set(myView->getColor(p.x, p.y)); fPicking = true; - } - else if (!fPicking) - { + } else if (!fPicking) { if (buttons & B_PRIMARY_MOUSE_BUTTON) - hi = hicolor->color (); + hi = hicolor->color(); if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - hi = locolor->color (); + hi = locolor->color(); BPoint prevpoint = B_ORIGIN; - while (buttons) - { - if (prevpoint != p) - { - SetHighColor (hi); - if (myView->LockLooper()) - { - SetupUndo (p, myView->get_and_plot (p, hi)); - myView->Invalidate (BRect (p.x - 1, p.y - 1, p.x + 1, p.y + 1)); + while (buttons) { + if (prevpoint != p) { + SetHighColor(hi); + if (myView->LockLooper()) { + SetupUndo(p, myView->get_and_plot(p, hi)); + myView->Invalidate(BRect(p.x - 1, p.y - 1, p.x + 1, p.y + 1)); myView->UnlockLooper(); } - snooze (30*1000); - pix.Set (p.x*zoom, p.y*zoom, p.x*zoom + zoom - 1, p.y*zoom + zoom - 1); - FillRect (pix); - if (grid_visible) - { + snooze(30 * 1000); + pix.Set(p.x * zoom, p.y * zoom, p.x * zoom + zoom - 1, p.y * zoom + zoom - 1); + FillRect(pix); + if (grid_visible) { rgb_color Hi; if (grid_visible == 1) Hi = Black; else Hi = White; - SetHighColor (Hi); + SetHighColor(Hi); pix.right++; pix.bottom++; - StrokeRect (pix); - } + StrokeRect(pix); + } prevpoint = p; - GetMouse (&point, &buttons); + GetMouse(&point, &buttons); BRect bounds = Bounds(); - if (point.x > bounds.right) // Still flickers... - ScrollBy (zoom*(point.x - bounds.right), 0); + if (point.x > bounds.right) // Still flickers... + ScrollBy(zoom * (point.x - bounds.right), 0); if (point.x < bounds.left && bounds.left > 0) - ScrollBy (zoom*(point.x - bounds.left), 0); - if (point.y > bounds.bottom) // Ditto. Think of a nice test. (I know what you're thinking, but I tried that...) - ScrollBy (0, zoom*(point.y - bounds.bottom)); + ScrollBy(zoom * (point.x - bounds.left), 0); + if (point.y > bounds.bottom) // Ditto. Think of a nice test. (I know what you're + // thinking, but I tried that...) + ScrollBy(0, zoom * (point.y - bounds.bottom)); if (point.y < bounds.top && bounds.top > 0) - ScrollBy (0, zoom*(point.y - bounds.top)); - } - else - GetMouse (&point, &buttons); + ScrollBy(0, zoom * (point.y - bounds.top)); + } else + GetMouse(&point, &buttons); + + p = BPoint(int(point.x / zoom), int(point.y / zoom)); - p = BPoint (int (point.x/zoom), int (point.y/zoom)); - - snooze (20000); + snooze(20000); } } -// Sync (); + // Sync (); } -void MagView::MouseMoved (BPoint point, uint32 transit, const BMessage *msg) +void +MagView::MouseMoved(BPoint point, uint32 transit, const BMessage* msg) { - extern Becasso *mainapp; - if (transit == B_EXITED_VIEW) - { + extern Becasso* mainapp; + if (transit == B_EXITED_VIEW) { mainapp->setHand(); mouse_on_canvas = false; // Invalidate(); - } - else if (transit == B_ENTERED_VIEW && Window()->IsActive() && !msg) - { + } else if (transit == B_ENTERED_VIEW && Window()->IsActive() && !msg) { mouse_on_canvas = true; } int32 buttons; - Window()->CurrentMessage()->FindInt32 ("buttons", &buttons); - if (modifiers() & B_OPTION_KEY) // Color Picker + Window()->CurrentMessage()->FindInt32("buttons", &buttons); + if (modifiers() & B_OPTION_KEY) // Color Picker { extern ColorMenuButton *hicolor, *locolor; - BPoint p = BPoint (int (point.x/zoom), int (point.y/zoom)); + BPoint p = BPoint(int(point.x / zoom), int(point.y / zoom)); if (buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) - hicolor->set (myView->getColor (p.x, p.y)); + hicolor->set(myView->getColor(p.x, p.y)); if (buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - locolor->set (myView->getColor (p.x, p.y)); + locolor->set(myView->getColor(p.x, p.y)); fPicking = true; } } -void MagView::Pulse () +void +MagView::Pulse() { BPoint point; uint32 buttons; - GetMouse (&point, &buttons, true); + GetMouse(&point, &buttons, true); - extern Becasso *mainapp; - if (modifiers() & B_OPTION_KEY && mouse_on_canvas) // Color Picker + extern Becasso* mainapp; + if (modifiers() & B_OPTION_KEY && mouse_on_canvas) // Color Picker { - mainapp->setPicker (true); + mainapp->setPicker(true); fPicking = true; - } - else if (fPicking) - { - mainapp->setPicker (false); + } else if (fPicking) { + mainapp->setPicker(false); if (mouse_on_canvas && !buttons) - mainapp->FixCursor(); // Otherwise: Few pixels off!! (BeOS bug w.r.t. hot spot of cursors ...) + mainapp->FixCursor( + ); // Otherwise: Few pixels off!! (BeOS bug w.r.t. hot spot of cursors ...) fPicking = false; } } -void MagView::setzoom (int z) +void +MagView::setzoom(int z) { zoom = z; - int maxw = int (zoom*myView->canvasFrame().IntegerWidth() + B_V_SCROLL_BAR_WIDTH); - int maxh = int (zoom*myView->canvasFrame().IntegerHeight() + B_H_SCROLL_BAR_HEIGHT + - ((MagWindow *)Window())->menubarHeight() + 1); - Window()->SetSizeLimits (64, maxw, 64, maxh); - Window()->ResizeTo (min_c (maxw, Window()->Frame().Width()), - min_c (maxh, Window()->Frame().Height())); - FrameResized (Bounds().Width(), Bounds().Height()); - Draw (Bounds ()); + int maxw = int(zoom * myView->canvasFrame().IntegerWidth() + B_V_SCROLL_BAR_WIDTH); + int maxh = + int(zoom * myView->canvasFrame().IntegerHeight() + B_H_SCROLL_BAR_HEIGHT + + ((MagWindow*)Window())->menubarHeight() + 1); + Window()->SetSizeLimits(64, maxw, 64, maxh); + Window()->ResizeTo( + min_c(maxw, Window()->Frame().Width()), min_c(maxh, Window()->Frame().Height()) + ); + FrameResized(Bounds().Width(), Bounds().Height()); + Draw(Bounds()); } -float MagView::currentzoom () +float +MagView::currentzoom() { return (zoom); } -void MagView::setgrid (int g) +void +MagView::setgrid(int g) { grid_visible = g; - Draw (Bounds ()); + Draw(Bounds()); } -void MagView::setScrollBars (BScrollBar *_h, BScrollBar *_v) +void +MagView::setScrollBars(BScrollBar* _h, BScrollBar* _v) { mh = _h; mv = _v; } -void MagView::AttachedToWindow () +void +MagView::AttachedToWindow() { - setzoom (8); - FrameResized (Bounds().Width(), Bounds().Height()); - SetViewColor (B_TRANSPARENT_32_BIT); + setzoom(8); + FrameResized(Bounds().Width(), Bounds().Height()); + SetViewColor(B_TRANSPARENT_32_BIT); } -void MagView::FrameResized (float width, float height) +void +MagView::FrameResized(float width, float height) { float hmin, hmax, vmin, vmax; - mh->GetRange (&hmin, &hmax); - mv->GetRange (&vmin, &vmax); - mh->SetRange (hmin, myView->canvasFrame().Width()*zoom - width + zoom - 1); - mv->SetRange (vmin, myView->canvasFrame().Height()*zoom - height + zoom - 1); - mh->SetProportion (Bounds().IntegerWidth()/zoom/myView->canvasFrame().Width()); - mv->SetProportion (Bounds().IntegerHeight()/zoom/myView->canvasFrame().Height()); - mh->SetSteps (zoom, zoom*int (Bounds().IntegerWidth()/zoom)); - mv->SetSteps (zoom, zoom*int (Bounds().IntegerHeight()/zoom)); + mh->GetRange(&hmin, &hmax); + mv->GetRange(&vmin, &vmax); + mh->SetRange(hmin, myView->canvasFrame().Width() * zoom - width + zoom - 1); + mv->SetRange(vmin, myView->canvasFrame().Height() * zoom - height + zoom - 1); + mh->SetProportion(Bounds().IntegerWidth() / zoom / myView->canvasFrame().Width()); + mv->SetProportion(Bounds().IntegerHeight() / zoom / myView->canvasFrame().Height()); + mh->SetSteps(zoom, zoom * int(Bounds().IntegerWidth() / zoom)); + mv->SetSteps(zoom, zoom * int(Bounds().IntegerHeight() / zoom)); } -bool MagView::CanUndo () +bool +MagView::CanUndo() { return (undoIndex >= 0); } -bool MagView::CanRedo () +bool +MagView::CanRedo() { return (redoIndex > undoIndex); } -void MagView::SetupUndo (BPoint p, uint32 c) +void +MagView::SetupUndo(BPoint p, uint32 c) { - if (undoIndex < MAX_MAG_UNDO - 1) - { + if (undoIndex < MAX_MAG_UNDO - 1) { ++undoIndex; redoIndex = undoIndex; - undo[undoIndex].x = uint16 (p.x); - undo[undoIndex].y = uint16 (p.y); + undo[undoIndex].x = uint16(p.x); + undo[undoIndex].y = uint16(p.y); undo[undoIndex].c = c; -// printf ("Setup undo in %ld\n", undoIndex); - } - else - { + // printf ("Setup undo in %ld\n", undoIndex); + } else { for (uint32 i = 0; i < MAX_MAG_UNDO - 1; i++) undo[i] = undo[i + 1]; - undo[MAX_MAG_UNDO - 1].x = uint16 (p.x); - undo[MAX_MAG_UNDO - 1].y = uint16 (p.y); + undo[MAX_MAG_UNDO - 1].x = uint16(p.x); + undo[MAX_MAG_UNDO - 1].y = uint16(p.y); undo[MAX_MAG_UNDO - 1].c = c; } } -status_t MagView::Undo () +status_t +MagView::Undo() { - if (undoIndex >= 0) - { - BPoint p = BPoint (undo[undoIndex].x, undo[undoIndex].y); - if (myView->LockLooper()) - { + if (undoIndex >= 0) { + BPoint p = BPoint(undo[undoIndex].x, undo[undoIndex].y); + if (myView->LockLooper()) { uint32 c = undo[undoIndex].c; rgb_color col = {RED(c), GREEN(c), BLUE(c), ALPHA(c)}; - undo[undoIndex].c = myView->get_and_plot (p, col); - myView->Invalidate (BRect (p.x - 1, p.y - 1, p.x + 1, p.y + 1)); + undo[undoIndex].c = myView->get_and_plot(p, col); + myView->Invalidate(BRect(p.x - 1, p.y - 1, p.x + 1, p.y + 1)); myView->UnlockLooper(); -// printf ("Undid %ld, index now %ld\n", undoIndex, undoIndex - 1); + // printf ("Undid %ld, index now %ld\n", undoIndex, undoIndex - 1); --undoIndex; BRect pix; - pix.Set (p.x*zoom, p.y*zoom, - p.x*zoom + zoom - 1, p.y*zoom + zoom - 1); - SetHighColor (col); - FillRect (pix); - if (LockLooper()) - { - if (grid_visible) - { + pix.Set(p.x * zoom, p.y * zoom, p.x * zoom + zoom - 1, p.y * zoom + zoom - 1); + SetHighColor(col); + FillRect(pix); + if (LockLooper()) { + if (grid_visible) { rgb_color Hi; if (grid_visible == 1) Hi = Black; else Hi = White; - SetHighColor (Hi); + SetHighColor(Hi); pix.right++; pix.bottom++; - StrokeRect (pix); + StrokeRect(pix); } UnlockLooper(); } } return B_OK; - } - else - return B_ERROR; // Nothing to undo... + } else + return B_ERROR; // Nothing to undo... } -status_t MagView::Redo () +status_t +MagView::Redo() { - if (1 || redoIndex < MAX_MAG_UNDO && redoIndex > 0) - { - if (myView->LockLooper()) - { + if (1 || redoIndex < MAX_MAG_UNDO && redoIndex > 0) { + if (myView->LockLooper()) { ++undoIndex; - BPoint p = BPoint (undo[undoIndex].x, undo[undoIndex].y); + BPoint p = BPoint(undo[undoIndex].x, undo[undoIndex].y); uint32 c = undo[undoIndex].c; rgb_color col = {RED(c), GREEN(c), BLUE(c), ALPHA(c)}; - undo[undoIndex].c = myView->get_and_plot (p, col); - myView->Invalidate (BRect (p.x - 1, p.y - 1, p.x + 1, p.y + 1)); + undo[undoIndex].c = myView->get_and_plot(p, col); + myView->Invalidate(BRect(p.x - 1, p.y - 1, p.x + 1, p.y + 1)); myView->UnlockLooper(); BRect pix; - pix.Set (p.x*zoom, p.y*zoom, - p.x*zoom + zoom - 1, p.y*zoom + zoom - 1); - SetHighColor (col); - FillRect (pix); - if (LockLooper()) - { - if (grid_visible) - { + pix.Set(p.x * zoom, p.y * zoom, p.x * zoom + zoom - 1, p.y * zoom + zoom - 1); + SetHighColor(col); + FillRect(pix); + if (LockLooper()) { + if (grid_visible) { rgb_color Hi; if (grid_visible == 1) Hi = Black; else Hi = White; - SetHighColor (Hi); + SetHighColor(Hi); pix.right++; pix.bottom++; - StrokeRect (pix); + StrokeRect(pix); } UnlockLooper(); } } - + return B_OK; - } - else + } else return B_ERROR; } diff --git a/source/MagView.h b/source/MagView.h index b3dcd8e..bc20a8a 100644 --- a/source/MagView.h +++ b/source/MagView.h @@ -11,47 +11,47 @@ struct MagUndoEntry { - uint16 x; - uint16 y; - uint32 c; + uint16 x; + uint16 y; + uint32 c; }; class MagView : public BView { -public: - MagView (BRect frame, const char *name, CanvasView *_myView); -virtual ~MagView (); -virtual void Draw (BRect updateRect); -virtual void MouseDown (BPoint point); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *msg); -virtual void FrameResized (float width, float height); -virtual void AttachedToWindow (); -virtual void Pulse (); - -void setScrollBars (BScrollBar *_h, BScrollBar *_v); -void setzoom (int z); -void setgrid (int g); -bool contains (BPoint p) const; -float currentzoom (); - -bool CanUndo(); -bool CanRedo(); -status_t Undo(); -status_t Redo(); - -private: -void SetupUndo (BPoint p, uint32 c); - -float zoom; -int grid_visible; -BPoint pos; -BScrollBar *mh, *mv; -CanvasView *myView; -MagUndoEntry undo[MAX_MAG_UNDO]; -int32 undoIndex; -int32 redoIndex; -bool mouse_on_canvas; -bool fPicking; + public: + MagView(BRect frame, const char* name, CanvasView* _myView); + virtual ~MagView(); + virtual void Draw(BRect updateRect); + virtual void MouseDown(BPoint point); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg); + virtual void FrameResized(float width, float height); + virtual void AttachedToWindow(); + virtual void Pulse(); + + void setScrollBars(BScrollBar* _h, BScrollBar* _v); + void setzoom(int z); + void setgrid(int g); + bool contains(BPoint p) const; + float currentzoom(); + + bool CanUndo(); + bool CanRedo(); + status_t Undo(); + status_t Redo(); + + private: + void SetupUndo(BPoint p, uint32 c); + + float zoom; + int grid_visible; + BPoint pos; + BScrollBar *mh, *mv; + CanvasView* myView; + MagUndoEntry undo[MAX_MAG_UNDO]; + int32 undoIndex; + int32 redoIndex; + bool mouse_on_canvas; + bool fPicking; }; #endif \ No newline at end of file diff --git a/source/MagWindow.cpp b/source/MagWindow.cpp index 361489c..2c8bb37 100644 --- a/source/MagWindow.cpp +++ b/source/MagWindow.cpp @@ -5,104 +5,107 @@ #include #include -MagWindow::MagWindow (BRect frame, const char *name, CanvasView *_myView) -: BWindow (frame, name, B_DOCUMENT_WINDOW, 0, 0) +MagWindow::MagWindow(BRect frame, const char* name, CanvasView* _myView) + : BWindow(frame, name, B_DOCUMENT_WINDOW, 0, 0) { BRect viewFrame, hFrame, vFrame, menubarFrame; - menubarFrame.Set (0, 0, 0, 0); - menubar = new BMenuBar (menubarFrame, "Magnify Menubar"); - BPopUpMenu *zoomMenu = new BPopUpMenu (""); - zoomMenu->AddItem (new BMenuItem ("1:2", new BMessage ('zm2'))); - zoomMenu->AddItem (new BMenuItem ("1:4", new BMessage ('zm4'))); - zoomMenu->AddItem (new BMenuItem ("1:8", new BMessage ('zm8'))); - zoomMenu->AddItem (new BMenuItem ("1:16", new BMessage ('zm16'))); - zoomMenu->FindItem('zm8')->SetMarked (true); - menubar->AddItem (zoomMenu); - BPopUpMenu *gridMenu = new BPopUpMenu (""); - gridMenu->AddItem (new BMenuItem (lstring (410, "Grid off"), new BMessage ('grd0'))); - gridMenu->AddItem (new BMenuItem (lstring (411, "Grid B"), new BMessage ('grdB'))); - gridMenu->AddItem (new BMenuItem (lstring (412, "Grid W"), new BMessage ('grdW'))); - gridMenu->FindItem('grdB')->SetMarked (true); - menubar->AddItem (gridMenu); - editMenu = new BMenu (lstring (60, "")); - editMenu->AddItem (new BMenuItem (lstring (61, "Undo"), new BMessage (B_UNDO), 'Z')); - editMenu->AddItem (new BMenuItem (lstring (62, "Redo"), new BMessage ('redo'), 'Z', B_SHIFT_KEY)); - menubar->AddItem (editMenu); - AddChild (menubar); + menubarFrame.Set(0, 0, 0, 0); + menubar = new BMenuBar(menubarFrame, "Magnify Menubar"); + BPopUpMenu* zoomMenu = new BPopUpMenu(""); + zoomMenu->AddItem(new BMenuItem("1:2", new BMessage('zm2'))); + zoomMenu->AddItem(new BMenuItem("1:4", new BMessage('zm4'))); + zoomMenu->AddItem(new BMenuItem("1:8", new BMessage('zm8'))); + zoomMenu->AddItem(new BMenuItem("1:16", new BMessage('zm16'))); + zoomMenu->FindItem('zm8')->SetMarked(true); + menubar->AddItem(zoomMenu); + BPopUpMenu* gridMenu = new BPopUpMenu(""); + gridMenu->AddItem(new BMenuItem(lstring(410, "Grid off"), new BMessage('grd0'))); + gridMenu->AddItem(new BMenuItem(lstring(411, "Grid B"), new BMessage('grdB'))); + gridMenu->AddItem(new BMenuItem(lstring(412, "Grid W"), new BMessage('grdW'))); + gridMenu->FindItem('grdB')->SetMarked(true); + menubar->AddItem(gridMenu); + editMenu = new BMenu(lstring(60, "")); + editMenu->AddItem(new BMenuItem(lstring(61, "Undo"), new BMessage(B_UNDO), 'Z')); + editMenu->AddItem(new BMenuItem(lstring(62, "Redo"), new BMessage('redo'), 'Z', B_SHIFT_KEY)); + menubar->AddItem(editMenu); + AddChild(menubar); menubar->ResizeToPreferred(); menubarFrame = menubar->Frame(); menubarheight = menubarFrame.Height(); - viewFrame.Set (0, menubarheight + 1, - frame.Width() - B_V_SCROLL_BAR_WIDTH, - frame.Height() - B_H_SCROLL_BAR_HEIGHT); - magView = new MagView (viewFrame, "Magnify View", _myView); - hFrame.Set (0, frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1, - frame.Width() - B_V_SCROLL_BAR_WIDTH + 1, - frame.Height() + 1); - h = new BScrollBar (hFrame, NULL, magView, 0, 0, B_HORIZONTAL); - vFrame.Set (frame.Width() - B_V_SCROLL_BAR_WIDTH + 1, - menubarFrame.Height(), frame.Width() + 1, - frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1); - v = new BScrollBar (vFrame, NULL, magView, 0, 0, B_VERTICAL); - AddChild (h); - AddChild (v); - magView->setScrollBars (h, v); - AddChild (magView); + viewFrame.Set( + 0, menubarheight + 1, frame.Width() - B_V_SCROLL_BAR_WIDTH, + frame.Height() - B_H_SCROLL_BAR_HEIGHT + ); + magView = new MagView(viewFrame, "Magnify View", _myView); + hFrame.Set( + 0, frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1, frame.Width() - B_V_SCROLL_BAR_WIDTH + 1, + frame.Height() + 1 + ); + h = new BScrollBar(hFrame, NULL, magView, 0, 0, B_HORIZONTAL); + vFrame.Set( + frame.Width() - B_V_SCROLL_BAR_WIDTH + 1, menubarFrame.Height(), frame.Width() + 1, + frame.Height() - B_H_SCROLL_BAR_HEIGHT + 1 + ); + v = new BScrollBar(vFrame, NULL, magView, 0, 0, B_VERTICAL); + AddChild(h); + AddChild(v); + magView->setScrollBars(h, v); + AddChild(magView); myWindow = _myView->Window(); - SetPulseRate (50000); + SetPulseRate(50000); } -MagWindow::~MagWindow () +MagWindow::~MagWindow() { - RemoveChild (h); + RemoveChild(h); delete h; - RemoveChild (v); + RemoveChild(v); delete v; - RemoveChild (menubar); + RemoveChild(menubar); delete menubar; - RemoveChild (magView); + RemoveChild(magView); delete magView; } -void MagWindow::MenusBeginning () +void +MagWindow::MenusBeginning() { - if (magView) - { - editMenu->FindItem (B_UNDO)->SetEnabled (magView->CanUndo()); - editMenu->FindItem ('redo')->SetEnabled (magView->CanRedo()); + if (magView) { + editMenu->FindItem(B_UNDO)->SetEnabled(magView->CanUndo()); + editMenu->FindItem('redo')->SetEnabled(magView->CanRedo()); } } -void MagWindow::MessageReceived (BMessage *msg) +void +MagWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'zm2': - magView->setzoom (2); + magView->setzoom(2); break; case 'zm4': - magView->setzoom (4); + magView->setzoom(4); break; case 'zm8': - magView->setzoom (8); + magView->setzoom(8); break; case 'zm16': - magView->setzoom (16); + magView->setzoom(16); break; case 'grd0': - magView->setgrid (0); + magView->setgrid(0); break; case 'grdB': - magView->setgrid (1); + magView->setgrid(1); break; case 'grdW': - magView->setgrid (2); + magView->setgrid(2); break; case 'draw': - magView->Invalidate (); + magView->Invalidate(); break; case 'magO': - Show (); + Show(); break; case B_UNDO: magView->Undo(); @@ -111,18 +114,20 @@ void MagWindow::MessageReceived (BMessage *msg) magView->Redo(); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } -bool MagWindow::QuitRequested () +bool +MagWindow::QuitRequested() { - myWindow->PostMessage ('magQ'); + myWindow->PostMessage('magQ'); return false; } -float MagWindow::menubarHeight () +float +MagWindow::menubarHeight() { return menubarheight; } \ No newline at end of file diff --git a/source/MagWindow.h b/source/MagWindow.h index 8984b35..e1d5ed9 100644 --- a/source/MagWindow.h +++ b/source/MagWindow.h @@ -11,24 +11,25 @@ class MagWindow : public BWindow { -friend class CanvasView; -public: - MagWindow (BRect frame, const char *name, CanvasView *_MyView); -virtual ~MagWindow (); -virtual void MessageReceived (BMessage *msg); -virtual bool QuitRequested (); -virtual void MenusBeginning (); + friend class CanvasView; -float menubarHeight (); + public: + MagWindow(BRect frame, const char* name, CanvasView* _MyView); + virtual ~MagWindow(); + virtual void MessageReceived(BMessage* msg); + virtual bool QuitRequested(); + virtual void MenusBeginning(); -private: -typedef BWindow inherited; -MagView *magView; -BScrollBar *h, *v; -BMenuBar *menubar; -BMenu *editMenu; -BWindow *myWindow; -float menubarheight; + float menubarHeight(); + + private: + typedef BWindow inherited; + MagView* magView; + BScrollBar *h, *v; + BMenuBar* menubar; + BMenu* editMenu; + BWindow* myWindow; + float menubarheight; }; #endif diff --git a/source/MainWindow.cpp b/source/MainWindow.cpp index 0a831b2..331721b 100644 --- a/source/MainWindow.cpp +++ b/source/MainWindow.cpp @@ -33,1537 +33,1278 @@ ////////////////////////////// #if __POWERPC__ -# pragma optimization_level 1 +#pragma optimization_level 1 #endif PicMenuButton *mode, *tool; ColorMenuButton *hicolor, *locolor; -PatternMenuButton *pat; -HelpView *help; +PatternMenuButton* pat; +HelpView* help; -AttribWindow *mAttribWindow; -AttribDraw *mAttribDraw; -AttribSelect *mAttribSelect; +AttribWindow* mAttribWindow; +AttribDraw* mAttribDraw; +AttribSelect* mAttribSelect; -AttribWindow *tAttribWindow; -AttribBrush *tAttribBrush; -AttribEraser *tAttribEraser; -AttribText *tAttribText; -AttribSpraycan *tAttribSpraycan; -AttribClone *tAttribClone; -AttribFill *tAttribFill; -AttribFreehand *tAttribFreehand; -AttribLines *tAttribLines; -AttribPolyblob *tAttribPolyblob; -AttribPolygon *tAttribPolygon; -AttribRect *tAttribRect; -AttribRoundRect *tAttribRoundRect; -AttribCircle *tAttribCircle; -AttribEllipse *tAttribEllipse; +AttribWindow* tAttribWindow; +AttribBrush* tAttribBrush; +AttribEraser* tAttribEraser; +AttribText* tAttribText; +AttribSpraycan* tAttribSpraycan; +AttribClone* tAttribClone; +AttribFill* tAttribFill; +AttribFreehand* tAttribFreehand; +AttribLines* tAttribLines; +AttribPolyblob* tAttribPolyblob; +AttribPolygon* tAttribPolygon; +AttribRect* tAttribRect; +AttribRoundRect* tAttribRoundRect; +AttribCircle* tAttribCircle; +AttribEllipse* tAttribEllipse; -MainWindow::MainWindow (const BRect frame, const char *name) -: BWindow (frame, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK) +MainWindow::MainWindow(const BRect frame, const char* name) + : BWindow( + frame, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK + ) { - BBitmap *butbit[BUT_ARRAY]; + BBitmap* butbit[BUT_ARRAY]; for (int i = 0; i < BUT_ARRAY; i++) - butbit[i] = new BBitmap (BRect (0, 0, 31, 31), B_COLOR_8_BIT); - uchar butdata[BUT_ARRAY][1024] = - { - { // Draw - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF,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, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x05, 0x05, 0x10, 0x10, 0x00, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x10, 0x10, 0x05, - 0x05, 0x10, 0x10, 0x05, 0x05, 0x10, 0x10, 0x05, 0x05, 0x10, 0x10, 0x05, - 0x05, 0x10, 0x10, 0x05, 0x05, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x00, 0x05, 0x05, 0x10, 0x10, 0x05, 0x05, 0x10, 0x10, - 0x05, 0x05, 0x10, 0x10, 0x05, 0x05, 0x10, 0x10, 0x05, 0x05, 0x10, 0x10, - 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x10, - 0x10, 0x05, 0x05, 0x10, 0x10, 0x05, 0x05, 0x10, 0x10, 0x05, 0x05, 0x10, - 0x10, 0x05, 0x05, 0x10, 0x10, 0x05, 0x05, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,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FF, 0x08, 0x00, 0x08, 0x14, 0x14, 0x14, 0x14, 0x14, 0x08, 0x00, 0x08, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x08, 0x00, 0x08, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x08, 0x00, + 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x08, 0x00, 0x08, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x08, 0x00, 0x08, 0x3F, 0x3F, 0x08, 0x00, 0x08, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x00, 0x00, 0x14, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x08, 0x00, 0x08, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x08, 0x00, 0x08, 0x14, 0x14, + 0x14, 0x14, 0x00, 0x00, 0x14, 0x14, 0x09, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0x08, 0x00, 0x08, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x08, + 0x00, 0x14, 0x00, 0x00, 0x14, 0x14, 0x14, 0x14, 0x08, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x00, 0x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0x1E, + 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0x00, 0x10, 0x10, 0x05, 0x05, 0x10, 0x10, 0x0D, 0x17, 0x19, 0x1E, 0x1E, + 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x05, 0x05, 0x10, 0x10, 0x05, 0x05, 0x10, 0x1E, 0x1E, 0x1E, + 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x10, 0x10, 0x05, 0x05, 0x10, 0x10, 0x05, 0x05, 0x10, + 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x00, 0x05, 0x10, 0x10, 0x05, 0x05, + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x05, 0x05, 0x10, + 0x10, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x10, 0x10, 0x05, + 0x05, 0x10, 0x10, 0x05, 0x05, 0x10, 0x10, 0x05, 0x05, 0x10, 0x10, 0x05, 0x05, 0x10, 0x10, + 0x05, 0x05, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x05, 0x05, + 0x10, 0x10, 0x05, 0x05,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ToolButtons", B_FOLLOW_NONE, (uint32) NULL); - AddChild (button); - button->SetViewColor (B_TRANSPARENT_32_BIT); - button->SetDrawingMode (B_OP_OVER); - butbit[0]->SetBits (butdata[0], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Draw - button->DrawBitmap (butbit[0], B_ORIGIN); - buttons[0] = button->EndPicture (); - butbit[1]->SetBits (butdata[1], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Select - button->DrawBitmap (butbit[1], B_ORIGIN); - buttons[1] = button->EndPicture (); - butbit[2]->SetBits (butdata[2], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Brush - button->DrawBitmap (butbit[2], B_ORIGIN); - buttons[2] = button->EndPicture (); - butbit[3]->SetBits (butdata[3], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Eraser - button->DrawBitmap (butbit[3], B_ORIGIN); - buttons[3] = button->EndPicture (); - butbit[4]->SetBits (butdata[4], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Fill - button->DrawBitmap (butbit[4], B_ORIGIN); - buttons[4] = button->EndPicture (); - butbit[5]->SetBits (butdata[5], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Text - button->DrawBitmap (butbit[5], B_ORIGIN); - buttons[5] = button->EndPicture (); - butbit[6]->SetBits (butdata[6], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Spraycan - button->DrawBitmap (butbit[6], B_ORIGIN); - buttons[6] = button->EndPicture (); - butbit[7]->SetBits (butdata[7], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Clone - button->DrawBitmap (butbit[7], B_ORIGIN); - buttons[7] = button->EndPicture (); - butbit[8]->SetBits (butdata[8], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Freehand - button->DrawBitmap (butbit[8], B_ORIGIN); - buttons[8] = button->EndPicture (); - butbit[9]->SetBits (butdata[9], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Lines - button->DrawBitmap (butbit[9], B_ORIGIN); - buttons[9] = button->EndPicture (); - butbit[10]->SetBits (butdata[10], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Polyblob (Free Shape) - button->DrawBitmap (butbit[10], B_ORIGIN); - buttons[10] = button->EndPicture (); - butbit[11]->SetBits (butdata[11], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Polygon - button->DrawBitmap (butbit[11], B_ORIGIN); - buttons[11] = button->EndPicture (); - butbit[12]->SetBits (butdata[12], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Rect - button->DrawBitmap (butbit[12], B_ORIGIN); - buttons[12] = button->EndPicture (); - butbit[13]->SetBits (butdata[13], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Round Rect - button->DrawBitmap (butbit[13], B_ORIGIN); - buttons[13] = button->EndPicture (); - butbit[14]->SetBits (butdata[14], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Circle - button->DrawBitmap (butbit[14], B_ORIGIN); - buttons[14] = button->EndPicture (); - butbit[15]->SetBits (butdata[15], 1024, 0, B_COLOR_8_BIT); - button->BeginPicture (new BPicture); // Ellipse - button->DrawBitmap (butbit[15], B_ORIGIN); - buttons[15] = button->EndPicture (); - RemoveChild (button); + BRect butrect = BRect(0, 0, BUTTON_SIZE, BUTTON_SIZE); + BView* button = new BView(butrect, "ToolButtons", B_FOLLOW_NONE, (uint32)NULL); + AddChild(button); + button->SetViewColor(B_TRANSPARENT_32_BIT); + button->SetDrawingMode(B_OP_OVER); + butbit[0]->SetBits(butdata[0], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Draw + button->DrawBitmap(butbit[0], B_ORIGIN); + buttons[0] = button->EndPicture(); + butbit[1]->SetBits(butdata[1], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Select + button->DrawBitmap(butbit[1], B_ORIGIN); + buttons[1] = button->EndPicture(); + butbit[2]->SetBits(butdata[2], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Brush + button->DrawBitmap(butbit[2], B_ORIGIN); + buttons[2] = button->EndPicture(); + butbit[3]->SetBits(butdata[3], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Eraser + button->DrawBitmap(butbit[3], B_ORIGIN); + buttons[3] = button->EndPicture(); + butbit[4]->SetBits(butdata[4], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Fill + button->DrawBitmap(butbit[4], B_ORIGIN); + buttons[4] = button->EndPicture(); + butbit[5]->SetBits(butdata[5], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Text + button->DrawBitmap(butbit[5], B_ORIGIN); + buttons[5] = button->EndPicture(); + butbit[6]->SetBits(butdata[6], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Spraycan + button->DrawBitmap(butbit[6], B_ORIGIN); + buttons[6] = button->EndPicture(); + butbit[7]->SetBits(butdata[7], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Clone + button->DrawBitmap(butbit[7], B_ORIGIN); + buttons[7] = button->EndPicture(); + butbit[8]->SetBits(butdata[8], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Freehand + button->DrawBitmap(butbit[8], B_ORIGIN); + buttons[8] = button->EndPicture(); + butbit[9]->SetBits(butdata[9], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Lines + button->DrawBitmap(butbit[9], B_ORIGIN); + buttons[9] = button->EndPicture(); + butbit[10]->SetBits(butdata[10], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Polyblob (Free Shape) + button->DrawBitmap(butbit[10], B_ORIGIN); + buttons[10] = button->EndPicture(); + butbit[11]->SetBits(butdata[11], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Polygon + button->DrawBitmap(butbit[11], B_ORIGIN); + buttons[11] = button->EndPicture(); + butbit[12]->SetBits(butdata[12], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Rect + button->DrawBitmap(butbit[12], B_ORIGIN); + buttons[12] = button->EndPicture(); + butbit[13]->SetBits(butdata[13], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Round Rect + button->DrawBitmap(butbit[13], B_ORIGIN); + buttons[13] = button->EndPicture(); + butbit[14]->SetBits(butdata[14], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Circle + button->DrawBitmap(butbit[14], B_ORIGIN); + buttons[14] = button->EndPicture(); + butbit[15]->SetBits(butdata[15], 1024, 0, B_COLOR_8_BIT); + button->BeginPicture(new BPicture); // Ellipse + button->DrawBitmap(butbit[15], B_ORIGIN); + buttons[15] = button->EndPicture(); + RemoveChild(button); // Do not delete the butbit bitmaps. They are passed as BitmapView icons, // and become the responsibility of those views. - + BRect menubarFrame, helpFrame, modeFrame, toolFrame, hiFrame, loFrame, patFrame; - menubarFrame.Set (0, 0, 64, 0); - menubar = new BMenuBar (menubarFrame, "MainMenubar", B_FOLLOW_LEFT | B_FOLLOW_TOP); - BMenu *fileMenu = new BMenu (lstring (10, "File")); - BMenuItem *item = new BMenuItem (lstring (11, "New Canvas…"), new BMessage ('newc'), 'N'); - item->SetTarget (be_app); - fileMenu->AddItem (item); -// item = new BMenuItem (lstring (12, "Open File…"), new BMessage ('open'), 'O'); -// item->SetTarget (be_app); + menubarFrame.Set(0, 0, 64, 0); + menubar = new BMenuBar(menubarFrame, "MainMenubar", B_FOLLOW_LEFT | B_FOLLOW_TOP); + BMenu* fileMenu = new BMenu(lstring(10, "File")); + BMenuItem* item = new BMenuItem(lstring(11, "New Canvas…"), new BMessage('newc'), 'N'); + item->SetTarget(be_app); + fileMenu->AddItem(item); + // item = new BMenuItem (lstring (12, "Open File…"), new BMessage ('open'), 'O'); + // item->SetTarget (be_app); item = make_recent_menu(); - fileMenu->AddItem (item); - BMenu *captureMenu = new BMenu (lstring (14, "Capture")); - captureMenu->SetEnabled (false); - fileMenu->AddItem (captureMenu); - extern BList *AddOns; - AddOn *addon; - for (long i = 0; addon = (AddOn *) AddOns->ItemAt (i), addon; i++) - { - switch (addon->Type()) - { - case BECASSO_CAPTURE: - { - BMessage *ms = new BMessage ('capt'); - ms->AddInt32 ("index", i); - BMenuItem *it = new BMenuItem (addon->Name(), ms); - it->SetTarget (be_app); - captureMenu->AddItem (it); - captureMenu->SetEnabled (true); + fileMenu->AddItem(item); + BMenu* captureMenu = new BMenu(lstring(14, "Capture")); + captureMenu->SetEnabled(false); + fileMenu->AddItem(captureMenu); + extern BList* AddOns; + AddOn* addon; + for (long i = 0; addon = (AddOn*)AddOns->ItemAt(i), addon; i++) { + switch (addon->Type()) { + case BECASSO_CAPTURE: { + BMessage* ms = new BMessage('capt'); + ms->AddInt32("index", i); + BMenuItem* it = new BMenuItem(addon->Name(), ms); + it->SetTarget(be_app); + captureMenu->AddItem(it); + captureMenu->SetEnabled(true); break; } default: @@ -1571,251 +1312,322 @@ MainWindow::MainWindow (const BRect frame, const char *name) } } fileMenu->AddSeparatorItem(); - item = new BMenuItem (lstring (15, "Print Setup…"), new BMessage ('PrSU')); - item->SetTarget (be_app); - fileMenu->AddItem (item); + item = new BMenuItem(lstring(15, "Print Setup…"), new BMessage('PrSU')); + item->SetTarget(be_app); + fileMenu->AddItem(item); fileMenu->AddSeparatorItem(); - item = new BMenuItem (lstring (16, "About Becasso"), new BMessage (B_ABOUT_REQUESTED)); - item->SetTarget (be_app); - fileMenu->AddItem (item); + item = new BMenuItem(lstring(16, "About Becasso"), new BMessage(B_ABOUT_REQUESTED)); + item->SetTarget(be_app); + fileMenu->AddItem(item); extern int gGlobalAlpha; - if (!gGlobalAlpha) - { - item = new BMenuItem (lstring (9, "Register online"), new BMessage ('rgsr')); - fileMenu->AddItem (item); + if (!gGlobalAlpha) { + item = new BMenuItem(lstring(9, "Register online"), new BMessage('rgsr')); + fileMenu->AddItem(item); } fileMenu->AddSeparatorItem(); - item = new BMenuItem (lstring (18, "Preferences…"), new BMessage ('prfs')); - item->SetTarget (be_app); - fileMenu->AddItem (item); + item = new BMenuItem(lstring(18, "Preferences…"), new BMessage('prfs')); + item->SetTarget(be_app); + fileMenu->AddItem(item); fileMenu->AddSeparatorItem(); - item = new BMenuItem (lstring (17, "Quit Becasso"), new BMessage (B_QUIT_REQUESTED), 'Q'); - item->SetTarget (be_app); - fileMenu->AddItem (item); - menubar->AddItem (fileMenu); - AddChild (menubar); + item = new BMenuItem(lstring(17, "Quit Becasso"), new BMessage(B_QUIT_REQUESTED), 'Q'); + item->SetTarget(be_app); + fileMenu->AddItem(item); + menubar->AddItem(fileMenu); + AddChild(menubar); menubar->ResizeToPreferred(); menubarFrame = menubar->Frame(); - ResizeTo (NUM_BUTTONS * BUTTON_SIZE, BUTTON_SIZE + menubarFrame.Height()); - helpFrame.Set (menubarFrame.Width() + 1, 0, Bounds().Width(), menubarFrame.Height()); - help = new HelpView (helpFrame, "Help"); - help->setText ("Becasso"); - AddChild (help); + ResizeTo(NUM_BUTTONS * BUTTON_SIZE, BUTTON_SIZE + menubarFrame.Height()); + helpFrame.Set(menubarFrame.Width() + 1, 0, Bounds().Width(), menubarFrame.Height()); + help = new HelpView(helpFrame, "Help"); + help->setText("Becasso"); + AddChild(help); - modeFrame.Set (0, menubarFrame.Height() + 1, BUTTON_SIZE, menubarFrame.Height() + BUTTON_SIZE); + modeFrame.Set(0, menubarFrame.Height() + 1, BUTTON_SIZE, menubarFrame.Height() + BUTTON_SIZE); toolFrame = hiFrame = loFrame = patFrame = modeFrame; - toolFrame.OffsetBy (BUTTON_SIZE, 0); - hiFrame.OffsetBy (2*BUTTON_SIZE, 0); - loFrame.OffsetBy (3*BUTTON_SIZE, 0); - patFrame.OffsetBy (4*BUTTON_SIZE, 0); + toolFrame.OffsetBy(BUTTON_SIZE, 0); + hiFrame.OffsetBy(2 * BUTTON_SIZE, 0); + loFrame.OffsetBy(3 * BUTTON_SIZE, 0); + patFrame.OffsetBy(4 * BUTTON_SIZE, 0); - mode = new PicMenuButton (modeFrame, lstring (19, "Mode"), buttons[0]); - PicMenu *modePU = new PicMenu ("modePU", mode, 1, 2, BUTTON_SIZE); - BRect mRect (116, 196, 216, 296); - BRect tRect (100, 180, 200, 280); - BPoint mOrigin = get_window_origin (numModeWindow); - BPoint tOrigin = get_window_origin (numAttribWindow); + mode = new PicMenuButton(modeFrame, lstring(19, "Mode"), buttons[0]); + PicMenu* modePU = new PicMenu("modePU", mode, 1, 2, BUTTON_SIZE); + BRect mRect(116, 196, 216, 296); + BRect tRect(100, 180, 200, 280); + BPoint mOrigin = get_window_origin(numModeWindow); + BPoint tOrigin = get_window_origin(numAttribWindow); if (mOrigin != InvalidPoint) - mRect.OffsetTo (mOrigin); + mRect.OffsetTo(mOrigin); if (tOrigin != InvalidPoint) - tRect.OffsetTo (tOrigin); - mAttribWindow = new AttribWindow (mRect, "Mode"); - tAttribWindow = new AttribWindow (tRect, "Attribs"); + tRect.OffsetTo(tOrigin); + mAttribWindow = new AttribWindow(mRect, "Mode"); + tAttribWindow = new AttribWindow(tRect, "Attribs"); mAttribDraw = new AttribDraw(); - mAttribWindow->AddView (mAttribDraw, butbit[0]); - PicItem *pitem = new PicItem (buttons[0], mAttribDraw, mAttribWindow, lstring (20, "Draw")); - pitem->SetMarked (true); - modePU->AddItem (pitem, BRect (0, 0, BUTTON_SIZE - 1, BUTTON_SIZE - 1)); + mAttribWindow->AddView(mAttribDraw, butbit[0]); + PicItem* pitem = new PicItem(buttons[0], mAttribDraw, mAttribWindow, lstring(20, "Draw")); + pitem->SetMarked(true); + modePU->AddItem(pitem, BRect(0, 0, BUTTON_SIZE - 1, BUTTON_SIZE - 1)); mAttribSelect = new AttribSelect(); - mAttribWindow->AddView (mAttribSelect, butbit[1]); - modePU->AddItem (new PicItem (buttons[1], mAttribSelect, mAttribWindow, lstring (21, "Select")), BRect (0, BUTTON_SIZE, BUTTON_SIZE - 1, 2*BUTTON_SIZE - 1)); - mode->AddItem (modePU); - AddChild (mode); + mAttribWindow->AddView(mAttribSelect, butbit[1]); + modePU->AddItem( + new PicItem(buttons[1], mAttribSelect, mAttribWindow, lstring(21, "Select")), + BRect(0, BUTTON_SIZE, BUTTON_SIZE - 1, 2 * BUTTON_SIZE - 1) + ); + mode->AddItem(modePU); + AddChild(mode); - tool = new PicMenuButton (toolFrame, lstring (40, "Tool"), buttons[2]); - PicMenu *toolPU = new PicMenu ("toolPU", tool, 2, NumTools/2, BUTTON_SIZE); - BRect cframe (0, 0, BUTTON_SIZE - 1, BUTTON_SIZE - 1); + tool = new PicMenuButton(toolFrame, lstring(40, "Tool"), buttons[2]); + PicMenu* toolPU = new PicMenu("toolPU", tool, 2, NumTools / 2, BUTTON_SIZE); + BRect cframe(0, 0, BUTTON_SIZE - 1, BUTTON_SIZE - 1); int counter = 0; tAttribBrush = new AttribBrush(); - tAttribWindow->AddView (tAttribBrush, butbit[2]); - pitem = new PicItem (buttons[2], tAttribBrush, tAttribWindow, lstring (22, "Brush")); - pitem->SetMarked (true); - toolPU->AddItem (pitem, cframe); + tAttribWindow->AddView(tAttribBrush, butbit[2]); + pitem = new PicItem(buttons[2], tAttribBrush, tAttribWindow, lstring(22, "Brush")); + pitem->SetMarked(true); + toolPU->AddItem(pitem, cframe); tAttribEraser = new AttribEraser(); - tAttribWindow->AddView (tAttribEraser, butbit[3]); + tAttribWindow->AddView(tAttribEraser, butbit[3]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[3], tAttribEraser, tAttribWindow, lstring (23, "Eraser")), cframe); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[3], tAttribEraser, tAttribWindow, lstring(23, "Eraser")), cframe + ); tAttribFill = new AttribFill(); - tAttribWindow->AddView (tAttribFill, butbit[4]); + tAttribWindow->AddView(tAttribFill, butbit[4]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[4], tAttribFill, tAttribWindow, lstring (24, "Fill")), cframe); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[4], tAttribFill, tAttribWindow, lstring(24, "Fill")), cframe + ); tAttribText = new AttribText(); - tAttribWindow->AddView (tAttribText, butbit[5]); + tAttribWindow->AddView(tAttribText, butbit[5]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[5], tAttribText, tAttribWindow, lstring (25, "Text")), cframe); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[5], tAttribText, tAttribWindow, lstring(25, "Text")), cframe + ); tAttribSpraycan = new AttribSpraycan(); - tAttribWindow->AddView (tAttribSpraycan, butbit[6]); + tAttribWindow->AddView(tAttribSpraycan, butbit[6]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[6], tAttribSpraycan, tAttribWindow, lstring (26, "Spray Can")), cframe); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[6], tAttribSpraycan, tAttribWindow, lstring(26, "Spray Can")), cframe + ); tAttribClone = new AttribClone(); - tAttribWindow->AddView (tAttribClone, butbit[7]); + tAttribWindow->AddView(tAttribClone, butbit[7]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[7], tAttribBrush, tAttribWindow, lstring (35, "Clone")), cframe); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[7], tAttribBrush, tAttribWindow, lstring(35, "Clone")), cframe + ); tAttribFreehand = new AttribFreehand(); - tAttribWindow->AddView (tAttribFreehand, butbit[8]); + tAttribWindow->AddView(tAttribFreehand, butbit[8]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[8], tAttribFreehand, tAttribWindow, lstring (27, "Freehand")), cframe); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[8], tAttribFreehand, tAttribWindow, lstring(27, "Freehand")), cframe + ); tAttribLines = new AttribLines(); - tAttribWindow->AddView (tAttribLines, butbit[9]); + tAttribWindow->AddView(tAttribLines, butbit[9]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[9], tAttribLines, tAttribWindow, lstring (28, "Lines")), cframe); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[9], tAttribLines, tAttribWindow, lstring(28, "Lines")), cframe + ); tAttribPolyblob = new AttribPolyblob(); - tAttribWindow->AddView (tAttribPolyblob, butbit[10]); + tAttribWindow->AddView(tAttribPolyblob, butbit[10]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[10], tAttribPolyblob, tAttribWindow, lstring (29, "Free Shapes")), cframe); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[10], tAttribPolyblob, tAttribWindow, lstring(29, "Free Shapes")), cframe + ); tAttribPolygon = new AttribPolygon(); - tAttribWindow->AddView (tAttribPolygon, butbit[11]); + tAttribWindow->AddView(tAttribPolygon, butbit[11]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[11], tAttribPolygon, tAttribWindow, lstring (30, "Polygons")), cframe); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[11], tAttribPolygon, tAttribWindow, lstring(30, "Polygons")), cframe + ); tAttribRect = new AttribRect(); - tAttribWindow->AddView (tAttribRect, butbit[12]); + tAttribWindow->AddView(tAttribRect, butbit[12]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[12], tAttribRect, tAttribWindow, lstring (31, "Rectangles")), cframe); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[12], tAttribRect, tAttribWindow, lstring(31, "Rectangles")), cframe + ); tAttribRoundRect = new AttribRoundRect(); - tAttribWindow->AddView (tAttribRoundRect, butbit[13]); + tAttribWindow->AddView(tAttribRoundRect, butbit[13]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[13], tAttribRoundRect, tAttribWindow, lstring (32, "Ovals")), cframe); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[13], tAttribRoundRect, tAttribWindow, lstring(32, "Ovals")), cframe + ); tAttribCircle = new AttribCircle(); - tAttribWindow->AddView (tAttribCircle, butbit[14]); + tAttribWindow->AddView(tAttribCircle, butbit[14]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[14], tAttribCircle, tAttribWindow, lstring (33, "Circles")), cframe); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[14], tAttribCircle, tAttribWindow, lstring(33, "Circles")), cframe + ); tAttribEllipse = new AttribEllipse(); - tAttribWindow->AddView (tAttribEllipse, butbit[15]); + tAttribWindow->AddView(tAttribEllipse, butbit[15]); counter++; - cframe.Set (counter & 1 ? BUTTON_SIZE : 0, (counter/2)*BUTTON_SIZE, counter & 1 ? 2*BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter/2 + 1)*BUTTON_SIZE - 1); - toolPU->AddItem (new PicItem (buttons[15], tAttribEllipse, tAttribWindow, lstring (34, "Ellipses")), cframe); - tool->AddItem (toolPU); + cframe.Set( + counter & 1 ? BUTTON_SIZE : 0, (counter / 2) * BUTTON_SIZE, + counter & 1 ? 2 * BUTTON_SIZE - 1 : BUTTON_SIZE - 1, (counter / 2 + 1) * BUTTON_SIZE - 1 + ); + toolPU->AddItem( + new PicItem(buttons[15], tAttribEllipse, tAttribWindow, lstring(34, "Ellipses")), cframe + ); + tool->AddItem(toolPU); mAttribWindow->Run(); tAttribWindow->Run(); - mAttribWindow->RaiseView (0); - tAttribWindow->RaiseView (0); + mAttribWindow->RaiseView(0); + tAttribWindow->RaiseView(0); if (mOrigin != InvalidPoint) mAttribWindow->Show(); if (tOrigin != InvalidPoint) tAttribWindow->Show(); - AddChild (tool); - hicolor = new ColorMenuButton ("fg", hiFrame, lstring (41, "Foreground Color")); - AddChild (hicolor); - locolor = new ColorMenuButton ("bg", loFrame, lstring (42, "Background Color")); - locolor->set (63); - AddChild (locolor); - pat = new PatternMenuButton (patFrame, lstring (43, "Pattern")); - pat->set (0); - AddChild (pat); -// printf ("MainWindow::ctor done\n"); + AddChild(tool); + hicolor = new ColorMenuButton("fg", hiFrame, lstring(41, "Foreground Color")); + AddChild(hicolor); + locolor = new ColorMenuButton("bg", loFrame, lstring(42, "Background Color")); + locolor->set(63); + AddChild(locolor); + pat = new PatternMenuButton(patFrame, lstring(43, "Pattern")); + pat->set(0); + AddChild(pat); + // printf ("MainWindow::ctor done\n"); } -MainWindow::~MainWindow () +MainWindow::~MainWindow() { -/* - RemoveChild (menubar); - delete menubar; - RemoveChild (mode); - delete mode; - RemoveChild (tool); - delete tool; - RemoveChild (hicolor); - delete hicolor; - RemoveChild (locolor); - delete locolor; - RemoveChild (pat); - delete pat; - RemoveChild (help); - delete help; -*/ + /* + RemoveChild (menubar); + delete menubar; + RemoveChild (mode); + delete mode; + RemoveChild (tool); + delete tool; + RemoveChild (hicolor); + delete hicolor; + RemoveChild (locolor); + delete locolor; + RemoveChild (pat); + delete pat; + RemoveChild (help); + delete help; + */ BPoint origin = B_ORIGIN; - ConvertToScreen (&origin); - set_window_origin (0, origin); + ConvertToScreen(&origin); + set_window_origin(0, origin); } -void MainWindow::MenusBeginning () +void +MainWindow::MenusBeginning() { } -void MainWindow::RefsReceived (BMessage *message) +void +MainWindow::RefsReceived(BMessage* message) { -// printf ("MainWindow::RefsReceived\n"); - be_app->RefsReceived (message); + // printf ("MainWindow::RefsReceived\n"); + be_app->RefsReceived(message); } -bool MainWindow::QuitRequested () +bool +MainWindow::QuitRequested() { - be_app->PostMessage (B_QUIT_REQUESTED); + be_app->PostMessage(B_QUIT_REQUESTED); return (false); } -BHandler *MainWindow::ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property) +BHandler* +MainWindow::ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property +) { -// printf ("\nmessage:\n"); -// message->PrintToStream(); -// printf ("specifier:\n"); -// specifier->PrintToStream(); + // printf ("\nmessage:\n"); + // message->PrintToStream(); + // printf ("specifier:\n"); + // specifier->PrintToStream(); - return inherited::ResolveSpecifier (message, index, specifier, command, property); + return inherited::ResolveSpecifier(message, index, specifier, command, property); } - -void MainWindow::MessageReceived (BMessage *message) +void +MainWindow::MessageReceived(BMessage* message) { -// printf ("MainWindow::MessageReceived\n"); - switch (message->what) - { + // printf ("MainWindow::MessageReceived\n"); + switch (message->what) { case 'chlp': -// printf ("Help message received.\n"); + // printf ("Help message received.\n"); // Hmmm. This message is sometimes not delivered, it seems. - help->setText (message->FindString ("View")); + help->setText(message->FindString("View")); help->Invalidate(); break; case B_SIMPLE_DATA: - be_app->PostMessage (message); + be_app->PostMessage(message); break; - case 0: // Unbelievable, but this is the message you get when - be_app->PostMessage (message); // dropping an icon from FileTypes. + case 0: // Unbelievable, but this is the message you get when + be_app->PostMessage(message); // dropping an icon from FileTypes. break; - case 'PPNT': // RRaster drop. - be_app->PostMessage (message); + case 'PPNT': // RRaster drop. + be_app->PostMessage(message); break; - case 'fixC': - { + case 'fixC': { BPoint pt; - BView *aView = ChildAt (0); + BView* aView = ChildAt(0); uint32 buttons; - aView->GetMouse (&pt, &buttons); - aView->ConvertToScreen (&pt); - set_mouse_position (int (pt.x + .5), int (pt.y + .5)); + aView->GetMouse(&pt, &buttons); + aView->ConvertToScreen(&pt); + set_mouse_position(int(pt.x + .5), int(pt.y + .5)); break; } case 'open': - be_app->MessageReceived (message); + be_app->MessageReceived(message); break; case 'rgsr': - system ("NetPositive http://www.sumware.demon.nl/products/becasso/register.html &"); + system("NetPositive http://www.sumware.demon.nl/products/becasso/register.html &"); break; default: - inherited::MessageReceived (message); + inherited::MessageReceived(message); } } \ No newline at end of file diff --git a/source/MainWindow.h b/source/MainWindow.h index 9c7f74a..a18c455 100644 --- a/source/MainWindow.h +++ b/source/MainWindow.h @@ -16,19 +16,21 @@ class MainWindow : public BWindow { -public: - MainWindow (const BRect frame, const char *name); -virtual ~MainWindow (); -virtual bool QuitRequested (); -virtual void RefsReceived (BMessage *message); -virtual void MenusBeginning (); -virtual BHandler *ResolveSpecifier (BMessage *message, int32 index, BMessage *specifier, int32 command, const char *property); -virtual void MessageReceived (BMessage *message); + public: + MainWindow(const BRect frame, const char* name); + virtual ~MainWindow(); + virtual bool QuitRequested(); + virtual void RefsReceived(BMessage* message); + virtual void MenusBeginning(); + virtual BHandler* ResolveSpecifier( + BMessage* message, int32 index, BMessage* specifier, int32 command, const char* property + ); + virtual void MessageReceived(BMessage* message); -private: -typedef BWindow inherited; -BMenuBar *menubar; -BPicture *buttons[BUT_ARRAY]; + private: + typedef BWindow inherited; + BMenuBar* menubar; + BPicture* buttons[BUT_ARRAY]; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/MetaLayer.cpp b/source/MetaLayer.cpp index 94aa58c..141d75a 100644 --- a/source/MetaLayer.cpp +++ b/source/MetaLayer.cpp @@ -1,10 +1,5 @@ #include "MetaLayer.h" -MetaLayer::MetaLayer (BRect bounds, const char *name, int type) -: Layer (bounds, name), fType (type) -{ -} +MetaLayer::MetaLayer(BRect bounds, const char* name, int type) : Layer(bounds, name), fType(type) {} -MetaLayer::~MetaLayer () -{ -} \ No newline at end of file +MetaLayer::~MetaLayer() {} \ No newline at end of file diff --git a/source/MetaLayer.h b/source/MetaLayer.h index e08122d..e92fe23 100644 --- a/source/MetaLayer.h +++ b/source/MetaLayer.h @@ -1,14 +1,14 @@ #include "Layer.h" -#define BITMAP_LAYER 0 -#define TEXT_LAYER 1 +#define BITMAP_LAYER 0 +#define TEXT_LAYER 1 class MetaLayer : public Layer { -public: - MetaLayer (BRect bounds, const char *name, int type = BITMAP_LAYER); -virtual ~MetaLayer (); + public: + MetaLayer(BRect bounds, const char* name, int type = BITMAP_LAYER); + virtual ~MetaLayer(); -private: -int fType; + private: + int fType; }; \ No newline at end of file diff --git a/source/Modes.h b/source/Modes.h index 090ec9d..45ad594 100644 --- a/source/Modes.h +++ b/source/Modes.h @@ -3,12 +3,12 @@ #ifndef _MODES_H #define _MODES_H -#define M_DRAW 0 -#define M_SELECT 1 -#define M_DRAW_SELECT 2 -#define M_DRAG 3 -#define M_MERGE 4 -#define M_DELLAYER 5 -#define M_RESIZE 6 +#define M_DRAW 0 +#define M_SELECT 1 +#define M_DRAW_SELECT 2 +#define M_DRAG 3 +#define M_MERGE 4 +#define M_DELLAYER 5 +#define M_RESIZE 6 #endif diff --git a/source/NagWindow.cpp b/source/NagWindow.cpp index b64d606..61378ce 100644 --- a/source/NagWindow.cpp +++ b/source/NagWindow.cpp @@ -14,48 +14,49 @@ #define NAG_TIME 15 -NagWindow::NagWindow (BRect frame) -: BWindow (frame, "", B_MODAL_WINDOW, B_NOT_RESIZABLE) +NagWindow::NagWindow(BRect frame) : BWindow(frame, "", B_MODAL_WINDOW, B_NOT_RESIZABLE) { BRect bgFrame, iFrame; bgFrame = Bounds(); iFrame = Bounds(); bgFrame.left = 40; iFrame.right = 39; - BView *bg = new BView (bgFrame, "RW bg", B_FOLLOW_ALL, B_WILL_DRAW); - bg->SetViewColor (LightGrey); - AddChild (bg); + BView* bg = new BView(bgFrame, "RW bg", B_FOLLOW_ALL, B_WILL_DRAW); + bg->SetViewColor(LightGrey); + AddChild(bg); app_info info; - be_app->GetAppInfo (&info); - BFile file (&info.ref, O_RDONLY); - BResources res (&file); - BBitmap *icon = new BBitmap (BRect (0, 0, 31, 31), B_CMAP8); + be_app->GetAppInfo(&info); + BFile file(&info.ref, O_RDONLY); + BResources res(&file); + BBitmap* icon = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8); size_t size; - const void *icondata = res.LoadResource ('ICON', "BEOS:L:image/x-becasso", &size); - icon->SetBits (icondata, 1024, 0, B_COLOR_8_BIT); - BitmapView *iView = new BitmapView (iFrame, "icon", icon, B_OP_OVER, false); - AddChild (iView); - iView->SetPosition (BPoint (4, 8)); - iView->SetViewColor (DarkGrey); - + const void* icondata = res.LoadResource('ICON', "BEOS:L:image/x-becasso", &size); + icon->SetBits(icondata, 1024, 0, B_COLOR_8_BIT); + BitmapView* iView = new BitmapView(iFrame, "icon", icon, B_OP_OVER, false); + AddChild(iView); + iView->SetPosition(BPoint(4, 8)); + iView->SetViewColor(DarkGrey); + char wait[256]; - sprintf (wait, lstring (432, "Please wait %d seconds…"), NAG_TIME); - - bg->AddChild (new BStringView (BRect (4, 4, 400, 20), "", lstring (4, "Unregistered Version"))); - bg->AddChild (new BStringView (BRect (4, 22, 400, 38), "", wait)); - bg->AddChild (new BStringView (BRect (4, 40, 400, 56), "", lstring (433, "(This delay will go away when you register Becasso.)"))); - bg->AddChild (new BStringView (BRect (4, 58, 400, 74), "", lstring (434, ""))); -} + sprintf(wait, lstring(432, "Please wait %d seconds…"), NAG_TIME); -NagWindow::~NagWindow () -{ + bg->AddChild(new BStringView(BRect(4, 4, 400, 20), "", lstring(4, "Unregistered Version"))); + bg->AddChild(new BStringView(BRect(4, 22, 400, 38), "", wait)); + bg->AddChild(new BStringView( + BRect(4, 40, 400, 56), "", + lstring(433, "(This delay will go away when you register Becasso.)") + )); + bg->AddChild(new BStringView(BRect(4, 58, 400, 74), "", lstring(434, ""))); } -void NagWindow::Go () +NagWindow::~NagWindow() {} + +void +NagWindow::Go() { Show(); - sleep (NAG_TIME); + sleep(NAG_TIME); Lock(); Quit(); } \ No newline at end of file diff --git a/source/NagWindow.h b/source/NagWindow.h index 7ff3552..d7bb12b 100644 --- a/source/NagWindow.h +++ b/source/NagWindow.h @@ -5,14 +5,14 @@ class NagWindow : public BWindow { -public: - NagWindow (BRect frame); -virtual ~NagWindow (); + public: + NagWindow(BRect frame); + virtual ~NagWindow(); -virtual void Go (); + virtual void Go(); -private: -typedef BWindow inherited; + private: + typedef BWindow inherited; }; #endif \ No newline at end of file diff --git a/source/OutputFormatWindow.cpp b/source/OutputFormatWindow.cpp index ab6e69c..c1247b8 100644 --- a/source/OutputFormatWindow.cpp +++ b/source/OutputFormatWindow.cpp @@ -27,12 +27,11 @@ // Defines -#define DO_SETUP 'dosu' -#define MESSAGE_SENT 'msgs' -#define SEND_MESSAGE 'smsg' -#define ITEM_SELECTED 'itsl' -#define INVOKE_LIST 'invk' - +#define DO_SETUP 'dosu' +#define MESSAGE_SENT 'msgs' +#define SEND_MESSAGE 'smsg' +#define ITEM_SELECTED 'itsl' +#define INVOKE_LIST 'invk' // Struct for keeping output format info together struct OutputFormat @@ -41,92 +40,77 @@ struct OutputFormat translator_id translator; }; - // CaptionView class for displaying a caption with a separator line class CaptionView : public BView { -public: - CaptionView(BRect frame, const char *caption); + public: + CaptionView(BRect frame, const char* caption); virtual ~CaptionView(); virtual void Draw(BRect updateRect); -private: - char *mCaption; + private: + char* mCaption; float text_height, text_descent; }; - // View for displaying the three info lines class InfoLinesView : public BView { -public: + public: InfoLinesView(BRect frame, int32 nLines); virtual ~InfoLinesView(); - void SetInfoLines(const char **LineTexts); + void SetInfoLines(const char** LineTexts); virtual void Draw(BRect updateRect); -private: + private: int32 mLines; - const char **mLineTexts; + const char** mLineTexts; float text_height, text_descent; }; - // The main view class OutputFormatView : public BView { -public: + public: OutputFormatView( - BRect frame, - BPositionIO *stream, - BInvoker *item_selected, - BTranslatorRoster *roster); + BRect frame, BPositionIO* stream, BInvoker* item_selected, BTranslatorRoster* roster + ); virtual ~OutputFormatView(); virtual void AttachedToWindow(); - virtual void MessageReceived(BMessage *msg); + virtual void MessageReceived(BMessage* msg); -private: + private: void AddConfigView(); void MakeFollowBottom(bool flag = true); - void RecursiveSetMode(BView *view); - BInvoker *selected_invoker; - bool message_sent; // --SS - BTranslatorRoster *the_roster; // switched to avoid compiler warning - BListView *list_view; - BScrollView *scroll_view; - BButton *cancel_button; - BButton *the_button; - CaptionView *info_caption; - InfoLinesView *info_view; - OutputFormat *output_list; // -SS - CaptionView *config_caption; // switched - BView *config_view; // --SS - BWindow *the_window; // switched + void RecursiveSetMode(BView* view); + BInvoker* selected_invoker; + bool message_sent; // --SS + BTranslatorRoster* the_roster; // switched to avoid compiler warning + BListView* list_view; + BScrollView* scroll_view; + BButton* cancel_button; + BButton* the_button; + CaptionView* info_caption; + InfoLinesView* info_view; + OutputFormat* output_list; // -SS + CaptionView* config_caption; // switched + BView* config_view; // --SS + BWindow* the_window; // switched int32 index; - const char *name_line; - const char *info_line; + const char* name_line; + const char* info_line; char version_line[40]; }; - // OutputFormatWindow constructor OutputFormatWindow::OutputFormatWindow( - BPositionIO *in_stream, - BInvoker *item_selected, - BInvoker *window_cancelled, - BTranslatorRoster *roster) - - : BWindow( - BRect(100.0, 45.0, 425.0, 322.0), - "Select Format", - B_TITLED_WINDOW, - 0) - , the_stream(in_stream) - , selected_invoker(item_selected) - , cancelled_invoker(window_cancelled) - , the_roster(roster) - , message_sent(false) - , setup_done(false) + BPositionIO* in_stream, BInvoker* item_selected, BInvoker* window_cancelled, + BTranslatorRoster* roster +) + + : BWindow(BRect(100.0, 45.0, 425.0, 322.0), "Select Format", B_TITLED_WINDOW, 0), + the_stream(in_stream), selected_invoker(item_selected), cancelled_invoker(window_cancelled), + the_roster(roster), message_sent(false), setup_done(false) { // Don't do anything time consuming in the contructor, // let's get the message looper thread going first @@ -134,44 +118,41 @@ OutputFormatWindow::OutputFormatWindow( PostMessage(DO_SETUP); } - // Handle messages sent to the window void -OutputFormatWindow::MessageReceived(BMessage *msg) +OutputFormatWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case DO_SETUP: - if (!setup_done) - { - if (the_roster == 0) - the_roster = BTranslatorRoster::Default(); - - OutputFormatView *main_view = new OutputFormatView( - Bounds(), the_stream, selected_invoker, the_roster); - ResizeTo(main_view->Bounds().Width(), main_view->Bounds().Height()); - Lock(); - AddChild(main_view); - Unlock(); - Show(); - setup_done = true; - } - break; + switch (msg->what) { + case DO_SETUP: + if (!setup_done) { + if (the_roster == 0) + the_roster = BTranslatorRoster::Default(); + + OutputFormatView* main_view = + new OutputFormatView(Bounds(), the_stream, selected_invoker, the_roster); + ResizeTo(main_view->Bounds().Width(), main_view->Bounds().Height()); + Lock(); + AddChild(main_view); + Unlock(); + Show(); + setup_done = true; + } + break; - case MESSAGE_SENT: - message_sent = true; - PostMessage(B_QUIT_REQUESTED); - break; + case MESSAGE_SENT: + message_sent = true; + PostMessage(B_QUIT_REQUESTED); + break; - default: - BWindow::MessageReceived(msg); - break; + default: + BWindow::MessageReceived(msg); + break; } } OutputFormatWindow::~OutputFormatWindow() { -// delete the_stream; + // delete the_stream; } // Quit the window @@ -185,20 +166,12 @@ OutputFormatWindow::QuitRequested() return true; } - // Main view constructor OutputFormatView::OutputFormatView( - BRect frame, - BPositionIO *stream, - BInvoker *item_selected, - BTranslatorRoster *roster) - : BView(frame, "", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) - , selected_invoker(item_selected) - , message_sent(false) - , the_roster(roster) - , output_list(0) - , config_caption(0) - , config_view(0) + BRect frame, BPositionIO* stream, BInvoker* item_selected, BTranslatorRoster* roster +) + : BView(frame, "", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), selected_invoker(item_selected), + message_sent(false), the_roster(roster), output_list(0), config_caption(0), config_view(0) { index = -1; version_line[0] = '\0'; @@ -209,62 +182,55 @@ OutputFormatView::OutputFormatView( SetLowColor(222, 222, 222); // Top caption - CaptionView *caption_view = new CaptionView( - BRect(8.0, 0.0, Bounds().right - 8.0, 0.0), "Output Formats"); + CaptionView* caption_view = + new CaptionView(BRect(8.0, 0.0, Bounds().right - 8.0, 0.0), "Output Formats"); AddChild(caption_view); // Create the main list view; we'll put it in a scroll view later list_view = new BListView( BRect( - 10.0, - caption_view->Frame().bottom + 3.0, - Bounds().right - 10.0 - B_V_SCROLL_BAR_WIDTH, - caption_view->Frame().bottom + 108.0), - ""); + 10.0, caption_view->Frame().bottom + 3.0, Bounds().right - 10.0 - B_V_SCROLL_BAR_WIDTH, + caption_view->Frame().bottom + 108.0 + ), + "" + ); list_view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP_BOTTOM); list_view->SetSelectionMessage(new BMessage(ITEM_SELECTED)); list_view->SetInvocationMessage(new BMessage(SEND_MESSAGE)); // Identify type and group of incoming stream translator_info in_info; - if (the_roster->Identify(stream, 0, &in_info, B_TRANSLATOR_BITMAP) == B_NO_ERROR) - { + if (the_roster->Identify(stream, 0, &in_info, B_TRANSLATOR_BITMAP) == B_NO_ERROR) { uint32 in_type = in_info.type; uint32 in_group = in_info.group; -// printf ("in_type %c%c%c%c, in_group %c%c%c%c\n", -// ((char *) &in_type)[0], ((char *) &in_type)[1], ((char *) &in_type)[2], ((char *) &in_type)[3], -// ((char *) &in_group)[0], ((char *) &in_group)[1], ((char *) &in_group)[2], ((char *) &in_group)[3]); + // printf ("in_type %c%c%c%c, in_group %c%c%c%c\n", + // ((char *) &in_type)[0], ((char *) &in_type)[1], ((char *) &in_type)[2], ((char + //*) &in_type)[3], + // ((char *) &in_group)[0], ((char *) &in_group)[1], ((char *) &in_group)[2], + //((char *) &in_group)[3]); - translator_info *info_list = 0; + translator_info* info_list = 0; int32 info_count = 0; - if (the_roster->GetTranslators(stream, 0, &info_list, &info_count) == B_OK) - { + if (the_roster->GetTranslators(stream, 0, &info_list, &info_count) == B_OK) { // One format per translator is a good starting point, // we'll dynamically resize if necessary int32 max_formats = info_count; output_list = new OutputFormat[max_formats]; int32 output_count = 0; -// printf ("%ld translators found\n", info_count); // --SS - for (int32 i = 0; i < info_count; ++i) - { - const translation_format *format_list = 0; // --SS const + // printf ("%ld translators found\n", info_count); // --SS + for (int32 i = 0; i < info_count; ++i) { + const translation_format* format_list = 0; // --SS const int32 format_count = 0; if (the_roster->GetOutputFormats( - info_list[i].translator, - &format_list, - &format_count) == B_NO_ERROR) - { - for (int32 j = 0; j < format_count; ++j) - { + info_list[i].translator, &format_list, &format_count + ) == B_NO_ERROR) { + for (int32 j = 0; j < format_count; ++j) { // Only list formats that differ from the input format // and belong to the same group. - if (format_list[j].type != in_type && - format_list[j].group == in_group) - { - if (output_count == max_formats) - { + if (format_list[j].type != in_type && format_list[j].group == in_group) { + if (output_count == max_formats) { max_formats += 10; - OutputFormat *new_list = new OutputFormat[max_formats]; + OutputFormat* new_list = new OutputFormat[max_formats]; for (int32 k = 0; k < output_count; ++k) new_list[k] = output_list[k]; @@ -278,11 +244,14 @@ OutputFormatView::OutputFormatView( list_view->AddItem(new BStringItem(format_list[j].name)); ++output_count; } -// else -// printf ("rejected in_type %c%c%c%c, in_group %c%c%c%c\n", -// ((char *) &format_list[j].type)[0], ((char *) &format_list[j].type)[1], ((char *) &format_list[j].type)[2], ((char *) &format_list[j].type)[3], -// ((char *) &format_list[j].group)[0], ((char *) &format_list[j].group)[1], ((char *) &format_list[j].group)[2], ((char *) &format_list[j].group)[3]); - + // else + // printf ("rejected in_type %c%c%c%c, in_group %c%c%c%c\n", + // ((char *) &format_list[j].type)[0], ((char *) + //&format_list[j].type)[1], ((char *) &format_list[j].type)[2], ((char *) + //&format_list[j].type)[3], + // ((char *) &format_list[j].group)[0], ((char *) + //&format_list[j].group)[1], ((char *) &format_list[j].group)[2], ((char *) + //&format_list[j].group)[3]); } } } @@ -292,33 +261,24 @@ OutputFormatView::OutputFormatView( // Put the list view in a scroll view with a vertical scroll bar scroll_view = new BScrollView( - "", - list_view, - B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, - B_WILL_DRAW, - false, - true, - B_PLAIN_BORDER); + "", list_view, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW, false, true, B_PLAIN_BORDER + ); AddChild(scroll_view); // Cancel button cancel_button = new BButton( - BRect(0.0, 0.0, 0.0, 0.0), - "", - "Cancel", - new BMessage(B_QUIT_REQUESTED), - B_FOLLOW_RIGHT | B_FOLLOW_TOP); + BRect(0.0, 0.0, 0.0, 0.0), "", "Cancel", new BMessage(B_QUIT_REQUESTED), + B_FOLLOW_RIGHT | B_FOLLOW_TOP + ); // Resize to make the text fit the button cancel_button->ResizeToPreferred(); AddChild(cancel_button); // Main button the_button = new BButton( - BRect(0.0, 0.0, 0.0, 0.0), - "", - "Use", - new BMessage(INVOKE_LIST), - B_FOLLOW_RIGHT | B_FOLLOW_TOP); + BRect(0.0, 0.0, 0.0, 0.0), "", "Use", new BMessage(INVOKE_LIST), + B_FOLLOW_RIGHT | B_FOLLOW_TOP + ); // Make it the default button the_button->MakeDefault(true); // Resize to make the text fit the button @@ -326,24 +286,27 @@ OutputFormatView::OutputFormatView( // Move it to the extreme right the_button->MoveBy( scroll_view->Frame().right - the_button->Frame().right, - scroll_view->Frame().bottom - the_button->Frame().top + 7.0); + scroll_view->Frame().bottom - the_button->Frame().top + 7.0 + ); AddChild(the_button); // Center the cancel button next to the main button cancel_button->MoveBy( the_button->Frame().left - cancel_button->Frame().right - 10.0, the_button->Frame().top - cancel_button->Frame().top + - (the_button->Frame().Height() - cancel_button->Frame().Height()) / 2.0); + (the_button->Frame().Height() - cancel_button->Frame().Height()) / 2.0 + ); // Caption for the info view info_caption = new CaptionView( BRect(8.0, the_button->Frame().bottom + 1.0, Bounds().right - 8.0, 0.0), - "Translator Information"); + "Translator Information" + ); AddChild(info_caption); // Info view - info_view = new InfoLinesView( - BRect(16.0, info_caption->Frame().bottom + 1.0, Bounds().right, 0.0), 3); + info_view = + new InfoLinesView(BRect(16.0, info_caption->Frame().bottom + 1.0, Bounds().right, 0.0), 3); AddChild(info_view); // Resize the main view so that everything fits @@ -352,13 +315,8 @@ OutputFormatView::OutputFormatView( MakeFollowBottom(); } - // Main view destructor -OutputFormatView::~OutputFormatView() -{ - delete[] output_list; -} - +OutputFormatView::~OutputFormatView() { delete[] output_list; } // Stuff we can only do when the main view is attached to a window void @@ -370,10 +328,8 @@ OutputFormatView::AttachedToWindow() // Set some size limits on the window the_window->SetSizeLimits( - 200.0, - 32767.0, - Bounds().Height() - scroll_view->Bounds().Height() + 50.0, - 32767.0); + 200.0, 32767.0, Bounds().Height() - scroll_view->Bounds().Height() + 50.0, 32767.0 + ); // Set the target for messages sent to this view list_view->SetTarget(this); the_button->SetTarget(this); @@ -395,93 +351,78 @@ OutputFormatView::AttachedToWindow() BView::AttachedToWindow(); } - // Handle messages to the main view void -OutputFormatView::MessageReceived(BMessage *msg) +OutputFormatView::MessageReceived(BMessage* msg) { int32 item_index; - const char *info_lines[3]; - - switch (msg->what) - { - case ITEM_SELECTED: - if (msg->FindInt32("index", &item_index) == B_OK && - item_index >= 0 && - item_index < list_view->CountItems()) - { - // Store the currently selected item - // in the class member 'index' - index = item_index; - // Update the info view and config view - int32 outVersion; - the_roster->GetTranslatorInfo( - output_list[item_index].translator, - &name_line, - &info_line, - &outVersion); - int32 ver = outVersion / 100; - int32 rev1 = (outVersion % 100) / 10; - int32 rev2 = outVersion % 10; - sprintf(version_line, "Version %ld.%ld.%ld", ver, rev1, rev2); // --SS %ld - info_lines[0] = name_line; - info_lines[1] = info_line; - info_lines[2] = version_line; - info_view->SetInfoLines(info_lines); - AddConfigView(); - } - else - { - // Reselect the original item - if (index >= 0) - list_view->Select(index); - } - break; - - case INVOKE_LIST: - { - // The main button was pressed - // Find out which item is selected, and invoke it - int32 item_count = list_view->CountItems(); - for (int32 i = 0; i < item_count; ++i) - { - if (list_view->IsItemSelected(i)) - { - list_view->Invoke(); - break; - } + const char* info_lines[3]; + + switch (msg->what) { + case ITEM_SELECTED: + if (msg->FindInt32("index", &item_index) == B_OK && item_index >= 0 && + item_index < list_view->CountItems()) { + // Store the currently selected item + // in the class member 'index' + index = item_index; + // Update the info view and config view + int32 outVersion; + the_roster->GetTranslatorInfo( + output_list[item_index].translator, &name_line, &info_line, &outVersion + ); + int32 ver = outVersion / 100; + int32 rev1 = (outVersion % 100) / 10; + int32 rev2 = outVersion % 10; + sprintf(version_line, "Version %ld.%ld.%ld", ver, rev1, rev2); // --SS %ld + info_lines[0] = name_line; + info_lines[1] = info_line; + info_lines[2] = version_line; + info_view->SetInfoLines(info_lines); + AddConfigView(); + } else { + // Reselect the original item + if (index >= 0) + list_view->Select(index); + } + break; + + case INVOKE_LIST: { + // The main button was pressed + // Find out which item is selected, and invoke it + int32 item_count = list_view->CountItems(); + for (int32 i = 0; i < item_count; ++i) { + if (list_view->IsItemSelected(i)) { + list_view->Invoke(); + break; } - break; } + break; + } - case SEND_MESSAGE: - // An output format has been selected - if (!message_sent && - msg->FindInt32("index", &item_index) == B_OK && - item_index >= 0 && - item_index < list_view->CountItems()) - { - // Get the message from the invoker - BMessage the_message (*(selected_invoker->Message())); - - // Add some info about the selected output format to it - the_message.AddInt32("translator", output_list[item_index].translator); - the_message.AddInt32("type", output_list[item_index].type); - - // Send the message - selected_invoker->Invoke(&the_message); - message_sent = true; - the_window->PostMessage(MESSAGE_SENT); - } - break; + case SEND_MESSAGE: + // An output format has been selected + if (!message_sent && msg->FindInt32("index", &item_index) == B_OK && item_index >= 0 && + item_index < list_view->CountItems()) { + // Get the message from the invoker + BMessage the_message(*(selected_invoker->Message())); - default: - BView::MessageReceived(msg); - break; + // Add some info about the selected output format to it + the_message.AddInt32("translator", output_list[item_index].translator); + the_message.AddInt32("type", output_list[item_index].type); + + // Send the message + selected_invoker->Invoke(&the_message); + message_sent = true; + the_window->PostMessage(MESSAGE_SENT); + } + break; + + default: + BView::MessageReceived(msg); + break; } } - // Private function to add the config view of the currently // selected output format to our window void @@ -496,8 +437,7 @@ OutputFormatView::AddConfigView() MakeFollowBottom(false); // Remove the old config view if there is one - if (config_view) - { + if (config_view) { RemoveChild(config_view); delete config_view; config_view = 0; @@ -505,19 +445,16 @@ OutputFormatView::AddConfigView() BRect config_rect; if (the_roster->MakeConfigurationView( - output_list[index].translator, - 0, - &config_view, - &config_rect) == B_NO_ERROR && - config_view != 0) - { + output_list[index].translator, 0, &config_view, &config_rect + ) == B_NO_ERROR && + config_view != 0) { // Create a caption for the config view // if there wasn't one already - if (!config_caption) - { + if (!config_caption) { config_caption = new CaptionView( BRect(8.0, info_view->Frame().bottom + 1.0, Bounds().right - 8.0, 0.0), - "Translator Settings"); + "Translator Settings" + ); config_caption->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); AddChild(config_caption); } @@ -525,7 +462,8 @@ OutputFormatView::AddConfigView() // Move the config view to just below the config caption config_view->MoveBy( 16.0 - config_view->Frame().left, - config_caption->Frame().bottom + 1.0 - config_view->Frame().top); + config_caption->Frame().bottom + 1.0 - config_view->Frame().top + ); // Colour it gray config_view->SetViewColor(222, 222, 222); @@ -536,19 +474,17 @@ OutputFormatView::AddConfigView() float width_diff = config_view->Frame().right + 16.0 - Bounds().Width(); the_window->ResizeTo( Bounds().Width() + (width_diff > 0.0 ? width_diff : 0.0), - config_view->Frame().bottom + 8.0); + config_view->Frame().bottom + 8.0 + ); // Add it to the main view AddChild(config_view); // Make the config_view and its children follow the bottom of the window RecursiveSetMode(config_view); - } - else - { + } else { // This translator doesn't have a config view - if (config_caption) - { + if (config_caption) { RemoveChild(config_caption); delete config_caption; config_caption = 0; @@ -564,15 +500,12 @@ OutputFormatView::AddConfigView() if (min_width < 200.0) min_width = 200.0; the_window->SetSizeLimits( - min_width, - 32767.0, - Bounds().Height() - scroll_view->Bounds().Height() + 50.0, - 32767.0); + min_width, 32767.0, Bounds().Height() - scroll_view->Bounds().Height() + 50.0, 32767.0 + ); the_window->Unlock(); } - // Private function to switch between follow bottom behaviour void OutputFormatView::MakeFollowBottom(bool flag) @@ -583,36 +516,33 @@ OutputFormatView::MakeFollowBottom(bool flag) info_caption->SetResizingMode(B_FOLLOW_LEFT_RIGHT | (flag ? B_FOLLOW_BOTTOM : B_FOLLOW_TOP)); info_view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | (flag ? B_FOLLOW_BOTTOM : B_FOLLOW_TOP)); if (config_caption) - config_caption->SetResizingMode(B_FOLLOW_LEFT_RIGHT | (flag ? B_FOLLOW_BOTTOM : B_FOLLOW_TOP)); + config_caption->SetResizingMode( + B_FOLLOW_LEFT_RIGHT | (flag ? B_FOLLOW_BOTTOM : B_FOLLOW_TOP) + ); } - // Recursively set the resizing mode of a view and its children void -OutputFormatView::RecursiveSetMode(BView *view) +OutputFormatView::RecursiveSetMode(BView* view) { // Set the parent view itself view->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); // Now set all its children - BView *child; - if ((child = view->ChildAt(0)) != 0) - { - while (child) - { + BView* child; + if ((child = view->ChildAt(0)) != 0) { + while (child) { RecursiveSetMode(child); child = child->NextSibling(); } } } - // InfoLinesView constructor InfoLinesView::InfoLinesView(BRect frame, int32 nLines) - : BView(frame, "", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW) - , mLines(nLines) + : BView(frame, "", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW), mLines(nLines) { - mLineTexts = new const char *[mLines]; // --SS const + mLineTexts = new const char*[mLines]; // --SS const for (int32 i = 0; i < mLines; ++i) mLineTexts[i] = 0; @@ -629,45 +559,34 @@ InfoLinesView::InfoLinesView(BRect frame, int32 nLines) ResizeTo(frame.Width(), nLines * text_height); } - // InfoLinesView destructor -InfoLinesView::~InfoLinesView() -{ - delete[] mLineTexts; -} - +InfoLinesView::~InfoLinesView() { delete[] mLineTexts; } // Update the texts in the info lines void -InfoLinesView::SetInfoLines(const char **LineTexts) +InfoLinesView::SetInfoLines(const char** LineTexts) { for (int32 i = 0; i < mLines; ++i) mLineTexts[i] = LineTexts[i]; Invalidate(Bounds()); } - // Draw the info lines void InfoLinesView::Draw(BRect /*updateRect*/) { - for (int32 i = 0; i < mLines; ++i) - { - if (mLineTexts[i]) - { - DrawString( - mLineTexts[i], - BPoint(0.0, (i + 1.0) * text_height - text_descent)); + for (int32 i = 0; i < mLines; ++i) { + if (mLineTexts[i]) { + DrawString(mLineTexts[i], BPoint(0.0, (i + 1.0) * text_height - text_descent)); } } } - // CaptionView constructor -CaptionView::CaptionView(BRect frame, const char *caption) +CaptionView::CaptionView(BRect frame, const char* caption) : BView(frame, "", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW) { - mCaption = new char[strlen(caption)+ 1]; + mCaption = new char[strlen(caption) + 1]; strcpy(mCaption, caption); SetViewColor(222, 222, 222); @@ -682,13 +601,8 @@ CaptionView::CaptionView(BRect frame, const char *caption) ResizeTo(frame.Width(), text_height + 19.0); } - // CaptionView destructor -CaptionView::~CaptionView() -{ - delete[] mCaption; -} - +CaptionView::~CaptionView() { delete[] mCaption; } // Draw the caption void diff --git a/source/OutputFormatWindow.h b/source/OutputFormatWindow.h index 321ae9d..2731b03 100644 --- a/source/OutputFormatWindow.h +++ b/source/OutputFormatWindow.h @@ -45,32 +45,32 @@ class BInvoker; class BPositionIO; - class OutputFormatWindow : public BWindow { -public: + public: OutputFormatWindow( // Input stream (e.g. a ProgressiveBitmapStream of the bitmap to save) - BPositionIO *in_stream, + BPositionIO* in_stream, // Invoker for when an output format is selected - BInvoker *item_selected, + BInvoker* item_selected, // Invoker for when the window is cancelled (optional) - BInvoker *window_cancelled = 0, + BInvoker* window_cancelled = 0, // Translator roster to use, or 0 for the default - BTranslatorRoster *roster = 0); + BTranslatorRoster* roster = 0 + ); virtual ~OutputFormatWindow(); - virtual void MessageReceived(BMessage *msg); + virtual void MessageReceived(BMessage* msg); virtual bool QuitRequested(); -private: - BPositionIO *the_stream; - BInvoker *selected_invoker; - BInvoker *cancelled_invoker; - BTranslatorRoster *the_roster; + private: + BPositionIO* the_stream; + BInvoker* selected_invoker; + BInvoker* cancelled_invoker; + BTranslatorRoster* the_roster; bool message_sent; bool setup_done; }; -#endif // OUTPUT_FORMAT_WINDOW_H +#endif // OUTPUT_FORMAT_WINDOW_H diff --git a/source/PalletWindow.cpp b/source/PalletWindow.cpp index 1c19808..88ba6fc 100644 --- a/source/PalletWindow.cpp +++ b/source/PalletWindow.cpp @@ -2,28 +2,26 @@ #define inherited BWindow -PalletWindow::PalletWindow(BRect frame, const char *name, int Orientation) +PalletWindow::PalletWindow(BRect frame, const char* name, int Orientation) : BWindow(frame, name, B_BORDERED_WINDOW, B_NOT_RESIZABLE | B_WILL_ACCEPT_FIRST_CLICK) { // Need a dragbar at the top BRect border; if (Orientation == 0) - border.Set (0, 0, frame.Width() - 1, PW_TABSIZE); + border.Set(0, 0, frame.Width() - 1, PW_TABSIZE); else - border.Set (0, 0, PW_TABSIZE, frame.Height() - 1); - - dv = new DragView (border, name, Orientation); + border.Set(0, 0, PW_TABSIZE, frame.Height() - 1); + + dv = new DragView(border, name, Orientation); // Need to be increase our height to accomodate the dragbar if (Orientation == 0) - ResizeBy (0, PW_TABSIZE); + ResizeBy(0, PW_TABSIZE); else - ResizeBy (PW_TABSIZE, 0); + ResizeBy(PW_TABSIZE, 0); AddChild(dv); } -PalletWindow::~PalletWindow() -{ -} +PalletWindow::~PalletWindow() {} diff --git a/source/PalletWindow.h b/source/PalletWindow.h index d81748a..1ce4ad3 100644 --- a/source/PalletWindow.h +++ b/source/PalletWindow.h @@ -13,21 +13,20 @@ #define PW_TABSIZE 16 -class PalletWindow : public BWindow { +class PalletWindow : public BWindow +{ -public: - PalletWindow(BRect Frame, - const char *name = "PalletWindow", - int Orientation = 0); -virtual ~PalletWindow(); - DragView *dv; -/* -virtual void Quit(); -virtual void ScreenChanged(BRect screen_size, color_space depth); -virtual void WindowActivated(bool state); -virtual void Show(); -virtual void Hide(); -*/ + public: + PalletWindow(BRect Frame, const char* name = "PalletWindow", int Orientation = 0); + virtual ~PalletWindow(); + DragView* dv; + /* + virtual void Quit(); + virtual void ScreenChanged(BRect screen_size, color_space depth); + virtual void WindowActivated(bool state); + virtual void Show(); + virtual void Hide(); + */ }; #endif \ No newline at end of file diff --git a/source/PatternItem.cpp b/source/PatternItem.cpp index 4925f63..515bc83 100644 --- a/source/PatternItem.cpp +++ b/source/PatternItem.cpp @@ -3,57 +3,54 @@ #include "ColorMenuButton.h" #include "Colors.h" -PatternItem::PatternItem (const pattern _p) -: BMenuItem ("", NULL) -{ - pat = _p; -} +PatternItem::PatternItem(const pattern _p) : BMenuItem("", NULL) { pat = _p; } -PatternItem::~PatternItem () -{ -} +PatternItem::~PatternItem() {} -pattern PatternItem::getPattern () +pattern +PatternItem::getPattern() { return (pat); } -void PatternItem::setPattern (pattern _p) +void +PatternItem::setPattern(pattern _p) { pat = _p; } -void PatternItem::Draw () +void +PatternItem::Draw() { extern ColorMenuButton *locolor, *hicolor; BRect frame = Frame(); frame.right--; frame.bottom--; rgb_color oldLo = Menu()->LowColor(); - Menu()->SetLowColor (locolor->color()); - Menu()->SetHighColor (hicolor->color()); - Menu()->FillRect (frame, pat); + Menu()->SetLowColor(locolor->color()); + Menu()->SetHighColor(hicolor->color()); + Menu()->FillRect(frame, pat); rgb_color oldHi = Menu()->HighColor(); frame.right++; frame.bottom++; - Menu()->SetHighColor (Black); - Menu()->StrokeRect (frame); - Menu()->SetHighColor (oldHi); - if (IsSelected() || IsMarked()) - { - frame.InsetBy (1, 1); + Menu()->SetHighColor(Black); + Menu()->StrokeRect(frame); + Menu()->SetHighColor(oldHi); + if (IsSelected() || IsMarked()) { + frame.InsetBy(1, 1); oldHi = Menu()->HighColor(); - Menu()->SetHighColor (White); - Menu()->StrokeRect (frame); - frame.InsetBy (1, 1); - Menu()->SetHighColor (Black); - Menu()->StrokeRect (frame); - Menu()->SetHighColor (oldHi); + Menu()->SetHighColor(White); + Menu()->StrokeRect(frame); + frame.InsetBy(1, 1); + Menu()->SetHighColor(Black); + Menu()->StrokeRect(frame); + Menu()->SetHighColor(oldHi); } - Menu()->SetLowColor (oldLo); + Menu()->SetLowColor(oldLo); } -void PatternItem::GetContentSize (float *width, float *height) +void +PatternItem::GetContentSize(float* width, float* height) { *width = 0; *height = P_SIZE; diff --git a/source/PatternItem.h b/source/PatternItem.h index b412bf6..e2981df 100644 --- a/source/PatternItem.h +++ b/source/PatternItem.h @@ -5,19 +5,20 @@ class PatternItem : public BMenuItem { -public: - PatternItem (const pattern _p); -virtual ~PatternItem (); -pattern getPattern (); -void setPattern (pattern _p); + public: + PatternItem(const pattern _p); + virtual ~PatternItem(); + pattern getPattern(); + void setPattern(pattern _p); -virtual void Draw (); -protected: -virtual void GetContentSize (float *width, float *height); + virtual void Draw(); -private: -typedef BMenuItem inherited; -pattern pat; + protected: + virtual void GetContentSize(float* width, float* height); + + private: + typedef BMenuItem inherited; + pattern pat; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/PatternMenu.cpp b/source/PatternMenu.cpp index 28cc6ac..ad40f66 100644 --- a/source/PatternMenu.cpp +++ b/source/PatternMenu.cpp @@ -3,7 +3,7 @@ #include "PatternItem.h" #include "PatternMenuView.h" #include "ColorMenuButton.h" -#include "BecassoAddOn.h" // for some defines +#include "BecassoAddOn.h" // for some defines #include #include #include @@ -12,19 +12,18 @@ #include #include "Settings.h" -PatternMenu::PatternMenu (BView *_view, int h, int v, float s) -: BMenu ("PatternMenu", h*s, v*s) +PatternMenu::PatternMenu(BView* _view, int h, int v, float s) : BMenu("PatternMenu", h * s, v * s) { pattern patterns[MAX_PATTERNS]; - uchar data[MAX_PATTERNS][8] = - { {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, - {0xFF, 0xDD, 0xFF, 0x77, 0xFF, 0xDD, 0xFF, 0x77}, + uchar data[MAX_PATTERNS][8] = { + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, + {0xFF, 0xDD, 0xFF, 0x77, 0xFF, 0xDD, 0xFF, 0x77}, {0xFF, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA, 0xFF, 0xAA}, {0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD}, -// {0x9B, 0xB9, 0x7D, 0xD6, 0xED, 0xBB, 0x6E, 0xB7}, + // {0x9B, 0xB9, 0x7D, 0xD6, 0xED, 0xBB, 0x6E, 0xB7}, {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55}, -// {0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA}, -// {0x94, 0x29, 0x82, 0x29, 0x92, 0x44, 0x91, 0x48}, + // {0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA}, + // {0x94, 0x29, 0x82, 0x29, 0x92, 0x44, 0x91, 0x48}, {0x33, 0xCC, 0x33, 0xCC, 0x33, 0xCC, 0x33, 0xCC}, {0x00, 0x55, 0x00, 0x55, 0x00, 0x55, 0x00, 0x55}, {0x88, 0x22, 0x88, 0x22, 0x88, 0x22, 0x88, 0x22}, @@ -40,225 +39,226 @@ PatternMenu::PatternMenu (BView *_view, int h, int v, float s) {0x88, 0x44, 0x22, 0x11, 0x88, 0x44, 0x22, 0x11}, {0xDD, 0xEE, 0x77, 0xBB, 0xDD, 0xEE, 0x77, 0xBB}, {0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00}, - {0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88} }; + {0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88} + }; - for (int i = 0; i < h*v; i++) + for (int i = 0; i < h * v; i++) for (int j = 0; j < 8; j++) patterns[i].data[j] = data[i][j]; index = 0; for (int i = 0; i < v; i++) - for (int j = 0; j < h; j++) - { - BRect cframe = BRect (j*s, i*s, (j + 1)*s, (i + 1)*s); - AddItem (new PatternItem (patterns[index]), cframe); + for (int j = 0; j < h; j++) { + BRect cframe = BRect(j * s, i * s, (j + 1) * s, (i + 1) * s); + AddItem(new PatternItem(patterns[index]), cframe); } - Mark (0); + Mark(0); view = _view; - hs = h*s; - vs = v*s; + hs = h * s; + vs = v * s; parent = NULL; fWindow = NULL; -// app_info info; -// be_app->GetAppInfo (&info); + // app_info info; + // be_app->GetAppInfo (&info); } -PatternMenu::~PatternMenu () -{ -} +PatternMenu::~PatternMenu() {} -void PatternMenu::setParent (PatternMenuButton *pmb) +void +PatternMenu::setParent(PatternMenuButton* pmb) { parent = pmb; - + // Now is also a good time to put the tear-off window on screen // (if the app last quit that way) - if (!fWindow) - { + if (!fWindow) { BPoint origin; BRect place = Bounds(); - origin = get_window_origin (numPatternTO); - if (origin != InvalidPoint) - { - place.OffsetTo (origin); - TearDone (place, true); + origin = get_window_origin(numPatternTO); + if (origin != InvalidPoint) { + place.OffsetTo(origin); + TearDone(place, true); } } } -void PatternMenu::AddItem (PatternItem *item, BRect frame) +void +PatternMenu::AddItem(PatternItem* item, BRect frame) { if (index < MAX_PATTERNS - 1) items[index++] = item; else items[index] = item; - inherited::AddItem (item, frame); + inherited::AddItem(item, frame); } -PatternItem *PatternMenu::ItemAt (int i) +PatternItem* +PatternMenu::ItemAt(int i) { return (items[i]); } -PatternItem *PatternMenu::FindMarked () +PatternItem* +PatternMenu::FindMarked() { return (items[index]); } -class patternTearInfo +class patternTearInfo { -public: - patternTearInfo (BRect r, PatternMenu *p, BView *s) : dragRect (r), parent (p), someView (s) {}; + public: + patternTearInfo(BRect r, PatternMenu* p, BView* s) : dragRect(r), parent(p), someView(s){}; BRect dragRect; - PatternMenu *parent; - BView *someView; + PatternMenu* parent; + BView* someView; }; -int32 pattern_tear_drag (void *data); +int32 +pattern_tear_drag(void* data); -int32 pattern_tear_drag (void *data) +int32 +pattern_tear_drag(void* data) { - patternTearInfo *tearInfo = (patternTearInfo *) data; + patternTearInfo* tearInfo = (patternTearInfo*)data; uint32 buttons = 1; BPoint point; - PatternMenu *menu = tearInfo->parent; + PatternMenu* menu = tearInfo->parent; BRect place = tearInfo->dragRect; - BView *view = tearInfo->someView; + BView* view = tearInfo->someView; // It might seem a good idea to use `menu' as the view, but // this gave errors: `Method requires owner but doesn't have one'. - delete tearInfo; // The caller doesn't do this (race condition otherwise) + delete tearInfo; // The caller doesn't do this (race condition otherwise) // printf ("Entering loop; view = %p\n", view); - while (buttons) - { + while (buttons) { view->Window()->Lock(); - view->GetMouse (&point, &buttons); + view->GetMouse(&point, &buttons); view->Window()->Unlock(); - snooze (50000); + snooze(50000); } // printf ("Exited loop\n"); view->Window()->Lock(); - point = view->ConvertToScreen (point); + point = view->ConvertToScreen(point); view->Window()->Unlock(); // printf ("Released at (%.0f, %.0f)\n", point.x, point.y); - place.OffsetTo (point); - + place.OffsetTo(point); + menu->getParent()->lock->Lock(); - menu->TearDone (place, !menu->getParent()->MenuWinOnScreen); + menu->TearDone(place, !menu->getParent()->MenuWinOnScreen); menu->getParent()->lock->Unlock(); return B_NO_ERROR; } -void PatternMenu::MouseMoved (BPoint point, uint32 transit, const BMessage * /* msg */) +void +PatternMenu::MouseMoved(BPoint point, uint32 transit, const BMessage* /* msg */) { uint32 buttons; if (!Parent()) return; - GetMouse (&point, &buttons); - if (transit == B_EXITED_VIEW && buttons) // Do the tear off thing! + GetMouse(&point, &buttons); + if (transit == B_EXITED_VIEW && buttons) // Do the tear off thing! { -#if defined (EASTER_EGG_SFX) +#if defined(EASTER_EGG_SFX) extern bool EasterEgg; - if (modifiers() & B_SHIFT_KEY && EasterEgg) - { - extern EffectsPlayer *easterEgg; + if (modifiers() & B_SHIFT_KEY && EasterEgg) { + extern EffectsPlayer* easterEgg; easterEgg->StartEffect(); } #endif - BMessage *tearmsg = new BMessage ('tear'); - BBitmap *dragmap = new BBitmap (Bounds(), B_RGBA32, true); + BMessage* tearmsg = new BMessage('tear'); + BBitmap* dragmap = new BBitmap(Bounds(), B_RGBA32, true); dragmap->Lock(); - BView *dragview = new BView (Bounds(), "temp dragmap view", B_FOLLOW_ALL, B_WILL_DRAW); - dragmap->AddChild (dragview); - //dragview->SetLowColor (LightGrey); - //dragview->FillRect (Bounds(), B_SOLID_LOW); + BView* dragview = new BView(Bounds(), "temp dragmap view", B_FOLLOW_ALL, B_WILL_DRAW); + dragmap->AddChild(dragview); + // dragview->SetLowColor (LightGrey); + // dragview->FillRect (Bounds(), B_SOLID_LOW); extern ColorMenuButton *locolor, *hicolor; - dragview->SetLowColor (locolor->color()); - for (int i = 0; i < MAX_PATTERNS; i++) - { + dragview->SetLowColor(locolor->color()); + for (int i = 0; i < MAX_PATTERNS; i++) { BRect frame = items[i]->Frame(); - dragview->SetHighColor (hicolor->color()); - dragview->FillRect (frame, items[i]->getPattern()); - dragview->SetHighColor (Black); - dragview->StrokeRect (frame); + dragview->SetHighColor(hicolor->color()); + dragview->FillRect(frame, items[i]->getPattern()); + dragview->SetHighColor(Black); + dragview->StrokeRect(frame); dragview->Sync(); } - dragview->SetHighColor (DarkGrey); - dragview->StrokeRect (Bounds()); - dragmap->RemoveChild (dragview); + dragview->SetHighColor(DarkGrey); + dragview->StrokeRect(Bounds()); + dragmap->RemoveChild(dragview); dragmap->Unlock(); - bgra_pixel *bits = (bgra_pixel *) dragmap->Bits(); - for (bgra_pixel p = 0; p < dragmap->BitsLength()/4; p++) - { + bgra_pixel* bits = (bgra_pixel*)dragmap->Bits(); + for (bgra_pixel p = 0; p < dragmap->BitsLength() / 4; p++) { bgra_pixel pixel = *bits; *bits++ = (pixel & COLOR_MASK) | (127 << ALPHA_BPOS); } delete dragview; - DragMessage (tearmsg, dragmap, B_OP_ALPHA, B_ORIGIN); + DragMessage(tearmsg, dragmap, B_OP_ALPHA, B_ORIGIN); delete tearmsg; BRect place = Bounds(); - + // Send a fake Esc keydown to the popup char kbuf[2]; - BMessage kmsg (B_KEY_DOWN); - kmsg.AddInt64 ("when", system_time()); - kmsg.AddInt32 ("modifiers", 0); - kmsg.AddInt32 ("key", B_ESCAPE); - kmsg.AddInt8 ("byte", B_ESCAPE); + BMessage kmsg(B_KEY_DOWN); + kmsg.AddInt64("when", system_time()); + kmsg.AddInt32("modifiers", 0); + kmsg.AddInt32("key", B_ESCAPE); + kmsg.AddInt8("byte", B_ESCAPE); kbuf[0] = B_ESCAPE; kbuf[1] = '\0'; - kmsg.AddString ("bytes", kbuf); - Window()->PostMessage (&kmsg, this); + kmsg.AddString("bytes", kbuf); + Window()->PostMessage(&kmsg, this); // This makes the original popup go away. // We can't use Hide() since that crashes. - - patternTearInfo *tearInfo = new patternTearInfo (place, this, parent); - resume_thread (spawn_thread (pattern_tear_drag, "Menu Tear Thread", B_NORMAL_PRIORITY, tearInfo)); + + patternTearInfo* tearInfo = new patternTearInfo(place, this, parent); + resume_thread( + spawn_thread(pattern_tear_drag, "Menu Tear Thread", B_NORMAL_PRIORITY, tearInfo) + ); } // inherited::MouseMoved (point, transit, msg); } -void PatternMenu::TearDone (BRect place, bool newwin) +void +PatternMenu::TearDone(BRect place, bool newwin) { - if (newwin) - { - fWindow = new DragWindow ("pat", place, parent->Name()); + if (newwin) { + fWindow = new DragWindow("pat", place, parent->Name()); BRect mvRect = Bounds(); // mvRect.OffsetBy (0, PW_TABSIZE + 1); - PatternMenuView *mv = new PatternMenuView (mvRect, "MenuView", parent); - fWindow->AddChild (mv); + PatternMenuView* mv = new PatternMenuView(mvRect, "MenuView", parent); + fWindow->AddChild(mv); fWindow->Show(); - } - else - { - fWindow->MoveTo (place.LeftTop()); + } else { + fWindow->MoveTo(place.LeftTop()); fWindow->Activate(); } } -void PatternMenu::Mark (int _index) +void +PatternMenu::Mark(int _index) { - items[index]->SetMarked (false); + items[index]->SetMarked(false); index = _index; - items[index]->SetMarked (true); + items[index]->SetMarked(true); } -BPoint PatternMenu::ScreenLocation () +BPoint +PatternMenu::ScreenLocation() { BScreen screen; - BPoint currentpoint = BPoint (0, 0); - view->ConvertToScreen (¤tpoint); - currentpoint.y = min_c (currentpoint.y, screen.Frame().bottom - vs - 4); - currentpoint.x = min_c (currentpoint.x, screen.Frame().right - hs - 4); + BPoint currentpoint = BPoint(0, 0); + view->ConvertToScreen(¤tpoint); + currentpoint.y = min_c(currentpoint.y, screen.Frame().bottom - vs - 4); + currentpoint.x = min_c(currentpoint.x, screen.Frame().right - hs - 4); return (currentpoint); } -void PatternMenu::InvalidateWindow () +void +PatternMenu::InvalidateWindow() { - if (fWindow) - { + if (fWindow) { fWindow->Lock(); fWindow->ChildAt(0)->Invalidate(); fWindow->UpdateIfNeeded(); diff --git a/source/PatternMenu.h b/source/PatternMenu.h index ab2e442..29a4f6a 100644 --- a/source/PatternMenu.h +++ b/source/PatternMenu.h @@ -15,31 +15,34 @@ class PatternMenuButton; class PatternMenu : public BMenu { -friend class PatternMenuButton; -public: - PatternMenu (BView *_view, int h, int v, float s); -virtual ~PatternMenu (); -virtual void AddItem (PatternItem *item, BRect frame); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *msg); -PatternItem *FindMarked (); -PatternItem *ItemAt (int i); -virtual void Mark (int _index); -void setParent (PatternMenuButton *pmb); -PatternMenuButton *getParent () { return parent; }; -void TearDone (BRect place, bool newwin); -void InvalidateWindow (); - -protected: -virtual BPoint ScreenLocation (); - -private: -typedef BMenu inherited; -DragWindow *fWindow; -PatternMenuButton *parent; -PatternItem *items[MAX_PATTERNS]; -int index; -BView *view; -float hs, vs; + friend class PatternMenuButton; + + public: + PatternMenu(BView* _view, int h, int v, float s); + virtual ~PatternMenu(); + virtual void AddItem(PatternItem* item, BRect frame); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg); + PatternItem* FindMarked(); + PatternItem* ItemAt(int i); + virtual void Mark(int _index); + void setParent(PatternMenuButton* pmb); + + PatternMenuButton* getParent() { return parent; }; + + void TearDone(BRect place, bool newwin); + void InvalidateWindow(); + + protected: + virtual BPoint ScreenLocation(); + + private: + typedef BMenu inherited; + DragWindow* fWindow; + PatternMenuButton* parent; + PatternItem* items[MAX_PATTERNS]; + int index; + BView* view; + float hs, vs; }; #endif diff --git a/source/PatternMenuButton.cpp b/source/PatternMenuButton.cpp index 3a17bb2..044296e 100644 --- a/source/PatternMenuButton.cpp +++ b/source/PatternMenuButton.cpp @@ -7,123 +7,116 @@ #define OPEN_RAD 4 -PatternMenuButton::PatternMenuButton (BRect frame, const char *name) -: BView (frame, name, B_FOLLOW_LEFT, B_WILL_DRAW) +PatternMenuButton::PatternMenuButton(BRect frame, const char* name) + : BView(frame, name, B_FOLLOW_LEFT, B_WILL_DRAW) { - SetViewColor (B_TRANSPARENT_32_BIT); + SetViewColor(B_TRANSPARENT_32_BIT); index = 0; - strcpy (_name, name); - menu = new PatternMenu (this, P_H_NUM, P_V_NUM, P_SIZE); + strcpy(_name, name); + menu = new PatternMenu(this, P_H_NUM, P_V_NUM, P_SIZE); lock = new BLocker(); MenuWinOnScreen = false; editorshowing = false; - get_click_speed (&dcspeed); + get_click_speed(&dcspeed); click = 1; - menu->setParent (this); + menu->setParent(this); } -PatternMenuButton::~PatternMenuButton () +PatternMenuButton::~PatternMenuButton() { delete menu; delete lock; } -void PatternMenuButton::editorSaysBye () +void +PatternMenuButton::editorSaysBye() { editorshowing = false; } -void PatternMenuButton::ShowEditor () +void +PatternMenuButton::ShowEditor() { // editor = new PatternWindow (BRect (), _name, this); editorshowing = true; // editor->Show(); } -void PatternMenuButton::MouseDown (BPoint point) +void +PatternMenuButton::MouseDown(BPoint point) { -// BMenuItem *selected; -// point = BPoint (0, 0); -// ConvertToScreen (&point); -// BRect openRect = BRect (point.x - OPEN_RAD, point.y - OPEN_RAD, -// point.x + OPEN_RAD, point.y + OPEN_RAD); -// menu->Show(); -// if ((selected = menu->Track (true, &openRect)) != NULL) -// { -// index = menu->IndexOf (selected); -// menu->Mark (index); -// menu->InvalidateWindow(); -// } -// menu->Hide(); -// Invalidate(); + // BMenuItem *selected; + // point = BPoint (0, 0); + // ConvertToScreen (&point); + // BRect openRect = BRect (point.x - OPEN_RAD, point.y - OPEN_RAD, + // point.x + OPEN_RAD, point.y + OPEN_RAD); + // menu->Show(); + // if ((selected = menu->Track (true, &openRect)) != NULL) + // { + // index = menu->IndexOf (selected); + // menu->Mark (index); + // menu->InvalidateWindow(); + // } + // menu->Hide(); + // Invalidate(); Window()->Lock(); - uint32 buttons = Window()->CurrentMessage()->FindInt32 ("buttons"); -// uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); - BMenuItem *mselected; - point = BPoint (0, 0); - ConvertToScreen (&point); - if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) - { + uint32 buttons = Window()->CurrentMessage()->FindInt32("buttons"); + // uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); + BMenuItem* mselected; + point = BPoint(0, 0); + ConvertToScreen(&point); + if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) { BPoint bp, pbp; uint32 bt; - GetMouse (&pbp, &bt, true); + GetMouse(&pbp, &bt, true); bigtime_t start = system_time(); - while (system_time() - start < dcspeed) - { - snooze (20000); - GetMouse (&bp, &bt, true); - if (!bt && click != 2) - { + while (system_time() - start < dcspeed) { + snooze(20000); + GetMouse(&bp, &bt, true); + if (!bt && click != 2) { click = 0; } - if (bt && !click) - { + if (bt && !click) { click = 2; } if (bp != pbp) break; } - if (click != 2) - { - BRect openRect = BRect (point.x - OPEN_RAD, point.y - OPEN_RAD, - point.x + OPEN_RAD, point.y + OPEN_RAD); + if (click != 2) { + BRect openRect = BRect( + point.x - OPEN_RAD, point.y - OPEN_RAD, point.x + OPEN_RAD, point.y + OPEN_RAD + ); menu->Show(); - if ((mselected = menu->Track (true, &openRect)) != NULL) - { - index = menu->IndexOf (mselected); - menu->Mark (index); + if ((mselected = menu->Track(true, &openRect)) != NULL) { + index = menu->IndexOf(mselected); + menu->Mark(index); if (MenuWinOnScreen) menu->InvalidateWindow(); } menu->Hide(); - if (editorshowing) - { -// rgb_color c = color(); -// BMessage *msg = new BMessage ('SetC'); -// msg->AddInt32 ("color", c.red); -// msg->AddInt32 ("color", c.green); -// msg->AddInt32 ("color", c.blue); -// editor->PostMessage (msg); -// delete msg; + if (editorshowing) { + // rgb_color c = color(); + // BMessage *msg = new BMessage ('SetC'); + // msg->AddInt32 ("color", c.red); + // msg->AddInt32 ("color", c.green); + // msg->AddInt32 ("color", c.blue); + // editor->PostMessage (msg); + // delete msg; } click = 1; } } - if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { + if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { click = 1; - if (editorshowing) - { -// rgb_color c = color(); -// BMessage *msg = new BMessage ('SetC'); -// msg->AddInt32 ("color", c.red); -// msg->AddInt32 ("color", c.green); -// msg->AddInt32 ("color", c.blue); -// editor->PostMessage (msg); -// delete msg; - } - else - { + if (editorshowing) { + // rgb_color c = color(); + // BMessage *msg = new BMessage ('SetC'); + // msg->AddInt32 ("color", c.red); + // msg->AddInt32 ("color", c.green); + // msg->AddInt32 ("color", c.blue); + // editor->PostMessage (msg); + // delete msg; + } else { ShowEditor(); } } @@ -131,106 +124,107 @@ void PatternMenuButton::MouseDown (BPoint point) Window()->Unlock(); } -void PatternMenuButton::MessageReceived (BMessage *msg) +void +PatternMenuButton::MessageReceived(BMessage* msg) { - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); } -void PatternMenuButton::MouseMoved (BPoint point, uint32 transit, const BMessage *msg) +void +PatternMenuButton::MouseMoved(BPoint point, uint32 transit, const BMessage* msg) { point = point; msg = msg; - if (transit == B_ENTERED_VIEW) - { - BMessage *hlp = new BMessage ('chlp'); - hlp->AddString ("View", _name); - Window()->PostMessage (hlp); + if (transit == B_ENTERED_VIEW) { + BMessage* hlp = new BMessage('chlp'); + hlp->AddString("View", _name); + Window()->PostMessage(hlp); delete hlp; - } - else if (transit == B_EXITED_VIEW) - { - BMessage *hlp = new BMessage ('chlp'); - hlp->AddString ("View", ""); - Window()->PostMessage (hlp); + } else if (transit == B_EXITED_VIEW) { + BMessage* hlp = new BMessage('chlp'); + hlp->AddString("View", ""); + Window()->PostMessage(hlp); delete hlp; } } -void PatternMenuButton::Draw (BRect update) +void +PatternMenuButton::Draw(BRect update) { extern ColorMenuButton *locolor, *hicolor; rgb_color Hi = hicolor->color(); rgb_color Lo = locolor->color(); update = Bounds(); - SetHighColor (Hi); - SetLowColor (Lo); - FillRect (update, pat()); - SetHighColor (Grey8); - SetDrawingMode (B_OP_ADD); - StrokeLine (update.LeftBottom(), update.LeftTop()); - StrokeLine (update.RightTop()); - SetDrawingMode (B_OP_SUBTRACT); - StrokeLine (update.RightBottom()); - StrokeLine (update.LeftBottom()); + SetHighColor(Hi); + SetLowColor(Lo); + FillRect(update, pat()); + SetHighColor(Grey8); + SetDrawingMode(B_OP_ADD); + StrokeLine(update.LeftBottom(), update.LeftTop()); + StrokeLine(update.RightTop()); + SetDrawingMode(B_OP_SUBTRACT); + StrokeLine(update.RightBottom()); + StrokeLine(update.LeftBottom()); } -void PatternMenuButton::set (int _index) +void +PatternMenuButton::set(int _index) { if (_index >= P_SIZE) return; - + index = _index; - menu->Mark (index); - if (Window()) - { + menu->Mark(index); + if (Window()) { Window()->Lock(); Invalidate(); Window()->Unlock(); } if (MenuWinOnScreen) menu->InvalidateWindow(); - if (editorshowing) - { -// rgb_color c = color(); -// BMessage *msg = new BMessage ('SetC'); -// msg->AddInt32 ("color", c.red); -// msg->AddInt32 ("color", c.green); -// msg->AddInt32 ("color", c.blue); -// msg->AddInt32 ("alpha", c.alpha); -// editor->PostMessage (msg); -// delete msg; + if (editorshowing) { + // rgb_color c = color(); + // BMessage *msg = new BMessage ('SetC'); + // msg->AddInt32 ("color", c.red); + // msg->AddInt32 ("color", c.green); + // msg->AddInt32 ("color", c.blue); + // msg->AddInt32 ("alpha", c.alpha); + // editor->PostMessage (msg); + // delete msg; } - be_app->PostMessage ('clrX'); + be_app->PostMessage('clrX'); } -void PatternMenuButton::set (pattern _p) +void +PatternMenuButton::set(pattern _p) { - verbose (1, "PMB::set\n"); - menu->FindMarked()->setPattern (_p); + verbose(1, "PMB::set\n"); + menu->FindMarked()->setPattern(_p); Window()->Lock(); Invalidate(); Window()->Unlock(); if (MenuWinOnScreen) menu->InvalidateWindow(); - if (editorshowing) - { -// BMessage *msg = new BMessage ('SetC'); -// msg->AddInt32 ("color", c.red); -// msg->AddInt32 ("color", c.green); -// msg->AddInt32 ("color", c.blue); -// msg->AddInt32 ("alpha", c.alpha); -// editor->PostMessage (msg); -// delete msg; + if (editorshowing) { + // BMessage *msg = new BMessage ('SetC'); + // msg->AddInt32 ("color", c.red); + // msg->AddInt32 ("color", c.green); + // msg->AddInt32 ("color", c.blue); + // msg->AddInt32 ("alpha", c.alpha); + // editor->PostMessage (msg); + // delete msg; } - be_app->PostMessage ('clrX'); + be_app->PostMessage('clrX'); } -int32 PatternMenuButton::selected () +int32 +PatternMenuButton::selected() { return (index); } -pattern PatternMenuButton::pat () +pattern +PatternMenuButton::pat() { return (menu->FindMarked()->getPattern()); } \ No newline at end of file diff --git a/source/PatternMenuButton.h b/source/PatternMenuButton.h index 58ddb1b..d378a63 100644 --- a/source/PatternMenuButton.h +++ b/source/PatternMenuButton.h @@ -11,38 +11,41 @@ #define P_V_NUM 2 #define P_H_NUM 10 -#define P_SIZE 24 +#define P_SIZE 24 class PatternMenuButton : public BView { -public: - PatternMenuButton (BRect frame, const char *name); -virtual ~PatternMenuButton (); -virtual void MouseDown (BPoint point); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *msg); -virtual void Draw (BRect update); -virtual void MessageReceived (BMessage *msg); -int32 selected (); -void set (int _index); -void set (pattern _pat); -pattern pat (); -PatternMenu *getMenu () { return (menu); }; -bool IsEditorShowing () { return (editorshowing); }; -// class PatternWindow *Editor () { return (editor); }; -void ShowEditor (); -void editorSaysBye (); -BLocker *lock; -bool MenuWinOnScreen; - -private: -typedef BView inherited; -// class PatternWindow *editor; -char _name[MAX_HLPNAME]; -PatternMenu *menu; -int index; -bool editorshowing; -int click; -bigtime_t dcspeed; + public: + PatternMenuButton(BRect frame, const char* name); + virtual ~PatternMenuButton(); + virtual void MouseDown(BPoint point); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg); + virtual void Draw(BRect update); + virtual void MessageReceived(BMessage* msg); + int32 selected(); + void set(int _index); + void set(pattern _pat); + pattern pat(); + + PatternMenu* getMenu() { return (menu); }; + + bool IsEditorShowing() { return (editorshowing); }; + + // class PatternWindow *Editor () { return (editor); }; + void ShowEditor(); + void editorSaysBye(); + BLocker* lock; + bool MenuWinOnScreen; + + private: + typedef BView inherited; + // class PatternWindow *editor; + char _name[MAX_HLPNAME]; + PatternMenu* menu; + int index; + bool editorshowing; + int click; + bigtime_t dcspeed; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/PatternMenuView.cpp b/source/PatternMenuView.cpp index 151f244..2a8cea6 100644 --- a/source/PatternMenuView.cpp +++ b/source/PatternMenuView.cpp @@ -2,119 +2,108 @@ #include "PatternMenuButton.h" #include "PatternMenu.h" #include "ColorMenuButton.h" + // #include "PatternWindow.h" -PatternMenuView::PatternMenuView (BRect frame, const char *name, PatternMenuButton *cmb) -: BView (frame, name, B_FOLLOW_ALL, B_WILL_DRAW) +PatternMenuView::PatternMenuView(BRect frame, const char* name, PatternMenuButton* cmb) + : BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW) { - SetViewColor (B_TRANSPARENT_32_BIT); + SetViewColor(B_TRANSPARENT_32_BIT); fPMB = cmb; cmb->lock->Lock(); cmb->MenuWinOnScreen = true; cmb->lock->Unlock(); index = -1; - get_click_speed (&dcspeed); + get_click_speed(&dcspeed); click = 1; } -PatternMenuView::~PatternMenuView () +PatternMenuView::~PatternMenuView() { fPMB->lock->Lock(); fPMB->MenuWinOnScreen = false; fPMB->lock->Unlock(); } -void PatternMenuView::Draw (BRect /* updateRect */) +void +PatternMenuView::Draw(BRect /* updateRect */) { - if (fPMB) - { - PatternMenu *pm = fPMB->getMenu(); + if (fPMB) { + PatternMenu* pm = fPMB->getMenu(); int numitems = pm->CountItems(); - //printf ("numitems = %i, index = %i\n", numitems, index); + // printf ("numitems = %i, index = %i\n", numitems, index); extern ColorMenuButton *locolor, *hicolor; - SetLowColor (locolor->color()); - for (int i = 0; i < numitems; i++) - { - PatternItem *pmi = pm->ItemAt(i); + SetLowColor(locolor->color()); + for (int i = 0; i < numitems; i++) { + PatternItem* pmi = pm->ItemAt(i); BRect frame = pmi->Frame(); - SetHighColor (hicolor->color()); + SetHighColor(hicolor->color()); frame.left++; frame.top++; - FillRect (frame, pmi->getPattern()); + FillRect(frame, pmi->getPattern()); frame.left--; frame.top--; - SetHighColor (Black); - StrokeRect (frame); - if (pmi->IsMarked() || index == i) - { + SetHighColor(Black); + StrokeRect(frame); + if (pmi->IsMarked() || index == i) { frame.right--; frame.bottom--; - SetHighColor (White); - StrokeRect (frame); - frame.InsetBy (1, 1); - SetHighColor (Black); - StrokeRect (frame); + SetHighColor(White); + StrokeRect(frame); + frame.InsetBy(1, 1); + SetHighColor(Black); + StrokeRect(frame); } } Sync(); - } - else - { + } else { } } -void PatternMenuView::MouseDown (BPoint point) +void +PatternMenuView::MouseDown(BPoint point) { Window()->Lock(); - uint32 buttons = Window()->CurrentMessage()->FindInt32 ("buttons"); -// uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); - if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) - { - index = int (point.y/P_SIZE)*P_H_NUM + int (point.x/P_SIZE); - fPMB->set (index); + uint32 buttons = Window()->CurrentMessage()->FindInt32("buttons"); + // uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); + if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) { + index = int(point.y / P_SIZE) * P_H_NUM + int(point.x / P_SIZE); + fPMB->set(index); BPoint bp, pbp; uint32 bt; - GetMouse (&pbp, &bt, true); + GetMouse(&pbp, &bt, true); bigtime_t start = system_time(); - while (system_time() - start < dcspeed) - { - snooze (20000); - GetMouse (&bp, &bt, true); - if (!bt && click != 2) - { + while (system_time() - start < dcspeed) { + snooze(20000); + GetMouse(&bp, &bt, true); + if (!bt && click != 2) { click = 0; } - if (bt && !click) - { + if (bt && !click) { click = 2; } if (bp != pbp) break; } - if (click != 2) - { + if (click != 2) { click = 1; } } - if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { - index = int (point.y/P_SIZE)*P_H_NUM + int (point.x/P_SIZE); - fPMB->set (index); -// PatternMenu *menu = fPMB->getMenu(); + if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { + index = int(point.y / P_SIZE) * P_H_NUM + int(point.x / P_SIZE); + fPMB->set(index); + // PatternMenu *menu = fPMB->getMenu(); click = 1; - if (fPMB->IsEditorShowing()) - { -// rgb_color c = fPMB->ColorForIndex (index); -// BMessage *msg = new BMessage ('SetC'); -// msg->AddInt32 ("color", c.red); -// msg->AddInt32 ("color", c.green); -// msg->AddInt32 ("color", c.blue); -// fPMB->Editor()->PostMessage (msg); -// delete msg; - } - else - { + if (fPMB->IsEditorShowing()) { + // rgb_color c = fPMB->ColorForIndex (index); + // BMessage *msg = new BMessage ('SetC'); + // msg->AddInt32 ("color", c.red); + // msg->AddInt32 ("color", c.green); + // msg->AddInt32 ("color", c.blue); + // fPMB->Editor()->PostMessage (msg); + // delete msg; + } else { fPMB->ShowEditor(); Invalidate(); } @@ -122,29 +111,27 @@ void PatternMenuView::MouseDown (BPoint point) Window()->Unlock(); } -BRect PatternMenuView::RectForIndex (int ind) +BRect +PatternMenuView::RectForIndex(int ind) { - BRect rect = BRect (0, 0, P_SIZE - 1, P_SIZE - 1); - rect.OffsetBy (int (ind % P_H_NUM)*P_SIZE, int (ind/P_H_NUM)*P_SIZE); + BRect rect = BRect(0, 0, P_SIZE - 1, P_SIZE - 1); + rect.OffsetBy(int(ind % P_H_NUM) * P_SIZE, int(ind / P_H_NUM) * P_SIZE); return (rect); } -void PatternMenuView::MouseMoved (BPoint point, uint32 transit, const BMessage * /* msg */) +void +PatternMenuView::MouseMoved(BPoint point, uint32 transit, const BMessage* /* msg */) { int previndex = index; - if (transit == B_EXITED_VIEW) - { + if (transit == B_EXITED_VIEW) { index = -1; + } else { + index = int(point.y / P_SIZE) * P_H_NUM + int(point.x / P_SIZE); } - else - { - index = int (point.y/P_SIZE)*P_H_NUM + int (point.x/P_SIZE); - } - if (previndex != index) - { + if (previndex != index) { if (previndex != -1) - Invalidate (RectForIndex (previndex)); + Invalidate(RectForIndex(previndex)); if (index != -1) - Invalidate (RectForIndex (index)); + Invalidate(RectForIndex(index)); } } \ No newline at end of file diff --git a/source/PatternMenuView.h b/source/PatternMenuView.h index bb9d37e..2af9ab6 100644 --- a/source/PatternMenuView.h +++ b/source/PatternMenuView.h @@ -6,20 +6,20 @@ class PatternMenuView : public BView { -public: - PatternMenuView (BRect rect, const char *name, PatternMenuButton *pmb); -virtual ~PatternMenuView (); -virtual void Draw (BRect updateRect); -virtual void MouseDown (BPoint point); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *msg); -BRect RectForIndex (int ind); + public: + PatternMenuView(BRect rect, const char* name, PatternMenuButton* pmb); + virtual ~PatternMenuView(); + virtual void Draw(BRect updateRect); + virtual void MouseDown(BPoint point); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg); + BRect RectForIndex(int ind); -private: -typedef BView inherited; -PatternMenuButton *fPMB; -int index; -int click; -bigtime_t dcspeed; + private: + typedef BView inherited; + PatternMenuButton* fPMB; + int index; + int click; + bigtime_t dcspeed; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/PicItem.cpp b/source/PicItem.cpp index 3831816..b8dc4ef 100644 --- a/source/PicItem.cpp +++ b/source/PicItem.cpp @@ -2,40 +2,42 @@ #include "MainWindow.h" // Hack alert! #include "Colors.h" -PicItem::PicItem (const BPicture *_picture, AttribView *_attrib, AttribWindow *_myWindow, const char *_help) -: BMenuItem ("", NULL) +PicItem::PicItem( + const BPicture* _picture, AttribView* _attrib, AttribWindow* _myWindow, const char* _help +) + : BMenuItem("", NULL) { - picture = new BPicture (*_picture); + picture = new BPicture(*_picture); attrib = _attrib; myWindow = _myWindow; - help = new char [strlen (_help) + 1]; - strcpy (help, _help); + help = new char[strlen(_help) + 1]; + strcpy(help, _help); } -PicItem::~PicItem () +PicItem::~PicItem() { - delete [] help; + delete[] help; delete picture; } -void PicItem::Draw () -{ +void +PicItem::Draw() +{ rgb_color oldHi = Menu()->HighColor(); - if (IsSelected()) - { - Menu()->SetHighColor (Grey19); - Menu()->FillRect (Frame()); + if (IsSelected()) { + Menu()->SetHighColor(Grey19); + Menu()->FillRect(Frame()); } - if (IsMarked()) - { - Menu()->SetHighColor (Black); - Menu()->StrokeRect (Frame()); + if (IsMarked()) { + Menu()->SetHighColor(Black); + Menu()->StrokeRect(Frame()); } - Menu()->SetHighColor (oldHi); - Menu()->DrawPicture (picture, Frame().LeftTop()); + Menu()->SetHighColor(oldHi); + Menu()->DrawPicture(picture, Frame().LeftTop()); } -void PicItem::GetContentSize (float *width, float *height) +void +PicItem::GetContentSize(float* width, float* height) { // *** Hack! *width = 0; diff --git a/source/PicItem.h b/source/PicItem.h index c079d65..58d7361 100644 --- a/source/PicItem.h +++ b/source/PicItem.h @@ -10,25 +10,32 @@ class PicItem : public BMenuItem { -public: - PicItem (const BPicture *_picture, AttribView *_attrib, AttribWindow *_myWindow, const char *_help); -virtual ~PicItem (); -BPicture *getPicture () { return picture; }; -AttribView *getAttrib () { return attrib; }; -const char *helptext () { return help; }; -AttribWindow *getMyWindow () { return myWindow; }; -virtual void Draw (); - - -protected: -virtual void GetContentSize (float *width, float *height); - -private: -typedef BMenuItem inherited; -char *help; -BPicture *picture; -AttribView *attrib; -AttribWindow *myWindow; + public: + PicItem( + const BPicture* _picture, AttribView* _attrib, AttribWindow* _myWindow, const char* _help + ); + virtual ~PicItem(); + + BPicture* getPicture() { return picture; }; + + AttribView* getAttrib() { return attrib; }; + + const char* helptext() { return help; }; + + AttribWindow* getMyWindow() { return myWindow; }; + + virtual void Draw(); + + + protected: + virtual void GetContentSize(float* width, float* height); + + private: + typedef BMenuItem inherited; + char* help; + BPicture* picture; + AttribView* attrib; + AttribWindow* myWindow; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/PicMenu.cpp b/source/PicMenu.cpp index 68e3c33..4458802 100644 --- a/source/PicMenu.cpp +++ b/source/PicMenu.cpp @@ -2,7 +2,7 @@ #include "PicItem.h" #include "PicMenuView.h" #include "BitmapView.h" -#include "BecassoAddOn.h" // for some defines +#include "BecassoAddOn.h" // for some defines #include #include #include @@ -11,125 +11,125 @@ #include #include "Settings.h" -PicMenu::PicMenu (const char *name, BView *_view, int h, int v, float s) -: BMenu (name, h*s, v*s) +PicMenu::PicMenu(const char* name, BView* _view, int h, int v, float s) : BMenu(name, h * s, v * s) { marked = 0; numitems = 0; parent = NULL; fWindow = NULL; view = _view; - hs = h*s; - vs = v*s; + hs = h * s; + vs = v * s; hnum = h; - strcpy (kind, name); + strcpy(kind, name); } -PicMenu::~PicMenu () -{ -} +PicMenu::~PicMenu() {} -void PicMenu::setParent (PicMenuButton *pmb) +void +PicMenu::setParent(PicMenuButton* pmb) { parent = pmb; - + // Now is also a good time to put the tear-off window on screen // (if the app last quit that way) - if (!fWindow) - { + if (!fWindow) { BPoint origin; BRect place = Bounds(); - if (!strcmp (Name(), "modePU")) - origin = get_window_origin (numModeTO); - else if (!strcmp (Name(), "toolPU")) - origin = get_window_origin (numToolTO); - if (origin != InvalidPoint) - { - place.OffsetTo (origin); - TearDone (place, true); + if (!strcmp(Name(), "modePU")) + origin = get_window_origin(numModeTO); + else if (!strcmp(Name(), "toolPU")) + origin = get_window_origin(numToolTO); + if (origin != InvalidPoint) { + place.OffsetTo(origin); + TearDone(place, true); } } } -//void PicMenu::AddItem (PicItem *item) +// void PicMenu::AddItem (PicItem *item) //{ // if (index < MAX_ITEMS - 1) // items[index++] = item; // else // items[index] = item; // inherited::AddItem (item); -//} +// } // -void PicMenu::AddItem (PicItem *item, const BRect rect) +void +PicMenu::AddItem(PicItem* item, const BRect rect) { if (numitems < MAX_ITEMS - 1) items[numitems++] = item; else items[numitems] = item; - inherited::AddItem (item, rect); + inherited::AddItem(item, rect); } -void PicMenu::Mark (int _index) +void +PicMenu::Mark(int _index) { - items[marked]->SetMarked (false); + items[marked]->SetMarked(false); marked = _index; - items[marked]->SetMarked (true); + items[marked]->SetMarked(true); } -BPoint PicMenu::ScreenLocation () +BPoint +PicMenu::ScreenLocation() { BScreen screen; - BPoint currentpoint = BPoint (0, 0); - view->ConvertToScreen (¤tpoint); - currentpoint.y = min_c (currentpoint.y, screen.Frame().bottom - vs - 4); - currentpoint.x = min_c (currentpoint.x, screen.Frame().right - hs - 4); + BPoint currentpoint = BPoint(0, 0); + view->ConvertToScreen(¤tpoint); + currentpoint.y = min_c(currentpoint.y, screen.Frame().bottom - vs - 4); + currentpoint.x = min_c(currentpoint.x, screen.Frame().right - hs - 4); return (currentpoint); } #define WINVERSION -#if defined (WINVERSION) +#if defined(WINVERSION) -class picTearInfo +class picTearInfo { -public: - picTearInfo (BRect r, PicMenu *p, BView *s) : dragRect (r), parent (p), someView (s) {}; + public: + picTearInfo(BRect r, PicMenu* p, BView* s) : dragRect(r), parent(p), someView(s){}; BRect dragRect; - PicMenu *parent; - BView *someView; + PicMenu* parent; + BView* someView; }; -int32 pic_tear_drag (void *data); +int32 +pic_tear_drag(void* data); -int32 pic_tear_drag (void *data) +int32 +pic_tear_drag(void* data) { - picTearInfo *tearInfo = (picTearInfo *) data; + picTearInfo* tearInfo = (picTearInfo*)data; uint32 buttons = 1; BPoint point; - PicMenu *menu = tearInfo->parent; + PicMenu* menu = tearInfo->parent; BRect place = tearInfo->dragRect; - BView *view = tearInfo->someView; + BView* view = tearInfo->someView; // It might seem a good idea to use `menu' as the view, but // this gave errors: `Method requires owner but doesn't have one'. - delete tearInfo; // The caller doesn't do this (race condition otherwise) + delete tearInfo; // The caller doesn't do this (race condition otherwise) -// printf ("Entering loop\n"); - while (buttons) - { + // printf ("Entering loop\n"); + while (buttons) { view->Window()->Lock(); - view->GetMouse (&point, &buttons); + view->GetMouse(&point, &buttons); view->Window()->Unlock(); - snooze (50000); + snooze(50000); } -// printf ("Exited loop\n"); + // printf ("Exited loop\n"); view->Window()->Lock(); - point = view->ConvertToScreen (point); + point = view->ConvertToScreen(point); view->Window()->Unlock(); // printf ("Released at (%.0f, %.0f)\n", point.x, point.y); - place.OffsetTo (point); + place.OffsetTo(point); menu->getParent()->lock->Lock(); - menu->TearDone (place, !menu->getParent()->MenuWinOnScreen); + menu->TearDone(place, !menu->getParent()->MenuWinOnScreen); menu->getParent()->lock->Unlock(); return B_NO_ERROR; @@ -137,122 +137,115 @@ int32 pic_tear_drag (void *data) #endif -void PicMenu::MouseMoved (BPoint point, uint32 transit, const BMessage *msg) +void +PicMenu::MouseMoved(BPoint point, uint32 transit, const BMessage* msg) { msg = msg; uint32 buttons; if (!Parent()) return; - GetMouse (&point, &buttons); - if (transit == B_EXITED_VIEW && buttons) // Do the tear off thing! + GetMouse(&point, &buttons); + if (transit == B_EXITED_VIEW && buttons) // Do the tear off thing! { -#if defined (EASTER_EGG_SFX) +#if defined(EASTER_EGG_SFX) extern bool EasterEgg; - if (modifiers() & B_SHIFT_KEY && EasterEgg) - { - extern EffectsPlayer *easterEgg; + if (modifiers() & B_SHIFT_KEY && EasterEgg) { + extern EffectsPlayer* easterEgg; easterEgg->StartEffect(); } #endif - BMessage *tearmsg = new BMessage ('tear'); - BBitmap *dragmap = new BBitmap (Bounds(), B_RGBA32, true); + BMessage* tearmsg = new BMessage('tear'); + BBitmap* dragmap = new BBitmap(Bounds(), B_RGBA32, true); dragmap->Lock(); - BView *dragview = new BView (Bounds(), "temp dragmap view", B_FOLLOW_ALL, B_WILL_DRAW); - dragmap->AddChild (dragview); - dragview->SetLowColor (LightGrey); - dragview->FillRect (Bounds(), B_SOLID_LOW); - for (int i = 0; i < numitems; i++) - { + BView* dragview = new BView(Bounds(), "temp dragmap view", B_FOLLOW_ALL, B_WILL_DRAW); + dragmap->AddChild(dragview); + dragview->SetLowColor(LightGrey); + dragview->FillRect(Bounds(), B_SOLID_LOW); + for (int i = 0; i < numitems; i++) { BPoint point; - if (hnum < 2) - { + if (hnum < 2) { point.x = 1; - point.y = i*(Bounds().Width() + 1) + 1; - } - else - { + point.y = i * (Bounds().Width() + 1) + 1; + } else { // only works for 2 wide... - point.x = i & 1 ? Bounds().Width()/hnum + 1 : 1; - point.y = (i/2)*(Bounds().Width()/hnum) + 1; - } - dragview->DrawPicture (items[i]->getPicture(), point); + point.x = i & 1 ? Bounds().Width() / hnum + 1 : 1; + point.y = (i / 2) * (Bounds().Width() / hnum) + 1; + } + dragview->DrawPicture(items[i]->getPicture(), point); dragview->Sync(); } - dragview->SetHighColor (DarkGrey); - dragview->StrokeRect (Bounds()); - dragmap->RemoveChild (dragview); - bgra_pixel *bits = (bgra_pixel *) dragmap->Bits(); - for (bgra_pixel p = 0; p < dragmap->BitsLength()/4; p++) - { + dragview->SetHighColor(DarkGrey); + dragview->StrokeRect(Bounds()); + dragmap->RemoveChild(dragview); + bgra_pixel* bits = (bgra_pixel*)dragmap->Bits(); + for (bgra_pixel p = 0; p < dragmap->BitsLength() / 4; p++) { bgra_pixel pixel = *bits; *bits++ = (pixel & COLOR_MASK) | (127 << ALPHA_BPOS); } dragmap->Unlock(); delete dragview; - DragMessage (tearmsg, dragmap, B_OP_ALPHA, B_ORIGIN); + DragMessage(tearmsg, dragmap, B_OP_ALPHA, B_ORIGIN); delete tearmsg; BRect place = Bounds(); - + // Send a fake Esc keydown to the popup char kbuf[2]; - BMessage kmsg (B_KEY_DOWN); - kmsg.AddInt64 ("when", system_time()); - kmsg.AddInt32 ("modifiers", 0); - kmsg.AddInt32 ("key", B_ESCAPE); - kmsg.AddInt8 ("byte", B_ESCAPE); + BMessage kmsg(B_KEY_DOWN); + kmsg.AddInt64("when", system_time()); + kmsg.AddInt32("modifiers", 0); + kmsg.AddInt32("key", B_ESCAPE); + kmsg.AddInt8("byte", B_ESCAPE); kbuf[0] = B_ESCAPE; kbuf[1] = '\0'; - kmsg.AddString ("bytes", kbuf); - Window()->PostMessage (&kmsg, this); + kmsg.AddString("bytes", kbuf); + Window()->PostMessage(&kmsg, this); // This makes the original popup go away. // We can't use Hide() since that crashes. - - picTearInfo *tearInfo = new picTearInfo (place, this, parent); - resume_thread (spawn_thread (pic_tear_drag, "Menu Tear Thread", B_NORMAL_PRIORITY, tearInfo)); + + picTearInfo* tearInfo = new picTearInfo(place, this, parent); + resume_thread(spawn_thread(pic_tear_drag, "Menu Tear Thread", B_NORMAL_PRIORITY, tearInfo)); } } -void PicMenu::TearDone (BRect place, bool newwin) +void +PicMenu::TearDone(BRect place, bool newwin) { - if (newwin) - { - fWindow = new DragWindow (Name(), place, MENU_WIN_TITLE); + if (newwin) { + fWindow = new DragWindow(Name(), place, MENU_WIN_TITLE); BRect mvRect = Bounds(); // mvRect.OffsetBy (0, PW_TABSIZE + 1); - PicMenuView *mv = new PicMenuView (mvRect, hnum, "MenuView", parent); - fWindow->AddChild (mv); + PicMenuView* mv = new PicMenuView(mvRect, hnum, "MenuView", parent); + fWindow->AddChild(mv); fWindow->Show(); - } - else - { - fWindow->MoveTo (place.LeftTop()); + } else { + fWindow->MoveTo(place.LeftTop()); fWindow->Activate(); } } -void PicMenu::MessageReceived (BMessage *msg) +void +PicMenu::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case 'tear': - { + switch (msg->what) { + case 'tear': { break; } default: // msg->PrintToStream(); - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); } } -PicItem *PicMenu::FindMarked () +PicItem* +PicMenu::FindMarked() { - return items[marked]; //IndexOf (inherited::FindMarked())]; + return items[marked]; // IndexOf (inherited::FindMarked())]; } -void PicMenu::InvalidateWindow () +void +PicMenu::InvalidateWindow() { - if (fWindow) - { + if (fWindow) { fWindow->Lock(); fWindow->ChildAt(0)->Invalidate(); fWindow->UpdateIfNeeded(); diff --git a/source/PicMenu.h b/source/PicMenu.h index 7bff812..0c9b5cc 100644 --- a/source/PicMenu.h +++ b/source/PicMenu.h @@ -16,38 +16,43 @@ class PicMenuButton; class PicMenu : public BMenu { -friend class PicMenuButton; -public: - PicMenu (const char *name, BView *_view, int h, int v, float s); -virtual ~PicMenu (); -//virtual void AddItem (PicItem *item); -virtual void AddItem (PicItem *item, const BRect rect); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *msg); -virtual void MessageReceived (BMessage *msg); -PicItem *FindMarked (); -PicItem *ItemAt (int ind) { return items[ind]; }; -virtual void Mark (int _index); -long Selected (); -void setParent (PicMenuButton *pmb); -PicMenuButton *getParent () { return parent; }; -void TearDone (BRect place, bool newwin); -void InvalidateWindow (); - -protected: -virtual BPoint ScreenLocation (); - -private: -typedef BMenu inherited; -DragWindow *fWindow; -PicItem *items[MAX_ITEMS]; -int32 marked; -int32 numitems; -PicMenuButton *parent; -SoundEffect8_11 *fxTear; -BView *view; -float hs, vs; -int hnum; -char kind[64]; + friend class PicMenuButton; + + public: + PicMenu(const char* name, BView* _view, int h, int v, float s); + virtual ~PicMenu(); + // virtual void AddItem (PicItem *item); + virtual void AddItem(PicItem* item, const BRect rect); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg); + virtual void MessageReceived(BMessage* msg); + PicItem* FindMarked(); + + PicItem* ItemAt(int ind) { return items[ind]; }; + + virtual void Mark(int _index); + long Selected(); + void setParent(PicMenuButton* pmb); + + PicMenuButton* getParent() { return parent; }; + + void TearDone(BRect place, bool newwin); + void InvalidateWindow(); + + protected: + virtual BPoint ScreenLocation(); + + private: + typedef BMenu inherited; + DragWindow* fWindow; + PicItem* items[MAX_ITEMS]; + int32 marked; + int32 numitems; + PicMenuButton* parent; + SoundEffect8_11* fxTear; + BView* view; + float hs, vs; + int hnum; + char kind[64]; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/PicMenuButton.cpp b/source/PicMenuButton.cpp index 3781ac3..e8a1509 100644 --- a/source/PicMenuButton.cpp +++ b/source/PicMenuButton.cpp @@ -4,7 +4,7 @@ #include #include #include "PicItem.h" -#include "MainWindow.h" // Hack alert! +#include "MainWindow.h" // Hack alert! #include "AttribView.h" #include "AttribWindow.h" #include "Colors.h" @@ -12,181 +12,175 @@ #define OPEN_RAD 4 -PicMenuButton::PicMenuButton (BRect frame, const char *name, BPicture *p) -: BPictureButton (frame, name, p, p, NULL) +PicMenuButton::PicMenuButton(BRect frame, const char* name, BPicture* p) + : BPictureButton(frame, name, p, p, NULL) { - SetViewColor (B_TRANSPARENT_32_BIT); + SetViewColor(B_TRANSPARENT_32_BIT); index = 0; - strcpy (_name, name); - get_click_speed (&dcspeed); + strcpy(_name, name); + get_click_speed(&dcspeed); click = 1; lock = new BLocker(); MenuWinOnScreen = false; menu = 0; -// printf ("PicMenuButton::ctor done\n"); + // printf ("PicMenuButton::ctor done\n"); } -PicMenuButton::~PicMenuButton () +PicMenuButton::~PicMenuButton() { delete menu; delete lock; } -void PicMenuButton::AddItem (PicMenu *_m) +void +PicMenuButton::AddItem(PicMenu* _m) { menu = _m; - menu->setParent (this); + menu->setParent(this); } -void PicMenuButton::Draw (BRect update) +void +PicMenuButton::Draw(BRect update) { -// printf ("PicMenuButton::Draw\n"); + // printf ("PicMenuButton::Draw\n"); update = Bounds(); - SetLowColor (LightGrey); - FillRect (update, B_SOLID_LOW); - inherited::Draw (update); - SetHighColor (Grey31); - StrokeLine (update.LeftBottom(), - BPoint (update.left, update.top)); - StrokeLine (BPoint (update.right - 1, update.top)); - SetHighColor (DarkGrey); - StrokeLine (BPoint (update.right - 1, update.bottom)); - SetHighColor (Grey23); - StrokeLine (update.LeftBottom()); + SetLowColor(LightGrey); + FillRect(update, B_SOLID_LOW); + inherited::Draw(update); + SetHighColor(Grey31); + StrokeLine(update.LeftBottom(), BPoint(update.left, update.top)); + StrokeLine(BPoint(update.right - 1, update.top)); + SetHighColor(DarkGrey); + StrokeLine(BPoint(update.right - 1, update.bottom)); + SetHighColor(Grey23); + StrokeLine(update.LeftBottom()); } -void PicMenuButton::MouseDown (BPoint point) +void +PicMenuButton::MouseDown(BPoint point) { Window()->Lock(); - uint32 buttons = Window()->CurrentMessage()->FindInt32 ("buttons"); -// uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); - if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) - { + uint32 buttons = Window()->CurrentMessage()->FindInt32("buttons"); + // uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); + if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) { BPoint bp, pbp; uint32 bt; - GetMouse (&pbp, &bt, true); + GetMouse(&pbp, &bt, true); bigtime_t start = system_time(); - while (system_time() - start < dcspeed) - { - snooze (20000); - GetMouse (&bp, &bt, true); - if (!bt && click != 2) - { + while (system_time() - start < dcspeed) { + snooze(20000); + GetMouse(&bp, &bt, true); + if (!bt && click != 2) { click = 0; } - if (bt && !click) - { + if (bt && !click) { click = 2; } if (bp != pbp) break; } - if (click != 2) - { - BMenuItem *mselected; - point = BPoint (0, -index*(BUTTON_SIZE + 3)); // Hack! - ConvertToScreen (&point); - BRect openRect = BRect (point.x - OPEN_RAD, point.y - OPEN_RAD, - point.x + OPEN_RAD, point.y + OPEN_RAD); + if (click != 2) { + BMenuItem* mselected; + point = BPoint(0, -index * (BUTTON_SIZE + 3)); // Hack! + ConvertToScreen(&point); + BRect openRect = BRect( + point.x - OPEN_RAD, point.y - OPEN_RAD, point.x + OPEN_RAD, point.y + OPEN_RAD + ); menu->Show(); - if ((mselected = menu->Track (true, &openRect)) != NULL) - { - index = menu->IndexOf (mselected); - set (index); + if ((mselected = menu->Track(true, &openRect)) != NULL) { + index = menu->IndexOf(mselected); + set(index); // menu->Mark (index); if (MenuWinOnScreen) menu->InvalidateWindow(); -// mselected->SetMarked (true); -// SetEnabledOn (menu->FindMarked()->getPicture()); -// SetEnabledOff (menu->FindMarked()->getPicture()); -// index = menu->IndexOf (mselected); -// AttribWindow *aWindow = menu->FindMarked()->getMyWindow(); -// aWindow->Lock(); -// aWindow->RaiseView (index); -// aWindow->Unlock(); -// if (MenuWinOnScreen) -// { -// menu->InvalidateWindow(); -// } + // mselected->SetMarked (true); + // SetEnabledOn (menu->FindMarked()->getPicture()); + // SetEnabledOff (menu->FindMarked()->getPicture()); + // index = menu->IndexOf (mselected); + // AttribWindow *aWindow = menu->FindMarked()->getMyWindow(); + // aWindow->Lock(); + // aWindow->RaiseView (index); + // aWindow->Unlock(); + // if (MenuWinOnScreen) + // { + // menu->InvalidateWindow(); + // } } menu->Hide(); Invalidate(); click = 1; } } - if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { + if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { click = 1; - AttribWindow *aWindow = menu->FindMarked()->getMyWindow(); + AttribWindow* aWindow = menu->FindMarked()->getMyWindow(); aWindow->Lock(); - if (aWindow->IsHidden()) - { + if (aWindow->IsHidden()) { aWindow->Show(); - } - else - { + } else { aWindow->Activate(); } aWindow->Unlock(); } - const char *ht = menu->FindMarked()->helptext(); - char *helpstring = new char [strlen (ht) + strlen (_name) + 2]; - strcpy (helpstring, menu->FindMarked()->helptext()); - strcat (helpstring, " "); - strcat (helpstring, _name); - BMessage hlp ('chlp'); - hlp.AddString ("View", helpstring); - Window()->PostMessage (&hlp); - delete [] helpstring; + const char* ht = menu->FindMarked()->helptext(); + char* helpstring = new char[strlen(ht) + strlen(_name) + 2]; + strcpy(helpstring, menu->FindMarked()->helptext()); + strcat(helpstring, " "); + strcat(helpstring, _name); + BMessage hlp('chlp'); + hlp.AddString("View", helpstring); + Window()->PostMessage(&hlp); + delete[] helpstring; Window()->Unlock(); } -void PicMenuButton::MouseMoved (BPoint point, uint32 transit, const BMessage *msg) +void +PicMenuButton::MouseMoved(BPoint point, uint32 transit, const BMessage* msg) { point = point; msg = msg; - if (transit == B_ENTERED_VIEW) - { - char helpstring[2*MAX_HLPNAME]; - strcpy (helpstring, menu->FindMarked()->helptext()); - strcat (helpstring, " "); - strcat (helpstring, _name); - BMessage *hlp = new BMessage ('chlp'); - hlp->AddString ("View", helpstring); - Window()->PostMessage (hlp); + if (transit == B_ENTERED_VIEW) { + char helpstring[2 * MAX_HLPNAME]; + strcpy(helpstring, menu->FindMarked()->helptext()); + strcat(helpstring, " "); + strcat(helpstring, _name); + BMessage* hlp = new BMessage('chlp'); + hlp->AddString("View", helpstring); + Window()->PostMessage(hlp); delete hlp; - } - else if (transit == B_EXITED_VIEW) - { - BMessage *hlp = new BMessage ('chlp'); - hlp->AddString ("View", ""); - Window()->PostMessage (hlp); + } else if (transit == B_EXITED_VIEW) { + BMessage* hlp = new BMessage('chlp'); + hlp->AddString("View", ""); + Window()->PostMessage(hlp); delete hlp; } } -void PicMenuButton::MessageReceived (BMessage *msg) +void +PicMenuButton::MessageReceived(BMessage* msg) { -// msg->PrintToStream(); - inherited::MessageReceived (msg); + // msg->PrintToStream(); + inherited::MessageReceived(msg); } -int32 PicMenuButton::selected () +int32 +PicMenuButton::selected() { return (index); } -void PicMenuButton::set (int32 ind) +void +PicMenuButton::set(int32 ind) { index = ind; - menu->Mark (index); - BPicture *pic = menu->FindMarked()->getPicture(); - SetEnabledOff (pic); - SetEnabledOn (pic); - AttribWindow *aWindow = menu->FindMarked()->getMyWindow(); + menu->Mark(index); + BPicture* pic = menu->FindMarked()->getPicture(); + SetEnabledOff(pic); + SetEnabledOn(pic); + AttribWindow* aWindow = menu->FindMarked()->getMyWindow(); aWindow->Lock(); - aWindow->RaiseView (index); + aWindow->RaiseView(index); aWindow->Unlock(); Window()->Lock(); Invalidate(); diff --git a/source/PicMenuButton.h b/source/PicMenuButton.h index 5557aab..3c65079 100644 --- a/source/PicMenuButton.h +++ b/source/PicMenuButton.h @@ -10,27 +10,29 @@ class PicMenuButton : public BPictureButton { -public: - PicMenuButton (BRect frame, const char *name, BPicture *p); -virtual ~PicMenuButton (); -virtual void AddItem (PicMenu *_menu); -virtual void MouseDown (BPoint point); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *msg); -virtual void MessageReceived (BMessage *msg); -virtual void Draw (BRect update); -int32 selected (); -void set (int32 ind); -PicMenu *getMenu () { return (menu); }; -BLocker *lock; -bool MenuWinOnScreen; + public: + PicMenuButton(BRect frame, const char* name, BPicture* p); + virtual ~PicMenuButton(); + virtual void AddItem(PicMenu* _menu); + virtual void MouseDown(BPoint point); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg); + virtual void MessageReceived(BMessage* msg); + virtual void Draw(BRect update); + int32 selected(); + void set(int32 ind); -private: -typedef BPictureButton inherited; -PicMenu *menu; -int32 index; -char _name[MAX_HLPNAME]; -int click; -bigtime_t dcspeed; + PicMenu* getMenu() { return (menu); }; + + BLocker* lock; + bool MenuWinOnScreen; + + private: + typedef BPictureButton inherited; + PicMenu* menu; + int32 index; + char _name[MAX_HLPNAME]; + int click; + bigtime_t dcspeed; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/PicMenuView.cpp b/source/PicMenuView.cpp index 7d30435..3c36e9c 100644 --- a/source/PicMenuView.cpp +++ b/source/PicMenuView.cpp @@ -2,152 +2,142 @@ #include "PicMenu.h" #include -PicMenuView::PicMenuView (BRect frame, int _hnum, const char *name, PicMenuButton *pmb) -: BView (frame, name, B_FOLLOW_ALL, B_WILL_DRAW) +PicMenuView::PicMenuView(BRect frame, int _hnum, const char* name, PicMenuButton* pmb) + : BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW) { - SetViewColor (B_TRANSPARENT_32_BIT); + SetViewColor(B_TRANSPARENT_32_BIT); fPMB = pmb; pmb->lock->Lock(); pmb->MenuWinOnScreen = true; pmb->lock->Unlock(); - SetViewColor (LightGrey); + SetViewColor(LightGrey); index = -1; - get_click_speed (&dcspeed); + get_click_speed(&dcspeed); click = 1; hnum = _hnum; } -PicMenuView::~PicMenuView () +PicMenuView::~PicMenuView() { -// printf ("~MenuView\n"); + // printf ("~MenuView\n"); fPMB->lock->Lock(); fPMB->MenuWinOnScreen = false; fPMB->lock->Unlock(); } -void PicMenuView::Draw (BRect updateRect) +void +PicMenuView::Draw(BRect updateRect) { updateRect = updateRect; - if (fPMB) - { - float bw = Bounds().Width()/hnum; + if (fPMB) { + float bw = Bounds().Width() / hnum; BRect thisbutton; - PicMenu *pm = fPMB->getMenu(); + PicMenu* pm = fPMB->getMenu(); int numitems = pm->CountItems(); - //printf ("numitems = %i, index = %i\n", numitems, index); - for (int i = 0; i < numitems; i++) - { - thisbutton.Set ((i%hnum)*bw, (i/hnum)*bw, (i%hnum + 1)*bw, (i/hnum + 1)*bw); - SetLowColor (LightGrey); - SetHighColor (DarkGrey); - FillRect (thisbutton, index == i ? B_SOLID_HIGH : B_SOLID_LOW); - PicItem *pmi = pm->ItemAt(i); - BPicture *p = pmi->getPicture(); - DrawPicture (p, thisbutton.LeftTop()); - if (pmi->IsMarked()) - { - SetHighColor (Black); - StrokeRect (pmi->Frame()); + // printf ("numitems = %i, index = %i\n", numitems, index); + for (int i = 0; i < numitems; i++) { + thisbutton.Set( + (i % hnum) * bw, (i / hnum) * bw, (i % hnum + 1) * bw, (i / hnum + 1) * bw + ); + SetLowColor(LightGrey); + SetHighColor(DarkGrey); + FillRect(thisbutton, index == i ? B_SOLID_HIGH : B_SOLID_LOW); + PicItem* pmi = pm->ItemAt(i); + BPicture* p = pmi->getPicture(); + DrawPicture(p, thisbutton.LeftTop()); + if (pmi->IsMarked()) { + SetHighColor(Black); + StrokeRect(pmi->Frame()); } Sync(); } - } - else - { + } else { } } -void PicMenuView::MouseMoved (BPoint point, uint32 transit, const BMessage *msg) +void +PicMenuView::MouseMoved(BPoint point, uint32 transit, const BMessage* msg) { msg = msg; int previndex = index; - float bw = Bounds().Width()/hnum + 1; - PicMenu *menu = fPMB->getMenu(); - if (transit == B_EXITED_VIEW) - { + float bw = Bounds().Width() / hnum + 1; + PicMenu* menu = fPMB->getMenu(); + if (transit == B_EXITED_VIEW) { index = -1; - BMessage *hlp = new BMessage ('chlp'); - hlp->AddString ("View", ""); - fPMB->Window()->PostMessage (hlp); + BMessage* hlp = new BMessage('chlp'); + hlp->AddString("View", ""); + fPMB->Window()->PostMessage(hlp); delete hlp; - } - else - { - index = int (point.y/bw)*hnum + int (point.x/bw); - char helpstring[2*MAX_HLPNAME]; - strcpy (helpstring, menu->ItemAt(index)->helptext()); - strcat (helpstring, " "); - strcat (helpstring, fPMB->Name()); - BMessage *hlp = new BMessage ('chlp'); - hlp->AddString ("View", helpstring); - fPMB->Window()->PostMessage (hlp); + } else { + index = int(point.y / bw) * hnum + int(point.x / bw); + char helpstring[2 * MAX_HLPNAME]; + strcpy(helpstring, menu->ItemAt(index)->helptext()); + strcat(helpstring, " "); + strcat(helpstring, fPMB->Name()); + BMessage* hlp = new BMessage('chlp'); + hlp->AddString("View", helpstring); + fPMB->Window()->PostMessage(hlp); delete hlp; } - if (previndex != index) - { + if (previndex != index) { if (previndex != -1) - Invalidate (RectForIndex (previndex)); + Invalidate(RectForIndex(previndex)); if (index != -1) - Invalidate (RectForIndex (index)); + Invalidate(RectForIndex(index)); } } -BRect PicMenuView::RectForIndex (int i) +BRect +PicMenuView::RectForIndex(int i) { - float bw = Bounds().Width()/hnum; - return BRect ((i % hnum)*bw, (i/hnum)*bw, (i % hnum + 1)*bw - 1, (i/hnum + 1)*bw - 1); + float bw = Bounds().Width() / hnum; + return BRect( + (i % hnum) * bw, (i / hnum) * bw, (i % hnum + 1) * bw - 1, (i / hnum + 1) * bw - 1 + ); } -void PicMenuView::MouseDown (BPoint point) +void +PicMenuView::MouseDown(BPoint point) { Window()->Lock(); - uint32 buttons = Window()->CurrentMessage()->FindInt32 ("buttons"); -// uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); - if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) - { - float bw = Bounds().Width()/hnum + 1; - index = int (point.y/bw)*hnum + int (point.x/bw); - fPMB->set (index); + uint32 buttons = Window()->CurrentMessage()->FindInt32("buttons"); + // uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); + if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) { + float bw = Bounds().Width() / hnum + 1; + index = int(point.y / bw) * hnum + int(point.x / bw); + fPMB->set(index); BPoint bp, pbp; uint32 bt; - GetMouse (&pbp, &bt, true); + GetMouse(&pbp, &bt, true); bigtime_t start = system_time(); - while (system_time() - start < dcspeed) - { - snooze (20000); - GetMouse (&bp, &bt, true); - if (!bt && click != 2) - { + while (system_time() - start < dcspeed) { + snooze(20000); + GetMouse(&bp, &bt, true); + if (!bt && click != 2) { click = 0; } - if (bt && !click) - { + if (bt && !click) { click = 2; } if (bp != pbp) break; } - if (click != 2) - { + if (click != 2) { click = 1; } } - if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { - float bw = Bounds().Width()/hnum + 1; - index = int (point.y/bw)*hnum + int (point.x/bw); - fPMB->set (index); + if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { + float bw = Bounds().Width() / hnum + 1; + index = int(point.y / bw) * hnum + int(point.x / bw); + fPMB->set(index); click = 1; - PicMenu *menu = fPMB->getMenu(); - AttribWindow *aWindow = menu->FindMarked()->getMyWindow(); + PicMenu* menu = fPMB->getMenu(); + AttribWindow* aWindow = menu->FindMarked()->getMyWindow(); aWindow->Lock(); - if (aWindow->IsHidden()) - { + if (aWindow->IsHidden()) { aWindow->Show(); - } - else - { + } else { aWindow->Activate(); } aWindow->Unlock(); diff --git a/source/PicMenuView.h b/source/PicMenuView.h index 1c9d17d..34c8ad7 100644 --- a/source/PicMenuView.h +++ b/source/PicMenuView.h @@ -6,22 +6,22 @@ class PicMenuView : public BView { -public: - PicMenuView (BRect rect, int _hnum, const char *name, PicMenuButton *pmb); -virtual ~PicMenuView (); -virtual void Draw (BRect updateRect); -virtual void MouseMoved (BPoint point, uint32 transit, const BMessage *msg); -virtual void MouseDown (BPoint point); + public: + PicMenuView(BRect rect, int _hnum, const char* name, PicMenuButton* pmb); + virtual ~PicMenuView(); + virtual void Draw(BRect updateRect); + virtual void MouseMoved(BPoint point, uint32 transit, const BMessage* msg); + virtual void MouseDown(BPoint point); -private: -BRect RectForIndex (int i); + private: + BRect RectForIndex(int i); -typedef BView inherited; -PicMenuButton *fPMB; -int index; -int click; -int hnum; -bigtime_t dcspeed; + typedef BView inherited; + PicMenuButton* fPMB; + int index; + int click; + int hnum; + bigtime_t dcspeed; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/PointStack.cpp b/source/PointStack.cpp index 92e854f..a7f2ee5 100644 --- a/source/PointStack.cpp +++ b/source/PointStack.cpp @@ -2,14 +2,14 @@ #include #include -PointStack::PointStack () +PointStack::PointStack() { bot = 0; top = 0; stack = new LPoint[MAXPOINTSTACK]; } -PointStack::PointStack (LPoint p) +PointStack::PointStack(LPoint p) { top = 1; bot = 0; @@ -17,35 +17,34 @@ PointStack::PointStack (LPoint p) stack[0] = p; } -PointStack::~PointStack () -{ - delete [] stack; -} +PointStack::~PointStack() { delete[] stack; } -bool PointStack::push (LPoint point) +bool +PointStack::push(LPoint point) { top %= MAXPOINTSTACK; stack[top++] = point; return (true); -// NOTE: This version _doesn't_ check whether the stack -// is full... This is potentially dangerous for -// large area fills. + // NOTE: This version _doesn't_ check whether the stack + // is full... This is potentially dangerous for + // large area fills. } -LPoint PointStack::pop () +LPoint +PointStack::pop() { bot %= MAXPOINTSTACK; - if (bot == top) - { - fprintf (stderr, "PointStack: Popping from empty stack!\n"); - exit (1); + if (bot == top) { + fprintf(stderr, "PointStack: Popping from empty stack!\n"); + exit(1); } return stack[bot++]; } -bool PointStack::isempty () +bool +PointStack::isempty() { return (bot == top); } diff --git a/source/PointStack.h b/source/PointStack.h index 7db337e..9b6cac0 100644 --- a/source/PointStack.h +++ b/source/PointStack.h @@ -5,13 +5,24 @@ class LPoint { -public: - LPoint () {}; - LPoint (long _x, long _y) { x = _x; y = _y; }; - LPoint (BPoint p) { x = long (p.x); y = long (p.y); }; - ~LPoint () {}; - long x; - long y; + public: + LPoint(){}; + + LPoint(long _x, long _y) + { + x = _x; + y = _y; + }; + + LPoint(BPoint p) + { + x = long(p.x); + y = long(p.y); + }; + + ~LPoint(){}; + long x; + long y; }; #define MAXPOINTSTACK 1024 @@ -20,18 +31,18 @@ class LPoint class PointStack { -public: - PointStack (); - PointStack (LPoint p); - ~PointStack (); - bool push (LPoint point); - LPoint pop (); - bool isempty (); - -private: - LPoint *stack; + public: + PointStack(); + PointStack(LPoint p); + ~PointStack(); + bool push(LPoint point); + LPoint pop(); + bool isempty(); + + private: + LPoint* stack; int bot; int top; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/PosView.cpp b/source/PosView.cpp index 30f1f41..9bdc323 100644 --- a/source/PosView.cpp +++ b/source/PosView.cpp @@ -1,12 +1,11 @@ #include "PosView.h" #include "CanvasWindow.h" -PosView::PosView (const BRect frame, const char *name, - CanvasView *_canvas) - : BView (frame, name, B_FOLLOW_BOTTOM, B_WILL_DRAW | B_PULSE_NEEDED) +PosView::PosView(const BRect frame, const char* name, CanvasView* _canvas) + : BView(frame, name, B_FOLLOW_BOTTOM, B_WILL_DRAW | B_PULSE_NEEDED) { - SetViewColor (LightGrey); - SetFont (be_plain_font); + SetViewColor(LightGrey); + SetFont(be_plain_font); mouse_x = 0; mouse_y = 0; delta_x = 0; @@ -18,72 +17,100 @@ PosView::PosView (const BRect frame, const char *name, canvas = _canvas; } -void PosView::Pulse () +void +PosView::Pulse() { uint32 buttons; BPoint pos; - GetMouse (&pos, &buttons, false); - pos = canvas->ConvertFromScreen (ConvertToScreen (pos)); - if (pos != prev) - { - mouse_x = int (pos.x / canvas->getScale()); - mouse_y = int (pos.y / canvas->getScale()); - Draw (Bounds()); + GetMouse(&pos, &buttons, false); + pos = canvas->ConvertFromScreen(ConvertToScreen(pos)); + if (pos != prev) { + mouse_x = int(pos.x / canvas->getScale()); + mouse_y = int(pos.y / canvas->getScale()); + Draw(Bounds()); prev = pos; } } -void PosView::SetPoint (const int x, const int y) +void +PosView::SetPoint(const int x, const int y) { set_x = x; set_y = y; if (x == y == -1) - DoRadius (false); + DoRadius(false); Invalidate(); } -void PosView::DoRadius (const bool r) +void +PosView::DoRadius(const bool r) { do_radius = r; } -void PosView::SetTextLayer (const bool t) +void +PosView::SetTextLayer(const bool t) { is_textlayer = t; } -void PosView::Draw (BRect /* updaterect */) +void +PosView::Draw(BRect /* updaterect */) { - SetLowColor (LightGrey); - SetHighColor (DarkGrey); - FillRect (Bounds(), B_SOLID_LOW); - StrokeRect (Bounds()); - SetHighColor (Grey31); - StrokeLine (Bounds().LeftTop() + BPoint (1, 1), - Bounds().RightTop() + BPoint (-1, 1)); - if (canvas->Bounds().Contains (BPoint (mouse_x*canvas->getScale(), mouse_y*canvas->getScale())) - && (Window()->IsActive())) - SetHighColor (Black); + SetLowColor(LightGrey); + SetHighColor(DarkGrey); + FillRect(Bounds(), B_SOLID_LOW); + StrokeRect(Bounds()); + SetHighColor(Grey31); + StrokeLine(Bounds().LeftTop() + BPoint(1, 1), Bounds().RightTop() + BPoint(-1, 1)); + if (canvas->Bounds().Contains(BPoint(mouse_x * canvas->getScale(), mouse_y * canvas->getScale()) + ) && + (Window()->IsActive())) + SetHighColor(Black); else - SetHighColor (DarkGrey); - SetFont (be_plain_font); - SetFontSize (9); - char s[32]; - if (set_x >= 0) - { + SetHighColor(DarkGrey); + + SetFont(be_plain_font); + SetFontSize(9); + BString deltaXData; + BString deltaYData; + BString mouseXData; + BString mouseYData; + BString radiusValue; + BString plusSign = BString("+"); + BString positionString; + fNumberFormat.Format(mouseXData, mouse_x); + fNumberFormat.Format(mouseYData, mouse_y); + if (set_x >= 0) { int delta_x = mouse_x - set_x; int delta_y = mouse_y - set_y; - if (do_radius) - sprintf (s, "(%i,%i)∆(%s%i,%s%i) %.1f", mouse_x, mouse_y, delta_x > 0 ? "+" : "", delta_x, delta_y > 0 ? "+" : "", delta_y, sqrt (delta_x*delta_x + delta_y*delta_y)); - else - sprintf (s, "(%i,%i) ∆(%s%i,%s%i)", mouse_x, mouse_y, delta_x > 0 ? "+" : "", delta_x, delta_y > 0 ? "+" : "", delta_y); + fNumberFormat.Format(deltaXData, delta_x); + fNumberFormat.Format(deltaYData, delta_y); + fNumberFormat.SetPrecision(1); + fNumberFormat.Format(radiusValue, sqrt(delta_x * delta_x + delta_y * delta_y)); + if (do_radius) { + positionString.SetToFormat( + "(%s, %s) ∆ (%s%s, %s%s) %s", mouseXData.String(), mouseYData.String(), + (delta_x > 0 ? plusSign.String() : ""), deltaXData.String(), + (delta_y > 0 ? plusSign.String() : ""), deltaYData.String(), radiusValue.String() + ); + } else { + positionString.SetToFormat( + "(%s, %s) ∆ (%s%s, %s%s)", mouseXData.String(), mouseYData.String(), + (delta_x > 0 ? plusSign.String() : ""), deltaXData.String(), + (delta_y > 0 ? plusSign.String() : ""), deltaYData.String() + ); + } + } else { + positionString.SetToFormat("(%s, %s)", mouseXData.String(), mouseYData.String()); } - else - sprintf (s, "(%i, %i)", mouse_x, mouse_y); - DrawString (s, BPoint ((POSWIDTH - StringWidth (s))/2, 11)); -// if (is_textlayer) -// { -// SetFontSize (12); -// DrawString ("T", BPoint (2, 12)); -// } -} \ No newline at end of file + DrawString( + positionString.String(), BPoint((POSWIDTH - StringWidth(positionString.String())) / 2, 11) + ); + + // if (is_textlayer) + // { + // SetFontSize (12); + // DrawString ("T", BPoint (2, 12)); + // } +} diff --git a/source/PosView.h b/source/PosView.h index c2a5103..28b7de1 100644 --- a/source/PosView.h +++ b/source/PosView.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "CanvasView.h" #include "Colors.h" @@ -12,28 +13,29 @@ class PosView : public BView { -public: - PosView (const BRect frame, const char *name, CanvasView *_canvas); -virtual void Draw (BRect updaterect); -virtual void Pulse (); - - void SetPoint (const int x, const int y); - void DoRadius (const bool r); - void SetTextLayer (const bool t = true); + public: + PosView(const BRect frame, const char* name, CanvasView* _canvas); + virtual void Draw(BRect updaterect); + virtual void Pulse(); -private: -typedef BView inherited; -CanvasView *canvas; -int mouse_x; -int mouse_y; -int set_x; -int set_y; -int delta_x; -int delta_y; -float radius; -bool do_radius; -bool is_textlayer; -BPoint prev; + void SetPoint(const int x, const int y); + void DoRadius(const bool r); + void SetTextLayer(const bool t = true); + + private: + typedef BView inherited; + CanvasView* canvas; + int mouse_x; + int mouse_y; + int set_x; + int set_y; + int delta_x; + int delta_y; + float radius; + bool do_radius; + bool is_textlayer; + BNumberFormat fNumberFormat; + BPoint prev; }; -#endif \ No newline at end of file +#endif diff --git a/source/Position.cpp b/source/Position.cpp index f501fa4..b62350a 100644 --- a/source/Position.cpp +++ b/source/Position.cpp @@ -4,41 +4,41 @@ #if 1 -int32 position_tracker (void *data) +int32 +position_tracker(void* data) { - SView *view = (SView *) data; + SView* view = (SView*)data; Position pos; uint32 time = view->getSnoozeTime(); extern port_id position_port; - view->GetPosition (&pos); - while (pos.fProximity) - { - write_port (position_port, 'Spos', (void *) &pos, sizeof (Position)); - snooze (time); - view->GetPosition (&pos); + view->GetPosition(&pos); + while (pos.fProximity) { + write_port(position_port, 'Spos', (void*)&pos, sizeof(Position)); + snooze(time); + view->GetPosition(&pos); } - write_port (position_port, 'Lpos', (void *) &pos, sizeof (Position)); + write_port(position_port, 'Lpos', (void*)&pos, sizeof(Position)); // The last position written has its fButtons entry empty. return 0; } #else -int32 position_tracker (void *data) +int32 +position_tracker(void* data) { - CanvasView *view = (CanvasView *) data; + CanvasView* view = (CanvasView*)data; Position pos; uint32 time = view->getSnoozeTime(); extern port_id position_port; - view->GetPosition (&pos); - BMessage *pm = new BMessage (); - while (pos.fProximity) - { - write_port (position_port, 'Spos', (void *) &pos, sizeof (Position)); - snooze (time); - view->GetPosition (&pos); + view->GetPosition(&pos); + BMessage* pm = new BMessage(); + while (pos.fProximity) { + write_port(position_port, 'Spos', (void*)&pos, sizeof(Position)); + snooze(time); + view->GetPosition(&pos); } - view->PostMessage (pm); + view->PostMessage(pm); delete pm; // The last position written has its fButtons entry empty. return 0; diff --git a/source/Position.h b/source/Position.h index 1be4293..4254823 100644 --- a/source/Position.h +++ b/source/Position.h @@ -7,13 +7,14 @@ typedef struct { - BPoint fPoint; - BPoint fTilt; - uint32 fButtons; - uint8 fPressure; - bool fProximity; + BPoint fPoint; + BPoint fTilt; + uint32 fButtons; + uint8 fPressure; + bool fProximity; } Position; -int32 position_tracker (void *data); +int32 +position_tracker(void* data); -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/PrefsWindow.cpp b/source/PrefsWindow.cpp index e7a5f49..06120db 100644 --- a/source/PrefsWindow.cpp +++ b/source/PrefsWindow.cpp @@ -25,91 +25,102 @@ extern becasso_settings g_settings; extern BLocker g_settings_lock; - // TODO fix revert totd, preview, ... are missing // TODO fix Revert Apply OK use standard behavior -PrefsWindow::PrefsWindow () -: BWindow (BRect (100, 100, 180, 108), lstring (380, "Preferences"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS) +PrefsWindow::PrefsWindow() + : BWindow( + BRect(100, 100, 180, 108), lstring(380, "Preferences"), B_TITLED_WINDOW, + B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS + ) { - BView *bg = new BView ("SW bg", B_WILL_DRAW); - bg->SetViewColor (LightGrey); // TODO Fix This Color + BView* bg = new BView("SW bg", B_WILL_DRAW); + bg->SetViewColor(LightGrey); // TODO Fix This Color g_settings_lock.Lock(); fLocalSettings = g_settings; fBackup = g_settings; g_settings_lock.Unlock(); - char cur[16]; - sprintf (cur, "%ld", fLocalSettings.recents); - fNumEntriesTC = new BTextControl ("recent", lstring (383, "Number of entries in Recent menu:"), cur, new BMessage ('prNR')); + BString cur; + fNumberFormat.Format(cur, fLocalSettings.recents); + fNumEntriesTC = new BTextControl( + "recent", lstring(383, "Number of entries in Recent menu:"), cur, new BMessage('prNR') + ); - fLangPU = new BPopUpMenu ("Language"); + fLangPU = new BPopUpMenu("Language"); app_info info; - be_app->GetAppInfo (&info); - BEntry appEntry = BEntry (&info.ref); + be_app->GetAppInfo(&info); + BEntry appEntry = BEntry(&info.ref); BEntry appDir; - appEntry.GetParent (&appDir); - BPath appDirPath (&appDir); - appDirPath.Append ("data/strings"); - BDirectory dir (appDirPath.Path()); + appEntry.GetParent(&appDir); + BPath appDirPath(&appDir); + appDirPath.Append("data/strings"); + BDirectory dir(appDirPath.Path()); BEntry entry; - while (dir.GetNextEntry (&entry, false) == B_OK) - { + while (dir.GetNextEntry(&entry, false) == B_OK) { char name[B_FILE_NAME_LENGTH]; - entry.GetName (name); - BMenuItem *item = new BMenuItem (name, new BMessage ('prLC')); - if (!strcmp (name, fLocalSettings.language)) - item->SetMarked (true); - fLangPU->AddItem (item); + entry.GetName(name); + BMenuItem* item = new BMenuItem(name, new BMessage('prLC')); + if (!strcmp(name, fLocalSettings.language)) + item->SetMarked(true); + fLangPU->AddItem(item); }; /* TODO Use locale to match language with this implementation - BMenuField *langMF = new BMenuField (BRect (8, 34, 272, 54), "lan", lstring (384, "Interface language: "), fLangPU); - bg->AddChild (langMF); - BStringView *lanWarn = new BStringView (BRect (8, 54, 276, 72), "lanwarn", lstring (385, "(Will take effect at next program launch)")); + BMenuField *langMF = new BMenuField (BRect (8, 34, 272, 54), "lan", lstring (384, "Interface + language: "), fLangPU); bg->AddChild (langMF); BStringView *lanWarn = new BStringView (BRect (8, + 54, 276, 72), "lanwarn", lstring (385, "(Will take effect at next program launch)")); bg->AddChild (lanWarn); */ -// fUndoSlider = new BSlider("slider", NULL, new BMessage ('prMU'), 1, MAX_UNDO-1, B_HORIZONTAL); - /* thumb_style thumbType = B_BLOCK_THUMB, - uint32 resizingMode = B_FOLLOW_LEFT_TOP, - uint32 flags = B_NAVIGABLE | B_WILL_DRAW - | B_FRAME_EVENTS);*/ - fUndoSlider = new Slider (BRect (10, 80, 272, 96), 150, lstring (331, "Maximum # Undos"), 1, MAX_UNDO - 1, 1, new BMessage ('prMU'), B_HORIZONTAL, 16); - fUndoSlider->SetValue (fLocalSettings.max_undo); + // fUndoSlider = new BSlider("slider", NULL, new BMessage ('prMU'), 1, MAX_UNDO-1, + // B_HORIZONTAL); + /* thumb_style thumbType = B_BLOCK_THUMB, + uint32 resizingMode = B_FOLLOW_LEFT_TOP, + uint32 flags = B_NAVIGABLE | B_WILL_DRAW + | B_FRAME_EVENTS);*/ + fUndoSlider = new Slider( + BRect(10, 80, 272, 96), 150, lstring(331, "Maximum # Undos"), 1, MAX_UNDO - 1, 1, + new BMessage('prMU'), B_HORIZONTAL, 16 + ); + fUndoSlider->SetValue(fLocalSettings.max_undo); + - - fSelectionCB = new BCheckBox ("selection", lstring (435, "Always invert selection"), new BMessage ('selI')); - fSelectionCB->SetValue (fLocalSettings.selection_type == SELECTION_STATIC); + fSelectionCB = + new BCheckBox("selection", lstring(435, "Always invert selection"), new BMessage('selI')); + fSelectionCB->SetValue(fLocalSettings.selection_type == SELECTION_STATIC); - BCheckBox *totdCB = new BCheckBox ("totd", lstring (387, "Show tips at startup"), new BMessage ('totd')); - totdCB->SetValue (fLocalSettings.totd); + BCheckBox* totdCB = + new BCheckBox("totd", lstring(387, "Show tips at startup"), new BMessage('totd')); + totdCB->SetValue(fLocalSettings.totd); - fPrevSizePU = new BPopUpMenu ("Preview Size"); - BMenuItem *item = new BMenuItem ("64x64", new BMessage ('p064')); + fPrevSizePU = new BPopUpMenu("Preview Size"); + BMenuItem* item = new BMenuItem("64x64", new BMessage('p064')); if (fLocalSettings.preview_size == 64) - item->SetMarked (true); - fPrevSizePU->AddItem (item); - item = new BMenuItem ("128x128", new BMessage ('p128')); + item->SetMarked(true); + fPrevSizePU->AddItem(item); + item = new BMenuItem("128x128", new BMessage('p128')); if (fLocalSettings.preview_size == 128) - item->SetMarked (true); + item->SetMarked(true); fPrevSizePU->AddItem(item); - item = new BMenuItem ("256x256", new BMessage ('p256')); + item = new BMenuItem("256x256", new BMessage('p256')); if (fLocalSettings.preview_size == 256) - item->SetMarked (true); + item->SetMarked(true); fPrevSizePU->AddItem(item); - BMenuField *previewMF = new BMenuField ("prv", lstring (386, "Filter Preview Size: "), fPrevSizePU); + BMenuField* previewMF = + new BMenuField("prv", lstring(386, "Filter Preview Size: "), fPrevSizePU); - BButton *revert = new BButton ("revert", lstring (381, "Revert"), new BMessage ('prfR')); - BButton *apply = new BButton ("apply", lstring (382, "Apply"), new BMessage ('prfA')); - BButton *ok = new BButton ("ok", lstring (136, "OK"), new BMessage ('prfK')); - ok->MakeDefault (true); + BButton* revert = new BButton("revert", lstring(381, "Revert"), new BMessage('prfR')); + BButton* apply = new BButton("apply", lstring(382, "Apply"), new BMessage('prfA')); + BButton* ok = new BButton("ok", lstring(136, "OK"), new BMessage('prfK')); + ok->MakeDefault(true); BLayoutBuilder::Group<>(bg, B_VERTICAL, B_USE_DEFAULT_SPACING) - //.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) + //.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, + // B_USE_DEFAULT_SPACING) .Add(fNumEntriesTC) .Add(fUndoSlider) .Add(fSelectionCB) @@ -117,54 +128,53 @@ PrefsWindow::PrefsWindow () .Add(previewMF) .Add(new BSeparatorView(B_HORIZONTAL)) .AddGroup(B_HORIZONTAL) - .AddGlue() - .Add(revert) - .Add(apply) - .Add(ok); + .AddGlue() + .Add(revert) + .Add(apply) + .Add(ok); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) - .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) + .SetInsets( + B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING + ) .Add(bg); } -PrefsWindow::~PrefsWindow () -{ -} +PrefsWindow::~PrefsWindow() {} -void PrefsWindow::refresh() +void +PrefsWindow::refresh() { - char cur[16]; - sprintf (cur, "%li", fLocalSettings.recents); - fNumEntriesTC->SetText (cur); - //fLangPU->FindItem(fLocalSettings.language)->SetMarked (true); - fUndoSlider->SetValue (fLocalSettings.max_undo); - fSelectionCB->SetValue (fLocalSettings.selection_type == SELECTION_STATIC); + BString cur; + fNumberFormat.Format(cur, fLocalSettings.recents); + fNumEntriesTC->SetText(cur.String()); + // fLangPU->FindItem(fLocalSettings.language)->SetMarked (true); + fUndoSlider->SetValue(fLocalSettings.max_undo); + fSelectionCB->SetValue(fLocalSettings.selection_type == SELECTION_STATIC); } -void PrefsWindow::MessageReceived (BMessage *message) +void +PrefsWindow::MessageReceived(BMessage* message) { - switch (message->what) - { - case 'prMU': - { - fLocalSettings.max_undo = int (message->FindFloat ("value")); + switch (message->what) { + case 'prMU': { + fLocalSettings.max_undo = int(message->FindFloat("value")); break; } - case 'prNR': - { - fLocalSettings.recents = atoi (fNumEntriesTC->Text()); + case 'prNR': { + fLocalSettings.recents = atoi(fNumEntriesTC->Text()); fLocalSettings.settings_touched = true; break; } - case 'prLC': - { - strcpy (fLocalSettings.language, fLangPU->FindMarked()->Label()); + case 'prLC': { + strcpy(fLocalSettings.language, fLangPU->FindMarked()->Label()); break; } case 'selI': fLocalSettings.selection_type = fSelectionCB->Value() ? SELECTION_STATIC : SELECTION_IN_OUT; break; case 'totd': - fLocalSettings.totd = message->FindInt32 ("be:value"); + fLocalSettings.totd = message->FindInt32("be:value"); break; case 'p064': fLocalSettings.preview_size = 64; @@ -175,7 +185,7 @@ void PrefsWindow::MessageReceived (BMessage *message) case 'p256': fLocalSettings.preview_size = 256; break; - + case 'prfR': g_settings_lock.Lock(); fLocalSettings = fBackup; diff --git a/source/PrefsWindow.h b/source/PrefsWindow.h index fb0060d..3777250 100644 --- a/source/PrefsWindow.h +++ b/source/PrefsWindow.h @@ -2,6 +2,7 @@ #define PREFSWINDOW_H #include +#include #include #include "Settings.h" @@ -12,25 +13,25 @@ class Slider; class PrefsWindow : public BWindow { -public: - PrefsWindow (); -virtual ~PrefsWindow (); + public: + PrefsWindow(); + virtual ~PrefsWindow(); -virtual void MessageReceived (BMessage *message); + virtual void MessageReceived(BMessage* message); -void refresh(); + void refresh(); -private: + private: + typedef BWindow inherited; + becasso_settings fLocalSettings; + becasso_settings fBackup; -typedef BWindow inherited; -becasso_settings fLocalSettings; -becasso_settings fBackup; - -BTextControl *fNumEntriesTC; -BPopUpMenu *fLangPU; -BPopUpMenu *fPrevSizePU; -Slider *fUndoSlider; -BCheckBox *fSelectionCB; + BTextControl* fNumEntriesTC; + BNumberFormat fNumberFormat; + BPopUpMenu* fLangPU; + BPopUpMenu* fPrevSizePU; + Slider* fUndoSlider; + BCheckBox* fSelectionCB; }; -#endif \ No newline at end of file +#endif diff --git a/source/ProgressiveBitmapStream.cpp b/source/ProgressiveBitmapStream.cpp index 1c1710c..8042fb9 100644 --- a/source/ProgressiveBitmapStream.cpp +++ b/source/ProgressiveBitmapStream.cpp @@ -21,36 +21,33 @@ // Defines -#define UPDATE_BAR 'UPDB' -#define STOP_PRESSED 'STOP' - +#define UPDATE_BAR 'UPDB' +#define STOP_PRESSED 'STOP' // BarWindow class class BarWindow : public BWindow { -public: - BarWindow(BRect frame, char *window_title, float max); - virtual void MessageReceived(BMessage *msg); + public: + BarWindow(BRect frame, char* window_title, float max); + virtual void MessageReceived(BMessage* msg); bool StopPressed() const; -private: - BStatusBar *the_bar; + private: + BStatusBar* the_bar; bool stop; }; - // Progress bar window constructor -BarWindow::BarWindow(BRect frame, char *window_title, float max) +BarWindow::BarWindow(BRect frame, char* window_title, float max) : BWindow( - frame, - window_title, - B_TITLED_WINDOW, - B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE) + frame, window_title, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE + ) - , stop(false) + , + stop(false) { // Background view - BView *main_view = new BView(Bounds(), "", B_FOLLOW_NONE, B_WILL_DRAW); + BView* main_view = new BView(Bounds(), "", B_FOLLOW_NONE, B_WILL_DRAW); AddChild(main_view); main_view->SetViewColor(220, 220, 220); @@ -60,37 +57,32 @@ BarWindow::BarWindow(BRect frame, char *window_title, float max) main_view->AddChild(the_bar); // Stop button - main_view->AddChild(new BButton( - BRect(180.0, 50.0, 240.0, 74.0), - "", - "Stop", - new BMessage(STOP_PRESSED))); + main_view->AddChild( + new BButton(BRect(180.0, 50.0, 240.0, 74.0), "", "Stop", new BMessage(STOP_PRESSED)) + ); Show(); } - // Update status bar void -BarWindow::MessageReceived(BMessage *msg) +BarWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case UPDATE_BAR: - the_bar->Update(msg->FindFloat("delta")); - break; - - case STOP_PRESSED: - stop = true; - break; - - default: - BWindow::MessageReceived(msg); - break; + switch (msg->what) { + case UPDATE_BAR: + the_bar->Update(msg->FindFloat("delta")); + break; + + case STOP_PRESSED: + stop = true; + break; + + default: + BWindow::MessageReceived(msg); + break; } } - // Check if stop button was pressed bool BarWindow::StopPressed() const @@ -98,12 +90,10 @@ BarWindow::StopPressed() const return stop; } - // Constructor for when using the bitmap stream as source -ProgressiveBitmapStream::ProgressiveBitmapStream(BBitmap *bitmap) - : BPositionIO() +ProgressiveBitmapStream::ProgressiveBitmapStream(BBitmap* bitmap) : BPositionIO() { - fWriteOnly = false; // Read-only + fWriteOnly = false; // Read-only fBitmap = bitmap; fHeader.magic = B_TRANSLATOR_BITMAP; @@ -140,13 +130,10 @@ ProgressiveBitmapStream::ProgressiveBitmapStream(BBitmap *bitmap) fHeaderWritten = 0; } - // Constructor for when using the bitmap stream as destination ProgressiveBitmapStream::ProgressiveBitmapStream( - BInvoker *bitmap_created, - BInvoker *rect_updated, - bool dither, - bool keep_org) + BInvoker* bitmap_created, BInvoker* rect_updated, bool dither, bool keep_org +) : BPositionIO() { fWriteOnly = true; @@ -175,7 +162,6 @@ ProgressiveBitmapStream::ProgressiveBitmapStream( index_list = system_colors()->index_map; } - // Destructor ProgressiveBitmapStream::~ProgressiveBitmapStream() { @@ -185,7 +171,7 @@ ProgressiveBitmapStream::~ProgressiveBitmapStream() if (fDisposeOrg) delete fOrgBitmap; - + if (fDispose) delete fBitmap; @@ -193,10 +179,9 @@ ProgressiveBitmapStream::~ProgressiveBitmapStream() fBarWin->PostMessage(B_QUIT_REQUESTED); } - // ReadAt() - used when saving a bitmap ssize_t -ProgressiveBitmapStream::ReadAt(off_t pos, void *buffer, size_t size) +ProgressiveBitmapStream::ReadAt(off_t pos, void* buffer, size_t size) { if (fWriteOnly || !fBitmap || pos >= fSize) return B_ERROR; @@ -207,8 +192,7 @@ ProgressiveBitmapStream::ReadAt(off_t pos, void *buffer, size_t size) // Read data from the header size_t from_header = 0; - if (pos < sizeof(TranslatorBitmap)) - { + if (pos < sizeof(TranslatorBitmap)) { from_header = sizeof(TranslatorBitmap) - pos; if (from_header > size) from_header = size; @@ -217,22 +201,19 @@ ProgressiveBitmapStream::ReadAt(off_t pos, void *buffer, size_t size) // Read data from the bitmap size_t from_bitmap = size - from_header; - if (from_bitmap > 0) - { + if (from_bitmap > 0) { memcpy( - static_cast(buffer) + from_header, - static_cast(fBitmap->Bits()) + pos + from_header - sizeof(TranslatorBitmap), - from_bitmap); + static_cast(buffer) + from_header, + static_cast(fBitmap->Bits()) + pos + from_header - sizeof(TranslatorBitmap), + from_bitmap + ); // Update the progress bar if there is one - if (fBar) - { - if (!fBarWin) - { + if (fBar) { + if (!fBarWin) { fBarWin = new BarWindow( - BRect(fBarLeftTop, fBarLeftTop + BPoint(250.0, 82.0)), - fBarTitle, - fDataSize); + BRect(fBarLeftTop, fBarLeftTop + BPoint(250.0, 82.0)), fBarTitle, fDataSize + ); } BMessage msg(UPDATE_BAR); msg.AddFloat("delta", from_bitmap); @@ -249,10 +230,9 @@ ProgressiveBitmapStream::ReadAt(off_t pos, void *buffer, size_t size) return size; } - // Write() implemented without using Seek() ssize_t -ProgressiveBitmapStream::Write(const void *buffer, size_t size) +ProgressiveBitmapStream::Write(const void* buffer, size_t size) { ssize_t ret_val = WriteAt(fPosition, buffer, size); if (ret_val > 0) @@ -260,10 +240,9 @@ ProgressiveBitmapStream::Write(const void *buffer, size_t size) return ret_val; } - // WriteAt() - used when loading a bitmap ssize_t -ProgressiveBitmapStream::WriteAt(off_t pos, const void *buffer, size_t size) +ProgressiveBitmapStream::WriteAt(off_t pos, const void* buffer, size_t size) { if (!fWriteOnly) return B_ERROR; @@ -273,8 +252,7 @@ ProgressiveBitmapStream::WriteAt(off_t pos, const void *buffer, size_t size) // Write data to the header size_t to_header = 0; - if (pos < sizeof(TranslatorBitmap)) - { + if (pos < sizeof(TranslatorBitmap)) { to_header = sizeof(TranslatorBitmap) - pos; if (to_header > size) to_header = size; @@ -287,23 +265,22 @@ ProgressiveBitmapStream::WriteAt(off_t pos, const void *buffer, size_t size) // We assume that when 32 bytes have been written to the header, // the header is complete and the bitmap may be allocated fHeaderWritten += to_header; - if (fHeaderWritten >= sizeof(TranslatorBitmap)) - { + if (fHeaderWritten >= sizeof(TranslatorBitmap)) { // First convert the header to the correct endianess swap_data(B_UINT32_TYPE, &(fHeader.magic), sizeof(uint32), B_SWAP_BENDIAN_TO_HOST); swap_data(B_RECT_TYPE, &(fHeader.bounds), sizeof(BRect), B_SWAP_BENDIAN_TO_HOST); swap_data(B_UINT32_TYPE, &(fHeader.rowBytes), sizeof(uint32), B_SWAP_BENDIAN_TO_HOST); - swap_data(B_UINT32_TYPE, &(fHeader.colors), sizeof(color_space), B_SWAP_BENDIAN_TO_HOST); + swap_data( + B_UINT32_TYPE, &(fHeader.colors), sizeof(color_space), B_SWAP_BENDIAN_TO_HOST + ); swap_data(B_UINT32_TYPE, &(fHeader.dataSize), sizeof(uint32), B_SWAP_BENDIAN_TO_HOST); // Some rigorous checks - if (fHeader.magic != B_TRANSLATOR_BITMAP || - !fHeader.bounds.IsValid() || - fHeader.dataSize != (fHeader.bounds.bottom - - fHeader.bounds.top + 1) * fHeader.rowBytes) - { + if (fHeader.magic != B_TRANSLATOR_BITMAP || !fHeader.bounds.IsValid() || + fHeader.dataSize != + (fHeader.bounds.bottom - fHeader.bounds.top + 1) * fHeader.rowBytes) { return B_ERROR; - } + } if (fHeader.colors != B_RGBA32) fDither = false; @@ -311,23 +288,19 @@ ProgressiveBitmapStream::WriteAt(off_t pos, const void *buffer, size_t size) fHeader.bounds.OffsetTo(0.0, 0.0); // Allocate the bitmap(s) - if (fDither) - { + if (fDither) { fBitmap = new BBitmap(fHeader.bounds, B_COLOR_8_BIT); if (fKeepOrg) fOrgBitmap = new BBitmap(fHeader.bounds, fHeader.colors); - } - else - { + } else { fBitmap = new BBitmap(fHeader.bounds, fHeader.colors); } SetExtras(); // Send 'bitmap created' message - if (fBitmapInvoker) - { - BMessage msg (*(fBitmapInvoker->Message())); + if (fBitmapInvoker) { + BMessage msg(*(fBitmapInvoker->Message())); msg.AddPointer("bitmap", fBitmap); fBitmapInvoker->Invoke(&msg); } @@ -336,75 +309,60 @@ ProgressiveBitmapStream::WriteAt(off_t pos, const void *buffer, size_t size) // Write data to the bitmap size_t to_bitmap = size - to_header; - if (to_bitmap > 0) - { + if (to_bitmap > 0) { if (!fBitmap) return B_ERROR; // Truncate if someone tries to write too much - if (size > fSize - pos) - { + if (size > fSize - pos) { to_bitmap -= size - fSize + pos; size = fSize - pos; } off_t in_bitmap = pos + to_header - sizeof(TranslatorBitmap); - if (fDither) - { - if (fKeepOrg) - { + if (fDither) { + if (fKeepOrg) { memcpy( - static_cast(fOrgBitmap->Bits()) + in_bitmap, - static_cast(buffer) + to_header, - to_bitmap); + static_cast(fOrgBitmap->Bits()) + in_bitmap, + static_cast(buffer) + to_header, to_bitmap + ); } - Dither( - static_cast(buffer) + to_header, - in_bitmap, - to_bitmap); - } - else - { + Dither(static_cast(buffer) + to_header, in_bitmap, to_bitmap); + } else { memcpy( - static_cast(fBitmap->Bits()) + in_bitmap, - static_cast(buffer) + to_header, - to_bitmap); + static_cast(fBitmap->Bits()) + in_bitmap, + static_cast(buffer) + to_header, to_bitmap + ); } // Send 'rect updated' message - if (fRectInvoker) - { + if (fRectInvoker) { // First calculate the rect that needs updating int top = in_bitmap / fHeader.rowBytes; int left = in_bitmap % fHeader.rowBytes; int right = left + to_bitmap - 1; int bottom = top + (right / fHeader.rowBytes); - if (bottom == top) - { - left /= int (fBytesPerPixel); - right /= int (fBytesPerPixel); - } - else - { + if (bottom == top) { + left /= int(fBytesPerPixel); + right /= int(fBytesPerPixel); + } else { left = 0; - right = int (fHeader.bounds.right); + right = int(fHeader.bounds.right); } - BMessage msg (*(fRectInvoker->Message())); + BMessage msg(*(fRectInvoker->Message())); msg.AddRect("rect", BRect(left, top, right, bottom)); fRectInvoker->Invoke(&msg); } // Update the progress bar if there is one - if (fBar) - { - if (!fBarWin) - { + if (fBar) { + if (!fBarWin) { fBarWin = new BarWindow( - BRect(fBarLeftTop, fBarLeftTop + BPoint(250.0, 82.0)), - fBarTitle, - fHeader.dataSize); + BRect(fBarLeftTop, fBarLeftTop + BPoint(250.0, 82.0)), fBarTitle, + fHeader.dataSize + ); } BMessage msg(UPDATE_BAR); msg.AddFloat("delta", to_bitmap); @@ -421,27 +379,25 @@ ProgressiveBitmapStream::WriteAt(off_t pos, const void *buffer, size_t size) return size; } - // Seek() off_t ProgressiveBitmapStream::Seek(off_t position, uint32 seek_mode) { - switch(seek_mode) - { - case SEEK_SET: - break; + switch (seek_mode) { + case SEEK_SET: + break; - case SEEK_CUR: - position += fPosition; - break; + case SEEK_CUR: + position += fPosition; + break; - case SEEK_END: - position += fSize; - break; + case SEEK_END: + position += fSize; + break; - default: - return B_ERROR; - break; + default: + return B_ERROR; + break; } if (position < 0 || position > fSize) @@ -454,7 +410,6 @@ ProgressiveBitmapStream::Seek(off_t position, uint32 seek_mode) return fPosition; } - // Position() off_t ProgressiveBitmapStream::Position() const @@ -462,7 +417,6 @@ ProgressiveBitmapStream::Position() const return fPosition; } - // SetSize() status_t ProgressiveBitmapStream::SetSize(off_t numBytes) @@ -473,7 +427,6 @@ ProgressiveBitmapStream::SetSize(off_t numBytes) return B_OK; } - // Delete the bitmap at destruction time? void ProgressiveBitmapStream::SetDispose(bool dispose) @@ -481,26 +434,23 @@ ProgressiveBitmapStream::SetDispose(bool dispose) fDispose = dispose; } - // A simple way to retrieve the bitmap. // You don't really need it if you use the bitmap_created invoker. -BBitmap * +BBitmap* ProgressiveBitmapStream::Bitmap() const { return fBitmap; } - // If you set the keep_org flag and there was dithering, // there might be an original 32-bit bitmap to retrieve. -BBitmap * +BBitmap* ProgressiveBitmapStream::OriginalBitmap() { fDisposeOrg = false; return fOrgBitmap; } - // Causes each read/write call to return errors. // Ideal for aborting a data translation in progress. // If the translator chooses to ignore the errors, @@ -511,7 +461,6 @@ ProgressiveBitmapStream::ForceErrors() fForceErrors = true; } - // Check if the errors were forced. It can be switched on // from within the class if the user presses the stop // button in the progress window. @@ -521,11 +470,9 @@ ProgressiveBitmapStream::ErrorsForced() const return fForceErrors; } - // Display a progress bar as data is read/written to/from the stream void -ProgressiveBitmapStream::DisplayProgressBar( - BPoint left_top, const char *window_title) +ProgressiveBitmapStream::DisplayProgressBar(BPoint left_top, const char* window_title) { fBar = true; fBarLeftTop = left_top; @@ -533,53 +480,48 @@ ProgressiveBitmapStream::DisplayProgressBar( strncpy(fBarTitle, window_title, 80); } - // Private function to set some bitmap specific stuff void ProgressiveBitmapStream::SetExtras() { fSize = sizeof(TranslatorBitmap) + fHeader.dataSize; - switch (fHeader.colors) - { - case B_RGBA32: - fBytesPerPixel = 4.0; - break; + switch (fHeader.colors) { + case B_RGBA32: + fBytesPerPixel = 4.0; + break; - case B_RGB_16_BIT: - fBytesPerPixel = 2.0; - break; + case B_RGB_16_BIT: + fBytesPerPixel = 2.0; + break; - case B_MONOCHROME_1_BIT: - fBytesPerPixel = 1.0 / 8.0; - break; + case B_MONOCHROME_1_BIT: + fBytesPerPixel = 1.0 / 8.0; + break; - default: // 8-bit - fBytesPerPixel = 1.0; - break; + default: // 8-bit + fBytesPerPixel = 1.0; + break; } - if (fDither) - { - int size = int (3 * (fHeader.bounds.Width() + 3)); + if (fDither) { + int size = int(3 * (fHeader.bounds.Width() + 3)); fDeltaBuffer = new float[size]; for (int32 i = 0; i < size; ++i) fDeltaBuffer[i] = 0.0; } } - // Private function to dither 32-bit data to an 8-bit bitmap void -ProgressiveBitmapStream::Dither(const uchar *src, int32 place, int32 n_bytes) +ProgressiveBitmapStream::Dither(const uchar* src, int32 place, int32 n_bytes) { // Where are we? int y_pos = place / fHeader.rowBytes; int x_pos = place % fHeader.rowBytes; int skip = 4 - x_pos % 4; - if (skip < 4) - { + if (skip < 4) { src += skip; n_bytes -= skip; } @@ -588,39 +530,40 @@ ProgressiveBitmapStream::Dither(const uchar *src, int32 place, int32 n_bytes) int x_len = fHeader.rowBytes / 4; int row_bytes = fBitmap->BytesPerRow(); - uchar *in_bitmap = static_cast(fBitmap->Bits()) + y_pos * row_bytes + x_pos; - float *deltas = &fDeltaBuffer[x_pos * 3]; + uchar* in_bitmap = static_cast(fBitmap->Bits()) + y_pos * row_bytes + x_pos; + float* deltas = &fDeltaBuffer[x_pos * 3]; // Work our way through the data row by row - while (n_bytes > 2) - { + while (n_bytes > 2) { float r_delta = 0.0; float g_delta = 0.0; float b_delta = 0.0; // Do all pixels in one row - for (int x = x_pos; x < x_len && n_bytes > 2; ++x) - { + for (int x = x_pos; x < x_len && n_bytes > 2; ++x) { int r; int g; int b; // Get a pixel from the input buffer and // add corrections from the pixels around it - if (fSeeked) - { + if (fSeeked) { // Can't use the delta buffer, // so we'll only use horizontal error diffusion - r = int (src[2] + r_delta); - g = (int32) src[1] + (int32) g_delta; - b = (int32) src[0] + (int32) b_delta; - } - else - { + r = int(src[2] + r_delta); + g = (int32)src[1] + (int32)g_delta; + b = (int32)src[0] + (int32)b_delta; + } else { // Floyd-Steinberg diffusion - r = int (src[2] + r_delta * 0.4375 + deltas[0] * 0.0625 + deltas[3] * 0.3125 + deltas[6] * 0.1875); - g = int (src[1] + g_delta * 0.4375 + deltas[1] * 0.0625 + deltas[4] * 0.3125 + deltas[7] * 0.1875); - b = int (src[0] + b_delta * 0.4375 + deltas[2] * 0.0625 + deltas[5] * 0.3125 + deltas[8] * 0.1875); + r = + int(src[2] + r_delta * 0.4375 + deltas[0] * 0.0625 + deltas[3] * 0.3125 + + deltas[6] * 0.1875); + g = + int(src[1] + g_delta * 0.4375 + deltas[1] * 0.0625 + deltas[4] * 0.3125 + + deltas[7] * 0.1875); + b = + int(src[0] + b_delta * 0.4375 + deltas[2] * 0.0625 + deltas[5] * 0.3125 + + deltas[8] * 0.1875); } // Store deltas for the current pixel @@ -631,11 +574,11 @@ ProgressiveBitmapStream::Dither(const uchar *src, int32 place, int32 n_bytes) // Fix high and low values r = r > 255 ? 255 : r; - r = r < 0 ? 0 : r; + r = r < 0 ? 0 : r; g = g > 255 ? 255 : g; - g = g < 0 ? 0 : g; + g = g < 0 ? 0 : g; b = b > 255 ? 255 : b; - b = b < 0 ? 0 : b; + b = b < 0 ? 0 : b; // Lets see which colour we get from the BeOS palette uchar colour = index_list[((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3)]; @@ -652,7 +595,7 @@ ProgressiveBitmapStream::Dither(const uchar *src, int32 place, int32 n_bytes) src += 4; n_bytes -= 4; } - in_bitmap += row_bytes - x_len; // Skip bytes at row end + in_bitmap += row_bytes - x_len; // Skip bytes at row end x_pos = 0; deltas = fDeltaBuffer; fSeeked = false; diff --git a/source/ProgressiveBitmapStream.h b/source/ProgressiveBitmapStream.h index 5b6957a..c436a32 100644 --- a/source/ProgressiveBitmapStream.h +++ b/source/ProgressiveBitmapStream.h @@ -67,8 +67,8 @@ */ -#ifndef PROGRESSIVE_BITMAP_STREAM_H -#define PROGRESSIVE_BITMAP_STREAM_H +#ifndef PROGRESSIVE_BITMAP_STREAM_H +#define PROGRESSIVE_BITMAP_STREAM_H #include @@ -80,64 +80,60 @@ class BBitmap; class BInvoker; class BarWindow; - class ProgressiveBitmapStream : public BPositionIO { -public: - // Constructor for when used as source - ProgressiveBitmapStream(BBitmap *bitmap); + public: + // Constructor for when used as source + ProgressiveBitmapStream(BBitmap* bitmap); - // Constructor for when used as destination - ProgressiveBitmapStream( - BInvoker * bitmap_created = 0, - BInvoker * rect_updated = 0, - bool dither = false, - bool keep_org = false); + // Constructor for when used as destination + ProgressiveBitmapStream( + BInvoker* bitmap_created = 0, BInvoker* rect_updated = 0, bool dither = false, + bool keep_org = false + ); - virtual ~ProgressiveBitmapStream(); - ssize_t Write(const void *buffer, size_t size); - ssize_t ReadAt(off_t pos, void *buffer, size_t size); - ssize_t WriteAt(off_t pos, const void *buffer, size_t size); - off_t Seek(off_t position, uint32 seek_mode); - off_t Position() const; - status_t SetSize(off_t numBytes); - void SetDispose(bool dispose); - BBitmap * Bitmap() const; - BBitmap * OriginalBitmap(); - void ForceErrors(); - bool ErrorsForced() const; - void DisplayProgressBar( - BPoint left_top, - const char *window_title); + virtual ~ProgressiveBitmapStream(); + ssize_t Write(const void* buffer, size_t size); + ssize_t ReadAt(off_t pos, void* buffer, size_t size); + ssize_t WriteAt(off_t pos, const void* buffer, size_t size); + off_t Seek(off_t position, uint32 seek_mode); + off_t Position() const; + status_t SetSize(off_t numBytes); + void SetDispose(bool dispose); + BBitmap* Bitmap() const; + BBitmap* OriginalBitmap(); + void ForceErrors(); + bool ErrorsForced() const; + void DisplayProgressBar(BPoint left_top, const char* window_title); -private: - bool fWriteOnly; - bool fDispose; - bool fDisposeOrg; - TranslatorBitmap fHeader; - BBitmap * fBitmap; - BBitmap * fOrgBitmap; - bool fBar; - BInvoker * fBitmapInvoker; - BInvoker * fRectInvoker; - off_t fPosition; - off_t fSize; - float fBytesPerPixel; - void SetExtras(); - bool fForceErrors; - bool fDither; - bool fKeepOrg; - void Dither(const uchar *src, int32 place, int32 n_bytes); - BPoint fBarLeftTop; - char fBarTitle[81]; - BarWindow * fBarWin; - bool fSeeked; - float * fDeltaBuffer; - const rgb_color * palette; - const uchar * index_list; - int32 fHeaderWritten; - uint32 fDataSize; + private: + bool fWriteOnly; + bool fDispose; + bool fDisposeOrg; + TranslatorBitmap fHeader; + BBitmap* fBitmap; + BBitmap* fOrgBitmap; + bool fBar; + BInvoker* fBitmapInvoker; + BInvoker* fRectInvoker; + off_t fPosition; + off_t fSize; + float fBytesPerPixel; + void SetExtras(); + bool fForceErrors; + bool fDither; + bool fKeepOrg; + void Dither(const uchar* src, int32 place, int32 n_bytes); + BPoint fBarLeftTop; + char fBarTitle[81]; + BarWindow* fBarWin; + bool fSeeked; + float* fDeltaBuffer; + const rgb_color* palette; + const uchar* index_list; + int32 fHeaderWritten; + uint32 fDataSize; }; -#endif // PROGRESSIVE_BITMAP_STREAM_H +#endif // PROGRESSIVE_BITMAP_STREAM_H diff --git a/source/Properties.h b/source/Properties.h index e068c78..3635f17 100644 --- a/source/Properties.h +++ b/source/Properties.h @@ -1,17 +1,16 @@ -#define PROP_MODE 1 -#define PROP_TOOL 2 -#define PROP_FGCOLOR 3 -#define PROP_BGCOLOR 4 -#define PROP_SIZE 5 -#define PROP_NAME 6 -#define PROP_EXPFMT 7 -#define PROP_SCRIPTEE 8 -#define PROP_CANVAS 9 -#define PROP_LAYER 10 -#define PROP_ACTIVELAYER 11 -#define PROP_MODE_SETTING 12 -#define PROP_TOOL_SETTING 13 -#define PROP_TABLET 14 -#define PROP_GLOBALALPHA 15 -#define PROP_CONTENTS 16 - +#define PROP_MODE 1 +#define PROP_TOOL 2 +#define PROP_FGCOLOR 3 +#define PROP_BGCOLOR 4 +#define PROP_SIZE 5 +#define PROP_NAME 6 +#define PROP_EXPFMT 7 +#define PROP_SCRIPTEE 8 +#define PROP_CANVAS 9 +#define PROP_LAYER 10 +#define PROP_ACTIVELAYER 11 +#define PROP_MODE_SETTING 12 +#define PROP_TOOL_SETTING 13 +#define PROP_TABLET 14 +#define PROP_GLOBALALPHA 15 +#define PROP_CONTENTS 16 diff --git a/source/RGBSquare.cpp b/source/RGBSquare.cpp index 6a4ba6b..54821c9 100644 --- a/source/RGBSquare.cpp +++ b/source/RGBSquare.cpp @@ -4,18 +4,18 @@ #include "Colors.h" #include -RGBSquare::RGBSquare (BRect frame, int nc, ColorWindow *ed) -: BView (frame, "RGBSquare", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW) +RGBSquare::RGBSquare(BRect frame, int nc, ColorWindow* ed) + : BView(frame, "RGBSquare", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW) { - SetViewColor (B_TRANSPARENT_32_BIT); + SetViewColor(B_TRANSPARENT_32_BIT); color_space cs = B_RGB32; { BScreen screen; if (screen.ColorSpace() == B_COLOR_8_BIT) cs = B_COLOR_8_BIT; } - colorsquare = new BBitmap (BRect (0, 0, 255, 255), cs); - colorcol = new BBitmap (BRect (0, 0, 31, 255), cs); + colorsquare = new BBitmap(BRect(0, 0, 255, 255), cs); + colorcol = new BBitmap(BRect(0, 0, 31, 255), cs); notcolor = nc; editor = ed; current = editor->rgb(); @@ -24,279 +24,254 @@ RGBSquare::RGBSquare (BRect frame, int nc, ColorWindow *ed) prev = B_ORIGIN; } -RGBSquare::~RGBSquare () +RGBSquare::~RGBSquare() { delete colorsquare; delete colorcol; } -void RGBSquare::AttachedToWindow () +void +RGBSquare::AttachedToWindow() { current = editor->rgb(); - SetColor (current); + SetColor(current); inherited::AttachedToWindow(); } -void RGBSquare::DrawLines () +void +RGBSquare::DrawLines() { - SetDrawingMode (B_OP_INVERT); - SetHighColor (Black); - switch (notcolor) - { - case 0: // Red in the column - StrokeLine (BPoint (0, current.red), BPoint (31, current.red)); - StrokeLine (BPoint (current.blue + 40, 0), BPoint (current.blue + 40, 255)); - StrokeLine (BPoint (40, current.green), BPoint (295, current.green)); + SetDrawingMode(B_OP_INVERT); + SetHighColor(Black); + switch (notcolor) { + case 0: // Red in the column + StrokeLine(BPoint(0, current.red), BPoint(31, current.red)); + StrokeLine(BPoint(current.blue + 40, 0), BPoint(current.blue + 40, 255)); + StrokeLine(BPoint(40, current.green), BPoint(295, current.green)); break; - case 1: // Green in the column - StrokeLine (BPoint (0, current.green), BPoint (31, current.green)); - StrokeLine (BPoint (current.blue + 40, 0), BPoint (current.blue + 40, 255)); - StrokeLine (BPoint (40, current.red), BPoint (295, current.red)); + case 1: // Green in the column + StrokeLine(BPoint(0, current.green), BPoint(31, current.green)); + StrokeLine(BPoint(current.blue + 40, 0), BPoint(current.blue + 40, 255)); + StrokeLine(BPoint(40, current.red), BPoint(295, current.red)); break; default: // Blue in the column - StrokeLine (BPoint (0, current.blue), BPoint (31, current.blue)); - StrokeLine (BPoint (current.green + 40, 0), BPoint (current.green + 40, 255)); - StrokeLine (BPoint (40, current.red), BPoint (295, current.red)); + StrokeLine(BPoint(0, current.blue), BPoint(31, current.blue)); + StrokeLine(BPoint(current.green + 40, 0), BPoint(current.green + 40, 255)); + StrokeLine(BPoint(40, current.red), BPoint(295, current.red)); break; } } -void RGBSquare::ScreenChanged (BRect /* frame */, color_space mode) +void +RGBSquare::ScreenChanged(BRect /* frame */, color_space mode) { // Note: Only changes from 8 <-> {16, 32} are interesting. // 16 bit screens won't use dithering. - if (colorsquare->ColorSpace() == B_COLOR_8_BIT && mode != B_COLOR_8_BIT) - { + if (colorsquare->ColorSpace() == B_COLOR_8_BIT && mode != B_COLOR_8_BIT) { delete colorsquare; delete colorcol; - colorsquare = new BBitmap (BRect (0, 0, 255, 255), B_RGB32); - colorcol = new BBitmap (BRect (0, 0, 31, 255), B_RGB32); + colorsquare = new BBitmap(BRect(0, 0, 255, 255), B_RGB32); + colorcol = new BBitmap(BRect(0, 0, 31, 255), B_RGB32); first = true; AttachedToWindow(); Invalidate(); - } - else if (colorsquare->ColorSpace() != B_COLOR_8_BIT && mode == B_COLOR_8_BIT) - { + } else if (colorsquare->ColorSpace() != B_COLOR_8_BIT && mode == B_COLOR_8_BIT) { delete colorsquare; delete colorcol; - colorsquare = new BBitmap (BRect (0, 0, 255, 255), B_COLOR_8_BIT); - colorcol = new BBitmap (BRect (0, 0, 31, 255), B_COLOR_8_BIT); + colorsquare = new BBitmap(BRect(0, 0, 255, 255), B_COLOR_8_BIT); + colorcol = new BBitmap(BRect(0, 0, 31, 255), B_COLOR_8_BIT); first = true; AttachedToWindow(); Invalidate(); } } -void RGBSquare::Draw (BRect /* update */) +void +RGBSquare::Draw(BRect /* update */) { BRect middle, right; - middle.Set (32, 0, 39, 256); - right.Set (295, 0, Bounds().Width(), 256); - SetDrawingMode (B_OP_COPY); - DrawBitmapAsync (colorsquare, BPoint (40, 0)); - DrawBitmap (colorcol, BPoint (0, 0)); - SetHighColor (LightGrey); - FillRect (middle); - FillRect (right); + middle.Set(32, 0, 39, 256); + right.Set(295, 0, Bounds().Width(), 256); + SetDrawingMode(B_OP_COPY); + DrawBitmapAsync(colorsquare, BPoint(40, 0)); + DrawBitmap(colorcol, BPoint(0, 0)); + SetHighColor(LightGrey); + FillRect(middle); + FillRect(right); DrawLines(); } -void RGBSquare::MouseDown (BPoint point) +void +RGBSquare::MouseDown(BPoint point) { if (point == prev) clicks++; else clicks = 0; prev = point; - - if (clicks > 1) - { - uint32 buttons = Window()->CurrentMessage()->FindInt32 ("buttons"); - if (buttons & B_PRIMARY_MOUSE_BUTTON) - { - BMessage set ('CXSm'); - Window()->PostMessage (&set); + + if (clicks > 1) { + uint32 buttons = Window()->CurrentMessage()->FindInt32("buttons"); + if (buttons & B_PRIMARY_MOUSE_BUTTON) { + BMessage set('CXSm'); + Window()->PostMessage(&set); } - if (buttons & B_SECONDARY_MOUSE_BUTTON) - { - BMessage set ('CXSc'); - Window()->PostMessage (&set); + if (buttons & B_SECONDARY_MOUSE_BUTTON) { + BMessage set('CXSc'); + Window()->PostMessage(&set); } - inherited::MouseDown (point); - } - else - { - thread_id id = spawn_thread (RGB_track_mouse, "RGB tracker", B_DISPLAY_PRIORITY, this); - resume_thread (id); + inherited::MouseDown(point); + } else { + thread_id id = spawn_thread(RGB_track_mouse, "RGB tracker", B_DISPLAY_PRIORITY, this); + resume_thread(id); } } -void RGBSquare::mouseDown (BPoint point, int ob) +void +RGBSquare::mouseDown(BPoint point, int ob) { - if (ob == 1) - { + if (ob == 1) { float prevy = -1; - if (prevy != point.y) - { + if (prevy != point.y) { rgb_color c = current; - switch (notcolor) - { + switch (notcolor) { case 0: // Red in the column - c.red = clipchar (point.y); + c.red = clipchar(point.y); break; case 1: // Green in the column - c.green = clipchar (point.y); + c.green = clipchar(point.y); break; - default:// Blue in the column - c.blue = clipchar (point.y); + default: // Blue in the column + c.blue = clipchar(point.y); break; } - SetColor (c); + SetColor(c); Window()->UpdateIfNeeded(); } - BMessage *msg = new BMessage ('CSQc'); - msg->AddInt32 ("color", current.red); - msg->AddInt32 ("color", current.green); - msg->AddInt32 ("color", current.blue); - Window()->PostMessage (msg); + BMessage* msg = new BMessage('CSQc'); + msg->AddInt32("color", current.red); + msg->AddInt32("color", current.green); + msg->AddInt32("color", current.blue); + Window()->PostMessage(msg); delete msg; prevy = point.y; - } - else if (ob == 2) - { + } else if (ob == 2) { DrawLines(); - switch (notcolor) - { + switch (notcolor) { case 0: // Red in the column - current.green = clipchar (point.y); - current.blue = clipchar (point.x - 40); + current.green = clipchar(point.y); + current.blue = clipchar(point.x - 40); break; case 1: // Green in the column - current.red = clipchar (point.y); - current.blue = clipchar (point.x - 40); - break; - default:// Blue in the column - current.red = clipchar (point.y); - current.green = clipchar (point.x - 40); + current.red = clipchar(point.y); + current.blue = clipchar(point.x - 40); + break; + default: // Blue in the column + current.red = clipchar(point.y); + current.green = clipchar(point.x - 40); break; } DrawLines(); Window()->UpdateIfNeeded(); - BMessage *msg = new BMessage ('CSQc'); - msg->AddInt32 ("color", current.red); - msg->AddInt32 ("color", current.green); - msg->AddInt32 ("color", current.blue); - Window()->PostMessage (msg); + BMessage* msg = new BMessage('CSQc'); + msg->AddInt32("color", current.red); + msg->AddInt32("color", current.green); + msg->AddInt32("color", current.blue); + Window()->PostMessage(msg); delete msg; } } - -int32 RGB_track_mouse (void *data) +int32 +RGB_track_mouse(void* data) { - BRect colRect = BRect (0, 0, 31, 255); - BRect squareRect = BRect (40, 0, 295, 255); - BMessage *msg; - RGBSquare *obj = (RGBSquare *)data; + BRect colRect = BRect(0, 0, 31, 255); + BRect squareRect = BRect(40, 0, 295, 255); + BMessage* msg; + RGBSquare* obj = (RGBSquare*)data; uint32 buttons; BPoint point; - BPoint prev = BPoint (-1, -1); + BPoint prev = BPoint(-1, -1); obj->Window()->Lock(); - obj->GetMouse (&point, &buttons, true); - if (colRect.Contains (point)) - { - msg = new BMessage ('RGBc'); - obj->Window()->PostMessage (msg); + obj->GetMouse(&point, &buttons, true); + if (colRect.Contains(point)) { + msg = new BMessage('RGBc'); + obj->Window()->PostMessage(msg); delete msg; - } - else if (squareRect.Contains (point)) - { - msg = new BMessage ('RGBs'); - obj->Window()->PostMessage (msg); + } else if (squareRect.Contains(point)) { + msg = new BMessage('RGBs'); + obj->Window()->PostMessage(msg); delete msg; } - while (buttons) - { - if (prev != point) - { - msg = new BMessage ('RGBm'); - msg->AddFloat ("x", point.x); - msg->AddFloat ("y", point.y); - obj->Window()->PostMessage (msg); + while (buttons) { + if (prev != point) { + msg = new BMessage('RGBm'); + msg->AddFloat("x", point.x); + msg->AddFloat("y", point.y); + obj->Window()->PostMessage(msg); delete msg; prev = point; } obj->Window()->Unlock(); - snooze (50000); + snooze(50000); obj->Window()->Lock(); - obj->GetMouse (&point, &buttons, true); + obj->GetMouse(&point, &buttons, true); } - msg = new BMessage ('RGBu'); - obj->Window()->PostMessage (msg); + msg = new BMessage('RGBu'); + obj->Window()->PostMessage(msg); delete msg; obj->Window()->Unlock(); return 0; } -void RGBSquare::SetColor (rgb_color c) +void +RGBSquare::SetColor(rgb_color c) // There is a one pixel black border which I don't understand... { // This could be faster... In the meantime, just do it. - if (true || first || ((notcolor == 0) && (c.red != current.red)) - || ((notcolor == 1) && (c.green != current.green)) - || ((notcolor == 2) && (c.blue != current.blue))) - { - if (notcolor == 0) // Red in the column + if (true || first || ((notcolor == 0) && (c.red != current.red)) || + ((notcolor == 1) && (c.green != current.green)) || + ((notcolor == 2) && (c.blue != current.blue))) { + if (notcolor == 0) // Red in the column { uchar r = c.red; - for (int g = 0; g < 256; g++) - { - for (int b = 0; b < 256; b++) - { + for (int g = 0; g < 256; g++) { + for (int b = 0; b < 256; b++) { square[g][b][0] = r; square[g][b][1] = g; square[g][b][2] = b; } - for (int x = 0; x < 32; x++) - { + for (int x = 0; x < 32; x++) { col[g][x][0] = g; col[g][x][1] = 0; col[g][x][2] = 0; } } - } - else if (notcolor == 1) // Green in the column + } else if (notcolor == 1) // Green in the column { uchar g = c.green; - for (int r = 0; r < 256; r++) - { - for (int b = 0; b < 256; b++) - { + for (int r = 0; r < 256; r++) { + for (int b = 0; b < 256; b++) { square[r][b][0] = r; square[r][b][1] = g; square[r][b][2] = b; } - for (int x = 0; x < 32; x++) - { + for (int x = 0; x < 32; x++) { col[r][x][0] = 0; col[r][x][1] = r; col[r][x][2] = 0; } } - } - else // Blue in the column + } else // Blue in the column { uchar b = c.blue; - for (int r = 0; r < 256; r++) - { - for (int g = 0; g < 256; g++) - { + for (int r = 0; r < 256; r++) { + for (int g = 0; g < 256; g++) { square[r][g][0] = r; square[r][g][1] = g; square[r][g][2] = b; } - for (int x = 0; x < 32; x++) - { + for (int x = 0; x < 32; x++) { col[r][x][0] = 0; col[r][x][1] = 0; col[r][x][2] = r; @@ -304,23 +279,25 @@ void RGBSquare::SetColor (rgb_color c) } } current = c; -// uchar *test = (uchar *) colorsquare->Bits(); -// printf ("Alpha = %i\n", int (test[3])); - colorsquare->SetBits (square, 256*256*3, 0, B_RGB32); - colorcol->SetBits (col, 256*32*3, 0, B_RGB32); -// printf ("Alpha = %i\n", int (test[3])); + // uchar *test = (uchar *) colorsquare->Bits(); + // printf ("Alpha = %i\n", int (test[3])); + colorsquare->SetBits(square, 256 * 256 * 3, 0, B_RGB32); + colorcol->SetBits(col, 256 * 32 * 3, 0, B_RGB32); + // printf ("Alpha = %i\n", int (test[3])); first = false; } Invalidate(); } -void RGBSquare::SetNotColor (int nc) +void +RGBSquare::SetNotColor(int nc) { notcolor = nc; - SetColor (current); + SetColor(current); } -rgb_color RGBSquare::GetColor () +rgb_color +RGBSquare::GetColor() { return current; } \ No newline at end of file diff --git a/source/RGBSquare.h b/source/RGBSquare.h index d2da58e..8d84946 100644 --- a/source/RGBSquare.h +++ b/source/RGBSquare.h @@ -8,33 +8,34 @@ class RGBSquare : public BView { -public: - RGBSquare (BRect frame, int nc, ColorWindow *ed); -virtual ~RGBSquare (); -virtual void Draw (BRect update); -virtual void MouseDown (BPoint point); -virtual void mouseDown (BPoint point, int ob); -virtual void AttachedToWindow (); -virtual void ScreenChanged (BRect frame, color_space cs); -void SetColor (rgb_color c); -void SetNotColor (int nc); -rgb_color GetColor (); + public: + RGBSquare(BRect frame, int nc, ColorWindow* ed); + virtual ~RGBSquare(); + virtual void Draw(BRect update); + virtual void MouseDown(BPoint point); + virtual void mouseDown(BPoint point, int ob); + virtual void AttachedToWindow(); + virtual void ScreenChanged(BRect frame, color_space cs); + void SetColor(rgb_color c); + void SetNotColor(int nc); + rgb_color GetColor(); -private: -typedef BView inherited; -void DrawLines(); -BBitmap *colorsquare; -BBitmap *colorcol; -uchar square[256][256][3]; -uchar col[256][32][3]; -rgb_color current; -int notcolor; -class ColorWindow *editor; -bool first; -int clicks; -BPoint prev; + private: + typedef BView inherited; + void DrawLines(); + BBitmap* colorsquare; + BBitmap* colorcol; + uchar square[256][256][3]; + uchar col[256][32][3]; + rgb_color current; + int notcolor; + class ColorWindow* editor; + bool first; + int clicks; + BPoint prev; }; -int32 RGB_track_mouse (void *data); +int32 +RGB_track_mouse(void* data); -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/RegWindow.cpp b/source/RegWindow.cpp index 4141081..83c74de 100644 --- a/source/RegWindow.cpp +++ b/source/RegWindow.cpp @@ -17,8 +17,8 @@ #include #include -RegWindow::RegWindow (const BRect frame, const char *title, char type) -: BWindow (frame, title, B_TITLED_WINDOW, B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_RESIZABLE) +RegWindow::RegWindow(const BRect frame, const char* title, char type) + : BWindow(frame, title, B_TITLED_WINDOW, B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_RESIZABLE) { fType = type; fStatus = 0; @@ -27,89 +27,109 @@ RegWindow::RegWindow (const BRect frame, const char *title, char type) iFrame = Bounds(); bgFrame.left = 40; iFrame.right = 39; - BView *bg = new BView (bgFrame, "RW bg", B_FOLLOW_ALL, B_WILL_DRAW); - bg->SetViewColor (LightGrey); - AddChild (bg); + BView* bg = new BView(bgFrame, "RW bg", B_FOLLOW_ALL, B_WILL_DRAW); + bg->SetViewColor(LightGrey); + AddChild(bg); app_info info; - be_app->GetAppInfo (&info); - BFile file (&info.ref, O_RDONLY); - BResources res (&file); - BBitmap *icon = new BBitmap (BRect (0, 0, 31, 31), B_CMAP8); + be_app->GetAppInfo(&info); + BFile file(&info.ref, O_RDONLY); + BResources res(&file); + BBitmap* icon = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8); size_t size; - const void *icondata = res.LoadResource ('ICON', "BEOS:L:image/x-becasso", &size); - icon->SetBits (icondata, 1024, 0, B_COLOR_8_BIT); - BitmapView *iView = new BitmapView (iFrame, "icon", icon, B_OP_OVER, false); - AddChild (iView); - iView->SetPosition (BPoint (4, 8)); - iView->SetViewColor (DarkGrey); - - regFrame.Set (bgFrame.Width() - 80, bgFrame.bottom - 34, bgFrame.Width() - 8, bgFrame.bottom - 8); - cancelFrame.Set (regFrame.left - 88, regFrame.top, regFrame.left - 8, regFrame.bottom); - BButton *cancel = new BButton (cancelFrame, "RW cancel", lstring (131, "Cancel"), new BMessage ('Rcnc')); - BButton *reg = new BButton (regFrame, "RW reg", lstring (426, "Register"), new BMessage ('Rreg')); - reg->MakeDefault (true); - bg->AddChild (cancel); - bg->AddChild (reg); - - fName = new BTextControl (BRect (4, regFrame.top - 30, bgFrame.Width() - 4, regFrame.top - 8), "Name", lstring (425, "Name:"), "", new BMessage ('Rnam')); - fName->SetDivider (50); - bg->AddChild (fName); - - if (type == REG_PPC) - { - bg->AddChild (new BStringView (BRect (4, 4, bgFrame.Width() - 4, 20), "rg1", lstring (436, "PowerPC hardware detected"))); - bg->AddChild (new BStringView (BRect (4, 20, bgFrame.Width() - 4, 36), "rg2", lstring (437, "This is a free version."))); - } - else if (type == REG_HAS_14) - { - bg->AddChild (new BStringView (BRect (4, 4, bgFrame.Width() - 4, 20), "rg1", lstring (421, "Becasso 1.4 detected"))); - bg->AddChild (new BStringView (BRect (4, 20, bgFrame.Width() - 4, 36), "rg2", lstring (422, "This is a free upgrade."))); - } - else if (type == REG_PREINST) - { - bg->AddChild (new BStringView (BRect (4, 4, bgFrame.Width() - 4, 20), "rg1", lstring (430, "Becasso 2.0 was pre-installed,"))); - bg->AddChild (new BStringView (BRect (4, 20, bgFrame.Width() - 4, 36), "rg2", lstring (431, "but hasn't been registered yet."))); - } - else // must have the CD + const void* icondata = res.LoadResource('ICON', "BEOS:L:image/x-becasso", &size); + icon->SetBits(icondata, 1024, 0, B_COLOR_8_BIT); + BitmapView* iView = new BitmapView(iFrame, "icon", icon, B_OP_OVER, false); + AddChild(iView); + iView->SetPosition(BPoint(4, 8)); + iView->SetViewColor(DarkGrey); + + regFrame.Set( + bgFrame.Width() - 80, bgFrame.bottom - 34, bgFrame.Width() - 8, bgFrame.bottom - 8 + ); + cancelFrame.Set(regFrame.left - 88, regFrame.top, regFrame.left - 8, regFrame.bottom); + BButton* cancel = + new BButton(cancelFrame, "RW cancel", lstring(131, "Cancel"), new BMessage('Rcnc')); + BButton* reg = new BButton(regFrame, "RW reg", lstring(426, "Register"), new BMessage('Rreg')); + reg->MakeDefault(true); + bg->AddChild(cancel); + bg->AddChild(reg); + + fName = new BTextControl( + BRect(4, regFrame.top - 30, bgFrame.Width() - 4, regFrame.top - 8), "Name", + lstring(425, "Name:"), "", new BMessage('Rnam') + ); + fName->SetDivider(50); + bg->AddChild(fName); + + if (type == REG_PPC) { + bg->AddChild(new BStringView( + BRect(4, 4, bgFrame.Width() - 4, 20), "rg1", lstring(436, "PowerPC hardware detected") + )); + bg->AddChild(new BStringView( + BRect(4, 20, bgFrame.Width() - 4, 36), "rg2", lstring(437, "This is a free version.") + )); + } else if (type == REG_HAS_14) { + bg->AddChild(new BStringView( + BRect(4, 4, bgFrame.Width() - 4, 20), "rg1", lstring(421, "Becasso 1.4 detected") + )); + bg->AddChild(new BStringView( + BRect(4, 20, bgFrame.Width() - 4, 36), "rg2", lstring(422, "This is a free upgrade.") + )); + } else if (type == REG_PREINST) { + bg->AddChild(new BStringView( + BRect(4, 4, bgFrame.Width() - 4, 20), "rg1", + lstring(430, "Becasso 2.0 was pre-installed,") + )); + bg->AddChild(new BStringView( + BRect(4, 20, bgFrame.Width() - 4, 36), "rg2", + lstring(431, "but hasn't been registered yet.") + )); + } else // must have the CD { - bg->AddChild (new BStringView (BRect (4, 4, bgFrame.Width() - 4, 20), "rg3", lstring (427, "Thank you for purchasing Becasso!"))); + bg->AddChild(new BStringView( + BRect(4, 4, bgFrame.Width() - 4, 20), "rg3", + lstring(427, "Thank you for purchasing Becasso!") + )); } - bg->AddChild (new BStringView (BRect (4, 40, bgFrame.Width() - 4, 56), "rg4", lstring (428, "Please register by entering your name."))); - bg->AddChild (new BStringView (BRect (4, 56, bgFrame.Width() - 4, 72), "rg5", lstring (429, "This will unlock the full version."))); + bg->AddChild(new BStringView( + BRect(4, 40, bgFrame.Width() - 4, 56), "rg4", + lstring(428, "Please register by entering your name.") + )); + bg->AddChild(new BStringView( + BRect(4, 56, bgFrame.Width() - 4, 72), "rg5", + lstring(429, "This will unlock the full version.") + )); } -RegWindow::~RegWindow () -{ -} +RegWindow::~RegWindow() {} -int32 RegWindow::Go () +int32 +RegWindow::Go() { // not too happy with this implementation... bool ishidden = false; Show(); - while (!ishidden) - { + while (!ishidden) { Lock(); ishidden = IsHidden(); Unlock(); - snooze (50000); + snooze(50000); } return (fStatus); } -void RegWindow::MessageReceived (BMessage *msg) +void +RegWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'Rcnc': fStatus = 0; Hide(); break; - case 'Rreg': - { + case 'Rreg': { extern char gAlphaMask[128]; - strcpy (gAlphaMask, fName->Text()); + strcpy(gAlphaMask, fName->Text()); fStatus = 1; Hide(); break; @@ -117,6 +137,6 @@ void RegWindow::MessageReceived (BMessage *msg) case 'Rnam': break; default: - BWindow::MessageReceived (msg); + BWindow::MessageReceived(msg); } } \ No newline at end of file diff --git a/source/RegWindow.h b/source/RegWindow.h index 118905a..8227309 100644 --- a/source/RegWindow.h +++ b/source/RegWindow.h @@ -5,31 +5,30 @@ #include -#define REG_NONE 0 -#define REG_CD 1 -#define REG_ESD 2 -#define REG_PREINST 3 -#define REG_PPC 4 -#define REG_HAIKU 5 -#define REG_HAS_14 14 -#define REG_HAS_15 15 +#define REG_NONE 0 +#define REG_CD 1 +#define REG_ESD 2 +#define REG_PREINST 3 +#define REG_PPC 4 +#define REG_HAIKU 5 +#define REG_HAS_14 14 +#define REG_HAS_15 15 class BTextControl; class RegWindow : public BWindow { -public: - - RegWindow (const BRect frame, const char *title, char type); -virtual ~RegWindow (); - -int32 Go(); -virtual void MessageReceived (BMessage *msg); - -private: -char fType; -int32 fStatus; -BTextControl *fName; + public: + RegWindow(const BRect frame, const char* title, char type); + virtual ~RegWindow(); + + int32 Go(); + virtual void MessageReceived(BMessage* msg); + + private: + char fType; + int32 fStatus; + BTextControl* fName; }; #endif diff --git a/source/ResizeWindow.cpp b/source/ResizeWindow.cpp index f4a3a1b..ccbf166 100644 --- a/source/ResizeWindow.cpp +++ b/source/ResizeWindow.cpp @@ -12,10 +12,12 @@ #include #include "Settings.h" -ResizeWindow::ResizeWindow (CanvasWindow *target, const char *title, int32 _h, int32 _w) -: BWindow (BRect (100, 100, 300, 248), title, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS) +ResizeWindow::ResizeWindow(CanvasWindow* target, const char* title, int32 _h, int32 _w) + : BWindow( + BRect(100, 100, 300, 248), title, B_TITLED_WINDOW, + B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS + ) { - char hS[16], wS[16], rD[16]; fTarget = target; fRez = 72; fH = _w; @@ -23,9 +25,9 @@ ResizeWindow::ResizeWindow (CanvasWindow *target, const char *title, int32 _h, i fHUnit = UNIT_PIXELS; fVUnit = UNIT_PIXELS; - BBox *text = new BBox ("SW box"); - text->SetLabel (lstring (180, "Canvas Size")); - + BBox* text = new BBox("SW box"); + text->SetLabel(lstring(180, "Canvas Size")); + #if 0 textFrame.Set (8, 80, 192, 120); BBox *rez = new BBox (textFrame, "SW r box"); @@ -33,151 +35,158 @@ ResizeWindow::ResizeWindow (CanvasWindow *target, const char *title, int32 _h, i bg->AddChild (rez); #endif - sprintf (hS, "%li", _h); - sprintf (wS, "%li", _w); - sprintf (rD, "%li", fRez); + BString hS, wS, rD; + + fNumberFormat.Format(hS, _h); + fNumberFormat.Format(wS, _w); + fNumberFormat.Format(rD, fRez); - newWidth = new BTextControl ("NewWidth", lstring (181, "Width"), wS, new BMessage ('Swdt')); - newHeight = new BTextControl ("NewHeight", lstring (182, "Height"), hS, new BMessage ('Shgt')); - rDPI = new BTextControl ("rez", lstring (186, "Resolution"), rD, new BMessage ('Srez')); - BStringView *dpiV = new BStringView ("dpiV", "dpi"); + newWidth = new BTextControl("NewWidth", lstring(181, "Width"), wS, new BMessage('Swdt')); + newHeight = new BTextControl("NewHeight", lstring(182, "Height"), hS, new BMessage('Shgt')); + rDPI = new BTextControl("rez", lstring(186, "Resolution"), rD, new BMessage('Srez')); + BStringView* dpiV = new BStringView("dpiV", "dpi"); - newHeight->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT); - newWidth->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT); - rDPI->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT); + newHeight->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); + newWidth->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); + rDPI->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); - BPopUpMenu *hPU = new BPopUpMenu (""); - hPU->AddItem (new BMenuItem (lstring (187, "pixels"), new BMessage ('h_px'))); - hPU->AddItem (new BMenuItem (lstring (188, "in"), new BMessage ('h_in'))); - hPU->AddItem (new BMenuItem (lstring (189, "cm"), new BMessage ('h_cm'))); - hPU->ItemAt(0)->SetMarked (true); + BPopUpMenu* hPU = new BPopUpMenu(""); + hPU->AddItem(new BMenuItem(lstring(187, "pixels"), new BMessage('h_px'))); + hPU->AddItem(new BMenuItem(lstring(188, "in"), new BMessage('h_in'))); + hPU->AddItem(new BMenuItem(lstring(189, "cm"), new BMessage('h_cm'))); + hPU->ItemAt(0)->SetMarked(true); - BMenuField *hMF = new BMenuField ("hUnit", NULL, hPU); - BPopUpMenu *vPU = new BPopUpMenu (""); - vPU->AddItem (new BMenuItem (lstring (187, "pixels"), new BMessage ('v_px'))); - vPU->AddItem (new BMenuItem (lstring (188, "in"), new BMessage ('v_in'))); - vPU->AddItem (new BMenuItem (lstring (189, "cm"), new BMessage ('v_cm'))); - vPU->ItemAt(0)->SetMarked (true); + BMenuField* hMF = new BMenuField("hUnit", NULL, hPU); + BPopUpMenu* vPU = new BPopUpMenu(""); + vPU->AddItem(new BMenuItem(lstring(187, "pixels"), new BMessage('v_px'))); + vPU->AddItem(new BMenuItem(lstring(188, "in"), new BMessage('v_in'))); + vPU->AddItem(new BMenuItem(lstring(189, "cm"), new BMessage('v_cm'))); + vPU->ItemAt(0)->SetMarked(true); - BMenuField *vMF = new BMenuField ("vUnit", NULL, vPU); + BMenuField* vMF = new BMenuField("vUnit", NULL, vPU); - BView *view = new BView("SW bg", B_WILL_DRAW); - view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + BView* view = new BView("SW bg", B_WILL_DRAW); + view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BLayoutBuilder::Grid<>(view, 2.0, 2.0) // FIX - .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) - .Add(newWidth->CreateLabelLayoutItem(), 0, 0) - .Add(newWidth->CreateTextViewLayoutItem(), 1, 0) - .Add(hMF, 2,0) - .Add(newHeight->CreateLabelLayoutItem(), 0, 1) - .Add(newHeight->CreateTextViewLayoutItem(), 1, 1) - .Add(vMF, 2, 1) - .Add(rDPI->CreateLabelLayoutItem(), 0, 2) - .Add(rDPI->CreateTextViewLayoutItem(), 1, 2) - .Add(dpiV, 2, 2); + .SetInsets( + B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING + ) + .Add(newWidth->CreateLabelLayoutItem(), 0, 0) + .Add(newWidth->CreateTextViewLayoutItem(), 1, 0) + .Add(hMF, 2, 0) + .Add(newHeight->CreateLabelLayoutItem(), 0, 1) + .Add(newHeight->CreateTextViewLayoutItem(), 1, 1) + .Add(vMF, 2, 1) + .Add(rDPI->CreateLabelLayoutItem(), 0, 2) + .Add(rDPI->CreateTextViewLayoutItem(), 1, 2) + .Add(dpiV, 2, 2); text->AddChild(view); - BButton *cancel = new BButton ("RSW cancel", lstring (131, "Cancel"), new BMessage ('RScn')); - BButton *open = new BButton ("RSW ok", lstring (136, "OK"), new BMessage ('RSok')); - open->MakeDefault (true); + BButton* cancel = new BButton("RSW cancel", lstring(131, "Cancel"), new BMessage('RScn')); + BButton* open = new BButton("RSW ok", lstring(136, "OK"), new BMessage('RSok')); + open->MakeDefault(true); BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING) - .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) + .SetInsets( + B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING + ) .Add(text) .AddGroup(B_HORIZONTAL) - .AddGlue() - .Add(cancel) - .Add(open); - + .AddGlue() + .Add(cancel) + .Add(open); + fStatus = 0; } -ResizeWindow::~ResizeWindow () -{ -} +ResizeWindow::~ResizeWindow() {} -void ResizeWindow::recalc () +void +ResizeWindow::recalc() { - char h[16], v[16]; - switch (fHUnit) - { + BString h, v; + switch (fHUnit) { case UNIT_PIXELS: - sprintf (h, "%li", fH); - newWidth->SetText (h); + fNumberFormat.Format(h, fH); + newWidth->SetText(h); break; case UNIT_INCH: - sprintf (h, "%.2f", (float) fH/fRez + .005); - newWidth->SetText (h); + fNumberFormat.SetPrecision(2); + fNumberFormat.Format(h, (double)(fH / fRez + .005)); + newWidth->SetText(h); break; case UNIT_CM: - sprintf (h, "%.2f", (float) fH/fRez*2.54 + .005); - newWidth->SetText (h); + fNumberFormat.SetPrecision(2); + fNumberFormat.Format(h, (double)(fH / fRez * 2.54 + .005)); + newWidth->SetText(h); break; default: - fprintf (stderr, "SizeWindow: Unknown Unit (H)\n"); + fprintf(stderr, "SizeWindow: Unknown Unit (H)\n"); } - switch (fVUnit) - { + switch (fVUnit) { case UNIT_PIXELS: - sprintf (v, "%li", fV); - newHeight->SetText (v); + fNumberFormat.Format(v, fV); + newHeight->SetText(v); break; case UNIT_INCH: - sprintf (v, "%.2f", (float) fV/fRez + .005); - newHeight->SetText (v); + fNumberFormat.SetPrecision(2); + fNumberFormat.Format(v, (double)(fV / fRez + .005)); + newHeight->SetText(v); break; case UNIT_CM: - sprintf (v, "%.2f", (float) fV/fRez*2.54 + .005); - newHeight->SetText (v); + fNumberFormat.SetPrecision(2); + fNumberFormat.Format(v, (double)(fV / fRez * 2.54 + .005)); + newHeight->SetText(v); break; default: - fprintf (stderr, "SizeWindow: Unknown Unit (V)\n"); + fprintf(stderr, "SizeWindow: Unknown Unit (V)\n"); } } -void ResizeWindow::readvalues () +void +ResizeWindow::readvalues() { - switch (fHUnit) - { + switch (fHUnit) { case UNIT_PIXELS: - fH = atoi (newWidth->Text()); + fH = atoi(newWidth->Text()); break; case UNIT_INCH: - fH = int32 (fRez * atof (newWidth->Text())); + fH = int32(fRez * atof(newWidth->Text())); break; case UNIT_CM: - fH = int32 (fRez / 2.54 * atof (newWidth->Text())); + fH = int32(fRez / 2.54 * atof(newWidth->Text())); break; } - switch (fVUnit) - { + switch (fVUnit) { case UNIT_PIXELS: - fV = atoi (newHeight->Text()); + fV = atoi(newHeight->Text()); break; case UNIT_INCH: - fV = int32 (fRez * atof (newHeight->Text())); + fV = int32(fRez * atof(newHeight->Text())); break; case UNIT_CM: - fV = int32 (fRez / 2.54 * atof (newHeight->Text())); + fV = int32(fRez / 2.54 * atof(newHeight->Text())); break; } } -void ResizeWindow::MessageReceived (BMessage *message) +void +ResizeWindow::MessageReceived(BMessage* message) { - switch (message->what) - { + switch (message->what) { case 'RScn': Quit(); break; - case 'RSok': - { + case 'RSok': { readvalues(); - BMessage msg ('rszt'); - msg.AddInt32 ("width", fH); - msg.AddInt32 ("height", fV); - fTarget->PostMessage (&msg); + BMessage msg('rszt'); + msg.AddInt32("width", fH); + msg.AddInt32("height", fV); + fTarget->PostMessage(&msg); Quit(); break; } @@ -210,7 +219,7 @@ void ResizeWindow::MessageReceived (BMessage *message) readvalues(); break; case 'Srez': - fRez = atoi (rDPI->Text()); + fRez = atoi(rDPI->Text()); readvalues(); break; default: diff --git a/source/ResizeWindow.h b/source/ResizeWindow.h index b6ae6d2..cdb1a2a 100644 --- a/source/ResizeWindow.h +++ b/source/ResizeWindow.h @@ -3,40 +3,42 @@ #include #include +#include #include #include "CanvasWindow.h" -#define UNIT_PIXELS 0 -#define UNIT_INCH 1 -#define UNIT_CM 2 +#define UNIT_PIXELS 0 +#define UNIT_INCH 1 +#define UNIT_CM 2 class ResizeWindow : public BWindow { -public: - ResizeWindow (CanvasWindow *target, const char *title, int32 h, int32 w); -virtual ~ResizeWindow (); - -virtual void MessageReceived (BMessage *message); - -int32 w() { return fH; }; -int32 h() { return fV; }; - -private: - -void recalc (); -void readvalues (); - -typedef BWindow inherited; -BTextControl *newWidth; -BTextControl *newHeight; -BTextControl *rDPI; -CanvasWindow *fTarget; -int32 fRez; -int32 fStatus; -int32 fHUnit; -int32 fVUnit; -int32 fH; -int32 fV; + public: + ResizeWindow(CanvasWindow* target, const char* title, int32 h, int32 w); + virtual ~ResizeWindow(); + + virtual void MessageReceived(BMessage* message); + + int32 w() { return fH; }; + + int32 h() { return fV; }; + + private: + void recalc(); + void readvalues(); + + typedef BWindow inherited; + BTextControl* newWidth; + BTextControl* newHeight; + BTextControl* rDPI; + BNumberFormat fNumberFormat; + CanvasWindow* fTarget; + int32 fRez; + int32 fStatus; + int32 fHUnit; + int32 fVUnit; + int32 fH; + int32 fV; }; -#endif \ No newline at end of file +#endif diff --git a/source/RoColor.h b/source/RoColor.h index c8eb9f7..71422c4 100644 --- a/source/RoColor.h +++ b/source/RoColor.h @@ -1,16 +1,16 @@ #ifndef ROCOLOR_H #define ROCOLOR_H -struct roSColor -{ - float m_Red; - float m_Green; - float m_Blue; - float m_Alpha; - float m_Hue; +struct roSColor +{ + float m_Red; + float m_Green; + float m_Blue; + float m_Alpha; + float m_Hue; }; -/* Extended Colour Type Constant */ -#define RO_COLOR_STRUCT_128_TYPE 'roCr' +/* Extended Colour Type Constant */ +#define RO_COLOR_STRUCT_128_TYPE 'roCr' -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/SBitmap.cpp b/source/SBitmap.cpp index 4135881..e023338 100644 --- a/source/SBitmap.cpp +++ b/source/SBitmap.cpp @@ -5,91 +5,91 @@ #include #include -SBitmap::SBitmap (BBitmap *src) +SBitmap::SBitmap(BBitmap* src) { fBounds = src->Bounds(); - switch (src->ColorSpace()) - { - case B_COLOR_8_BIT: - case B_GRAYSCALE_8_BIT: - fBPP = 1; - break; - default: - fBPP = 4; - break; + switch (src->ColorSpace()) { + case B_COLOR_8_BIT: + case B_GRAYSCALE_8_BIT: + fBPP = 1; + break; + default: + fBPP = 4; + break; } fBPR = fBPP * (fBounds.IntegerWidth() + 1); - if (fBPR % 4) // padding required + if (fBPR % 4) // padding required { - uint32 pad = 4 - ((uint32) fBPR % 4); + uint32 pad = 4 - ((uint32)fBPR % 4); fBPR += pad; } - int32 bitslength = fBPR*(fBounds.IntegerHeight() + 1); - - ASSERT_WITH_MESSAGE (bitslength == src->BitsLength(), "BitsLength() mismatch"); - - fBits = malloc (bitslength); + int32 bitslength = fBPR * (fBounds.IntegerHeight() + 1); + + ASSERT_WITH_MESSAGE(bitslength == src->BitsLength(), "BitsLength() mismatch"); - memcpy (fBits, src->Bits(), src->BitsLength()); + fBits = malloc(bitslength); + + memcpy(fBits, src->Bits(), src->BitsLength()); } -SBitmap::SBitmap (const BRect bounds, const color_space cs) -: fBounds (bounds), fCS (cs) +SBitmap::SBitmap(const BRect bounds, const color_space cs) : fBounds(bounds), fCS(cs) { - switch (cs) - { - case B_COLOR_8_BIT: - case B_GRAYSCALE_8_BIT: - fBPP = 1; - break; - default: - fBPP = 4; - break; + switch (cs) { + case B_COLOR_8_BIT: + case B_GRAYSCALE_8_BIT: + fBPP = 1; + break; + default: + fBPP = 4; + break; } fBPR = fBPP * (fBounds.IntegerWidth() + 1); - if (fBPR % 4) // padding required + if (fBPR % 4) // padding required { - uint32 pad = 4 - ((uint32) fBPR % 4); + uint32 pad = 4 - ((uint32)fBPR % 4); fBPR += pad; } - - int32 bitslength = fBPR*(fBounds.IntegerHeight() + 1); - fBits = malloc (bitslength); -} -SBitmap::~SBitmap () -{ - free (fBits); + int32 bitslength = fBPR * (fBounds.IntegerHeight() + 1); + fBits = malloc(bitslength); } -int32 SBitmap::BytesPerRow () const +SBitmap::~SBitmap() { free(fBits); } + +int32 +SBitmap::BytesPerRow() const { return fBPR; } -int32 SBitmap::BytesPerPixel () const +int32 +SBitmap::BytesPerPixel() const { return fBPP; } -int32 SBitmap::BitsLength () const +int32 +SBitmap::BitsLength() const { - return fBPR*(fBounds.IntegerHeight() + 1); + return fBPR * (fBounds.IntegerHeight() + 1); } -void *SBitmap::Bits () +void* +SBitmap::Bits() { return fBits; } -BRect SBitmap::Bounds () const +BRect +SBitmap::Bounds() const { return fBounds; } -color_space SBitmap::ColorSpace () const +color_space +SBitmap::ColorSpace() const { return fCS; } diff --git a/source/SBitmap.h b/source/SBitmap.h index af2b0cc..dc63bd8 100644 --- a/source/SBitmap.h +++ b/source/SBitmap.h @@ -7,26 +7,25 @@ class SBitmap { -public: - SBitmap (BBitmap *src); - SBitmap (const BRect bounds, const color_space cs); - ~SBitmap (); - - int32 BytesPerRow () const; - int32 BytesPerPixel () const; - int32 BitsLength () const; - void *Bits (); - BRect Bounds () const; - color_space ColorSpace () const; + public: + SBitmap(BBitmap* src); + SBitmap(const BRect bounds, const color_space cs); + ~SBitmap(); -private: + int32 BytesPerRow() const; + int32 BytesPerPixel() const; + int32 BitsLength() const; + void* Bits(); + BRect Bounds() const; + color_space ColorSpace() const; - BRect fBounds; - int32 fBPP; - color_space fCS; - int32 fBPR; - - void *fBits; + private: + BRect fBounds; + int32 fBPP; + color_space fCS; + int32 fBPR; + + void* fBits; }; #endif \ No newline at end of file diff --git a/source/SView.cpp b/source/SView.cpp index 0f45ef6..417a13b 100644 --- a/source/SView.cpp +++ b/source/SView.cpp @@ -5,8 +5,8 @@ #include #include -SView::SView (BRect frame, const char *name, uint32 resizeMask, uint32 flags) -: BView (frame, name, resizeMask, flags) +SView::SView(BRect frame, const char* name, uint32 resizeMask, uint32 flags) + : BView(frame, name, resizeMask, flags) { fScale = 1; fPressure = 255; @@ -14,62 +14,58 @@ SView::SView (BRect frame, const char *name, uint32 resizeMask, uint32 flags) fSnoozeTime = 20000; } -SView::~SView () -{ -} +SView::~SView() {} -void SView::GetMouse (BPoint *pos, uint32 *buttons, bool checkqueue) +void +SView::GetMouse(BPoint* pos, uint32* buttons, bool checkqueue) { // printf ("SView::GetMouse\n"); - inherited::GetMouse (pos, buttons, checkqueue); - (*pos).x = int ((*pos).x/fScale + 0.5); - (*pos).y = int ((*pos).y/fScale + 0.5); + inherited::GetMouse(pos, buttons, checkqueue); + (*pos).x = int((*pos).x / fScale + 0.5); + (*pos).y = int((*pos).y / fScale + 0.5); } -void SView::GetPosition (Position *position, bool setcursor) +void +SView::GetPosition(Position* position, bool setcursor) { // clock_t start, end; // start = clock(); BPoint point; uint32 buttons; - GetMouse (&point, &buttons, true); - BMessage *currentMessage = Window()->CurrentMessage(); - extern Tablet *wacom; - if (wacom->IsValid() && wacom->Update() == B_OK) - { - if (wacom->Proximity()) - { + GetMouse(&point, &buttons, true); + BMessage* currentMessage = Window()->CurrentMessage(); + extern Tablet* wacom; + if (wacom->IsValid() && wacom->Update() == B_OK) { + if (wacom->Proximity()) { fDevice = DEV_TABLET; - position->fPoint = wacom->Point(); - position->fTilt = wacom->Tilt(); - position->fPressure = uint8 (255*wacom->Pressure()); + position->fPoint = wacom->Point(); + position->fTilt = wacom->Tilt(); + position->fPressure = uint8(255 * wacom->Pressure()); position->fProximity = wacom->Proximity(); - if (setcursor) - { - BPoint scrpoint = ConvertToScreen (position->fPoint); - set_mouse_position (int32 (scrpoint.x), int32 (scrpoint.y)); + if (setcursor) { + BPoint scrpoint = ConvertToScreen(position->fPoint); + set_mouse_position(int32(scrpoint.x), int32(scrpoint.y)); } // printf ("%d\n", wacom->Buttons()); - switch (wacom->Buttons()) - { - case 0: // Actually, only proximity here... + switch (wacom->Buttons()) { + case 0: // Actually, only proximity here... position->fButtons = 0; break; case 1: - case 2: // Stylus point + case 2: // Stylus point position->fButtons = B_PRIMARY_MOUSE_BUTTON; break; - case 3: // Side switch + case 3: // Side switch position->fButtons = B_SECONDARY_MOUSE_BUTTON; break; case 4: position->fButtons = 0; break; - case 5: // "Eraser" + case 5: // "Eraser" position->fButtons = B_TERTIARY_MOUSE_BUTTON; break; default: - fprintf (stderr, "Unsupported button combination\n"); + fprintf(stderr, "Unsupported button combination\n"); } // end = clock(); // printf ("Took %d ms\n", (end - start)); @@ -77,105 +73,117 @@ void SView::GetPosition (Position *position, bool setcursor) } } // Else (i.e. no tablet or no proximity) - if (fDevice == DEV_TABLET) - { - position->fButtons = 0; + if (fDevice == DEV_TABLET) { + position->fButtons = 0; position->fProximity = false; fDevice = DEV_MOUSE; return; } fDevice = DEV_MOUSE; - position->fPoint = point; + position->fPoint = point; float tx, ty; - if (currentMessage->FindFloat ("be:tilt_x", &tx) != B_OK - || currentMessage->FindFloat ("be:tilt_y", &ty) != B_OK) - position->fTilt = BPoint (0, 0); + if (currentMessage->FindFloat("be:tilt_x", &tx) != B_OK || + currentMessage->FindFloat("be:tilt_y", &ty) != B_OK) + position->fTilt = BPoint(0, 0); else - position->fTilt = BPoint (tx, ty); + position->fTilt = BPoint(tx, ty); float pres; - if (currentMessage->FindFloat ("be:tablet_pressure", &pres) == B_OK) - fPressure = uint8 (255*pres); + if (currentMessage->FindFloat("be:tablet_pressure", &pres) == B_OK) + fPressure = uint8(255 * pres); else fPressure = 255; - position->fPressure = fPressure; -// printf ("Pressure: %d\n", fPressure); - position->fButtons = buttons; + position->fPressure = fPressure; + // printf ("Pressure: %d\n", fPressure); + position->fButtons = buttons; position->fProximity = false; } -inline void SView::StrokeRect (BRect r, pattern p) +inline void +SView::StrokeRect(BRect r, pattern p) { - inherited::StrokeRect (makePositive (r), p); + inherited::StrokeRect(makePositive(r), p); } -inline void SView::FillRect (BRect r, pattern p) +inline void +SView::FillRect(BRect r, pattern p) { - inherited::FillRect (makePositive (r), p); + inherited::FillRect(makePositive(r), p); } -inline void SView::InvertRect (BRect r) +inline void +SView::InvertRect(BRect r) { - inherited::InvertRect (makePositive (r)); + inherited::InvertRect(makePositive(r)); } -inline void SView::StrokeRoundRect (BRect r, float xRadius, float yRadius, pattern p) +inline void +SView::StrokeRoundRect(BRect r, float xRadius, float yRadius, pattern p) { - inherited::StrokeRoundRect (makePositive (r), xRadius, yRadius, p); + inherited::StrokeRoundRect(makePositive(r), xRadius, yRadius, p); } -inline void SView::FillRoundRect (BRect r, float xRadius, float yRadius, pattern p) +inline void +SView::FillRoundRect(BRect r, float xRadius, float yRadius, pattern p) { - inherited::FillRoundRect (makePositive (r), xRadius, yRadius, p); + inherited::FillRoundRect(makePositive(r), xRadius, yRadius, p); } -inline void SView::StrokeEllipse (BRect r, pattern p) +inline void +SView::StrokeEllipse(BRect r, pattern p) { - inherited::StrokeEllipse (makePositive (r), p); + inherited::StrokeEllipse(makePositive(r), p); } -inline void SView::StrokeEllipse (BPoint center, float xRadius, float yRadius, pattern p) +inline void +SView::StrokeEllipse(BPoint center, float xRadius, float yRadius, pattern p) { - inherited::StrokeEllipse (center, xRadius, yRadius, p); + inherited::StrokeEllipse(center, xRadius, yRadius, p); } -inline void SView::FillEllipse (BRect r, pattern p) +inline void +SView::FillEllipse(BRect r, pattern p) { - inherited::FillEllipse (makePositive (r), p); + inherited::FillEllipse(makePositive(r), p); } -inline void SView::FillEllipse (BPoint center, float xRadius, float yRadius, pattern p) +inline void +SView::FillEllipse(BPoint center, float xRadius, float yRadius, pattern p) { - inherited::FillEllipse (center, xRadius, yRadius, p); + inherited::FillEllipse(center, xRadius, yRadius, p); } -inline void SView::SStrokeRect (BRect r, pattern p) +inline void +SView::SStrokeRect(BRect r, pattern p) { r.left *= fScale; r.top *= fScale; r.right *= fScale; r.bottom *= fScale; - inherited::StrokeRect (makePositive (r), p); + inherited::StrokeRect(makePositive(r), p); } -inline void SView::SFillRect (BRect r, pattern p) +inline void +SView::SFillRect(BRect r, pattern p) { r.left *= fScale; r.top *= fScale; r.right *= fScale; r.bottom *= fScale; - inherited::FillRect (makePositive (r), p); + inherited::FillRect(makePositive(r), p); } -inline void SView::SInvertRect (BRect r) +inline void +SView::SInvertRect(BRect r) { r.left *= fScale; r.top *= fScale; r.right *= fScale; r.bottom *= fScale; - inherited::InvertRect (makePositive (r)); + inherited::InvertRect(makePositive(r)); } -inline void SView::SStrokeRoundRect (BRect r, float xRadius, float yRadius, pattern p) +inline void +SView::SStrokeRoundRect(BRect r, float xRadius, float yRadius, pattern p) { r.left *= fScale; r.top *= fScale; @@ -183,10 +191,11 @@ inline void SView::SStrokeRoundRect (BRect r, float xRadius, float yRadius, patt r.bottom *= fScale; xRadius *= fScale; yRadius *= fScale; - inherited::StrokeRoundRect (makePositive (r), xRadius, yRadius, p); + inherited::StrokeRoundRect(makePositive(r), xRadius, yRadius, p); } -inline void SView::SFillRoundRect (BRect r, float xRadius, float yRadius, pattern p) +inline void +SView::SFillRoundRect(BRect r, float xRadius, float yRadius, pattern p) { r.left *= fScale; r.top *= fScale; @@ -194,51 +203,56 @@ inline void SView::SFillRoundRect (BRect r, float xRadius, float yRadius, patter r.bottom *= fScale; xRadius *= fScale; yRadius *= fScale; - inherited::FillRoundRect (makePositive (r), xRadius, yRadius, p); + inherited::FillRoundRect(makePositive(r), xRadius, yRadius, p); } -inline void SView::SStrokeEllipse (BRect r, pattern p) +inline void +SView::SStrokeEllipse(BRect r, pattern p) { r.left *= fScale; r.top *= fScale; r.right *= fScale; r.bottom *= fScale; - inherited::StrokeEllipse (makePositive (r), p); + inherited::StrokeEllipse(makePositive(r), p); } -inline void SView::SStrokeEllipse (BPoint center, float xRadius, float yRadius, pattern p) +inline void +SView::SStrokeEllipse(BPoint center, float xRadius, float yRadius, pattern p) { center.x *= fScale; center.y *= fScale; xRadius *= fScale; yRadius *= fScale; - inherited::StrokeEllipse (center, xRadius, yRadius, p); + inherited::StrokeEllipse(center, xRadius, yRadius, p); } -inline void SView::SFillEllipse (BRect r, pattern p) +inline void +SView::SFillEllipse(BRect r, pattern p) { r.left *= fScale; r.top *= fScale; r.right *= fScale; r.bottom *= fScale; - inherited::FillEllipse (makePositive (r), p); + inherited::FillEllipse(makePositive(r), p); } -inline void SView::SFillEllipse (BPoint center, float xRadius, float yRadius, pattern p) +inline void +SView::SFillEllipse(BPoint center, float xRadius, float yRadius, pattern p) { center.x *= fScale; center.y *= fScale; xRadius *= fScale; yRadius *= fScale; - inherited::FillEllipse (center, xRadius, yRadius, p); + inherited::FillEllipse(center, xRadius, yRadius, p); } -BRect SView::makePositive (BRect r) +BRect +SView::makePositive(BRect r) { BRect res; - res.left = min_c (r.left, r.right); - res.right = max_c (r.left, r.right); - res.top = min_c (r.top, r.bottom); - res.bottom = max_c (r.top, r.bottom); + res.left = min_c(r.left, r.right); + res.right = max_c(r.left, r.right); + res.top = min_c(r.top, r.bottom); + res.bottom = max_c(r.top, r.bottom); return res; } \ No newline at end of file diff --git a/source/SView.h b/source/SView.h index 8aa1fa8..4f5a7f9 100644 --- a/source/SView.h +++ b/source/SView.h @@ -8,48 +8,56 @@ class SView : public BView { -public: - SView (BRect frame, const char *name, uint32 resizeMask, uint32 flags); -virtual ~SView (); -virtual void StrokeRect (BRect r, pattern p = B_SOLID_HIGH); -virtual void FillRect (BRect r, pattern p = B_SOLID_HIGH); -virtual void InvertRect (BRect r); -virtual void StrokeRoundRect (BRect r, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); -virtual void FillRoundRect (BRect r, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); -virtual void StrokeEllipse (BRect r, pattern p = B_SOLID_HIGH); -virtual void StrokeEllipse (BPoint center, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); -virtual void FillEllipse (BRect r, pattern p = B_SOLID_HIGH); -virtual void FillEllipse (BPoint center, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); - -virtual void SStrokeRect (BRect r, pattern p = B_SOLID_HIGH); -virtual void SFillRect (BRect r, pattern p = B_SOLID_HIGH); -virtual void SInvertRect (BRect r); -virtual void SStrokeRoundRect (BRect r, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); -virtual void SFillRoundRect (BRect r, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); -virtual void SStrokeEllipse (BRect r, pattern p = B_SOLID_HIGH); -virtual void SStrokeEllipse (BPoint center, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); -virtual void SFillEllipse (BRect r, pattern p = B_SOLID_HIGH); -virtual void SFillEllipse (BPoint center, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); -virtual void GetMouse (BPoint *pos, uint32 *buttons, bool checkqueue = true); -virtual void GetPosition (Position *position, bool setcursor = false); - -inline BRect makePositive (BRect r); -void setScale (float s) { fScale = s; }; -void setPressure (uint8 pressure) { fPressure = pressure; }; -uint8 getPressure () { return fPressure; }; -uint32 getSnoozeTime () { return fSnoozeTime; }; -void setSnoozeTime (uint32 time) { fSnoozeTime = time; }; - -private: -typedef BView inherited; -float fScale; -uint8 fPressure; -uint32 fSnoozeTime; -int fDevice; + public: + SView(BRect frame, const char* name, uint32 resizeMask, uint32 flags); + virtual ~SView(); + virtual void StrokeRect(BRect r, pattern p = B_SOLID_HIGH); + virtual void FillRect(BRect r, pattern p = B_SOLID_HIGH); + virtual void InvertRect(BRect r); + virtual void StrokeRoundRect(BRect r, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); + virtual void FillRoundRect(BRect r, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); + virtual void StrokeEllipse(BRect r, pattern p = B_SOLID_HIGH); + virtual void + StrokeEllipse(BPoint center, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); + virtual void FillEllipse(BRect r, pattern p = B_SOLID_HIGH); + virtual void FillEllipse(BPoint center, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); + + virtual void SStrokeRect(BRect r, pattern p = B_SOLID_HIGH); + virtual void SFillRect(BRect r, pattern p = B_SOLID_HIGH); + virtual void SInvertRect(BRect r); + virtual void SStrokeRoundRect(BRect r, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); + virtual void SFillRoundRect(BRect r, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); + virtual void SStrokeEllipse(BRect r, pattern p = B_SOLID_HIGH); + virtual void + SStrokeEllipse(BPoint center, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); + virtual void SFillEllipse(BRect r, pattern p = B_SOLID_HIGH); + virtual void + SFillEllipse(BPoint center, float xRadius, float yRadius, pattern p = B_SOLID_HIGH); + virtual void GetMouse(BPoint* pos, uint32* buttons, bool checkqueue = true); + virtual void GetPosition(Position* position, bool setcursor = false); + + inline BRect makePositive(BRect r); + + void setScale(float s) { fScale = s; }; + + void setPressure(uint8 pressure) { fPressure = pressure; }; + + uint8 getPressure() { return fPressure; }; + + uint32 getSnoozeTime() { return fSnoozeTime; }; + + void setSnoozeTime(uint32 time) { fSnoozeTime = time; }; + + private: + typedef BView inherited; + float fScale; + uint8 fPressure; + uint32 fSnoozeTime; + int fDevice; }; -#define DEV_NONE 0 -#define DEV_MOUSE 1 +#define DEV_NONE 0 +#define DEV_MOUSE 1 #define DEV_TABLET 2 -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/Selection.cpp b/source/Selection.cpp index 2bd9316..21f163d 100644 --- a/source/Selection.cpp +++ b/source/Selection.cpp @@ -3,27 +3,25 @@ #include #include -Selection::Selection (BRect bounds) -: BBitmap (bounds, B_BITMAP_ACCEPTS_VIEWS, B_GRAYSCALE_8_BIT) +Selection::Selection(BRect bounds) : BBitmap(bounds, B_BITMAP_ACCEPTS_VIEWS, B_GRAYSCALE_8_BIT) { fRect = bounds; fMode = DM_BLEND; - bzero (Bits(), BitsLength()); + bzero(Bits(), BitsLength()); } -Selection::Selection (const Selection& selection) -: BBitmap (selection.fRect, B_BITMAP_ACCEPTS_VIEWS, B_GRAYSCALE_8_BIT) +Selection::Selection(const Selection& selection) + : BBitmap(selection.fRect, B_BITMAP_ACCEPTS_VIEWS, B_GRAYSCALE_8_BIT) { fRect = selection.fRect; fMode = selection.fMode; - bzero (Bits(), BitsLength()); + bzero(Bits(), BitsLength()); } -Selection::~Selection () -{ -} +Selection::~Selection() {} -void Selection::ClearTo (grey_pixel p) +void +Selection::ClearTo(grey_pixel p) { - memset (Bits(), p, BitsLength()); + memset(Bits(), p, BitsLength()); } diff --git a/source/Selection.h b/source/Selection.h index 323aec8..8ac0ba3 100644 --- a/source/Selection.h +++ b/source/Selection.h @@ -10,19 +10,23 @@ class IMPEXP Selection : public BBitmap { -public: - Selection (BRect bounds); - Selection (const Selection& selection); -virtual ~Selection (); -int getMode () { return fMode; }; -void setMode (int mode) { fMode = mode; }; -BRect Bounds () { return fRect; }; -void ClearTo (grey_pixel p); - -private: -typedef BBitmap inherited; -BRect fRect; -int fMode; + public: + Selection(BRect bounds); + Selection(const Selection& selection); + virtual ~Selection(); + + int getMode() { return fMode; }; + + void setMode(int mode) { fMode = mode; }; + + BRect Bounds() { return fRect; }; + + void ClearTo(grey_pixel p); + + private: + typedef BBitmap inherited; + BRect fRect; + int fMode; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/Settings.cpp b/source/Settings.cpp index 4dd050e..94d9e28 100644 --- a/source/Settings.cpp +++ b/source/Settings.cpp @@ -10,11 +10,12 @@ #include #include -BLocker g_settings_lock ("Becasso Settings Lock"); +BLocker g_settings_lock("Becasso Settings Lock"); becasso_settings g_settings; -static char *lStrings[MAX_STRINGS]; +static char* lStrings[MAX_STRINGS]; -BPoint get_window_origin (uint32 index) +BPoint +get_window_origin(uint32 index) { BPoint origin; g_settings_lock.Lock(); @@ -23,7 +24,8 @@ BPoint get_window_origin (uint32 index) return origin; } -void set_window_origin (uint32 index, BPoint origin) +void +set_window_origin(uint32 index, BPoint origin) { g_settings_lock.Lock(); g_settings.origin[index] = origin; @@ -33,73 +35,71 @@ void set_window_origin (uint32 index, BPoint origin) typedef struct { - entry_ref ref; - time_t mtime; + entry_ref ref; + time_t mtime; } refandtime; #ifdef BE_RECENT_MENU -BMenuItem *make_recent_menu () +BMenuItem* +make_recent_menu() { g_settings_lock.Lock(); int32 max_entries = g_settings.recents; g_settings_lock.Unlock(); - const char *typelist[2] = { "image", "application/postscript" }; - BMenuItem *recent = new BMenuItem (BRecentFilesList::NewFileListMenu (lstring (12, "Open…"), - NULL, NULL, be_app, max_entries, false, - typelist, 2, NULL), new BMessage ('open')); - recent->SetShortcut ('O', B_COMMAND_KEY); + const char* typelist[2] = {"image", "application/postscript"}; + BMenuItem* recent = new BMenuItem( + BRecentFilesList::NewFileListMenu( + lstring(12, "Open…"), NULL, NULL, be_app, max_entries, false, typelist, 2, NULL + ), + new BMessage('open') + ); + recent->SetShortcut('O', B_COMMAND_KEY); return recent; } #else -void make_recent_menu (BMenu *menu) +void +make_recent_menu(BMenu* menu) { for (int32 i = menu->CountItems(); i > 0; i--) - delete menu->RemoveItem (int32 (0)); - + delete menu->RemoveItem(int32(0)); + BPath path; - if (find_directory (B_USER_SETTINGS_DIRECTORY, &path) == B_OK) - { - path.Append ("Becasso/Recent"); - BDirectory dir (path.Path()); + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { + path.Append("Becasso/Recent"); + BDirectory dir(path.Path()); refandtime entryList[256]; int32 num_entries = 0; g_settings_lock.Lock(); int32 max_entries = g_settings.recents; g_settings_lock.Unlock(); BEntry entry; - while (dir.GetNextEntry (&entry, false) == B_OK) - { + while (dir.GetNextEntry(&entry, false) == B_OK) { entry_ref ref; - entry.GetRef (&ref); + entry.GetRef(&ref); entryList[num_entries].ref = ref; - - BNode node (&entry); + + BNode node(&entry); time_t mtime; - node.GetModificationTime (&mtime); // modification time _of the link_ + node.GetModificationTime(&mtime); // modification time _of the link_ entryList[num_entries++].mtime = mtime; } - if (!num_entries) - { - menu->AddItem (new BMenuItem ("", NULL)); - } - else // we have a list of entry_refs now. + if (!num_entries) { + menu->AddItem(new BMenuItem("", NULL)); + } else // we have a list of entry_refs now. { // printf ("%ld entries found\n", num_entries); // Since the #items in the list will be small, do a stupid sort - for (int i = 0; i < num_entries; i++) - { + for (int i = 0; i < num_entries; i++) { int index = i; time_t mtime = entryList[i].mtime; time_t mtimei = mtime; int j; - for (j = i; j < num_entries; j++) - { - if (difftime (entryList[j].mtime, mtimei) > 0) - { + for (j = i; j < num_entries; j++) { + if (difftime(entryList[j].mtime, mtimei) > 0) { index = j; mtimei = entryList[j].mtime; } @@ -109,26 +109,24 @@ void make_recent_menu (BMenu *menu) entryList[i] = entryList[index]; entryList[index] = tmp; } - if (num_entries > max_entries) - { - for (int i = max_entries; i < num_entries; i++) - { - BEntry entry (&entryList[i].ref); + if (num_entries > max_entries) { + for (int i = max_entries; i < num_entries; i++) { + BEntry entry(&entryList[i].ref); entry.Remove(); } } - for (int i = min_c (num_entries, max_entries) - 1; i >= 0; i--) - { + for (int i = min_c(num_entries, max_entries) - 1; i >= 0; i--) { char name[B_FILE_NAME_LENGTH]; entry_ref ref = entryList[i].ref; - BEntry entry (&ref); - entry.GetName (name); - BMessage *msg = new BMessage ('opnR'); - msg->AddRef ("ref", &ref); -// printf ("%ld %s %s\n", entryList[i].mtime, ctime(&entryList[i].mtime), name); - BMenuItem *item = new BMenuItem (name, msg); - item->SetTarget (be_app); - menu->AddItem (item); + BEntry entry(&ref); + entry.GetName(name); + BMessage* msg = new BMessage('opnR'); + msg->AddRef("ref", &ref); + // printf ("%ld %s %s\n", entryList[i].mtime, + // ctime(&entryList[i].mtime), name); + BMenuItem* item = new BMenuItem(name, msg); + item->SetTarget(be_app); + menu->AddItem(item); } } } @@ -136,26 +134,27 @@ void make_recent_menu (BMenu *menu) #endif -void add_to_recent (entry_ref ref) +void +add_to_recent(entry_ref ref) { return; // We're using Be's version now - + BPath dirpath; - if (find_directory (B_USER_SETTINGS_DIRECTORY, &dirpath) == B_OK) - { - dirpath.Append ("Becasso/Recent"); - BDirectory dir (dirpath.Path()); - - BEntry entry (&ref); - BPath path (&entry); + if (find_directory(B_USER_SETTINGS_DIRECTORY, &dirpath) == B_OK) { + dirpath.Append("Becasso/Recent"); + BDirectory dir(dirpath.Path()); + + BEntry entry(&ref); + BPath path(&entry); // printf ("Adding %s to recent menu\n", path.Path()); BSymLink link; - dir.CreateSymLink (path.Leaf(), path.Path(), &link); + dir.CreateSymLink(path.Leaf(), path.Path(), &link); } } -int32 max_undo () +int32 +max_undo() { g_settings_lock.Lock(); int32 m = g_settings.max_undo + 1; @@ -163,79 +162,71 @@ int32 max_undo () return m; } -PrefsLoader::PrefsLoader () +PrefsLoader::PrefsLoader() { - // printf ("PrefsLoader...\n"); + // printf ("PrefsLoader...\n"); g_settings_lock.Lock(); // defaults: - strcpy (g_settings.language, "US-English"); + strcpy(g_settings.language, "US-English"); g_settings.recents = 10; - g_settings.origin[0] = BPoint (100, 100); + g_settings.origin[0] = BPoint(100, 100); g_settings.max_undo = 8; g_settings.selection_type = SELECTION_IN_OUT; g_settings.preview_size = 64; g_settings.totd = 1; for (int index = 1; index < NUM_WINDOWS; index++) g_settings.origin[index] = InvalidPoint; - + g_settings.settings_touched = false; - + extern bool NoSettings; - - if (!NoSettings) - { + + if (!NoSettings) { BPath path; - if (find_directory (B_USER_SETTINGS_DIRECTORY, &path)) - { - path.SetTo ("/tmp"); + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path)) { + path.SetTo("/tmp"); } - path.Append ("Becasso/Settings"); - FILE *fp = fopen (path.Path(), "r"); + path.Append("Becasso/Settings"); + FILE* fp = fopen(path.Path(), "r"); // printf ("fopen (%s)\n", path.Path()); - if (fp) - { + if (fp) { char line[1024]; char name[32]; - char *ptr; - while (true) - { + char* ptr; + while (true) { line[0] = 0; - fgets (line, 1024, fp); - if (!line[0]) - { + fgets(line, 1024, fp); + if (!line[0]) { break; } ptr = line; - while (isspace (*ptr)) + while (isspace(*ptr)) ptr++; - if (*ptr == '#' || !*ptr) // Comment line + if (*ptr == '#' || !*ptr) // Comment line continue; - if (sscanf (ptr, "%31[a-zA-Z_0-9] =", name) != 1) - { - fprintf (stderr, "Strange Becasso settings line: %s\n", name); - } - else - { - if (!strcmp (name, "window_origin")) - { + if (sscanf(ptr, "%31[a-zA-Z_0-9] =", name) != 1) { + fprintf(stderr, "Strange Becasso settings line: %s\n", name); + } else { + if (!strcmp(name, "window_origin")) { int32 index; while (*ptr != '=') ptr++; ptr++; - if (sscanf (ptr, "%ld:", &index) == 1) - { + if (sscanf(ptr, "%ld:", &index) == 1) { while (*ptr != ':') ptr++; ptr++; - if (sscanf (ptr, "%f,%f", &g_settings.origin[index].x, &g_settings.origin[index].y) != 2) - fprintf (stderr, "Illegal window origin in Becasso settings: %s\n", ptr); - } - else - fprintf (stderr, "Illegal window index in Becasso settings: %s\n", ptr); - } - else if (!strcmp (name, "language")) - { + if (sscanf( + ptr, "%f,%f", &g_settings.origin[index].x, + &g_settings.origin[index].y + ) != 2) + fprintf( + stderr, "Illegal window origin in Becasso settings: %s\n", ptr + ); + } else + fprintf(stderr, "Illegal window index in Becasso settings: %s\n", ptr); + } else if (!strcmp(name, "language")) { while (*ptr != '=') ptr++; ptr++; @@ -243,181 +234,156 @@ PrefsLoader::PrefsLoader () while (*ptr != '\n') g_settings.language[i++] = *ptr++; g_settings.language[i] = 0; - } - else if (!strcmp (name, "recent_entries")) - { + } else if (!strcmp(name, "recent_entries")) { while (*ptr != '=') ptr++; ptr++; - if (sscanf (ptr, "%ld", &g_settings.recents) != 1) - fprintf (stderr, "Illegal # of Recent items in Becasso settings: %s\n", ptr); - } - else if (!strcmp (name, "max_undo")) - { + if (sscanf(ptr, "%ld", &g_settings.recents) != 1) + fprintf( + stderr, "Illegal # of Recent items in Becasso settings: %s\n", ptr + ); + } else if (!strcmp(name, "max_undo")) { while (*ptr != '=') ptr++; ptr++; - if (sscanf (ptr, "%ld", &g_settings.max_undo) != 1) - fprintf (stderr, "Illegal max_undo # in Becasso settings: %s\n", ptr); - } - else if (!strcmp (name, "preview_size")) - { + if (sscanf(ptr, "%ld", &g_settings.max_undo) != 1) + fprintf(stderr, "Illegal max_undo # in Becasso settings: %s\n", ptr); + } else if (!strcmp(name, "preview_size")) { while (*ptr != '=') ptr++; ptr++; - if (sscanf (ptr, "%ld", &g_settings.preview_size) != 1) - fprintf (stderr, "Illegal preview_size in Becasso settings: %s\n", ptr); - } - else if (!strcmp (name, "totd")) - { + if (sscanf(ptr, "%ld", &g_settings.preview_size) != 1) + fprintf(stderr, "Illegal preview_size in Becasso settings: %s\n", ptr); + } else if (!strcmp(name, "totd")) { while (*ptr != '=') ptr++; ptr++; - if (sscanf (ptr, "%ld", &g_settings.totd) != 1) - fprintf (stderr, "Illegal totd number in Becasso settings: %s\n", ptr); - } - else if (!strcmp (name, "selection_render")) - { + if (sscanf(ptr, "%ld", &g_settings.totd) != 1) + fprintf(stderr, "Illegal totd number in Becasso settings: %s\n", ptr); + } else if (!strcmp(name, "selection_render")) { while (*ptr != '=') ptr++; ptr++; - if (sscanf (ptr, "%ld", &g_settings.selection_type) != 1) - fprintf (stderr, "Illegal selection_render in Becasso settings: %s\n", ptr); - } - else - { - fprintf (stderr, "Unknown Becasso setting: %s\n", name); + if (sscanf(ptr, "%ld", &g_settings.selection_type) != 1) + fprintf( + stderr, "Illegal selection_render in Becasso settings: %s\n", ptr + ); + } else { + fprintf(stderr, "Unknown Becasso setting: %s\n", name); } } } - fclose (fp); + fclose(fp); } } g_settings_lock.Unlock(); } - -PrefsLoader::~PrefsLoader () +PrefsLoader::~PrefsLoader() { -// printf ("~PrefsLoader\n"); + // printf ("~PrefsLoader\n"); extern bool NoSettings, WriteSettings; - if (!NoSettings || WriteSettings) - { + if (!NoSettings || WriteSettings) { BPath path; // Make sure ~/config/settings/Becasso exists - if (find_directory (B_USER_SETTINGS_DIRECTORY, &path) == B_OK) - { - BDirectory dir (path.Path()); - dir.CreateDirectory ("Becasso", &dir); // this won't clobber anyway + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { + BDirectory dir(path.Path()); + dir.CreateDirectory("Becasso", &dir); // this won't clobber anyway } Save(); } } - -void PrefsLoader::Save () +void +PrefsLoader::Save() { -// printf ("Save\n"); + // printf ("Save\n"); g_settings_lock.Lock(); - if (g_settings.settings_touched) - { + if (g_settings.settings_touched) { BPath path; - if (find_directory (B_USER_SETTINGS_DIRECTORY, &path)) - { - path.SetTo ("/tmp"); + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path)) { + path.SetTo("/tmp"); } - path.Append ("Becasso/Settings"); - FILE *fp = fopen (path.Path(), "w"); - if (fp) - { - fprintf (fp, "# Becasso settings - Sum Software (http://www.sumware.demon.nl)\n"); - fprintf (fp, "language=%s\n", g_settings.language); - fprintf (fp, "recent_entries=%ld\n", g_settings.recents); - fprintf (fp, "max_undo=%ld\n", g_settings.max_undo); - fprintf (fp, "preview_size=%ld\n", g_settings.preview_size); - fprintf (fp, "selection_render=%ld\n", g_settings.selection_type); - fprintf (fp, "totd=%ld\n", g_settings.totd); - for (int index = 0; index < NUM_WINDOWS; index++) - { + path.Append("Becasso/Settings"); + FILE* fp = fopen(path.Path(), "w"); + if (fp) { + fprintf(fp, "# Becasso settings - Sum Software (http://www.sumware.demon.nl)\n"); + fprintf(fp, "language=%s\n", g_settings.language); + fprintf(fp, "recent_entries=%ld\n", g_settings.recents); + fprintf(fp, "max_undo=%ld\n", g_settings.max_undo); + fprintf(fp, "preview_size=%ld\n", g_settings.preview_size); + fprintf(fp, "selection_render=%ld\n", g_settings.selection_type); + fprintf(fp, "totd=%ld\n", g_settings.totd); + for (int index = 0; index < NUM_WINDOWS; index++) { BPoint origin = g_settings.origin[index]; if (origin != InvalidPoint) - fprintf (fp, "window_origin = %d:%g,%g\n", index, origin.x, origin.y); - } - fclose (fp); - } - else - fprintf (stderr, "Couldn't save Settings\n"); + fprintf(fp, "window_origin = %d:%g,%g\n", index, origin.x, origin.y); + } + fclose(fp); + } else + fprintf(stderr, "Couldn't save Settings\n"); } g_settings.settings_touched = false; g_settings_lock.Unlock(); } - -status_t init_strings (const char *file) +status_t +init_strings(const char* file) { - FILE *fp = fopen (file, "rb"); + FILE* fp = fopen(file, "rb"); if (!fp) return B_ERROR; - + char buffer[4096]; - - do - { + + do { int index; int32 i = 0; - char c = fgetc (fp); - if (c == '#') - { - fgets (buffer, 4095, fp); // comment line + char c = fgetc(fp); + if (c == '#') { + fgets(buffer, 4095, fp); // comment line // printf ("%s", buffer); continue; - } - else - ungetc (c, fp); + } else + ungetc(c, fp); - if (fscanf (fp, "%d:", &index) > 0) - { - do - { - c = fgetc (fp); - if (c == '\n' || feof (fp)) + if (fscanf(fp, "%d:", &index) > 0) { + do { + c = fgetc(fp); + if (c == '\n' || feof(fp)) c = 0; - else if (c == '\\') - { - c = fgetc (fp); - switch (c) - { - case 'n': - c = '\n'; - break; - case '\\': - break; - default: - fprintf (stderr, "\\%c unknown in strings\n", c); + else if (c == '\\') { + c = fgetc(fp); + switch (c) { + case 'n': + c = '\n'; + break; + case '\\': + break; + default: + fprintf(stderr, "\\%c unknown in strings\n", c); } } buffer[i++] = c; } while (c); } - lStrings[index] = new char[strlen (buffer) + 1]; - strcpy (lStrings[index], buffer); + lStrings[index] = new char[strlen(buffer) + 1]; + strcpy(lStrings[index], buffer); // printf ("%d: %s.\n", index, lStrings[index]); - } while (!feof (fp)); - - fclose (fp); + } while (!feof(fp)); + + fclose(fp); return B_OK; } -const char *lstring (const int32 index, const char *default_string) +const char* +lstring(const int32 index, const char* default_string) { - if (lStrings[index]) - { + if (lStrings[index]) { // printf ("%ld -> %s\n", index, lStrings[index]); return lStrings[index]; - } - else - { + } else { // printf ("Warning about %ld\n", index); return default_string; } diff --git a/source/Settings.h b/source/Settings.h index cb063f7..737b3e5 100644 --- a/source/Settings.h +++ b/source/Settings.h @@ -8,60 +8,68 @@ #include #include -static const BPoint InvalidPoint = BPoint (0, 0); +static const BPoint InvalidPoint = BPoint(0, 0); #define NUM_WINDOWS 9 #define MAX_STRINGS 9999 #define MAX_UNDO 17 -#define SELECTION_IN_OUT 0 -#define SELECTION_STATIC 1 +#define SELECTION_IN_OUT 0 +#define SELECTION_STATIC 1 enum { - numMainWindow = 0, - numAttribWindow = 1, - numModeWindow = 2, - numModeTO = 3, - numToolTO = 4, - numFGColorTO = 5, - numBGColorTO = 6, - numPatternTO = 7, - numTOTDWindow = 8 + numMainWindow = 0, + numAttribWindow = 1, + numModeWindow = 2, + numModeTO = 3, + numToolTO = 4, + numFGColorTO = 5, + numBGColorTO = 6, + numPatternTO = 7, + numTOTDWindow = 8 }; #define BE_RECENT_MENU 1 -BPoint get_window_origin (uint32 win); -void set_window_origin (uint32 win, BPoint origin); +BPoint +get_window_origin(uint32 win); +void +set_window_origin(uint32 win, BPoint origin); #if BE_RECENT_MENU -BMenuItem *make_recent_menu (); +BMenuItem* +make_recent_menu(); #else -void make_recent_menu (BMenu *menu); +void +make_recent_menu(BMenu* menu); #endif -void add_to_recent (entry_ref ref); -int32 max_undo (); -status_t init_strings (const char *file); -const char *lstring (const int32 index, const char *default_string); +void +add_to_recent(entry_ref ref); +int32 +max_undo(); +status_t +init_strings(const char* file); +const char* +lstring(const int32 index, const char* default_string); struct becasso_settings { - BPoint origin[NUM_WINDOWS]; - char language[64]; - int32 recents; - int32 max_undo; - int32 selection_type; - int32 preview_size; - int32 totd; - bool settings_touched; + BPoint origin[NUM_WINDOWS]; + char language[64]; + int32 recents; + int32 max_undo; + int32 selection_type; + int32 preview_size; + int32 totd; + bool settings_touched; }; class PrefsLoader { -public: - PrefsLoader (); - ~PrefsLoader (); -void Save (); + public: + PrefsLoader(); + ~PrefsLoader(); + void Save(); }; #endif diff --git a/source/SizeWindow.cpp b/source/SizeWindow.cpp index 5e7358f..95406b4 100644 --- a/source/SizeWindow.cpp +++ b/source/SizeWindow.cpp @@ -12,10 +12,11 @@ #include #include "Settings.h" -SizeWindow::SizeWindow (int32 _h, int32 _w, int32 _c) -: BWindow (BRect (100, 100, 300, 272), "", B_MODAL_WINDOW, B_NOT_RESIZABLE| B_AUTO_UPDATE_SIZE_LIMITS) +SizeWindow::SizeWindow(int32 _h, int32 _w, int32 _c) + : BWindow( + BRect(100, 100, 300, 272), "", B_MODAL_WINDOW, B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS + ) { - char hS[16], wS[16], rD[16]; fRez = 72; fH = _w; fV = _h; @@ -23,165 +24,173 @@ SizeWindow::SizeWindow (int32 _h, int32 _w, int32 _c) fHUnit = UNIT_PIXELS; fVUnit = UNIT_PIXELS; - BBox *text = new BBox ("SW box"); - text->SetLabel (lstring (180, "Canvas Size")); - - sprintf (hS, "%li", _h); - sprintf (wS, "%li", _w); - sprintf (rD, "%li", fRez); - - newWidth = new BTextControl ("NewWidth", lstring (181, "Width"), wS, new BMessage ('Swdt')); - newHeight = new BTextControl ("NewHeight", lstring (182, "Height"), hS, new BMessage ('Shgt')); - rDPI = new BTextControl ("rez", lstring (186, "Resolution"), rD, new BMessage ('Srez')); - - newHeight->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT); - newWidth->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT); - rDPI->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT); - BStringView *dpiV = new BStringView ("dpiV", "dpi"); - BPopUpMenu *hPU = new BPopUpMenu (""); - hPU->AddItem (new BMenuItem (lstring (187, "pixels"), new BMessage ('h_px'))); - hPU->AddItem (new BMenuItem (lstring (188, "in"), new BMessage ('h_in'))); - hPU->AddItem (new BMenuItem (lstring (189, "cm"), new BMessage ('h_cm'))); - hPU->ItemAt(0)->SetMarked (true); - BMenuField *hMF = new BMenuField ("hUnit", NULL, hPU); - BPopUpMenu *vPU = new BPopUpMenu (""); - vPU->AddItem (new BMenuItem (lstring (187, "pixels"), new BMessage ('v_px'))); - vPU->AddItem (new BMenuItem (lstring (188, "in"), new BMessage ('v_in'))); - vPU->AddItem (new BMenuItem (lstring (189, "cm"), new BMessage ('v_cm'))); - vPU->ItemAt(0)->SetMarked (true); - BMenuField *vMF = new BMenuField ("vUnit", NULL, vPU); - - BView *view = new BView("SW bg", B_WILL_DRAW); - view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + BBox* text = new BBox("SW box"); + text->SetLabel(lstring(180, "Canvas Size")); + + BString hS, wS, rD; + + fNumberFormat.Format(hS, _h); + fNumberFormat.Format(wS, _w); + fNumberFormat.Format(rD, fRez); + + newWidth = new BTextControl("NewWidth", lstring(181, "Width"), wS, new BMessage('Swdt')); + newHeight = new BTextControl("NewHeight", lstring(182, "Height"), hS, new BMessage('Shgt')); + rDPI = new BTextControl("rez", lstring(186, "Resolution"), rD, new BMessage('Srez')); + + newHeight->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); + newWidth->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); + rDPI->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); + BStringView* dpiV = new BStringView("dpiV", "dpi"); + BPopUpMenu* hPU = new BPopUpMenu(""); + hPU->AddItem(new BMenuItem(lstring(187, "pixels"), new BMessage('h_px'))); + hPU->AddItem(new BMenuItem(lstring(188, "in"), new BMessage('h_in'))); + hPU->AddItem(new BMenuItem(lstring(189, "cm"), new BMessage('h_cm'))); + hPU->ItemAt(0)->SetMarked(true); + BMenuField* hMF = new BMenuField("hUnit", NULL, hPU); + BPopUpMenu* vPU = new BPopUpMenu(""); + vPU->AddItem(new BMenuItem(lstring(187, "pixels"), new BMessage('v_px'))); + vPU->AddItem(new BMenuItem(lstring(188, "in"), new BMessage('v_in'))); + vPU->AddItem(new BMenuItem(lstring(189, "cm"), new BMessage('v_cm'))); + vPU->ItemAt(0)->SetMarked(true); + BMenuField* vMF = new BMenuField("vUnit", NULL, vPU); + + BView* view = new BView("SW bg", B_WILL_DRAW); + view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BLayoutBuilder::Grid<>(view, 2.0, 2.0) // FIX - .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) - .Add(newWidth->CreateLabelLayoutItem(), 0, 0) - .Add(newWidth->CreateTextViewLayoutItem(), 1, 0) - .Add(hMF, 2,0) - .Add(newHeight->CreateLabelLayoutItem(), 0, 1) - .Add(newHeight->CreateTextViewLayoutItem(), 1, 1) - .Add(vMF, 2, 1) - .Add(rDPI->CreateLabelLayoutItem(), 0, 2) - .Add(rDPI->CreateTextViewLayoutItem(), 1, 2) - .Add(dpiV, 2, 2); + .SetInsets( + B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING + ) + .Add(newWidth->CreateLabelLayoutItem(), 0, 0) + .Add(newWidth->CreateTextViewLayoutItem(), 1, 0) + .Add(hMF, 2, 0) + .Add(newHeight->CreateLabelLayoutItem(), 0, 1) + .Add(newHeight->CreateTextViewLayoutItem(), 1, 1) + .Add(vMF, 2, 1) + .Add(rDPI->CreateLabelLayoutItem(), 0, 2) + .Add(rDPI->CreateTextViewLayoutItem(), 1, 2) + .Add(dpiV, 2, 2); text->AddChild(view); - BButton *createButton = new BButton ("SW open", lstring (183, "Create"), new BMessage ('Sopn')); - BButton *cancelButton = new BButton ("SW cancel", lstring (131, "Cancel"), new BMessage ('Scnc')); - createButton->MakeDefault (true); - - BPopUpMenu *cPU = new BPopUpMenu (""); - cPU->AddItem (new BMenuItem (lstring (407, "Current Foreground"), new BMessage ('cFG '))); - cPU->AddItem (new BMenuItem (lstring (408, "Current Background"), new BMessage ('cBG '))); - cPU->AddItem (new BMenuItem (lstring (409, "Transparent"), new BMessage ('cTR '))); - cPU->ItemAt(fColor)->SetMarked (true); - BMenuField *cMF = new BMenuField ("color", lstring (406, "Color: "), cPU); - - + BButton* createButton = new BButton("SW open", lstring(183, "Create"), new BMessage('Sopn')); + BButton* cancelButton = new BButton("SW cancel", lstring(131, "Cancel"), new BMessage('Scnc')); + createButton->MakeDefault(true); + + BPopUpMenu* cPU = new BPopUpMenu(""); + cPU->AddItem(new BMenuItem(lstring(407, "Current Foreground"), new BMessage('cFG '))); + cPU->AddItem(new BMenuItem(lstring(408, "Current Background"), new BMessage('cBG '))); + cPU->AddItem(new BMenuItem(lstring(409, "Transparent"), new BMessage('cTR '))); + cPU->ItemAt(fColor)->SetMarked(true); + BMenuField* cMF = new BMenuField("color", lstring(406, "Color: "), cPU); + + BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING) - .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) + .SetInsets( + B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, + B_USE_DEFAULT_SPACING + ) .Add(text) .Add(cMF) .AddGroup(B_HORIZONTAL) - .AddGlue() - .Add(cancelButton) - .Add(createButton); + .AddGlue() + .Add(cancelButton) + .Add(createButton); fStatus = 0; } -SizeWindow::~SizeWindow () -{ -} +SizeWindow::~SizeWindow() {} -int32 SizeWindow::Go () +int32 +SizeWindow::Go() { // not too happy with this implementation... bool ishidden = false; Show(); - while (!ishidden) - { + while (!ishidden) { Lock(); ishidden = IsHidden(); Unlock(); - snooze (50000); + snooze(50000); } return (fStatus); } -void SizeWindow::recalc () +void +SizeWindow::recalc() { - char h[16], v[16]; - switch (fHUnit) - { + BString h, v; + switch (fHUnit) { case UNIT_PIXELS: - sprintf (h, "%li", fH); - newWidth->SetText (h); + fNumberFormat.Format(h, fH); + newWidth->SetText(h); break; case UNIT_INCH: - sprintf (h, "%.2f", (float) fH/fRez + .005); - newWidth->SetText (h); + fNumberFormat.SetPrecision(2); + fNumberFormat.Format(h, (double)(fH / fRez + .005)); + newWidth->SetText(h); break; case UNIT_CM: - sprintf (h, "%.2f", (float) fH/fRez*2.54 + .005); - newWidth->SetText (h); + fNumberFormat.SetPrecision(2); + fNumberFormat.Format(h, (double)(fH / fRez * 2.54 + .005)); + newWidth->SetText(h); break; default: - fprintf (stderr, "SizeWindow: Unknown Unit (H)\n"); + fprintf(stderr, "SizeWindow: Unknown Unit (H)\n"); } - switch (fVUnit) - { + switch (fVUnit) { case UNIT_PIXELS: - sprintf (v, "%li", fV); - newHeight->SetText (v); + fNumberFormat.Format(v, fV); + newHeight->SetText(v); break; case UNIT_INCH: - sprintf (v, "%.2f", (float) fV/fRez + .005); - newHeight->SetText (v); + fNumberFormat.SetPrecision(2); + fNumberFormat.Format(v, (double)(fV / fRez + .005)); + newHeight->SetText(v); break; case UNIT_CM: - sprintf (v, "%.2f", (float) fV/fRez*2.54 + .005); - newHeight->SetText (v); + fNumberFormat.SetPrecision(2); + fNumberFormat.Format(v, (double)(fV / fRez * 2.54 + .005)); + newHeight->SetText(v); break; default: - fprintf (stderr, "SizeWindow: Unknown Unit (V)\n"); + fprintf(stderr, "SizeWindow: Unknown Unit (V)\n"); } } -void SizeWindow::readvalues () +void +SizeWindow::readvalues() { - switch (fHUnit) - { + switch (fHUnit) { case UNIT_PIXELS: - fH = atoi (newWidth->Text()); + fH = atoi(newWidth->Text()); break; case UNIT_INCH: - fH = int32 (fRez * atof (newWidth->Text())); + fH = int32(fRez * atof(newWidth->Text())); break; case UNIT_CM: - fH = int32 (fRez / 2.54 * atof (newWidth->Text())); + fH = int32(fRez / 2.54 * atof(newWidth->Text())); break; } - switch (fVUnit) - { + switch (fVUnit) { case UNIT_PIXELS: - fV = atoi (newHeight->Text()); + fV = atoi(newHeight->Text()); break; case UNIT_INCH: - fV = int32 (fRez * atof (newHeight->Text())); + fV = int32(fRez * atof(newHeight->Text())); break; case UNIT_CM: - fV = int32 (fRez / 2.54 * atof (newHeight->Text())); + fV = int32(fRez / 2.54 * atof(newHeight->Text())); break; } } -void SizeWindow::MessageReceived (BMessage *message) +void +SizeWindow::MessageReceived(BMessage* message) { - switch (message->what) - { + switch (message->what) { case 'Scnc': fStatus = 0; Hide(); @@ -220,7 +229,7 @@ void SizeWindow::MessageReceived (BMessage *message) readvalues(); break; case 'Srez': - fRez = atoi (rDPI->Text()); + fRez = atoi(rDPI->Text()); readvalues(); break; case 'cFG ': diff --git a/source/SizeWindow.h b/source/SizeWindow.h index 188abc3..70490b0 100644 --- a/source/SizeWindow.h +++ b/source/SizeWindow.h @@ -2,49 +2,53 @@ #define SIZEWINDOW_H #include +#include #include #include // Returns 1 if the `Open' button was pressed, // 0 if the 'Cancel' button was pressed. -#define UNIT_PIXELS 0 -#define UNIT_INCH 1 -#define UNIT_CM 2 +#define UNIT_PIXELS 0 +#define UNIT_INCH 1 +#define UNIT_CM 2 -#define COLOR_FG 0 -#define COLOR_BG 1 -#define COLOR_TR 2 +#define COLOR_FG 0 +#define COLOR_BG 1 +#define COLOR_TR 2 class SizeWindow : public BWindow { -public: - SizeWindow (int32 h, int32 w, int32 c); -virtual ~SizeWindow (); - -virtual void MessageReceived (BMessage *message); -virtual int32 Go (); - -int32 w() { return fH; }; -int32 h() { return fV; }; -int32 color() { return fColor; }; - -private: - -void recalc (); -void readvalues (); - -typedef BWindow inherited; -BTextControl *newWidth; -BTextControl *newHeight; -BTextControl *rDPI; -int32 fRez; -int32 fStatus; -int32 fHUnit; -int32 fVUnit; -int32 fH; -int32 fV; -int32 fColor; + public: + SizeWindow(int32 h, int32 w, int32 c); + virtual ~SizeWindow(); + + virtual void MessageReceived(BMessage* message); + virtual int32 Go(); + + int32 w() { return fH; }; + + int32 h() { return fV; }; + + int32 color() { return fColor; }; + + private: + void recalc(); + void readvalues(); + + typedef BWindow inherited; + BNumberFormat fNumberFormat; + BTextControl* newWidth; + BTextControl* newHeight; + BTextControl* rDPI; + + int32 fStatus; + int32 fHUnit; + int32 fVUnit; + int32 fH; + int32 fV; + int32 fColor; + int32 fRez; }; -#endif \ No newline at end of file +#endif diff --git a/source/Slider.cpp b/source/Slider.cpp index 3e38a78..1c6993a 100644 --- a/source/Slider.cpp +++ b/source/Slider.cpp @@ -9,41 +9,42 @@ #include "Slider.h" #include "Colors.h" -#define KNOBMARGIN 4 -#define KNOBVAL 16 +#define KNOBMARGIN 4 +#define KNOBVAL 16 -class EnterFilter : public BMessageFilter +class EnterFilter : public BMessageFilter { -public: - EnterFilter (BHandler *handler); -virtual filter_result Filter (BMessage *message, BHandler **target); + public: + EnterFilter(BHandler* handler); + virtual filter_result Filter(BMessage* message, BHandler** target); -private: -BHandler *fHandler; + private: + BHandler* fHandler; }; -EnterFilter::EnterFilter (BHandler *handler) -: BMessageFilter (B_PROGRAMMED_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN) +EnterFilter::EnterFilter(BHandler* handler) + : BMessageFilter(B_PROGRAMMED_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN) { fHandler = handler; } -filter_result EnterFilter::Filter (BMessage *message, BHandler **target) +filter_result +EnterFilter::Filter(BMessage* message, BHandler** target) { int32 raw_char; - if (message->FindInt32 ("raw_char", &raw_char) == B_OK) - { - if (raw_char == B_ENTER || raw_char == B_TAB || raw_char == B_ESCAPE) - { + if (message->FindInt32("raw_char", &raw_char) == B_OK) { + if (raw_char == B_ENTER || raw_char == B_TAB || raw_char == B_ESCAPE) { *target = fHandler; } } return B_DISPATCH_MESSAGE; } - -Slider::Slider (BRect p, float _sep, const char *_name, float _min, float _max, float _step, BMessage *_msg, orientation _posture, int _f, const char *_fmt) -: BView (p, _name, B_FOLLOW_NONE, B_WILL_DRAW | B_NAVIGABLE) +Slider::Slider( + BRect p, float _sep, const char* _name, float _min, float _max, float _step, BMessage* _msg, + orientation _posture, int _f, const char* _fmt +) + : BView(p, _name, B_FOLLOW_NONE, B_WILL_DRAW | B_NAVIGABLE) { value = _min; min = _min; @@ -58,313 +59,305 @@ Slider::Slider (BRect p, float _sep, const char *_name, float _min, float _max, bounds.right = width + 1; bounds.bottom = height; f = _f; - strcpy (fmt, _fmt); - strcpy (name, _name); + strcpy(fmt, _fmt); + strcpy(name, _name); sep = _sep; - offslid = new BBitmap (bounds, B_COLOR_8_BIT, true); - offview = new BView (bounds, "Offscreen Slider View", B_FOLLOW_NONE, (uint32) NULL); - offslid->AddChild (offview); - SetViewColor (B_TRANSPARENT_32_BIT); - get_click_speed (&dcspeed); + offslid = new BBitmap(bounds, B_COLOR_8_BIT, true); + offview = new BView(bounds, "Offscreen Slider View", B_FOLLOW_NONE, (uint32)NULL); + offslid->AddChild(offview); + SetViewColor(B_TRANSPARENT_32_BIT); + get_click_speed(&dcspeed); click = 1; tc = NULL; target = NULL; } -Slider::~Slider () +Slider::~Slider() { - offslid->RemoveChild (offview); + offslid->RemoveChild(offview); delete offview; delete offslid; delete msg; } -void Slider::AttachedToWindow () +void +Slider::AttachedToWindow() { - char valmin[KNOBVAL]; - char valmax[KNOBVAL]; - sprintf (valmin, fmt, min); - sprintf (valmax, fmt, max); + BString valMin, valMax; + fNumberFormat.Format(valMin, (double)min); + fNumberFormat.Format(valMax, (double)max); + if (!f) - knobsize = max_c (StringWidth (valmin), StringWidth (valmax)) + 2*KNOBMARGIN; + knobsize = max_c(StringWidth(valMin), StringWidth(valMax)) + 2 * KNOBMARGIN; else knobsize = f; target = Parent(); } -void Slider::SetTarget (BHandler *h) +void +Slider::SetTarget(BHandler* h) { target = h; } -//void Slider::ValueChanged (long newValue) +// void Slider::ValueChanged (long newValue) //{ -//} +// } -void Slider::Draw (BRect rect) +void +Slider::Draw(BRect rect) { - BRect label = BRect (0, 0, sep, height); - if (rect.Intersects (label)) // Label needs to be redrawn + BRect label = BRect(0, 0, sep, height); + if (rect.Intersects(label)) // Label needs to be redrawn { - SetLowColor (LightGrey); - SetHighColor (Black); - FillRect (label, B_SOLID_LOW); - DrawString (name, BPoint (0, label.bottom - 5)); + SetLowColor(LightGrey); + SetHighColor(Black); + FillRect(label, B_SOLID_LOW); + DrawString(name, BPoint(0, label.bottom - 5)); } - offslid->Lock (); - offview->SetHighColor (Grey21); - offview->FillRect (bounds); - offview->SetHighColor (Grey30); - offview->StrokeLine (bounds.RightTop (), bounds.RightBottom ()); - offview->StrokeLine (bounds.LeftBottom ()); - offview->SetHighColor (Grey14); - offview->StrokeLine (bounds.LeftTop ()); - offview->StrokeLine (bounds.RightTop ()); - knobpos = BPoint (float (value - min)/(max - min)*(width - knobsize), 1); - knob = BRect (knobpos.x + 1, knobpos.y + 1, knobpos.x + knobsize - 2, knobpos.y + height - 2); - offview->SetHighColor (Grey27); - offview->FillRect (knob); - offview->SetHighColor (Black); - offview->SetLowColor (Grey27); - offview->SetFont (be_plain_font); - char val[KNOBVAL]; - sprintf (val, fmt, value); - offview->DrawString (val, BPoint (knobpos.x + (knobsize - StringWidth (val))/2 + 1, knobpos.y + 12)); - offview->SetHighColor (Grey30); - offview->StrokeLine (BPoint (knobpos.x + knobsize - 1, knobpos.y), BPoint (knobpos.x + 1, knobpos.y)); - offview->StrokeLine (BPoint (knobpos.x + 1, knobpos.y + height - 2)); - offview->SetHighColor (Grey13); - offview->StrokeLine (BPoint (knobpos.x + knobsize - 1, knobpos.y + height - 2)); - offview->StrokeLine (BPoint (knobpos.x + knobsize - 1, knobpos.y)); - if (IsFocus()) - { + offslid->Lock(); + offview->SetHighColor(Grey21); + offview->FillRect(bounds); + offview->SetHighColor(Grey30); + offview->StrokeLine(bounds.RightTop(), bounds.RightBottom()); + offview->StrokeLine(bounds.LeftBottom()); + offview->SetHighColor(Grey14); + offview->StrokeLine(bounds.LeftTop()); + offview->StrokeLine(bounds.RightTop()); + knobpos = BPoint(float(value - min) / (max - min) * (width - knobsize), 1); + knob = BRect(knobpos.x + 1, knobpos.y + 1, knobpos.x + knobsize - 2, knobpos.y + height - 2); + offview->SetHighColor(Grey27); + offview->FillRect(knob); + offview->SetHighColor(Black); + offview->SetLowColor(Grey27); + offview->SetFont(be_plain_font); + BString val = fmt; + fNumberFormat.Format(val, value); + offview->DrawString( + val.String(), BPoint(knobpos.x + (knobsize - StringWidth(val)) / 2 + 1, knobpos.y + 12) + ); + offview->SetHighColor(Grey30); + offview->StrokeLine( + BPoint(knobpos.x + knobsize - 1, knobpos.y), BPoint(knobpos.x + 1, knobpos.y) + ); + offview->StrokeLine(BPoint(knobpos.x + 1, knobpos.y + height - 2)); + offview->SetHighColor(Grey13); + offview->StrokeLine(BPoint(knobpos.x + knobsize - 1, knobpos.y + height - 2)); + offview->StrokeLine(BPoint(knobpos.x + knobsize - 1, knobpos.y)); + if (IsFocus()) { // printf ("%s focused!\n", Name()); - BRect k (knobpos.x, knobpos.y - 1, knobpos.x + knobsize - 1, knobpos.y + height - 2); - k.InsetBy (1, 1); - offview->SetHighColor (ui_color (B_KEYBOARD_NAVIGATION_COLOR)); - offview->StrokeRect (k); + BRect k(knobpos.x, knobpos.y - 1, knobpos.x + knobsize - 1, knobpos.y + height - 2); + k.InsetBy(1, 1); + offview->SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); + offview->StrokeRect(k); } - offview->Sync (); - offslid->Unlock (); - DrawBitmapAsync (offslid, BPoint (sep, 0)); + offview->Sync(); + offslid->Unlock(); + DrawBitmapAsync(offslid, BPoint(sep, 0)); } -void Slider::MakeFocus (bool focused) +void +Slider::MakeFocus(bool focused) { - inherited::MakeFocus (focused); + inherited::MakeFocus(focused); Invalidate(); } -void Slider::MouseDown (BPoint point) +void +Slider::MouseDown(BPoint point) // Note: Still assumes horizontal slider ATM! { - if (tc) // TextControl still visible... Block other mouse movement. + if (tc) // TextControl still visible... Block other mouse movement. return; - - BPoint knobpos = BPoint (float (value - min)/(max - min)*(width - knobsize), 1); - knob = BRect (knobpos.x + 1, knobpos.y + 1, knobpos.x + knobsize - 2, knobpos.y + height - 2); + + BPoint knobpos = BPoint(float(value - min) / (max - min) * (width - knobsize), 1); + knob = BRect(knobpos.x + 1, knobpos.y + 1, knobpos.x + knobsize - 2, knobpos.y + height - 2); uint32 buttons; - buttons = Window()->CurrentMessage()->FindInt32 ("buttons"); + buttons = Window()->CurrentMessage()->FindInt32("buttons"); float px = -1; bool dragging = false; - if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) - { + if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) { BPoint bp, pbp; uint32 bt; - GetMouse (&pbp, &bt, true); + GetMouse(&pbp, &bt, true); bigtime_t start = system_time(); - if (knob.Contains (BPoint (pbp.x - sep, pbp.y))) - { - while (system_time() - start < dcspeed) - { - snooze (20000); - GetMouse (&bp, &bt, true); - if (!bt && click != 2) - { + if (knob.Contains(BPoint(pbp.x - sep, pbp.y))) { + while (system_time() - start < dcspeed) { + snooze(20000); + GetMouse(&bp, &bt, true); + if (!bt && click != 2) { click = 0; } - if (bt && !click) - { + if (bt && !click) { click = 2; } if (bp != pbp) break; } } - if (click != 2) - { + if (click != 2) { // Now we're dragging... - while (buttons) - { - BPoint p = BPoint (point.x - sep, point.y); + while (buttons) { + BPoint p = BPoint(point.x - sep, point.y); float x = p.x; - if (!(knob.Contains (p)) && !dragging) - { - if (x > knob.left) - { - value += step * (x - knob.right)/10; - } - else - { - value += step * (x - knob.left)/10; + if (!(knob.Contains(p)) && !dragging) { + if (x > knob.left) { + value += step * (x - knob.right) / 10; + } else { + value += step * (x - knob.left) / 10; } if (value < min) value = min; if (value > max) value = max; - if (step > 1 && fmod (value - min, step)) // Hack hack! - value = int ((value - min)/step)*step + min; - // if (fmt[strlen (fmt) - 2] == '0') - // value = int (value + 0.5); + if (step > 1 && fmod(value - min, step)) // Hack hack! + value = int((value - min) / step) * step + min; + // if (fmt[strlen (fmt) - 2] == '0') + // value = int (value + 0.5); offslid->Lock(); - Invalidate (BRect (sep + 1, 0, offslid->Bounds().Width() + sep, height)); + Invalidate(BRect(sep + 1, 0, offslid->Bounds().Width() + sep, height)); offslid->Unlock(); NotifyTarget(); - } - else if (px != p.x && step <= 1) // Hacks galore! + } else if (px != p.x && step <= 1) // Hacks galore! { dragging = true; - value = (x - knobsize/2) / (width - knobsize) * (max - min) + min; - //printf ("x = %f, knobsize = %f, value = %f\n", x, knobsize, value); - //printf ("Value: %f ", value); + value = (x - knobsize / 2) / (width - knobsize) * (max - min) + min; + // printf ("x = %f, knobsize = %f, value = %f\n", x, knobsize, value); + // printf ("Value: %f ", value); if (value < min) value = min; if (value > max) value = max; - if (step > 1 && fmod (value - min, step)) - value = int ((value - min)/step)*step + min; - if (fmt[strlen (fmt) - 2] == '0') - value = int (value + 0.5); - //printf ("-> %f\n", value); + if (step > 1 && fmod(value - min, step)) + value = int((value - min) / step) * step + min; + if (fmt[strlen(fmt) - 2] == '0') + value = int(value + 0.5); + // printf ("-> %f\n", value); offslid->Lock(); - Invalidate (BRect (sep + 1, 0, offslid->Bounds().Width() + sep, height)); + Invalidate(BRect(sep + 1, 0, offslid->Bounds().Width() + sep, height)); offslid->Unlock(); px = p.x; NotifyTarget(); } - knobpos = BPoint (float (value - min)/(max - min)*(width - knobsize), 1); - knob = BRect (knobpos.x + 1, knobpos.y + 1, knobpos.x + knobsize - 2, knobpos.y + height - 2); - snooze (20000); - GetMouse (&point, &buttons, true); + knobpos = BPoint(float(value - min) / (max - min) * (width - knobsize), 1); + knob = BRect( + knobpos.x + 1, knobpos.y + 1, knobpos.x + knobsize - 2, knobpos.y + height - 2 + ); + snooze(20000); + GetMouse(&point, &buttons, true); } click = 1; } } - if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) - { + if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { click = 1; - if (tc) - { - RemoveChild (tc); + if (tc) { + RemoveChild(tc); delete tc; } - knobpos = BPoint (float (value - min)/(max - min)*(width - knobsize), 1); - BRect kbr = BRect (knobpos.x + sep, knobpos.y, knobpos.x + knobsize - 2 + sep, knobpos.y + height - 3); -// kbr.PrintToStream(); - tc = new BTextControl (kbr, "slider value field", "", "", new BMessage ('tcVC')); - tc->SetTarget (this); - tc->SetDivider (0); - EnterFilter *filter = new EnterFilter (this); - tc->TextView()->AddFilter (filter); - char vs[64]; - sprintf (vs, fmt, value); - tc->SetText (vs); - AddChild (tc); - tc->MakeFocus (true); + knobpos = BPoint(float(value - min) / (max - min) * (width - knobsize), 1); + BRect kbr = BRect( + knobpos.x + sep, knobpos.y, knobpos.x + knobsize - 2 + sep, knobpos.y + height - 3 + ); + // kbr.PrintToStream(); + tc = new BTextControl(kbr, "slider value field", "", "", new BMessage('tcVC')); + tc->SetTarget(this); + tc->SetDivider(0); + EnterFilter* filter = new EnterFilter(this); + tc->TextView()->AddFilter(filter); + BString vs = fmt; + fNumberFormat.Format(vs, value); + tc->SetText(vs); + AddChild(tc); + tc->MakeFocus(true); } - NotifyTarget (); + NotifyTarget(); } -void Slider::MessageReceived (BMessage *message) +void +Slider::MessageReceived(BMessage* message) { - switch (message->what) - { - case 'tcVC': - { + switch (message->what) { + case 'tcVC': { float tv = 0; - if (tc) - { - tv = atof (tc->Text()); - if (tv < min) tv = min; - if (tv > max) tv = max; - if (step > 1 && fmod (tv - min, step)) - tv = int ((tv - min)/step)*step + min; - if (fmt[strlen (fmt) - 2] == '0') - tv = int (tv + 0.5); - RemoveChild (tc); + if (tc) { + tv = atof(tc->Text()); + if (tv < min) + tv = min; + if (tv > max) + tv = max; + if (step > 1 && fmod(tv - min, step)) + tv = int((tv - min) / step) * step + min; + if (fmt[strlen(fmt) - 2] == '0') + tv = int(tv + 0.5); + RemoveChild(tc); } delete tc; tc = NULL; - SetValue (tv); + SetValue(tv); NotifyTarget(); break; } default: // message->PrintToStream(); - inherited::MessageReceived (message); + inherited::MessageReceived(message); } } -void Slider::KeyDown (const char *bytes, int32 numBytes) +void +Slider::KeyDown(const char* bytes, int32 numBytes) { - if (numBytes == 1) - { - switch (*bytes) - { - case B_ESCAPE: - { - if (tc) - { + if (numBytes == 1) { + switch (*bytes) { + case B_ESCAPE: { + if (tc) { // printf ("TextControl is open\n"); - RemoveChild (tc); + RemoveChild(tc); delete (tc); tc = NULL; } break; } case B_SPACE: - case B_ENTER: - { - //printf ("Enter\n"); - if (tc) - { + case B_ENTER: { + // printf ("Enter\n"); + if (tc) { // printf ("TextControl is open\n"); - BMessage *key = new BMessage ('tcVC'); - MessageReceived (key); + BMessage* key = new BMessage('tcVC'); + MessageReceived(key); delete key; - } - else - { - knobpos = BPoint (float (value - min)/(max - min)*(width - knobsize), 1); - BRect kbr = BRect (knobpos.x + sep, knobpos.y, knobpos.x + knobsize - 2 + sep, knobpos.y + height - 3); - // kbr.PrintToStream(); - tc = new BTextControl (kbr, "slider value field", "", "", new BMessage ('tcVC')); - tc->SetTarget (this); - tc->SetDivider (0); - EnterFilter *filter = new EnterFilter (this); - tc->TextView()->AddFilter (filter); - char vs[64]; - sprintf (vs, fmt, value); - tc->SetText (vs); - AddChild (tc); - tc->MakeFocus (true); - inherited::KeyDown (bytes, numBytes); + } else { + knobpos = BPoint(float(value - min) / (max - min) * (width - knobsize), 1); + BRect kbr = BRect( + knobpos.x + sep, knobpos.y, knobpos.x + knobsize - 2 + sep, + knobpos.y + height - 3 + ); + // kbr.PrintToStream(); + tc = new BTextControl(kbr, "slider value field", "", "", new BMessage('tcVC')); + tc->SetTarget(this); + tc->SetDivider(0); + EnterFilter* filter = new EnterFilter(this); + tc->TextView()->AddFilter(filter); + BString vs = fmt; + fNumberFormat.Format(vs, value); + tc->SetText(vs.String()); + AddChild(tc); + tc->MakeFocus(true); + inherited::KeyDown(bytes, numBytes); } break; } case B_LEFT_ARROW: - //printf ("Left\n"); - if (value > min) - { + // printf ("Left\n"); + if (value > min) { value -= step; Invalidate(); NotifyTarget(); } break; case B_RIGHT_ARROW: - //printf ("Right\n"); - if (value < max) - { + // printf ("Right\n"); + if (value < max) { value += step; Invalidate(); NotifyTarget(); @@ -372,51 +365,49 @@ void Slider::KeyDown (const char *bytes, int32 numBytes) break; case B_TAB: // printf ("Tab\n"); - if (tc) - { + if (tc) { // printf ("TextControl is open\n"); - BMessage *key = new BMessage ('tcVC'); - MessageReceived (key); + BMessage* key = new BMessage('tcVC'); + MessageReceived(key); delete key; - } - else - { - // MakeFocus (false); - inherited::KeyDown (bytes, numBytes); + } else { + // MakeFocus (false); + inherited::KeyDown(bytes, numBytes); Invalidate(); break; } default: - inherited::KeyDown (bytes, numBytes); + inherited::KeyDown(bytes, numBytes); } - } - else - inherited::KeyDown (bytes, numBytes); + } else + inherited::KeyDown(bytes, numBytes); } -float Slider::Value () +float +Slider::Value() { return (value); } -void Slider::SetValue (float _v) +void +Slider::SetValue(float _v) { value = _v; Invalidate(); } -void Slider::NotifyTarget () +void +Slider::NotifyTarget() { - if (!target) - { - fprintf (stderr, "Slider: Null target\n"); + if (!target) { + fprintf(stderr, "Slider: Null target\n"); return; } - BMessage *changed = new BMessage (*msg); - changed->AddFloat ("value", value); -// printf ("%f\n", value); + BMessage* changed = new BMessage(*msg); + changed->AddFloat("value", value); + // printf ("%f\n", value); target->LockLooper(); - target->MessageReceived (changed); + target->MessageReceived(changed); target->UnlockLooper(); delete changed; } diff --git a/source/Slider.h b/source/Slider.h index 764bfcd..a21b6de 100644 --- a/source/Slider.h +++ b/source/Slider.h @@ -7,50 +7,55 @@ #include #include #include +#include #include #include "Build.h" class IMPEXP Slider : public BView { -public: - Slider (BRect frame, float sep, const char *name, float _min, float _max, float step, BMessage *_msg, orientation _posture = B_HORIZONTAL, int f = 0, const char *_fmt = "%.0f"); -virtual ~Slider (); -//void ValueChanged (long newValue); -virtual void MouseDown (BPoint point); -virtual void Draw (BRect update); -virtual void AttachedToWindow (); -virtual void MessageReceived (BMessage *msg); -virtual void KeyDown (const char *bytes, int32 numBytes); -virtual void MakeFocus (bool focused = true); -virtual void SetTarget (BHandler *target); -float Value (); -void SetValue (float _v); + public: + Slider( + BRect frame, float sep, const char* name, float _min, float _max, float step, + BMessage* _msg, orientation _posture = B_HORIZONTAL, int f = 0, const char* _fmt = "%.0f" + ); + virtual ~Slider(); + // void ValueChanged (long newValue); + virtual void MouseDown(BPoint point); + virtual void Draw(BRect update); + virtual void AttachedToWindow(); + virtual void MessageReceived(BMessage* msg); + virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void MakeFocus(bool focused = true); + virtual void SetTarget(BHandler* target); + float Value(); + void SetValue(float _v); -private: -typedef BView inherited; -void NotifyTarget (); -float min; -float max; -float sep; -float step; -BMessage *msg; -char fmt[16]; -char name[64]; -orientation pos; -float value; -BRect bounds; -BRect knob; -BBitmap *offslid; -BView *offview; -BPoint knobpos; -float knobsize; -int f; -float width; -float height; -bigtime_t dcspeed; -int click; -BTextControl *tc; -BHandler *target; + private: + typedef BView inherited; + void NotifyTarget(); + float min; + float max; + float sep; + float step; + BMessage* msg; + char fmt[16]; + char name[64]; + orientation pos; + float value; + BRect bounds; + BRect knob; + BBitmap* offslid; + BView* offview; + BPoint knobpos; + float knobsize; + int f; + float width; + float height; + bigtime_t dcspeed; + int click; + BTextControl* tc; + BHandler* target; + BNumberFormat fNumberFormat; }; -#endif \ No newline at end of file +#endif diff --git a/source/SplashWindow.cpp b/source/SplashWindow.cpp index aab1888..f1f606a 100644 --- a/source/SplashWindow.cpp +++ b/source/SplashWindow.cpp @@ -4,32 +4,28 @@ #include - -SplashWindow::SplashWindow (BRect rect, BBitmap *becasso, BBitmap *sum) -: BWindow (rect, "Splash Screen", B_BORDERED_WINDOW, (int32) NULL) +SplashWindow::SplashWindow(BRect rect, BBitmap* becasso, BBitmap* sum) + : BWindow(rect, "Splash Screen", B_BORDERED_WINDOW, (int32)NULL) { - abV = new SAboutView (Bounds(), becasso, sum, true); - AddChild (abV); + abV = new SAboutView(Bounds(), becasso, sum, true); + AddChild(abV); } -SplashWindow::~SplashWindow () -{ -} +SplashWindow::~SplashWindow() {} -void SplashWindow::MessageReceived (BMessage *msg) +void +SplashWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case 'Iaos': - { - const char *s; - msg->FindString ("InitString", &s); -// printf ("s = %s\n", s); - abV->SetInitString (s); + switch (msg->what) { + case 'Iaos': { + const char* s; + msg->FindString("InitString", &s); + // printf ("s = %s\n", s); + abV->SetInitString(s); break; } default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } \ No newline at end of file diff --git a/source/SplashWindow.h b/source/SplashWindow.h index d2f976c..5bf6691 100644 --- a/source/SplashWindow.h +++ b/source/SplashWindow.h @@ -7,14 +7,14 @@ class SAboutView; class SplashWindow : public BWindow { -public: - SplashWindow (BRect rect, BBitmap *becasso, BBitmap *sum); -virtual ~SplashWindow (); -virtual void MessageReceived (BMessage *msg); + public: + SplashWindow(BRect rect, BBitmap* becasso, BBitmap* sum); + virtual ~SplashWindow(); + virtual void MessageReceived(BMessage* msg); -private: -typedef BWindow inherited; -SAboutView *abV; + private: + typedef BWindow inherited; + SAboutView* abV; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/TOTDWindow.cpp b/source/TOTDWindow.cpp index 31f940a..254e621 100644 --- a/source/TOTDWindow.cpp +++ b/source/TOTDWindow.cpp @@ -14,67 +14,77 @@ #include #include -TOTDWindow::TOTDWindow (const BRect frame, const int num) -: BWindow (frame, lstring (500, "Tip of the day"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) +TOTDWindow::TOTDWindow(const BRect frame, const int num) + : BWindow( + frame, lstring(500, "Tip of the day"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE + ) { fTotd = num; app_info info; - be_app->GetAppInfo (&info); - BFile file (&info.ref, O_RDONLY); - BResources res (&file); - BBitmap *icon = new BBitmap (BRect (0, 0, 31, 31), B_CMAP8); + be_app->GetAppInfo(&info); + BFile file(&info.ref, O_RDONLY); + BResources res(&file); + BBitmap* icon = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8); size_t size; - const void *icondata = res.LoadResource ('ICON', "BEOS:L:TOTD", &size); - icon->SetBits (icondata, 1024, 0, B_COLOR_8_BIT); - BitmapView *iview = new BitmapView (BRect (0, 0, 39, Bounds().Height()), "icon", icon, B_OP_OVER, false); - iview->SetViewColor (DarkGrey); - iview->SetPosition (BPoint (4, 8)); - AddChild (iview); - + const void* icondata = res.LoadResource('ICON', "BEOS:L:TOTD", &size); + icon->SetBits(icondata, 1024, 0, B_COLOR_8_BIT); + BitmapView* iview = + new BitmapView(BRect(0, 0, 39, Bounds().Height()), "icon", icon, B_OP_OVER, false); + iview->SetViewColor(DarkGrey); + iview->SetPosition(BPoint(4, 8)); + AddChild(iview); + BRect rest = Bounds(); rest.left = 40; - - BView *v = new BView (rest, "totd", B_FOLLOW_ALL, 0); - v->SetViewColor (LightGrey); - AddChild (v); - rest.OffsetTo (B_ORIGIN); - - BButton *next = new BButton (BRect (rest.right - 80, rest.bottom - 32, rest.right - 4, rest.bottom - 4), "next", lstring (502, "Next tip"),new BMessage ('next')); - v->AddChild (next); - - BCheckBox *show = new BCheckBox (BRect (8, rest.bottom - 24, rest.right - 84, rest.bottom - 8), "show", lstring (501, "Show tips at startup"), new BMessage ('show')); - v->AddChild (show); - - fTextView = new BTextView (BRect (4, 4, rest.right - 4, rest.bottom - 36), "totd", BRect (0, 0, rest.right - 8, rest.bottom - 44), B_FOLLOW_ALL, B_WILL_DRAW); - fTextView->SetViewColor (LightGrey); - fTextView->MakeEditable (false); - v->AddChild (fTextView); - + + BView* v = new BView(rest, "totd", B_FOLLOW_ALL, 0); + v->SetViewColor(LightGrey); + AddChild(v); + rest.OffsetTo(B_ORIGIN); + + BButton* next = new BButton( + BRect(rest.right - 80, rest.bottom - 32, rest.right - 4, rest.bottom - 4), "next", + lstring(502, "Next tip"), new BMessage('next') + ); + v->AddChild(next); + + BCheckBox* show = new BCheckBox( + BRect(8, rest.bottom - 24, rest.right - 84, rest.bottom - 8), "show", + lstring(501, "Show tips at startup"), new BMessage('show') + ); + v->AddChild(show); + + fTextView = new BTextView( + BRect(4, 4, rest.right - 4, rest.bottom - 36), "totd", + BRect(0, 0, rest.right - 8, rest.bottom - 44), B_FOLLOW_ALL, B_WILL_DRAW + ); + fTextView->SetViewColor(LightGrey); + fTextView->MakeEditable(false); + v->AddChild(fTextView); + extern becasso_settings g_settings; extern BLocker g_settings_lock; g_settings_lock.Lock(); fTotd = g_settings.totd; g_settings_lock.Unlock(); - show->SetValue (fTotd); + show->SetValue(fTotd); - const char *totdText = lstring (502 + fTotd, "@@@"); - if (!strcmp (totdText, "@@@")) - { + const char* totdText = lstring(502 + fTotd, "@@@"); + if (!strcmp(totdText, "@@@")) { g_settings_lock.Lock(); g_settings.totd = 1; g_settings_lock.Unlock(); fTotd = 1; - fTextView->SetText (lstring (503, "")); - } - else - fTextView->SetText (totdText); + fTextView->SetText(lstring(503, "")); + } else + fTextView->SetText(totdText); } -TOTDWindow::~TOTDWindow () +TOTDWindow::~TOTDWindow() { BPoint origin = Frame().LeftTop(); - set_window_origin (numTOTDWindow, origin); + set_window_origin(numTOTDWindow, origin); extern becasso_settings g_settings; extern BLocker g_settings_lock; @@ -84,41 +94,38 @@ TOTDWindow::~TOTDWindow () g_settings_lock.Unlock(); } -bool TOTDWindow::QuitRequested () +bool +TOTDWindow::QuitRequested() { return true; } -void TOTDWindow::MessageReceived (BMessage *msg) +void +TOTDWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case 'show': - { - extern BLocker g_settings_lock; - extern becasso_settings g_settings; - g_settings_lock.Lock(); - if (msg->FindInt32 ("be:value")) - g_settings.totd = fTotd; - else - g_settings.totd = 0; - g_settings_lock.Unlock(); - break; - } - case 'next': - { - fTotd++; - const char *totdText = lstring (502 + fTotd, "@@@"); - if (!strcmp (totdText, "@@@")) - { - fTotd = 1; - fTextView->SetText (lstring (503, "")); - } - else - fTextView->SetText (totdText); - break; - } - default: - BWindow::MessageReceived (msg); + switch (msg->what) { + case 'show': { + extern BLocker g_settings_lock; + extern becasso_settings g_settings; + g_settings_lock.Lock(); + if (msg->FindInt32("be:value")) + g_settings.totd = fTotd; + else + g_settings.totd = 0; + g_settings_lock.Unlock(); + break; + } + case 'next': { + fTotd++; + const char* totdText = lstring(502 + fTotd, "@@@"); + if (!strcmp(totdText, "@@@")) { + fTotd = 1; + fTextView->SetText(lstring(503, "")); + } else + fTextView->SetText(totdText); + break; + } + default: + BWindow::MessageReceived(msg); } } diff --git a/source/TOTDWindow.h b/source/TOTDWindow.h index 130bcbf..3dfab37 100644 --- a/source/TOTDWindow.h +++ b/source/TOTDWindow.h @@ -7,15 +7,15 @@ class BTextView; class TOTDWindow : public BWindow { -public: - TOTDWindow (const BRect frame, const int num); -virtual ~TOTDWindow (); -virtual void MessageReceived (BMessage *msg); -virtual bool QuitRequested (); + public: + TOTDWindow(const BRect frame, const int num); + virtual ~TOTDWindow(); + virtual void MessageReceived(BMessage* msg); + virtual bool QuitRequested(); -private: -int32 fTotd; -BTextView *fTextView; + private: + int32 fTotd; + BTextView* fTextView; }; #endif \ No newline at end of file diff --git a/source/TabView.cpp b/source/TabView.cpp index fb89ca5..7be9357 100644 --- a/source/TabView.cpp +++ b/source/TabView.cpp @@ -4,176 +4,170 @@ #include #include -#define _HTABHEIGHT (TAB_HEIGHT/2) +#define _HTABHEIGHT (TAB_HEIGHT / 2) -TabView::TabView (BRect frame, const char *name, uint32 resizingMode) -: BView (frame, name, resizingMode, B_WILL_DRAW | B_NAVIGABLE) +TabView::TabView(BRect frame, const char* name, uint32 resizingMode) + : BView(frame, name, resizingMode, B_WILL_DRAW | B_NAVIGABLE) { index = 0; current = -2; focusedview = 0; - SetViewColor (LightGrey); + SetViewColor(LightGrey); } -TabView::~TabView () +TabView::~TabView() { for (int i = 0; i < index; i++) delete views[i]; } -void TabView::Draw (BRect update) +void +TabView::Draw(BRect update) { update = update; - if (current < -1) // No sheet selected yet + if (current < -1) // No sheet selected yet return; float xpos = _HTABHEIGHT + 1; - for (int i = 0; i < index; i++) - { - float width = StringWidth (tabname[i]); + for (int i = 0; i < index; i++) { + float width = StringWidth(tabname[i]); // Up slope of tab - SetHighColor (Grey30); + SetHighColor(Grey30); if (current == i - 1) - MovePenTo (BPoint (xpos - _HTABHEIGHT/2 + 1, _HTABHEIGHT - 1)); + MovePenTo(BPoint(xpos - _HTABHEIGHT / 2 + 1, _HTABHEIGHT - 1)); else - MovePenTo (BPoint (xpos - _HTABHEIGHT, TAB_HEIGHT)); - StrokeLine (BPoint (xpos, 0)); + MovePenTo(BPoint(xpos - _HTABHEIGHT, TAB_HEIGHT)); + StrokeLine(BPoint(xpos, 0)); // Horizontal line of tab - StrokeLine (BPoint (xpos + width, 0)); + StrokeLine(BPoint(xpos + width, 0)); // Down slope of tab - SetHighColor (Grey15); + SetHighColor(Grey15); if (i == current || i == index - 1) - StrokeLine (BPoint (xpos + width + _HTABHEIGHT, TAB_HEIGHT)); + StrokeLine(BPoint(xpos + width + _HTABHEIGHT, TAB_HEIGHT)); else - StrokeLine (BPoint (xpos + width + _HTABHEIGHT/2, _HTABHEIGHT)); + StrokeLine(BPoint(xpos + width + _HTABHEIGHT / 2, _HTABHEIGHT)); // Tab label if (current == i) - SetHighColor (Black); + SetHighColor(Black); else - SetHighColor (Grey8); - SetLowColor (Grey30); - SetDrawingMode (B_OP_OVER); - DrawString (tabname[i], BPoint (xpos + 1, TAB_HEIGHT - 2)); + SetHighColor(Grey8); + SetLowColor(Grey30); + SetDrawingMode(B_OP_OVER); + DrawString(tabname[i], BPoint(xpos + 1, TAB_HEIGHT - 2)); // View top - if (current == i - 1) - { - SetHighColor (Grey30); - StrokeLine (BPoint (xpos + 1, TAB_HEIGHT), BPoint (xpos + width + _HTABHEIGHT, TAB_HEIGHT)); - } - else if (current == i + 1) - { - SetHighColor (Grey30); - StrokeLine (BPoint (xpos - _HTABHEIGHT, TAB_HEIGHT), BPoint (xpos + width, TAB_HEIGHT)); + if (current == i - 1) { + SetHighColor(Grey30); + StrokeLine( + BPoint(xpos + 1, TAB_HEIGHT), BPoint(xpos + width + _HTABHEIGHT, TAB_HEIGHT) + ); + } else if (current == i + 1) { + SetHighColor(Grey30); + StrokeLine(BPoint(xpos - _HTABHEIGHT, TAB_HEIGHT), BPoint(xpos + width, TAB_HEIGHT)); } - if (IsFocus() && focusedview == i) - { - SetHighColor (ui_color (B_KEYBOARD_NAVIGATION_COLOR)); - StrokeLine (BPoint (xpos + 1, TAB_HEIGHT - 1), BPoint (xpos + width - 1, TAB_HEIGHT - 1)); + if (IsFocus() && focusedview == i) { + SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR)); + StrokeLine(BPoint(xpos + 1, TAB_HEIGHT - 1), BPoint(xpos + width - 1, TAB_HEIGHT - 1)); } xpos += width + _HTABHEIGHT; } // other view borders - SetHighColor (Grey14); - StrokeLine (BPoint (Bounds().Width(), TAB_HEIGHT), BPoint (Bounds().right, Bounds().bottom - 1)); - StrokeLine (BPoint (Bounds().left, Bounds().bottom - 1)); - SetHighColor (Grey30); - StrokeLine (BPoint (0, TAB_HEIGHT)); - StrokeLine (BPoint (xpos + 1, TAB_HEIGHT), BPoint (Bounds().Width(), TAB_HEIGHT)); + SetHighColor(Grey14); + StrokeLine(BPoint(Bounds().Width(), TAB_HEIGHT), BPoint(Bounds().right, Bounds().bottom - 1)); + StrokeLine(BPoint(Bounds().left, Bounds().bottom - 1)); + SetHighColor(Grey30); + StrokeLine(BPoint(0, TAB_HEIGHT)); + StrokeLine(BPoint(xpos + 1, TAB_HEIGHT), BPoint(Bounds().Width(), TAB_HEIGHT)); } -void TabView::KeyDown (const char *bytes, int32 numBytes) +void +TabView::KeyDown(const char* bytes, int32 numBytes) { - if (numBytes == 1) - { - switch (*bytes) - { + if (numBytes == 1) { + switch (*bytes) { case B_SPACE: - case B_ENTER: - { - //printf ("Enter\n"); - RaiseView (focusedview); - inherited::KeyDown (bytes, numBytes); + case B_ENTER: { + // printf ("Enter\n"); + RaiseView(focusedview); + inherited::KeyDown(bytes, numBytes); break; } case B_LEFT_ARROW: - //printf ("Left\n"); + // printf ("Left\n"); focusedview--; if (focusedview < 0) focusedview = index - 1; Invalidate(); break; case B_RIGHT_ARROW: - //printf ("Right\n"); + // printf ("Right\n"); focusedview++; if (focusedview >= index) focusedview = 0; Invalidate(); break; case B_TAB: - //MakeFocus (false); - inherited::KeyDown (bytes, numBytes); + // MakeFocus (false); + inherited::KeyDown(bytes, numBytes); Invalidate(); break; default: - inherited::KeyDown (bytes, numBytes); + inherited::KeyDown(bytes, numBytes); } - } - else - inherited::KeyDown (bytes, numBytes); + } else + inherited::KeyDown(bytes, numBytes); } -void TabView::MakeFocus (bool focused) +void +TabView::MakeFocus(bool focused) { - inherited::MakeFocus (focused); + inherited::MakeFocus(focused); Invalidate(); } -void TabView::MouseDown (BPoint point) +void +TabView::MouseDown(BPoint point) { if (point.y < 0 || point.y > TAB_HEIGHT) return; float xpos = 10; float width; - for (int i = 0; i < index; i++) - { - width = StringWidth (tabname[i]); - if (point.x > xpos - 5 && point.x < xpos + width + 5) - { - RaiseView (i); + for (int i = 0; i < index; i++) { + width = StringWidth(tabname[i]); + if (point.x > xpos - 5 && point.x < xpos + width + 5) { + RaiseView(i); return; } xpos += width; } } -void TabView::AddView (BView *view, const char *tab) +void +TabView::AddView(BView* view, const char* tab) { - if (index < MAX_VIEWS - 1) - { - strcpy (tabname[index], tab); + if (index < MAX_VIEWS - 1) { + strcpy(tabname[index], tab); views[index] = view; - if (index == 0) - { - RaiseView (0); + if (index == 0) { + RaiseView(0); } index++; - } - else - fprintf (stderr, "More than %i Views in a TabView\n", MAX_VIEWS); + } else + fprintf(stderr, "More than %i Views in a TabView\n", MAX_VIEWS); } -//BView *TabView::Current () +// BView *TabView::Current () //{ // return (views[current]); -//} +// } -void TabView::RaiseView (int n) +void +TabView::RaiseView(int n) { if (current == n) return; if (current > -2) - RemoveChild (views[current]); - AddChild (views[n]); + RemoveChild(views[current]); + AddChild(views[n]); current = n; Invalidate(); } diff --git a/source/TabView.h b/source/TabView.h index e72e824..d310527 100644 --- a/source/TabView.h +++ b/source/TabView.h @@ -8,30 +8,30 @@ #include #include "Build.h" -#define MAX_VIEWS 32 -#define MAX_TAB 32 +#define MAX_VIEWS 32 +#define MAX_TAB 32 #define TAB_HEIGHT 16 class IMPEXP TabView : public BView { -public: - TabView (BRect frame, const char *name, uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP); -virtual ~TabView (); -virtual void Draw (BRect update); -virtual void MouseDown (BPoint point); -virtual void KeyDown (const char *bytes, int32 numBytes); -virtual void MakeFocus (bool focused = true); -void AddView (BView *view, const char *tab); -//BView *Current (); -void RaiseView (int n); + public: + TabView(BRect frame, const char* name, uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP); + virtual ~TabView(); + virtual void Draw(BRect update); + virtual void MouseDown(BPoint point); + virtual void KeyDown(const char* bytes, int32 numBytes); + virtual void MakeFocus(bool focused = true); + void AddView(BView* view, const char* tab); + // BView *Current (); + void RaiseView(int n); -private: -typedef BView inherited; -BView *views[MAX_VIEWS]; -char tabname[MAX_VIEWS][MAX_TAB]; -int index; -int current; -int focusedview; + private: + typedef BView inherited; + BView* views[MAX_VIEWS]; + char tabname[MAX_VIEWS][MAX_TAB]; + int index; + int current; + int focusedview; }; -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/Tablet.cpp b/source/Tablet.cpp index 6c6533c..76d4542 100644 --- a/source/Tablet.cpp +++ b/source/Tablet.cpp @@ -3,18 +3,18 @@ #include #include -Tablet::Tablet (const char *port) +Tablet::Tablet(const char* port) { -// openlog ("TabletDriver", LOG_THID, LOG_USER); - strcpy (fPortName, port); + // openlog ("TabletDriver", LOG_THID, LOG_USER); + strcpy(fPortName, port); fValid = false; - fPort = new BSerialPort (); + fPort = new BSerialPort(); fTreshold = 0.1; fTabletType = 0; fMaxPressure = 256; } -Tablet::~Tablet () +Tablet::~Tablet() { closelog(); if (fValid) @@ -22,7 +22,8 @@ Tablet::~Tablet () delete fPort; } -bool Tablet::Init () +bool +Tablet::Init() { fValid = false; /////////////////////// @@ -30,96 +31,95 @@ bool Tablet::Init () // // return (false); /////////////////////// - if (strlen (fPortName) < 1) + if (strlen(fPortName) < 1) return false; - syslog (LOG_DEBUG, "Checking for Tablet at %s\n", fPortName); - fPort->SetDataRate (B_9600_BPS); - fPort->SetFlowControl (B_NOFLOW_CONTROL); - fPort->SetBlocking (false); - if (fPort->Open (fPortName) > 0) - { - fPort->SetTimeout (20000); + syslog(LOG_DEBUG, "Checking for Tablet at %s\n", fPortName); + fPort->SetDataRate(B_9600_BPS); + fPort->SetFlowControl(B_NOFLOW_CONTROL); + fPort->SetBlocking(false); + if (fPort->Open(fPortName) > 0) { + fPort->SetTimeout(20000); int num; - syslog (LOG_DEBUG, "Wrote %ld bytes\n", fPort->Write ("~#\r", 3)); - snooze (100000); - num = GetLine (fPort, fModel, 32); - if (num > 0) - { - syslog (LOG_DEBUG, "Tablet model: %s\n", fModel); - if (!strcpy (fModel, "~#ET")) - fTabletType = ET_TABLET; // Graphire + syslog(LOG_DEBUG, "Wrote %ld bytes\n", fPort->Write("~#\r", 3)); + snooze(100000); + num = GetLine(fPort, fModel, 32); + if (num > 0) { + syslog(LOG_DEBUG, "Tablet model: %s\n", fModel); + if (!strcpy(fModel, "~#ET")) + fTabletType = ET_TABLET; // Graphire else - fTabletType = UD_TABLET; // ASSUMPTION!!! + fTabletType = UD_TABLET; // ASSUMPTION!!! // Should check for UD here - what does a PenPartner say? (KT?) - if (fTabletType == ET_TABLET) - { - fPort->Write ("ZF0\r", 4); // Filter off. + if (fTabletType == ET_TABLET) { + fPort->Write("ZF0\r", 4); // Filter off. fMaxPressure = 512; } - fPort->Write ("~C\r", 3); - snooze (250000); - num = GetLine (fPort, fBuffer, 255); - // printf ("Buffer: %s\n", fBuffer); - fMaxX = atof (&fBuffer[2]); - fMaxY = atof (&fBuffer[8]); - syslog (LOG_DEBUG, "Max Coords: (%f, %f)\n", fMaxX, fMaxY); - fRect = BRect (0, 0, fMaxX, fMaxY); + fPort->Write("~C\r", 3); + snooze(250000); + num = GetLine(fPort, fBuffer, 255); + // printf ("Buffer: %s\n", fBuffer); + fMaxX = atof(&fBuffer[2]); + fMaxY = atof(&fBuffer[8]); + syslog(LOG_DEBUG, "Max Coords: (%f, %f)\n", fMaxX, fMaxY); + fRect = BRect(0, 0, fMaxX, fMaxY); fPos.x = fPos.y = 0; fValid = true; - } - else - syslog (LOG_DEBUG, "No tablet at this port, or tablet switched off...\n"); - } - else - syslog (LOG_DEBUG, "No tablet at this port\n"); + } else + syslog(LOG_DEBUG, "No tablet at this port, or tablet switched off...\n"); + } else + syslog(LOG_DEBUG, "No tablet at this port\n"); return (fValid); } - -BPoint Tablet::Point () +BPoint +Tablet::Point() { -// syslog (LOG_DEBUG, "Returning (%f, %f)", fScaleX*(fPos.x - fRect.left)/(fRect.Width() + 1), fScaleY*(fPos.y - fRect.top)/(fRect.Height() + 1)); - return (BPoint (fScaleX*(fPos.x - fRect.left)/(fRect.Width() + 1), fScaleY*(fPos.y - fRect.top)/(fRect.Height() + 1))); + // syslog (LOG_DEBUG, "Returning (%f, %f)", fScaleX*(fPos.x - fRect.left)/(fRect.Width() + 1), + // fScaleY*(fPos.y - fRect.top)/(fRect.Height() + 1)); + return (BPoint( + fScaleX * (fPos.x - fRect.left) / (fRect.Width() + 1), + fScaleY * (fPos.y - fRect.top) / (fRect.Height() + 1) + )); } - -status_t Tablet::Update () +status_t +Tablet::Update() { -// fPort->ClearOutput(); + // fPort->ClearOutput(); fPort->ClearInput(); - fPort->Write ("@", 1); - snooze (20000); -// int32 num = GetLine (fPort, fBuffer, 255); - -/* NOTE: This was cause of a particularly nasty bug. - * GetLine scanned the line until a sign, ASCII 13. However, in some - * coordinate data packages, that value (0xD) also appeared as part of the - * data structure, signalling GetLine() to end the input there!! - * Since 13 is also Xoff, I spent a lot of time looking in entirely the - * wrong direction as to what was going wrong... -*/ - /*int32 num = */fPort->Read (fBuffer, 7); - /*printf ("Read %d bytes... ", num);*/ fflush (stdout); - if (convertpositiontostruct (fBuffer, fPos, fTabletType) == B_ERROR) - { + fPort->Write("@", 1); + snooze(20000); + // int32 num = GetLine (fPort, fBuffer, 255); + + /* NOTE: This was cause of a particularly nasty bug. + * GetLine scanned the line until a sign, ASCII 13. However, in some + * coordinate data packages, that value (0xD) also appeared as part of the + * data structure, signalling GetLine() to end the input there!! + * Since 13 is also Xoff, I spent a lot of time looking in entirely the + * wrong direction as to what was going wrong... + */ + /*int32 num = */ fPort->Read(fBuffer, 7); + /*printf ("Read %d bytes... ", num);*/ fflush(stdout); + if (convertpositiontostruct(fBuffer, fPos, fTabletType) == B_ERROR) { return (B_ERROR); - syslog (LOG_DEBUG, "Invalid Data.\n"); + syslog(LOG_DEBUG, "Invalid Data.\n"); } return B_OK; } -status_t convertinfotostruct (const uint32 * /*data */, tablet_info & /*info*/) +status_t +convertinfotostruct(const uint32* /*data */, tablet_info& /*info*/) { return (B_NO_ERROR); } -status_t convertpositiontostruct (const char *data, tablet_position &info, uint32 tablet_type) +status_t +convertpositiontostruct(const char* data, tablet_position& info, uint32 tablet_type) { int mid; - if (!(data[0] & kSyncBitMask)) - { + if (!(data[0] & kSyncBitMask)) { // printf("convertpositiontostruct - early return, no sync bit\n"); return B_ERROR; } @@ -128,24 +128,22 @@ status_t convertpositiontostruct (const char *data, tablet_position &info, uint3 info.stylus = data[0] & kPointerBitMask; info.buttonflag = data[0] & kButtonBitMask; - info.x = (data[0] & 0x3)*16384; - info.x += (data[1] & 0x7f)*128; + info.x = (data[0] & 0x3) * 16384; + info.x += (data[1] & 0x7f) * 128; info.x += (data[2] & 0x7f); info.buttons = (data[3] & 0x78) >> 3; - info.y = (data[3] & 0x3)*16384; - info.y += (data[4] & 0x7f)*128; + info.y = (data[3] & 0x3) * 16384; + info.y += (data[4] & 0x7f) * 128; info.y += (data[5] & 0x7f); info.pressuresign = (data[6] & kPressureSignBitMask) >> kPressureSignBit; info.pressuredata = (data[6] & 0x3f) << 1 | ((data[4] & kP0BitMask) >> kP0Bit); - if (tablet_type == ET_TABLET) - { + if (tablet_type == ET_TABLET) { info.pressuredata = (info.pressuredata << 1) & ((data[0] * kAp1BitMask) >> kAp1Bit); mid = 256; - } - else + } else mid = 128; if (info.pressuresign) info.pressure = info.pressuredata; @@ -161,12 +159,13 @@ status_t convertpositiontostruct (const char *data, tablet_position &info, uint3 // terminated with a // ...but it's not, apparently. -int GetLine (BSerialPort *port, char *buff, const long buffLen) +int +GetLine(BSerialPort* port, char* buff, const long buffLen) { - //return; + // return; bool done = false; - char *ptr = buff; + char* ptr = buff; long totalread = 0; #if 0 @@ -176,26 +175,21 @@ int GetLine (BSerialPort *port, char *buff, const long buffLen) #else uint8 aChar; - while (!done && (totalread < buffLen)) - { - long numRead = port->Read (&aChar, 1); - if (numRead > 0) - { - if (aChar == '\r' || !aChar) - { + while (!done && (totalread < buffLen)) { + long numRead = port->Read(&aChar, 1); + if (numRead > 0) { + if (aChar == '\r' || !aChar) { *ptr = '\0'; done = true; break; - } - else + } else *ptr = aChar; ptr++; totalread++; - } - else // Nothing within timeout + } else // Nothing within timeout { *ptr = 0; - syslog (LOG_DEBUG, "\n"); + syslog(LOG_DEBUG, "\n"); done = true; break; } diff --git a/source/Tablet.h b/source/Tablet.h index 0e94ee1..4ee2954 100644 --- a/source/Tablet.h +++ b/source/Tablet.h @@ -7,44 +7,65 @@ #include #include -#define UD_TABLET 1 -#define ET_TABLET 2 // Graphire +#define UD_TABLET 1 +#define ET_TABLET 2 // Graphire class Tablet { -public: - Tablet (const char *portname); -virtual ~Tablet (); -virtual bool Init (); -virtual status_t Update (); -virtual void SetScale (float x, float y) { fScaleX = x; fScaleY = y; }; -virtual void SetRect (const BRect &rect) { fRect = rect; }; -virtual BRect GetRect () { return fRect; }; -virtual void SetThreshold (float t) { fTreshold = t; }; -virtual BPoint Point (); -virtual const char *Model () { return (fModel); }; -virtual uint32 Buttons () { return (fPos.buttons); }; -virtual bool Proximity () { return (fPos.proximity); }; -virtual float Pressure () { return (fPos.pressure/fMaxPressure); }; -virtual bool IsValid () { return (fValid); }; -virtual float Threshold () { return (fTreshold); }; -virtual BPoint Tilt () { return (BPoint (fPos.xtiltsign ? fPos.xtiltdata : -fPos.xtiltdata, - fPos.ytiltsign ? fPos.ytiltdata : -fPos.ytiltdata)); }; - -private: -float fMaxX, fMaxY; -float fScaleX, fScaleY; -float fTreshold; -tablet_info fInfo; -tablet_position fPos; -BRect fRect; -BSerialPort *fPort; -char fPortName[128]; -char fBuffer[256]; -char fModel[32]; -bool fValid; -float fMaxPressure; -int32 fTabletType; + public: + Tablet(const char* portname); + virtual ~Tablet(); + virtual bool Init(); + virtual status_t Update(); + + virtual void SetScale(float x, float y) + { + fScaleX = x; + fScaleY = y; + }; + + virtual void SetRect(const BRect& rect) { fRect = rect; }; + + virtual BRect GetRect() { return fRect; }; + + virtual void SetThreshold(float t) { fTreshold = t; }; + + virtual BPoint Point(); + + virtual const char* Model() { return (fModel); }; + + virtual uint32 Buttons() { return (fPos.buttons); }; + + virtual bool Proximity() { return (fPos.proximity); }; + + virtual float Pressure() { return (fPos.pressure / fMaxPressure); }; + + virtual bool IsValid() { return (fValid); }; + + virtual float Threshold() { return (fTreshold); }; + + virtual BPoint Tilt() + { + return (BPoint( + fPos.xtiltsign ? fPos.xtiltdata : -fPos.xtiltdata, + fPos.ytiltsign ? fPos.ytiltdata : -fPos.ytiltdata + )); + }; + + private: + float fMaxX, fMaxY; + float fScaleX, fScaleY; + float fTreshold; + tablet_info fInfo; + tablet_position fPos; + BRect fRect; + BSerialPort* fPort; + char fPortName[128]; + char fBuffer[256]; + char fModel[32]; + bool fValid; + float fMaxPressure; + int32 fTabletType; }; #endif diff --git a/source/ThumbnailFilePanel.cpp b/source/ThumbnailFilePanel.cpp index 9fb501f..1e38503 100644 --- a/source/ThumbnailFilePanel.cpp +++ b/source/ThumbnailFilePanel.cpp @@ -16,127 +16,128 @@ #define THUMBNAIL_VIEW_WIDTH 160 #ifndef MIN -#define MIN(x,y) ((x)<(y)?(x):(y)) +#define MIN(x, y) ((x) < (y) ? (x) : (y)) #endif -ThumbnailFilePanel::ThumbnailFilePanel (file_panel_mode mode, - BMessenger* target, - entry_ref *panel_directory, - uint32 node_flavors, - bool allow_multiple_selection, - BMessage *message, - BRefFilter *filter, - bool modal, - bool hide_when_done) -: BFilePanel (mode, target, panel_directory, node_flavors, allow_multiple_selection, - message, filter, modal, hide_when_done) +ThumbnailFilePanel::ThumbnailFilePanel( + file_panel_mode mode, BMessenger* target, entry_ref* panel_directory, uint32 node_flavors, + bool allow_multiple_selection, BMessage* message, BRefFilter* filter, bool modal, + bool hide_when_done +) + : BFilePanel( + mode, target, panel_directory, node_flavors, allow_multiple_selection, message, filter, + modal, hide_when_done + ) { float resizeby = THUMBNAIL_VIEW_HEIGHT - 40; float minWidth, minHeight, maxWidth, maxHeight; Window()->Lock(); - Window()->GetSizeLimits (&minWidth, &maxWidth, &minHeight, &maxHeight); - BView *background = Window()->ChildAt (0); - BView *poseView = background->FindView ("PoseView"); -// BView *cancelButton = background->FindView ("cancel button"); - BView *countVW = background->FindView ("CountVw"); - BView *vScrollBar = background->FindView ("VScrollBar"); - - BView *hScrollBar = background->FindView ("HScrollBar"); - //printf ("Looking for Horizontal ScrollBar...\n"); - // Horizontal ScrollBar workaround - // Note: Be was so kind as to change the name from "" to "HScrollBar" in 4.1 - if (!hScrollBar) // >= R4.1 I suppose. + Window()->GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); + BView* background = Window()->ChildAt(0); + BView* poseView = background->FindView("PoseView"); + // BView *cancelButton = background->FindView ("cancel button"); + BView* countVW = background->FindView("CountVw"); + BView* vScrollBar = background->FindView("VScrollBar"); + + BView* hScrollBar = background->FindView("HScrollBar"); + // printf ("Looking for Horizontal ScrollBar...\n"); + // Horizontal ScrollBar workaround + // Note: Be was so kind as to change the name from "" to "HScrollBar" in 4.1 + if (!hScrollBar) // >= R4.1 I suppose. { - for (int i = background->CountChildren(); i > 0; i--) - { - BView *view = background->ChildAt (i - 1); + for (int i = background->CountChildren(); i > 0; i--) { + BView* view = background->ChildAt(i - 1); // printf ("View %d, '%s'\n", i - 1, view->Name()); - if (!strcmp ("", view->Name())) - { + if (!strcmp("", view->Name())) { hScrollBar = view; break; } } } BRect tFrame = poseView->Frame(); - Window()->ResizeBy (0, resizeby); - Window()->SetSizeLimits (minWidth, maxWidth, minHeight + resizeby, maxWidth); + Window()->ResizeBy(0, resizeby); + Window()->SetSizeLimits(minWidth, maxWidth, minHeight + resizeby, maxWidth); // The poseView will resize along, so undo that. - poseView->ResizeBy (0, -resizeby); - vScrollBar->ResizeBy (0, -resizeby); - hScrollBar->MoveBy (0, -resizeby); - countVW->MoveBy (0, -resizeby); - BRect viewRect= BRect (tFrame.left - 1, tFrame.bottom + 24,tFrame.left + THUMBNAIL_VIEW_WIDTH, tFrame.bottom + 8 + THUMBNAIL_VIEW_HEIGHT); - fView = new ThumbnailView (viewRect, - "thumbnail view", - B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW); - background->AddChild (fView); - - infoView1 = new BStringView (BRect (viewRect.right + 8, viewRect.top, background->Frame().right - 4, viewRect.top + 16), "infoView1", "File Type", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); - infoView2 = new BStringView (BRect (viewRect.right + 8, viewRect.top + 18, background->Frame().right - 4, viewRect.top + 34), "infoView2", "Dimensions", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); - background->AddChild (infoView1); - background->AddChild (infoView2); + poseView->ResizeBy(0, -resizeby); + vScrollBar->ResizeBy(0, -resizeby); + hScrollBar->MoveBy(0, -resizeby); + countVW->MoveBy(0, -resizeby); + BRect viewRect = BRect( + tFrame.left - 1, tFrame.bottom + 24, tFrame.left + THUMBNAIL_VIEW_WIDTH, + tFrame.bottom + 8 + THUMBNAIL_VIEW_HEIGHT + ); + fView = + new ThumbnailView(viewRect, "thumbnail view", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW); + background->AddChild(fView); + + infoView1 = new BStringView( + BRect(viewRect.right + 8, viewRect.top, background->Frame().right - 4, viewRect.top + 16), + "infoView1", "File Type", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM + ); + infoView2 = new BStringView( + BRect( + viewRect.right + 8, viewRect.top + 18, background->Frame().right - 4, viewRect.top + 34 + ), + "infoView2", "Dimensions", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM + ); + background->AddChild(infoView1); + background->AddChild(infoView2); SelectionChanged(); Window()->Unlock(); } -ThumbnailFilePanel::~ThumbnailFilePanel () -{ -} +ThumbnailFilePanel::~ThumbnailFilePanel() {} -void ThumbnailFilePanel::SelectionChanged () +void +ThumbnailFilePanel::SelectionChanged() { Rewind(); entry_ref ref; - if (GetNextSelectedRef (&ref) != B_OK) - { - infoView1->SetText (""); - infoView2->SetText (""); - fView->update (NULL); + if (GetNextSelectedRef(&ref) != B_OK) { + infoView1->SetText(""); + infoView2->SetText(""); + fView->update(NULL); return; } - BEntry entry (&ref); - BBitmap *map = entry2bitmap (entry, true); - if (!map) - { - infoView1->SetText (""); - infoView2->SetText (""); - fView->update (NULL); + BEntry entry(&ref); + BBitmap* map = entry2bitmap(entry, true); + if (!map) { + infoView1->SetText(""); + infoView2->SetText(""); + fView->update(NULL); return; } - //filetype [node.ReadAttr ("BEOS:TYPE", 0, 0, filetype, 80)] = 0; - //printf ("Filetype: '%s'\n", filetype); - BNode node (&ref); - BNodeInfo ninfo (&node); + // filetype [node.ReadAttr ("BEOS:TYPE", 0, 0, filetype, 80)] = 0; + // printf ("Filetype: '%s'\n", filetype); + BNode node(&ref); + BNodeInfo ninfo(&node); char filetype[256]; - if (ninfo.GetType (filetype) < B_OK) - { - BEntry entry (&ref); - BPath path (&entry); - update_mime_info (path.Path(), 0, 1, 0); - if (ninfo.GetType (filetype) < B_OK) - { - fprintf (stderr, "Can't find the type of '%s'\n", path.Path()); + if (ninfo.GetType(filetype) < B_OK) { + BEntry entry(&ref); + BPath path(&entry); + update_mime_info(path.Path(), 0, 1, 0); + if (ninfo.GetType(filetype) < B_OK) { + fprintf(stderr, "Can't find the type of '%s'\n", path.Path()); } } - - BMimeType mime (filetype); + + BMimeType mime(filetype); BRect viewRect = fView->Frame(); - infoView1->MoveTo (viewRect.right + 8, viewRect.top); - infoView2->MoveTo (viewRect.right + 8, viewRect.top + 18); + infoView1->MoveTo(viewRect.right + 8, viewRect.top); + infoView2->MoveTo(viewRect.right + 8, viewRect.top + 18); if (mime.IsValid()) - infoView1->SetText (filetype); + infoView1->SetText(filetype); else - infoView1->SetText ("?"); - - char sizestr[80]; - sprintf (sizestr, "%ld x %ld", - map->Bounds().IntegerWidth() + 1, - map->Bounds().IntegerHeight() + 1); - infoView2->SetText (sizestr); - - fView->update (map); + infoView1->SetText("?"); + + BString heightData, sizeString, widthData; + fNumberFormat.Format(heightData, map->Bounds().IntegerHeight() + 1); + fNumberFormat.Format(widthData, map->Bounds().IntegerWidth() + 1); + sizeString.SetToFormat("%s × %s", widthData.String(), heightData.String()); + infoView2->SetText(sizeString); + + fView->update(map); delete map; } @@ -145,61 +146,59 @@ void ThumbnailFilePanel::SelectionChanged () // ThumbnailView // -ThumbnailView::ThumbnailView (BRect frame, const char *name, uint32 resizingMode, uint32 flags) -: BView (frame, name, resizingMode, flags) +ThumbnailView::ThumbnailView(BRect frame, const char* name, uint32 resizingMode, uint32 flags) + : BView(frame, name, resizingMode, flags) { fBitmap = NULL; } -void ThumbnailView::AttachedToWindow () +void +ThumbnailView::AttachedToWindow() { - SetViewColor (Parent()->ViewColor()); + SetViewColor(Parent()->ViewColor()); } -ThumbnailView::~ThumbnailView () -{ - delete fBitmap; -} +ThumbnailView::~ThumbnailView() { delete fBitmap; } -void ThumbnailView::Draw (BRect update) +void +ThumbnailView::Draw(BRect update) { - if (!fBitmap) - { - SetHighColor (Parent()->ViewColor()); - FillRect (update); + if (!fBitmap) { + SetHighColor(Parent()->ViewColor()); + FillRect(update); return; } - DrawBitmap (fBitmap, BPoint (1, 1)); + DrawBitmap(fBitmap, BPoint(1, 1)); BRect bb = fBitmap->Bounds(); bb.right += 2; bb.bottom += 2; - SetHighColor (Grey13); - StrokeLine (bb.RightTop(), bb.LeftTop()); - StrokeLine (bb.LeftBottom()); - SetHighColor (Grey29); - StrokeLine (bb.RightBottom()); - StrokeLine (bb.RightTop()); + SetHighColor(Grey13); + StrokeLine(bb.RightTop(), bb.LeftTop()); + StrokeLine(bb.LeftBottom()); + SetHighColor(Grey29); + StrokeLine(bb.RightBottom()); + StrokeLine(bb.RightTop()); } -void ThumbnailView::update (BBitmap *map) +void +ThumbnailView::update(BBitmap* map) { delete fBitmap; fBitmap = NULL; - if (map) - { + if (map) { BRect mbounds = map->Bounds(); BRect bounds = Bounds(); - bounds.InsetBy (1, 1); - float ratio = MIN (bounds.Width()/mbounds.Width(), bounds.Height()/mbounds.Height()); - bounds.right = bounds.left + ratio*mbounds.Width(); - bounds.bottom = bounds.top + ratio*mbounds.Height(); - bounds.OffsetTo (B_ORIGIN); - BView *tmpView = new BView (bounds, "tmp View for scaling", 0, 0); - fBitmap = new BBitmap (bounds, B_RGBA32, true); + bounds.InsetBy(1, 1); + float ratio = MIN(bounds.Width() / mbounds.Width(), bounds.Height() / mbounds.Height()); + bounds.right = bounds.left + ratio * mbounds.Width(); + bounds.bottom = bounds.top + ratio * mbounds.Height(); + bounds.OffsetTo(B_ORIGIN); + BView* tmpView = new BView(bounds, "tmp View for scaling", 0, 0); + fBitmap = new BBitmap(bounds, B_RGBA32, true); fBitmap->Lock(); - fBitmap->AddChild (tmpView); - tmpView->DrawBitmap (map, mbounds, bounds); - fBitmap->RemoveChild (tmpView); + fBitmap->AddChild(tmpView); + tmpView->DrawBitmap(map, mbounds, bounds); + fBitmap->RemoveChild(tmpView); delete tmpView; } Invalidate(); diff --git a/source/ThumbnailFilePanel.h b/source/ThumbnailFilePanel.h index f733f96..96e23e3 100644 --- a/source/ThumbnailFilePanel.h +++ b/source/ThumbnailFilePanel.h @@ -7,40 +7,39 @@ #include #include #include +#include class ThumbnailView : public BView { -public: - ThumbnailView (BRect frame, const char *name, uint32 resizingMode, uint32 flags); -virtual ~ThumbnailView (); -virtual void AttachedToWindow (); -virtual void Draw (BRect update); + public: + ThumbnailView(BRect frame, const char* name, uint32 resizingMode, uint32 flags); + virtual ~ThumbnailView(); + virtual void AttachedToWindow(); + virtual void Draw(BRect update); -void update (BBitmap *map); + void update(BBitmap* map); -private: -BBitmap *fBitmap; + private: + BBitmap* fBitmap; }; class ThumbnailFilePanel : public BFilePanel { -public: - ThumbnailFilePanel (file_panel_mode mode = B_OPEN_PANEL, - BMessenger* target = NULL, - entry_ref *panel_directory = NULL, - uint32 node_flavors = 0, - bool allow_multiple_selection = true, - BMessage *message = NULL, - BRefFilter *filter = NULL, - bool modal = false, - bool hide_when_done = true); -virtual ~ThumbnailFilePanel (); -virtual void SelectionChanged (); - -private: -ThumbnailView *fView; -BStringView *infoView1; -BStringView *infoView2; + public: + ThumbnailFilePanel( + file_panel_mode mode = B_OPEN_PANEL, BMessenger* target = NULL, + entry_ref* panel_directory = NULL, uint32 node_flavors = 0, + bool allow_multiple_selection = true, BMessage* message = NULL, BRefFilter* filter = NULL, + bool modal = false, bool hide_when_done = true + ); + virtual ~ThumbnailFilePanel(); + virtual void SelectionChanged(); + + private: + ThumbnailView* fView; + BStringView* infoView1; + BStringView* infoView2; + BNumberFormat fNumberFormat; }; #endif diff --git a/source/Tools.h b/source/Tools.h index a05508a..38c1a17 100644 --- a/source/Tools.h +++ b/source/Tools.h @@ -1,19 +1,19 @@ #ifndef _TOOLS_H #define _TOOLS_H -#define T_BRUSH 0 -#define T_ERASER 1 -#define T_FILL 2 -#define T_TEXT 3 -#define T_SPRAYCAN 4 -#define T_CLONE 5 -#define T_FREEHAND 6 -#define T_LINES 7 -#define T_POLYBLOB 8 -#define T_POLYGON 9 -#define T_RECT 10 -#define T_RRECT 11 -#define T_CIRCLE 12 -#define T_ELLIPSE 13 +#define T_BRUSH 0 +#define T_ERASER 1 +#define T_FILL 2 +#define T_TEXT 3 +#define T_SPRAYCAN 4 +#define T_CLONE 5 +#define T_FREEHAND 6 +#define T_LINES 7 +#define T_POLYBLOB 8 +#define T_POLYGON 9 +#define T_RECT 10 +#define T_RRECT 11 +#define T_CIRCLE 12 +#define T_ELLIPSE 13 #endif diff --git a/source/VideoConsumer.h b/source/VideoConsumer.h index 60b4d13..a0911e3 100644 --- a/source/VideoConsumer.h +++ b/source/VideoConsumer.h @@ -14,120 +14,88 @@ #include #include -class VideoConsumer : - public BMediaEventLooper, - public BBufferConsumer +class VideoConsumer : public BMediaEventLooper, public BBufferConsumer { -public: - VideoConsumer( - const char * name, - BView * view, - BMediaAddOn *addon, - const int32 internal_id); - ~VideoConsumer(); - -/* BMediaNode */ -public: - - virtual BMediaAddOn *AddOn(int32 *cookie) const; - -protected: - - virtual void Start(bigtime_t performance_time); - virtual void Stop(bigtime_t performance_time, bool immediate); - virtual void Seek(bigtime_t media_time, bigtime_t performance_time); - virtual void TimeWarp(bigtime_t at_real_time, bigtime_t to_performance_time); - - virtual void NodeRegistered(); - virtual status_t RequestCompleted( - const media_request_info & info); - - virtual status_t DeleteHook(BMediaNode * node); - -/* BMediaEventLooper */ -protected: - virtual void HandleEvent( - const media_timed_event *event, - bigtime_t lateness, - bool realTimeEvent); -/* BBufferConsumer */ -public: - - virtual status_t AcceptFormat( - const media_destination &dest, - media_format * format); - virtual status_t GetNextInput( - int32 * cookie, - media_input * out_input); - - virtual void DisposeInputCookie( - int32 cookie); - -protected: - - virtual void BufferReceived( - BBuffer * buffer); - -private: - - virtual void ProducerDataStatus( - const media_destination &for_whom, - int32 status, - bigtime_t at_media_time); - virtual status_t GetLatencyFor( - const media_destination &for_whom, - bigtime_t * out_latency, - media_node_id * out_id); - virtual status_t Connected( - const media_source &producer, - const media_destination &where, - const media_format & with_format, - media_input * out_input); - virtual void Disconnected( - const media_source &producer, - const media_destination &where); - virtual status_t FormatChanged( - const media_source & producer, - const media_destination & consumer, - int32 from_change_count, - const media_format & format); - -/* implementation */ - -public: - status_t CreateBuffers( - const media_format & with_format); - - void DeleteBuffers(); - - BBitmap *Grab(); - - status_t LocalSave( - char *filename, - BBitmap *bitmap); - - -private: - - int32 mInternalID; - BMediaAddOn *mAddOn; - - bool mConnectionActive; - media_input mIn; - media_destination mDestination; - bigtime_t mMyLatency; - - BWindow *mWindow; - BView *mView; - BBitmap *mBitmap[3]; - bool mOurBuffers; - BBufferGroup *mBuffers; - BBuffer *mBufferMap[3]; - - bigtime_t mRate; - uint32 mImageFormat; - int32 mTranslator; - int32 fLastIndex; + public: + VideoConsumer(const char* name, BView* view, BMediaAddOn* addon, const int32 internal_id); + ~VideoConsumer(); + + /* BMediaNode */ + public: + virtual BMediaAddOn* AddOn(int32* cookie) const; + + protected: + virtual void Start(bigtime_t performance_time); + virtual void Stop(bigtime_t performance_time, bool immediate); + virtual void Seek(bigtime_t media_time, bigtime_t performance_time); + virtual void TimeWarp(bigtime_t at_real_time, bigtime_t to_performance_time); + + virtual void NodeRegistered(); + virtual status_t RequestCompleted(const media_request_info& info); + + virtual status_t DeleteHook(BMediaNode* node); + + /* BMediaEventLooper */ + protected: + virtual void + HandleEvent(const media_timed_event* event, bigtime_t lateness, bool realTimeEvent); + /* BBufferConsumer */ + public: + virtual status_t AcceptFormat(const media_destination& dest, media_format* format); + virtual status_t GetNextInput(int32* cookie, media_input* out_input); + + virtual void DisposeInputCookie(int32 cookie); + + protected: + virtual void BufferReceived(BBuffer* buffer); + + private: + virtual void + ProducerDataStatus(const media_destination& for_whom, int32 status, bigtime_t at_media_time); + virtual status_t + GetLatencyFor(const media_destination& for_whom, bigtime_t* out_latency, media_node_id* out_id); + virtual status_t Connected( + const media_source& producer, const media_destination& where, + const media_format& with_format, media_input* out_input + ); + virtual void Disconnected(const media_source& producer, const media_destination& where); + virtual status_t FormatChanged( + const media_source& producer, const media_destination& consumer, int32 from_change_count, + const media_format& format + ); + + /* implementation */ + + public: + status_t CreateBuffers(const media_format& with_format); + + void DeleteBuffers(); + + BBitmap* Grab(); + + status_t LocalSave(char* filename, BBitmap* bitmap); + + + private: + int32 mInternalID; + BMediaAddOn* mAddOn; + + bool mConnectionActive; + media_input mIn; + media_destination mDestination; + bigtime_t mMyLatency; + + BWindow* mWindow; + BView* mView; + BBitmap* mBitmap[3]; + bool mOurBuffers; + BBufferGroup* mBuffers; + BBuffer* mBufferMap[3]; + + bigtime_t mRate; + uint32 mImageFormat; + int32 mTranslator; + int32 fLastIndex; }; #endif diff --git a/source/Wacom.h b/source/Wacom.h index d5a7a1d..9fadc5d 100644 --- a/source/Wacom.h +++ b/source/Wacom.h @@ -11,15 +11,15 @@ #ifndef _WACOM_DRIVER_H #define _WACOM_DRIVER_H -const uint8 kSyncBit = 7; -const uint8 kProximityBit = 6; -const uint8 kPointerBit = 5; -const uint8 kButtonBit = 3; -const uint8 kPressureSignBit = 6; -const uint8 kP0Bit = 2; -const uint8 kAp1Bit = 2; - -const uint8 kSyncBitMask = 0x1 << kSyncBit; +const uint8 kSyncBit = 7; +const uint8 kProximityBit = 6; +const uint8 kPointerBit = 5; +const uint8 kButtonBit = 3; +const uint8 kPressureSignBit = 6; +const uint8 kP0Bit = 2; +const uint8 kAp1Bit = 2; + +const uint8 kSyncBitMask = 0x1 << kSyncBit; const uint8 kProximityBitMask = 0x1 << kProximityBit; const uint8 kPointerBitMask = 0x1 << kPointerBit; const uint8 kButtonBitMask = 0x1 << kButtonBit; @@ -42,89 +42,96 @@ enum { */ /*-------------------------------------------------------------------------- - General info struct used to pass control info in and + General info struct used to pass control info in and out of driver. */ -enum ECommandSet { +enum ECommandSet +{ WT_WacomIV = 3, WT_WacomIIS = 2, WT_MM1201 = 1, WT_BitPad = 0 }; -enum EBaudRate { +enum EBaudRate +{ WT_19200 = 3, WT_9600 = 2, WT_4800 = 1, - WT_2400 = 0 + WT_2400 = 0 }; -enum EParity { +enum EParity +{ WT_EVEN = 3, WT_ODD = 2, WT_NONE = 0 }; -enum EDataBits { +enum EDataBits +{ WT_8bit = 1, WT_7bit = 0 }; -enum EStopBits { - WT_2STOPBITS = 1, - WT_1STOPBIT = 0 +enum EStopBits +{ + WT_2STOPBITS = 1, + WT_1STOPBIT = 0 }; typedef struct { - int8 commandset; - int8 baudrate; - int8 parity; - int8 datalength; - int8 stopbits; - - int8 ctsdsr; - int8 transfermode; - int8 outputformat; - int8 coordinatesystem; - int8 transferrate; - - int8 resolution; - int8 origin; - int8 outofrange; - int8 terminator; - - int8 pressure; - int8 readingheight; - int8 multimode; - int8 mmcommandset; - int8 mm961orient; - int8 bitpadIIcursor; - int8 remotemode; + int8 commandset; + int8 baudrate; + int8 parity; + int8 datalength; + int8 stopbits; + + int8 ctsdsr; + int8 transfermode; + int8 outputformat; + int8 coordinatesystem; + int8 transferrate; + + int8 resolution; + int8 origin; + int8 outofrange; + int8 terminator; + + int8 pressure; + int8 readingheight; + int8 multimode; + int8 mmcommandset; + int8 mm961orient; + int8 bitpadIIcursor; + int8 remotemode; } tablet_info; - -typedef struct +typedef struct { - int32 x; - int32 y; - uint32 buttons; - int32 pressuredata; - int32 pressure; - int32 xtiltdata; - int32 ytiltdata; - int32 status; - bool pressuresign; - bool proximity; - bool stylus; - bool buttonflag; - bool xtiltsign; - bool ytiltsign; + int32 x; + int32 y; + uint32 buttons; + int32 pressuredata; + int32 pressure; + int32 xtiltdata; + int32 ytiltdata; + int32 status; + bool pressuresign; + bool proximity; + bool stylus; + bool buttonflag; + bool xtiltsign; + bool ytiltsign; } tablet_position; -int GetLine(BSerialPort *port, char *buff, const long buffLen); -status_t convertpositiontostruct(const char *data, tablet_position &, uint32 tablet_type); -status_t convertinfotostruct(const uint32 *data, tablet_info &); +int +GetLine(BSerialPort* port, char* buff, const long buffLen); +status_t +convertpositiontostruct(const char* data, tablet_position&, uint32 tablet_type); +status_t +convertinfotostruct(const uint32* data, tablet_info&); #endif diff --git a/source/XpalWindow.cpp b/source/XpalWindow.cpp index 12e83d9..1d3ff7d 100644 --- a/source/XpalWindow.cpp +++ b/source/XpalWindow.cpp @@ -8,34 +8,43 @@ #define XPW_BSIZE 74 -XpalWindow::XpalWindow (BRect rect, const char *name, BMessenger *target) -: BWindow (rect, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE), fTarget (target) +XpalWindow::XpalWindow(BRect rect, const char* name, BMessenger* target) + : BWindow(rect, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE), fTarget(target) { - BView *bg = new BView (Bounds(), "bg", B_FOLLOW_ALL, B_WILL_DRAW); - bg->SetViewColor (LightGrey); - AddChild (bg); + BView* bg = new BView(Bounds(), "bg", B_FOLLOW_ALL, B_WILL_DRAW); + bg->SetViewColor(LightGrey); + AddChild(bg); float bw = Bounds().Width(); - Slider *nSlid = new Slider (BRect (8, 8, 8 + (bw - 16), 24), 50, lstring (184, "# Colors"), 1, 256, 1, new BMessage ('numC')); - bg->AddChild (nSlid); + Slider* nSlid = new Slider( + BRect(8, 8, 8 + (bw - 16), 24), 50, lstring(184, "# Colors"), 1, 256, 1, + new BMessage('numC') + ); + bg->AddChild(nSlid); fNum = 256; - nSlid->SetValue (256); - fClobberCB = new BCheckBox (BRect (8, 30, 8 + (bw - 16), 46), "clobber", lstring (185, "Clobber Remaining Palette"), new BMessage ('clob')); + nSlid->SetValue(256); + fClobberCB = new BCheckBox( + BRect(8, 30, 8 + (bw - 16), 46), "clobber", lstring(185, "Clobber Remaining Palette"), + new BMessage('clob') + ); fClobber = false; - fClobberCB->SetValue (false); - fClobberCB->SetEnabled (false); - bg->AddChild (fClobberCB); - BButton *xFG = new BButton (BRect (bw - 2*XPW_BSIZE - 16, 50, bw - XPW_BSIZE - 16, 74), "fg", lstring (70, "Foreground"), new BMessage ('xpfg')); - BButton *xBG = new BButton (BRect (bw - XPW_BSIZE - 8, 50, bw - 8, 74), "bg", lstring (71, "Background"), new BMessage ('xpbg')); - bg->AddChild (xFG); - bg->AddChild (xBG); + fClobberCB->SetValue(false); + fClobberCB->SetEnabled(false); + bg->AddChild(fClobberCB); + BButton* xFG = new BButton( + BRect(bw - 2 * XPW_BSIZE - 16, 50, bw - XPW_BSIZE - 16, 74), "fg", + lstring(70, "Foreground"), new BMessage('xpfg') + ); + BButton* xBG = new BButton( + BRect(bw - XPW_BSIZE - 8, 50, bw - 8, 74), "bg", lstring(71, "Background"), + new BMessage('xpbg') + ); + bg->AddChild(xFG); + bg->AddChild(xBG); fStatus = 0; } -XpalWindow::~XpalWindow () -{ - delete fTarget; -} +XpalWindow::~XpalWindow() { delete fTarget; } #if 0 int32 XpalWindow::Go () @@ -60,45 +69,43 @@ int32 XpalWindow::Go () } #endif -void XpalWindow::MessageReceived (BMessage *message) +void +XpalWindow::MessageReceived(BMessage* message) { - switch (message->what) - { + switch (message->what) { case 'numC': - fNum = int (message->FindFloat ("value")); + fNum = int(message->FindFloat("value")); if (fNum < 256) - fClobberCB->SetEnabled (true); + fClobberCB->SetEnabled(true); else - fClobberCB->SetEnabled (false); + fClobberCB->SetEnabled(false); break; case 'clob': fClobber = fClobberCB->Value(); if (fClobber) - printf ("Clobber now true\n"); + printf("Clobber now true\n"); else - printf ("Clobber now false\n"); + printf("Clobber now false\n"); break; - case 'xpfg': - { - BMessage *m = new BMessage ('xclF'); - m->AddBool ("clobber", fClobber); - m->AddInt32 ("num_cols", fNum); + case 'xpfg': { + BMessage* m = new BMessage('xclF'); + m->AddBool("clobber", fClobber); + m->AddInt32("num_cols", fNum); // m->PrintToStream(); - fTarget->SendMessage (m); + fTarget->SendMessage(m); delete m; break; } - case 'xpbg': - { - BMessage *m = new BMessage ('xclB'); - m->AddBool ("clobber", fClobber); - m->AddInt32 ("num_cols", fNum); - fTarget->SendMessage (m); + case 'xpbg': { + BMessage* m = new BMessage('xclB'); + m->AddBool("clobber", fClobber); + m->AddInt32("num_cols", fNum); + fTarget->SendMessage(m); delete m; break; } default: - inherited::MessageReceived (message); + inherited::MessageReceived(message); break; } } \ No newline at end of file diff --git a/source/XpalWindow.h b/source/XpalWindow.h index d44d3c2..6033271 100644 --- a/source/XpalWindow.h +++ b/source/XpalWindow.h @@ -8,19 +8,19 @@ class XpalWindow : public BWindow { -public: - XpalWindow (BRect rect, const char *name, BMessenger *target); -virtual ~XpalWindow (); -virtual void MessageReceived (BMessage *message); -//int32 Go (); + public: + XpalWindow(BRect rect, const char* name, BMessenger* target); + virtual ~XpalWindow(); + virtual void MessageReceived(BMessage* message); + // int32 Go (); -private: -typedef BWindow inherited; -int fNum; -BMessenger *fTarget; -BCheckBox *fClobberCB; -int32 fStatus; -bool fClobber; + private: + typedef BWindow inherited; + int fNum; + BMessenger* fTarget; + BCheckBox* fClobberCB; + int32 fStatus; + bool fClobber; }; #endif diff --git a/source/add-ons/AutoContrast/AutoContrast.cpp b/source/add-ons/AutoContrast/AutoContrast.cpp index 24ff94b..0663e41 100644 --- a/source/add-ons/AutoContrast/AutoContrast.cpp +++ b/source/add-ons/AutoContrast/AutoContrast.cpp @@ -5,51 +5,56 @@ #include "AddOnSupport.h" #include -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "AutoContrast"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 2001 ∑ Sum Software"); - strcpy (info->description, "Optimizes image contrast"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 0; - info->release = 1; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "AutoContrast"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 2001 ∑ Sum Software"); + strcpy(info->description, "Optimizes image contrast"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 0; + info->release = 1; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */ +) { status_t error = ADDON_OK; BRect bounds = inLayer->Bounds(); if (*outLayer == NULL && mode == M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection! + *outSelection = new Selection(*inSelection); + else // No Selection! return (0); } if (*outLayer) @@ -58,171 +63,146 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits() - 1; - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits() - 1; + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - float delta = 50.0/h; // For the Status Bar. Two passes -> 50 instead of 100. - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits() - 1; + float delta = 50.0 / h; // For the Status Bar. Two passes -> 50 instead of 100. + + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits() - 1; // first, find the current max and min values float minC = 255.0; float maxC = 0.0; - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { - if (!inSelection || *(++mapbits)) - { + for (uint32 x = 0; x < w; x++) { + if (!inSelection || *(++mapbits)) { bgra_pixel pixel = *(++sbits); - int cval = int (0.213*RED(pixel) + 0.715*GREEN(pixel) + 0.072*BLUE(pixel) + .5); - if (cval < minC) minC = cval; - if (cval > maxC) maxC = cval; - } - else + int cval = + int(0.213 * RED(pixel) + 0.715 * GREEN(pixel) + 0.072 * BLUE(pixel) + .5); + if (cval < minC) + minC = cval; + if (cval > maxC) + maxC = cval; + } else ++sbits; } mapbits += mdiff; } -// printf ("min = %f, max = %f\n", minC, maxC); + // printf ("min = %f, max = %f\n", minC, maxC); // now, adjust contrast accordingly - if (maxC > minC) - { - float factor = 255.0/(maxC - minC); - sbits = (bgra_pixel *) inLayer->Bits() - 1; - mapbits = inSelection ? (grey_pixel *) inSelection->Bits() - 1 : 0; - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits() - 1; - - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + if (maxC > minC) { + float factor = 255.0 / (maxC - minC); + sbits = (bgra_pixel*)inLayer->Bits() - 1; + mapbits = inSelection ? (grey_pixel*)inSelection->Bits() - 1 : 0; + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits() - 1; + + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { int mapx = 255; - if (!inSelection || (mapx = *(++mapbits))) - { + if (!inSelection || (mapx = *(++mapbits))) { bgra_pixel pixel = *(++sbits); - bgra_pixel newpix = PIXEL (clipchar (factor*(RED(pixel) - minC)), - clipchar (factor*(GREEN(pixel) - minC)), - clipchar (factor*(BLUE(pixel) - minC)), - ALPHA(pixel)); - *(++dbits) = weighted_average (newpix, mapx, pixel, 255 - mapx); - } - else + bgra_pixel newpix = PIXEL( + clipchar(factor * (RED(pixel) - minC)), + clipchar(factor * (GREEN(pixel) - minC)), + clipchar(factor * (BLUE(pixel) - minC)), ALPHA(pixel) + ); + *(++dbits) = weighted_average(newpix, mapx, pixel, 255 - mapx); + } else *(++dbits) = *(++sbits); } mapbits += mdiff; } - } - else - { - sbits = (bgra_pixel *) inLayer->Bits(); - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits(); - memcpy (dbits, sbits, w*h*4); + } else { + sbits = (bgra_pixel*)inLayer->Bits(); + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits(); + memcpy(dbits, sbits, w * h * 4); } break; } - case M_SELECT: - { + case M_SELECT: { if (!inSelection) *outSelection = NULL; - else - { + else { // first, find the current max and min values float minC = 255.0; float maxC = 0.0; - grey_pixel *sbits = mapbits; - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + grey_pixel* sbits = mapbits; + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { grey_pixel pixel = *(++sbits); - if (pixel > maxC) maxC = pixel; - if (pixel < minC) minC = pixel; + if (pixel > maxC) + maxC = pixel; + if (pixel < minC) + minC = pixel; } sbits += mdiff; } - + // now, adjust contrast accordingly - if (maxC > minC) - { - float factor = 255.0/(maxC - minC); - + if (maxC > minC) { + float factor = 255.0 / (maxC - minC); + sbits = mapbits; - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits() - 1; - - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits() - 1; + + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { grey_pixel pixel = *(++sbits); - *(++dbits) = clipchar (factor*(pixel - minC)); + *(++dbits) = clipchar(factor * (pixel - minC)); } sbits += mdiff; dbits += mdiff; } - } - else - { + } else { sbits = mapbits; - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits(); - memcpy (dbits, sbits, w*h); + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits(); + memcpy(dbits, sbits, w * h); } } break; } default: - fprintf (stderr, "AutoContrast: Unknown mode\n"); + fprintf(stderr, "AutoContrast: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -230,7 +210,7 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); - + if (final) addon_done(); diff --git a/source/add-ons/Blur/Blur.cpp b/source/add-ons/Blur/Blur.cpp index 10d62a3..2668830 100644 --- a/source/add-ons/Blur/Blur.cpp +++ b/source/add-ons/Blur/Blur.cpp @@ -5,56 +5,61 @@ #include "AddOnSupport.h" #include -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Blur"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1999-2001 ∑ Sum Software"); - strcpy (info->description, "Applies a 3x3 blur kernel convolution"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 1; - info->release = 3; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "Blur"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1999-2001 ∑ Sum Software"); + strcpy(info->description, "Applies a 3x3 blur kernel convolution"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 1; + info->release = 3; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { // Blur hasn't got any UI return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */ +) { status_t error = ADDON_OK; BRect bounds = inLayer->Bounds(); -// printf ("Bounds: "); -// bounds.PrintToStream(); -// printf ("Frame: "); -// frame->PrintToStream(); + // printf ("Bounds: "); + // bounds.PrintToStream(); + // printf ("Frame: "); + // frame->PrintToStream(); if (*outLayer == NULL && mode == M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to blur! + *outSelection = new Selection(*inSelection); + else // No Selection to blur! return (0); } if (*outLayer) @@ -63,132 +68,122 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits(); - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits(); + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w + 2; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits(); - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits(); + float delta = 100.0 / h; // For the Status Bar. + + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits(); + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits(); // Note: We don't update the status bar during the corners and edges. // The time this takes is insignificant anyway. - + // First do the corners: // Left top if (!inSelection || *mapbits) - *dbits = average4 (*sbits, *(sbits + 1), - *(sbits + w), *(sbits + w + 1)); + *dbits = average4(*sbits, *(sbits + 1), *(sbits + w), *(sbits + w + 1)); else *dbits = *sbits; // Right top if (!inSelection || *(mapbits + w - 1)) - *(dbits + w - 1) = average4 (*(sbits + w - 2), *(sbits + w - 1), - *(sbits + 2*w - 2), *(sbits + 2*w - 1)); + *(dbits + w - 1) = average4( + *(sbits + w - 2), *(sbits + w - 1), *(sbits + 2 * w - 2), *(sbits + 2 * w - 1) + ); else *(dbits + w - 1) = *(sbits + w - 1); // Left bottom - if (!inSelection || *(mapbits + (h - 1)*mbpr)) - *(dbits + (h - 1)*w) = average4 (*(sbits + (h - 2)*w), *(sbits + (h - 2)*w + 1), - *(sbits + (h - 1)*w), *(sbits + (h - 1)*w)); + if (!inSelection || *(mapbits + (h - 1) * mbpr)) + *(dbits + (h - 1) * w) = average4( + *(sbits + (h - 2) * w), *(sbits + (h - 2) * w + 1), *(sbits + (h - 1) * w), + *(sbits + (h - 1) * w) + ); else - *(dbits + (h - 1)*w) = *(sbits + (h - 1)*w); + *(dbits + (h - 1) * w) = *(sbits + (h - 1) * w); // Right bottom - if (!inSelection || *(mapbits + (h - 1)*mbpr + w - 1)) - *(dbits + h*w - 1) = average4 (*(sbits + (h - 1)*w - 2), *(sbits + (h - 1)*w - 1), - *(sbits + h*w - 2), *(sbits + h*w - 1)); + if (!inSelection || *(mapbits + (h - 1) * mbpr + w - 1)) + *(dbits + h * w - 1) = average4( + *(sbits + (h - 1) * w - 2), *(sbits + (h - 1) * w - 1), *(sbits + h * w - 2), + *(sbits + h * w - 1) + ); else - *(dbits + h*w - 1) = *(sbits + h*w - 1); - + *(dbits + h * w - 1) = *(sbits + h * w - 1); + // Now do the edges: // Top/bottom edges - for (uint32 x = 1; x < w - 1; x++) - { - if (!inSelection || *(mapbits + x)) - { - bgra_pixel *sbitsx = sbits + x; - bgra_pixel *sbitsxl = sbitsx + w; - *(dbits + x) = average6 (*(sbitsx - 1), *sbitsx, *(sbitsx + 1), - *(sbitsxl - 1), *sbitsxl, *(sbitsxl + 1)); - } - else + for (uint32 x = 1; x < w - 1; x++) { + if (!inSelection || *(mapbits + x)) { + bgra_pixel* sbitsx = sbits + x; + bgra_pixel* sbitsxl = sbitsx + w; + *(dbits + x) = average6( + *(sbitsx - 1), *sbitsx, *(sbitsx + 1), *(sbitsxl - 1), *sbitsxl, *(sbitsxl + 1) + ); + } else *(dbits + x) = *(sbits + x); - - if (!inSelection || *(mapbits + (h - 1)*mbpr + x)) - { - bgra_pixel *sbitsx = sbits + (h - 1)*w + x; - bgra_pixel *sbitsxu = sbitsx - w; - *(dbits + (h - 1)*w + x) = average6 (*(sbitsx - 1), *sbitsx, *(sbitsx + 1), - *(sbitsxu - 1), *sbitsxu, *(sbitsxu + 1)); - } - else - *(dbits + (h - 1)*w + x) = *(sbits + (h - 1)*w + x); + + if (!inSelection || *(mapbits + (h - 1) * mbpr + x)) { + bgra_pixel* sbitsx = sbits + (h - 1) * w + x; + bgra_pixel* sbitsxu = sbitsx - w; + *(dbits + (h - 1) * w + x) = average6( + *(sbitsx - 1), *sbitsx, *(sbitsx + 1), *(sbitsxu - 1), *sbitsxu, *(sbitsxu + 1) + ); + } else + *(dbits + (h - 1) * w + x) = *(sbits + (h - 1) * w + x); } - + // Left/right edges: - for (uint32 y = 1; y < h - 1; y++) - { - if (!inSelection || *(mapbits + y*mbpr)) - { - bgra_pixel *sbitsy = sbits + y*w; - bgra_pixel *sbitsyr = sbitsy + 1; - *(dbits + y*w) = average6 (*(sbitsy - w), *sbitsy, *(sbitsy + w), - *(sbitsyr - w), *sbitsyr, *(sbitsyr + w)); - } - else - *(dbits + y*w) = *(sbits + y*w); - - if (!inSelection || *(mapbits + y*mbpr + w - 1)) - { - bgra_pixel *sbitsy = sbits + (y + 1)*w - 1; - bgra_pixel *sbitsyl = sbitsy - 1; - *(dbits + (y + 1)*w - 1) = average6 (*(sbitsy - w), *sbitsy, *(sbitsy + w), - *(sbitsyl - w), *sbitsyl, *(sbitsyl + w)); - } - else - *(dbits + (y + 1)*w - 1) = *(sbits + (y + 1)*w - 1); + for (uint32 y = 1; y < h - 1; y++) { + if (!inSelection || *(mapbits + y * mbpr)) { + bgra_pixel* sbitsy = sbits + y * w; + bgra_pixel* sbitsyr = sbitsy + 1; + *(dbits + y * w) = average6( + *(sbitsy - w), *sbitsy, *(sbitsy + w), *(sbitsyr - w), *sbitsyr, *(sbitsyr + w) + ); + } else + *(dbits + y * w) = *(sbits + y * w); + + if (!inSelection || *(mapbits + y * mbpr + w - 1)) { + bgra_pixel* sbitsy = sbits + (y + 1) * w - 1; + bgra_pixel* sbitsyl = sbitsy - 1; + *(dbits + (y + 1) * w - 1) = average6( + *(sbitsy - w), *sbitsy, *(sbitsy + w), *(sbitsyl - w), *sbitsyl, *(sbitsyl + w) + ); + } else + *(dbits + (y + 1) * w - 1) = *(sbits + (y + 1) * w - 1); } - + // Finally, the bulk of the canvas. dbits += w; sbits += w; mapbits += mbpr; - for (uint32 y = 1; y < h - 1; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + for (uint32 y = 1; y < h - 1; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 1; x < w - 1; x++) - { - if (!inSelection || *(++mapbits)) - { - bgra_pixel *sbitsu = ++sbits - w; - bgra_pixel *sbitsl = sbits + w; - *(++dbits) = average9 (*(sbitsu - 1), *sbitsu, *(sbitsu + 1), - *(sbits - 1), *sbits, *(sbits + 1), - *(sbitsl - 1), *sbitsl, *(sbitsl + 1)); - } - else + for (uint32 x = 1; x < w - 1; x++) { + if (!inSelection || *(++mapbits)) { + bgra_pixel* sbitsu = ++sbits - w; + bgra_pixel* sbitsl = sbits + w; + *(++dbits) = average9( + *(sbitsu - 1), *sbitsu, *(sbitsu + 1), *(sbits - 1), *sbits, *(sbits + 1), + *(sbitsl - 1), *sbitsl, *(sbitsl + 1) + ); + } else *(++dbits) = *(++sbits); } dbits += 2; @@ -197,79 +192,86 @@ status_t process (Layer *inLayer, Selection *inSelection, } break; } - case M_SELECT: - { + case M_SELECT: { if (!inSelection) *outSelection = NULL; - else - { - grey_pixel *sbits = mapbits; - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits(); + else { + grey_pixel* sbits = mapbits; + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits(); // First do the corners: // Left top - *dbits = (*sbits + *(sbits + 1) + *(sbits + mbpr) + *(sbits + mbpr + 1))/4; + *dbits = (*sbits + *(sbits + 1) + *(sbits + mbpr) + *(sbits + mbpr + 1)) / 4; // Right top - *(dbits + mbpr - 1) = (*(sbits + mbpr - 2) + *(sbits + mbpr - 1) + *(sbits + 2*mbpr - 2) + *(sbits + 2*mbpr - 1))/4; + *(dbits + mbpr - 1) = (*(sbits + mbpr - 2) + *(sbits + mbpr - 1) + + *(sbits + 2 * mbpr - 2) + *(sbits + 2 * mbpr - 1)) / + 4; // Left bottom - *(dbits + (h - 1)*mbpr) = (*(sbits + (h - 2)*mbpr) + *(sbits + (h - 2)*mbpr + 1) + *(sbits + (h - 1)*mbpr) + *(sbits + (h - 1)*mbpr))/4; + *(dbits + (h - 1) * mbpr) = (*(sbits + (h - 2) * mbpr) + *(sbits + (h - 2) * mbpr + 1) + + *(sbits + (h - 1) * mbpr) + *(sbits + (h - 1) * mbpr)) / + 4; // Right bottom - *(dbits + h*mbpr - 1) = (*(sbits + (h - 1)*mbpr - 2) + *(sbits + (h - 1)*mbpr - 1) + *(sbits + h*mbpr - 2) + *(sbits + h*mbpr - 1))/4; - + *(dbits + h * mbpr - 1) = + (*(sbits + (h - 1) * mbpr - 2) + *(sbits + (h - 1) * mbpr - 1) + + *(sbits + h * mbpr - 2) + *(sbits + h * mbpr - 1)) / + 4; + // Now do the edges: // Top/bottom edges - for (uint32 x = 1; x < w - 1; x++) - { - grey_pixel *sbitsx = sbits + x; - grey_pixel *sbitsxl = sbitsx + mbpr; - *(dbits + x) = (*(sbitsx - 1) + *sbitsx + *(sbitsx + 1) + *(sbitsxl - 1) + *sbitsxl + *(sbitsxl + 1))/6; - - sbitsx = sbits + (h - 1)*mbpr + x; - grey_pixel *sbitsxu = sbitsx - mbpr; - *(dbits + (h - 1)*mbpr + x) = (*(sbitsx - 1) + *sbitsx + *(sbitsx + 1) + *(sbitsxu - 1) + *sbitsxu + *(sbitsxu + 1))/6; + for (uint32 x = 1; x < w - 1; x++) { + grey_pixel* sbitsx = sbits + x; + grey_pixel* sbitsxl = sbitsx + mbpr; + *(dbits + x) = (*(sbitsx - 1) + *sbitsx + *(sbitsx + 1) + *(sbitsxl - 1) + + *sbitsxl + *(sbitsxl + 1)) / + 6; + + sbitsx = sbits + (h - 1) * mbpr + x; + grey_pixel* sbitsxu = sbitsx - mbpr; + *(dbits + (h - 1) * mbpr + x) = (*(sbitsx - 1) + *sbitsx + *(sbitsx + 1) + + *(sbitsxu - 1) + *sbitsxu + *(sbitsxu + 1)) / + 6; } - + // Left/right edges: - for (uint32 y = 1; y < h - 1; y++) - { - grey_pixel *sbitsy = sbits + y*mbpr; - grey_pixel *sbitsyr = sbitsy + 1; - *(dbits + y*mbpr) = (*(sbitsy - mbpr) + *sbitsy + *(sbitsy + mbpr) + *(sbitsyr - mbpr) + *sbitsyr + *(sbitsyr + mbpr))/6; - - sbitsy = sbits + (y + 1)*mbpr - 1; - grey_pixel *sbitsyl = sbitsy - 1; - *(dbits + (y + 1)*mbpr - 1) = (*(sbitsy - mbpr) + *sbitsy + *(sbitsy + mbpr) + *(sbitsyl - mbpr) + *sbitsyl + *(sbitsyl + mbpr))/6; + for (uint32 y = 1; y < h - 1; y++) { + grey_pixel* sbitsy = sbits + y * mbpr; + grey_pixel* sbitsyr = sbitsy + 1; + *(dbits + y * mbpr) = (*(sbitsy - mbpr) + *sbitsy + *(sbitsy + mbpr) + + *(sbitsyr - mbpr) + *sbitsyr + *(sbitsyr + mbpr)) / + 6; + + sbitsy = sbits + (y + 1) * mbpr - 1; + grey_pixel* sbitsyl = sbitsy - 1; + *(dbits + (y + 1) * mbpr - 1) = (*(sbitsy - mbpr) + *sbitsy + *(sbitsy + mbpr) + + *(sbitsyl - mbpr) + *sbitsyl + *(sbitsyl + mbpr)) / + 6; } - + // Finally, the bulk of the canvas. - dbits += mbpr; // We've already done the top row + dbits += mbpr; // We've already done the top row sbits += mbpr; - for (uint32 y = 1; y < h - 1; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + for (uint32 y = 1; y < h - 1; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - sbits = (grey_pixel *) inSelection->Bits() + y*mbpr; - dbits = (grey_pixel *) (*outSelection)->Bits() + y*mbpr; - for (uint32 x = 1; x < w - 1; x++) - { - grey_pixel *sbitsu = ++sbits - mbpr; - grey_pixel *sbitsl = sbits + mbpr; - *(++dbits) = (*(sbitsu - 1) + *sbitsu + *(sbitsu + 1) + - *(sbits - 1) + *sbits + *(sbits + 1) + - *(sbitsl - 1) + *sbitsl + *(sbitsl + 1))/9; + sbits = (grey_pixel*)inSelection->Bits() + y * mbpr; + dbits = (grey_pixel*)(*outSelection)->Bits() + y * mbpr; + for (uint32 x = 1; x < w - 1; x++) { + grey_pixel* sbitsu = ++sbits - mbpr; + grey_pixel* sbitsl = sbits + mbpr; + *(++dbits) = (*(sbitsu - 1) + *sbitsu + *(sbitsu + 1) + *(sbits - 1) + *sbits + + *(sbits + 1) + *(sbitsl - 1) + *sbitsl + *(sbitsl + 1)) / + 9; } } } break; } default: - fprintf (stderr, "Blur: Unknown mode\n"); + fprintf(stderr, "Blur: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -277,7 +279,7 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); - + if (final) addon_done(); diff --git a/source/add-ons/Brightness/Brightness.cpp b/source/add-ons/Brightness/Brightness.cpp index 81d0398..d5990c1 100644 --- a/source/add-ons/Brightness/Brightness.cpp +++ b/source/add-ons/Brightness/Brightness.cpp @@ -12,92 +12,100 @@ float gContrast = 0; class BCView : public BView { -public: - BCView (BRect rect); -virtual ~BCView () {} -virtual void MessageReceived (BMessage *msg); + public: + BCView(BRect rect); -private: -typedef BView inherited; + virtual ~BCView() {} + + virtual void MessageReceived(BMessage* msg); + + private: + typedef BView inherited; }; -BCView::BCView (BRect rect) -: BView (rect, "brightness/contrast", B_FOLLOW_ALL, B_WILL_DRAW) +BCView::BCView(BRect rect) : BView(rect, "brightness/contrast", B_FOLLOW_ALL, B_WILL_DRAW) { - gBrightness = 0; - gContrast = 0; - ResizeTo (Bounds().Width(), 50); - Slider *bSlid = new Slider (BRect (8, 8, 180, 24), 70, "Brightness", -100, 100, 1, new BMessage ('gblB')); - Slider *cSlid = new Slider (BRect (8, 28, 180, 44), 70, "Contrast", -100, 100, 1, new BMessage ('gblC')); - AddChild (bSlid); - AddChild (cSlid); - bSlid->SetValue (gBrightness); - cSlid->SetValue (gContrast); + gBrightness = 0; + gContrast = 0; + ResizeTo(Bounds().Width(), 50); + Slider* bSlid = + new Slider(BRect(8, 8, 180, 24), 70, "Brightness", -100, 100, 1, new BMessage('gblB')); + Slider* cSlid = + new Slider(BRect(8, 28, 180, 44), 70, "Contrast", -100, 100, 1, new BMessage('gblC')); + AddChild(bSlid); + AddChild(cSlid); + bSlid->SetValue(gBrightness); + cSlid->SetValue(gContrast); } -void BCView::MessageReceived (BMessage *msg) +void +BCView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'gblB': - gBrightness = msg->FindFloat ("value"); + gBrightness = msg->FindFloat("value"); break; case 'gblC': - gContrast = msg->FindFloat ("value"); + gContrast = msg->FindFloat("value"); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); return; } addon_preview(); } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Brightness/Contrast"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 2001 ∑ Sum Software"); - strcpy (info->description, "Change brightness and contrast of an image"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 0; - info->release = 2; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "Brightness/Contrast"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 2001 ∑ Sum Software"); + strcpy(info->description, "Change brightness and contrast of an image"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 0; + info->release = 2; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new BCView (rect); + *view = new BCView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */ +) { status_t error = ADDON_OK; BRect bounds = inLayer->Bounds(); if (*outLayer == NULL && mode == M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection! + *outSelection = new Selection(*inSelection); + else // No Selection! return (0); } if (*outLayer) @@ -106,84 +114,70 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits() - 1; - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits() - 1; + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. - - int brightness = int (gBrightness*255/100 + 0.5); - float contrast = (gContrast + 100.0)/100; - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits() - 1; - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits() - 1; - - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + float delta = 100.0 / h; // For the Status Bar. + + int brightness = int(gBrightness * 255 / 100 + 0.5); + float contrast = (gContrast + 100.0) / 100; + + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits() - 1; + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits() - 1; + + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { int map = 255; - if (!inSelection || (map = *(++mapbits))) - { + if (!inSelection || (map = *(++mapbits))) { bgra_pixel pixel = *(++sbits); - bgra_pixel newpix = PIXEL (clipchar (brightness + contrast*RED(pixel)), - clipchar (brightness + contrast*GREEN(pixel)), - clipchar (brightness + contrast*BLUE(pixel)), - ALPHA(pixel)); - *(++dbits) = weighted_average (newpix, map, pixel, 255 - map); - } - else + bgra_pixel newpix = PIXEL( + clipchar(brightness + contrast * RED(pixel)), + clipchar(brightness + contrast * GREEN(pixel)), + clipchar(brightness + contrast * BLUE(pixel)), ALPHA(pixel) + ); + *(++dbits) = weighted_average(newpix, map, pixel, 255 - map); + } else *(++dbits) = *(++sbits); } mapbits += mdiff; } break; } - case M_SELECT: - { + case M_SELECT: { if (!inSelection) *outSelection = NULL; - else - { - grey_pixel *sbits = mapbits; - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits() - 1; - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + else { + grey_pixel* sbits = mapbits; + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits() - 1; + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { grey_pixel pixel = *(++sbits); - *(++dbits) = clipchar (brightness + contrast*pixel); + *(++dbits) = clipchar(brightness + contrast * pixel); } sbits += mdiff; dbits += mdiff; @@ -192,7 +186,7 @@ status_t process (Layer *inLayer, Selection *inSelection, break; } default: - fprintf (stderr, "Brightness: Unknown mode\n"); + fprintf(stderr, "Brightness: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -200,7 +194,7 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); - + if (final) addon_done(); diff --git a/source/add-ons/BumpMap/BumpMap.cpp b/source/add-ons/BumpMap/BumpMap.cpp index fc3f8fd..3ccefd9 100644 --- a/source/add-ons/BumpMap/BumpMap.cpp +++ b/source/add-ons/BumpMap/BumpMap.cpp @@ -8,9 +8,9 @@ #include #include -#define WHITE 0 -#define FOREGROUND 1 -#define BACKGROUND 2 +#define WHITE 0 +#define FOREGROUND 1 +#define BACKGROUND 2 typedef struct { @@ -19,31 +19,39 @@ typedef struct float z; } v3; -inline v3 cross (const v3 &a, const v3 &b); -inline v3 prod (const float a, const v3 &v); -inline v3 minus (const v3 &a, const v3 &b); -inline float dot (const v3 &a, const v3 &b); -inline void normalize (v3 *a); +inline v3 +cross(const v3& a, const v3& b); +inline v3 +prod(const float a, const v3& v); +inline v3 +minus(const v3& a, const v3& b); +inline float +dot(const v3& a, const v3& b); +inline void +normalize(v3* a); -v3 cross (const v3 &a, const v3 &b) +v3 +cross(const v3& a, const v3& b) { v3 res; - res.x = a.y*b.z - a.z*b.y; - res.y = a.x*b.z - a.z*b.x; - res.z = a.x*b.y - a.y*b.x; + res.x = a.y * b.z - a.z * b.y; + res.y = a.x * b.z - a.z * b.x; + res.z = a.x * b.y - a.y * b.x; return res; } -v3 prod (const float a, const v3 &v) +v3 +prod(const float a, const v3& v) { v3 res; - res.x = a*v.x; - res.y = a*v.y; - res.z = a*v.z; + res.x = a * v.x; + res.y = a * v.y; + res.z = a * v.z; return res; } -v3 minus (const v3 &a, const v3 &b) +v3 +minus(const v3& a, const v3& b) { v3 res; res.x = a.x - b.x; @@ -52,88 +60,97 @@ v3 minus (const v3 &a, const v3 &b) return res; } -float dot (const v3 &a, const v3 &b) +float +dot(const v3& a, const v3& b) { - return (a.x*b.x + a.y*b.y + a.z*b.z); + return (a.x * b.x + a.y * b.y + a.z * b.z); } -void normalize (v3 *a) +void +normalize(v3* a) { - float r = sqrt (a->x*a->x + a->y*a->y + a->z*a->z); - if (r) - { + float r = sqrt(a->x * a->x + a->y * a->y + a->z * a->z); + if (r) { a->x /= r; a->y /= r; a->z /= r; } } -float gElevation; -float gAngle; -float gSpecular; -float gReflection; -float gTranslucent; -int gColorType; +float gElevation; +float gAngle; +float gSpecular; +float gReflection; +float gTranslucent; +int gColorType; class BumpView : public BView { -public: - BumpView (BRect rect); -virtual ~BumpView () {} -virtual void MessageReceived (BMessage *msg); + public: + BumpView(BRect rect); -private: + virtual ~BumpView() {} + + virtual void MessageReceived(BMessage* msg); + + private: }; -BumpView::BumpView (BRect rect) -: BView (rect, "bumpview", B_FOLLOW_ALL, B_WILL_DRAW) +BumpView::BumpView(BRect rect) : BView(rect, "bumpview", B_FOLLOW_ALL, B_WILL_DRAW) { - ResizeTo (188, 190); - Slider *eSlid = new Slider (BRect (8, 8, 180, 24), 64, "Elevation", 0, 90, 1, new BMessage ('bmpE')); - Slider *aSlid = new Slider (BRect (8, 28, 180, 44), 64, "Angle", 0, 360, 1, new BMessage ('bmpA')); - Slider *sSlid = new Slider (BRect (8, 48, 180, 64), 64, "Specular", 0, 100, 1, new BMessage ('bmpS')); - Slider *rSlid = new Slider (BRect (8, 68, 180, 84), 64, "Reflection", 0, 100, 1, new BMessage ('bmpR')); - Slider *tSlid = new Slider (BRect (8, 88, 180, 104), 64, "Translucent", 0, 100, 1, new BMessage ('bmpT')); - AddChild (aSlid); - AddChild (eSlid); - AddChild (sSlid); - AddChild (rSlid); - AddChild (tSlid); - aSlid->SetValue (135); - eSlid->SetValue (45); - sSlid->SetValue (0); - rSlid->SetValue (0); - tSlid->SetValue (0); - BBox *light = new BBox (BRect (8, 110, 180, 188), "light"); - light->SetLabel ("Light Color"); - AddChild (light); - BRadioButton *rbW = new BRadioButton (BRect (6, 18, 170, 34), "rbW", "White", new BMessage ('bmlW')); - BRadioButton *rbF = new BRadioButton (BRect (6, 36, 170, 52), "rbF", "Foreground Color", new BMessage ('bmlF')); - BRadioButton *rbB = new BRadioButton (BRect (6, 54, 170, 70), "rbB", "Background Color", new BMessage ('bmlB')); - light->AddChild (rbW); - light->AddChild (rbF); - light->AddChild (rbB); - rbW->SetValue (true); + ResizeTo(188, 190); + Slider* eSlid = + new Slider(BRect(8, 8, 180, 24), 64, "Elevation", 0, 90, 1, new BMessage('bmpE')); + Slider* aSlid = new Slider(BRect(8, 28, 180, 44), 64, "Angle", 0, 360, 1, new BMessage('bmpA')); + Slider* sSlid = + new Slider(BRect(8, 48, 180, 64), 64, "Specular", 0, 100, 1, new BMessage('bmpS')); + Slider* rSlid = + new Slider(BRect(8, 68, 180, 84), 64, "Reflection", 0, 100, 1, new BMessage('bmpR')); + Slider* tSlid = + new Slider(BRect(8, 88, 180, 104), 64, "Translucent", 0, 100, 1, new BMessage('bmpT')); + AddChild(aSlid); + AddChild(eSlid); + AddChild(sSlid); + AddChild(rSlid); + AddChild(tSlid); + aSlid->SetValue(135); + eSlid->SetValue(45); + sSlid->SetValue(0); + rSlid->SetValue(0); + tSlid->SetValue(0); + BBox* light = new BBox(BRect(8, 110, 180, 188), "light"); + light->SetLabel("Light Color"); + AddChild(light); + BRadioButton* rbW = + new BRadioButton(BRect(6, 18, 170, 34), "rbW", "White", new BMessage('bmlW')); + BRadioButton* rbF = + new BRadioButton(BRect(6, 36, 170, 52), "rbF", "Foreground Color", new BMessage('bmlF')); + BRadioButton* rbB = + new BRadioButton(BRect(6, 54, 170, 70), "rbB", "Background Color", new BMessage('bmlB')); + light->AddChild(rbW); + light->AddChild(rbF); + light->AddChild(rbB); + rbW->SetValue(true); } -void BumpView::MessageReceived (BMessage *msg) +void +BumpView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'bmpE': - gElevation = msg->FindFloat ("value"); + gElevation = msg->FindFloat("value"); break; case 'bmpA': - gAngle = msg->FindFloat ("value"); + gAngle = msg->FindFloat("value"); break; case 'bmpS': - gSpecular = msg->FindFloat ("value"); + gSpecular = msg->FindFloat("value"); break; case 'bmpR': - gReflection = msg->FindFloat ("value"); + gReflection = msg->FindFloat("value"); break; case 'bmpT': - gTranslucent = msg->FindFloat ("value"); + gTranslucent = msg->FindFloat("value"); break; case 'bmlW': gColorType = WHITE; @@ -145,192 +162,193 @@ void BumpView::MessageReceived (BMessage *msg) gColorType = BACKGROUND; break; default: - BView::MessageReceived (msg); + BView::MessageReceived(msg); return; } addon_preview(); } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "BumpMap"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 2000-2001 ∑ Sum Software"); - strcpy (info->description, "Uses the selection as a bump map for lighting"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 0; - info->release = 2; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = LAYER_ONLY; + strcpy(info->name, "BumpMap"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 2000-2001 ∑ Sum Software"); + strcpy(info->description, "Uses the selection as a bump map for lighting"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 0; + info->release = 2; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = LAYER_ONLY; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new BumpView (rect); + *view = new BumpView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); -// printf ("Bounds: "); -// bounds.PrintToStream(); -// printf ("Frame: "); -// frame->PrintToStream(); + // printf ("Bounds: "); + // bounds.PrintToStream(); + // printf ("Frame: "); + // frame->PrintToStream(); if (!inSelection || mode == M_SELECT) // we don't bump map the bump map itself :-) return (0); - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = new Layer (*inLayer); - + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = new Layer(*inLayer); + if (*outLayer) (*outLayer)->Lock(); if (*outSelection) (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; -// uint32 dbpr = (*outLayer)->BytesPerRow()/4; -// uint32 sbpr = inLayer->BytesPerRow()/4; + // uint32 dbpr = (*outLayer)->BytesPerRow()/4; + // uint32 sbpr = inLayer->BytesPerRow()/4; - grey_pixel *mapbits = (grey_pixel *) inSelection->Bits(); - uint32 mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = (grey_pixel*)inSelection->Bits(); + uint32 mbpr = inSelection->BytesPerRow(); uint32 mdiff = mbpr - w + 2; - float angle = gAngle*M_PI/180; - float cangle = cos (angle); - float sangle = sin (angle); - - float elevation = gElevation*M_PI/180; -// float celevation = cos (elevation); - float selevation = sin (elevation); + float angle = gAngle * M_PI / 180; + float cangle = cos(angle); + float sangle = sin(angle); + + float elevation = gElevation * M_PI / 180; + // float celevation = cos (elevation); + float selevation = sin(elevation); rgb_color color; - switch (gColorType) - { - case WHITE: - color.red = 255; - color.green = 255; - color.blue = 255; - break; - - case FOREGROUND: - color = highcolor(); - break; - - case BACKGROUND: - color = lowcolor(); - break; + switch (gColorType) { + case WHITE: + color.red = 255; + color.green = 255; + color.blue = 255; + break; + + case FOREGROUND: + color = highcolor(); + break; + + case BACKGROUND: + color = lowcolor(); + break; } - + v3 light; light.x = cangle; light.y = sangle; light.z = selevation; - normalize (&light); - + normalize(&light); + double specular = gSpecular; - double reflection = gReflection/25; - double translucent = gTranslucent/25; + double reflection = gReflection / 25; + double translucent = gTranslucent / 25; if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits(); - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits(); + float delta = 100.0 / h; // For the Status Bar. + + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits(); + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits(); // (we skip the edges); mapbits += mbpr; mapbits++; for (uint32 x = 0; x < w; x++) *dbits++ = *sbits++; - + dbits++; sbits++; - for (uint32 y = 1; y < h - 1; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + for (uint32 y = 1; y < h - 1; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 1; x < w - 1; x++) - { + for (uint32 x = 1; x < w - 1; x++) { // Determine the normal vector on the bump map float b11, b12, b13, b21, b22, b23, b31, b32, b33; - b11 = float (*(mapbits - mbpr - 1))/255; - b12 = float (*(mapbits - mbpr))/255; - b13 = float (*(mapbits - mbpr + 1))/255; - b21 = float (*(mapbits - 1))/255; - b22 = float (*(mapbits))/255; - b23 = float (*(mapbits + 1))/255; - b31 = float (*(mapbits + mbpr - 1))/255; - b32 = float (*(mapbits + mbpr))/255; - b33 = float (*(mapbits + mbpr + 1))/255; + b11 = float(*(mapbits - mbpr - 1)) / 255; + b12 = float(*(mapbits - mbpr)) / 255; + b13 = float(*(mapbits - mbpr + 1)) / 255; + b21 = float(*(mapbits - 1)) / 255; + b22 = float(*(mapbits)) / 255; + b23 = float(*(mapbits + 1)) / 255; + b31 = float(*(mapbits + mbpr - 1)) / 255; + b32 = float(*(mapbits + mbpr)) / 255; + b33 = float(*(mapbits + mbpr + 1)) / 255; v3 a, b, z; a.x = 1; a.y = 0; - a.z = (((b13 + b33)/2 + b23) - ((b11 + b31)/2 + b21))/2; + a.z = (((b13 + b33) / 2 + b23) - ((b11 + b31) / 2 + b21)) / 2; b.x = 0; b.y = 1; - b.z = (((b31 + b33)/2 + b32) - ((b11 + b13)/2 + b12))/2; + b.z = (((b31 + b33) / 2 + b32) - ((b11 + b13) / 2 + b12)) / 2; z.x = 0; z.y = 0; z.z = 1; - v3 n = cross (a, b); - normalize (&n); - float amount = dot (light, n); + v3 n = cross(a, b); + normalize(&n); + float amount = dot(light, n); // calculate reflection vector - v3 r = minus (prod (2*dot (n, light), n), light); - double spec = dot (r, z); - double aspec = fabs (spec); - double samount_tran = (specular == 0) ? 0 : pow (aspec, (101 - specular)/4)*translucent; - double samount_spec = (specular == 0 || spec < 0) ? 0 : pow (spec, (101 - specular)/4)*reflection; + v3 r = minus(prod(2 * dot(n, light), n), light); + double spec = dot(r, z); + double aspec = fabs(spec); + double samount_tran = + (specular == 0) ? 0 : pow(aspec, (101 - specular) / 4) * translucent; + double samount_spec = + (specular == 0 || spec < 0) ? 0 : pow(spec, (101 - specular) / 4) * reflection; double samount = samount_tran + samount_spec; - + // printf ("(%ld, %ld) %f, %f\n", x, y, spec, samount); - float sr = samount*color.red; - float sg = samount*color.green; - float sb = samount*color.blue; + float sr = samount * color.red; + float sg = samount * color.green; + float sb = samount * color.blue; - float ramount = 1 + (amount > 0 ? amount*color.red/255 : amount); - float gamount = 1 + (amount > 0 ? amount*color.green/255 : amount); - float bamount = 1 + (amount > 0 ? amount*color.blue/255 : amount); + float ramount = 1 + (amount > 0 ? amount * color.red / 255 : amount); + float gamount = 1 + (amount > 0 ? amount * color.green / 255 : amount); + float bamount = 1 + (amount > 0 ? amount * color.blue / 255 : amount); bgra_pixel pixel = *sbits++; - *dbits++ = PIXEL (clipchar (ramount*RED (pixel) + sr), - clipchar (gamount*GREEN (pixel) + sg), - clipchar (bamount*BLUE (pixel) + sb), - ALPHA (pixel)); + *dbits++ = PIXEL( + clipchar(ramount * RED(pixel) + sr), clipchar(gamount * GREEN(pixel) + sg), + clipchar(bamount * BLUE(pixel) + sb), ALPHA(pixel) + ); mapbits++; } *dbits++ = *sbits++; @@ -341,12 +359,11 @@ status_t process (Layer *inLayer, Selection *inSelection, *dbits++ = *sbits++; break; } - case M_SELECT: - { + case M_SELECT: { break; } default: - fprintf (stderr, "Bumpmap: Unknown mode\n"); + fprintf(stderr, "Bumpmap: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -354,7 +371,7 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); - + if (final) addon_done(); return (error); diff --git a/source/add-ons/CaptureTest/CaptureTest.cpp b/source/add-ons/CaptureTest/CaptureTest.cpp index c92fb39..8b91d93 100644 --- a/source/add-ons/CaptureTest/CaptureTest.cpp +++ b/source/add-ons/CaptureTest/CaptureTest.cpp @@ -9,72 +9,91 @@ class CaptureWindow : public BWindow { -public: - CaptureWindow (BRect rect) : BWindow (rect, "Capture Test", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK) {}; -virtual ~CaptureWindow () {}; -virtual bool QuitRequested () { Hide(); return false; }; + public: + CaptureWindow(BRect rect) + : BWindow( + rect, "Capture Test", B_TITLED_WINDOW, + B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK + ){}; + virtual ~CaptureWindow(){}; + + virtual bool QuitRequested() + { + Hide(); + return false; + }; }; -CaptureWindow *window; +CaptureWindow* window; -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "CaptureTest"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998-2001 ∑ Sum Software"); - strcpy (info->description, "Fake Capture add-on"); - info->type = BECASSO_CAPTURE; - info->index = index; - info->version = 1; - info->release = 2; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = 0; - info->flags = 0; - window = new CaptureWindow (BRect (100, 180, 100 + 188, 180 + 72)); - BView *bg = new BView (BRect (0, 0, 188, 72), "bg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); - bg->SetViewColor (LightGrey); - window->AddChild (bg); - BMessage *msg = new BMessage (CAPTURE_READY); - msg->AddInt32 ("index", index); - BButton *grab = new BButton (BRect (128, 40, 180, 64), "grab", "Grab", msg); - grab->SetTarget (be_app); - bg->AddChild (grab); + strcpy(info->name, "CaptureTest"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998-2001 ∑ Sum Software"); + strcpy(info->description, "Fake Capture add-on"); + info->type = BECASSO_CAPTURE; + info->index = index; + info->version = 1; + info->release = 2; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = 0; + info->flags = 0; + window = new CaptureWindow(BRect(100, 180, 100 + 188, 180 + 72)); + BView* bg = new BView(BRect(0, 0, 188, 72), "bg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); + bg->SetViewColor(LightGrey); + window->AddChild(bg); + BMessage* msg = new BMessage(CAPTURE_READY); + msg->AddInt32("index", index); + BButton* grab = new BButton(BRect(128, 40, 180, 64), "grab", "Grab", msg); + grab->SetTarget(be_app); + bg->AddChild(grab); window->Run(); return (0); } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_open () +status_t +addon_open() { window->Lock(); if (window->IsHidden()) - window->Show (); + window->Show(); else - window->Activate (); + window->Activate(); window->Unlock(); return (0); } -BBitmap *bitmap (char *title) +BBitmap* +bitmap(char* title) { - strcpy (title, "Grabbed"); - BBitmap *b = new BBitmap (BRect (0, 0, 127, 127), B_RGB_32_BIT, true); - BView *v = new BView (BRect (0, 0, 127, 127), "bg", 0, 0); + strcpy(title, "Grabbed"); + BBitmap* b = new BBitmap(BRect(0, 0, 127, 127), B_RGB_32_BIT, true); + BView* v = new BView(BRect(0, 0, 127, 127), "bg", 0, 0); b->Lock(); - b->AddChild (v); + b->AddChild(v); rgb_color fg, bg; - fg.red = 255; fg.green = 255; fg.blue = 255; fg.alpha = 255; - bg.red = 0; bg.green = 0; bg.blue = 0; bg.alpha = 127; - v->SetHighColor (fg); - v->SetLowColor (bg); - v->FillRect (BRect (0, 0, 127, 127), B_MIXED_COLORS); + fg.red = 255; + fg.green = 255; + fg.blue = 255; + fg.alpha = 255; + bg.red = 0; + bg.green = 0; + bg.blue = 0; + bg.alpha = 127; + v->SetHighColor(fg); + v->SetLowColor(bg); + v->FillRect(BRect(0, 0, 127, 127), B_MIXED_COLORS); v->Sync(); - b->RemoveChild (v); + b->RemoveChild(v); b->Unlock(); delete v; return (b); diff --git a/source/add-ons/Chromakey/Chromakey.cpp b/source/add-ons/Chromakey/Chromakey.cpp index 152b176..9f3b2ff 100644 --- a/source/add-ons/Chromakey/Chromakey.cpp +++ b/source/add-ons/Chromakey/Chromakey.cpp @@ -9,62 +9,67 @@ #include #include -int gSigma; -int gThreshold; -int gMode; +int gSigma; +int gThreshold; +int gMode; -#define CK_BLUE 0 -#define CK_FG 1 -#define CK_BG 2 +#define CK_BLUE 0 +#define CK_FG 1 +#define CK_BG 2 class CKView : public BView { -public: - CKView (BRect rect); -virtual ~CKView () {} -virtual void MessageReceived (BMessage *msg); + public: + CKView(BRect rect); -private: -typedef BView inherited; + virtual ~CKView() {} + + virtual void MessageReceived(BMessage* msg); + + private: + typedef BView inherited; }; -CKView::CKView (BRect rect) -: BView (rect, "CKView", B_FOLLOW_ALL, B_WILL_DRAW) +CKView::CKView(BRect rect) : BView(rect, "CKView", B_FOLLOW_ALL, B_WILL_DRAW) { - gSigma = 5; - gThreshold = 5; - gMode = CK_BLUE; - BBox *mode = new BBox (BRect (8, 4, 180, 78), "mode"); - mode->SetLabel ("Key Color"); - AddChild (mode); - - BRadioButton *rbBl = new BRadioButton (BRect (4, 14, 170, 30), "blue", "Blue", new BMessage ('ckBl')); - BRadioButton *rbFG = new BRadioButton (BRect (4, 32, 170, 48), "fg", "Foreground", new BMessage ('ckFG')); - BRadioButton *rbBG = new BRadioButton (BRect (4, 50, 170, 66), "bg", "Background", new BMessage ('ckBG')); - mode->AddChild (rbBl); - mode->AddChild (rbFG); - mode->AddChild (rbBG); - - rbBl->SetValue (true); - Slider *xSlid = new Slider (BRect (8, 82, 180, 98), 60, "Sigma", 0, 100, 1, new BMessage ('ckSg')); - Slider *ySlid = new Slider (BRect (8, 102, 180, 118), 60, "Threshold", 0, 100, 1, new BMessage ('ckTh')); - AddChild (xSlid); - AddChild (ySlid); - xSlid->SetValue (gSigma); - ySlid->SetValue (gThreshold); - - ResizeTo (Bounds().Width(), 124); + gSigma = 5; + gThreshold = 5; + gMode = CK_BLUE; + BBox* mode = new BBox(BRect(8, 4, 180, 78), "mode"); + mode->SetLabel("Key Color"); + AddChild(mode); + + BRadioButton* rbBl = + new BRadioButton(BRect(4, 14, 170, 30), "blue", "Blue", new BMessage('ckBl')); + BRadioButton* rbFG = + new BRadioButton(BRect(4, 32, 170, 48), "fg", "Foreground", new BMessage('ckFG')); + BRadioButton* rbBG = + new BRadioButton(BRect(4, 50, 170, 66), "bg", "Background", new BMessage('ckBG')); + mode->AddChild(rbBl); + mode->AddChild(rbFG); + mode->AddChild(rbBG); + + rbBl->SetValue(true); + Slider* xSlid = new Slider(BRect(8, 82, 180, 98), 60, "Sigma", 0, 100, 1, new BMessage('ckSg')); + Slider* ySlid = + new Slider(BRect(8, 102, 180, 118), 60, "Threshold", 0, 100, 1, new BMessage('ckTh')); + AddChild(xSlid); + AddChild(ySlid); + xSlid->SetValue(gSigma); + ySlid->SetValue(gThreshold); + + ResizeTo(Bounds().Width(), 124); } -void CKView::MessageReceived (BMessage *msg) +void +CKView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'ckSg': - gSigma = int (msg->FindFloat ("value") + 0.5); + gSigma = int(msg->FindFloat("value") + 0.5); break; case 'ckTh': - gThreshold = int (msg->FindFloat ("value") + 0.5); + gThreshold = int(msg->FindFloat("value") + 0.5); break; case 'ckBl': gMode = CK_BLUE; @@ -76,58 +81,63 @@ void CKView::MessageReceived (BMessage *msg) gMode = CK_BG; break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); return; } addon_preview(); } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "ChromaKey"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 2002 ∑ Sum Software"); - strcpy (info->description, "Keys out a color to transparent"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 0; - info->release = 1; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "ChromaKey"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 2002 ∑ Sum Software"); + strcpy(info->description, "Keys out a color to transparent"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 0; + info->release = 1; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new CKView (rect); + *view = new CKView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /* frame */, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /* frame */, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to blur! + *outSelection = new Selection(*inSelection); + else // No Selection to blur! return (error); } if (*outLayer) @@ -136,23 +146,22 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - uint8 *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; + uint8* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; - int threshold = gThreshold*441/100; + int threshold = gThreshold * 441 / 100; int sigma = gSigma; - if (inSelection) - { - mapbits = (uint8 *) inSelection->Bits() - 1; - mbpr = inSelection->BytesPerRow(); + if (inSelection) { + mapbits = (uint8*)inSelection->Bits() - 1; + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. + float delta = 100.0 / h; // For the Status Bar. rgb_color key; @@ -160,63 +169,51 @@ status_t process (Layer *inLayer, Selection *inSelection, key = highcolor(); else if (gMode == CK_BG) key = lowcolor(); - else - { + else { key.red = 0; key.green = 0; key.blue = 255; } - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (uint32 *) inLayer->Bits() - 1; - bgra_pixel *dbits = (uint32 *) (*outLayer)->Bits() - 1; - - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (uint32*)inLayer->Bits() - 1; + bgra_pixel* dbits = (uint32*)(*outLayer)->Bits() - 1; + + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { grey_pixel mp = inSelection ? *(++mapbits) : 255; - if (mp) - { + if (mp) { bgra_pixel p = *(++sbits); - rgb_color pix = bgra2rgb (p); - int d = int (diff (pix, key) + 0.5); + rgb_color pix = bgra2rgb(p); + int d = int(diff(pix, key) + 0.5); if (d < threshold) *(++dbits) = p & COLOR_MASK; - else if (d < threshold + sigma) - { - int alpha = 255*(d - threshold)/sigma; - *(++dbits) = (p & COLOR_MASK) | (pix.alpha*alpha << (ALPHA_BPOS - 8)); - } - else + else if (d < threshold + sigma) { + int alpha = 255 * (d - threshold) / sigma; + *(++dbits) = (p & COLOR_MASK) | (pix.alpha * alpha << (ALPHA_BPOS - 8)); + } else *(++dbits) = p; - } - else + } else *(++dbits) = *(++sbits); } mapbits += mdiff; } - + break; } - case M_SELECT: - { + case M_SELECT: { break; } default: - fprintf (stderr, "ChromaKey: Unknown mode\n"); + fprintf(stderr, "ChromaKey: Unknown mode\n"); error = ADDON_UNKNOWN; } diff --git a/source/add-ons/ColorCurves/ColorCurves.cpp b/source/add-ons/ColorCurves/ColorCurves.cpp index b92a119..2c9fff7 100644 --- a/source/add-ons/ColorCurves/ColorCurves.cpp +++ b/source/add-ons/ColorCurves/ColorCurves.cpp @@ -19,22 +19,24 @@ #define MAC_GAMMA 1.8 -#define CS_RGBA 0 -#define CS_CMYK 1 -#define CS_HSV 2 -#define CS_RGBL 3 +#define CS_RGBA 0 +#define CS_CMYK 1 +#define CS_HSV 2 +#define CS_RGBL 3 -#define GT_STRAIGHT 0 -#define GT_SMOOTH 1 -#define GT_GAMMA 2 +#define GT_STRAIGHT 0 +#define GT_SMOOTH 1 +#define GT_GAMMA 2 -#define NUM_CHANNELS 11 // RGBA + CMYK + HSV +#define NUM_CHANNELS 11 // RGBA + CMYK + HSV #ifdef __INTEL__ -extern "C" void gamma_x86 (uint32 *s, uint32 *d, uint32 *table, uint32 numPix); +extern "C" void +gamma_x86(uint32* s, uint32* d, uint32* table, uint32 numPix); #endif #define MAX_POINTS 64 + typedef struct { unsigned char x; @@ -43,97 +45,102 @@ typedef struct class CurveView : public BView { -public: - CurveView (BRect rect, const char *name) : BView (rect, name, 0, B_WILL_DRAW) - { - type = GT_STRAIGHT; - SetViewColor (B_TRANSPARENT_32_BIT); - for (int i = 0; i < NUM_CHANNELS; i++) - { - fGamma[i] = 1.0; - npoints[i] = 2; - points[i][0].x = 0; points[i][0].y = 0; - points[i][1].x = 255; points[i][1].y = 255; - FillTable (i); - } - fCurrent = 99; - } -virtual ~CurveView () {} -virtual void Draw (BRect update); -virtual void MouseDown (BPoint point); - -void AddPoint (); -void do_AddPoint (int channel); -void RemovePoint (); -void do_RemovePoint (int channel); -void SetType (int t); -void SetGamma (float gamma) - { - if (fCurrent == 99) - { - fGamma[0] = gamma; - fGamma[1] = gamma; - fGamma[2] = gamma; - } - else - fGamma[fCurrent] = gamma; - } -float Gamma (int c = -1) - { - if (c == -1) - c = fCurrent; - if (c == 99) - return fGamma[0]; - else - return fGamma[c]; - } - -void FillTable (int channel = -1); -void do_FillTable (int channel); -int NPoints () - { - if (fCurrent == 99) - return npoints[0]; - else - return npoints[fCurrent]; - } - -int Current () { return fCurrent; } -void SetCurrent (int current); - -unsigned char wct[NUM_CHANNELS][256]; - -private: -int type; -int npoints[NUM_CHANNELS]; -point points[NUM_CHANNELS][MAX_POINTS]; -int added[NUM_CHANNELS][MAX_POINTS]; -int fCurrent; -float fGamma[NUM_CHANNELS]; + public: + CurveView(BRect rect, const char* name) : BView(rect, name, 0, B_WILL_DRAW) + { + type = GT_STRAIGHT; + SetViewColor(B_TRANSPARENT_32_BIT); + for (int i = 0; i < NUM_CHANNELS; i++) { + fGamma[i] = 1.0; + npoints[i] = 2; + points[i][0].x = 0; + points[i][0].y = 0; + points[i][1].x = 255; + points[i][1].y = 255; + FillTable(i); + } + fCurrent = 99; + } + + virtual ~CurveView() {} + + virtual void Draw(BRect update); + virtual void MouseDown(BPoint point); + + void AddPoint(); + void do_AddPoint(int channel); + void RemovePoint(); + void do_RemovePoint(int channel); + void SetType(int t); + + void SetGamma(float gamma) + { + if (fCurrent == 99) { + fGamma[0] = gamma; + fGamma[1] = gamma; + fGamma[2] = gamma; + } else + fGamma[fCurrent] = gamma; + } + + float Gamma(int c = -1) + { + if (c == -1) + c = fCurrent; + if (c == 99) + return fGamma[0]; + else + return fGamma[c]; + } + + void FillTable(int channel = -1); + void do_FillTable(int channel); + + int NPoints() + { + if (fCurrent == 99) + return npoints[0]; + else + return npoints[fCurrent]; + } + + int Current() { return fCurrent; } + + void SetCurrent(int current); + + unsigned char wct[NUM_CHANNELS][256]; + + private: + int type; + int npoints[NUM_CHANNELS]; + point points[NUM_CHANNELS][MAX_POINTS]; + int added[NUM_CHANNELS][MAX_POINTS]; + int fCurrent; + float fGamma[NUM_CHANNELS]; }; -CurveView *gCurve = 0; +CurveView* gCurve = 0; class ColorCurvesView : public BView { -public: - ColorCurvesView (BRect rect) : BView (rect, "color_curves", B_FOLLOW_ALL, B_WILL_DRAW) - { - ResizeTo (430, 308); - controlsBox = new BBox (BRect (280, 8, 422, 298), "controls box"); - graphBox = new BBox (BRect (8, 8, 272, 298), "graph tabs"); - AddChild (graphBox); - AddChild (controlsBox); - - cspacePU = new BPopUpMenu ("ColorSpace"); - cspacePU->AddItem (new BMenuItem ("RGBA", new BMessage ('cspR'))); - cspacePU->AddItem (new BMenuItem ("CMYK", new BMessage ('cspC'))); - cspacePU->AddItem (new BMenuItem ("HSV", new BMessage ('cspH'))); - cspacePU->AddItem (new BMenuItem ("RGB Locked", new BMessage ('cspL'))); - cspacePU->ItemAt(CS_RGBL)->SetMarked (true); - cspaceMF = new BMenuField (BRect (4, 264, 104, 278), "cspaceMF", "", cspacePU); - cspaceMF->SetDivider (0); - graphBox->AddChild (cspaceMF); + public: + ColorCurvesView(BRect rect) : BView(rect, "color_curves", B_FOLLOW_ALL, B_WILL_DRAW) + { + ResizeTo(430, 308); + controlsBox = new BBox(BRect(280, 8, 422, 298), "controls box"); + graphBox = new BBox(BRect(8, 8, 272, 298), "graph tabs"); + AddChild(graphBox); + AddChild(controlsBox); + + cspacePU = new BPopUpMenu("ColorSpace"); + cspacePU->AddItem(new BMenuItem("RGBA", new BMessage('cspR'))); + cspacePU->AddItem(new BMenuItem("CMYK", new BMessage('cspC'))); + cspacePU->AddItem(new BMenuItem("HSV", new BMessage('cspH'))); + cspacePU->AddItem(new BMenuItem("RGB Locked", new BMessage('cspL'))); + cspacePU->ItemAt(CS_RGBL)->SetMarked(true); + cspaceMF = new BMenuField(BRect(4, 264, 104, 278), "cspaceMF", "", cspacePU); + cspaceMF->SetDivider(0); + graphBox->AddChild(cspaceMF); #if 0 graphPU = new BPopUpMenu ("Graphed"); @@ -146,287 +153,307 @@ class ColorCurvesView : public BView graphMF->SetDivider (0); graphBox->AddChild (graphMF); #else - graphMF = NULL; + graphMF = NULL; #endif - typeBox = new BBox (BRect (8, 8, 134, 66), "typeBox"); - typeBox->SetLabel ("Correction"); - controlsBox->AddChild (typeBox); - - freeRB = new BRadioButton (BRect (8, 16, 118, 32), "freeRB", "Free Function", new BMessage ('Tfre')); - gammaRB = new BRadioButton (BRect (8, 34, 118, 50), "gammaRB", "Gamma", new BMessage ('Tgam')); - typeBox->AddChild (freeRB); - typeBox->AddChild (gammaRB); - freeRB->SetValue (B_CONTROL_ON); - - addB = new BButton (BRect (8, 72, 132, 88), "addB", "Add Point", new BMessage ('addP')); - removeB = new BButton (BRect (8, 100, 132, 128), "removeB", "Remove Point", new BMessage ('delP')); - controlsBox->AddChild (addB); - controlsBox->AddChild (removeB); - removeB->SetEnabled (false); - - graphTypeBox = new BBox (BRect (8, 138, 134, 198), "graphTypeBox"); - graphTypeBox->SetLabel ("Curve Type"); - controlsBox->AddChild (graphTypeBox); - - linesRB = new BRadioButton (BRect (8, 16, 118, 32), "linesRB", "Straight Lines", new BMessage ('Glin')); - smoothRB = new BRadioButton (BRect (8, 34, 118, 50), "smoothRB", "Smooth Fit", new BMessage ('Gfit')); - graphTypeBox->AddChild (linesRB); - graphTypeBox->AddChild (smoothRB); - linesRB->SetValue (B_CONTROL_ON); - - gCurve = new CurveView (BRect (4, 4, 259, 259), "curve"); - graphBox->AddChild (gCurve); - - gammaS = new Slider (BRect (8, 206, 134, 224), 50, "Gamma", 0, 3, 0.01, new BMessage ('gamC'), B_HORIZONTAL, 0, "%1.2f"); - gammaS->SetValue (gCurve->Gamma()); - controlsBox->AddChild (gammaS); - - BButton *pc2mac = new BButton (BRect (8, 230, 68, 254), "pc2mac", "PC » Mac", new BMessage ('gp2m')); - BButton *mac2pc = new BButton (BRect (74, 230, 134, 254), "mac2pc", "Mac » PC", new BMessage ('gm2p')); - controlsBox->AddChild (pc2mac); - controlsBox->AddChild (mac2pc); - } -virtual ~ColorCurvesView () {} -virtual void MessageReceived (BMessage *msg); - -int Channel () - { - return (cspacePU->IndexOf (cspacePU->FindMarked())*4 + graphPU->IndexOf (graphPU->FindMarked())); - } - -BBox *controlsBox; -BBox *graphBox; -BBox *typeBox; -BBox *graphTypeBox; -BMenuField *cspaceMF; -BPopUpMenu *cspacePU; -BMenuField *graphMF; -BPopUpMenu *graphPU; -BStringView *curcoords; -BRadioButton*freeRB, *gammaRB; -BRadioButton*linesRB, *smoothRB; -Slider *gammaS; -BButton *addB, *removeB; + typeBox = new BBox(BRect(8, 8, 134, 66), "typeBox"); + typeBox->SetLabel("Correction"); + controlsBox->AddChild(typeBox); + + freeRB = new BRadioButton( + BRect(8, 16, 118, 32), "freeRB", "Free Function", new BMessage('Tfre') + ); + gammaRB = new BRadioButton(BRect(8, 34, 118, 50), "gammaRB", "Gamma", new BMessage('Tgam')); + typeBox->AddChild(freeRB); + typeBox->AddChild(gammaRB); + freeRB->SetValue(B_CONTROL_ON); + + addB = new BButton(BRect(8, 72, 132, 88), "addB", "Add Point", new BMessage('addP')); + removeB = + new BButton(BRect(8, 100, 132, 128), "removeB", "Remove Point", new BMessage('delP')); + controlsBox->AddChild(addB); + controlsBox->AddChild(removeB); + removeB->SetEnabled(false); + + graphTypeBox = new BBox(BRect(8, 138, 134, 198), "graphTypeBox"); + graphTypeBox->SetLabel("Curve Type"); + controlsBox->AddChild(graphTypeBox); + + linesRB = new BRadioButton( + BRect(8, 16, 118, 32), "linesRB", "Straight Lines", new BMessage('Glin') + ); + smoothRB = + new BRadioButton(BRect(8, 34, 118, 50), "smoothRB", "Smooth Fit", new BMessage('Gfit')); + graphTypeBox->AddChild(linesRB); + graphTypeBox->AddChild(smoothRB); + linesRB->SetValue(B_CONTROL_ON); + + gCurve = new CurveView(BRect(4, 4, 259, 259), "curve"); + graphBox->AddChild(gCurve); + + gammaS = new Slider( + BRect(8, 206, 134, 224), 50, "Gamma", 0, 3, 0.01, new BMessage('gamC'), B_HORIZONTAL, 0, + "%1.2f" + ); + gammaS->SetValue(gCurve->Gamma()); + controlsBox->AddChild(gammaS); + + BButton* pc2mac = + new BButton(BRect(8, 230, 68, 254), "pc2mac", "PC » Mac", new BMessage('gp2m')); + BButton* mac2pc = + new BButton(BRect(74, 230, 134, 254), "mac2pc", "Mac » PC", new BMessage('gm2p')); + controlsBox->AddChild(pc2mac); + controlsBox->AddChild(mac2pc); + } + + virtual ~ColorCurvesView() {} + + virtual void MessageReceived(BMessage* msg); + + int Channel() + { + return ( + cspacePU->IndexOf(cspacePU->FindMarked()) * 4 + graphPU->IndexOf(graphPU->FindMarked()) + ); + } + + BBox* controlsBox; + BBox* graphBox; + BBox* typeBox; + BBox* graphTypeBox; + BMenuField* cspaceMF; + BPopUpMenu* cspacePU; + BMenuField* graphMF; + BPopUpMenu* graphPU; + BStringView* curcoords; + BRadioButton *freeRB, *gammaRB; + BRadioButton *linesRB, *smoothRB; + Slider* gammaS; + BButton *addB, *removeB; }; -ColorCurvesView *gView = 0; +ColorCurvesView* gView = 0; -void CurveView::Draw (BRect update) +void +CurveView::Draw(BRect update) { int chan; - SetLowColor (240, 240, 240, 255); - FillRect (update, B_SOLID_LOW); - SetHighColor (255, 0, 0, 255); + SetLowColor(240, 240, 240, 255); + FillRect(update, B_SOLID_LOW); + SetHighColor(255, 0, 0, 255); if (fCurrent == 99) chan = 0; else chan = fCurrent; - MovePenTo (BPoint (0, 255 - wct[chan][0])); + MovePenTo(BPoint(0, 255 - wct[chan][0])); for (int i = 1; i < 256; i++) - StrokeLine (BPoint (i, 255 - wct[chan][i])); - if (type != GT_GAMMA) - { - SetHighColor (Black); + StrokeLine(BPoint(i, 255 - wct[chan][i])); + if (type != GT_GAMMA) { + SetHighColor(Black); for (int i = 0; i < npoints[chan]; i++) - StrokeRect (BRect (points[chan][i].x - 3, 252 - points[chan][i].y, points[chan][i].x + 3, 258 - points[chan][i].y)); + StrokeRect(BRect( + points[chan][i].x - 3, 252 - points[chan][i].y, points[chan][i].x + 3, + 258 - points[chan][i].y + )); } } -void CurveView::SetType (int t) +void +CurveView::SetType(int t) { type = t; - FillTable (fCurrent); + FillTable(fCurrent); addon_preview(); Invalidate(); } -void CurveView::SetCurrent (int current) +void +CurveView::SetCurrent(int current) { - if (current == 99) // Lock RGB + if (current == 99) // Lock RGB { // copy from R npoints[1] = npoints[0]; npoints[2] = npoints[0]; - for (int i = 0; i < npoints[0]; i++) - { + for (int i = 0; i < npoints[0]; i++) { points[1][i] = points[0][i]; points[2][i] = points[0][i]; } fGamma[1] = fGamma[0]; fGamma[2] = fGamma[0]; } - fCurrent = current; - FillTable (current); - addon_preview(); - Invalidate(); + fCurrent = current; + FillTable(current); + addon_preview(); + Invalidate(); } - -void CurveView::do_FillTable (int channel) +void +CurveView::do_FillTable(int channel) { -// printf ("Filling %d\n", channel); - switch (type) - { - case GT_STRAIGHT: - { - for (int i = 0; i < npoints[channel] - 1; i++) - { + // printf ("Filling %d\n", channel); + switch (type) { + case GT_STRAIGHT: { + for (int i = 0; i < npoints[channel] - 1; i++) { for (int j = points[channel][i].x; j <= points[channel][i + 1].x; j++) - wct[channel][j] = (unsigned char) (float (points[channel][i + 1].y - points[channel][i].y)*(j - points[channel][i].x)/(points[channel][i + 1].x - points[channel][i].x) + points[channel][i].y); + wct[channel][j] = + (unsigned char)(float(points[channel][i + 1].y - points[channel][i].y) * + (j - points[channel][i].x) / + (points[channel][i + 1].x - points[channel][i].x) + + points[channel][i].y); } break; } - case GT_SMOOTH: - { - if (npoints[channel] == 2) - { + case GT_SMOOTH: { + if (npoints[channel] == 2) { for (int j = 0; j <= 255; j++) - wct[channel][j] = (unsigned char) (float (points[channel][1].y - points[channel][0].y)*j/255 + points[channel][0].y); - } - else - { + wct[channel][j] = + (unsigned char)(float(points[channel][1].y - points[channel][0].y) * j / 255 + + points[channel][0].y); + } else { float a, b, c, d; float yprime, ynprime; // First section: quadratic function -// ynprime = (float (points[1].y - points[0].y)/(points[1].x - points[0].x)*(points[2].x - points[1].x) -// + float (points[2].y - points[1].y)/(points[2].x - points[1].x)*(points[1].x - points[0].x)) -// / (points[2].x - points[0].x); - ynprime = float (points[channel][2].y - points[channel][0].y)/(points[channel][2].x - points[channel][0].x); - a = ynprime/points[channel][1].x - float (points[channel][1].y - points[channel][0].y)/(points[channel][1].x*points[channel][1].x); - b = 2*float (points[channel][1].y - points[channel][0].y)/points[channel][1].x - ynprime; + // ynprime = (float (points[1].y - points[0].y)/(points[1].x - + // points[0].x)*(points[2].x - points[1].x) + // + float (points[2].y - points[1].y)/(points[2].x - + // points[1].x)*(points[1].x - points[0].x)) / (points[2].x - + // points[0].x); + ynprime = float(points[channel][2].y - points[channel][0].y) / + (points[channel][2].x - points[channel][0].x); + a = ynprime / points[channel][1].x - + float(points[channel][1].y - points[channel][0].y) / + (points[channel][1].x * points[channel][1].x); + b = 2 * float(points[channel][1].y - points[channel][0].y) / points[channel][1].x - + ynprime; c = points[channel][0].y; for (int j = 0; j <= points[channel][1].x; j++) - wct[channel][j] = clipchar (a*j*j + b*j + c); + wct[channel][j] = clipchar(a * j * j + b * j + c); // Middle sections: cubic - for (int i = 1; i < npoints[channel] - 2; i++) - { + for (int i = 1; i < npoints[channel] - 2; i++) { float xl = points[channel][i].x; float yl = points[channel][i].y; float xr = points[channel][i + 1].x; float yr = points[channel][i + 1].y; float xt = xr - xl; yprime = ynprime; -// ynprime = (float (yr - yl)/(xr - xl)*(points[i + 2].x - points[i + 1].x) -// + float (points[i + 2].y - yr)/(points[i + 2].x - points[i + 1].x)*xt) -// / (xr - points[i - 1].x); - ynprime = float (points[channel][i + 2].y - points[channel][i].y)/(points[channel][i + 2].x - points[channel][i].x); - a = (ynprime - yprime - 2*(yr - yprime*xt - yl)/xt)/(xt*xt); - b = (ynprime - yprime - 3*a*xt*xt)/(2*xt); + // ynprime = (float (yr - yl)/(xr - xl)*(points[i + 2].x - points[i + + // 1].x) + // + float (points[i + 2].y - yr)/(points[i + 2].x - points[i + //+ 1].x)*xt) / (xr - points[i - 1].x); + ynprime = float(points[channel][i + 2].y - points[channel][i].y) / + (points[channel][i + 2].x - points[channel][i].x); + a = (ynprime - yprime - 2 * (yr - yprime * xt - yl) / xt) / (xt * xt); + b = (ynprime - yprime - 3 * a * xt * xt) / (2 * xt); c = yprime; d = points[channel][i].y; - for (int j = points[channel][i].x; j <= points[channel][i + 1].x; j++) - { + for (int j = points[channel][i].x; j <= points[channel][i + 1].x; j++) { float x = j - points[channel][i].x; - wct[channel][j] = clipchar (a*x*x*x + b*x*x + c*x + d); + wct[channel][j] = clipchar(a * x * x * x + b * x * x + c * x + d); } } // Last section: quadratic again - float xt = points[channel][npoints[channel] - 1].x - points[channel][npoints[channel] - 2].x; - a = float (points[channel][npoints[channel] - 1].y - ynprime*xt - points[channel][npoints[channel] - 2].y)/(xt*xt); + float xt = + points[channel][npoints[channel] - 1].x - points[channel][npoints[channel] - 2].x; + a = float( + points[channel][npoints[channel] - 1].y - ynprime * xt - + points[channel][npoints[channel] - 2].y + ) / + (xt * xt); b = ynprime; c = points[channel][npoints[channel] - 2].y; - for (int j = points[channel][npoints[channel] - 2].x; j <= points[channel][npoints[channel] - 1].x; j++) - { + for (int j = points[channel][npoints[channel] - 2].x; + j <= points[channel][npoints[channel] - 1].x; j++) { float x = j - points[channel][npoints[channel] - 2].x; - wct[channel][j] = clipchar (a*x*x + b*x + c); + wct[channel][j] = clipchar(a * x * x + b * x + c); } } break; } - case GT_GAMMA: - { + case GT_GAMMA: { float gamma = Gamma(); - for (int i = 0; i < 256; i++) - { - float v = float (i) / 255.0; - wct[channel][i] = uchar (255*pow (v, gamma)); + for (int i = 0; i < 256; i++) { + float v = float(i) / 255.0; + wct[channel][i] = uchar(255 * pow(v, gamma)); } break; } default: - fprintf (stderr, "Color Curves: Unknown graph type\n"); + fprintf(stderr, "Color Curves: Unknown graph type\n"); break; } } -void CurveView::FillTable (int channel) +void +CurveView::FillTable(int channel) { if (channel == -1) channel = fCurrent; - if (channel == 99) - { - do_FillTable (0); - do_FillTable (1); - do_FillTable (2); - } - else - do_FillTable (channel); + if (channel == 99) { + do_FillTable(0); + do_FillTable(1); + do_FillTable(2); + } else + do_FillTable(channel); } -void CurveView::do_AddPoint (int channel) +void +CurveView::do_AddPoint(int channel) { - if (npoints[channel] == MAX_POINTS) - { - fprintf (stderr, "Color Curves: Too many control points\n"); + if (npoints[channel] == MAX_POINTS) { + fprintf(stderr, "Color Curves: Too many control points\n"); return; } - if (npoints[channel] == 2) - { + if (npoints[channel] == 2) { added[channel][npoints[channel]++] = 1; points[channel][2] = points[channel][1]; - points[channel][1].x = (points[channel][2].x - points[channel][0].x)/2; - points[channel][1].y = (points[channel][2].y - points[channel][0].y)/2; - } - else - { + points[channel][1].x = (points[channel][2].x - points[channel][0].x) / 2; + points[channel][1].y = (points[channel][2].y - points[channel][0].y) / 2; + } else { // Find largest section and add the new point there int maxdist = 0; int ind = 0; - for (int i = 0; i < npoints[channel] - 1; i++) - { + for (int i = 0; i < npoints[channel] - 1; i++) { int dist = points[channel][i + 1].x - points[channel][i].x; - if (dist > maxdist) - { + if (dist > maxdist) { ind = i + 1; maxdist = dist; } } -// printf ("Max dist = %d at %d\n", maxdist, ind); + // printf ("Max dist = %d at %d\n", maxdist, ind); added[channel][npoints[channel]++] = ind; for (int i = npoints[channel] - 1; i > ind; i--) points[channel][i] = points[channel][i - 1]; - points[channel][ind].x = (points[channel][ind + 1].x + points[channel][ind - 1].x)/2; + points[channel][ind].x = (points[channel][ind + 1].x + points[channel][ind - 1].x) / 2; points[channel][ind].y = wct[channel][points[channel][ind].x]; -// printf ("New point at (%d, %d)\n", points[ind].x, points[ind].y); + // printf ("New point at (%d, %d)\n", points[ind].x, points[ind].y); } } -void CurveView::AddPoint () +void +CurveView::AddPoint() { - if (fCurrent == 99) - { - do_AddPoint (0); - do_AddPoint (1); - do_AddPoint (2); - } - else - do_AddPoint (fCurrent); - FillTable (fCurrent); + if (fCurrent == 99) { + do_AddPoint(0); + do_AddPoint(1); + do_AddPoint(2); + } else + do_AddPoint(fCurrent); + FillTable(fCurrent); addon_preview(); Invalidate(); } -void CurveView::do_RemovePoint (int channel) +void +CurveView::do_RemovePoint(int channel) { - if (npoints[channel] == 2) - { - fprintf (stderr, "Color Curves: Trying to remove one of the last two control points\n"); + if (npoints[channel] == 2) { + fprintf(stderr, "Color Curves: Trying to remove one of the last two control points\n"); return; } int ind = added[channel][--npoints[channel]]; @@ -434,52 +461,46 @@ void CurveView::do_RemovePoint (int channel) points[channel][i] = points[channel][i + 1]; } -void CurveView::RemovePoint () +void +CurveView::RemovePoint() { - if (fCurrent == 99) - { - do_RemovePoint (0); - do_RemovePoint (1); - do_RemovePoint (2); - } - else - do_RemovePoint (fCurrent); - FillTable (fCurrent); + if (fCurrent == 99) { + do_RemovePoint(0); + do_RemovePoint(1); + do_RemovePoint(2); + } else + do_RemovePoint(fCurrent); + FillTable(fCurrent); addon_preview(); Invalidate(); } -void CurveView::MouseDown (BPoint point) +void +CurveView::MouseDown(BPoint point) { - if (fCurrent == 99) - { - for (int i = 0; i < npoints[0]; i++) - { - BRect handle (points[0][i].x - 3, 252 - points[0][i].y, points[0][i].x + 3, 257 - points[0][i].y); - if (handle.Contains (point)) - { + if (fCurrent == 99) { + for (int i = 0; i < npoints[0]; i++) { + BRect handle( + points[0][i].x - 3, 252 - points[0][i].y, points[0][i].x + 3, 257 - points[0][i].y + ); + if (handle.Contains(point)) { // Grabbed a handle, start tracking! uint32 buttons = 1; BPoint prev = point; - while (buttons) - { - if (point != prev) - { - points[0][i].x = clipchar (point.x); - points[0][i].y = clipchar (255 - point.y); - points[1][i].x = clipchar (point.x); - points[1][i].y = clipchar (255 - point.y); - points[2][i].x = clipchar (point.x); - points[2][i].y = clipchar (255 - point.y); - - if (i == 0) - { + while (buttons) { + if (point != prev) { + points[0][i].x = clipchar(point.x); + points[0][i].y = clipchar(255 - point.y); + points[1][i].x = clipchar(point.x); + points[1][i].y = clipchar(255 - point.y); + points[2][i].x = clipchar(point.x); + points[2][i].y = clipchar(255 - point.y); + + if (i == 0) { points[0][i].x = 0; points[1][i].x = 0; points[2][i].x = 0; - } - else - { + } else { if (points[0][i].x <= points[0][i - 1].x) points[0][i].x = points[0][i - 1].x + 1; if (points[1][i].x <= points[1][i - 1].x) @@ -488,14 +509,11 @@ void CurveView::MouseDown (BPoint point) points[2][i].x = points[2][i - 1].x + 1; } - if (i == npoints[0] - 1) - { + if (i == npoints[0] - 1) { points[0][i].x = 255; points[1][i].x = 255; points[2][i].x = 255; - } - else - { + } else { if (points[0][i].x >= points[0][i + 1].x) points[0][i].x = points[0][i + 1].x - 1; if (points[1][i].x >= points[1][i + 1].x) @@ -504,291 +522,290 @@ void CurveView::MouseDown (BPoint point) points[2][i].x = points[2][i + 1].x - 1; } - FillTable (fCurrent); + FillTable(fCurrent); addon_preview(); - Draw (Bounds()); + Draw(Bounds()); prev = point; } - snooze (20000); - GetMouse (&point, &buttons); + snooze(20000); + GetMouse(&point, &buttons); } } } - } - else - { - for (int i = 0; i < npoints[fCurrent]; i++) - { - BRect handle (points[fCurrent][i].x - 3, 252 - points[fCurrent][i].y, points[fCurrent][i].x + 3, 257 - points[fCurrent][i].y); - if (handle.Contains (point)) - { + } else { + for (int i = 0; i < npoints[fCurrent]; i++) { + BRect handle( + points[fCurrent][i].x - 3, 252 - points[fCurrent][i].y, points[fCurrent][i].x + 3, + 257 - points[fCurrent][i].y + ); + if (handle.Contains(point)) { // Grabbed a handle, start tracking! uint32 buttons = 1; BPoint prev = point; - while (buttons) - { - if (point != prev) - { - points[fCurrent][i].x = clipchar (point.x); - points[fCurrent][i].y = clipchar (255 - point.y); + while (buttons) { + if (point != prev) { + points[fCurrent][i].x = clipchar(point.x); + points[fCurrent][i].y = clipchar(255 - point.y); if (i == 0) points[fCurrent][i].x = 0; - else - if (points[fCurrent][i].x <= points[fCurrent][i - 1].x) - points[fCurrent][i].x = points[fCurrent][i - 1].x + 1; + else if (points[fCurrent][i].x <= points[fCurrent][i - 1].x) + points[fCurrent][i].x = points[fCurrent][i - 1].x + 1; if (i == npoints[fCurrent] - 1) points[fCurrent][i].x = 255; - else - if (points[fCurrent][i].x >= points[fCurrent][i + 1].x) - points[fCurrent][i].x = points[fCurrent][i + 1].x - 1; + else if (points[fCurrent][i].x >= points[fCurrent][i + 1].x) + points[fCurrent][i].x = points[fCurrent][i + 1].x - 1; - FillTable (fCurrent); + FillTable(fCurrent); addon_preview(); - Draw (Bounds()); + Draw(Bounds()); prev = point; } - snooze (20000); - GetMouse (&point, &buttons); + snooze(20000); + GetMouse(&point, &buttons); } } } } } -void ColorCurvesView::MessageReceived (BMessage *msg) +void +ColorCurvesView::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case 'cspL': - if (graphMF) - graphBox->RemoveChild (graphMF); - delete graphMF; - graphMF = NULL; - gCurve->SetCurrent (99); - break; - case 'cspR': - { - if (graphMF) - graphBox->RemoveChild (graphMF); + switch (msg->what) { + case 'cspL': + if (graphMF) + graphBox->RemoveChild(graphMF); delete graphMF; - graphPU = new BPopUpMenu ("Graphed"); - BMenuItem *item; - graphPU->AddItem (item = new BMenuItem ("Red", new BMessage ('RspR'))); - item->SetTarget (this); - graphPU->AddItem (item = new BMenuItem ("Green", new BMessage ('RspG'))); - item->SetTarget (this); - graphPU->AddItem (item = new BMenuItem ("Blue", new BMessage ('RspB'))); - item->SetTarget (this); - graphPU->AddItem (item = new BMenuItem ("Alpha", new BMessage ('RspA'))); - item->SetTarget (this); - graphPU->ItemAt(0)->SetMarked (true); - graphMF = new BMenuField (BRect (68, 264, 148, 278), "graphMF", "", graphPU); - graphMF->SetDivider (0); - graphBox->AddChild (graphMF); - gCurve->SetCurrent (0); + graphMF = NULL; + gCurve->SetCurrent(99); + break; + case 'cspR': { + if (graphMF) + graphBox->RemoveChild(graphMF); + delete graphMF; + graphPU = new BPopUpMenu("Graphed"); + BMenuItem* item; + graphPU->AddItem(item = new BMenuItem("Red", new BMessage('RspR'))); + item->SetTarget(this); + graphPU->AddItem(item = new BMenuItem("Green", new BMessage('RspG'))); + item->SetTarget(this); + graphPU->AddItem(item = new BMenuItem("Blue", new BMessage('RspB'))); + item->SetTarget(this); + graphPU->AddItem(item = new BMenuItem("Alpha", new BMessage('RspA'))); + item->SetTarget(this); + graphPU->ItemAt(0)->SetMarked(true); + graphMF = new BMenuField(BRect(68, 264, 148, 278), "graphMF", "", graphPU); + graphMF->SetDivider(0); + graphBox->AddChild(graphMF); + gCurve->SetCurrent(0); break; } - case 'cspC': - { - if (graphMF) - graphBox->RemoveChild (graphMF); + case 'cspC': { + if (graphMF) + graphBox->RemoveChild(graphMF); delete graphMF; - graphPU = new BPopUpMenu ("Graphed"); - BMenuItem *item; - graphPU->AddItem (item = new BMenuItem ("Cyan", new BMessage ('CspC'))); - item->SetTarget (this); - graphPU->AddItem (item = new BMenuItem ("Magenta", new BMessage ('CspM'))); - item->SetTarget (this); - graphPU->AddItem (item = new BMenuItem ("Yellow", new BMessage ('CspY'))); - item->SetTarget (this); - graphPU->AddItem (item = new BMenuItem ("Black", new BMessage ('CspK'))); - item->SetTarget (this); - graphPU->ItemAt(0)->SetMarked (true); - graphMF = new BMenuField (BRect (68, 264, 148, 278), "graphMF", "", graphPU); - graphMF->SetDivider (0); - graphBox->AddChild (graphMF); - gCurve->SetCurrent (4); + graphPU = new BPopUpMenu("Graphed"); + BMenuItem* item; + graphPU->AddItem(item = new BMenuItem("Cyan", new BMessage('CspC'))); + item->SetTarget(this); + graphPU->AddItem(item = new BMenuItem("Magenta", new BMessage('CspM'))); + item->SetTarget(this); + graphPU->AddItem(item = new BMenuItem("Yellow", new BMessage('CspY'))); + item->SetTarget(this); + graphPU->AddItem(item = new BMenuItem("Black", new BMessage('CspK'))); + item->SetTarget(this); + graphPU->ItemAt(0)->SetMarked(true); + graphMF = new BMenuField(BRect(68, 264, 148, 278), "graphMF", "", graphPU); + graphMF->SetDivider(0); + graphBox->AddChild(graphMF); + gCurve->SetCurrent(4); break; } - case 'cspH': - { - if (graphMF) - graphBox->RemoveChild (graphMF); + case 'cspH': { + if (graphMF) + graphBox->RemoveChild(graphMF); delete graphMF; - graphPU = new BPopUpMenu ("Graphed"); - BMenuItem *item; - graphPU->AddItem (item = new BMenuItem ("Hue", new BMessage ('HspH'))); // doesn't make sense but looks funny - item->SetTarget (this); - graphPU->AddItem (item = new BMenuItem ("Saturation", new BMessage ('HspS'))); - item->SetTarget (this); - graphPU->AddItem (item = new BMenuItem ("Value", new BMessage ('HspV'))); - item->SetTarget (this); - graphPU->ItemAt(0)->SetMarked (true); - item->SetTarget (this); - graphMF = new BMenuField (BRect (68, 264, 148, 278), "graphMF", "", graphPU); - graphMF->SetDivider (0); - graphBox->AddChild (graphMF); - gCurve->SetCurrent (8); + graphPU = new BPopUpMenu("Graphed"); + BMenuItem* item; + graphPU->AddItem( + item = new BMenuItem("Hue", new BMessage('HspH')) + ); // doesn't make sense but looks funny + item->SetTarget(this); + graphPU->AddItem(item = new BMenuItem("Saturation", new BMessage('HspS'))); + item->SetTarget(this); + graphPU->AddItem(item = new BMenuItem("Value", new BMessage('HspV'))); + item->SetTarget(this); + graphPU->ItemAt(0)->SetMarked(true); + item->SetTarget(this); + graphMF = new BMenuField(BRect(68, 264, 148, 278), "graphMF", "", graphPU); + graphMF->SetDivider(0); + graphBox->AddChild(graphMF); + gCurve->SetCurrent(8); break; } case 'RspR': - gCurve->SetCurrent (0); - gammaS->SetValue (gCurve->Gamma (0)); + gCurve->SetCurrent(0); + gammaS->SetValue(gCurve->Gamma(0)); break; case 'RspG': - gCurve->SetCurrent (1); - gammaS->SetValue (gCurve->Gamma (1)); + gCurve->SetCurrent(1); + gammaS->SetValue(gCurve->Gamma(1)); break; case 'RspB': - gCurve->SetCurrent (2); - gammaS->SetValue (gCurve->Gamma (2)); + gCurve->SetCurrent(2); + gammaS->SetValue(gCurve->Gamma(2)); break; case 'RspA': - gCurve->SetCurrent (3); - gammaS->SetValue (gCurve->Gamma (3)); + gCurve->SetCurrent(3); + gammaS->SetValue(gCurve->Gamma(3)); break; case 'CspC': - gCurve->SetCurrent (4); - gammaS->SetValue (gCurve->Gamma (4)); + gCurve->SetCurrent(4); + gammaS->SetValue(gCurve->Gamma(4)); break; case 'CspM': - gCurve->SetCurrent (5); - gammaS->SetValue (gCurve->Gamma (5)); + gCurve->SetCurrent(5); + gammaS->SetValue(gCurve->Gamma(5)); break; case 'CspY': - gCurve->SetCurrent (6); - gammaS->SetValue (gCurve->Gamma (6)); + gCurve->SetCurrent(6); + gammaS->SetValue(gCurve->Gamma(6)); break; case 'CspK': - gCurve->SetCurrent (7); - gammaS->SetValue (gCurve->Gamma (7)); + gCurve->SetCurrent(7); + gammaS->SetValue(gCurve->Gamma(7)); break; case 'HspH': - gCurve->SetCurrent (8); - gammaS->SetValue (gCurve->Gamma (8)); + gCurve->SetCurrent(8); + gammaS->SetValue(gCurve->Gamma(8)); break; case 'HspS': - gCurve->SetCurrent (9); - gammaS->SetValue (gCurve->Gamma (9)); + gCurve->SetCurrent(9); + gammaS->SetValue(gCurve->Gamma(9)); break; case 'HspV': - gCurve->SetCurrent (10); - gammaS->SetValue (gCurve->Gamma (10)); + gCurve->SetCurrent(10); + gammaS->SetValue(gCurve->Gamma(10)); break; case 'Tfre': - linesRB->SetEnabled (true); - smoothRB->SetEnabled (true); - addB->SetEnabled (gCurve && gCurve->NPoints() < MAX_POINTS - 1); - removeB->SetEnabled (gCurve && gCurve->NPoints() > 2); + linesRB->SetEnabled(true); + smoothRB->SetEnabled(true); + addB->SetEnabled(gCurve && gCurve->NPoints() < MAX_POINTS - 1); + removeB->SetEnabled(gCurve && gCurve->NPoints() > 2); if (linesRB->Value()) - gCurve->SetType (GT_STRAIGHT); + gCurve->SetType(GT_STRAIGHT); else - gCurve->SetType (GT_SMOOTH); + gCurve->SetType(GT_SMOOTH); break; case 'Tgam': - linesRB->SetEnabled (false); - smoothRB->SetEnabled (false); - addB->SetEnabled (false); - removeB->SetEnabled (false); - gCurve->SetType (GT_GAMMA); + linesRB->SetEnabled(false); + smoothRB->SetEnabled(false); + addB->SetEnabled(false); + removeB->SetEnabled(false); + gCurve->SetType(GT_GAMMA); break; case 'addP': if (gCurve) gCurve->AddPoint(); - addB->SetEnabled (gCurve && gCurve->NPoints() < MAX_POINTS - 1); - removeB->SetEnabled (gCurve && gCurve->NPoints() > 2); + addB->SetEnabled(gCurve && gCurve->NPoints() < MAX_POINTS - 1); + removeB->SetEnabled(gCurve && gCurve->NPoints() > 2); break; case 'delP': if (gCurve) gCurve->RemovePoint(); - addB->SetEnabled (gCurve && gCurve->NPoints() < MAX_POINTS - 1); - removeB->SetEnabled (gCurve && gCurve->NPoints() > 2); + addB->SetEnabled(gCurve && gCurve->NPoints() < MAX_POINTS - 1); + removeB->SetEnabled(gCurve && gCurve->NPoints() > 2); break; case 'Glin': if (gCurve) - gCurve->SetType (GT_STRAIGHT); + gCurve->SetType(GT_STRAIGHT); break; case 'Gfit': if (gCurve) - gCurve->SetType (GT_SMOOTH); + gCurve->SetType(GT_SMOOTH); break; case 'gamC': { - float gamma = msg->FindFloat ("value"); - gCurve->SetGamma (gamma); + float gamma = msg->FindFloat("value"); + gCurve->SetGamma(gamma); gCurve->FillTable(); addon_preview(); gCurve->Invalidate(); break; - } + } case 'gp2m': - gammaS->SetValue (MAC_GAMMA); - gCurve->SetGamma (MAC_GAMMA); + gammaS->SetValue(MAC_GAMMA); + gCurve->SetGamma(MAC_GAMMA); gCurve->FillTable(); addon_preview(); gCurve->Invalidate(); break; case 'gm2p': - gammaS->SetValue (1.0/MAC_GAMMA); - gCurve->SetGamma (1.0/MAC_GAMMA); + gammaS->SetValue(1.0 / MAC_GAMMA); + gCurve->SetGamma(1.0 / MAC_GAMMA); gCurve->FillTable(); addon_preview(); gCurve->Invalidate(); break; - default: - BView::MessageReceived (msg); - } + default: + BView::MessageReceived(msg); + } } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Color Curves"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1999-2001 ∑ Sum Software"); - strcpy (info->description, "Adjust Colors (gamma correction)"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 0; - info->release = 5; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = true; + strcpy(info->name, "Color Curves"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1999-2001 ∑ Sum Software"); + strcpy(info->description, "Adjust Colors (gamma correction)"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 0; + info->release = 5; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = true; return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - gView = new ColorCurvesView (rect); + gView = new ColorCurvesView(rect); *view = gView; return B_OK; } #define wct gCurve->wct -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /* frame */, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /* frame */, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); + *outSelection = new Selection(*inSelection); else return (0); } @@ -797,39 +814,33 @@ status_t process (Layer *inLayer, Selection *inSelection, if (*outSelection) (*outSelection)->Lock(); - int cspace = gView->cspacePU->IndexOf (gView->cspacePU->FindMarked()); -// printf ("cspace = %d\n", cspace); + int cspace = gView->cspacePU->IndexOf(gView->cspacePU->FindMarked()); + // printf ("cspace = %d\n", cspace); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits(); - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits(); + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. + float delta = 100.0 / h; // For the Status Bar. - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits(); - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits(); - - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits(); + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits(); + + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } @@ -837,84 +848,75 @@ status_t process (Layer *inLayer, Selection *inSelection, #if __INTEL__ // use faster asm version - if (!inSelection && (cspace == 0 || cspace == 3)) - { - uint32 table[4*256]; + if (!inSelection && (cspace == 0 || cspace == 3)) { + uint32 table[4 * 256]; // fill the table - for (uint32 t = 0; t < 256; t++) - { - table[t] = PIXEL (0, 0, 0, wct[3][t]); - table[t + 256] = PIXEL (wct[0][t], 0, 0, 0); - table[t + 512] = PIXEL (0, wct[1][t], 0, 0); - table[t + 768] = PIXEL (0, 0, wct[2][t], 0); + for (uint32 t = 0; t < 256; t++) { + table[t] = PIXEL(0, 0, 0, wct[3][t]); + table[t + 256] = PIXEL(wct[0][t], 0, 0, 0); + table[t + 512] = PIXEL(0, wct[1][t], 0, 0); + table[t + 768] = PIXEL(0, 0, wct[2][t], 0); } // printf ("("); fflush (stdout); - gamma_x86 (sbits, dbits, table, w*h); + gamma_x86(sbits, dbits, table, w * h); // printf (")"); fflush (stdout); - } - else - { + } else { #endif - for (uint32 x = 0; x < w; x++) - { - if (!inSelection || *(++mapbits)) - { - if (cspace == 0 || cspace == 3) // RGBA - { - bgra_pixel pixel = *(++sbits); - *(++dbits) = PIXEL (wct[0][RED (pixel)], wct[1][GREEN (pixel)], wct[2][BLUE (pixel)], wct[3][ALPHA (pixel)]); - } - else if (cspace == 1) // CMYK - { - uint32 p = *(++sbits); - cmyk_pixel pixel = bgra2cmyk (p); - bgra_pixel bgra = cmyk2bgra (PIXEL (wct[6][YELLOW (pixel)], wct[5][MAGENTA (pixel)], wct[4][CYAN (pixel)], wct[7][BLACK (pixel)])); - *(++dbits) = (bgra & COLOR_MASK) | (p & ALPHA_MASK); - } - else // HSV - { - uint32 p = *(++sbits); - hsv_color c = bgra2hsv (p); - c.hue = float (wct[8][int (c.hue/360.0*255)])*360/255; - c.saturation = float (wct[9][int (c.saturation*255)])/255.0; - c.value = float (wct[10][int (c.value*255)])/255.0; - *(++dbits) = (hsv2bgra (c) & COLOR_MASK) | (p & ALPHA_MASK); - } + for (uint32 x = 0; x < w; x++) { + if (!inSelection || *(++mapbits)) { + if (cspace == 0 || cspace == 3) // RGBA + { + bgra_pixel pixel = *(++sbits); + *(++dbits) = PIXEL( + wct[0][RED(pixel)], wct[1][GREEN(pixel)], wct[2][BLUE(pixel)], + wct[3][ALPHA(pixel)] + ); + } else if (cspace == 1) // CMYK + { + uint32 p = *(++sbits); + cmyk_pixel pixel = bgra2cmyk(p); + bgra_pixel bgra = cmyk2bgra(PIXEL( + wct[6][YELLOW(pixel)], wct[5][MAGENTA(pixel)], wct[4][CYAN(pixel)], + wct[7][BLACK(pixel)] + )); + *(++dbits) = (bgra & COLOR_MASK) | (p & ALPHA_MASK); + } else // HSV + { + uint32 p = *(++sbits); + hsv_color c = bgra2hsv(p); + c.hue = float(wct[8][int(c.hue / 360.0 * 255)]) * 360 / 255; + c.saturation = float(wct[9][int(c.saturation * 255)]) / 255.0; + c.value = float(wct[10][int(c.value * 255)]) / 255.0; + *(++dbits) = (hsv2bgra(c) & COLOR_MASK) | (p & ALPHA_MASK); + } + } else + *(++dbits) = *(++sbits); } - else - *(++dbits) = *(++sbits); + mapbits += mdiff; } - mapbits += mdiff; - } #if __INTEL__ } #endif break; } - case M_SELECT: - { + case M_SELECT: { if (!inSelection) *outSelection = NULL; - else - { - grey_pixel *sbits = mapbits; - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits(); - - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + else { + grey_pixel* sbits = mapbits; + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits(); + + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - sbits = (grey_pixel *) inSelection->Bits() + y*mbpr; - dbits = (grey_pixel *) (*outSelection)->Bits() + y*mbpr; - for (uint32 x = 0; x < w; x++) - { + sbits = (grey_pixel*)inSelection->Bits() + y * mbpr; + dbits = (grey_pixel*)(*outSelection)->Bits() + y * mbpr; + for (uint32 x = 0; x < w; x++) { *(++dbits) = *(++sbits); } } @@ -922,7 +924,7 @@ status_t process (Layer *inLayer, Selection *inSelection, break; } default: - fprintf (stderr, "Blur: Unknown mode\n"); + fprintf(stderr, "Blur: Unknown mode\n"); error = ADDON_UNKNOWN; } diff --git a/source/add-ons/Diffuse/Diffuse.cpp b/source/add-ons/Diffuse/Diffuse.cpp index 38ff41a..1aff1ac 100644 --- a/source/add-ons/Diffuse/Diffuse.cpp +++ b/source/add-ons/Diffuse/Diffuse.cpp @@ -12,116 +12,127 @@ // static uint32 rndval = 0; -int gX; -int gY; -int xvec[MAXRANDSIZE], yvec[MAXRANDSIZE]; +int gX; +int gY; +int xvec[MAXRANDSIZE], yvec[MAXRANDSIZE]; -void fillvectors (int x, int y) +void +fillvectors(int x, int y) { - for (int i = 0; i < MAXRANDSIZE; i++) - { - float r = float (i)/MAXRANDSIZE*4; - xvec[i] = int (x*exp (-r) * ((i & 1) ? 1 : -1)); - yvec[i] = int (y*exp (-r) * ((i & 1) ? 1 : -1)); + for (int i = 0; i < MAXRANDSIZE; i++) { + float r = float(i) / MAXRANDSIZE * 4; + xvec[i] = int(x * exp(-r) * ((i & 1) ? 1 : -1)); + yvec[i] = int(y * exp(-r) * ((i & 1) ? 1 : -1)); } } -int random (int max) +int +random(int max) { -// rndval = 1664525*rndval + 1013904223; - return (int) ((((double) rand())/RAND_MAX)*max); -// return (int)(((double) rndval)/RAND_MAX)*max/2; + // rndval = 1664525*rndval + 1013904223; + return (int)((((double)rand()) / RAND_MAX) * max); + // return (int)(((double) rndval)/RAND_MAX)*max/2; // A bit convoluted, but this is necessary on GCC because RAND_MAX is MAX_INT. } class DiffuseView : public BView { -public: - DiffuseView (BRect rect) : BView (rect, "diffuse_view", B_FOLLOW_ALL, B_WILL_DRAW) - { - gX = 5; - gY = 5; - ResizeTo (188, 48); - Slider *xSlid = new Slider (BRect (8, 8, 180, 24), 60, "x size", 1, MAXGBLURSIZE, 2, new BMessage ('gblX')); - Slider *ySlid = new Slider (BRect (8, 28, 180, 44), 60, "y size", 1, MAXGBLURSIZE, 2, new BMessage ('gblY')); - AddChild (xSlid); - AddChild (ySlid); - xSlid->SetValue (5); - ySlid->SetValue (5); - fillvectors (5, 5); - } -virtual ~DiffuseView () {} -virtual void MessageReceived (BMessage *msg) - { - switch (msg->what) - { - case 'gblX': - gX = int (msg->FindFloat ("value") + 0.5); - fillvectors (gX, gY); - break; - case 'gblY': - gY = int (msg->FindFloat ("value") + 0.5); - fillvectors (gX, gY); - break; - default: - BView::MessageReceived (msg); - return; - } - addon_preview(); - } + public: + DiffuseView(BRect rect) : BView(rect, "diffuse_view", B_FOLLOW_ALL, B_WILL_DRAW) + { + gX = 5; + gY = 5; + ResizeTo(188, 48); + Slider* xSlid = new Slider( + BRect(8, 8, 180, 24), 60, "x size", 1, MAXGBLURSIZE, 2, new BMessage('gblX') + ); + Slider* ySlid = new Slider( + BRect(8, 28, 180, 44), 60, "y size", 1, MAXGBLURSIZE, 2, new BMessage('gblY') + ); + AddChild(xSlid); + AddChild(ySlid); + xSlid->SetValue(5); + ySlid->SetValue(5); + fillvectors(5, 5); + } + + virtual ~DiffuseView() {} + + virtual void MessageReceived(BMessage* msg) + { + switch (msg->what) { + case 'gblX': + gX = int(msg->FindFloat("value") + 0.5); + fillvectors(gX, gY); + break; + case 'gblY': + gY = int(msg->FindFloat("value") + 0.5); + fillvectors(gX, gY); + break; + default: + BView::MessageReceived(msg); + return; + } + addon_preview(); + } }; -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Diffuse"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998-2001 ∑ Sum Software"); - strcpy (info->description, "Spreads the pixels randomly"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 1; - info->release = 2; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "Diffuse"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998-2001 ∑ Sum Software"); + strcpy(info->description, "Spreads the pixels randomly"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 1; + info->release = 2; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new DiffuseView (rect); + *view = new DiffuseView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /* frame */, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /* frame */, bool final, BPoint /* point */, uint32 /* buttons */ +) { - srand (0); + srand(0); int error = ADDON_OK; BRect bounds = inLayer->Bounds(); -// printf ("Bounds: "); -// bounds.PrintToStream(); -// printf ("Frame: "); -// frame->PrintToStream(); + // printf ("Bounds: "); + // bounds.PrintToStream(); + // printf ("Frame: "); + // frame->PrintToStream(); if (*outLayer == NULL && mode == M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to diffuse! + *outSelection = new Selection(*inSelection); + else // No Selection to diffuse! return (0); } if (*outLayer) @@ -130,96 +141,81 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { // printf ("inSelection\n"); - mapbits = (grey_pixel *) inSelection->Bits(); - mbpr = inSelection->BytesPerRow(); + mapbits = (grey_pixel*)inSelection->Bits(); + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - - float delta = 100.0/h; // For the Status Bar. - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (uint32 *) inLayer->Bits() - 1; - bgra_pixel *dbits = (uint32 *) (*outLayer)->Bits() - 1; - - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + + float delta = 100.0 / h; // For the Status Bar. + + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (uint32*)inLayer->Bits() - 1; + bgra_pixel* dbits = (uint32*)(*outLayer)->Bits() - 1; + + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { - if (!inSelection || *(++mapbits)) - { - int xspread = xvec[random (MAXRANDSIZE)]; - int yspread = yvec[random (MAXRANDSIZE)]; + for (uint32 x = 0; x < w; x++) { + if (!inSelection || *(++mapbits)) { + int xspread = xvec[random(MAXRANDSIZE)]; + int yspread = yvec[random(MAXRANDSIZE)]; if (x + xspread < 0 || x + xspread >= w) xspread = -xspread; if (y + yspread < 0 || y + yspread >= h) yspread = -yspread; - - //printf ("(%d, %d): (%d, %d)\n", x, y, xspread, yspread); - bgra_pixel *p = ++sbits + yspread*w + xspread; + + // printf ("(%d, %d): (%d, %d)\n", x, y, xspread, yspread); + bgra_pixel* p = ++sbits + yspread * w + xspread; *(++dbits) = *p; - } - else + } else *(++dbits) = *(++sbits); } mapbits += mdiff; } break; } - case M_SELECT: - { + case M_SELECT: { if (!inSelection) *outSelection = NULL; - else - { - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits() - 1; + else { + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits() - 1; int ddiff = (*outSelection)->BytesPerRow() - w; - grey_pixel *sbits = mapbits - 1; - //printf ("ddiff = %d, mdiff = %d\n", ddiff, mdiff); - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + grey_pixel* sbits = mapbits - 1; + // printf ("ddiff = %d, mdiff = %d\n", ddiff, mdiff); + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { - int xspread = xvec[random (MAXRANDSIZE)]; - int yspread = yvec[random (MAXRANDSIZE)]; + for (uint32 x = 0; x < w; x++) { + int xspread = xvec[random(MAXRANDSIZE)]; + int yspread = yvec[random(MAXRANDSIZE)]; if (x + xspread < 0 || x + xspread >= w) xspread = -xspread; if (y + yspread < 0 || y + yspread >= h) yspread = -yspread; - - //printf ("(%d, %d): (%d, %d)\n", x, y, xspread, yspread); - grey_pixel *p = ++sbits + yspread*mbpr + xspread; + + // printf ("(%d, %d): (%d, %d)\n", x, y, xspread, yspread); + grey_pixel* p = ++sbits + yspread * mbpr + xspread; *(++dbits) = *p; } sbits += mdiff; @@ -229,7 +225,7 @@ status_t process (Layer *inLayer, Selection *inSelection, break; } default: - fprintf (stderr, "Diffuse: Unknown mode\n"); + fprintf(stderr, "Diffuse: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -237,9 +233,9 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); - + if (final) addon_done(); - + return (error); } diff --git a/source/add-ons/Gaussian/Gaussian.cpp b/source/add-ons/Gaussian/Gaussian.cpp index df1aad9..bda4846 100644 --- a/source/add-ons/Gaussian/Gaussian.cpp +++ b/source/add-ons/Gaussian/Gaussian.cpp @@ -8,125 +8,134 @@ #include #define MAXGBLURSIZE 15 -#define GBLURRAD 7 // int (MAXGBLURSIZE/2) +#define GBLURRAD 7 // int (MAXGBLURSIZE/2) float matrix[MAXGBLURSIZE][MAXGBLURSIZE]; -int gX, gY; -void fillmatrix (int x, int y); +int gX, gY; +void +fillmatrix(int x, int y); class BlurView : public BView { -public: - BlurView (BRect rect); -virtual ~BlurView () {} -virtual void MessageReceived (BMessage *msg); + public: + BlurView(BRect rect); -private: -typedef BView inherited; + virtual ~BlurView() {} + + virtual void MessageReceived(BMessage* msg); + + private: + typedef BView inherited; }; -BlurView::BlurView (BRect rect) -: BView (rect, "blurview", B_FOLLOW_ALL, B_WILL_DRAW) +BlurView::BlurView(BRect rect) : BView(rect, "blurview", B_FOLLOW_ALL, B_WILL_DRAW) { - gX = 5; - gY = 5; - ResizeTo (Bounds().Width(), 50); - Slider *xSlid = new Slider (BRect (8, 8, 180, 24), 60, "x size", 1, MAXGBLURSIZE, 2, new BMessage ('gblX')); - Slider *ySlid = new Slider (BRect (8, 28, 180, 44), 60, "y size", 1, MAXGBLURSIZE, 2, new BMessage ('gblY')); - AddChild (xSlid); - AddChild (ySlid); - xSlid->SetValue (gX); - ySlid->SetValue (gY); + gX = 5; + gY = 5; + ResizeTo(Bounds().Width(), 50); + Slider* xSlid = + new Slider(BRect(8, 8, 180, 24), 60, "x size", 1, MAXGBLURSIZE, 2, new BMessage('gblX')); + Slider* ySlid = + new Slider(BRect(8, 28, 180, 44), 60, "y size", 1, MAXGBLURSIZE, 2, new BMessage('gblY')); + AddChild(xSlid); + AddChild(ySlid); + xSlid->SetValue(gX); + ySlid->SetValue(gY); } -void BlurView::MessageReceived (BMessage *msg) +void +BlurView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'gblX': - gX = int (msg->FindFloat ("value") + 0.5); - fillmatrix (gX, gY); + gX = int(msg->FindFloat("value") + 0.5); + fillmatrix(gX, gY); break; case 'gblY': - gY = int (msg->FindFloat ("value") + 0.5); - fillmatrix (gX, gY); + gY = int(msg->FindFloat("value") + 0.5); + fillmatrix(gX, gY); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); return; } addon_preview(); } -void fillmatrix (int x, int y) +void +fillmatrix(int x, int y) { float tmpmatrix[MAXGBLURSIZE][MAXGBLURSIZE]; float sum = 0; - + for (int i = 0; i < MAXGBLURSIZE; i++) - for (int j = 0; j < MAXGBLURSIZE; j++) - { - float rx = float (j - GBLURRAD)/(x/2.0); - float ry = float (i - GBLURRAD)/(y/2.0); - float rsq = (rx*rx + ry*ry); - tmpmatrix[i][j] = exp (-rsq); + for (int j = 0; j < MAXGBLURSIZE; j++) { + float rx = float(j - GBLURRAD) / (x / 2.0); + float ry = float(i - GBLURRAD) / (y / 2.0); + float rsq = (rx * rx + ry * ry); + tmpmatrix[i][j] = exp(-rsq); } - for (int i = -y/2; i <= y/2; i++) - for (int j = -x/2; j <= x/2; j++) + for (int i = -y / 2; i <= y / 2; i++) + for (int j = -x / 2; j <= x / 2; j++) sum += tmpmatrix[i + GBLURRAD][j + GBLURRAD]; for (int i = 0; i < MAXGBLURSIZE; i++) for (int j = 0; j < MAXGBLURSIZE; j++) - matrix[i][j] = tmpmatrix[i][j]/sum; + matrix[i][j] = tmpmatrix[i][j] / sum; } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Gaussian Blur"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998-2001 ∑ Sum Software"); - strcpy (info->description, "Applies a Gaussian blur"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 1; - info->release = 2; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; - fillmatrix (5, 5); + strcpy(info->name, "Gaussian Blur"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998-2001 ∑ Sum Software"); + strcpy(info->description, "Applies a Gaussian blur"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 1; + info->release = 2; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; + fillmatrix(5, 5); return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new BlurView (rect); + *view = new BlurView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /* frame */, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /* frame */, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to blur! + *outSelection = new Selection(*inSelection); + else // No Selection to blur! return (error); } if (*outLayer) @@ -135,207 +144,185 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - uint8 *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; + uint8* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; int sx = gX; int sy = gY; - if (inSelection) - { - mapbits = (uint8 *) inSelection->Bits() - 1; - mbpr = inSelection->BytesPerRow(); + if (inSelection) { + mapbits = (uint8*)inSelection->Bits() - 1; + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. - -// for (int i = -sy/2; i <= sy/2; i++) -// { -// for (int j = -sx/2; j <= sx/2; j++) -// { -// float v = matrix[i + GBLURRAD][j + GBLURRAD]; -// printf ("%3f ", w); -// } -// printf ("\n"); -// } -// printf ("\n"); - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *ibits = (bgra_pixel *) inLayer->Bits(); - uint32 ilpr = inLayer->BytesPerRow()/4; - + float delta = 100.0 / h; // For the Status Bar. + + // for (int i = -sy/2; i <= sy/2; i++) + // { + // for (int j = -sx/2; j <= sx/2; j++) + // { + // float v = matrix[i + GBLURRAD][j + GBLURRAD]; + // printf ("%3f ", w); + // } + // printf ("\n"); + // } + // printf ("\n"); + + switch (mode) { + case M_DRAW: { + bgra_pixel* ibits = (bgra_pixel*)inLayer->Bits(); + uint32 ilpr = inLayer->BytesPerRow() / 4; + // Allocate MAGBLURSIZE pixel rows with room for the "edges" (i.e. sx - 1 extra pixels) - bgra_pixel *rows[MAXGBLURSIZE]; + bgra_pixel* rows[MAXGBLURSIZE]; for (int i = 0; i < MAXGBLURSIZE; i++) - rows[i] = new bgra_pixel [w + sx - 1]; + rows[i] = new bgra_pixel[w + sx - 1]; - bgra_pixel *sbits = ibits - 1; - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits() - 1; + bgra_pixel* sbits = ibits - 1; + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits() - 1; // Copy the source into the buffer, "folding" the edges around. - for (int i = -sy/2; i <= sy/2; i++) - { - memcpy (rows[GBLURRAD + i] + sx/2, ibits + abs(i)*ilpr, ilpr*4); - for (int j = -sx/2; j < 0; j++) - { - rows[GBLURRAD + i][sx/2 + j] = rows[GBLURRAD + i][sx/2 - j]; - rows[GBLURRAD + i][w + sx/2 - j - 1] = rows[GBLURRAD + i][w + sx/2 + j - 1]; + for (int i = -sy / 2; i <= sy / 2; i++) { + memcpy(rows[GBLURRAD + i] + sx / 2, ibits + abs(i) * ilpr, ilpr * 4); + for (int j = -sx / 2; j < 0; j++) { + rows[GBLURRAD + i][sx / 2 + j] = rows[GBLURRAD + i][sx / 2 - j]; + rows[GBLURRAD + i][w + sx / 2 - j - 1] = rows[GBLURRAD + i][w + sx / 2 + j - 1]; } } - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - bgra_pixel *tmp = rows[0]; + bgra_pixel* tmp = rows[0]; for (int i = 1; i < MAXGBLURSIZE; i++) rows[i - 1] = rows[i]; rows[MAXGBLURSIZE - 1] = tmp; - if (y >= h - sy/2 - 1 && y < h) - { - memcpy (rows[GBLURRAD + sy/2] + sx/2, ibits + (2*(h - 1) - (y + sy/2))*ilpr, ilpr*4); - for (int j = -sx/2; j < 0; j++) - { - rows[GBLURRAD + sy/2][sx/2 + j] = rows[GBLURRAD + sy/2][sx/2 - j]; - rows[GBLURRAD + sy/2][w + sx/2 - j - 1] = rows[GBLURRAD + sy/2][w + sx/2 + j - 1]; + if (y >= h - sy / 2 - 1 && y < h) { + memcpy( + rows[GBLURRAD + sy / 2] + sx / 2, ibits + (2 * (h - 1) - (y + sy / 2)) * ilpr, + ilpr * 4 + ); + for (int j = -sx / 2; j < 0; j++) { + rows[GBLURRAD + sy / 2][sx / 2 + j] = rows[GBLURRAD + sy / 2][sx / 2 - j]; + rows[GBLURRAD + sy / 2][w + sx / 2 - j - 1] = + rows[GBLURRAD + sy / 2][w + sx / 2 + j - 1]; } - } - else if (y < h) - { - memcpy (rows[GBLURRAD + sy/2] + sx/2, ibits + (y + sy/2)*ilpr, ilpr*4); - for (int j = -sx/2; j < 0; j++) - { - rows[GBLURRAD + sy/2][sx/2 + j] = rows[GBLURRAD + sy/2][sx/2 - j]; - rows[GBLURRAD + sy/2][w + sx/2 - j - 1] = rows[GBLURRAD + sy/2][w + sx/2 + j - 1]; + } else if (y < h) { + memcpy(rows[GBLURRAD + sy / 2] + sx / 2, ibits + (y + sy / 2) * ilpr, ilpr * 4); + for (int j = -sx / 2; j < 0; j++) { + rows[GBLURRAD + sy / 2][sx / 2 + j] = rows[GBLURRAD + sy / 2][sx / 2 - j]; + rows[GBLURRAD + sy / 2][w + sx / 2 - j - 1] = + rows[GBLURRAD + sy / 2][w + sx / 2 + j - 1]; } } - for (uint32 x = 0; x < w; x++) - { - if (!inSelection || *(++mapbits)) - { + for (uint32 x = 0; x < w; x++) { + if (!inSelection || *(++mapbits)) { float wr = 0; float wg = 0; float wb = 0; float wa = 0; sbits++; - for (int i = -sy/2; i <= sy/2; i++) - { - bgra_pixel *b = rows[GBLURRAD + i] + x - 1; - for (int j = -sx/2; j <= sx/2; j++) - { + for (int i = -sy / 2; i <= sy / 2; i++) { + bgra_pixel* b = rows[GBLURRAD + i] + x - 1; + for (int j = -sx / 2; j <= sx / 2; j++) { bgra_pixel p = *(++b); float v = matrix[i + GBLURRAD][j + GBLURRAD]; - wb += v*BLUE(p); - wg += v*GREEN(p); - wr += v*RED(p); - wa += v*ALPHA(p); + wb += v * BLUE(p); + wg += v * GREEN(p); + wr += v * RED(p); + wa += v * ALPHA(p); } } - *(++dbits) = PIXEL (wr, wg, wb, wa); - } - else + *(++dbits) = PIXEL(wr, wg, wb, wa); + } else *(++dbits) = *(++sbits); } mapbits += mdiff; } for (int i = 0; i < MAXGBLURSIZE; i++) - delete [] rows[i]; + delete[] rows[i]; break; } - case M_SELECT: - { - grey_pixel *ibits = (grey_pixel *) inSelection->Bits(); - uint32 ibpr = inSelection->BytesPerRow(); - uint32 odiff = (*outSelection)->BytesPerRow() - w; + case M_SELECT: { + grey_pixel* ibits = (grey_pixel*)inSelection->Bits(); + uint32 ibpr = inSelection->BytesPerRow(); + uint32 odiff = (*outSelection)->BytesPerRow() - w; // Allocate MAGBLURSIZE pixel rows with room for the "edges" (i.e. sx - 1 extra pixels) - grey_pixel *rows[MAXGBLURSIZE]; + grey_pixel* rows[MAXGBLURSIZE]; for (int i = 0; i < MAXGBLURSIZE; i++) - rows[i] = new grey_pixel [ibpr + sx - 1]; + rows[i] = new grey_pixel[ibpr + sx - 1]; - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits() - 1; + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits() - 1; // Copy the source into the buffer, "folding" the edges around. - for (int i = -sy/2; i <= sy/2; i++) - { - memcpy (rows[GBLURRAD + i] + sx/2, ibits + abs(i)*ibpr, ibpr); - for (int j = -sx/2; j < 0; j++) - { - rows[GBLURRAD + i][sx/2 + j] = rows[GBLURRAD + i][sx/2 - j]; - rows[GBLURRAD + i][w + sx/2 - j - 1] = rows[GBLURRAD + i][w + sx/2 + j - 1]; + for (int i = -sy / 2; i <= sy / 2; i++) { + memcpy(rows[GBLURRAD + i] + sx / 2, ibits + abs(i) * ibpr, ibpr); + for (int j = -sx / 2; j < 0; j++) { + rows[GBLURRAD + i][sx / 2 + j] = rows[GBLURRAD + i][sx / 2 - j]; + rows[GBLURRAD + i][w + sx / 2 - j - 1] = rows[GBLURRAD + i][w + sx / 2 + j - 1]; } } - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - grey_pixel *tmp = rows[0]; + grey_pixel* tmp = rows[0]; for (int i = 1; i < MAXGBLURSIZE; i++) rows[i - 1] = rows[i]; rows[MAXGBLURSIZE - 1] = tmp; - if (y >= h - sy/2 - 1 && y < h) - { - memcpy (rows[GBLURRAD + sy/2] + sx/2, ibits + (2*(h - 1) - (y + sy/2))*ibpr, ibpr); - for (int j = -sx/2; j < 0; j++) - { - rows[GBLURRAD + sy/2][sx/2 + j] = rows[GBLURRAD + sy/2][sx/2 - j]; - rows[GBLURRAD + sy/2][w + sx/2 - j - 1] = rows[GBLURRAD + sy/2][w + sx/2 + j - 1]; + if (y >= h - sy / 2 - 1 && y < h) { + memcpy( + rows[GBLURRAD + sy / 2] + sx / 2, ibits + (2 * (h - 1) - (y + sy / 2)) * ibpr, + ibpr + ); + for (int j = -sx / 2; j < 0; j++) { + rows[GBLURRAD + sy / 2][sx / 2 + j] = rows[GBLURRAD + sy / 2][sx / 2 - j]; + rows[GBLURRAD + sy / 2][w + sx / 2 - j - 1] = + rows[GBLURRAD + sy / 2][w + sx / 2 + j - 1]; } - } - else if (y < h) - { - memcpy (rows[GBLURRAD + sy/2] + sx/2, ibits + (y + sy/2)*ibpr, ibpr); - for (int j = -sx/2; j < 0; j++) - { - rows[GBLURRAD + sy/2][sx/2 + j] = rows[GBLURRAD + sy/2][sx/2 - j]; - rows[GBLURRAD + sy/2][w + sx/2 - j - 1] = rows[GBLURRAD + sy/2][w + sx/2 + j - 1]; + } else if (y < h) { + memcpy(rows[GBLURRAD + sy / 2] + sx / 2, ibits + (y + sy / 2) * ibpr, ibpr); + for (int j = -sx / 2; j < 0; j++) { + rows[GBLURRAD + sy / 2][sx / 2 + j] = rows[GBLURRAD + sy / 2][sx / 2 - j]; + rows[GBLURRAD + sy / 2][w + sx / 2 - j - 1] = + rows[GBLURRAD + sy / 2][w + sx / 2 + j - 1]; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { float wa = 0; - for (int i = -sy/2; i <= sy/2; i++) - { - grey_pixel *b = rows[GBLURRAD + i] + x - 1; - for (int j = -sx/2; j <= sx/2; j++) - { + for (int i = -sy / 2; i <= sy / 2; i++) { + grey_pixel* b = rows[GBLURRAD + i] + x - 1; + for (int j = -sx / 2; j <= sx / 2; j++) { grey_pixel p = *(++b); float v = matrix[i + GBLURRAD][j + GBLURRAD]; - wa += v*p; + wa += v * p; } } - *(++dbits) = uchar (wa); + *(++dbits) = uchar(wa); } dbits += odiff; } for (int i = 0; i < MAXGBLURSIZE; i++) - delete [] rows[i]; + delete[] rows[i]; break; } default: - fprintf (stderr, "Blur: Unknown mode\n"); + fprintf(stderr, "Blur: Unknown mode\n"); error = ADDON_UNKNOWN; } diff --git a/source/add-ons/Gradient/Gradient.cpp b/source/add-ons/Gradient/Gradient.cpp index a9e9629..f3e187d 100644 --- a/source/add-ons/Gradient/Gradient.cpp +++ b/source/add-ons/Gradient/Gradient.cpp @@ -7,48 +7,54 @@ #include #include -#define G_LINEAR 1 +#define G_LINEAR 1 #define G_CIRCULAR 2 -#define G_COSINE 3 +#define G_COSINE 3 -int gOrientation; -int gSlope; +int gOrientation; +int gSlope; class GradientView : public BView { -public: - GradientView (BRect rect) : BView (rect, "gradient_view", B_FOLLOW_ALL, B_WILL_DRAW) - { - gOrientation = G_LINEAR; - gSlope = G_LINEAR; - ResizeTo (188, 138); - BBox *orientation = new BBox (BRect (4, 4, 184, 58), "orientation"); - orientation->SetLabel ("Orientation"); - AddChild (orientation); - BRadioButton *oLinear = new BRadioButton (BRect (8, 13, 164, 30), "lin", "Linear", new BMessage ('groL')); - BRadioButton *oCircular = new BRadioButton (BRect (8, 30, 164, 47), "circ", "Circular", new BMessage ('groC')); - orientation->AddChild (oLinear); - orientation->AddChild (oCircular); - oLinear->SetValue (true); - BBox *slope = new BBox (BRect (4, 64, 184, 134), "slope"); - slope->SetLabel ("Slope"); - AddChild (slope); - BRadioButton *sLinear = new BRadioButton (BRect (8, 13, 164, 30), "slin", "Linear", new BMessage ('grsL')); - BRadioButton *sCosine = new BRadioButton (BRect (8, 30, 164, 47), "scos", "Half Cosine", new BMessage ('grsS')); - BRadioButton *sCircular = new BRadioButton (BRect (8, 47, 164, 64), "scirc", "Circle Arc", new BMessage ('grsC')); - slope->AddChild (sLinear); - slope->AddChild (sCosine); - slope->AddChild (sCircular); - sLinear->SetValue (true); - }; -virtual ~GradientView () {}; -virtual void MessageReceived (BMessage *msg); + public: + GradientView(BRect rect) : BView(rect, "gradient_view", B_FOLLOW_ALL, B_WILL_DRAW) + { + gOrientation = G_LINEAR; + gSlope = G_LINEAR; + ResizeTo(188, 138); + BBox* orientation = new BBox(BRect(4, 4, 184, 58), "orientation"); + orientation->SetLabel("Orientation"); + AddChild(orientation); + BRadioButton* oLinear = + new BRadioButton(BRect(8, 13, 164, 30), "lin", "Linear", new BMessage('groL')); + BRadioButton* oCircular = + new BRadioButton(BRect(8, 30, 164, 47), "circ", "Circular", new BMessage('groC')); + orientation->AddChild(oLinear); + orientation->AddChild(oCircular); + oLinear->SetValue(true); + BBox* slope = new BBox(BRect(4, 64, 184, 134), "slope"); + slope->SetLabel("Slope"); + AddChild(slope); + BRadioButton* sLinear = + new BRadioButton(BRect(8, 13, 164, 30), "slin", "Linear", new BMessage('grsL')); + BRadioButton* sCosine = + new BRadioButton(BRect(8, 30, 164, 47), "scos", "Half Cosine", new BMessage('grsS')); + BRadioButton* sCircular = + new BRadioButton(BRect(8, 47, 164, 64), "scirc", "Circle Arc", new BMessage('grsC')); + slope->AddChild(sLinear); + slope->AddChild(sCosine); + slope->AddChild(sCircular); + sLinear->SetValue(true); + }; + + virtual ~GradientView(){}; + virtual void MessageReceived(BMessage* msg); }; -void GradientView::MessageReceived (BMessage *msg) +void +GradientView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'groL': gOrientation = G_LINEAR; break; @@ -65,60 +71,66 @@ void GradientView::MessageReceived (BMessage *msg) gSlope = G_CIRCULAR; break; default: - BView::MessageReceived (msg); + BView::MessageReceived(msg); return; } addon_preview(); } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Gradient"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998-2001 ∑ Sum Software"); - strcpy (info->description, "Generates a color gradient"); - info->type = BECASSO_GENERATOR; - info->index = index; - info->version = 1; - info->release = 3; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE | PREVIEW_MOUSE; - info->flags = 0; + strcpy(info->name, "Gradient"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998-2001 ∑ Sum Software"); + strcpy(info->description, "Generates a color gradient"); + info->type = BECASSO_GENERATOR; + info->index = index; + info->version = 1; + info->release = 3; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE | PREVIEW_MOUSE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new GradientView (rect); + *view = new GradientView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /* frame */, bool final, BPoint point, uint32 buttons) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /* frame */, bool final, BPoint point, uint32 buttons +) { - static BPoint firstpoint = BPoint (-1, -1); - static BPoint lastpoint = BPoint (-1, -1); + static BPoint firstpoint = BPoint(-1, -1); + static BPoint lastpoint = BPoint(-1, -1); static bool entry = false; - - if (!final && buttons && !entry) // First entry of a realtime drag + + if (!final && buttons && !entry) // First entry of a realtime drag { firstpoint = point; entry = true; return (ADDON_OK); } - if (!final && !buttons) // Exit a realtime drag (buttons released) + if (!final && !buttons) // Exit a realtime drag (buttons released) { entry = false; } @@ -127,10 +139,10 @@ status_t process (Layer *inLayer, Selection *inSelection, int error = ADDON_OK; BRect bounds = inLayer->Bounds(); if (*outLayer == NULL && mode == M_DRAW) - *outLayer = new Layer (*inLayer); - + *outLayer = new Layer(*inLayer); + if (*outSelection == NULL && mode == M_SELECT) - *outSelection = new Selection (inLayer->Bounds()); + *outSelection = new Selection(inLayer->Bounds()); if (*outLayer) (*outLayer)->Lock(); @@ -138,194 +150,171 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits() - 1; - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits() - 1; + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. - + float delta = 100.0 / h; // For the Status Bar. + rgb_color hi = highcolor(); rgb_color lo = lowcolor(); float vx = lastpoint.x - firstpoint.x; float vy = lastpoint.y - firstpoint.y; - float d = hypot (vx, vy); + float d = hypot(vx, vy); if (d < 1) d = 1; - float nx = vy/d; - float ny = -vx/d; + float nx = vy / d; + float ny = -vx / d; - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (uint32 *) inLayer->Bits() - 1; - bgra_pixel *dbits = (uint32 *) (*outLayer)->Bits() - 1; - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (uint32*)inLayer->Bits() - 1; + bgra_pixel* dbits = (uint32*)(*outLayer)->Bits() - 1; + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { uint8 val = 0; float dist = 0; - switch (gOrientation) - { - case G_LINEAR: - { - float f = ((x - firstpoint.x)*nx + (y - firstpoint.y)*ny); - float cx = firstpoint.x + f*nx; - float cy = firstpoint.y + f*ny; - dist = hypot (x - cx, y - cy); - if ((x - cx)*vx < 0 || (y - cy)*vy < 0) + switch (gOrientation) { + case G_LINEAR: { + float f = ((x - firstpoint.x) * nx + (y - firstpoint.y) * ny); + float cx = firstpoint.x + f * nx; + float cy = firstpoint.y + f * ny; + dist = hypot(x - cx, y - cy); + if ((x - cx) * vx < 0 || (y - cy) * vy < 0) dist = 0; break; } case G_CIRCULAR: - dist = hypot (firstpoint.x - x, firstpoint.y - y); + dist = hypot(firstpoint.x - x, firstpoint.y - y); break; default: - printf ("Huu!\n"); + printf("Huu!\n"); break; } if (dist > d) dist = d; if (dist < 0) dist = 0; - switch (gSlope) - { + switch (gSlope) { case G_LINEAR: - val = grey_pixel (255*dist/d); + val = grey_pixel(255 * dist / d); break; case G_CIRCULAR: - val = grey_pixel (255 - 255*sqrt (1 - dist*dist/(d*d))); + val = grey_pixel(255 - 255 * sqrt(1 - dist * dist / (d * d))); break; case G_COSINE: - val = grey_pixel (255 - 127.5*(cos (M_PI*dist/d) + 1)); + val = grey_pixel(255 - 127.5 * (cos(M_PI * dist / d) + 1)); break; default: - printf ("Huu!\n"); + printf("Huu!\n"); break; } - bgra_pixel pixel = weighted_average_rgb (lo, val, hi, 255 - val) & COLOR_MASK; - if (inSelection) - { - *(++dbits) = pixelblend (*(++sbits), (pixel | (*(++mapbits) << ALPHA_BPOS))); - } - else - { + bgra_pixel pixel = weighted_average_rgb(lo, val, hi, 255 - val) & COLOR_MASK; + if (inSelection) { + *(++dbits) = pixelblend(*(++sbits), (pixel | (*(++mapbits) << ALPHA_BPOS))); + } else { *(++dbits) = pixel | ALPHA_MASK; sbits++; } } mapbits += mdiff; } - if (*outLayer && buttons) - { - BView *view = new BView (inLayer->Bounds(), "tmp view", 0, 0); - (*outLayer)->AddChild (view); - view->SetHighColor (contrastingcolor (hi, lo)); - view->StrokeLine (firstpoint, lastpoint); + if (*outLayer && buttons) { + BView* view = new BView(inLayer->Bounds(), "tmp view", 0, 0); + (*outLayer)->AddChild(view); + view->SetHighColor(contrastingcolor(hi, lo)); + view->StrokeLine(firstpoint, lastpoint); view->Sync(); - (*outLayer)->RemoveChild (view); + (*outLayer)->RemoveChild(view); delete view; } break; } - case M_SELECT: - { - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + case M_SELECT: { + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - grey_pixel *sbits = 0; + grey_pixel* sbits = 0; if (inSelection) - sbits = (grey_pixel *) inSelection->Bits() + y*mbpr - 1; - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits() + y*mbpr - 1; - for (uint32 x = 0; x < w; x++) - { + sbits = (grey_pixel*)inSelection->Bits() + y * mbpr - 1; + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits() + y * mbpr - 1; + for (uint32 x = 0; x < w; x++) { uint8 val = 0; float dist = 0; - switch (gOrientation) - { - case G_LINEAR: - { - float f = ((x - firstpoint.x)*nx + (y - firstpoint.y)*ny); - float cx = firstpoint.x + f*nx; - float cy = firstpoint.y + f*ny; - dist = hypot (x - cx, y - cy); - if ((x - cx)*vx < 0 || (y - cy)*vy < 0) + switch (gOrientation) { + case G_LINEAR: { + float f = ((x - firstpoint.x) * nx + (y - firstpoint.y) * ny); + float cx = firstpoint.x + f * nx; + float cy = firstpoint.y + f * ny; + dist = hypot(x - cx, y - cy); + if ((x - cx) * vx < 0 || (y - cy) * vy < 0) dist = 0; break; } case G_CIRCULAR: - dist = hypot (firstpoint.x - x, firstpoint.y - y); + dist = hypot(firstpoint.x - x, firstpoint.y - y); break; default: - printf ("Huu!\n"); + printf("Huu!\n"); break; } if (dist > d) dist = d; if (dist < 0) dist = 0; - switch (gSlope) - { + switch (gSlope) { case G_LINEAR: - val = grey_pixel (255 - 255*dist/d); + val = grey_pixel(255 - 255 * dist / d); break; case G_CIRCULAR: - val = grey_pixel (255*sqrt (1 - dist*dist/(d*d))); + val = grey_pixel(255 * sqrt(1 - dist * dist / (d * d))); break; case G_COSINE: - val = grey_pixel (127.5*(cos (M_PI*dist/d) + 1)); + val = grey_pixel(127.5 * (cos(M_PI * dist / d) + 1)); break; default: - printf ("Huu!\n"); + printf("Huu!\n"); break; } if (inSelection) - *(++dbits) = val*(*(++sbits))/255; + *(++dbits) = val * (*(++sbits)) / 255; else *(++dbits) = val; } } - if (*outSelection && buttons) - { - BView *view = new BView (inLayer->Bounds(), "tmp view", 0, 0); - (*outSelection)->AddChild (view); - view->SetHighColor (Black); - view->StrokeLine (firstpoint, lastpoint); + if (*outSelection && buttons) { + BView* view = new BView(inLayer->Bounds(), "tmp view", 0, 0); + (*outSelection)->AddChild(view); + view->SetHighColor(Black); + view->StrokeLine(firstpoint, lastpoint); view->Sync(); - (*outSelection)->RemoveChild (view); + (*outSelection)->RemoveChild(view); delete view; } break; } default: - fprintf (stderr, "Gradient: Unknown mode\n"); + fprintf(stderr, "Gradient: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -336,6 +325,6 @@ status_t process (Layer *inLayer, Selection *inSelection, if (final) addon_done(); - + return (error); } diff --git a/source/add-ons/ImageElements/ImageElements.cpp b/source/add-ons/ImageElements/ImageElements.cpp index 7e6cb63..b85f8cc 100644 --- a/source/add-ons/ImageElements/ImageElements.cpp +++ b/source/add-ons/ImageElements/ImageElements.cpp @@ -10,121 +10,122 @@ class IEWindow : public AddOnWindow { -public: - IEWindow (BRect rect, becasso_addon_info *info) : AddOnWindow (rect, info) - { - }; -virtual ~IEWindow () {}; -virtual void MessageReceived (BMessage *msg); -private: -typedef AddOnWindow inherited; + public: + IEWindow(BRect rect, becasso_addon_info* info) : AddOnWindow(rect, info){}; + virtual ~IEWindow(){}; + virtual void MessageReceived(BMessage* msg); + + private: + typedef AddOnWindow inherited; }; -void IEWindow::MessageReceived (BMessage *msg) +void +IEWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); return; } // aPreview(); } -IEWindow *window; +IEWindow* window; -int addon_init (uint32 index, becasso_addon_info *info) +int +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "IE Network"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998 ∑ Sum Software"); - strcpy (info->description, "Bridge between Becasso and Image Elements by Attila Mezei"); - info->type = BECASSO_TRANSFORMER; - info->index = index; - info->version = 0; - info->release = 2; - info->becasso_version = 1; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - window = new IEWindow (BRect (100, 180, 100 + 188, 180 + 116), info); + strcpy(info->name, "IE Network"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998 ∑ Sum Software"); + strcpy(info->description, "Bridge between Becasso and Image Elements by Attila Mezei"); + info->type = BECASSO_TRANSFORMER; + info->index = index; + info->version = 0; + info->release = 2; + info->becasso_version = 1; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + window = new IEWindow(BRect(100, 180, 100 + 188, 180 + 116), info); window->Run(); return (0); } -int addon_exit (void) +int +addon_exit(void) { return (0); } -int addon_open (BWindow *client, const char *name) +int +addon_open(BWindow* client, const char* name) { char title[B_FILE_NAME_LENGTH]; - sprintf (title, "ImageElements %s", name); + sprintf(title, "ImageElements %s", name); window->Lock(); - window->SetTitle (title); + window->SetTitle(title); if (window->IsHidden()) - window->aShow (client); + window->aShow(client); else - window->aActivate (client); + window->aActivate(client); window->Unlock(); return (0); } -int addon_close () +int +addon_close() { window->aClose(); return (0); } -int process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect *frame, bool /* final */, BPoint /* point */, uint32 buttons) +int +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* frame, bool /* final */, BPoint /* point */, uint32 buttons +) { int error = ADDON_OK; -// BRect bounds = inLayer->Bounds(); - -// if (*outLayer == NULL && mode== M_DRAW) -// *outLayer = new Layer (*inLayer); - -// if (mode == M_SELECT) -// { -// if (inSelection) -// *outSelection = new Selection (*inSelection); -// else // No Selection to translate! -// return (error); -// } - + // BRect bounds = inLayer->Bounds(); + + // if (*outLayer == NULL && mode== M_DRAW) + // *outLayer = new Layer (*inLayer); + + // if (mode == M_SELECT) + // { + // if (inSelection) + // *outSelection = new Selection (*inSelection); + // else // No Selection to translate! + // return (error); + // } + BRect oldrect = *frame; BRect newrect = oldrect; - -// if (*outLayer) -// (*outLayer)->Lock(); -// if (*outSelection) -// (*outSelection)->Lock(); - - switch (mode) - { - case M_DRAW: - { - printf ("Shouting!\n"); - system ("hey ImageElements set IsActive of Window Untitled-1 to true"); + + // if (*outLayer) + // (*outLayer)->Lock(); + // if (*outSelection) + // (*outSelection)->Lock(); + + switch (mode) { + case M_DRAW: { + printf("Shouting!\n"); + system("hey ImageElements set IsActive of Window Untitled-1 to true"); break; } - case M_SELECT: - { + case M_SELECT: { break; } default: - fprintf (stderr, "Translate: Unknown mode\n"); + fprintf(stderr, "Translate: Unknown mode\n"); error = 1; } -// if (*outSelection) -// (*outSelection)->Unlock(); -// if (*outLayer) -// (*outLayer)->Unlock(); + // if (*outSelection) + // (*outSelection)->Unlock(); + // if (*outLayer) + // (*outLayer)->Unlock(); *frame = newrect; return (error); } - diff --git a/source/add-ons/Jim/Jim.cpp b/source/add-ons/Jim/Jim.cpp index 55bc09f..ad0d5e6 100644 --- a/source/add-ons/Jim/Jim.cpp +++ b/source/add-ons/Jim/Jim.cpp @@ -1,115 +1,128 @@ // © 1998 Sum Software #include "BecassoAddOn.h" -//#include "ScannerBe.h" + +// #include "ScannerBe.h" class CaptureWindow : public BWindow { -public: - CaptureWindow (BRect rect) : BWindow (rect, "Capture Test", -B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | -B_WILL_ACCEPT_FIRST_CLICK) {}; -virtual ~CaptureWindow () {}; -virtual bool QuitRequested () { Hide(); return false; }; + public: + CaptureWindow(BRect rect) + : BWindow( + rect, "Capture Test", B_TITLED_WINDOW, + B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK + ){}; + virtual ~CaptureWindow(){}; + + virtual bool QuitRequested() + { + Hide(); + return false; + }; }; -CaptureWindow *window; +CaptureWindow* window; -class ClickWatcher : public BLooper { -public: -virtual void MessageReceived( BMessage *msg ); +class ClickWatcher : public BLooper +{ + public: + virtual void MessageReceived(BMessage* msg); }; const uint32 kTriggerScan = 'trig'; -static bool gBeScanOpen = false; -//static scan_id gScanID = 0; -static ClickWatcher *gClickWatch = NULL; - +static bool gBeScanOpen = false; +// static scan_id gScanID = 0; +static ClickWatcher* gClickWatch = NULL; -int addon_init (uint32 index, becasso_addon_info *info) +int +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Jim"); - strcpy (info->author, "Jim Moy"); - strcpy (info->copyright, "© 1997 Jim Moy"); - strcpy (info->description, "Fake Capture add-on"); - info->type = BECASSO_CAPTURE; - info->index = index; - info->version = 1; - info->release = 0; - info->becasso_version = 1; - info->becasso_release = 0; - info->does_preview = true; -// window = new CaptureWindow (BRect (100, 180, 100 + 188, 180 + 72)); -// BView *bg = new BView (BRect (0, 0, 188, 72), "bg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); -// bg->SetViewColor (LightGrey); -// window->AddChild (bg); -// BMessage *msg = new BMessage (CAPTURE_READY); -// msg->AddInt32 ("index", index); -// BButton *grab = new BButton (BRect (128, 40, 180, 64), "grab", "Grab", msg); -// grab->SetTarget (be_app); -// bg->AddChild (grab); -// window->Run(); + strcpy(info->name, "Jim"); + strcpy(info->author, "Jim Moy"); + strcpy(info->copyright, "© 1997 Jim Moy"); + strcpy(info->description, "Fake Capture add-on"); + info->type = BECASSO_CAPTURE; + info->index = index; + info->version = 1; + info->release = 0; + info->becasso_version = 1; + info->becasso_release = 0; + info->does_preview = true; + // window = new CaptureWindow (BRect (100, 180, 100 + 188, 180 + 72)); + // BView *bg = new BView (BRect (0, 0, 188, 72), "bg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); + // bg->SetViewColor (LightGrey); + // window->AddChild (bg); + // BMessage *msg = new BMessage (CAPTURE_READY); + // msg->AddInt32 ("index", index); + // BButton *grab = new BButton (BRect (128, 40, 180, 64), "grab", "Grab", msg); + // grab->SetTarget (be_app); + // bg->AddChild (grab); + // window->Run(); gClickWatch = new ClickWatcher; gClickWatch->Run(); return (0); } -int addon_exit (void) +int +addon_exit(void) { return (0); } -int addon_open (BWindow *, const char *) +int +addon_open(BWindow*, const char*) { -// window->Lock(); -// if (window->IsHidden()) -// window->Show (); -// else -// window->Activate (); -// window->Unlock(); - printf ("Posting kTriggerScan\n"); - gClickWatch->PostMessage( kTriggerScan ); + // window->Lock(); + // if (window->IsHidden()) + // window->Show (); + // else + // window->Activate (); + // window->Unlock(); + printf("Posting kTriggerScan\n"); + gClickWatch->PostMessage(kTriggerScan); return (0); } -int addon_close () +int +addon_close() { -// window->Close(); + // window->Close(); return (0); } -BBitmap *bitmap (char *title) +BBitmap* +bitmap(char* title) { - printf ("Here!\n"); - strcpy (title, "Grabbed"); - BBitmap *b = new BBitmap (BRect (0, 0, 127, 127), B_RGB_32_BIT, true); - BView *v = new BView (BRect (0, 0, 127, 127), "bg", NULL, NULL); + printf("Here!\n"); + strcpy(title, "Grabbed"); + BBitmap* b = new BBitmap(BRect(0, 0, 127, 127), B_RGB_32_BIT, true); + BView* v = new BView(BRect(0, 0, 127, 127), "bg", NULL, NULL); b->Lock(); - b->AddChild (v); - v->FillRect (BRect (0, 0, 127, 127), B_MIXED_COLORS); + b->AddChild(v); + v->FillRect(BRect(0, 0, 127, 127), B_MIXED_COLORS); v->Sync(); - b->RemoveChild (v); + b->RemoveChild(v); b->Unlock(); delete v; return b; } -void ClickWatcher::MessageReceived( BMessage *msg ) +void +ClickWatcher::MessageReceived(BMessage* msg) { - if( msg->what != kTriggerScan ) { - BLooper::MessageReceived( msg ); + if (msg->what != kTriggerScan) { + BLooper::MessageReceived(msg); return; } - printf( "before scan_start()\n" ); -//fflush( stdout ); + printf("before scan_start()\n"); + // fflush( stdout ); status_t status = B_OK; -// status = scan_start( gScanID ); - if( status == B_OK ) - be_app->PostMessage( CAPTURE_READY ); - - printf( "after scan_start() (0x%X)\n", status ); -//fflush( stdout ); + // status = scan_start( gScanID ); + if (status == B_OK) + be_app->PostMessage(CAPTURE_READY); + printf("after scan_start() (0x%X)\n", status); + // fflush( stdout ); } diff --git a/source/add-ons/Mandelbrot/mandelbrot.cpp b/source/add-ons/Mandelbrot/mandelbrot.cpp index e139ef0..408ae00 100644 --- a/source/add-ons/Mandelbrot/mandelbrot.cpp +++ b/source/add-ons/Mandelbrot/mandelbrot.cpp @@ -9,14 +9,14 @@ Format : tabs==2 Any redistribution or reuse forbidden (execpt as part of a Becasso - distribution) without explicit notice from the author. + distribution) without explicit notice from the author. Using this code as a base sample code to create even more powerfull add-ons for Becasso is fully allowed and encouraged. This file shouldn't be distributed without its corresponding BeIDE project. The author, , cannot be taken as responsible for anything bad or good that may happen from the use, misuse or unuse of this source or anything compiled from it. - + (12may2001-SRMS adapted to 2.0 API) *****************************************************************************/ @@ -36,38 +36,44 @@ #include #include -#define K_MANDEL 1 -#define K_JULIA 2 - -#define K_MANDEL_MSG 'maMd' -#define K_JULIA_MSG 'juMd' -#define K_XCENTER_MSG 'xcMd' -#define K_YCENTER_MSG 'ycMd' -#define K_XZOOM_MSG 'xzMd' -#define K_YZOOM_MSG 'yzMd' -#define K_ANGLE_MSG 'agMd' -#define K_INVERT_MSG 'inMd' -#define K_APPLY_ITER_MSG 'aiMd' -#define K_PREV_ITER_MSG 'piMd' -#define K_BLOCK_4_MSG '04Md' -#define K_BLOCK_8_MSG '08Md' -#define K_BLOCK_16_MSG '16Md' -#define K_ISOMORPH_MSG 'imMd' +#define K_MANDEL 1 +#define K_JULIA 2 + +#define K_MANDEL_MSG 'maMd' +#define K_JULIA_MSG 'juMd' +#define K_XCENTER_MSG 'xcMd' +#define K_YCENTER_MSG 'ycMd' +#define K_XZOOM_MSG 'xzMd' +#define K_YZOOM_MSG 'yzMd' +#define K_ANGLE_MSG 'agMd' +#define K_INVERT_MSG 'inMd' +#define K_APPLY_ITER_MSG 'aiMd' +#define K_PREV_ITER_MSG 'piMd' +#define K_BLOCK_4_MSG '04Md' +#define K_BLOCK_8_MSG '08Md' +#define K_BLOCK_16_MSG '16Md' +#define K_ISOMORPH_MSG 'imMd' //--------------------------------------------------------------------------- // prototypes -void drawMandel(Layer *layer, uint32 width, uint32 height, bool final, BPoint point, - Layer *inLayer, Selection *selection, bool julia); +void +drawMandel( + Layer* layer, uint32 width, uint32 height, bool final, BPoint point, Layer* inLayer, + Selection* selection, bool julia +); -void selectMandel(Selection *outselection, uint32 width, uint32 height, bool final, BPoint point, - Selection *selection, bool julia); +void +selectMandel( + Selection* outselection, uint32 width, uint32 height, bool final, BPoint point, + Selection* selection, bool julia +); //--------------------------------------------------------------------------- // local static pointers #define EPSILON (1e-6) -#define max(a,b) ((a)>(b)?(a):(b)) +#define max(a, b) ((a) > (b) ? (a) : (b)) //--------------------------------------------------------------------------- @@ -75,56 +81,60 @@ void selectMandel(Selection *outselection, uint32 width, uint32 height, bool fin class MandelView : public BView //*************************************************************************** { -public: + public: MandelView(BRect rect); - virtual ~MandelView(void) {}; - virtual void MessageReceived(BMessage *msg); - int type(void) { return mType; } - uint32 blockSize(void) { return mBlockSize; } - bool invert(void) { return mInvert; } - bool isomorphic(void) { return mIsomorphic; } - uint32 applyIterations(void) { return mApplyIterations; } - uint32 previewIterations(void) { return mPreviewIterations; } + virtual ~MandelView(void){}; + virtual void MessageReceived(BMessage* msg); + + int type(void) { return mType; } + + uint32 blockSize(void) { return mBlockSize; } + + bool invert(void) { return mInvert; } + + bool isomorphic(void) { return mIsomorphic; } + + uint32 applyIterations(void) { return mApplyIterations; } + + uint32 previewIterations(void) { return mPreviewIterations; } void displayCenter(void); - void displayZoom (void); - void displayAngle (void); - void displayIter (void); + void displayZoom(void); + void displayAngle(void); + void displayIter(void); - double mXCenter, mYCenter, mXZoom, mYZoom; - int32 mAngle; + double mXCenter, mYCenter, mXZoom, mYZoom; + int32 mAngle; // interface items - BRadioButton *mIMandel; - BRadioButton *mIJulia; + BRadioButton* mIMandel; + BRadioButton* mIJulia; BTextControl *mIXCenter, *mIYCenter, *mIXZoom, *mIYZoom, *mIAngle; BTextControl *mIApplyIter, *mIPreviewIter; - BCheckBox *mIInvert, *mIIsomorphic; + BCheckBox *mIInvert, *mIIsomorphic; - BPoint mLastZoom; - BPoint mLastRotate; - BPoint mLastSlide; - uint32 mLastModifier; + BPoint mLastZoom; + BPoint mLastRotate; + BPoint mLastSlide; + uint32 mLastModifier; - double mCos[360]; - double mSin[360]; + double mCos[360]; + double mSin[360]; -private: + private: typedef BView inherited; - int mType; - bool mInvert; - bool mIsomorphic; - uint32 mBlockSize; // size of blocks in preview mode - uint32 mApplyIterations; - uint32 mPreviewIterations; + int mType; + bool mInvert; + bool mIsomorphic; + uint32 mBlockSize; // size of blocks in preview mode + uint32 mApplyIterations; + uint32 mPreviewIterations; }; - -MandelView *view = 0; +MandelView* view = 0; //*************************************************************************** -MandelView::MandelView(BRect rect) - :BView (rect, "mandel_view", B_FOLLOW_ALL, B_WILL_DRAW) +MandelView::MandelView(BRect rect) : BView(rect, "mandel_view", B_FOLLOW_ALL, B_WILL_DRAW) //*************************************************************************** { mType = K_MANDEL; @@ -142,52 +152,54 @@ MandelView::MandelView(BRect rect) mLastModifier = 0; - for(int i=0; i<360; i++) - { - mCos[i] = cos(i*2*3.141592654/360.0); - mSin[i] = sin(i*2*3.141592654/360.0); + for (int i = 0; i < 360; i++) { + mCos[i] = cos(i * 2 * 3.141592654 / 360.0); + mSin[i] = sin(i * 2 * 3.141592654 / 360.0); } - #define KH1 16 // size for plain font - #define KH2 16 // size for bold font - #define KH3 25 - #define KW 200 - +#define KH1 16 // size for plain font +#define KH2 16 // size for bold font +#define KH3 25 +#define KW 200 + uint32 kh1, kh2, kh3; - + // get fonts height font_height fh; be_plain_font->GetHeight(&fh); - kh1=uint32 (fh.ascent+fh.descent+fh.leading); + kh1 = uint32(fh.ascent + fh.descent + fh.leading); be_bold_font->GetHeight(&fh); - kh2=uint32 (fh.ascent+fh.descent+fh.leading); - - kh1=max(KH1,kh1+5); - kh2=max(KH2,kh2+5); - kh3=kh1+10; + kh2 = uint32(fh.ascent + fh.descent + fh.leading); + + kh1 = max(KH1, kh1 + 5); + kh2 = max(KH2, kh2 + 5); + kh3 = kh1 + 10; - uint32 th = kh2+5*kh3+10+kh2+2*kh1+10+kh2+3*kh1+5*kh3+10; - ResizeTo(KW,th); + uint32 th = kh2 + 5 * kh3 + 10 + kh2 + 2 * kh1 + 10 + kh2 + 3 * kh1 + 5 * kh3 + 10; + ResizeTo(KW, th); // create window content - const uint32 x1=4; // box left - const uint32 x2=8; // items left - const uint32 x3=KW-4; // box right - const uint32 x4=KW-8-x2; // item right - uint32 y1=1,y2; + const uint32 x1 = 4; // box left + const uint32 x2 = 8; // items left + const uint32 x3 = KW - 4; // box right + const uint32 x4 = KW - 8 - x2; // item right + uint32 y1 = 1, y2; // -- type box -- - BBox *type = new BBox(BRect(x1,y1,x3,y1+kh2+2*kh1+5), "type"); - y1 += kh2+2*kh1+10; + BBox* type = new BBox(BRect(x1, y1, x3, y1 + kh2 + 2 * kh1 + 5), "type"); + y1 += kh2 + 2 * kh1 + 10; type->SetLabel("Type"); AddChild(type); y2 = kh2; - mIMandel = new BRadioButton(BRect(x2,y2,x4,y2+kh1), "mandel", "Mandelbrot", new BMessage(K_MANDEL_MSG)); + mIMandel = new BRadioButton( + BRect(x2, y2, x4, y2 + kh1), "mandel", "Mandelbrot", new BMessage(K_MANDEL_MSG) + ); y2 += kh1; - mIJulia = new BRadioButton(BRect(x2,y2,x4,y2+kh1), "julia", "Julia", new BMessage(K_JULIA_MSG)); + mIJulia = + new BRadioButton(BRect(x2, y2, x4, y2 + kh1), "julia", "Julia", new BMessage(K_JULIA_MSG)); type->AddChild(mIMandel); type->AddChild(mIJulia); @@ -195,35 +207,47 @@ MandelView::MandelView(BRect rect) // -- interactive settings box -- - BBox *inter = new BBox(BRect(x1,y1,x3,y1+kh2+3*kh1+5*kh3+3), "inter"); - y1 += kh2+3*kh1+5*kh3+10; + BBox* inter = new BBox(BRect(x1, y1, x3, y1 + kh2 + 3 * kh1 + 5 * kh3 + 3), "inter"); + y1 += kh2 + 3 * kh1 + 5 * kh3 + 10; inter->SetLabel("Interactive Settings"); AddChild(inter); y2 = kh2; - inter->AddChild(new BStringView(BRect(x2,y2,x4,y2+kh1), "label1", "[Center: mouse]")); + inter->AddChild(new BStringView(BRect(x2, y2, x4, y2 + kh1), "label1", "[Center: mouse]")); y2 += kh1; - mIXCenter = new BTextControl(BRect(x2,y2,x4,y2+kh3), "xcenter", "X Center", "0", new BMessage(K_XCENTER_MSG)); + mIXCenter = new BTextControl( + BRect(x2, y2, x4, y2 + kh3), "xcenter", "X Center", "0", new BMessage(K_XCENTER_MSG) + ); mIXCenter->SetModificationMessage(new BMessage(K_XCENTER_MSG)); y2 += kh3; - mIYCenter = new BTextControl(BRect(x2,y2,x4,y2+kh3), "ycenter", "Y Center", "0", new BMessage(K_YCENTER_MSG)); + mIYCenter = new BTextControl( + BRect(x2, y2, x4, y2 + kh3), "ycenter", "Y Center", "0", new BMessage(K_YCENTER_MSG) + ); mIYCenter->SetModificationMessage(new BMessage(K_YCENTER_MSG)); y2 += kh3; - inter->AddChild(new BStringView(BRect(x2,y2,x4,y2+kh1), "label1", "[Zoom: Shift+mouse]")); + inter->AddChild(new BStringView(BRect(x2, y2, x4, y2 + kh1), "label1", "[Zoom: Shift+mouse]")); y2 += kh1; - mIXZoom = new BTextControl(BRect(x2,y2,x4,y2+kh3), "xcenter", "X Zoom", "0", new BMessage(K_XZOOM_MSG)); + mIXZoom = new BTextControl( + BRect(x2, y2, x4, y2 + kh3), "xcenter", "X Zoom", "0", new BMessage(K_XZOOM_MSG) + ); mIXZoom->SetModificationMessage(new BMessage(K_XZOOM_MSG)); y2 += kh3; - mIYZoom = new BTextControl(BRect(x2,y2,x4,y2+kh3), "ycenter", "Y Zoom", "0", new BMessage(K_YZOOM_MSG)); + mIYZoom = new BTextControl( + BRect(x2, y2, x4, y2 + kh3), "ycenter", "Y Zoom", "0", new BMessage(K_YZOOM_MSG) + ); mIYZoom->SetModificationMessage(new BMessage(K_YZOOM_MSG)); y2 += kh3; - inter->AddChild(new BStringView(BRect(x2,y2,x4,y2+kh1), "label1", "[Angle: Control+mouse]")); + inter->AddChild(new BStringView(BRect(x2, y2, x4, y2 + kh1), "label1", "[Angle: Control+mouse]") + ); y2 += kh1; - mIAngle = new BTextControl(BRect(x2,y2,x4,y2+kh3), "angle", "Angle", "0", new BMessage(K_ANGLE_MSG)); + mIAngle = new BTextControl( + BRect(x2, y2, x4, y2 + kh3), "angle", "Angle", "0", new BMessage(K_ANGLE_MSG) + ); mIAngle->SetModificationMessage(new BMessage(K_ANGLE_MSG)); - //x5 = max(mXCenter->Divider(),max(mYCenter->Divider(),max(mXZoom->Divider(),max(mYZoom->Divider(),mAngle->Divider())))); - uint32 x5 = uint32 (mIXCenter->StringWidth("X Center")+10); + // x5 = + // max(mXCenter->Divider(),max(mYCenter->Divider(),max(mXZoom->Divider(),max(mYZoom->Divider(),mAngle->Divider())))); + uint32 x5 = uint32(mIXCenter->StringWidth("X Center") + 10); mIXCenter->SetDivider(x5); mIYCenter->SetDivider(x5); mIXZoom->SetDivider(x5); @@ -238,33 +262,44 @@ MandelView::MandelView(BRect rect) // -- fixed settings box -- - BBox *fixed = new BBox(BRect(x1,y1,x3,y1+kh2+5*kh3+5), "fixed"); + BBox* fixed = new BBox(BRect(x1, y1, x3, y1 + kh2 + 5 * kh3 + 5), "fixed"); fixed->SetLabel("Fixed Settings"); AddChild(fixed); y2 = kh2; - mIApplyIter = new BTextControl(BRect(x2,y2,x4,y2+kh3), "applyiter", "Apply Iterations", "0", new BMessage(K_APPLY_ITER_MSG)); + mIApplyIter = new BTextControl( + BRect(x2, y2, x4, y2 + kh3), "applyiter", "Apply Iterations", "0", + new BMessage(K_APPLY_ITER_MSG) + ); mIApplyIter->SetModificationMessage(new BMessage(K_APPLY_ITER_MSG)); y2 += kh3; - mIPreviewIter = new BTextControl(BRect(x2,y2,x4,y2+kh3), "previter", "Preview Iterations", "0", new BMessage(K_PREV_ITER_MSG)); + mIPreviewIter = new BTextControl( + BRect(x2, y2, x4, y2 + kh3), "previter", "Preview Iterations", "0", + new BMessage(K_PREV_ITER_MSG) + ); mIPreviewIter->SetModificationMessage(new BMessage(K_PREV_ITER_MSG)); y2 += kh3; - BPopUpMenu *block = new BPopUpMenu("Colors"); + BPopUpMenu* block = new BPopUpMenu("Colors"); block->AddItem(new BMenuItem("4 pixels", new BMessage(K_BLOCK_4_MSG))); block->AddItem(new BMenuItem("8 pixels", new BMessage(K_BLOCK_8_MSG))); block->AddItem(new BMenuItem("16 pixels", new BMessage(K_BLOCK_16_MSG))); block->ItemAt(0)->SetMarked(true); - BMenuField *blockfield = new BMenuField(BRect(x2,y2,x4,y2+kh3), "block", "Preview Block Size", block); + BMenuField* blockfield = + new BMenuField(BRect(x2, y2, x4, y2 + kh3), "block", "Preview Block Size", block); y2 += kh3; - mIInvert = new BCheckBox(BRect(x2,y2,x4,y2+kh3), "invert", "Invert Colors", new BMessage(K_INVERT_MSG)); + mIInvert = new BCheckBox( + BRect(x2, y2, x4, y2 + kh3), "invert", "Invert Colors", new BMessage(K_INVERT_MSG) + ); mIInvert->SetValue(invert()); y2 += kh3; - mIIsomorphic = new BCheckBox(BRect(x2,y2,x4,y2+kh3), "isomorf", "Isomorphic", new BMessage(K_ISOMORPH_MSG)); + mIIsomorphic = new BCheckBox( + BRect(x2, y2, x4, y2 + kh3), "isomorf", "Isomorphic", new BMessage(K_ISOMORPH_MSG) + ); mIIsomorphic->SetValue(isomorphic()); - x5 = uint32 (mIPreviewIter->StringWidth("Preview Iterations")+10); + x5 = uint32(mIPreviewIter->StringWidth("Preview Iterations") + 10); mIApplyIter->SetDivider(x5); mIPreviewIter->SetDivider(x5); blockfield->SetDivider(x5); @@ -283,11 +318,11 @@ MandelView::MandelView(BRect rect) //*************************************************************************** -void MandelView::MessageReceived (BMessage *msg) +void +MandelView::MessageReceived(BMessage* msg) //*************************************************************************** { - switch (msg->what) - { + switch (msg->what) { case K_MANDEL_MSG: mType = K_MANDEL; break; @@ -304,80 +339,110 @@ void MandelView::MessageReceived (BMessage *msg) mBlockSize = 16; break; case K_INVERT_MSG: - if (mIInvert) mInvert = mIInvert->Value(); + if (mIInvert) + mInvert = mIInvert->Value(); printf("mIInvert %p, value %ld\n", mIInvert, mIInvert->Value()); break; case K_ISOMORPH_MSG: - if (mIIsomorphic) mIsomorphic = mIIsomorphic->Value(); + if (mIIsomorphic) + mIsomorphic = mIIsomorphic->Value(); break; - #define M_XY_MSG(msg,obj,var) case msg : if ( obj ) { char *p = (char *) obj ->Text(); if (p) var = atof(p); } break +#define M_XY_MSG(msg, obj, var) \ + case msg: \ + if (obj) { \ + char* p = (char*)obj->Text(); \ + if (p) \ + var = atof(p); \ + } \ + break M_XY_MSG(K_XCENTER_MSG, mIXCenter, mXCenter); M_XY_MSG(K_YCENTER_MSG, mIYCenter, mYCenter); - M_XY_MSG(K_XZOOM_MSG, mIXZoom, mXZoom); - M_XY_MSG(K_YZOOM_MSG, mIYZoom, mYZoom); - - #define M_INT_MSG(msg,obj,var) case msg : if ( obj ) { char *p = (char *) obj ->Text(); if (p) var = atol(p); } break - M_INT_MSG(K_APPLY_ITER_MSG, mIApplyIter, mApplyIterations); - M_INT_MSG(K_PREV_ITER_MSG, mIPreviewIter, mPreviewIterations); - M_INT_MSG(K_ANGLE_MSG, mIAngle, mAngle); + M_XY_MSG(K_XZOOM_MSG, mIXZoom, mXZoom); + M_XY_MSG(K_YZOOM_MSG, mIYZoom, mYZoom); + +#define M_INT_MSG(msg, obj, var) \ + case msg: \ + if (obj) { \ + char* p = (char*)obj->Text(); \ + if (p) \ + var = atol(p); \ + } \ + break + M_INT_MSG(K_APPLY_ITER_MSG, mIApplyIter, mApplyIterations); + M_INT_MSG(K_PREV_ITER_MSG, mIPreviewIter, mPreviewIterations); + M_INT_MSG(K_ANGLE_MSG, mIAngle, mAngle); default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); } } //*************************************************************************** -void MandelView::displayCenter(void) +void +MandelView::displayCenter(void) //*************************************************************************** { -char s[64]; - if (LockLooper()) - { - sprintf(s, "%f", mXCenter); if (mIXCenter) mIXCenter->SetText(s); - sprintf(s, "%f", mYCenter); if (mIYCenter) mIYCenter->SetText(s); + char s[64]; + if (LockLooper()) { + sprintf(s, "%f", mXCenter); + if (mIXCenter) + mIXCenter->SetText(s); + sprintf(s, "%f", mYCenter); + if (mIYCenter) + mIYCenter->SetText(s); UnlockLooper(); } } //*************************************************************************** -void MandelView::displayZoom(void) +void +MandelView::displayZoom(void) //*************************************************************************** { -char s[64]; - if (LockLooper()) - { - sprintf(s, "%f", mXZoom); if (mIXZoom) mIXZoom->SetText(s); - sprintf(s, "%f", mYZoom); if (mIYZoom) mIYZoom->SetText(s); + char s[64]; + if (LockLooper()) { + sprintf(s, "%f", mXZoom); + if (mIXZoom) + mIXZoom->SetText(s); + sprintf(s, "%f", mYZoom); + if (mIYZoom) + mIYZoom->SetText(s); UnlockLooper(); } } //*************************************************************************** -void MandelView::displayAngle(void) +void +MandelView::displayAngle(void) //*************************************************************************** { -char s[64]; - if (LockLooper()) - { - sprintf(s, "%ld deg", mAngle); if (mIAngle) mIAngle->SetText(s); + char s[64]; + if (LockLooper()) { + sprintf(s, "%ld deg", mAngle); + if (mIAngle) + mIAngle->SetText(s); UnlockLooper(); } } //*************************************************************************** -void MandelView::displayIter(void) +void +MandelView::displayIter(void) //*************************************************************************** { -char s[64]; - if (LockLooper()) - { - sprintf(s, "%ld", mApplyIterations); if (mIApplyIter) mIApplyIter->SetText(s); - sprintf(s, "%ld", mPreviewIterations); if (mIPreviewIter) mIPreviewIter->SetText(s); + char s[64]; + if (LockLooper()) { + sprintf(s, "%ld", mApplyIterations); + if (mIApplyIter) + mIApplyIter->SetText(s); + sprintf(s, "%ld", mPreviewIterations); + if (mIPreviewIter) + mIPreviewIter->SetText(s); UnlockLooper(); } } @@ -386,43 +451,49 @@ char s[64]; //--------------------------------------------------------------------------- //*************************************************************************** -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) //*************************************************************************** { - strcpy(info->name, "Mandelbrot"); - strcpy(info->author, "by R'alf "); - strcpy(info->copyright, "The PowerPulsar Guy."); - strcpy(info->description, "\nGenerates a color Mandelbrot or Julia\nKeys :\n" - "Cmd+mouse : move the center,\n" - "Cmd+Shift+Mouse : change the zoom"); - - info->type = BECASSO_GENERATOR; - info->index = index; - info->version = 0; - info->release = 2; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE | PREVIEW_MOUSE; - info->flags = 0; + strcpy(info->name, "Mandelbrot"); + strcpy(info->author, "by R'alf "); + strcpy(info->copyright, "The PowerPulsar Guy."); + strcpy( + info->description, "\nGenerates a color Mandelbrot or Julia\nKeys :\n" + "Cmd+mouse : move the center,\n" + "Cmd+Shift+Mouse : change the zoom" + ); + + info->type = BECASSO_GENERATOR; + info->index = index; + info->version = 0; + info->release = 2; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE | PREVIEW_MOUSE; + info->flags = 0; return B_OK; } //*************************************************************************** -status_t addon_exit(void) +status_t +addon_exit(void) //*************************************************************************** { return B_OK; } -status_t addon_close(void) +status_t +addon_close(void) { return B_OK; } -status_t addon_make_config (BView **vw, BRect rect) +status_t +addon_make_config(BView** vw, BRect rect) { - view = new MandelView (rect); + view = new MandelView(rect); *vw = view; return B_OK; } @@ -431,8 +502,11 @@ status_t addon_make_config (BView **vw, BRect rect) // ---------- //*************************************************************************** -void drawMandel(Layer *layer, uint32 width, uint32 height, bool final, BPoint point, - Layer *inLayer, Selection *selection, bool julia) +void +drawMandel( + Layer* layer, uint32 width, uint32 height, bool final, BPoint point, Layer* inLayer, + Selection* selection, bool julia +) //*************************************************************************** /* Note for the curious reader : @@ -440,91 +514,87 @@ void drawMandel(Layer *layer, uint32 width, uint32 height, bool final, BPoint po Don't be afraid if it looks messy at first -- in fact it is :-) */ { -uint32 *dmap = (uint32 *)layer->Bits() - 1; -uint32 dbpr = layer->BytesPerRow()/sizeof(uint32); -uint32 *smap = 0, sbpr = 0, selbpr = 0; -uint8 *selmap = 0; -uint32 block; -double a,b,ar,br,cr,sr,x,xp,x2,y,y2; -int k; -uint32 ki = 255; -int i,j,step,angle; - - if (!height || !width || !view) return; + uint32* dmap = (uint32*)layer->Bits() - 1; + uint32 dbpr = layer->BytesPerRow() / sizeof(uint32); + uint32 *smap = 0, sbpr = 0, selbpr = 0; + uint8* selmap = 0; + uint32 block; + double a, b, ar, br, cr, sr, x, xp, x2, y, y2; + int k; + uint32 ki = 255; + int i, j, step, angle; + + if (!height || !width || !view) + return; if (final) addon_start(); - float delta = 100.0/height; // For the Status Bar. + float delta = 100.0 / height; // For the Status Bar. double xcenter = view->mXCenter; double ycenter = view->mYCenter; double xzoom = view->mXZoom; double yzoom = view->mYZoom; - if (xzoom < EPSILON) xzoom = EPSILON; - if (yzoom < EPSILON) yzoom = EPSILON; + if (xzoom < EPSILON) + xzoom = EPSILON; + if (yzoom < EPSILON) + yzoom = EPSILON; uint32 mods = modifiers(); - if (mods & B_SHIFT_KEY) - { + if (mods & B_SHIFT_KEY) { // change zoom value log - if (view->mLastModifier != B_SHIFT_KEY) view->mLastModifier = B_SHIFT_KEY; - else - { - int fudge=(xzoom>1 ? int (pow(10,log10(xzoom)+1)) : 1); - xzoom += fudge*(point.x-view->mLastZoom.x)/width; - if (xzoom < EPSILON) xzoom = EPSILON; - if (view->isomorphic()) yzoom = xzoom; - else - { - fudge=(yzoom>1 ? int (pow(10,log10(yzoom)+1)) : 1); - yzoom += fudge*(point.y-view->mLastZoom.y)/height; + if (view->mLastModifier != B_SHIFT_KEY) + view->mLastModifier = B_SHIFT_KEY; + else { + int fudge = (xzoom > 1 ? int(pow(10, log10(xzoom) + 1)) : 1); + xzoom += fudge * (point.x - view->mLastZoom.x) / width; + if (xzoom < EPSILON) + xzoom = EPSILON; + if (view->isomorphic()) + yzoom = xzoom; + else { + fudge = (yzoom > 1 ? int(pow(10, log10(yzoom) + 1)) : 1); + yzoom += fudge * (point.y - view->mLastZoom.y) / height; } - if (yzoom < EPSILON) yzoom = EPSILON; + if (yzoom < EPSILON) + yzoom = EPSILON; view->mXZoom = xzoom; view->mYZoom = yzoom; view->displayZoom(); } view->mLastZoom = point; - } - else if (mods & B_CONTROL_KEY) - { + } else if (mods & B_CONTROL_KEY) { // change rotation - if (view->mLastModifier != B_CONTROL_KEY) - { + if (view->mLastModifier != B_CONTROL_KEY) { view->mLastModifier = B_CONTROL_KEY; view->mLastRotate = point; - } - else - { - double a,x,y; - //x = (point.x - window->mLastRotate.x); - //y = (point.y - window->mLastRotate.y); + } else { + double a, x, y; + // x = (point.x - window->mLastRotate.x); + // y = (point.y - window->mLastRotate.y); x = (view->mLastRotate.x - point.x); y = (view->mLastRotate.y - point.y); - a = atan2(y,x); - a *= 180/3.141592654; // convert in degrees - angle = int (a); - while(angle < 0) angle += 360; - while(angle >= 360) angle -= 360; + a = atan2(y, x); + a *= 180 / 3.141592654; // convert in degrees + angle = int(a); + while (angle < 0) + angle += 360; + while (angle >= 360) + angle -= 360; view->mAngle = angle; view->displayAngle(); } - } - else - { + } else { // move center - if (view->mLastModifier != B_COMMAND_KEY) view->mLastModifier = B_COMMAND_KEY; - else - { - if (julia) - { - xcenter = ((point.x-(width/2)) / (width/2)) * 2.0; - ycenter = ((point.y-(height/2)) / (height/2)) * 2.0; - } - else - { - xcenter = view->mXCenter + (view->mLastSlide.x - point.x)/(width/2*xzoom); - ycenter = view->mYCenter + (view->mLastSlide.y - point.y)/(height/2*yzoom); + if (view->mLastModifier != B_COMMAND_KEY) + view->mLastModifier = B_COMMAND_KEY; + else { + if (julia) { + xcenter = ((point.x - (width / 2)) / (width / 2)) * 2.0; + ycenter = ((point.y - (height / 2)) / (height / 2)) * 2.0; + } else { + xcenter = view->mXCenter + (view->mLastSlide.x - point.x) / (width / 2 * xzoom); + ycenter = view->mYCenter + (view->mLastSlide.y - point.y) / (height / 2 * yzoom); } view->mXCenter = xcenter; view->mYCenter = ycenter; @@ -533,284 +603,285 @@ int i,j,step,angle; view->mLastSlide = point; } - angle = 359-view->mAngle; + angle = 359 - view->mAngle; cr = view->mCos[angle]; sr = view->mSin[angle]; block = view->blockSize(); ki = (final ? view->applyIterations() : view->previewIterations()) - 1; - //ki = view->applyIterations(); + // ki = view->applyIterations(); step = (final ? 1 : block); rgb_color hi = highcolor(); rgb_color lo = lowcolor(); - if (view->invert()) - { + if (view->invert()) { rgb_color t = lo; lo = hi; hi = t; } - if (selection) - { - smap = (uint32 *)inLayer->Bits() - 1; - sbpr = inLayer->BytesPerRow()/sizeof(uint32); - selmap = (uint8 *)selection->Bits() - 1; - selbpr = selection->BytesPerRow()/sizeof(uint8); + if (selection) { + smap = (uint32*)inLayer->Bits() - 1; + sbpr = inLayer->BytesPerRow() / sizeof(uint32); + selmap = (uint8*)selection->Bits() - 1; + selbpr = selection->BytesPerRow() / sizeof(uint8); } - xzoom = 4.0/xzoom; - yzoom = 4.0/yzoom; - if (!julia) - { - xcenter += xzoom/2; - ycenter += yzoom/2; + xzoom = 4.0 / xzoom; + yzoom = 4.0 / yzoom; + if (!julia) { + xcenter += xzoom / 2; + ycenter += yzoom / 2; } xzoom /= width; yzoom /= height; - for(j=height; j>0; j-=step) - { - uint32 *dbits = dmap; - uint32 *sbits = smap; - uint8 *selbits = selmap; - dmap += dbpr*step; + for (j = height; j > 0; j -= step) { + uint32* dbits = dmap; + uint32* sbits = smap; + uint8* selbits = selmap; + dmap += dbpr * step; - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { - //error = ADDON_ABORT; + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { + // error = ADDON_ABORT; break; } } - - if (selection) - { - smap += sbpr*step; - selmap += selbpr*step; + + if (selection) { + smap += sbpr * step; + selmap += selbpr * step; } int yr = step; - if (j0; i-=step) - { - if (julia) - { + for (i = width; i > 0; i -= step) { + if (julia) { // julia - ar=((int)(width/2)-i)*xzoom; - a = cr*ar-sr*br; - b = sr*ar+cr*br; + ar = ((int)(width / 2) - i) * xzoom; + a = cr * ar - sr * br; + b = sr * ar + cr * br; x = a; y = b; - x2 = x*x; - y2 = y*y; - for(k=ki; k>0 && (x2+y2)<4.0; k--) - { + x2 = x * x; + y2 = y * y; + for (k = ki; k > 0 && (x2 + y2) < 4.0; k--) { // julia : like a mandelbrot (z=z2+c) except that : // z=(a,b) moving on the canvas for each pixel - // c=(rx,ry) coordinates selected on the mandelbrot set that doesn't move across iterations - // z = z2+c - - xp = x2-y2+xcenter; - y = 2*x*y+ycenter; + // c=(rx,ry) coordinates selected on the mandelbrot set that doesn't move across + // iterations z = z2+c + + xp = x2 - y2 + xcenter; + y = 2 * x * y + ycenter; x = xp; - x2 = x*x; - y2 = y*y; + x2 = x * x; + y2 = y * y; } - } - else - { + } else { // mandelbrot - ar = xcenter-xzoom*i; - a = cr*ar-sr*br; - b = sr*ar+cr*br; - + ar = xcenter - xzoom * i; + a = cr * ar - sr * br; + b = sr * ar + cr * br; + x = 0.0; y = 0.0; x2 = 0.0; y2 = 0.0; - for(k=ki; k>0 && (x2+y2)<4.0; k--) - { + for (k = ki; k > 0 && (x2 + y2) < 4.0; k--) { // z = z2+c // z = (x+iy) // c=(a+ib) // z2 = x2-y2+i2xy // x' = x2-y2+a // y' = xy + b - - xp = x2-y2+a; - y = 2*x*y+b; + + xp = x2 - y2 + a; + y = 2 * x * y + b; x = xp; - x2 = x*x; - y2 = y*y; + x2 = x * x; + y2 = y * y; } } - - if (k < 0) k = 0; - uint32 pixel = weighted_average_rgb (lo, k, hi, ki-k) & COLOR_MASK; + + if (k < 0) + k = 0; + uint32 pixel = weighted_average_rgb(lo, k, hi, ki - k) & COLOR_MASK; int xr = step; - if (xr > 1) - { - if (i 1) { + if (i < xr) + xr = i; + uint32* dbits2 = dbits; + int offset = dbpr - xr; // this hint has a side effect that can be considered a bug : // --> the alpha value gets modified by blocks - if (selection) - { - pixel = pixelblend (*(sbits+1), (pixel | (*(selbits+1)) << ALPHA_BPOS)); + if (selection) { + pixel = pixelblend(*(sbits + 1), (pixel | (*(selbits + 1)) << ALPHA_BPOS)); sbits += step; selbits += step; - } - else pixel |= ALPHA_MASK; + } else + pixel |= ALPHA_MASK; dbits += step; - for(int yr2=yr; yr2>0; yr2--) - { - switch(xr) - { - case 16: *(++dbits2) = pixel; - case 15: *(++dbits2) = pixel; - case 14: *(++dbits2) = pixel; - case 13: *(++dbits2) = pixel; - case 12: *(++dbits2) = pixel; - case 11: *(++dbits2) = pixel; - case 10: *(++dbits2) = pixel; - case 9: *(++dbits2) = pixel; - case 8: *(++dbits2) = pixel; - case 7: *(++dbits2) = pixel; - case 6: *(++dbits2) = pixel; - case 5: *(++dbits2) = pixel; - case 4: *(++dbits2) = pixel; - case 3: *(++dbits2) = pixel; - case 2: *(++dbits2) = pixel; - case 1: *(++dbits2) = pixel; + for (int yr2 = yr; yr2 > 0; yr2--) { + switch (xr) { + case 16: + *(++dbits2) = pixel; + case 15: + *(++dbits2) = pixel; + case 14: + *(++dbits2) = pixel; + case 13: + *(++dbits2) = pixel; + case 12: + *(++dbits2) = pixel; + case 11: + *(++dbits2) = pixel; + case 10: + *(++dbits2) = pixel; + case 9: + *(++dbits2) = pixel; + case 8: + *(++dbits2) = pixel; + case 7: + *(++dbits2) = pixel; + case 6: + *(++dbits2) = pixel; + case 5: + *(++dbits2) = pixel; + case 4: + *(++dbits2) = pixel; + case 3: + *(++dbits2) = pixel; + case 2: + *(++dbits2) = pixel; + case 1: + *(++dbits2) = pixel; } dbits2 += offset; } - } - else - { + } else { // step is 1 - if (selection) *(++dbits) = pixelblend (*(++sbits), (pixel | (*(++selbits)) << ALPHA_BPOS)); - else *(++dbits) = pixel | ALPHA_MASK; + if (selection) + *(++dbits) = pixelblend(*(++sbits), (pixel | (*(++selbits)) << ALPHA_BPOS)); + else + *(++dbits) = pixel | ALPHA_MASK; } } } if (final) addon_done(); - } // ---------- - //*************************************************************************** -void selectMandel(Selection *outselection, uint32 width, uint32 height, bool final, BPoint point, - Selection * /*selection*/, bool julia) +void +selectMandel( + Selection* outselection, uint32 width, uint32 height, bool final, BPoint point, + Selection* /*selection*/, bool julia +) //*************************************************************************** /* Note for the curious reader : This function is an ugly copy-paste from drawMandel. Don't focus on this mess, better have a look a drawMandel directly. - + Note : for the moment, the inSelection is ignored. It doesn't make sense here, indeed. */ { -uint8 *dmap = (uint8 *)outselection->Bits() - 1; -uint32 dbpr = outselection->BytesPerRow()/sizeof(uint8); -//uint32 selbpr; -//uint8 *selmap; -uint32 block; -double a,b,ar,br,cr,sr,x,xp,x2,y,y2; -int k; -uint32 ki = 255; -int i,j,step,angle; - - if (!height || !width || !view) return; + uint8* dmap = (uint8*)outselection->Bits() - 1; + uint32 dbpr = outselection->BytesPerRow() / sizeof(uint8); + // uint32 selbpr; + // uint8 *selmap; + uint32 block; + double a, b, ar, br, cr, sr, x, xp, x2, y, y2; + int k; + uint32 ki = 255; + int i, j, step, angle; + + if (!height || !width || !view) + return; if (final) addon_start(); - float delta = 100.0/height; // For the Status Bar. + float delta = 100.0 / height; // For the Status Bar. double xcenter = view->mXCenter; double ycenter = view->mYCenter; double xzoom = view->mXZoom; double yzoom = view->mYZoom; - if (xzoom < EPSILON) xzoom = EPSILON; - if (yzoom < EPSILON) yzoom = EPSILON; + if (xzoom < EPSILON) + xzoom = EPSILON; + if (yzoom < EPSILON) + yzoom = EPSILON; uint32 mods = modifiers(); - if (mods & B_SHIFT_KEY) - { + if (mods & B_SHIFT_KEY) { // change zoom value log - if (view->mLastModifier != B_SHIFT_KEY) view->mLastModifier = B_SHIFT_KEY; - else - { - int fudge=(xzoom>1 ? int (pow(10,log10(xzoom)+1)) : 1); - xzoom += fudge*(point.x-view->mLastZoom.x)/width; - if (xzoom < EPSILON) xzoom = EPSILON; - if (view->isomorphic()) yzoom = xzoom; - else - { - fudge=(yzoom>1 ? int (pow(10,log10(yzoom)+1)) : 1); - yzoom += fudge*(point.y-view->mLastZoom.y)/height; + if (view->mLastModifier != B_SHIFT_KEY) + view->mLastModifier = B_SHIFT_KEY; + else { + int fudge = (xzoom > 1 ? int(pow(10, log10(xzoom) + 1)) : 1); + xzoom += fudge * (point.x - view->mLastZoom.x) / width; + if (xzoom < EPSILON) + xzoom = EPSILON; + if (view->isomorphic()) + yzoom = xzoom; + else { + fudge = (yzoom > 1 ? int(pow(10, log10(yzoom) + 1)) : 1); + yzoom += fudge * (point.y - view->mLastZoom.y) / height; } - if (yzoom < EPSILON) yzoom = EPSILON; + if (yzoom < EPSILON) + yzoom = EPSILON; view->mXZoom = xzoom; view->mYZoom = yzoom; view->displayZoom(); } view->mLastZoom = point; - } - else if (mods & B_CONTROL_KEY) - { + } else if (mods & B_CONTROL_KEY) { // change rotation - if (view->mLastModifier != B_CONTROL_KEY) - { + if (view->mLastModifier != B_CONTROL_KEY) { view->mLastModifier = B_CONTROL_KEY; view->mLastRotate = point; - } - else - { - double a,x,y; - //x = (point.x - view->mLastRotate.x); - //y = (point.y - view->mLastRotate.y); + } else { + double a, x, y; + // x = (point.x - view->mLastRotate.x); + // y = (point.y - view->mLastRotate.y); x = (view->mLastRotate.x - point.x); y = (view->mLastRotate.y - point.y); - a = atan2(y,x); - a *= 180/3.141592654; // convert in degrees - angle = int (a); - while(angle < 0) angle += 360; - while(angle >= 360) angle -= 360; + a = atan2(y, x); + a *= 180 / 3.141592654; // convert in degrees + angle = int(a); + while (angle < 0) + angle += 360; + while (angle >= 360) + angle -= 360; view->mAngle = angle; view->displayAngle(); } - } - else - { + } else { // move center - if (view->mLastModifier != B_COMMAND_KEY) view->mLastModifier = B_COMMAND_KEY; - else - { - if (julia) - { - xcenter = ((point.x-(width/2)) / (width/2)) * 2.0; - ycenter = ((point.y-(height/2)) / (height/2)) * 2.0; - } - else - { - xcenter = view->mXCenter + (view->mLastSlide.x - point.x)/(width/2*xzoom); - ycenter = view->mYCenter + (view->mLastSlide.y - point.y)/(height/2*yzoom); + if (view->mLastModifier != B_COMMAND_KEY) + view->mLastModifier = B_COMMAND_KEY; + else { + if (julia) { + xcenter = ((point.x - (width / 2)) / (width / 2)) * 2.0; + ycenter = ((point.y - (height / 2)) / (height / 2)) * 2.0; + } else { + xcenter = view->mXCenter + (view->mLastSlide.x - point.x) / (width / 2 * xzoom); + ycenter = view->mYCenter + (view->mLastSlide.y - point.y) / (height / 2 * yzoom); } view->mXCenter = xcenter; view->mYCenter = ycenter; @@ -819,175 +890,182 @@ int i,j,step,angle; view->mLastSlide = point; } - angle = 359-view->mAngle; + angle = 359 - view->mAngle; cr = view->mCos[angle]; sr = view->mSin[angle]; block = view->blockSize(); ki = (final ? view->applyIterations() : view->previewIterations()) - 1; step = (final ? 1 : block); -/* - rgb_color hi = highcolor(); - rgb_color lo = lowcolor(); - if (window->invert()) - { - rgb_color t = lo; - lo = hi; - hi = t; - } -*/ + /* + rgb_color hi = highcolor(); + rgb_color lo = lowcolor(); + if (window->invert()) + { + rgb_color t = lo; + lo = hi; + hi = t; + } + */ -/* - if (selection) - { - selmap = (uint8 *)selection->Bits() - 1; - selbpr = selection->BytesPerRow()/sizeof(uint8); - } -*/ - xzoom = 4.0/xzoom; - yzoom = 4.0/yzoom; - if (!julia) - { - xcenter += xzoom/2; - ycenter += yzoom/2; + /* + if (selection) + { + selmap = (uint8 *)selection->Bits() - 1; + selbpr = selection->BytesPerRow()/sizeof(uint8); + } + */ + xzoom = 4.0 / xzoom; + yzoom = 4.0 / yzoom; + if (!julia) { + xcenter += xzoom / 2; + ycenter += yzoom / 2; } xzoom /= width; yzoom /= height; - for(j=height; j>0; j-=step) - { - uint8 *dbits = dmap; -// uint8 *selbits = selmap; - dmap += dbpr*step; + for (j = height; j > 0; j -= step) { + uint8* dbits = dmap; + // uint8 *selbits = selmap; + dmap += dbpr * step; - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { - //error = ADDON_ABORT; + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { + // error = ADDON_ABORT; break; } } - -// if (selection) selmap += selbpr*step; + + // if (selection) selmap += selbpr*step; int yr = step; - if (j0; i-=step) - { - if (julia) - { + for (i = width; i > 0; i -= step) { + if (julia) { // julia - ar=((int)(width/2)-i)*xzoom; - a = cr*ar-sr*br; - b = sr*ar+cr*br; + ar = ((int)(width / 2) - i) * xzoom; + a = cr * ar - sr * br; + b = sr * ar + cr * br; x = a; y = b; - x2 = x*x; - y2 = y*y; - for(k=ki; k>0 && (x2+y2)<4.0; k--) - { + x2 = x * x; + y2 = y * y; + for (k = ki; k > 0 && (x2 + y2) < 4.0; k--) { // julia : like a mandelbrot (z=z2+c) except that : // z=(a,b) moving on the canvas for each pixel - // c=(rx,ry) coordinates selected on the mandelbrot set that doesn't move across iterations - // z = z2+c - - xp = x2-y2+xcenter; - y = 2*x*y+ycenter; + // c=(rx,ry) coordinates selected on the mandelbrot set that doesn't move across + // iterations z = z2+c + + xp = x2 - y2 + xcenter; + y = 2 * x * y + ycenter; x = xp; - x2 = x*x; - y2 = y*y; + x2 = x * x; + y2 = y * y; } - } - else - { + } else { // mandelbrot - ar = xcenter-xzoom*i; - a = cr*ar-sr*br; - b = sr*ar+cr*br; - + ar = xcenter - xzoom * i; + a = cr * ar - sr * br; + b = sr * ar + cr * br; + x = 0.0; y = 0.0; x2 = 0.0; y2 = 0.0; - for(k=ki; k>0 && (x2+y2)<4.0; k--) - { + for (k = ki; k > 0 && (x2 + y2) < 4.0; k--) { // z = z2+c // z = (x+iy) // c=(a+ib) // z2 = x2-y2+i2xy // x' = x2-y2+a // y' = xy + b - - xp = x2-y2+a; - y = 2*x*y+b; + + xp = x2 - y2 + a; + y = 2 * x * y + b; x = xp; - x2 = x*x; - y2 = y*y; + x2 = x * x; + y2 = y * y; } } - - if (k < 0) k = 0; + + if (k < 0) + k = 0; // selection colors : // 0 = use layer pattern (selection) // 255 = nothing (transparent, no selection) // default : make mandelbrot zone to 0, outside to 255, invert if needed - uint32 pixel = uint32 ((double)(ki-k)/(double)ki*255.0); - if (view->invert()) pixel = 255-pixel; + uint32 pixel = uint32((double)(ki - k) / (double)ki * 255.0); + if (view->invert()) + pixel = 255 - pixel; int xr = step; - if (xr > 1) - { - if (i 1) { + if (i < xr) + xr = i; + uint8* dbits2 = dbits; + int offset = dbpr - xr; // this hint has a side effect that can be considered a bug : // --> the alpha value gets modified by blocks -// if (selection) -// { -// pixel = pixelblend (*(sbits+1), (pixel | *(selbits+1))); -// sbits += step; -// selbits += step; -// } -// else -// pixel |= 0x0FF; + // if (selection) + // { + // pixel = pixelblend (*(sbits+1), (pixel | *(selbits+1))); + // sbits += step; + // selbits += step; + // } + // else + // pixel |= 0x0FF; dbits += step; - for(int yr2=yr; yr2>0; yr2--) - { - switch(xr) - { - case 16: *(++dbits2) = pixel; - case 15: *(++dbits2) = pixel; - case 14: *(++dbits2) = pixel; - case 13: *(++dbits2) = pixel; - case 12: *(++dbits2) = pixel; - case 11: *(++dbits2) = pixel; - case 10: *(++dbits2) = pixel; - case 9: *(++dbits2) = pixel; - case 8: *(++dbits2) = pixel; - case 7: *(++dbits2) = pixel; - case 6: *(++dbits2) = pixel; - case 5: *(++dbits2) = pixel; - case 4: *(++dbits2) = pixel; - case 3: *(++dbits2) = pixel; - case 2: *(++dbits2) = pixel; - case 1: *(++dbits2) = pixel; + for (int yr2 = yr; yr2 > 0; yr2--) { + switch (xr) { + case 16: + *(++dbits2) = pixel; + case 15: + *(++dbits2) = pixel; + case 14: + *(++dbits2) = pixel; + case 13: + *(++dbits2) = pixel; + case 12: + *(++dbits2) = pixel; + case 11: + *(++dbits2) = pixel; + case 10: + *(++dbits2) = pixel; + case 9: + *(++dbits2) = pixel; + case 8: + *(++dbits2) = pixel; + case 7: + *(++dbits2) = pixel; + case 6: + *(++dbits2) = pixel; + case 5: + *(++dbits2) = pixel; + case 4: + *(++dbits2) = pixel; + case 3: + *(++dbits2) = pixel; + case 2: + *(++dbits2) = pixel; + case 1: + *(++dbits2) = pixel; } dbits2 += offset; } - } - else - { + } else { // step is 1 - //if (selection) *(++dbits) = pixelblend (*(++sbits), (pixel | *(++selbits))); - //else *(++dbits) = pixel | 0x0FF; + // if (selection) *(++dbits) = pixelblend (*(++sbits), (pixel | *(++selbits))); + // else *(++dbits) = pixel | 0x0FF; *(++dbits) = pixel; } } @@ -999,24 +1077,28 @@ int i,j,step,angle; // ---------- //*************************************************************************** -status_t process(Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /* frame */, bool final, BPoint point, uint32 buttons) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /* frame */, bool final, BPoint point, uint32 buttons +) //*************************************************************************** { - static BPoint lastpoint=BPoint(0,0); + static BPoint lastpoint = BPoint(0, 0); int error = 0; - if (!final && buttons) lastpoint = point; - if (!buttons && view) view->mLastModifier = 0; + if (!final && buttons) + lastpoint = point; + if (!buttons && view) + view->mLastModifier = 0; BRect bounds = inLayer->Bounds(); if (*outLayer == NULL && mode == M_DRAW) - *outLayer = new Layer (*inLayer); - + *outLayer = new Layer(*inLayer); + if (*outSelection == NULL && mode == M_SELECT) - *outSelection = new Selection (inLayer->Bounds()); + *outSelection = new Selection(inLayer->Bounds()); if (*outLayer) (*outLayer)->Lock(); @@ -1028,60 +1110,53 @@ status_t process(Layer *inLayer, Selection *inSelection, rgb_color hi = highcolor(); rgb_color lo = lowcolor(); - switch (mode) - { - case M_DRAW: - { + switch (mode) { + case M_DRAW: { if (view->type() == K_MANDEL) drawMandel(*outLayer, w, h, final, lastpoint, inLayer, inSelection, false); - else - { + else { drawMandel(*outLayer, w, h, final, lastpoint, inLayer, inSelection, true); - if (*outLayer && buttons) - { + if (*outLayer && buttons) { // circle for mandelbrot : c=<40,50> percent, radius=<40-20=20> percent - BView *view = new BView (inLayer->Bounds(), "tmp view", 0, 0); - (*outLayer)->AddChild (view); - view->SetHighColor (contrastingcolor (hi, lo)); - float x=lastpoint.x; - float y=lastpoint.y; - view->StrokeLine(BPoint(x-5,y), BPoint(x+5,y)); - view->StrokeLine(BPoint(x,y-5), BPoint(x,y+5)); - float w1=(float)w*0.4; - float h1=(float)h*0.5; - float r=(float)w*0.2; + BView* view = new BView(inLayer->Bounds(), "tmp view", 0, 0); + (*outLayer)->AddChild(view); + view->SetHighColor(contrastingcolor(hi, lo)); + float x = lastpoint.x; + float y = lastpoint.y; + view->StrokeLine(BPoint(x - 5, y), BPoint(x + 5, y)); + view->StrokeLine(BPoint(x, y - 5), BPoint(x, y + 5)); + float w1 = (float)w * 0.4; + float h1 = (float)h * 0.5; + float r = (float)w * 0.2; view->StrokeEllipse(BPoint(w1, h1), r, r); view->Sync(); - (*outLayer)->RemoveChild (view); + (*outLayer)->RemoveChild(view); delete view; } } break; } - case M_SELECT: - { + case M_SELECT: { if (view->type() == K_MANDEL) - selectMandel(*outSelection, w, h, final, lastpoint, inSelection, false); - else - { + selectMandel(*outSelection, w, h, final, lastpoint, inSelection, false); + else { selectMandel(*outSelection, w, h, final, lastpoint, inSelection, true); - if (*outLayer && buttons) - { + if (*outLayer && buttons) { // circle for mandelbrot : c=<40,50> percent, radius=<40-20=20> percent - BView *view = new BView (inLayer->Bounds(), "tmp view", 0, 0); - (*outSelection)->AddChild (view); - view->SetHighColor (contrastingcolor (hi, lo)); - float x=lastpoint.x; - float y=lastpoint.y; - view->StrokeLine(BPoint(x-5,y), BPoint(x+5,y)); - view->StrokeLine(BPoint(x,y-5), BPoint(x,y+5)); - float w1=(float)w*0.4; - float h1=(float)h*0.5; - float r=(float)w*0.2; + BView* view = new BView(inLayer->Bounds(), "tmp view", 0, 0); + (*outSelection)->AddChild(view); + view->SetHighColor(contrastingcolor(hi, lo)); + float x = lastpoint.x; + float y = lastpoint.y; + view->StrokeLine(BPoint(x - 5, y), BPoint(x + 5, y)); + view->StrokeLine(BPoint(x, y - 5), BPoint(x, y + 5)); + float w1 = (float)w * 0.4; + float h1 = (float)h * 0.5; + float r = (float)w * 0.2; view->StrokeEllipse(BPoint(w1, h1), r, r); view->Sync(); - (*outSelection)->RemoveChild (view); + (*outSelection)->RemoveChild(view); delete view; } } @@ -1092,7 +1167,8 @@ status_t process(Layer *inLayer, Selection *inSelection, error = 1; } - if (!buttons && view) view->mLastModifier = 0; + if (!buttons && view) + view->mLastModifier = 0; if (*outSelection) (*outSelection)->Unlock(); @@ -1103,4 +1179,3 @@ status_t process(Layer *inLayer, Selection *inSelection, //--------------------------------------------------------------------------- // eoc - diff --git a/source/add-ons/MotionBlur/MotionBlur.cpp b/source/add-ons/MotionBlur/MotionBlur.cpp index 5501714..ad4a80e 100644 --- a/source/add-ons/MotionBlur/MotionBlur.cpp +++ b/source/add-ons/MotionBlur/MotionBlur.cpp @@ -6,97 +6,105 @@ #include "Slider.h" #include -#define MAXSIZE 50 +#define MAXSIZE 50 -float gSize; -float gAngle; +float gSize; +float gAngle; class MotionBlurView : public BView { -public: - MotionBlurView (BRect rect) : BView (rect, "motion_blur_view", B_FOLLOW_ALL, B_WILL_DRAW) - { - gSize = 0; - gAngle = 0; - ResizeTo (188, 48); - Slider *sSlid = new Slider (BRect (8, 8, 180, 24), 60, "Distance", 2, MAXSIZE, 1, new BMessage ('mblS')); - Slider *aSlid = new Slider (BRect (8, 28, 180, 44), 60, "Angle", 0, 360, 1, new BMessage ('mblA')); - AddChild (sSlid); - AddChild (aSlid); - sSlid->SetValue (5); - aSlid->SetValue (0); - } -virtual ~MotionBlurView () {}; -virtual void MessageReceived (BMessage *msg); + public: + MotionBlurView(BRect rect) : BView(rect, "motion_blur_view", B_FOLLOW_ALL, B_WILL_DRAW) + { + gSize = 0; + gAngle = 0; + ResizeTo(188, 48); + Slider* sSlid = + new Slider(BRect(8, 8, 180, 24), 60, "Distance", 2, MAXSIZE, 1, new BMessage('mblS')); + Slider* aSlid = + new Slider(BRect(8, 28, 180, 44), 60, "Angle", 0, 360, 1, new BMessage('mblA')); + AddChild(sSlid); + AddChild(aSlid); + sSlid->SetValue(5); + aSlid->SetValue(0); + } + + virtual ~MotionBlurView(){}; + virtual void MessageReceived(BMessage* msg); }; -void MotionBlurView::MessageReceived (BMessage *msg) +void +MotionBlurView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'mblS': - gSize = msg->FindFloat ("value"); + gSize = msg->FindFloat("value"); break; case 'mblA': - gAngle = msg->FindFloat ("value"); + gAngle = msg->FindFloat("value"); break; default: - BView::MessageReceived (msg); + BView::MessageReceived(msg); return; } addon_preview(); } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Motion Blur"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998-2001 ∑ Sum Software"); - strcpy (info->description, "Mimics the effect of moving the camera while still open."); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 1; - info->release = 1; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "Motion Blur"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998-2001 ∑ Sum Software"); + strcpy(info->description, "Mimics the effect of moving the camera while still open."); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 1; + info->release = 1; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new MotionBlurView (rect); + *view = new MotionBlurView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /* frame */, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /* frame */, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); -// printf ("Bounds: "); -// bounds.PrintToStream(); -// printf ("Frame: "); -// frame->PrintToStream(); - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + // printf ("Bounds: "); + // bounds.PrintToStream(); + // printf ("Frame: "); + // frame->PrintToStream(); + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to blur! + *outSelection = new Selection(*inSelection); + else // No Selection to blur! return (0); } if (*outLayer) @@ -105,123 +113,104 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); int h = bounds.IntegerHeight() + 1; int w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits() - 1; - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits() - 1; + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. + float delta = 100.0 / h; // For the Status Bar. float distance = gSize; - float angle = gAngle*M_PI/180.0; - float cangle = cos (angle); - float sangle = sin (angle); - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits(); - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits() - 1; - uint32 pprs = inLayer->BytesPerRow()/4; + float angle = gAngle * M_PI / 180.0; + float cangle = cos(angle); + float sangle = sin(angle); + + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits(); + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits() - 1; + uint32 pprs = inLayer->BytesPerRow() / 4; /* Algorithm: Use the Bresenham line algorithm to `walk' along a line with the given angle and length, summing pixel values, and replace the original pixel with the average along that line. */ - + int32 sum[4]; bgra_pixel pixel; int x, y, i, xx, yy, n; int dx, dy, px, py, swapdir, e, s1, s2, err = 0; - + /* The actual work happens here */ - - for (y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + + for (y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (x = 0; x < w; x++) - { + for (x = 0; x < w; x++) { xx = x; yy = y; e = err; sum[0] = sum[1] = sum[2] = sum[3] = 0; - if (!inSelection || *(++mapbits)) - { - n = int (distance*(inSelection ? *mapbits : 255)/255); /* This effectively rounds it down */ - if (n > 1) - { - px = int (n*cangle); - py = int (n*sangle); - + if (!inSelection || *(++mapbits)) { + n = + int(distance * (inSelection ? *mapbits : 255) / 255 + ); /* This effectively rounds it down */ + if (n > 1) { + px = int(n * cangle); + py = int(n * sangle); + /* For the Bresenham algorithm (see Foley & Van Dam) dx = |x2 - x1|, s1 = sgn (x2 - x1) dy = |y2 - y1|, s2 = sgn (y2 - y1) */ - - if ((dx = px) != 0) - { - if (dx < 0) - { + + if ((dx = px) != 0) { + if (dx < 0) { dx = -dx; s1 = -1; - } - else + } else s1 = 1; - } - else + } else s1 = 0; - - if ((dy = py) != 0) - { - if (dy < 0) - { + + if ((dy = py) != 0) { + if (dy < 0) { dy = -dy; s2 = -1; - } - else + } else s2 = 1; - } - else + } else s2 = 0; - - if (dy > dx) - { + + if (dy > dx) { swapdir = dx; dx = dy; dy = swapdir; swapdir = 1; - } - else + } else swapdir = 0; - + dy *= 2; err = dy - dx; dx *= 2; - - for (i = 0; i < n; ) - { - pixel = (sbits + yy*pprs)[xx]; + + for (i = 0; i < n;) { + pixel = (sbits + yy * pprs)[xx]; sum[0] += RED(pixel); sum[1] += GREEN(pixel); sum[2] += BLUE(pixel); sum[3] += ALPHA(pixel); i++; - - while (e >= 0) - { + + while (e >= 0) { if (swapdir) xx += s1; else @@ -236,17 +225,14 @@ status_t process (Layer *inLayer, Selection *inSelection, if ((xx < 0) || (xx >= w) || (yy < 0) || (yy >= h)) break; } - } - else + } else i = 0; - } - else + } else i = 0; - + if (i == 0) - *(++dbits) = (sbits + y*pprs)[x]; - else - { + *(++dbits) = (sbits + y * pprs)[x]; + else { sum[0] /= i; sum[1] /= i; sum[2] /= i; @@ -258,102 +244,83 @@ status_t process (Layer *inLayer, Selection *inSelection, } break; } - case M_SELECT: - { + case M_SELECT: { if (!inSelection) *outSelection = NULL; - else - { - grey_pixel *sbits = mapbits; - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits() - 1; + else { + grey_pixel* sbits = mapbits; + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits() - 1; /* Algorithm: Use the Bresenham line algorithm to `walk' along a line with the given angle and length, summing pixel values, and replace the original pixel with the average along that line. */ - + int32 sum; grey_pixel pixel; int x, y, i, xx, yy, n; int dx, dy, px, py, swapdir, err, e, s1, s2; - + /* The actual work happens here */ - - n = int (distance); /* This effectively rounds it down */ - px = int (n*cangle); - py = int (n*sangle); - + + n = int(distance); /* This effectively rounds it down */ + px = int(n * cangle); + py = int(n * sangle); + /* For the Bresenham algorithm (see Foley & Van Dam) dx = |x2 - x1|, s1 = sgn (x2 - x1) dy = |y2 - y1|, s2 = sgn (y2 - y1) */ - - if ((dx = px) != 0) - { - if (dx < 0) - { + + if ((dx = px) != 0) { + if (dx < 0) { dx = -dx; s1 = -1; - } - else + } else s1 = 1; - } - else + } else s1 = 0; - - if ((dy = py) != 0) - { - if (dy < 0) - { + + if ((dy = py) != 0) { + if (dy < 0) { dy = -dy; s2 = -1; - } - else + } else s2 = 1; - } - else + } else s2 = 0; - - if (dy > dx) - { + + if (dy > dx) { swapdir = dx; dx = dy; dy = swapdir; swapdir = 1; - } - else + } else swapdir = 0; - + dy *= 2; err = dy - dx; dx *= 2; - for (y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + for (y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (x = 0; x < w; x++) - { + for (x = 0; x < w; x++) { xx = x; yy = y; e = err; sum = 0; - if (n > 1) - { - - for (i = 0; i < n; ) - { - pixel = (sbits + yy*mbpr)[xx]; + if (n > 1) { + + for (i = 0; i < n;) { + pixel = (sbits + yy * mbpr)[xx]; sum += pixel; i++; - - while (e >= 0) - { + + while (e >= 0) { if (swapdir) xx += s1; else @@ -368,14 +335,12 @@ status_t process (Layer *inLayer, Selection *inSelection, if ((xx < 0) || (xx >= w) || (yy < 0) || (yy >= h)) break; } - } - else + } else i = 0; - + if (i == 0) - *(++dbits) = (sbits + y*mbpr)[x]; - else - { + *(++dbits) = (sbits + y * mbpr)[x]; + else { sum /= i; *(++dbits) = sum; } @@ -386,7 +351,7 @@ status_t process (Layer *inLayer, Selection *inSelection, break; } default: - fprintf (stderr, "Blur: Unknown mode\n"); + fprintf(stderr, "Blur: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -394,7 +359,7 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); - + if (final) addon_done(); diff --git a/source/add-ons/MultiGradient/MultiGradient.cpp b/source/add-ons/MultiGradient/MultiGradient.cpp index 34fa480..f5bc515 100644 --- a/source/add-ons/MultiGradient/MultiGradient.cpp +++ b/source/add-ons/MultiGradient/MultiGradient.cpp @@ -6,33 +6,36 @@ #include #include -#define G_LINEAR 1 +#define G_LINEAR 1 #define G_CIRCULAR 2 -#define G_COSINE 3 +#define G_COSINE 3 class GradientWindow : public AddOnWindow { -public: - GradientWindow (BRect rect, becasso_addon_info *info) : AddOnWindow (rect, info) - { - fOrientation = G_LINEAR; - fSlope = G_LINEAR; - }; -virtual ~GradientWindow () {}; -virtual void MessageReceived (BMessage *msg); -int orientation () { return fOrientation; }; -int slope () { return fSlope; }; + public: + GradientWindow(BRect rect, becasso_addon_info* info) : AddOnWindow(rect, info) + { + fOrientation = G_LINEAR; + fSlope = G_LINEAR; + }; + + virtual ~GradientWindow(){}; + virtual void MessageReceived(BMessage* msg); + + int orientation() { return fOrientation; }; + + int slope() { return fSlope; }; -private: -typedef AddOnWindow inherited; -int fOrientation; -int fSlope; + private: + typedef AddOnWindow inherited; + int fOrientation; + int fSlope; }; -void GradientWindow::MessageReceived (BMessage *msg) +void +GradientWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'groL': fOrientation = G_LINEAR; break; @@ -49,90 +52,101 @@ void GradientWindow::MessageReceived (BMessage *msg) fSlope = G_CIRCULAR; break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); return; } aPreview(); } -GradientWindow *window; +GradientWindow* window; -int addon_init (uint32 index, becasso_addon_info *info) +int +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "MultiGradient"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1999 ∑ Sum Software"); - strcpy (info->description, "Generates a multicolor gradient"); - info->type = BECASSO_GENERATOR; - info->index = index; - info->version = 0; - info->release = 1; - info->becasso_version = 1; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE | PREVIEW_MOUSE; - window = new GradientWindow (BRect (100, 180, 100 + 188, 180 + 204), info); - BBox *orientation = new BBox (BRect (4, 4, 184, 58), "orientation"); - orientation->SetLabel ("Orientation"); - window->Background()->AddChild (orientation); - BRadioButton *oLinear = new BRadioButton (BRect (8, 13, 164, 30), "lin", "Linear", new BMessage ('groL')); - BRadioButton *oCircular = new BRadioButton (BRect (8, 30, 164, 47), "circ", "Circular", new BMessage ('groC')); - orientation->AddChild (oLinear); - orientation->AddChild (oCircular); - oLinear->SetValue (true); - BBox *slope = new BBox (BRect (4, 64, 184, 134), "slope"); - slope->SetLabel ("Slope"); - window->Background()->AddChild (slope); - BRadioButton *sLinear = new BRadioButton (BRect (8, 13, 164, 30), "slin", "Linear", new BMessage ('grsL')); - BRadioButton *sCosine = new BRadioButton (BRect (8, 30, 164, 47), "scos", "Half Cosine", new BMessage ('grsS')); - BRadioButton *sCircular = new BRadioButton (BRect (8, 47, 164, 64), "scirc", "Circle Arc", new BMessage ('grsC')); - slope->AddChild (sLinear); - slope->AddChild (sCosine); - slope->AddChild (sCircular); - sLinear->SetValue (true); + strcpy(info->name, "MultiGradient"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1999 ∑ Sum Software"); + strcpy(info->description, "Generates a multicolor gradient"); + info->type = BECASSO_GENERATOR; + info->index = index; + info->version = 0; + info->release = 1; + info->becasso_version = 1; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE | PREVIEW_MOUSE; + window = new GradientWindow(BRect(100, 180, 100 + 188, 180 + 204), info); + BBox* orientation = new BBox(BRect(4, 4, 184, 58), "orientation"); + orientation->SetLabel("Orientation"); + window->Background()->AddChild(orientation); + BRadioButton* oLinear = + new BRadioButton(BRect(8, 13, 164, 30), "lin", "Linear", new BMessage('groL')); + BRadioButton* oCircular = + new BRadioButton(BRect(8, 30, 164, 47), "circ", "Circular", new BMessage('groC')); + orientation->AddChild(oLinear); + orientation->AddChild(oCircular); + oLinear->SetValue(true); + BBox* slope = new BBox(BRect(4, 64, 184, 134), "slope"); + slope->SetLabel("Slope"); + window->Background()->AddChild(slope); + BRadioButton* sLinear = + new BRadioButton(BRect(8, 13, 164, 30), "slin", "Linear", new BMessage('grsL')); + BRadioButton* sCosine = + new BRadioButton(BRect(8, 30, 164, 47), "scos", "Half Cosine", new BMessage('grsS')); + BRadioButton* sCircular = + new BRadioButton(BRect(8, 47, 164, 64), "scirc", "Circle Arc", new BMessage('grsC')); + slope->AddChild(sLinear); + slope->AddChild(sCosine); + slope->AddChild(sCircular); + sLinear->SetValue(true); window->Run(); return (0); } -int addon_exit (void) +int +addon_exit(void) { return (0); } -int addon_open (BWindow *client, const char *name) +int +addon_open(BWindow* client, const char* name) { char title[B_FILE_NAME_LENGTH]; - sprintf (title, "Gradient %s", name); + sprintf(title, "Gradient %s", name); window->Lock(); - window->SetTitle (title); + window->SetTitle(title); if (window->IsHidden()) - window->aShow (client); + window->aShow(client); else - window->aActivate (client); + window->aActivate(client); window->Unlock(); return (0); } -int addon_close () +int +addon_close() { window->aClose(); return (0); } -int process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /* frame */, bool final, BPoint point, uint32 buttons) +int +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /* frame */, bool final, BPoint point, uint32 buttons +) { - static BPoint firstpoint = BPoint (-1, -1); - static BPoint lastpoint = BPoint (-1, -1); + static BPoint firstpoint = BPoint(-1, -1); + static BPoint lastpoint = BPoint(-1, -1); static bool entry = false; - - if (!final && buttons && !entry) // First entry of a realtime drag + + if (!final && buttons && !entry) // First entry of a realtime drag { firstpoint = point; entry = true; return (ADDON_OK); } - if (!final && !buttons) // Exit a realtime drag (buttons released) + if (!final && !buttons) // Exit a realtime drag (buttons released) { entry = false; } @@ -141,10 +155,10 @@ int process (Layer *inLayer, Selection *inSelection, int error = ADDON_OK; BRect bounds = inLayer->Bounds(); if (*outLayer == NULL && mode == M_DRAW) - *outLayer = new Layer (*inLayer); - + *outLayer = new Layer(*inLayer); + if (*outSelection == NULL && mode == M_SELECT) - *outSelection = new Selection (inLayer->Bounds()); + *outSelection = new Selection(inLayer->Bounds()); if (*outLayer) (*outLayer)->Lock(); @@ -152,203 +166,179 @@ int process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits() - 1; - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits() - 1; + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } - if (final) - { + if (final) { window->Lock(); window->Start(); window->Unlock(); } - float delta = 100.0/h; // For the Status Bar. - + float delta = 100.0 / h; // For the Status Bar. + rgb_color hi = highcolor(); rgb_color lo = lowcolor(); float vx = lastpoint.x - firstpoint.x; float vy = lastpoint.y - firstpoint.y; - float d = hypot (vx, vy); + float d = hypot(vx, vy); if (d < 1) d = 1; - float nx = vy/d; - float ny = -vx/d; + float nx = vy / d; + float ny = -vx / d; - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (uint32 *) inLayer->Bits() - 1; - bgra_pixel *dbits = (uint32 *) (*outLayer)->Bits() - 1; - for (uint32 y = 0; y < h; y++) - { - if (final) - { + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (uint32*)inLayer->Bits() - 1; + bgra_pixel* dbits = (uint32*)(*outLayer)->Bits() - 1; + for (uint32 y = 0; y < h; y++) { + if (final) { window->Lock(); - window->UpdateStatusBar (delta); - if (window->Stop()) - { + window->UpdateStatusBar(delta); + if (window->Stop()) { error = ADDON_ABORT; window->Unlock(); break; } window->Unlock(); } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { uint8 val = 0; float dist = 0; - switch (window->orientation()) - { - case G_LINEAR: - { - float f = ((x - firstpoint.x)*nx + (y - firstpoint.y)*ny); - float cx = firstpoint.x + f*nx; - float cy = firstpoint.y + f*ny; - dist = hypot (x - cx, y - cy); - if ((x - cx)*vx < 0 || (y - cy)*vy < 0) + switch (window->orientation()) { + case G_LINEAR: { + float f = ((x - firstpoint.x) * nx + (y - firstpoint.y) * ny); + float cx = firstpoint.x + f * nx; + float cy = firstpoint.y + f * ny; + dist = hypot(x - cx, y - cy); + if ((x - cx) * vx < 0 || (y - cy) * vy < 0) dist = 0; break; } case G_CIRCULAR: - dist = hypot (firstpoint.x - x, firstpoint.y - y); + dist = hypot(firstpoint.x - x, firstpoint.y - y); break; default: - printf ("Huu!\n"); + printf("Huu!\n"); break; } if (dist > d) dist = d; if (dist < 0) dist = 0; - switch (window->slope()) - { + switch (window->slope()) { case G_LINEAR: - val = grey_pixel (255*dist/d); + val = grey_pixel(255 * dist / d); break; case G_CIRCULAR: - val = grey_pixel (255 - 255*sqrt (1 - dist*dist/(d*d))); + val = grey_pixel(255 - 255 * sqrt(1 - dist * dist / (d * d))); break; case G_COSINE: - val = grey_pixel (255 - 127.5*(cos (M_PI*dist/d) + 1)); + val = grey_pixel(255 - 127.5 * (cos(M_PI * dist / d) + 1)); break; default: - printf ("Huu!\n"); + printf("Huu!\n"); break; } - bgra_pixel pixel = weighted_average_rgb (lo, val, hi, 255 - val) & COLOR_MASK; - if (inSelection) - { - *(++dbits) = pixelblend (*(++sbits), (pixel | (*(++mapbits) << ALPHA_BPOS))); - } - else - { + bgra_pixel pixel = weighted_average_rgb(lo, val, hi, 255 - val) & COLOR_MASK; + if (inSelection) { + *(++dbits) = pixelblend(*(++sbits), (pixel | (*(++mapbits) << ALPHA_BPOS))); + } else { *(++dbits) = pixel | ALPHA_MASK; sbits++; } } mapbits += mdiff; } - if (*outLayer && buttons) - { - BView *view = new BView (inLayer->Bounds(), "tmp view", 0, 0); - (*outLayer)->AddChild (view); - view->SetHighColor (contrastingcolor (hi, lo)); - view->StrokeLine (firstpoint, lastpoint); + if (*outLayer && buttons) { + BView* view = new BView(inLayer->Bounds(), "tmp view", 0, 0); + (*outLayer)->AddChild(view); + view->SetHighColor(contrastingcolor(hi, lo)); + view->StrokeLine(firstpoint, lastpoint); view->Sync(); - (*outLayer)->RemoveChild (view); + (*outLayer)->RemoveChild(view); delete view; } break; } - case M_SELECT: - { - for (uint32 y = 0; y < h; y++) - { - if (final) - { + case M_SELECT: { + for (uint32 y = 0; y < h; y++) { + if (final) { window->Lock(); - window->UpdateStatusBar (delta); - if (window->Stop()) - { + window->UpdateStatusBar(delta); + if (window->Stop()) { error = ADDON_ABORT; window->Unlock(); break; } window->Unlock(); } - grey_pixel *sbits = 0; + grey_pixel* sbits = 0; if (inSelection) - sbits = (grey_pixel *) inSelection->Bits() + y*mbpr - 1; - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits() + y*mbpr - 1; - for (uint32 x = 0; x < w; x++) - { + sbits = (grey_pixel*)inSelection->Bits() + y * mbpr - 1; + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits() + y * mbpr - 1; + for (uint32 x = 0; x < w; x++) { uint8 val = 0; float dist = 0; - switch (window->orientation()) - { - case G_LINEAR: - { - float f = ((x - firstpoint.x)*nx + (y - firstpoint.y)*ny); - float cx = firstpoint.x + f*nx; - float cy = firstpoint.y + f*ny; - dist = hypot (x - cx, y - cy); - if ((x - cx)*vx < 0 || (y - cy)*vy < 0) + switch (window->orientation()) { + case G_LINEAR: { + float f = ((x - firstpoint.x) * nx + (y - firstpoint.y) * ny); + float cx = firstpoint.x + f * nx; + float cy = firstpoint.y + f * ny; + dist = hypot(x - cx, y - cy); + if ((x - cx) * vx < 0 || (y - cy) * vy < 0) dist = 0; break; } case G_CIRCULAR: - dist = hypot (firstpoint.x - x, firstpoint.y - y); + dist = hypot(firstpoint.x - x, firstpoint.y - y); break; default: - printf ("Huu!\n"); + printf("Huu!\n"); break; } if (dist > d) dist = d; if (dist < 0) dist = 0; - switch (window->slope()) - { + switch (window->slope()) { case G_LINEAR: - val = grey_pixel (255 - 255*dist/d); + val = grey_pixel(255 - 255 * dist / d); break; case G_CIRCULAR: - val = grey_pixel (255*sqrt (1 - dist*dist/(d*d))); + val = grey_pixel(255 * sqrt(1 - dist * dist / (d * d))); break; case G_COSINE: - val = grey_pixel (127.5*(cos (M_PI*dist/d) + 1)); + val = grey_pixel(127.5 * (cos(M_PI * dist / d) + 1)); break; default: - printf ("Huu!\n"); + printf("Huu!\n"); break; } if (inSelection) - *(++dbits) = val*(*(++sbits))/255; + *(++dbits) = val * (*(++sbits)) / 255; else *(++dbits) = val; } } - if (*outSelection && buttons) - { - BView *view = new BView (inLayer->Bounds(), "tmp view", 0, 0); - (*outSelection)->AddChild (view); - view->SetHighColor (Black); - view->StrokeLine (firstpoint, lastpoint); + if (*outSelection && buttons) { + BView* view = new BView(inLayer->Bounds(), "tmp view", 0, 0); + (*outSelection)->AddChild(view); + view->SetHighColor(Black); + view->StrokeLine(firstpoint, lastpoint); view->Sync(); - (*outSelection)->RemoveChild (view); + (*outSelection)->RemoveChild(view); delete view; } break; } default: - fprintf (stderr, "MultiGradient: Unknown mode\n"); + fprintf(stderr, "MultiGradient: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -357,12 +347,11 @@ int process (Layer *inLayer, Selection *inSelection, if (*outLayer) (*outLayer)->Unlock(); - if (final) - { + if (final) { window->Lock(); window->Stopped(); window->Unlock(); } - + return (error); } diff --git a/source/add-ons/Negate/Negate.cpp b/source/add-ons/Negate/Negate.cpp index b51a86e..49f03d9 100644 --- a/source/add-ons/Negate/Negate.cpp +++ b/source/add-ons/Negate/Negate.cpp @@ -5,55 +5,60 @@ #include "AddOnSupport.h" #include -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Negate"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1999-2001 ∑ Sum Software"); - strcpy (info->description, "Inverts the image"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 0; - info->release = 3; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "Negate"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1999-2001 ∑ Sum Software"); + strcpy(info->description, "Inverts the image"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 0; + info->release = 3; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = NULL; // Negate doesn't have a GUI + *view = NULL; // Negate doesn't have a GUI return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); -// printf ("Bounds: "); -// bounds.PrintToStream(); -// printf ("Frame: "); -// frame->PrintToStream(); + // printf ("Bounds: "); + // bounds.PrintToStream(); + // printf ("Frame: "); + // frame->PrintToStream(); if (*outLayer == NULL && mode == M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); + *outSelection = new Selection(*inSelection); else return (0); } @@ -63,79 +68,65 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { // printf ("inSelection\n"); - mapbits = (grey_pixel *) inSelection->Bits(); - mbpr = inSelection->BytesPerRow(); + mapbits = (grey_pixel*)inSelection->Bits(); + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - - float delta = 100.0/h; // For the Status Bar. - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (uint32 *) inLayer->Bits() - 1; - bgra_pixel *dbits = (uint32 *) (*outLayer)->Bits() - 1; - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + float delta = 100.0 / h; // For the Status Bar. + + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (uint32*)inLayer->Bits() - 1; + bgra_pixel* dbits = (uint32*)(*outLayer)->Bits() - 1; + + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { grey_pixel mp = inSelection ? *(++mapbits) : 255; - if (mp) - { + if (mp) { bgra_pixel p = *(++sbits); - bgra_pixel gp = PIXEL (255 - RED(p), 255 - GREEN(p), 255 - BLUE(p), ALPHA(p)); + bgra_pixel gp = PIXEL(255 - RED(p), 255 - GREEN(p), 255 - BLUE(p), ALPHA(p)); if (mp == 255) *(++dbits) = gp; else - *(++dbits) = weighted_average (gp, mp, p, 255 - mp); - } - else + *(++dbits) = weighted_average(gp, mp, p, 255 - mp); + } else *(++dbits) = *(++sbits); } mapbits += mdiff; } break; } - case M_SELECT: - { - grey_pixel *sbits = (grey_pixel *) inSelection->Bits() - 1; - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits() - 1; + case M_SELECT: { + grey_pixel* sbits = (grey_pixel*)inSelection->Bits() - 1; + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits() - 1; int32 sdiff = inSelection->BytesPerRow() - w; int32 ddiff = (*outSelection)->BytesPerRow() - w; - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { *(++dbits) = 255 - *(++sbits); } sbits += sdiff; @@ -144,7 +135,7 @@ status_t process (Layer *inLayer, Selection *inSelection, break; } default: - fprintf (stderr, "Negate: Unknown mode\n"); + fprintf(stderr, "Negate: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -152,9 +143,9 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); - + if (final) addon_done(); - + return error; } diff --git a/source/add-ons/Noise/Noise.cpp b/source/add-ons/Noise/Noise.cpp index a283f1f..e7c31e3 100644 --- a/source/add-ons/Noise/Noise.cpp +++ b/source/add-ons/Noise/Noise.cpp @@ -9,50 +9,57 @@ #include #include -#define N_ADDITIVE 1 +#define N_ADDITIVE 1 #define N_MULTIPLICATIVE 2 -#define MAXRANDSIZE 256 -#define MAXAMOUNT 127 +#define MAXRANDSIZE 256 +#define MAXAMOUNT 127 -int gSigma; -int gType; +int gSigma; +int gType; int xvec[MAXRANDSIZE]; -void fillvector (int x); -int random (int max); +void +fillvector(int x); +int +random(int max); class NoiseView : public BView { -public: - NoiseView (BRect rect) : BView (rect, "noise_view", B_FOLLOW_NONE, B_WILL_DRAW) - { - gSigma = 5; - gType = N_ADDITIVE; - ResizeTo (188, 82); - Slider *xSlid = new Slider (BRect (8, 62, 180, 78), 50, "Sigma", 1, MAXAMOUNT, 1, new BMessage ('nSch')); - AddChild (xSlid); - BBox *type = new BBox (BRect (4, 4, 184, 58), "type"); - type->SetLabel ("Type"); - AddChild (type); - BRadioButton *tAdd = new BRadioButton (BRect (8, 13, 164, 30), "add", "Additive", new BMessage ('nTad')); - BRadioButton *tMul = new BRadioButton (BRect (8, 30, 164, 47), "mul", "Multiplicative", new BMessage ('nTmp')); - type->AddChild (tAdd); - type->AddChild (tMul); - tAdd->SetValue (true); - xSlid->SetValue (5); - fillvector (5); - } -virtual ~NoiseView () {} -virtual void MessageReceived (BMessage *msg); + public: + NoiseView(BRect rect) : BView(rect, "noise_view", B_FOLLOW_NONE, B_WILL_DRAW) + { + gSigma = 5; + gType = N_ADDITIVE; + ResizeTo(188, 82); + Slider* xSlid = + new Slider(BRect(8, 62, 180, 78), 50, "Sigma", 1, MAXAMOUNT, 1, new BMessage('nSch')); + AddChild(xSlid); + BBox* type = new BBox(BRect(4, 4, 184, 58), "type"); + type->SetLabel("Type"); + AddChild(type); + BRadioButton* tAdd = + new BRadioButton(BRect(8, 13, 164, 30), "add", "Additive", new BMessage('nTad')); + BRadioButton* tMul = + new BRadioButton(BRect(8, 30, 164, 47), "mul", "Multiplicative", new BMessage('nTmp')); + type->AddChild(tAdd); + type->AddChild(tMul); + tAdd->SetValue(true); + xSlid->SetValue(5); + fillvector(5); + } + + virtual ~NoiseView() {} + + virtual void MessageReceived(BMessage* msg); }; -void NoiseView::MessageReceived (BMessage *msg) +void +NoiseView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'nSch': - gSigma = int (msg->FindFloat ("value") + 0.5); - fillvector (gSigma); + gSigma = int(msg->FindFloat("value") + 0.5); + fillvector(gSigma); break; case 'nTad': gType = N_ADDITIVE; @@ -61,78 +68,84 @@ void NoiseView::MessageReceived (BMessage *msg) gType = N_MULTIPLICATIVE; break; default: - BView::MessageReceived (msg); + BView::MessageReceived(msg); return; } addon_preview(); } -void fillvector (int x) +void +fillvector(int x) { - for (int i = 0; i < MAXRANDSIZE; i++) - { - float r = float (i)/MAXRANDSIZE*4; - xvec[i] = int (x*exp (-r) * ((i & 1) ? 1 : -1)); + for (int i = 0; i < MAXRANDSIZE; i++) { + float r = float(i) / MAXRANDSIZE * 4; + xvec[i] = int(x * exp(-r) * ((i & 1) ? 1 : -1)); } } -int random (int m) +int +random(int m) { - return (int ((double) (rand())*m/RAND_MAX)); + return (int((double)(rand()) * m / RAND_MAX)); // A bit convoluted, but this is necessary on GCC because RAND_MAX is MAX_INT. } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Noise"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1999-2001 ∑ Sum Software"); - strcpy (info->description, "Adds noise to the image"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 1; - info->release = 2; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "Noise"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1999-2001 ∑ Sum Software"); + strcpy(info->description, "Adds noise to the image"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 1; + info->release = 2; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new NoiseView (rect); + *view = new NoiseView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /* frame */, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /* frame */, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); -// printf ("Bounds: "); -// bounds.PrintToStream(); -// printf ("Frame: "); -// frame->PrintToStream(); + // printf ("Bounds: "); + // bounds.PrintToStream(); + // printf ("Frame: "); + // frame->PrintToStream(); - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to diffuse! + *outSelection = new Selection(*inSelection); + else // No Selection to diffuse! return (0); } if (*outLayer) @@ -141,105 +154,83 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits(); - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits(); + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits() - 1; - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits() - 1; + float delta = 100.0 / h; // For the Status Bar. + + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits() - 1; + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits() - 1; - switch (gType) - { - case N_ADDITIVE: - { - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + switch (gType) { + case N_ADDITIVE: { + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { - if (!inSelection) - { - rgb_color p = bgra2rgb (*(++sbits)); - char amount = xvec[random (MAXRANDSIZE)]; - p.red = clipchar (p.red + amount); - p.green = clipchar (p.green + amount); - p.blue = clipchar (p.blue + amount); - *(++dbits) = rgb2bgra (p); - } - else if (*(++mapbits)) - { - rgb_color p = bgra2rgb (*(++sbits)); - char amount = xvec[random (MAXRANDSIZE)]* *mapbits/255; - p.red = clipchar (p.red + amount); - p.green = clipchar (p.green + amount); - p.blue = clipchar (p.blue + amount); - *(++dbits) = rgb2bgra (p); - } - else + for (uint32 x = 0; x < w; x++) { + if (!inSelection) { + rgb_color p = bgra2rgb(*(++sbits)); + char amount = xvec[random(MAXRANDSIZE)]; + p.red = clipchar(p.red + amount); + p.green = clipchar(p.green + amount); + p.blue = clipchar(p.blue + amount); + *(++dbits) = rgb2bgra(p); + } else if (*(++mapbits)) { + rgb_color p = bgra2rgb(*(++sbits)); + char amount = xvec[random(MAXRANDSIZE)] * *mapbits / 255; + p.red = clipchar(p.red + amount); + p.green = clipchar(p.green + amount); + p.blue = clipchar(p.blue + amount); + *(++dbits) = rgb2bgra(p); + } else *(++dbits) = *(++sbits); } mapbits += mdiff; } break; } - case N_MULTIPLICATIVE: - { - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + case N_MULTIPLICATIVE: { + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { - if (!inSelection) - { - rgb_color p = bgra2rgb (*(++sbits)); - char amount = xvec[random (MAXRANDSIZE)]; + for (uint32 x = 0; x < w; x++) { + if (!inSelection) { + rgb_color p = bgra2rgb(*(++sbits)); + char amount = xvec[random(MAXRANDSIZE)]; int factor = 255 + amount; - p.red = clipchar (p.red*factor/255); - p.green = clipchar (p.green*factor/255); - p.blue = clipchar (p.blue*factor/255); - *(++dbits) = rgb2bgra (p); - } - else if (*(++mapbits)) - { - rgb_color p = bgra2rgb (*(++sbits)); - char amount = xvec[random (MAXRANDSIZE)] * *mapbits/255; + p.red = clipchar(p.red * factor / 255); + p.green = clipchar(p.green * factor / 255); + p.blue = clipchar(p.blue * factor / 255); + *(++dbits) = rgb2bgra(p); + } else if (*(++mapbits)) { + rgb_color p = bgra2rgb(*(++sbits)); + char amount = xvec[random(MAXRANDSIZE)] * *mapbits / 255; int factor = 255 + amount; - p.red = clipchar (p.red*factor/255); - p.green = clipchar (p.green*factor/255); - p.blue = clipchar (p.blue*factor/255); - *(++dbits) = rgb2bgra (p); - } - else + p.red = clipchar(p.red * factor / 255); + p.green = clipchar(p.green * factor / 255); + p.blue = clipchar(p.blue * factor / 255); + *(++dbits) = rgb2bgra(p); + } else *(++dbits) = *(++sbits); } mapbits += mdiff; @@ -247,74 +238,62 @@ status_t process (Layer *inLayer, Selection *inSelection, break; } default: - fprintf (stderr, "Noise: Unknown type\n"); + fprintf(stderr, "Noise: Unknown type\n"); } break; } - case M_SELECT: - { + case M_SELECT: { if (!inSelection) *outSelection = NULL; - else - { - grey_pixel *sbits = mapbits; - grey_pixel *dbits = (grey_pixel *) (*outSelection)->Bits(); + else { + grey_pixel* sbits = mapbits; + grey_pixel* dbits = (grey_pixel*)(*outSelection)->Bits(); - switch (gType) - { - case N_ADDITIVE: - { - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + switch (gType) { + case N_ADDITIVE: { + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - grey_pixel *srcline = sbits + y*mbpr - 1; - grey_pixel *destline = dbits + y*mbpr - 1; - for (uint32 x = 0; x < w; x++) - { - *(++destline) = clipchar (*(++srcline) + xvec[random (MAXRANDSIZE)]); + grey_pixel* srcline = sbits + y * mbpr - 1; + grey_pixel* destline = dbits + y * mbpr - 1; + for (uint32 x = 0; x < w; x++) { + *(++destline) = clipchar(*(++srcline) + xvec[random(MAXRANDSIZE)]); } } break; } - case N_MULTIPLICATIVE: - { - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + case N_MULTIPLICATIVE: { + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - grey_pixel *srcline = sbits + y*mbpr - 1; - grey_pixel *destline = dbits + y*mbpr - 1; - for (uint32 x = 0; x < w; x++) - { - *(++destline) = clipchar (*(++srcline)*(255 + xvec[random (MAXRANDSIZE)])/255); + grey_pixel* srcline = sbits + y * mbpr - 1; + grey_pixel* destline = dbits + y * mbpr - 1; + for (uint32 x = 0; x < w; x++) { + *(++destline) = + clipchar(*(++srcline) * (255 + xvec[random(MAXRANDSIZE)]) / 255); } } break; } default: - fprintf (stderr, "Noise: Unknown type\n"); + fprintf(stderr, "Noise: Unknown type\n"); } break; } break; } default: - fprintf (stderr, "Noise: Unknown mode\n"); + fprintf(stderr, "Noise: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -322,7 +301,7 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); - + if (final) addon_done(); diff --git a/source/add-ons/OilPaint/OilPaint.cpp b/source/add-ons/OilPaint/OilPaint.cpp index c57fe1e..859c2ef 100644 --- a/source/add-ons/OilPaint/OilPaint.cpp +++ b/source/add-ons/OilPaint/OilPaint.cpp @@ -5,54 +5,56 @@ #include "Slider.h" #include -// Simulate an oil painting by replacing each pixel with the most frequently +// Simulate an oil painting by replacing each pixel with the most frequently // appearing color in an n x n grid around it. // NB: This is a very straightforward implementation, and NOT very efficient! class cn_list { -public: - cn_list (int _max) : fMax (_max), fIndex (0), fMf (0) - { - clist = new bgra_pixel[fMax]; - nlist = new int[fMax]; - }; -virtual ~cn_list () - { - delete [] clist; - delete [] nlist; - }; -int add (bgra_pixel c); -void reset () - { - fIndex = 0; - fMf = 0; - } -bgra_pixel most_frequent (); - -private: -bgra_pixel *clist; -int *nlist; -int fMax; -int fIndex; -int fMf; + public: + cn_list(int _max) : fMax(_max), fIndex(0), fMf(0) + { + clist = new bgra_pixel[fMax]; + nlist = new int[fMax]; + }; + + virtual ~cn_list() + { + delete[] clist; + delete[] nlist; + }; + + int add(bgra_pixel c); + + void reset() + { + fIndex = 0; + fMf = 0; + } + + bgra_pixel most_frequent(); + + private: + bgra_pixel* clist; + int* nlist; + int fMax; + int fIndex; + int fMf; }; -int cn_list::add (bgra_pixel c) +int +cn_list::add(bgra_pixel c) { - for (int i = 0; i < fIndex; i++) - { - if (clist[i] == c) - { + for (int i = 0; i < fIndex; i++) { + if (clist[i] == c) { if (++nlist[i] > nlist[fMf]) fMf = i; return (i); } } - if (fIndex == fMax) - { - fprintf (stderr, "cn_list: Too many items\n"); + if (fIndex == fMax) { + fprintf(stderr, "cn_list: Too many items\n"); return (-1); } clist[fIndex] = c; @@ -60,95 +62,101 @@ int cn_list::add (bgra_pixel c) return (fIndex - 1); } -bgra_pixel cn_list::most_frequent () +bgra_pixel +cn_list::most_frequent() { - if (nlist[fMf] == 1) // Apparently, only different colors. Return the original middle pixel. - return (clist[fIndex/2]); + if (nlist[fMf] == 1) // Apparently, only different colors. Return the original middle pixel. + return (clist[fIndex / 2]); return clist[fMf]; } -int gSize; +int gSize; class OilView : public BView { -public: - OilView (BRect rect) : BView (rect, "oil_view", B_FOLLOW_ALL, B_WILL_DRAW) - { - gSize = 5; - ResizeTo (188, 28); - Slider *sSlid = new Slider (BRect (8, 8, 180, 24), 64, "Mask Size", 3, 15, 2, new BMessage ('oilS')); - sSlid->SetValue (5); - AddChild (sSlid); - } -virtual ~OilView () {}; -virtual void MessageReceived (BMessage *msg); + public: + OilView(BRect rect) : BView(rect, "oil_view", B_FOLLOW_ALL, B_WILL_DRAW) + { + gSize = 5; + ResizeTo(188, 28); + Slider* sSlid = + new Slider(BRect(8, 8, 180, 24), 64, "Mask Size", 3, 15, 2, new BMessage('oilS')); + sSlid->SetValue(5); + AddChild(sSlid); + } + + virtual ~OilView(){}; + virtual void MessageReceived(BMessage* msg); }; -void OilView::MessageReceived (BMessage *msg) +void +OilView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'oilS': - gSize = int (msg->FindFloat ("value") + 0.5); + gSize = int(msg->FindFloat("value") + 0.5); break; default: - BView::MessageReceived (msg); + BView::MessageReceived(msg); return; } addon_preview(); } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "OilPaint"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998-2001 ∑ Sum Software"); - strcpy (info->description, "Simulates an oil painting effect"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 0; - info->release = 7; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "OilPaint"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998-2001 ∑ Sum Software"); + strcpy(info->description, "Simulates an oil painting effect"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 0; + info->release = 7; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } - -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new OilView (rect); + *view = new OilView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /* frame */, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /* frame */, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); - if (*outLayer == NULL && mode== M_DRAW) - { - *outLayer = new Layer (*inLayer); + if (*outLayer == NULL && mode == M_DRAW) { + *outLayer = new Layer(*inLayer); // printf ("Allocated new outLayer\n"); } - if (mode == M_SELECT) - { + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to filter! + *outSelection = new Selection(*inSelection); + else // No Selection to filter! return (0); } if (*outLayer) @@ -157,97 +165,90 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); int32 h = bounds.IntegerHeight() + 1; int32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits() - 1; - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits() - 1; + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. + float delta = 100.0 / h; // For the Status Bar. - switch (mode) - { - case M_DRAW: - { - uint32 slpr = inLayer->BytesPerRow()/4; - uint32 dlpr = (*outLayer)->BytesPerRow()/4; - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits() - 1; + switch (mode) { + case M_DRAW: { + uint32 slpr = inLayer->BytesPerRow() / 4; + uint32 dlpr = (*outLayer)->BytesPerRow() / 4; + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits() - 1; int size = gSize; - int hsize = size/2; // Rounded down. Size is always odd. - cn_list colors (size*size); - -// printf ("size = %i, hsize = %i\n", size, hsize); -// printf ("slpr = %i, dlpr = %i, h = %i, w = %i\n", slpr, (*outLayer)->BytesPerRow(), h, w); - for (int32 y = 0; y < h; y++) - { - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits() + y*dlpr - 1; - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + int hsize = size / 2; // Rounded down. Size is always odd. + cn_list colors(size * size); + + // printf ("size = %i, hsize = %i\n", size, hsize); + // printf ("slpr = %i, dlpr = %i, h = %i, w = %i\n", slpr, (*outLayer)->BytesPerRow(), + // h, w); + for (int32 y = 0; y < h; y++) { + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits() + y * dlpr - 1; + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (int32 x = 0; x < w; x++) - { - if (!inSelection || *(++mapbits)) - { + for (int32 x = 0; x < w; x++) { + if (!inSelection || *(++mapbits)) { int f = 255; if (inSelection) f = *mapbits; - - int32 cl = x - hsize*f/255; - if (cl < 0) cl = 0; - int32 cr = x + hsize*f/255; - if (cr > w - 1) cr = w - 1; - int32 cu = y - hsize*f/255; - if (cu < 0) cu = 0; - int32 cb = y + hsize*f/255; - if (cb > h - 1) cb = h - 1; - - //printf ("(%i, %i) ", y, x); fflush (stdout); - //printf ("LT (%i, %i), RB: (%i, %i)\n", cu, cl, cb, cr); + + int32 cl = x - hsize * f / 255; + if (cl < 0) + cl = 0; + int32 cr = x + hsize * f / 255; + if (cr > w - 1) + cr = w - 1; + int32 cu = y - hsize * f / 255; + if (cu < 0) + cu = 0; + int32 cb = y + hsize * f / 255; + if (cb > h - 1) + cb = h - 1; + + // printf ("(%i, %i) ", y, x); fflush (stdout); + // printf ("LT (%i, %i), RB: (%i, %i)\n", cu, cl, cb, cr); colors.reset(); - for (int32 i = cu; i <= cb; i++) - { - bgra_pixel *s = sbits + i*slpr + cl; + for (int32 i = cu; i <= cb; i++) { + bgra_pixel* s = sbits + i * slpr + cl; for (int32 j = cl; j <= cr; j++) - colors.add (*(++s)); + colors.add(*(++s)); } // printf ("(%ld, %ld) -> %p\n", x, y, colors.most_frequent()); *(++dbits) = colors.most_frequent(); - } - else - *(++dbits) = *(sbits + y*slpr + x); + } else + *(++dbits) = *(sbits + y * slpr + x); } if (inSelection) mapbits += mdiff; } break; } - case M_SELECT: - { + case M_SELECT: { if (!inSelection) *outSelection = NULL; - else - { + else { } break; } default: - fprintf (stderr, "OilPaint: Unknown mode\n"); + fprintf(stderr, "OilPaint: Unknown mode\n"); error = ADDON_UNKNOWN; } - + if (*outSelection) (*outSelection)->Unlock(); if (*outLayer) diff --git a/source/add-ons/Palmcam/Palmcam.cpp b/source/add-ons/Palmcam/Palmcam.cpp index a59af93..9d7e16a 100644 --- a/source/add-ons/Palmcam/Palmcam.cpp +++ b/source/add-ons/Palmcam/Palmcam.cpp @@ -22,80 +22,87 @@ #include #include "BeDSC.h" -BeDSC *camera = NULL; +BeDSC* camera = NULL; int cursel = -1; int nsel = 0; int my_addon_index = 0; - class CaptureWindow : public BWindow { -public: - CaptureWindow (BRect rect) : BWindow (rect, "PalmCam", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK) - { - fBPS = B_9600_BPS; - fPort[0] = 0; - abort = false; - } -virtual ~CaptureWindow () {} -virtual void MessageReceived (BMessage *msg); -virtual bool QuitRequested () - { - Hide(); - if (camera) camera->Close(); - return false; - } - -const char *portName () { return fPort; } -data_rate portBPS () { return fBPS; }; - -BButton *fGrab; -BButton *fErase; -BButton *fAbort; -BListView *fList; -BStatusBar *fStatusBar; - -bool abort; - -private: -typedef BWindow inherited; -data_rate fBPS; -char fPort[64]; + public: + CaptureWindow(BRect rect) + : BWindow(rect, "PalmCam", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK) + { + fBPS = B_9600_BPS; + fPort[0] = 0; + abort = false; + } + + virtual ~CaptureWindow() {} + + virtual void MessageReceived(BMessage* msg); + + virtual bool QuitRequested() + { + Hide(); + if (camera) + camera->Close(); + return false; + } + + const char* portName() { return fPort; } + + data_rate portBPS() { return fBPS; }; + + BButton* fGrab; + BButton* fErase; + BButton* fAbort; + BListView* fList; + BStatusBar* fStatusBar; + + bool abort; + + private: + typedef BWindow inherited; + data_rate fBPS; + char fPort[64]; }; -status_t reopen_camera (const char *port, data_rate bps); -status_t update_list (); +status_t +reopen_camera(const char* port, data_rate bps); +status_t +update_list(); -void CaptureWindow::MessageReceived (BMessage *msg) +void +CaptureWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'bps1': fBPS = B_9600_BPS; - reopen_camera (fPort, fBPS); + reopen_camera(fPort, fBPS); break; case 'bps2': fBPS = B_19200_BPS; - reopen_camera (fPort, fBPS); + reopen_camera(fPort, fBPS); break; case 'bps3': fBPS = B_38400_BPS; - reopen_camera (fPort, fBPS); + reopen_camera(fPort, fBPS); break; case 'bps4': fBPS = B_57600_BPS; - reopen_camera (fPort, fBPS); + reopen_camera(fPort, fBPS); break; case 'PCpt': - const char *name; - msg->FindString ("port", &name); - strcpy (fPort, name); - reopen_camera (fPort, fBPS); + const char* name; + msg->FindString("port", &name); + strcpy(fPort, name); + reopen_camera(fPort, fBPS); break; case 'PCab': abort = true; break; - case 'PCsc': // Selection changed + case 'PCsc': // Selection changed { // BStringItem *item; bool someselected = false; @@ -103,122 +110,113 @@ void CaptureWindow::MessageReceived (BMessage *msg) int32 lastselected = 0; nsel = 0; cursel = 0; - while ((selected = fList->CurrentSelection (i++)) >= 0) - { + while ((selected = fList->CurrentSelection(i++)) >= 0) { someselected = true; lastselected = selected; nsel++; } - if (someselected) - { - if (camera->Preview (lastselected + 1) != B_OK) - printf ("Error previewing (%ld)\n", lastselected + 1); + if (someselected) { + if (camera->Preview(lastselected + 1) != B_OK) + printf("Error previewing (%ld)\n", lastselected + 1); } - fGrab->SetEnabled (someselected); - fErase->SetEnabled (someselected); + fGrab->SetEnabled(someselected); + fErase->SetEnabled(someselected); break; } - case 'PCer': // erase items from camera + case 'PCer': // erase items from camera { -// printf ("Erase selection...\n"); + // printf ("Erase selection...\n"); bool someselected = false; int32 selected, i = 0; nsel = 0; cursel = 0; - while ((selected = fList->CurrentSelection (i++)) >= 0) - { + while ((selected = fList->CurrentSelection(i++)) >= 0) { someselected = true; } // We have to delete top-down because otherwise indices change during the process. - if (someselected) - { + if (someselected) { float numitems = --i; fStatusBar->Reset(); i--; -// printf ("Items to be erased: %d. First: %ld\n", int (numitems), i); - while ((selected = fList->CurrentSelection (i)) >= 0) - { -// camera->Preview (selected + 1); - fStatusBar->Update (100.0/numitems); -// printf ("Deleting %ld\n", selected + 1); - if (camera->Delete (selected + 1) != B_OK) - printf ("Error deleting (%ld) from camera\n", selected + 1); - fList->RemoveItem (selected); + // printf ("Items to be erased: %d. First: %ld\n", int (numitems), i); + while ((selected = fList->CurrentSelection(i)) >= 0) { + // camera->Preview (selected + 1); + fStatusBar->Update(100.0 / numitems); + // printf ("Deleting %ld\n", selected + 1); + if (camera->Delete(selected + 1) != B_OK) + printf("Error deleting (%ld) from camera\n", selected + 1); + fList->RemoveItem(selected); i--; } } - fGrab->SetEnabled (false); - fErase->SetEnabled (false); + fGrab->SetEnabled(false); + fErase->SetEnabled(false); fStatusBar->Reset(); break; } - case CAPTURE_READY: - { + case CAPTURE_READY: { // We get here when there was a multiple selection. // Horrible Hack alert!! // - BMessenger app (be_app); - snooze (1000000); // Let's hope the image has been opened by now. - app.SendMessage (msg); + BMessenger app(be_app); + snooze(1000000); // Let's hope the image has been opened by now. + app.SendMessage(msg); break; } default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); break; } } -CaptureWindow *window; +CaptureWindow* window; -status_t reopen_camera (const char *port, data_rate bps) +status_t +reopen_camera(const char* port, data_rate bps) { extern int DebugLevel; - if (!camera) - { + if (!camera) { if (DebugLevel) - fprintf (stderr, "No camera\n"); + fprintf(stderr, "No camera\n"); return B_ERROR; } - + if (DebugLevel) - fprintf (stderr, "Trying to close the camera\n"); -// delete camera; -// camera = new DSC(); + fprintf(stderr, "Trying to close the camera\n"); + // delete camera; + // camera = new DSC(); - if (camera->Close() != B_OK) - { + if (camera->Close() != B_OK) { // Could be that the camera simply wasn't opened. No problem. } - - if (DebugLevel) - { - fprintf (stderr, "Trying to open camera at %s... ", port); - fflush (stderr); + + if (DebugLevel) { + fprintf(stderr, "Trying to open camera at %s... ", port); + fflush(stderr); } - - if (camera->Open (port, bps) != B_OK) - { - fprintf (stderr, "Error opening camera\n"); + + if (camera->Open(port, bps) != B_OK) { + fprintf(stderr, "Error opening camera\n"); return B_ERROR; } if (DebugLevel) - fprintf (stderr, "Opened.\n"); - + fprintf(stderr, "Opened.\n"); + window->Lock(); window->fStatusBar->Reset(); - for (int i = 0; i < DSCPAUSE*8; i++) - { - window->fStatusBar->Update (100.0/(8*DSCPAUSE)); + for (int i = 0; i < DSCPAUSE * 8; i++) { + window->fStatusBar->Update(100.0 / (8 * DSCPAUSE)); window->UpdateIfNeeded(); - snooze (125000); // Wait for the camera to redraw its screen + snooze(125000); // Wait for the camera to redraw its screen } window->fStatusBar->Reset(); window->Unlock(); - return (update_list ()); + return (update_list()); } -status_t update_list () +status_t +update_list() { window->fList->MakeEmpty(); nsel = 0; @@ -226,152 +224,149 @@ status_t update_list () if (!camera) return B_ERROR; - + int n, nimg; dsc_quality_t qbuf[DSCMAXIMAGE]; - if ((nimg = camera->GetIndex (qbuf)) == -1) - { + if ((nimg = camera->GetIndex(qbuf)) == -1) { return B_OK; } extern int DebugLevel; if (DebugLevel) - fprintf (stderr, "%d images\n", nimg); - - for (n = 0; n < nimg; n++) - { + fprintf(stderr, "%d images\n", nimg); + + for (n = 0; n < nimg; n++) { char item[128]; - sprintf (item, "dsc%04u.jpg (%7ld) - ", n + 1, camera->RequestImage (n + 1)); - switch (qbuf[n]) - { - case normal: - strcat (item, "normal"); - break; - case fine: - strcat (item, "fine"); - break; - case superfine: - strcat (item, "superfine"); - break; - default: - strcat (item, "[???]"); - break; + sprintf(item, "dsc%04u.jpg (%7ld) - ", n + 1, camera->RequestImage(n + 1)); + switch (qbuf[n]) { + case normal: + strcat(item, "normal"); + break; + case fine: + strcat(item, "fine"); + break; + case superfine: + strcat(item, "superfine"); + break; + default: + strcat(item, "[???]"); + break; } - window->fList->AddItem (new BStringItem (item)); + window->fList->AddItem(new BStringItem(item)); } return B_OK; } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "PalmCam Capture"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 2000-2001 ∑ Sum Software, Fredrik Roubert"); - strcpy (info->description, "Panasonic PalmCam digital camera Capture add-on"); - info->type = BECASSO_CAPTURE; - info->index = index; - info->version = 0; - info->release = 5; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = 0; - info->flags = 0; - window = new CaptureWindow (BRect (100, 180, 100 + 300, 180 + 178)); - BView *bg = new BView (BRect (0, 0, 300, 178), "bg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); - bg->SetViewColor (LightGrey); - window->AddChild (bg); - - BPopUpMenu *portPU = new BPopUpMenu ("Port"); + strcpy(info->name, "PalmCam Capture"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 2000-2001 ∑ Sum Software, Fredrik Roubert"); + strcpy(info->description, "Panasonic PalmCam digital camera Capture add-on"); + info->type = BECASSO_CAPTURE; + info->index = index; + info->version = 0; + info->release = 5; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = 0; + info->flags = 0; + window = new CaptureWindow(BRect(100, 180, 100 + 300, 180 + 178)); + BView* bg = new BView(BRect(0, 0, 300, 178), "bg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); + bg->SetViewColor(LightGrey); + window->AddChild(bg); + + BPopUpMenu* portPU = new BPopUpMenu("Port"); // Get the available serial ports - BDirectory dir ("/dev/ports"); + BDirectory dir("/dev/ports"); BEntry entry; bool foundone = false; - while (dir.GetNextEntry (&entry, true) == B_OK) - { + while (dir.GetNextEntry(&entry, true) == B_OK) { foundone = true; char name[B_FILE_NAME_LENGTH]; - entry.GetName (name); - BMessage *msg = new BMessage ('PCpt'); - msg->AddString ("port", name); - portPU->AddItem (new BMenuItem (name, msg)); + entry.GetName(name); + BMessage* msg = new BMessage('PCpt'); + msg->AddString("port", name); + portPU->AddItem(new BMenuItem(name, msg)); } - if (!foundone) - { - portPU->AddItem (new BMenuItem ("", NULL)); + if (!foundone) { + portPU->AddItem(new BMenuItem("", NULL)); } - BMenuField *portMF = new BMenuField (BRect (8, 4, 120, 24), "dPort", "Port: ", portPU); - portMF->SetDivider (40); - bg->AddChild (portMF); - - BPopUpMenu *speedPU = new BPopUpMenu (""); - speedPU->AddItem (new BMenuItem (" 9600", new BMessage ('bps1'))); - speedPU->AddItem (new BMenuItem ("19200", new BMessage ('bps2'))); - speedPU->AddItem (new BMenuItem ("38400", new BMessage ('bps3'))); - speedPU->AddItem (new BMenuItem ("57600", new BMessage ('bps4'))); - speedPU->ItemAt(0)->SetMarked (true); - BMenuField *speedMF = new BMenuField (BRect (8, 28, 120, 48), "dSpeed", "Speed: ", speedPU); - speedMF->SetDivider (40); - bg->AddChild (speedMF); - + BMenuField* portMF = new BMenuField(BRect(8, 4, 120, 24), "dPort", "Port: ", portPU); + portMF->SetDivider(40); + bg->AddChild(portMF); + + BPopUpMenu* speedPU = new BPopUpMenu(""); + speedPU->AddItem(new BMenuItem(" 9600", new BMessage('bps1'))); + speedPU->AddItem(new BMenuItem("19200", new BMessage('bps2'))); + speedPU->AddItem(new BMenuItem("38400", new BMessage('bps3'))); + speedPU->AddItem(new BMenuItem("57600", new BMessage('bps4'))); + speedPU->ItemAt(0)->SetMarked(true); + BMenuField* speedMF = new BMenuField(BRect(8, 28, 120, 48), "dSpeed", "Speed: ", speedPU); + speedMF->SetDivider(40); + bg->AddChild(speedMF); + my_addon_index = index; - BMessage *msg = new BMessage (CAPTURE_READY); - msg->AddInt32 ("index", index); - window->fGrab = new BButton (BRect (8, 60, 60, 80), "grab", "Grab", msg); - window->fGrab->SetTarget (be_app); - window->fGrab->SetEnabled (false); - bg->AddChild (window->fGrab); - - window->fErase = new BButton (BRect (8, 88, 60, 108), "erase", "Erase", new BMessage ('PCer')); - window->fErase->SetEnabled (false); - bg->AddChild (window->fErase); - - window->fAbort = new BButton (BRect (8, 116, 60, 136), "abort", "Abort", new BMessage ('PCab')); - window->fAbort->SetEnabled (false); - bg->AddChild (window->fAbort); - - window->fList = new BListView (BRect (110, 8, 294 - B_V_SCROLL_BAR_WIDTH, 170), "image list", B_MULTIPLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES); - window->fList->SetSelectionMessage (new BMessage ('PCsc')); - - BScrollView *scroller = new BScrollView ("scroller", window->fList, B_FOLLOW_ALL_SIDES, 0, false, true); - bg->AddChild (scroller); - - window->fStatusBar = new BStatusBar (BRect (8, 148, 102, 171), "status"); - window->fStatusBar->SetResizingMode (B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); - window->fStatusBar->SetBarHeight (10.0); - bg->AddChild (window->fStatusBar); - + BMessage* msg = new BMessage(CAPTURE_READY); + msg->AddInt32("index", index); + window->fGrab = new BButton(BRect(8, 60, 60, 80), "grab", "Grab", msg); + window->fGrab->SetTarget(be_app); + window->fGrab->SetEnabled(false); + bg->AddChild(window->fGrab); + + window->fErase = new BButton(BRect(8, 88, 60, 108), "erase", "Erase", new BMessage('PCer')); + window->fErase->SetEnabled(false); + bg->AddChild(window->fErase); + + window->fAbort = new BButton(BRect(8, 116, 60, 136), "abort", "Abort", new BMessage('PCab')); + window->fAbort->SetEnabled(false); + bg->AddChild(window->fAbort); + + window->fList = new BListView( + BRect(110, 8, 294 - B_V_SCROLL_BAR_WIDTH, 170), "image list", B_MULTIPLE_SELECTION_LIST, + B_FOLLOW_ALL_SIDES + ); + window->fList->SetSelectionMessage(new BMessage('PCsc')); + + BScrollView* scroller = + new BScrollView("scroller", window->fList, B_FOLLOW_ALL_SIDES, 0, false, true); + bg->AddChild(scroller); + + window->fStatusBar = new BStatusBar(BRect(8, 148, 102, 171), "status"); + window->fStatusBar->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); + window->fStatusBar->SetBarHeight(10.0); + bg->AddChild(window->fStatusBar); + camera = new BeDSC(); window->Run(); return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { delete camera; return B_OK; } -status_t addon_open (void) +status_t +addon_open(void) { extern int DebugLevel; window->Lock(); if (window->IsHidden()) - window->Show (); + window->Show(); else - window->Activate (); + window->Activate(); window->Unlock(); - if (!window->portName()[0]) - { + if (!window->portName()[0]) { if (DebugLevel) - fprintf (stderr, "No port defined for the camera yet\n"); - } - else if (camera->Open (window->portName(), window->portBPS()) != B_OK) - { + fprintf(stderr, "No port defined for the camera yet\n"); + } else if (camera->Open(window->portName(), window->portBPS()) != B_OK) { if (DebugLevel) - fprintf (stderr, "Couldn't open camera at %s\n", window->portName()); - } - else - { + fprintf(stderr, "Couldn't open camera at %s\n", window->portName()); + } else { update_list(); window->Lock(); window->fList->Invalidate(); @@ -381,80 +376,75 @@ status_t addon_open (void) return B_OK; } -BBitmap *bitmap (char *title) +BBitmap* +bitmap(char* title) { int32 selected; - if (!nsel || cursel == -1) - { - fprintf (stderr, "PalmCam error - somehow nothing is selected.\n"); - + if (!nsel || cursel == -1) { + fprintf(stderr, "PalmCam error - somehow nothing is selected.\n"); + // Just to make sure, diable the buttons. - window->fGrab->SetEnabled (false); - window->fErase->SetEnabled (false); - - strcpy (title, "Error"); + window->fGrab->SetEnabled(false); + window->fErase->SetEnabled(false); + + strcpy(title, "Error"); return (NULL); } - selected = window->fList->CurrentSelection (cursel++) + 1; // The Palmcam starts at #1 - + selected = window->fList->CurrentSelection(cursel++) + 1; // The Palmcam starts at #1 + // Retreive the image from the camera - sprintf (title, "dsc%04u.jpg", int (selected)); - ssize_t imgsize = camera->RequestImage (selected); - if (imgsize == -1) - { - fprintf (stderr, "PalmCam error - file size of image %ld reported to be -1\n", selected); - strcpy (title, "Error"); + sprintf(title, "dsc%04u.jpg", int(selected)); + ssize_t imgsize = camera->RequestImage(selected); + if (imgsize == -1) { + fprintf(stderr, "PalmCam error - file size of image %ld reported to be -1\n", selected); + strcpy(title, "Error"); return (NULL); } extern int DebugLevel; if (DebugLevel) - fprintf (stderr, "Image size of %ld is %ld bytes\n", selected, imgsize); - - ssize_t upimgsize = (imgsize/2048 + 1)*2048; // Round up for some extra space - uint8 *imgbuf = new uint8 [upimgsize]; - + fprintf(stderr, "Image size of %ld is %ld bytes\n", selected, imgsize); + + ssize_t upimgsize = (imgsize / 2048 + 1) * 2048; // Round up for some extra space + uint8* imgbuf = new uint8[upimgsize]; + window->Lock(); - window->fAbort->SetEnabled (true); + window->fAbort->SetEnabled(true); window->fStatusBar->Reset(); window->Unlock(); ssize_t s, bf; int i; - for (i = 0, s = 0; s < imgsize; ) - { + for (i = 0, s = 0; s < imgsize;) { window->Lock(); - window->fStatusBar->Update (102400.0/imgsize, title); + window->fStatusBar->Update(102400.0 / imgsize, title); window->Unlock(); - if (window->abort) - { - fprintf (stderr, "Transfer aborted\n"); - strcpy (title, "Aborted"); + if (window->abort) { + fprintf(stderr, "Transfer aborted\n"); + strcpy(title, "Aborted"); cursel--; - delete [] imgbuf; + delete[] imgbuf; window->Lock(); - window->fAbort->SetEnabled (false); + window->fAbort->SetEnabled(false); window->fStatusBar->Reset(); window->abort = false; window->Unlock(); return NULL; } - if ((bf = camera->ReadImageBlock (i, imgbuf + s)) == -1) // Error reading block + if ((bf = camera->ReadImageBlock(i, imgbuf + s)) == -1) // Error reading block { - if (camera->RequestImage (selected) == -1) // Something's seriously wrong. Bail out. + if (camera->RequestImage(selected) == -1) // Something's seriously wrong. Bail out. { - fprintf (stderr, "PalmCam error during file transfer\n"); - strcpy (title, "Error"); - delete [] imgbuf; + fprintf(stderr, "PalmCam error during file transfer\n"); + strcpy(title, "Error"); + delete[] imgbuf; window->Lock(); window->fStatusBar->Reset(); window->Unlock(); return (NULL); } // else simply retry - } - else - { + } else { i++; s += bf; } @@ -462,37 +452,36 @@ BBitmap *bitmap (char *title) window->Lock(); window->fStatusBar->Reset(); window->Unlock(); - + // OK, we now have a JPEG image in imgbuf. Use the Translation Kit to make that into a bitmap. BBitmapStream outStream; - BMemoryIO inStream (imgbuf, upimgsize); - BBitmap *b = NULL; - if (BTranslatorRoster::Default()->Translate (&inStream, NULL, NULL, &outStream, B_TRANSLATOR_BITMAP) < B_OK) - { + BMemoryIO inStream(imgbuf, upimgsize); + BBitmap* b = NULL; + if (BTranslatorRoster::Default()->Translate( + &inStream, NULL, NULL, &outStream, B_TRANSLATOR_BITMAP + ) < B_OK) { // Something went wrong translating the JPEG - fprintf (stderr, "PalmCam error during JPEG translation\n"); - strcpy (title, "Error"); + fprintf(stderr, "PalmCam error during JPEG translation\n"); + strcpy(title, "Error"); return NULL; } - outStream.DetachBitmap (&b); - - delete [] imgbuf; - - if (cursel < nsel) // There are some more images to get... + outStream.DetachBitmap(&b); + + delete[] imgbuf; + + if (cursel < nsel) // There are some more images to get... { - BMessage *msg = new BMessage (CAPTURE_READY); - msg->AddInt32 ("index", my_addon_index); - BMessenger me (window); + BMessage* msg = new BMessage(CAPTURE_READY); + msg->AddInt32("index", my_addon_index); + BMessenger me(window); window->Lock(); - me.SendMessage (msg); + me.SendMessage(msg); window->Unlock(); - } - else - { + } else { window->Lock(); - window->fAbort->SetEnabled (false); + window->fAbort->SetEnabled(false); window->Unlock(); } - + return b; } diff --git a/source/add-ons/Palmcam/dc1000.c b/source/add-ons/Palmcam/dc1000.c index cccdcf3..94e1623 100644 --- a/source/add-ons/Palmcam/dc1000.c +++ b/source/add-ons/Palmcam/dc1000.c @@ -12,131 +12,126 @@ #include #include -#if __BEOS__ && _X86_ && ! __GNU_LIBRARY__ -# define __GNU_LIBRARY__ 1 +#if __BEOS__ && _X86_ && !__GNU_LIBRARY__ +#define __GNU_LIBRARY__ 1 #endif #if __GNU_LIBRARY__ -# include +#include #endif #ifndef NOSIG -# include +#include #endif #if __BEOS__ -# include -# include +#include +#include #endif #include "dsc.h" -#define FILENAME "dsc%04u.jpg" -#define THUMBFILENAME "dsc%04u-thumbnail.jpg" +#define FILENAME "dsc%04u.jpg" +#define THUMBFILENAME "dsc%04u-thumbnail.jpg" -static const char envport[] = "DSCPORT", - envbaud[] = "DSCBAUD"; +static const char envport[] = "DSCPORT", envbaud[] = "DSCBAUD"; -const speed_t defaultbaud = B9600; +const speed_t defaultbaud = B9600; #if __BEOS__ -static const char attr[] = "BEOS:TYPE", - mime[] = "image/jpeg"; +static const char attr[] = "BEOS:TYPE", mime[] = "image/jpeg"; #endif -#if defined(DEBUG) && ! defined(__BASE_FILE__) -# define __BASE_FILE__ "dc1000.c" +#if defined(DEBUG) && !defined(__BASE_FILE__) +#define __BASE_FILE__ "dc1000.c" #endif #if __GNU_LIBRARY__ -# define TRYHELP "Try `%s --help' for more information.\n" +#define TRYHELP "Try `%s --help' for more information.\n" #else -# define TRYHELP "Try `%s -h' for more information.\n" +#define TRYHELP "Try `%s -h' for more information.\n" #endif -int list(dsc_t*); -int listlong(dsc_t*); -int get(dsc_t*, int*, const char*, int, int, int); -int getall(dsc_t*, int, int, int); -int thumbnail(dsc_t*, int*, const char*, int, int); -int thumbnailall(dsc_t*, int, int); -int show(dsc_t*, int*, int); -int delete(dsc_t*, int*, int); -int parse(int*, const char*); -int getimage(dsc_t*, int, const char*, int, int, int); +int +list(dsc_t*); +int +listlong(dsc_t*); +int +get(dsc_t*, int*, const char*, int, int, int); +int +getall(dsc_t*, int, int, int); +int +thumbnail(dsc_t*, int*, const char*, int, int); +int +thumbnailall(dsc_t*, int, int); +int +show(dsc_t*, int*, int); +int delete(dsc_t*, int*, int); +int +parse(int*, const char*); +int +getimage(dsc_t*, int, const char*, int, int, int); #ifndef NOSIG -void sigint_h(int); +void +sigint_h(int); #endif -const char *logname; +const char* logname; static int sigint = 0; #ifdef NOSIG -# define sleep_s sleep +#define sleep_s sleep #else /* sleep() wakes up when a signal arrives */ -void sleep_s(unsigned int seconds) +void +sleep_s(unsigned int seconds) { - for (; seconds; seconds = sleep(seconds)); + for (; seconds; seconds = sleep(seconds)) + ; } #endif -int main(int argc, char *argv[]) +int +main(int argc, char* argv[]) { - char op = '\0'; - dsc_t *dsc; - int error = 0; - dsc_error dsc_open_error; + char op = '\0'; + dsc_t* dsc; + int error = 0; + dsc_error dsc_open_error; #ifndef NOSIG - struct sigaction sigact; + struct sigaction sigact; #endif - const char *port = NULL, - *output = NULL, - *cbaud = NULL; - speed_t baud = B0; - int flag_V = 0, - flag_q = 0, - flag_c = 0, - index[DSCMAXIMAGE + 1]; + const char *port = NULL, *output = NULL, *cbaud = NULL; + speed_t baud = B0; + int flag_V = 0, flag_q = 0, flag_c = 0, index[DSCMAXIMAGE + 1]; logname = argv[0]; index[0] = 0; - for (;;) - { - int c; + for (;;) { + int c; static const char optstring[] = "hvp:b:o:VqclLg:Gt:Ts:d:"; #if __GNU_LIBRARY__ - static const struct option longopts[] = - { - { "help", no_argument, NULL, 'h' }, - { "version", no_argument, NULL, 'v' }, - { "port", required_argument, NULL, 'p' }, - { "baud", required_argument, NULL, 'b' }, - { "output", required_argument, NULL, 'o' }, - { "verbose", no_argument, NULL, 'V' }, - { "quiet", no_argument, NULL, 'q' }, - { "silent", no_argument, NULL, 'q' }, - { "continue", no_argument, NULL, 'c' }, - { "list", no_argument, NULL, 'l' }, - { "listlong", no_argument, NULL, 'L' }, - { "get", required_argument, NULL, 'g' }, - { "getall", no_argument, NULL, 'G' }, - { "thumbnail", required_argument, NULL, 't' }, - { "thumbnailall", no_argument, NULL, 'T' }, - { "show", required_argument, NULL, 's' }, - { "delete", required_argument, NULL, 'd' }, - { 0, 0, 0, 0 } + static const struct option longopts[] = { + {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'v'}, + {"port", required_argument, NULL, 'p'}, {"baud", required_argument, NULL, 'b'}, + {"output", required_argument, NULL, 'o'}, {"verbose", no_argument, NULL, 'V'}, + {"quiet", no_argument, NULL, 'q'}, {"silent", no_argument, NULL, 'q'}, + {"continue", no_argument, NULL, 'c'}, {"list", no_argument, NULL, 'l'}, + {"listlong", no_argument, NULL, 'L'}, {"get", required_argument, NULL, 'g'}, + {"getall", no_argument, NULL, 'G'}, {"thumbnail", required_argument, NULL, 't'}, + {"thumbnailall", no_argument, NULL, 'T'}, {"show", required_argument, NULL, 's'}, + {"delete", required_argument, NULL, 'd'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, optstring, longopts, NULL); @@ -147,143 +142,130 @@ int main(int argc, char *argv[]) if (c == EOF) break; - switch (c) - { - case 'h': /* help */ - printf - ( -"\n" -"Usage: %s [-p port] [-b rate] [-o file] [-Vqc] {-hvlLGT|-gtsd index}\n" -"\n" + switch (c) { + case 'h': /* help */ + printf( + "\n" + "Usage: %s [-p port] [-b rate] [-o file] [-Vqc] {-hvlLGT|-gtsd index}\n" + "\n" #if __GNU_LIBRARY__ -" -p, --port=NAME use camera connected to serial port NAME\n" -" -b, --baud=RATE communicate at line speed RATE\n" -" -o, --output=NAME write to file NAME, used in conjunction with -g\n" -" -V, --verbose explain what is being done\n" -" -q, --quiet, --silent don't print status during file transfer\n" -" -c, --continue continue an aborted transfer\n" -"\n" -" -h, --help show this text\n" -" -v, --version show program version\n" -" -l, --list list the contents of the camera memory\n" -" -L, --listlong like list, but also shows the size of each image\n" -" -g, --get=INDEX transfer image(s) INDEX from the camera\n" -" -G, --getall transfer all images from the camera\n" -" -t, --thumbnail=INDEX transfer thumbnail(s) INDEX from the camera\n" -" -T, --thumbnailall transfer all thubmnails from the camera\n" -" -s, --show=INDEX show image(s) INDEX on the camera display\n" -" -d, --delete=INDEX delete image(s) INDEX from the camera memory\n" + " -p, --port=NAME use camera connected to serial port NAME\n" + " -b, --baud=RATE communicate at line speed RATE\n" + " -o, --output=NAME write to file NAME, used in conjunction with -g\n" + " -V, --verbose explain what is being done\n" + " -q, --quiet, --silent don't print status during file transfer\n" + " -c, --continue continue an aborted transfer\n" + "\n" + " -h, --help show this text\n" + " -v, --version show program version\n" + " -l, --list list the contents of the camera memory\n" + " -L, --listlong like list, but also shows the size of each image\n" + " -g, --get=INDEX transfer image(s) INDEX from the camera\n" + " -G, --getall transfer all images from the camera\n" + " -t, --thumbnail=INDEX transfer thumbnail(s) INDEX from the camera\n" + " -T, --thumbnailall transfer all thubmnails from the camera\n" + " -s, --show=INDEX show image(s) INDEX on the camera display\n" + " -d, --delete=INDEX delete image(s) INDEX from the camera memory\n" #else -" -p NAME use camera connected to serial port NAME\n" -" -b RATE communicate at line speed RATE\n" -" -o NAME write to file NAME, used in conjunction with -g\n" -" -V explain what is being done\n" -" -q don't print status during file transfer\n" -" -c continue an aborted transfer\n" -"\n" -" -h show this text\n" -" -v show program version\n" -" -l list the contents of the camera memory\n" -" -L like list, but also shows the size of each image\n" -" -g INDEX transfer image(s) INDEX from the camera\n" -" -G transfer all images from the camera\n" -" -t INDEX transfer thumbnail(s) INDEX from the camera\n" -" -T transfer all thubmnails from the camera\n" -" -s INDEX show image(s) INDEX on the camera display\n" -" -d INDEX delete image(s) INDEX from the camera memory\n" + " -p NAME use camera connected to serial port NAME\n" + " -b RATE communicate at line speed RATE\n" + " -o NAME write to file NAME, used in conjunction with -g\n" + " -V explain what is being done\n" + " -q don't print status during file transfer\n" + " -c continue an aborted transfer\n" + "\n" + " -h show this text\n" + " -v show program version\n" + " -l list the contents of the camera memory\n" + " -L like list, but also shows the size of each image\n" + " -g INDEX transfer image(s) INDEX from the camera\n" + " -G transfer all images from the camera\n" + " -t INDEX transfer thumbnail(s) INDEX from the camera\n" + " -T transfer all thubmnails from the camera\n" + " -s INDEX show image(s) INDEX on the camera display\n" + " -d INDEX delete image(s) INDEX from the camera memory\n" #endif -"\n" -"Report bugs to .\n" -"\n", argv[0] - ); - return 0; - - case 'v': /* version */ - printf( -"dc1000 0.5 (2000-06-02) BeOS beta\n" -"Copyright (C) 2000 Fredrik Roubert \n" -"dc1580 code copyright (C) 1999 Galen Brooks \n" -"This program comes with NO WARRANTY, to the extent permitted by law.\n" -"You may freely distribute copies of the program as long as this\n" -"copyright notice is left intact.\n" - ); - return 0; + "\n" + "Report bugs to .\n" + "\n", + argv[0] + ); + return 0; + + case 'v': /* version */ + printf("dc1000 0.5 (2000-06-02) BeOS beta\n" + "Copyright (C) 2000 Fredrik Roubert \n" + "dc1580 code copyright (C) 1999 Galen Brooks \n" + "This program comes with NO WARRANTY, to the extent permitted by law.\n" + "You may freely distribute copies of the program as long as this\n" + "copyright notice is left intact.\n"); + return 0; + + case 'p': /* port */ + port = optarg; + break; - case 'p': /* port */ - port = optarg; - break; + case 'b': /* baud */ + cbaud = optarg; + break; - case 'b': /* baud */ - cbaud = optarg; - break; + case 'o': /* output */ + output = optarg; + break; - case 'o': /* output */ - output = optarg; - break; + case 'V': /* verbose */ + flag_V = 1; + break; - case 'V': /* verbose */ - flag_V = 1; - break; + case 'q': /* quiet */ + flag_q = 1; + break; - case 'q': /* quiet */ - flag_q = 1; - break; + case 'c': /* continue */ + flag_c = 1; + break; - case 'c': /* continue */ - flag_c = 1; - break; + case 'g': /* get */ + case 't': /* thumbnail */ + case 's': /* show */ + case 'd': /* delete */ + if (parse(index, optarg) == -1) + return -1; - case 'g': /* get */ - case 't': /* thumbnail */ - case 's': /* show */ - case 'd': /* delete */ - if (parse(index, optarg) == -1) - return -1; - - case 'l': /* list */ - case 'L': /* listlong */ - case 'G': /* getall */ - case 'T': /* thumbnailall */ - op = c; - break; + case 'l': /* list */ + case 'L': /* listlong */ + case 'G': /* getall */ + case 'T': /* thumbnailall */ + op = c; + break; - case '?': - fprintf(stderr, TRYHELP, logname); - return 1; + case '?': + fprintf(stderr, TRYHELP, logname); + return 1; - default: - fprintf( - stderr, - "%s: error parsing command line, " + default: + fprintf( + stderr, + "%s: error parsing command line, " #if __GNU_LIBRARY__ - "getopt_long()" + "getopt_long()" #else - "getopt()" + "getopt()" #endif - " returned 0x%02x\n", - logname, c - ); - return 1; + " returned 0x%02x\n", + logname, c + ); + return 1; } } - if (optind < argc) - { - fprintf( - stderr, - "%s: unrecognized argument `%s'\n", - logname, argv[optind] - ); + if (optind < argc) { + fprintf(stderr, "%s: unrecognized argument `%s'\n", logname, argv[optind]); return 1; } - if (! op) - { - fprintf( - stderr, - "%s: nothing to do\n" TRYHELP, - logname, logname - ); + if (!op) { + fprintf(stderr, "%s: nothing to do\n" TRYHELP, logname, logname); return 1; } @@ -293,65 +275,49 @@ int main(int argc, char *argv[]) if (cbaud == NULL) cbaud = getenv(envbaud); - if (port == NULL) - { - fprintf( - stderr, - "%s: no port specified\n" TRYHELP, - logname, logname - ); + if (port == NULL) { + fprintf(stderr, "%s: no port specified\n" TRYHELP, logname, logname); return 1; } if (cbaud == NULL) baud = defaultbaud; else - switch (atoi(cbaud)) - { - case 9600: - baud = B9600; - break; + switch (atoi(cbaud)) { + case 9600: + baud = B9600; + break; - case 19200: - baud = B19200; - break; + case 19200: + baud = B19200; + break; - case 38400: - baud = B38400; - break; + case 38400: + baud = B38400; + break; - case 57600: - baud = B57600; - break; + case 57600: + baud = B57600; + break; - default: - fprintf( - stderr, - "%s: unsupported baudrate `%u'\n" - "Use one of 9600, 19200, 38400 " - "or 57600 instead.\n", - logname, atoi(cbaud) - ); - return 1; + default: + fprintf( + stderr, + "%s: unsupported baudrate `%u'\n" + "Use one of 9600, 19200, 38400 " + "or 57600 instead.\n", + logname, atoi(cbaud) + ); + return 1; } if (output != NULL && op != 'g') - fprintf( - stderr, - "%s: Ignoring option -o when using -%c\n", - logname, op - ); + fprintf(stderr, "%s: Ignoring option -o when using -%c\n", logname, op); - if ( output != NULL && - op == 'g' && - index[0] == 1 && - output[0] == '-' && - output[1] == '\0') - { + if (output != NULL && op == 'g' && index[0] == 1 && output[0] == '-' && output[1] == '\0') { flag_q = 1; - if (flag_V) - { + if (flag_V) { flag_V = 0; fprintf( stderr, @@ -361,8 +327,7 @@ int main(int argc, char *argv[]) ); } - if (flag_c) - { + if (flag_c) { flag_c = 0; fprintf( stderr, @@ -373,8 +338,7 @@ int main(int argc, char *argv[]) } } - if (flag_c && op != 'g' && op != 'G') - { + if (flag_c && op != 'g' && op != 'G') { flag_c = 0; fprintf( stderr, @@ -384,36 +348,32 @@ int main(int argc, char *argv[]) ); } - if (flag_V) - { + if (flag_V) { printf("\nPort: %s\nBaud: ", port); - switch (baud) - { - case B9600: - printf("9600"); - break; + switch (baud) { + case B9600: + printf("9600"); + break; - case B19200: - printf("19200"); - break; + case B19200: + printf("19200"); + break; - case B38400: - printf("38400"); - break; + case B38400: + printf("38400"); + break; - case B57600: - printf("57600"); - break; + case B57600: + printf("57600"); + break; } - if (index[0] > 0) - { - int i, f; + if (index[0] > 0) { + int i, f; printf(index[0] > 1 ? "\n\nImages: " : "\n\nImage: "); - for (i = 1, f = 1; i <= DSCMAXIMAGE; i ++) - if (index[i]) - { + for (i = 1, f = 1; i <= DSCMAXIMAGE; i++) + if (index[i]) { if (f) f = 0; else @@ -431,119 +391,85 @@ int main(int argc, char *argv[]) sigact.sa_flags = 0; if (sigaction(SIGINT, &sigact, NULL) == -1) - fprintf( - stderr, - "%s: System call sigaction() failed\n", - logname - ); + fprintf(stderr, "%s: System call sigaction() failed\n", logname); #endif - if ((dsc = dsc_open(port, baud, &dsc_open_error)) == NULL) - { - fprintf( - stderr, - "%s: %s\n", - logname, - dsc_strerror(&dsc_open_error) - ); + if ((dsc = dsc_open(port, baud, &dsc_open_error)) == NULL) { + fprintf(stderr, "%s: %s\n", logname, dsc_strerror(&dsc_open_error)); return 1; } - if (flag_V) - { + if (flag_V) { printf("Connected. Camera model is "); - switch (dsc->type) - { - case unknown: - printf("unknown"); - break; + switch (dsc->type) { + case unknown: + printf("unknown"); + break; - case dsc1: - printf("DC1000"); - break; + case dsc1: + printf("DC1000"); + break; - case dsc2: - printf("DC1580"); - break; + case dsc2: + printf("DC1580"); + break; } printf(".\nWaiting for camera to redraw screen...\n"); } sleep_s(DSCPAUSE); - if (! sigint) - switch (op) - { - case 'l': /* list */ - if (flag_V) - printf( - "Requesting index " - "from camera...\n" - ); - error = list(dsc); - break; + if (!sigint) + switch (op) { + case 'l': /* list */ + if (flag_V) + printf("Requesting index " + "from camera...\n"); + error = list(dsc); + break; - case 'L': /* listlong */ - if (flag_V) - printf( - "Requesting index " - "from camera...\n" - ); - error = listlong(dsc); - break; + case 'L': /* listlong */ + if (flag_V) + printf("Requesting index " + "from camera...\n"); + error = listlong(dsc); + break; - case 'g': /* get */ - error = get( - dsc, index, output, - flag_V, flag_q, flag_c - ); - break; + case 'g': /* get */ + error = get(dsc, index, output, flag_V, flag_q, flag_c); + break; - case 'G': /* getall */ - error = getall(dsc, flag_V, flag_q, flag_c); - break; + case 'G': /* getall */ + error = getall(dsc, flag_V, flag_q, flag_c); + break; - case 't': /* thumbnail */ - error = thumbnail( - dsc, index, output, - flag_V, flag_q - ); - break; + case 't': /* thumbnail */ + error = thumbnail(dsc, index, output, flag_V, flag_q); + break; - case 'T': /* thumbnailall */ - error = thumbnailall(dsc, flag_V, flag_q); - break; + case 'T': /* thumbnailall */ + error = thumbnailall(dsc, flag_V, flag_q); + break; - case 's': /* show */ - error = show(dsc, index, flag_V); - break; + case 's': /* show */ + error = show(dsc, index, flag_V); + break; - case 'd': /* delete */ - error = delete(dsc, index, flag_V); - break; + case 'd': /* delete */ + error = delete (dsc, index, flag_V); + break; } if (sigint) fprintf(stderr, "%s: Interrupt from keyboard\n", logname); else if (error == -1) - fprintf( - stderr, - "%s: %s\n", - logname, - dsc_strerror(&dsc->lasterror) - ); + fprintf(stderr, "%s: %s\n", logname, dsc_strerror(&dsc->lasterror)); if (flag_V) printf("Closing connection to camera...\n"); - if (dsc_close(dsc) == -1) - { - fprintf( - stderr, - "%s: %s\n", - logname, - dsc_strerror(&dsc->lasterror) - ); + if (dsc_close(dsc) == -1) { + fprintf(stderr, "%s: %s\n", logname, dsc_strerror(&dsc->lasterror)); error = -1; } else if (flag_V) printf("Connection successfully closed.\n\n"); @@ -551,36 +477,34 @@ int main(int argc, char *argv[]) return (error == -1 ? 1 : 0); } - -int list(dsc_t *dsc) +int +list(dsc_t* dsc) { - int n, nimg; - dsc_quality_t buf[DSCMAXIMAGE]; + int n, nimg; + dsc_quality_t buf[DSCMAXIMAGE]; if ((nimg = dsc_getindex(dsc, buf)) == -1) return -1; printf("\nTotal %u images.\n", nimg); - for (n = 0; n < nimg; n ++) - { + for (n = 0; n < nimg; n++) { printf("\nImage %02u", n + 1); - switch (buf[n]) - { - case unavailable: - break; + switch (buf[n]) { + case unavailable: + break; - case normal: - printf(": Normal"); - break; + case normal: + printf(": Normal"); + break; - case fine: - printf(": Fine"); - break; + case fine: + printf(": Fine"); + break; - case superfine: - printf(": Super fine"); - break; + case superfine: + printf(": Super fine"); + break; } } printf("\n\n"); @@ -588,38 +512,32 @@ int list(dsc_t *dsc) return 0; } - -int listlong(dsc_t *dsc) +int +listlong(dsc_t* dsc) { - int n, nimg; - dsc_quality_t buf[DSCMAXIMAGE]; + int n, nimg; + dsc_quality_t buf[DSCMAXIMAGE]; if ((nimg = dsc_getindex(dsc, buf)) == -1) return -1; - for (n = 0; n < nimg && ! sigint; n ++) - { - printf( - " %7i " FILENAME, - (int)dsc_requestimage(dsc, n+ 1), - n + 1 - ); - switch (buf[n]) - { - case unavailable: - break; + for (n = 0; n < nimg && !sigint; n++) { + printf(" %7i " FILENAME, (int)dsc_requestimage(dsc, n + 1), n + 1); + switch (buf[n]) { + case unavailable: + break; - case normal: - printf(" normal"); - break; + case normal: + printf(" normal"); + break; - case fine: - printf(" fine"); - break; + case fine: + printf(" fine"); + break; - case superfine: - printf(" super fine"); - break; + case superfine: + printf(" super fine"); + break; } putchar('\n'); } @@ -627,98 +545,79 @@ int listlong(dsc_t *dsc) return (sigint ? -1 : 0); } - -int get( - dsc_t *dsc, int *index, const char *output, - int flag_V, int flag_q, int flag_c -) +int +get(dsc_t* dsc, int* index, const char* output, int flag_V, int flag_q, int flag_c) { - int n; + int n; - if (output != NULL && index[0] > 1) - { + if (output != NULL && index[0] > 1) { output = NULL; - fprintf( - stderr, - "%s: Ignoring option -o for multiple images\n", - logname - ); + fprintf(stderr, "%s: Ignoring option -o for multiple images\n", logname); } - for (n = 1; n <= DSCMAXIMAGE; n ++) - if ( index[n] && - getimage(dsc, n, output, flag_V, flag_q, flag_c) == -1) + for (n = 1; n <= DSCMAXIMAGE; n++) + if (index[n] && getimage(dsc, n, output, flag_V, flag_q, flag_c) == -1) return -1; return 0; } - -int getall(dsc_t *dsc, int flag_V, int flag_q, int flag_c) +int +getall(dsc_t* dsc, int flag_V, int flag_q, int flag_c) { - int n, nimg; - dsc_quality_t buf[DSCMAXIMAGE]; + int n, nimg; + dsc_quality_t buf[DSCMAXIMAGE]; if ((nimg = dsc_getindex(dsc, buf)) == -1) return -1; - for (n = 1; n <= nimg; n ++) + for (n = 1; n <= nimg; n++) if (getimage(dsc, n, NULL, flag_V, flag_q, flag_c) == -1) return -1; return 0; } - -int thumbnail( - dsc_t *dsc, int *index, const char *output, - int flag_V, int flag_q -) +int +thumbnail(dsc_t* dsc, int* index, const char* output, int flag_V, int flag_q) { - int n; + int n; - if (output != NULL && index[0] > 1) - { + if (output != NULL && index[0] > 1) { output = NULL; - fprintf( - stderr, - "%s: Ignoring option -o for multiple images\n", - logname - ); + fprintf(stderr, "%s: Ignoring option -o for multiple images\n", logname); } - for (n = 1; n <= DSCMAXIMAGE; n ++) - if ( index[n] && - getimage(dsc, -n, output, flag_V, flag_q, 0) == -1) + for (n = 1; n <= DSCMAXIMAGE; n++) + if (index[n] && getimage(dsc, -n, output, flag_V, flag_q, 0) == -1) return -1; return 0; } - -int thumbnailall(dsc_t *dsc, int flag_V, int flag_q) +int +thumbnailall(dsc_t* dsc, int flag_V, int flag_q) { - int n, nimg; - dsc_quality_t buf[DSCMAXIMAGE]; + int n, nimg; + dsc_quality_t buf[DSCMAXIMAGE]; if ((nimg = dsc_getindex(dsc, buf)) == -1) return -1; - for (n = 1; n <= nimg; n ++) + for (n = 1; n <= nimg; n++) if (getimage(dsc, -n, NULL, flag_V, flag_q, 0) == -1) return -1; return 0; } - -int show(dsc_t *dsc, int *index, int flag_V) +int +show(dsc_t* dsc, int* index, int flag_V) { - int n; + int n; - for (n = 1; n <= DSCMAXIMAGE && ! sigint; n ++) - if (index[n]) - { + for (n = 1; n <= DSCMAXIMAGE && !sigint; n++) + if (index[n]) { if (flag_V) printf( "Sending request to show image " @@ -728,24 +627,20 @@ int show(dsc_t *dsc, int *index, int flag_V) if (dsc_preview(dsc, n) == -1) return -1; if (flag_V) - printf( - "Waiting for camera to " - "redraw screen...\n" - ); + printf("Waiting for camera to " + "redraw screen...\n"); sleep_s(DSCPAUSE); } return (sigint ? -1 : 0); } - -int delete(dsc_t *dsc, int *index, int flag_V) +int delete(dsc_t* dsc, int* index, int flag_V) { - int n, i; + int n, i; - for (n = 1; n <= DSCMAXIMAGE && ! sigint;) - if (index[n]) - { + for (n = 1; n <= DSCMAXIMAGE && !sigint;) + if (index[n]) { if (flag_V) printf( "Sending request to delete image " @@ -755,85 +650,71 @@ int delete(dsc_t *dsc, int *index, int flag_V) if (dsc_delete(dsc, n) == -1) return -1; - for (i = n; i < DSCMAXIMAGE; i ++) + for (i = n; i < DSCMAXIMAGE; i++) index[i] = index[i + 1]; index[DSCMAXIMAGE] = 0; } else - n ++; + n++; return (sigint ? -1 : 0); } - -int parse(int *index, const char *arg) +int +parse(int* index, const char* arg) { - int i, p, lp, l, n; - char *a, ap; + int i, p, lp, l, n; + char *a, ap; - for (i = 1; i <= DSCMAXIMAGE; i ++) + for (i = 1; i <= DSCMAXIMAGE; i++) index[i] = 0; - if ((a = strdup(arg)) == NULL) - { + if ((a = strdup(arg)) == NULL) { #ifdef DEBUG - fprintf( - stderr, - __BASE_FILE__ ": parse() " - "return from line %u, strdup() failed\n", - __LINE__ + 3 - ); + fprintf( + stderr, + __BASE_FILE__ ": parse() " + "return from line %u, strdup() failed\n", + __LINE__ + 3 + ); #endif return -1; } for (p = 0, lp = 0, l = -1;;) if (a[p] >= '0' && a[p] <= '9') - p ++; - else if (a[p] == ',' || a[p] == '-' || a[p] == '\0') - { + p++; + else if (a[p] == ',' || a[p] == '-' || a[p] == '\0') { ap = a[p]; a[p] = '\0'; n = atoi(a + lp); - if (n < 1 || n > DSCMAXIMAGE) - { - fprintf( - stderr, - "%s: bad index `%i'\n", - logname, n - ); + if (n < 1 || n > DSCMAXIMAGE) { + fprintf(stderr, "%s: bad index `%i'\n", logname, n); break; } if (ap == '-') l = n; - else - if (l == -1) - index[n] ^= 1; - else - { - for ( i = (l < n ? l : n); - i <= (n > l ? n : l); i ++) - index[i] ^= 1; - l = -1; - } + else if (l == -1) + index[n] ^= 1; + else { + for (i = (l < n ? l : n); i <= (n > l ? n : l); i++) + index[i] ^= 1; + l = -1; + } if (ap == '\0') break; - lp = ++ p; + lp = ++p; } else { - fprintf( - stderr, - "%s: bad character `%c' in index\n", - logname, a[p] - ); + fprintf(stderr, "%s: bad character `%c' in index\n", logname, a[p]); break; } free(a); - for (i = 1, n = 0; i <= DSCMAXIMAGE; i ++) + for (i = 1, n = 0; i <= DSCMAXIMAGE; i++) n += index[i]; index[0] = n; /* number of images */ @@ -841,41 +722,48 @@ int parse(int *index, const char *arg) return (n < 1 ? -1 : 0); } - -int getimage( - dsc_t *dsc, int index, const char *name, - int flag_V, int flag_q, int flag_c -) +int +getimage(dsc_t* dsc, int index, const char* name, int flag_V, int flag_q, int flag_c) { #ifdef DEBUG int errline; -# define returnerror() { errline = __LINE__; goto getimage_ERROR; } -# define returnerrno() { \ - errline = __LINE__; \ - dsc->lasterror.lerror = EDSCSERRNO; \ - dsc->lasterror.lerrno = errno; \ - goto getimage_ERROR; } +#define returnerror() \ + { \ + errline = __LINE__; \ + goto getimage_ERROR; \ + } +#define returnerrno() \ + { \ + errline = __LINE__; \ + dsc->lasterror.lerror = EDSCSERRNO; \ + dsc->lasterror.lerrno = errno; \ + goto getimage_ERROR; \ + } #else -# define returnerror() { goto getimage_ERROR; } -# define returnerrno() { \ - dsc->lasterror.lerror = EDSCSERRNO; \ - dsc->lasterror.lerrno = errno; \ - goto getimage_ERROR; } +#define returnerror() \ + { \ + goto getimage_ERROR; \ + } +#define returnerrno() \ + { \ + dsc->lasterror.lerror = EDSCSERRNO; \ + dsc->lasterror.lerrno = errno; \ + goto getimage_ERROR; \ + } #endif - int file = -1, i; - unsigned int cblk = 0; - char tmpname[PATH_MAX]; - u_int8_t buf[2048]; - ssize_t imagesize, s, b, csize = 0; - struct stat statbuf; + int file = -1, i; + unsigned int cblk = 0; + char tmpname[PATH_MAX]; + u_int8_t buf[2048]; + ssize_t imagesize, s, b, csize = 0; + struct stat statbuf; - if (name == NULL) - { + if (name == NULL) { if (index < 0) sprintf(tmpname, THUMBFILENAME, -index); else @@ -883,38 +771,27 @@ int getimage( name = tmpname; } - if (flag_c) - { - if (stat(name, &statbuf) == -1) - { + if (flag_c) { + if (stat(name, &statbuf) == -1) { if (errno != ENOENT) returnerrno(); flag_c = 0; } else { if (flag_V) - printf( - "Found file \"%s\" %lu bytes.\n", - name, (unsigned long)statbuf.st_size - ); + printf("Found file \"%s\" %lu bytes.\n", name, (unsigned long)statbuf.st_size); if ((imagesize = dsc_requestimage(dsc, index)) == -1) returnerror(); if (flag_V) - printf( - "Requested image #%u is %u bytes.\n", - index, (unsigned int)imagesize - ); + printf("Requested image #%u is %u bytes.\n", index, (unsigned int)imagesize); - if (statbuf.st_size == imagesize) - { + if (statbuf.st_size == imagesize) { if (flag_V) - printf( - "Image already " - "downloaded, skipping.\n" - ); - else if (! flag_q) + printf("Image already " + "downloaded, skipping.\n"); + else if (!flag_q) printf( "%s (%u bytes) already " "downloaded.\n", @@ -924,21 +801,16 @@ int getimage( return 0; } - if (statbuf.st_size > imagesize) - { + if (statbuf.st_size > imagesize) { if (flag_V) - printf( - "File is larger than " - "image, aborting.\n" - ); - else if (! flag_q) + printf("File is larger than " + "image, aborting.\n"); + else if (!flag_q) printf( "%s (%lu bytes) is larger " "than image #%u (%u bytes), " "aborting.\n", - name, - (unsigned long)statbuf.st_size, - index, (unsigned int)imagesize + name, (unsigned long)statbuf.st_size, index, (unsigned int)imagesize ); return -1; @@ -953,27 +825,19 @@ int getimage( if (lseek(file, csize, SEEK_SET) != csize) returnerrno(); - if (flag_V) - { - printf( - "Remaining size is %u bytes. Reading", - (unsigned int)(imagesize - csize) - ); + if (flag_V) { + printf("Remaining size is %u bytes. Reading", (unsigned int)(imagesize - csize)); if (flag_q) printf("...\n"); - } else if (! flag_q) { - printf( - "%s (%u bytes) reading", - name, (unsigned int)imagesize - ); - for (i = 0; i < cblk; i ++) + } else if (!flag_q) { + printf("%s (%u bytes) reading", name, (unsigned int)imagesize); + for (i = 0; i < cblk; i++) putchar(','); } } } - if (! flag_c) - { + if (!flag_c) { if (flag_V) printf("Creating file \"%s\"...\n", name); @@ -984,34 +848,25 @@ int getimage( if (flag_V) printf( - "Sending request to download %s #%u...\n", - index < 0 ? "thumbnail" : "image", + "Sending request to download %s #%u...\n", index < 0 ? "thumbnail" : "image", index < 0 ? -index : index ); if ((imagesize = dsc_requestimage(dsc, index)) == -1) returnerror(); - if (flag_V) - { - printf( - "Image size is %u bytes.\nReading", - (unsigned int)imagesize - ); + if (flag_V) { + printf("Image size is %u bytes.\nReading", (unsigned int)imagesize); if (flag_q) printf("...\n"); - } else if (! flag_q) - printf( - "%s (%u bytes) reading", - name, (unsigned int)imagesize - ); + } else if (!flag_q) + printf("%s (%u bytes) reading", name, (unsigned int)imagesize); } - if (! flag_q) + if (!flag_q) fflush(stdout); - if (flag_c) - { + if (flag_c) { i = cblk; s = csize; } else { @@ -1019,13 +874,11 @@ int getimage( s = 0; } - while (s < imagesize) - { + while (s < imagesize) { if (sigint) returnerrno(); - if ((b = dsc_readimageblock(dsc, i, buf)) == -1) - { + if ((b = dsc_readimageblock(dsc, i, buf)) == -1) { if (sigint) returnerrno(); if (dsc_requestimage(dsc, index) == -1) @@ -1033,41 +886,36 @@ int getimage( } else { if (write(file, buf, b) != b) returnerrno(); - if (! flag_q) - { + if (!flag_q) { putchar('.'); fflush(stdout); } - i ++; + i++; s += b; } } - if (! flag_q) + if (!flag_q) putchar('\n'); #if __BEOS__ - if (file != STDOUT_FILENO) - { + if (file != STDOUT_FILENO) { if (flag_V) printf("Setting MIME type...\n"); - if (fs_write_attr( - file, attr, B_STRING_TYPE, 0, - mime, sizeof(mime)) != sizeof(mime)) - { -# ifdef DEBUG + if (fs_write_attr(file, attr, B_STRING_TYPE, 0, mime, sizeof(mime)) != sizeof(mime)) { +#ifdef DEBUG fprintf( stderr, __BASE_FILE__ ": getimage() " - "fs_write_attr() failed, code == %u\n", + "fs_write_attr() failed, code == %u\n", errno ); -# else +#else if (flag_V) printf("Could not set MIME type.\n"); -# endif +#endif } } @@ -1084,14 +932,11 @@ int getimage( fprintf( stderr, __BASE_FILE__ ": getimage() " - "return from line %u, code == %u\n", - errline, - dsc->lasterror.lerror == EDSCSERRNO ? - dsc->lasterror.lerrno : - dsc->lasterror.lerror + "return from line %u, code == %u\n", + errline, dsc->lasterror.lerror == EDSCSERRNO ? dsc->lasterror.lerrno : dsc->lasterror.lerror ); #else - if (! flag_q) + if (!flag_q) putchar('\n'); #endif @@ -1106,19 +951,19 @@ int getimage( #ifndef NOSIG -void sigint_h(int s) +void +sigint_h(int s) { -# ifdef DEBUG +#ifdef DEBUG static const char msg[] = __BASE_FILE__ ": interrupt from keyboard\n"; write(STDERR_FILENO, msg, sizeof(msg) - 1); -# else -# ifndef NOBELL +#else +#ifndef NOBELL static const char bell = '\7'; write(STDERR_FILENO, &bell, 1); -# endif -# endif +#endif +#endif sigint = 1; } #endif - diff --git a/source/add-ons/Palmcam/dsc.c b/source/add-ons/Palmcam/dsc.c index d517e75..9a4b23e 100644 --- a/source/add-ons/Palmcam/dsc.c +++ b/source/add-ons/Palmcam/dsc.c @@ -20,12 +20,12 @@ #include #if __BEOS__ -# include -# include +#include +#include #else -# if ! linux -# include -# endif +#if !linux +#include +#endif #endif #include "dsc.h" @@ -36,83 +36,84 @@ #ifdef DEBUG -# ifndef __BASE_FILE__ -# define __BASE_FILE__ "dsc.c" -# endif +#ifndef __BASE_FILE__ +#define __BASE_FILE__ "dsc.c" +#endif -# define PLEASEREPORT "PLEASE REPORT THIS TO roubert@df.lth.se AT ONCE!" +#define PLEASEREPORT "PLEASE REPORT THIS TO roubert@df.lth.se AT ONCE!" -# define returnerror(ERROR, FUNCTION) { \ - errorline = __LINE__; \ - dsc->lasterror.lerror = ERROR; \ - dsc->lasterror.lerrno = errno; \ - goto FUNCTION ## _ERROR; } +#define returnerror(ERROR, FUNCTION) \ + { \ + errorline = __LINE__; \ + dsc->lasterror.lerror = ERROR; \ + dsc->lasterror.lerrno = errno; \ + goto FUNCTION##_ERROR; \ + } -# define DPRINTERR(LINE, ERROR, FUNCTION) \ - fprintf( \ - stderr, \ - __BASE_FILE__ ": " #FUNCTION \ - "() return from line %u, code == %u\n", \ - LINE, ERROR \ +#define DPRINTERR(LINE, ERROR, FUNCTION) \ + fprintf( \ + stderr, __BASE_FILE__ ": " #FUNCTION "() return from line %u, code == %u\n", LINE, ERROR \ ) #else -# define returnerror(ERROR, FUNCTION) { \ - dsc->lasterror.lerror = ERROR; \ - dsc->lasterror.lerrno = errno; \ - goto FUNCTION ## _ERROR; } +#define returnerror(ERROR, FUNCTION) \ + { \ + dsc->lasterror.lerror = ERROR; \ + dsc->lasterror.lerrno = errno; \ + goto FUNCTION##_ERROR; \ + } -# define DPRINTERR(LINE, ERROR, FUNCTION) +#define DPRINTERR(LINE, ERROR, FUNCTION) #endif -#define DSC2_SEND_DATA 0x00 -#define DSC2_SET_BAUD 0x04 -#define DSC2_GET_INDEX 0x07 -#define DSC2_OK 0x08 -#define DSC2_CONNECT 0x10 -#define DSC2_DELETE 0x11 -#define DSC2_PREVIEW 0x14 -#define DSC2_SET_RES 0x15 -#define DSC2_THUMB 0x16 -#define DSC2_SELECT 0x1a -#define DSC2_GET_DATA 0x1e -#define DSC2_RESET 0x1f +#define DSC2_SEND_DATA 0x00 +#define DSC2_SET_BAUD 0x04 +#define DSC2_GET_INDEX 0x07 +#define DSC2_OK 0x08 +#define DSC2_CONNECT 0x10 +#define DSC2_DELETE 0x11 +#define DSC2_PREVIEW 0x14 +#define DSC2_SET_RES 0x15 +#define DSC2_THUMB 0x16 +#define DSC2_SELECT 0x1a +#define DSC2_GET_DATA 0x1e +#define DSC2_RESET 0x1f static const u_int8_t s_prefix[] = /* generic command prefix */ - { 'M', 'K', 'E', ' ', 'D', 'S', 'C', ' ', 'P', 'C', ' ', ' ' }, + {'M', 'K', 'E', ' ', 'D', 'S', 'C', ' ', 'P', 'C', ' ', ' '}, r_prefix[] = /* generic response prefix */ - { 'M', 'K', 'E', ' ', 'P', 'C', ' ', ' ', 'D', 'S', 'C', ' ' }, + {'M', 'K', 'E', ' ', 'P', 'C', ' ', ' ', 'D', 'S', 'C', ' '}, r_ok_1[] = /* response ok dsc1 */ - { 0x00, 0x00, 0x00, 0x01, 0x01, 0x00 }, + {0x00, 0x00, 0x00, 0x01, 0x01, 0x00}, r_ok_2[] = /* response ok dsc2 */ - { 0x08, 0x00, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + {0x08, 0x00, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -#if ! __GNU_LIBRARY__ -void cfmakeraw(struct termios *termios_p) +#if !__GNU_LIBRARY__ +void +cfmakeraw(struct termios* termios_p) { - termios_p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP - |INLCR|IGNCR|ICRNL|IXON); + termios_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); termios_p->c_oflag &= ~OPOST; - termios_p->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); - termios_p->c_cflag &= ~(CSIZE|PARENB); + termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); + termios_p->c_cflag &= ~(CSIZE | PARENB); termios_p->c_cflag |= CS8; } #endif #if __BEOS__ -/* +/* * The BeOS code for dsc_read() is based on the work of Peter Goodeve in his * port of photopc to the BeOS. * @@ -120,94 +121,84 @@ void cfmakeraw(struct termios *termios_p) struct reader_s { - thread_id target; - long timeout; - int fd; - char *buf; - size_t count; - ssize_t r; + thread_id target; + long timeout; + int fd; + char* buf; + size_t count; + ssize_t r; }; - -int32 dsc_timer_thread(void *ctrlp) +int32 +dsc_timer_thread(void* ctrlp) { - struct reader_s *ctrl; - - ctrl = (struct reader_s *)ctrlp; - snooze((bigtime_t)ctrl->timeout); + struct reader_s* ctrl; + + ctrl = (struct reader_s*)ctrlp; + snooze((bigtime_t)ctrl->timeout); send_signal(ctrl->target, SIGINT); - suspend_thread(find_thread(NULL)); + suspend_thread(find_thread(NULL)); return 0; } - -int32 dsc_reader_thread(void *ctrlp) +int32 +dsc_reader_thread(void* ctrlp) { - struct reader_s *ctrl; - - ctrl = (struct reader_s *)ctrlp; + struct reader_s* ctrl; + + ctrl = (struct reader_s*)ctrlp; while (ctrl->r < ctrl->count) - ctrl->r += read( - ctrl->fd, - ctrl->buf + ctrl->r, ctrl->count - ctrl->r - ); - + ctrl->r += read(ctrl->fd, ctrl->buf + ctrl->r, ctrl->count - ctrl->r); + return 0; } #endif -ssize_t dsc_read(dsc_t *dsc, void *buf, size_t count) +ssize_t +dsc_read(dsc_t* dsc, void* buf, size_t count) { #ifdef DEBUGREAD - int i; + int i; #endif - size_t n; + size_t n; #if __BEOS__ - status_t tmp; - struct reader_s ctrl; - thread_id timer_id; + status_t tmp; + struct reader_s ctrl; + thread_id timer_id; - if (count > 0) - { + if (count > 0) { ctrl.fd = dsc->fd; ctrl.buf = buf; ctrl.count = count; ctrl.r = 0; ctrl.timeout = (READTIMEOUT) * 1000000L; - ctrl.target = spawn_thread( - dsc_reader_thread, "read fd", - B_NORMAL_PRIORITY, &ctrl - ); + ctrl.target = spawn_thread(dsc_reader_thread, "read fd", B_NORMAL_PRIORITY, &ctrl); - timer_id = spawn_thread( - dsc_timer_thread, "timeout", - B_NORMAL_PRIORITY, &ctrl - ); + timer_id = spawn_thread(dsc_timer_thread, "timeout", B_NORMAL_PRIORITY, &ctrl); resume_thread(timer_id); resume_thread(ctrl.target); wait_for_thread(ctrl.target, &tmp); kill_thread(timer_id); n = ctrl.r; - } - else + } else n = 0; #else - fd_set rfds; - struct timeval tv; - int s; - ssize_t r; -# if ! linux - time_t t; -# endif + fd_set rfds; + struct timeval tv; + int s; + ssize_t r; +#if !linux + time_t t; +#endif FD_ZERO(&rfds); FD_SET(dsc->fd, &rfds); @@ -215,28 +206,24 @@ ssize_t dsc_read(dsc_t *dsc, void *buf, size_t count) tv.tv_sec = READTIMEOUT; tv.tv_usec = 0; -# if ! linux +#if !linux t = time(NULL); -# endif +#endif n = 0; - while (n < count && timerisset(&tv)) - { + while (n < count && timerisset(&tv)) { s = select(dsc->fd + 1, &rfds, NULL, NULL, &tv); - if (s == 1) - { - if ((r = read(dsc->fd, (u_int8_t*)buf + n, count - n)) - == -1) - { + if (s == 1) { + if ((r = read(dsc->fd, (u_int8_t*)buf + n, count - n)) == -1) { DPRINTERR(__LINE__ + 1, errno, dsc_read); return -1; }; n += r; -# if ! linux -/* assume tv is left unchanged after call to select() */ +#if !linux + /* assume tv is left unchanged after call to select() */ if ((tv.tv_sec = READTIMEOUT + t - time(NULL)) < 0) tv.tv_sec = 0; -# endif +#endif } else if (s == -1) { DPRINTERR(__LINE__ + 1, errno, dsc_read); return -1; @@ -246,27 +233,22 @@ ssize_t dsc_read(dsc_t *dsc, void *buf, size_t count) #ifdef DEBUGREAD fprintf(stderr, "dsc_read() == %u [", (unsigned int)n); - for (i = 0; i < n; i ++) + for (i = 0; i < n; i++) fprintf( - stderr, - *((char*)buf + i) >= 32 && - *((char*)buf + i) < 127 ? "%c" : "\\x%02x", + stderr, *((char*)buf + i) >= 32 && *((char*)buf + i) < 127 ? "%c" : "\\x%02x", *((char*)buf + i) ); fprintf(stderr, "]\n"); #endif - if (n < count) - { + if (n < count) { #ifdef DEBUG - fprintf( - stderr, - __BASE_FILE__ - ": dsc_read() timeout (%u/%u) " - "return from line %u, code == %u\n", - (unsigned int)n, (unsigned int)count, - __LINE__ + 4, EDSCRTMOUT - ); + fprintf( + stderr, + __BASE_FILE__ ": dsc_read() timeout (%u/%u) " + "return from line %u, code == %u\n", + (unsigned int)n, (unsigned int)count, __LINE__ + 4, EDSCRTMOUT + ); #endif dsc->lasterror.lerror = EDSCRTMOUT; /* read time out */ return -1; @@ -275,11 +257,11 @@ ssize_t dsc_read(dsc_t *dsc, void *buf, size_t count) return (ssize_t)n; } - -int dsc2_send_cmd(dsc_t *dsc, int cmd, int data, int sequence) +int +dsc2_send_cmd(dsc_t* dsc, int cmd, int data, int sequence) { - u_int8_t databuf[16]; - int n; + u_int8_t databuf[16]; + int n; memset(databuf, 0, 16); @@ -296,58 +278,54 @@ int dsc2_send_cmd(dsc_t *dsc, int cmd, int data, int sequence) return n; } - -dsc_t *dsc_open(const char *pathname, speed_t speed, dsc_error *error) +dsc_t* +dsc_open(const char* pathname, speed_t speed, dsc_error* error) { #ifdef DEBUG - int errorline; + int errorline; #endif - dsc_t *dsc; - int n; - u_int8_t s_bps; - ssize_t s; - - static const u_int8_t - s_init1[] = { 0x00, 0x00, 0x00, 0x01, 0x04 }, - s_init2[] = { 0x00, 0x00, 0x00, 0x00, 0x02 }, - r_init2[] = { 0x00, 0x00, 0x00, 0x04, 0x03, 'D', 'S', 'C' }, - s_init3[] = { 0x00, 0x00, 0x00, 0x01, 0x10, 0x00 }; - - switch (speed) - { - case B9600: - s_bps = 0x02; - break; - - case B19200: - s_bps = 0x0d; - break; - - case B38400: - s_bps = 0x01; - break; - - case B57600: - s_bps = 0x03; - break; - - default: - DPRINTERR(__LINE__ + 2, EDSCBPSRNG, dsc_open); - error->lerror = EDSCBPSRNG; /* bps out of range */ - return NULL; + dsc_t* dsc; + int n; + u_int8_t s_bps; + ssize_t s; + + static const u_int8_t s_init1[] = {0x00, 0x00, 0x00, 0x01, 0x04}, + s_init2[] = {0x00, 0x00, 0x00, 0x00, 0x02}, + r_init2[] = {0x00, 0x00, 0x00, 0x04, 0x03, 'D', 'S', 'C'}, + s_init3[] = {0x00, 0x00, 0x00, 0x01, 0x10, 0x00}; + + switch (speed) { + case B9600: + s_bps = 0x02; + break; + + case B19200: + s_bps = 0x0d; + break; + + case B38400: + s_bps = 0x01; + break; + + case B57600: + s_bps = 0x03; + break; + + default: + DPRINTERR(__LINE__ + 2, EDSCBPSRNG, dsc_open); + error->lerror = EDSCBPSRNG; /* bps out of range */ + return NULL; } - if ((dsc = (dsc_t*)malloc(sizeof(dsc_t))) == NULL) - { + if ((dsc = (dsc_t*)malloc(sizeof(dsc_t))) == NULL) { DPRINTERR(__LINE__ + 2, errno, dsc_open); error->lerror = EDSCSERRNO; error->lerrno = errno; return NULL; } - if ((dsc->buf = (u_int8_t*)malloc(256)) == NULL) - { + if ((dsc->buf = (u_int8_t*)malloc(256)) == NULL) { DPRINTERR(__LINE__ + 2, errno, dsc_open); error->lerror = EDSCSERRNO; error->lerrno = errno; @@ -355,8 +333,7 @@ dsc_t *dsc_open(const char *pathname, speed_t speed, dsc_error *error) return NULL; } - if ((dsc->fd = open(pathname, O_RDWR | O_NOCTTY | O_NONBLOCK)) == -1) - { + if ((dsc->fd = open(pathname, O_RDWR | O_NOCTTY | O_NONBLOCK)) == -1) { DPRINTERR(__LINE__ + 1, errno, dsc_open); error->lerror = EDSCSERRNO; error->lerrno = errno; @@ -368,7 +345,7 @@ dsc_t *dsc_open(const char *pathname, speed_t speed, dsc_error *error) #if __BEOS__ /* remove O_NONBLOCK */ - fcntl(dsc->fd, F_SETFL, 0); + fcntl(dsc->fd, F_SETFL, 0); #endif @@ -390,16 +367,13 @@ dsc_t *dsc_open(const char *pathname, speed_t speed, dsc_error *error) if (tcsetattr(dsc->fd, TCSANOW, &dsc->term) == -1) returnerror(EDSCSERRNO, dsc_open); - for (n = 0; n < 3; n ++) - { + for (n = 0; n < 3; n++) { write(dsc->fd, s_prefix, 12); write(dsc->fd, s_init1, 5); write(dsc->fd, &s_bps, 1); tcdrain(dsc->fd); - if ((s = dsc_read(dsc, dsc->buf, 18)) == 18) - { - if ( memcmp(dsc->buf, r_prefix, 12) == 0 && - memcmp(dsc->buf + 12, r_ok_1, 6) == 0) + if ((s = dsc_read(dsc, dsc->buf, 18)) == 18) { + if (memcmp(dsc->buf, r_prefix, 12) == 0 && memcmp(dsc->buf + 12, r_ok_1, 6) == 0) break; /* got handshake from camera */ else s = 0; @@ -407,10 +381,9 @@ dsc_t *dsc_open(const char *pathname, speed_t speed, dsc_error *error) } if (s != 18) returnerror(EDSCNOANSW, dsc_open); - /* no answer from camera */ + /* no answer from camera */ - if (speed != B9600) - { + if (speed != B9600) { if (cfsetospeed(&dsc->term, speed) == -1) returnerror(EDSCSERRNO, dsc_open); @@ -421,38 +394,34 @@ dsc_t *dsc_open(const char *pathname, speed_t speed, dsc_error *error) write(dsc->fd, s_prefix, 12); write(dsc->fd, s_init2, 5); tcdrain(dsc->fd); - if ( dsc_read(dsc, dsc->buf, 12 + 9) != 12 + 9 || - memcmp(dsc->buf, r_prefix, 12) != 0 || + if (dsc_read(dsc, dsc->buf, 12 + 9) != 12 + 9 || memcmp(dsc->buf, r_prefix, 12) != 0 || memcmp(dsc->buf + 12, r_init2, 8) != 0) returnerror(EDSCNOANSW, dsc_open); + /* no answer from camera */ + + switch (dsc->buf[20]) { + case '1': + dsc->type = dsc1; + write(dsc->fd, s_prefix, 12); + write(dsc->fd, s_init3, 6); + tcdrain(dsc->fd); + if (dsc_read(dsc, dsc->buf, 12 + 6) != 12 + 6 || memcmp(dsc->buf, r_prefix, 12) != 0 || + memcmp(dsc->buf + 12, r_ok_1, 6) != 0) + returnerror(EDSCNOANSW, dsc_open); + /* no answer from camera */ + break; + + case '2': + dsc->type = dsc2; + dsc2_send_cmd(dsc, DSC2_CONNECT, 0, 0); + if (dsc_read(dsc, dsc->buf, 16) != 16 || memcmp(dsc->buf, r_ok_2, 16) != 0) + returnerror(EDSCNOANSW, dsc_open); /* no answer from camera */ + break; - switch (dsc->buf[20]) - { - case '1': - dsc->type = dsc1; - write(dsc->fd, s_prefix, 12); - write(dsc->fd, s_init3, 6); - tcdrain(dsc->fd); - if ( dsc_read(dsc, dsc->buf, 12 + 6) != 12 + 6 || - memcmp(dsc->buf, r_prefix, 12) != 0 || - memcmp(dsc->buf + 12, r_ok_1, 6) != 0) - returnerror(EDSCNOANSW, dsc_open); - /* no answer from camera */ - break; - - case '2': - dsc->type = dsc2; - dsc2_send_cmd(dsc, DSC2_CONNECT, 0, 0); - if ( dsc_read(dsc, dsc->buf, 16) != 16 || - memcmp(dsc->buf, r_ok_2, 16) != 0) - returnerror(EDSCNOANSW, dsc_open); - /* no answer from camera */ - break; - - default: - returnerror(EDSCBADPCL, dsc_open); - /* bad protocol */ + default: + returnerror(EDSCBADPCL, dsc_open); + /* bad protocol */ } return dsc; @@ -461,9 +430,7 @@ dsc_t *dsc_open(const char *pathname, speed_t speed, dsc_error *error) DPRINTERR( errorline, - dsc->lasterror.lerror == EDSCSERRNO ? - dsc->lasterror.lerrno : - dsc->lasterror.lerror, + dsc->lasterror.lerror == EDSCSERRNO ? dsc->lasterror.lerrno : dsc->lasterror.lerror, dsc_open ); @@ -475,49 +442,45 @@ dsc_t *dsc_open(const char *pathname, speed_t speed, dsc_error *error) return NULL; } - -int dsc_close(dsc_t *dsc) +int +dsc_close(dsc_t* dsc) { #ifdef DEBUG - int errorline; + int errorline; #endif - static const u_int8_t - s_reset[] = { 0x00, 0x00, 0x00, 0x00, 0x1f }; - - switch (dsc->type) - { - case dsc1: - write(dsc->fd, s_prefix, 12); - write(dsc->fd, s_reset, 5); - tcdrain(dsc->fd); - if ( dsc_read(dsc, dsc->buf, 12 + 6) != 12 + 6 || - memcmp(dsc->buf, r_prefix, 12) != 0 || - memcmp(dsc->buf + 12, r_ok_1, 6) != 0) - returnerror(EDSCNRESET, dsc_close); - /* could not reset camera */ - break; - - case dsc2: - dsc2_send_cmd(dsc, DSC2_RESET, 0, 0); - if ( dsc_read(dsc, dsc->buf, 16) != 16 || - memcmp(dsc->buf, r_ok_2, 16) != 0) - returnerror(EDSCNRESET, dsc_close); - /* could not reset camera */ - break; - - default: - returnerror(EDSCBADPCL, dsc_close); - /* bad protocol */ + static const u_int8_t s_reset[] = {0x00, 0x00, 0x00, 0x00, 0x1f}; + + switch (dsc->type) { + case dsc1: + write(dsc->fd, s_prefix, 12); + write(dsc->fd, s_reset, 5); + tcdrain(dsc->fd); + if (dsc_read(dsc, dsc->buf, 12 + 6) != 12 + 6 || memcmp(dsc->buf, r_prefix, 12) != 0 || + memcmp(dsc->buf + 12, r_ok_1, 6) != 0) + returnerror(EDSCNRESET, dsc_close); + /* could not reset camera */ + break; + + case dsc2: + dsc2_send_cmd(dsc, DSC2_RESET, 0, 0); + if (dsc_read(dsc, dsc->buf, 16) != 16 || memcmp(dsc->buf, r_ok_2, 16) != 0) + returnerror(EDSCNRESET, dsc_close); + /* could not reset camera */ + break; + + default: + returnerror(EDSCBADPCL, dsc_close); + /* bad protocol */ } - printf ("Closing fd\n"); + printf("Closing fd\n"); close(dsc->fd); - printf ("Freeing buf\n"); + printf("Freeing buf\n"); free(dsc->buf); - printf ("Freeing dsc\n"); + printf("Freeing dsc\n"); free(dsc); - printf ("Return\n"); + printf("Return\n"); return 0; dsc_close_ERROR: @@ -529,74 +492,67 @@ int dsc_close(dsc_t *dsc) return -1; } - -int dsc_getindex(dsc_t *dsc, dsc_quality_t *buf) +int +dsc_getindex(dsc_t* dsc, dsc_quality_t* buf) { #ifdef DEBUG - int errorline; + int errorline; #endif - unsigned int nimg = 0, n; + unsigned int nimg = 0, n; - static const u_int8_t - s_index[] = { 0x00, 0x00, 0x00, 0x00, 0x07 }, - r_index_1[] = { 0x00, 0x00, 0x00 }, - r_index_2[] = { 0x08, 0x00, 0xff, 0x08 }; + static const u_int8_t s_index[] = {0x00, 0x00, 0x00, 0x00, 0x07}, + r_index_1[] = {0x00, 0x00, 0x00}, r_index_2[] = {0x08, 0x00, 0xff, 0x08}; - switch (dsc->type) - { - case dsc1: - write(dsc->fd, s_prefix, 12); - write(dsc->fd, s_index, 5); - tcdrain(dsc->fd); - if ( dsc_read(dsc, dsc->buf, 17) != 17 || - memcmp(dsc->buf, r_prefix, 12) != 0 || - memcmp(dsc->buf + 12, r_index_1, 3) != 0) - returnerror(EDSCNOANSW, dsc_getindex); - /* no answer from camera */ + switch (dsc->type) { + case dsc1: + write(dsc->fd, s_prefix, 12); + write(dsc->fd, s_index, 5); + tcdrain(dsc->fd); + if (dsc_read(dsc, dsc->buf, 17) != 17 || memcmp(dsc->buf, r_prefix, 12) != 0 || + memcmp(dsc->buf + 12, r_index_1, 3) != 0) + returnerror(EDSCNOANSW, dsc_getindex); + /* no answer from camera */ - if ((nimg = (int)(dsc->buf[15] >> 1)) == 0) - return 0; + if ((nimg = (int)(dsc->buf[15] >> 1)) == 0) + return 0; #ifdef DEBUG - if (nimg > DSCMAXIMAGE) - fprintf( - stderr, - __BASE_FILE__ ": dsc_getindex() " - "camera states %u images in memory " - "(only %u possible)\n\n" - PLEASEREPORT - "\n\n", - nimg, DSCMAXIMAGE - ); + if (nimg > DSCMAXIMAGE) + fprintf( + stderr, + __BASE_FILE__ ": dsc_getindex() " + "camera states %u images in memory " + "(only %u possible)\n\n" PLEASEREPORT "\n\n", + nimg, DSCMAXIMAGE + ); #endif - if (dsc_read(dsc, dsc->buf, nimg * 2) != nimg * 2) - returnerror(EDSCNOANSW, dsc_getindex); - /* no answer from camera */ + if (dsc_read(dsc, dsc->buf, nimg * 2) != nimg * 2) + returnerror(EDSCNOANSW, dsc_getindex); + /* no answer from camera */ - for (n = 0; n < nimg; n ++) - buf[n] = (dsc_quality_t)dsc->buf[1 + n * 2]; + for (n = 0; n < nimg; n++) + buf[n] = (dsc_quality_t)dsc->buf[1 + n * 2]; - break; + break; - case dsc2: - dsc2_send_cmd(dsc, DSC2_GET_INDEX, 0, 0); - if ( dsc_read(dsc, dsc->buf, 16) != 16 || - memcmp(dsc->buf, r_index_2, 4) != 0) - returnerror(EDSCNOANSW, dsc_getindex); - /* no answer from camera */ + case dsc2: + dsc2_send_cmd(dsc, DSC2_GET_INDEX, 0, 0); + if (dsc_read(dsc, dsc->buf, 16) != 16 || memcmp(dsc->buf, r_index_2, 4) != 0) + returnerror(EDSCNOANSW, dsc_getindex); + /* no answer from camera */ - nimg = dsc->buf[4]; - memset(buf, unavailable, nimg); - /* don't know how to get stats on images - * without downloading */ + nimg = dsc->buf[4]; + memset(buf, unavailable, nimg); + /* don't know how to get stats on images + * without downloading */ - break; + break; - default: - returnerror(EDSCBADPCL, dsc_getindex); - /* bad protocol */ + default: + returnerror(EDSCBADPCL, dsc_getindex); + /* bad protocol */ } return nimg; @@ -607,47 +563,44 @@ int dsc_getindex(dsc_t *dsc, dsc_quality_t *buf) return -1; } - -int dsc_preview(dsc_t *dsc, int index) +int +dsc_preview(dsc_t* dsc, int index) { #ifdef DEBUG - int errorline; + int errorline; #endif - u_int8_t s_index = index; + u_int8_t s_index = index; - static const u_int8_t - s_request[] = { 0x00, 0x00, 0x00, 0x01, 0x14 }; + static const u_int8_t s_request[] = {0x00, 0x00, 0x00, 0x01, 0x14}; if (index < 1 || index > DSCMAXIMAGE) returnerror(EDSCBADNUM, dsc_preview); - /* bad image number */ + /* bad image number */ + + switch (dsc->type) { + case dsc1: + write(dsc->fd, s_prefix, 12); + write(dsc->fd, s_request, 5); + write(dsc->fd, &s_index, 1); + tcdrain(dsc->fd); + if (dsc_read(dsc, dsc->buf, 12 + 6) != 12 + 6 || memcmp(dsc->buf, r_prefix, 12) != 0 || + memcmp(dsc->buf + 12, r_ok_1, 6) != 0) + returnerror(EDSCNOANSW, dsc_preview); + /* no answer from camera */ + break; - switch (dsc->type) - { - case dsc1: - write(dsc->fd, s_prefix, 12); - write(dsc->fd, s_request, 5); - write(dsc->fd, &s_index, 1); - tcdrain(dsc->fd); - if ( dsc_read(dsc, dsc->buf, 12 + 6) != 12 + 6 || - memcmp(dsc->buf, r_prefix, 12) != 0 || - memcmp(dsc->buf + 12, r_ok_1, 6) != 0) - returnerror(EDSCNOANSW, dsc_preview); - /* no answer from camera */ - break; - - case dsc2: - dsc2_send_cmd(dsc, DSC2_PREVIEW, index, 0); - if ( dsc_read(dsc, dsc->buf, 16) != 16) - /* memcmp(dsc->buf, r_index_2, 4) != 0 */ - returnerror(EDSCNOANSW, dsc_preview); - /* no answer from camera */ - break; - - default: - returnerror(EDSCBADPCL, dsc_preview); - /* bad protocol */ + case dsc2: + dsc2_send_cmd(dsc, DSC2_PREVIEW, index, 0); + if (dsc_read(dsc, dsc->buf, 16) != 16) + /* memcmp(dsc->buf, r_index_2, 4) != 0 */ + returnerror(EDSCNOANSW, dsc_preview); + /* no answer from camera */ + break; + + default: + returnerror(EDSCBADPCL, dsc_preview); + /* bad protocol */ } return 0; @@ -658,56 +611,54 @@ int dsc_preview(dsc_t *dsc, int index) return -1; } - -int dsc_delete(dsc_t *dsc, int index) +int +dsc_delete(dsc_t* dsc, int index) { #ifdef DEBUG - int errorline; + int errorline; #endif - u_int8_t s_index = index; - unsigned int s; + u_int8_t s_index = index; + unsigned int s; - static const u_int8_t - s_request[] = { 0x00, 0x00, 0x00, 0x01, 0x11 }; + static const u_int8_t s_request[] = {0x00, 0x00, 0x00, 0x01, 0x11}; if (index < 1 || index > DSCMAXIMAGE) returnerror(EDSCBADNUM, dsc_delete); - /* bad image number */ + /* bad image number */ + + switch (dsc->type) { + case dsc1: + write(dsc->fd, s_prefix, 12); + write(dsc->fd, s_request, 5); + write(dsc->fd, &s_index, 1); + tcdrain(dsc->fd); + + /* redraw screen, delete image, redraw again */ + for (s = 3 * DSCPAUSE; s; s = sleep(s)) + ; + + if (dsc_read(dsc, dsc->buf, 12 + 6) != 12 + 6 || memcmp(dsc->buf, r_prefix, 12) != 0 || + memcmp(dsc->buf + 12, r_ok_1, 6) != 0) + returnerror(EDSCNOANSW, dsc_delete); + /* no answer from camera */ + break; + + case dsc2: + dsc2_send_cmd(dsc, DSC2_DELETE, index, 0); + + /* redraw screen, delete image, redraw again */ + for (s = 3 * DSCPAUSE; s; s = sleep(s)) + ; + + if (dsc_read(dsc, dsc->buf, 16) != 16 || memcmp(dsc->buf, r_ok_2, 16) != 0) + returnerror(EDSCNOANSW, dsc_delete); + /* no answer from camera */ + break; - switch (dsc->type) - { - case dsc1: - write(dsc->fd, s_prefix, 12); - write(dsc->fd, s_request, 5); - write(dsc->fd, &s_index, 1); - tcdrain(dsc->fd); - - /* redraw screen, delete image, redraw again */ - for (s = 3 * DSCPAUSE; s; s = sleep(s)); - - if ( dsc_read(dsc, dsc->buf, 12 + 6) != 12 + 6 || - memcmp(dsc->buf, r_prefix, 12) != 0 || - memcmp(dsc->buf + 12, r_ok_1, 6) != 0) - returnerror(EDSCNOANSW, dsc_delete); - /* no answer from camera */ - break; - - case dsc2: - dsc2_send_cmd(dsc, DSC2_DELETE, index, 0); - - /* redraw screen, delete image, redraw again */ - for (s = 3 * DSCPAUSE; s; s = sleep(s)); - - if ( dsc_read(dsc, dsc->buf, 16) != 16 || - memcmp(dsc->buf, r_ok_2, 16) != 0) - returnerror(EDSCNOANSW, dsc_delete); - /* no answer from camera */ - break; - - default: - returnerror(EDSCBADPCL, dsc_delete); - /* bad protocol */ + default: + returnerror(EDSCBADPCL, dsc_delete); + /* bad protocol */ } return 0; @@ -718,73 +669,66 @@ int dsc_delete(dsc_t *dsc, int index) return -1; } - -ssize_t dsc_requestimage(dsc_t *dsc, int index) +ssize_t +dsc_requestimage(dsc_t* dsc, int index) { #ifdef DEBUG - int errorline; + int errorline; #endif - u_int8_t s_index = index; - u_int32_t size = 0; - int command = 0x1a; - - static const u_int8_t - s_request[] = { 0x00, 0x00, 0x00, 0x01, 0x1a }, - r_request_1[] = { 0x00, 0x00, 0x00, 0x04, 0x1d, 0x00 }, - r_request_2[] = { 0x08, 0x00, 0xff, 0x1d }; - - switch (dsc->type) - { - case dsc1: - if (index < 1 || index > DSCMAXIMAGE) - returnerror(EDSCBADNUM, dsc_requestimage); - /* bad image number */ - - write(dsc->fd, s_prefix, 12); - write(dsc->fd, s_request, 5); - write(dsc->fd, &s_index, 1); - tcdrain(dsc->fd); - if ( dsc_read(dsc, dsc->buf, 12 + 6) != 12 + 6 || - memcmp(dsc->buf, r_prefix, 12) != 0 || - memcmp(dsc->buf + 12, r_request_1, 6) != 0) - returnerror(EDSCNOANSW, dsc_requestimage); - /* no answer from camera */ - - if (dsc_read(dsc, dsc->buf, 3) != 3) - returnerror(EDSCNOANSW, dsc_requestimage); - /* no answer from camera */ - - size = ((u_int32_t)dsc->buf[0] << 16) | - ((u_int32_t)dsc->buf[1] << 8) | - (u_int32_t)dsc->buf[2]; - break; - - case dsc2: - command = DSC2_SELECT; - if (index < 0) - { - index = -index; - command = DSC2_THUMB; - } - - if (index < 1 || index > DSCMAXIMAGE) - returnerror(EDSCBADNUM, dsc_requestimage); - /* bad image number */ - - dsc2_send_cmd(dsc, command, index, 0); - if ( dsc_read(dsc, dsc->buf, 16) != 16 || - memcmp(dsc->buf, r_request_2, 4) != 0) - returnerror(EDSCBADNUM, dsc_requestimage); - /* no answer from camera */ - - size = ((u_int32_t)dsc->buf[6] << 16) | - ((u_int32_t)dsc->buf[5] << 8); - break; - - default: - returnerror(EDSCBADPCL, dsc_requestimage); - /* bad protocol */ + u_int8_t s_index = index; + u_int32_t size = 0; + int command = 0x1a; + + static const u_int8_t s_request[] = {0x00, 0x00, 0x00, 0x01, 0x1a}, + r_request_1[] = {0x00, 0x00, 0x00, 0x04, 0x1d, 0x00}, + r_request_2[] = {0x08, 0x00, 0xff, 0x1d}; + + switch (dsc->type) { + case dsc1: + if (index < 1 || index > DSCMAXIMAGE) + returnerror(EDSCBADNUM, dsc_requestimage); + /* bad image number */ + + write(dsc->fd, s_prefix, 12); + write(dsc->fd, s_request, 5); + write(dsc->fd, &s_index, 1); + tcdrain(dsc->fd); + if (dsc_read(dsc, dsc->buf, 12 + 6) != 12 + 6 || memcmp(dsc->buf, r_prefix, 12) != 0 || + memcmp(dsc->buf + 12, r_request_1, 6) != 0) + returnerror(EDSCNOANSW, dsc_requestimage); + /* no answer from camera */ + + if (dsc_read(dsc, dsc->buf, 3) != 3) + returnerror(EDSCNOANSW, dsc_requestimage); + /* no answer from camera */ + + size = + ((u_int32_t)dsc->buf[0] << 16) | ((u_int32_t)dsc->buf[1] << 8) | (u_int32_t)dsc->buf[2]; + break; + + case dsc2: + command = DSC2_SELECT; + if (index < 0) { + index = -index; + command = DSC2_THUMB; + } + + if (index < 1 || index > DSCMAXIMAGE) + returnerror(EDSCBADNUM, dsc_requestimage); + /* bad image number */ + + dsc2_send_cmd(dsc, command, index, 0); + if (dsc_read(dsc, dsc->buf, 16) != 16 || memcmp(dsc->buf, r_request_2, 4) != 0) + returnerror(EDSCBADNUM, dsc_requestimage); + /* no answer from camera */ + + size = ((u_int32_t)dsc->buf[6] << 16) | ((u_int32_t)dsc->buf[5] << 8); + break; + + default: + returnerror(EDSCBADPCL, dsc_requestimage); + /* bad protocol */ } return (ssize_t)size; @@ -795,79 +739,69 @@ ssize_t dsc_requestimage(dsc_t *dsc, int index) return -1; } - -ssize_t dsc_readimageblock(dsc_t *dsc, int block, void *buf) +ssize_t +dsc_readimageblock(dsc_t* dsc, int block, void* buf) { #ifdef DEBUG - int errorline; + int errorline; #endif - u_int8_t s_block = block; - u_int32_t size; - - static const u_int8_t - getblock[] = { 0x00, 0x00, 0x00, 0x02, 0x1e, 0x00 }; - - switch (dsc->type) - { - case dsc1: - write(dsc->fd, s_prefix, 12); - write(dsc->fd, getblock, 6); - write(dsc->fd, &s_block, 1); - tcdrain(dsc->fd); - if ( dsc_read(dsc, dsc->buf, 12 + 5) != 12 + 5 || - memcmp(dsc->buf, r_prefix, 12) != 0 || - dsc->buf[12] != 0 || - dsc->buf[13] != 0 || - dsc->buf[16] != 0) - returnerror(EDSCNOANSW, dsc_readimageblock); - /* no answer from camera */ - - size = ((u_int32_t)dsc->buf[14] << 8) | - (u_int32_t)dsc->buf[15]; + u_int8_t s_block = block; + u_int32_t size; + + static const u_int8_t getblock[] = {0x00, 0x00, 0x00, 0x02, 0x1e, 0x00}; + + switch (dsc->type) { + case dsc1: + write(dsc->fd, s_prefix, 12); + write(dsc->fd, getblock, 6); + write(dsc->fd, &s_block, 1); + tcdrain(dsc->fd); + if (dsc_read(dsc, dsc->buf, 12 + 5) != 12 + 5 || memcmp(dsc->buf, r_prefix, 12) != 0 || + dsc->buf[12] != 0 || dsc->buf[13] != 0 || dsc->buf[16] != 0) + returnerror(EDSCNOANSW, dsc_readimageblock); + /* no answer from camera */ + + size = ((u_int32_t)dsc->buf[14] << 8) | (u_int32_t)dsc->buf[15]; #ifdef DEBUG - if (size > 1024) - fprintf( - stderr, - __BASE_FILE__ ": dsc_readimageblock() " - "camera sends image block bigger " - "than 1k (%u)\n\n" - PLEASEREPORT - "\n\n", - size - ); + if (size > 1024) + fprintf( + stderr, + __BASE_FILE__ ": dsc_readimageblock() " + "camera sends image block bigger " + "than 1k (%u)\n\n" PLEASEREPORT "\n\n", + size + ); #endif - if (dsc_read(dsc, buf, size) != size) - returnerror(EDSCNOANSW, dsc_readimageblock); - /* no answer from camera */ - break; - - case dsc2: - dsc2_send_cmd(dsc, DSC2_GET_DATA, block, block); - if ( dsc_read(dsc, dsc->buf, 4) != 4 || - dsc->buf[0] != 1 || - dsc->buf[1] != block || - dsc->buf[3] != 5) - returnerror(EDSCNOANSW, dsc_readimageblock); - /* no answer from camera */ - - size = 1024; /* always returns 1024 bytes */ - - if (dsc_read(dsc, buf, size) != size) - returnerror(EDSCNOANSW, dsc_readimageblock); - /* no answer from camera */ - - /* checksum */ - if (dsc_read(dsc, dsc->buf + 4, 2) != 2) - returnerror(EDSCNOANSW, dsc_readimageblock); - /* no answer from camera */ - break; - - default: - returnerror(EDSCBADPCL, dsc_readimageblock); - /* bad protocol */ + if (dsc_read(dsc, buf, size) != size) + returnerror(EDSCNOANSW, dsc_readimageblock); + /* no answer from camera */ + break; + + case dsc2: + dsc2_send_cmd(dsc, DSC2_GET_DATA, block, block); + if (dsc_read(dsc, dsc->buf, 4) != 4 || dsc->buf[0] != 1 || dsc->buf[1] != block || + dsc->buf[3] != 5) + returnerror(EDSCNOANSW, dsc_readimageblock); + /* no answer from camera */ + + size = 1024; /* always returns 1024 bytes */ + + if (dsc_read(dsc, buf, size) != size) + returnerror(EDSCNOANSW, dsc_readimageblock); + /* no answer from camera */ + + /* checksum */ + if (dsc_read(dsc, dsc->buf + 4, 2) != 2) + returnerror(EDSCNOANSW, dsc_readimageblock); + /* no answer from camera */ + break; + + default: + returnerror(EDSCBADPCL, dsc_readimageblock); + /* bad protocol */ } return (ssize_t)size; @@ -878,27 +812,24 @@ ssize_t dsc_readimageblock(dsc_t *dsc, int block, void *buf) return -1; } - -const char *dsc_strerror(const dsc_error *lasterror) +const char* +dsc_strerror(const dsc_error* lasterror) { - static const char * const errorlist[] = { - "Unknown error code!\n" + static const char* const errorlist[] = { + "Unknown error code!\n" #ifdef DEBUG - PLEASEREPORT + PLEASEREPORT #endif - , - "BPS out of range", - "No answer from camera", - "Read time out", - "Could not reset camera", - "Bad image number", - "Bad protocol" + , + "BPS out of range", + "No answer from camera", + "Read time out", + "Could not reset camera", + "Bad image number", + "Bad protocol" }; - return lasterror->lerror == EDSCSERRNO ? - strerror(lasterror->lerrno) : - lasterror->lerror < 1 || lasterror->lerror > EDSCMAXERR ? - errorlist[0] : - errorlist[lasterror->lerror]; + return lasterror->lerror == EDSCSERRNO ? strerror(lasterror->lerrno) + : lasterror->lerror < 1 || lasterror->lerror > EDSCMAXERR ? errorlist[0] + : errorlist[lasterror->lerror]; } - diff --git a/source/add-ons/Quantize/Quantize.cpp b/source/add-ons/Quantize/Quantize.cpp index 93936d5..911067a 100644 --- a/source/add-ons/Quantize/Quantize.cpp +++ b/source/add-ons/Quantize/Quantize.cpp @@ -9,108 +9,119 @@ #include #include -int16 *gLut = 0; +int16* gLut = 0; #define FOREGROUND 0 #define BACKGROUND 1 -#define R_BITS 5 -#define G_BITS 6 -#define B_BITS 5 +#define R_BITS 5 +#define G_BITS 6 +#define B_BITS 5 -#define R_PREC (1<SetValue (256); - fDitherCB = new BCheckBox (BRect (8, 30, 180, 46), "dither", "Floyd-Steinberg Dithering", new BMessage ('fsDt')); - fDitherCB->SetValue (false); - AddChild (fDitherCB); - BBox *palB = new BBox (BRect (8, 54, 180, 110), "palette"); - palB->SetLabel ("Use Colors From"); - AddChild (palB); - - BRadioButton *fgF = new BRadioButton (BRect (4, 14, 170, 30), "fg", "Foreground Palette", new BMessage ('palF')); - BRadioButton *fgB = new BRadioButton (BRect (4, 32, 170, 48), "bg", "Background Palette", new BMessage ('palB')); - palB->AddChild (fgF); - palB->AddChild (fgB); - - fgF->SetValue (true); - } -virtual ~QView () {} -virtual void MessageReceived (BMessage *msg); - -int numColors () { return fNumColors; } -bool dither () { return (fDitherCB ? fDitherCB->Value() : false); } -int palette () { return fPalette; } - -BCheckBox *fDitherCB; - -private: -int fNumColors; -int fPalette; + public: + QView(BRect rect) : BView(rect, "Quantize_view", B_FOLLOW_ALL, B_WILL_DRAW) + { + fNumColors = 256; + fDitherCB = NULL; + fPalette = FOREGROUND; + ResizeTo(188, 118); + Slider* nSlid = + new Slider(BRect(8, 8, 180, 24), 50, "# Colors", 1, 256, 1, new BMessage('numC')); + AddChild(nSlid); + nSlid->SetValue(256); + fDitherCB = new BCheckBox( + BRect(8, 30, 180, 46), "dither", "Floyd-Steinberg Dithering", new BMessage('fsDt') + ); + fDitherCB->SetValue(false); + AddChild(fDitherCB); + BBox* palB = new BBox(BRect(8, 54, 180, 110), "palette"); + palB->SetLabel("Use Colors From"); + AddChild(palB); + + BRadioButton* fgF = new BRadioButton( + BRect(4, 14, 170, 30), "fg", "Foreground Palette", new BMessage('palF') + ); + BRadioButton* fgB = new BRadioButton( + BRect(4, 32, 170, 48), "bg", "Background Palette", new BMessage('palB') + ); + palB->AddChild(fgF); + palB->AddChild(fgB); + + fgF->SetValue(true); + } + + virtual ~QView() {} + + virtual void MessageReceived(BMessage* msg); + + int numColors() { return fNumColors; } + + bool dither() { return (fDitherCB ? fDitherCB->Value() : false); } + + int palette() { return fPalette; } + + BCheckBox* fDitherCB; + + private: + int fNumColors; + int fPalette; }; -QView *view = NULL; +QView* view = NULL; -void QView::MessageReceived (BMessage *msg) +void +QView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'numC': - fNumColors = int (msg->FindFloat ("value")); + fNumColors = int(msg->FindFloat("value")); break; case 'fsDt': // We query the button itself... @@ -122,280 +133,269 @@ void QView::MessageReceived (BMessage *msg) fPalette = BACKGROUND; break; default: - BView::MessageReceived (msg); + BView::MessageReceived(msg); return; } for (int32 i = 0; i < R_PREC; i++) for (int32 j = 0; j < G_PREC; j++) for (int32 k = 0; k < B_PREC; k++) - ELEM (gLut, i, j, k) = -1; // We build the LUT on the fly - + ELEM(gLut, i, j, k) = -1; // We build the LUT on the fly + addon_preview(); } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Quantize"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 2000-2001 ∑ Sum Software"); - strcpy (info->description, "Quantizes the colors to a given palette"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 0; - info->release = 7; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = LAYER_ONLY; + strcpy(info->name, "Quantize"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 2000-2001 ∑ Sum Software"); + strcpy(info->description, "Quantizes the colors to a given palette"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 0; + info->release = 7; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = LAYER_ONLY; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { - delete [] gLut; + delete[] gLut; gLut = 0; return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -void fill_lut (int16 *lut, rgb_color palette[], int max_colors, int r, int g, int b); -int find_nearby_colors (rgb_color palette[], int numcolors, uint8 color_list[], int min_r, int min_g, int min_b); -void find_best_colors (rgb_color palette[], int numcolors, int minr, int ming, int minb, uint8 colorlist[], uint8 bestcolors[]); - -int find_nearby_colors (rgb_color palette[], int numcolors, uint8 color_list[], int minr, int ming, int minb) +void +fill_lut(int16* lut, rgb_color palette[], int max_colors, int r, int g, int b); +int +find_nearby_colors( + rgb_color palette[], int numcolors, uint8 color_list[], int min_r, int min_g, int min_b +); +void +find_best_colors( + rgb_color palette[], int numcolors, int minr, int ming, int minb, uint8 colorlist[], + uint8 bestcolors[] +); + +int +find_nearby_colors( + rgb_color palette[], int numcolors, uint8 color_list[], int minr, int ming, int minb +) { int maxr, maxg, maxb; int cr, cg, cb; int i, x, ncolors; float minmaxdist, min_dist, max_dist, tdist; - float mindist[256]; // 256 = the maximum palette size, actually. - + float mindist[256]; // 256 = the maximum palette size, actually. + maxr = minr + ((1 << BOX_R_SHIFT) - (1 << R_SHIFT)); - cr = (minr + maxr)/2; + cr = (minr + maxr) / 2; maxg = ming + ((1 << BOX_G_SHIFT) - (1 << G_SHIFT)); - cg = (ming + maxg)/2; - maxb = minb + ((1 << BOX_B_SHIFT) - (1 << B_SHIFT)); - cb = (minb + maxb)/2; - - /* For each color in colormap, find: - * 1. its minimum squared-distance to any point in the update box - * (zero if color is within update box); - * 2. its maximum squared-distance to any point in the update box. - * Both of these can be found by considering only the corners of the box. - * We save the minimum distance for each color in mindist[]; - * only the smallest maximum distance is of interest. - */ - + cg = (ming + maxg) / 2; + maxb = minb + ((1 << BOX_B_SHIFT) - (1 << B_SHIFT)); + cb = (minb + maxb) / 2; + + /* For each color in colormap, find: + * 1. its minimum squared-distance to any point in the update box + * (zero if color is within update box); + * 2. its maximum squared-distance to any point in the update box. + * Both of these can be found by considering only the corners of the box. + * We save the minimum distance for each color in mindist[]; + * only the smallest maximum distance is of interest. + */ + minmaxdist = 0x7FFFFFFFL; - for (i = 0; i < numcolors; i++) - { - /* We compute the squared-r-distance term, then add in the other two. */ + for (i = 0; i < numcolors; i++) { + /* We compute the squared-r-distance term, then add in the other two. */ x = palette[i].red; - if (x < minr) - { - tdist = (x - minr)*R_WEIGHT; - min_dist = tdist*tdist; - tdist = (x - maxr)*R_WEIGHT; - max_dist = tdist*tdist; - } - else if (x > maxr) - { - tdist = (x - maxr)*R_WEIGHT; - min_dist = tdist*tdist; - tdist = (x - minr)*R_WEIGHT; - max_dist = tdist*tdist; - } - else // within cell range so no contribution to min_dist + if (x < minr) { + tdist = (x - minr) * R_WEIGHT; + min_dist = tdist * tdist; + tdist = (x - maxr) * R_WEIGHT; + max_dist = tdist * tdist; + } else if (x > maxr) { + tdist = (x - maxr) * R_WEIGHT; + min_dist = tdist * tdist; + tdist = (x - minr) * R_WEIGHT; + max_dist = tdist * tdist; + } else // within cell range so no contribution to min_dist { min_dist = 0; - if (x <= cr) - { - tdist = (x - maxr)*R_WEIGHT; - max_dist = tdist*tdist; - } - else - { - tdist = (x - minr)*R_WEIGHT; - max_dist = tdist*tdist; + if (x <= cr) { + tdist = (x - maxr) * R_WEIGHT; + max_dist = tdist * tdist; + } else { + tdist = (x - minr) * R_WEIGHT; + max_dist = tdist * tdist; } } x = palette[i].green; - if (x < ming) - { - tdist = (x - ming)*G_WEIGHT; - min_dist += tdist*tdist; - tdist = (x - maxg)*G_WEIGHT; - max_dist += tdist*tdist; - } - else if (x > maxg) - { - tdist = (x - maxg)*G_WEIGHT; - min_dist += tdist*tdist; - tdist = (x - ming)*G_WEIGHT; - max_dist += tdist*tdist; - } - else - { - if (x <= cg) - { - tdist = (x - maxg)*G_WEIGHT; - max_dist += tdist*tdist; - } - else - { - tdist = (x - ming)*G_WEIGHT; - max_dist += tdist*tdist; + if (x < ming) { + tdist = (x - ming) * G_WEIGHT; + min_dist += tdist * tdist; + tdist = (x - maxg) * G_WEIGHT; + max_dist += tdist * tdist; + } else if (x > maxg) { + tdist = (x - maxg) * G_WEIGHT; + min_dist += tdist * tdist; + tdist = (x - ming) * G_WEIGHT; + max_dist += tdist * tdist; + } else { + if (x <= cg) { + tdist = (x - maxg) * G_WEIGHT; + max_dist += tdist * tdist; + } else { + tdist = (x - ming) * G_WEIGHT; + max_dist += tdist * tdist; } } x = palette[i].blue; - if (x < minb) - { - tdist = (x - minb)*B_WEIGHT; - min_dist += tdist*tdist; - tdist = (x - maxb)*B_WEIGHT; - max_dist += tdist*tdist; - } - else if (x > maxb) - { - tdist = (x - maxb)*B_WEIGHT; - min_dist += tdist*tdist; - tdist = (x - minb)*B_WEIGHT; - max_dist += tdist*tdist; - } - else - { - if (x <= cb) - { - tdist = (x - maxb)*B_WEIGHT; - max_dist += tdist*tdist; - } - else - { - tdist = (x - minb)*B_WEIGHT; - max_dist += tdist*tdist; + if (x < minb) { + tdist = (x - minb) * B_WEIGHT; + min_dist += tdist * tdist; + tdist = (x - maxb) * B_WEIGHT; + max_dist += tdist * tdist; + } else if (x > maxb) { + tdist = (x - maxb) * B_WEIGHT; + min_dist += tdist * tdist; + tdist = (x - minb) * B_WEIGHT; + max_dist += tdist * tdist; + } else { + if (x <= cb) { + tdist = (x - maxb) * B_WEIGHT; + max_dist += tdist * tdist; + } else { + tdist = (x - minb) * B_WEIGHT; + max_dist += tdist * tdist; } } - mindist[i] = min_dist; /* save away the results */ + mindist[i] = min_dist; /* save away the results */ if (max_dist < minmaxdist) minmaxdist = max_dist; } - /* Now we know that no cell in the update box is more than minmaxdist - * away from some colormap entry. Therefore, only colors that are - * within minmaxdist of some part of the box need be considered. - */ + /* Now we know that no cell in the update box is more than minmaxdist + * away from some colormap entry. Therefore, only colors that are + * within minmaxdist of some part of the box need be considered. + */ ncolors = 0; - for (i = 0; i < numcolors; i++) - { + for (i = 0; i < numcolors; i++) { if (mindist[i] <= minmaxdist) color_list[ncolors++] = i; } - + return ncolors; } -void find_best_colors (rgb_color palette[], int numcolors, int minr, int ming, int minb, uint8 colorlist[], uint8 bestcolors[]) +void +find_best_colors( + rgb_color palette[], int numcolors, int minr, int ming, int minb, uint8 colorlist[], + uint8 bestcolors[] +) { int ir, ig, ib; int i, icolor; - register float *bptr; // pointer into bestdist[] array - uint8 *cptr; // pointer into bestcolor[] array - float dist0, dist1; // initial distance values - register float dist2; // current distance in inner loop - float xx0, xx1; // distance increments + register float* bptr; // pointer into bestdist[] array + uint8* cptr; // pointer into bestcolor[] array + float dist0, dist1; // initial distance values + register float dist2; // current distance in inner loop + float xx0, xx1; // distance increments register float xx2; - float inc0, inc1, inc2; // initial values for increments + float inc0, inc1, inc2; // initial values for increments // This array holds the distance to the nearest-so-far color for each cell - float bestdist[BOX_R_ELEMS*BOX_G_ELEMS*BOX_B_ELEMS]; + float bestdist[BOX_R_ELEMS * BOX_G_ELEMS * BOX_B_ELEMS]; /* Initialize best-distance for each cell of the update box */ bptr = bestdist - 1; - for (i = BOX_R_ELEMS*BOX_G_ELEMS*BOX_B_ELEMS - 1; i >= 0; i--) + for (i = BOX_R_ELEMS * BOX_G_ELEMS * BOX_B_ELEMS - 1; i >= 0; i--) *(++bptr) = 0x7FFFFFFFL; - - /* For each color selected by find_nearby_colors, - * compute its distance to the center of each cell in the box. - * If that's less than best-so-far, update best distance and color number. - */ - - /* Nominal steps between cell centers ("x" in Thomas article) */ -#define STEP_R ((1 << R_SHIFT)*R_WEIGHT) -#define STEP_G ((1 << G_SHIFT)*G_WEIGHT) -#define STEP_B ((1 << B_SHIFT)*B_WEIGHT) - - for (i = 0; i < numcolors; i++) - { + + /* For each color selected by find_nearby_colors, + * compute its distance to the center of each cell in the box. + * If that's less than best-so-far, update best distance and color number. + */ + + /* Nominal steps between cell centers ("x" in Thomas article) */ +#define STEP_R ((1 << R_SHIFT) * R_WEIGHT) +#define STEP_G ((1 << G_SHIFT) * G_WEIGHT) +#define STEP_B ((1 << B_SHIFT) * B_WEIGHT) + + for (i = 0; i < numcolors; i++) { icolor = colorlist[i]; /* Compute (square of) distance from minr/g/b to this color */ - inc0 = (minr - palette[icolor].red)*R_WEIGHT; - dist0 = inc0*inc0; - inc1 = (ming - palette[icolor].green)*G_WEIGHT; - dist0 += inc1*inc1; - inc2 = (minb - palette[icolor].blue)*B_WEIGHT; - dist0 += inc2*inc2; + inc0 = (minr - palette[icolor].red) * R_WEIGHT; + dist0 = inc0 * inc0; + inc1 = (ming - palette[icolor].green) * G_WEIGHT; + dist0 += inc1 * inc1; + inc2 = (minb - palette[icolor].blue) * B_WEIGHT; + dist0 += inc2 * inc2; /* Form the initial difference increments */ - inc0 = inc0*(2*STEP_R) + STEP_R*STEP_R; - inc1 = inc1*(2*STEP_G) + STEP_G*STEP_G; - inc2 = inc2*(2*STEP_B) + STEP_B*STEP_B; + inc0 = inc0 * (2 * STEP_R) + STEP_R * STEP_R; + inc1 = inc1 * (2 * STEP_G) + STEP_G * STEP_G; + inc2 = inc2 * (2 * STEP_B) + STEP_B * STEP_B; /* Now loop over all cells in box, updating distance per Thomas method */ bptr = bestdist; cptr = bestcolors; xx0 = inc0; - for (ir = BOX_R_ELEMS - 1; ir >= 0; ir--) - { + for (ir = BOX_R_ELEMS - 1; ir >= 0; ir--) { dist1 = dist0; xx1 = inc1; - for (ig = BOX_G_ELEMS - 1; ig >= 0; ig--) - { + for (ig = BOX_G_ELEMS - 1; ig >= 0; ig--) { dist2 = dist1; xx2 = inc2; - for (ib = BOX_B_ELEMS - 1; ib >= 0; ib--) - { - if (dist2 < *bptr) - { - *bptr = dist2; - *cptr = icolor; + for (ib = BOX_B_ELEMS - 1; ib >= 0; ib--) { + if (dist2 < *bptr) { + *bptr = dist2; + *cptr = icolor; } dist2 += xx2; - xx2 += 2*STEP_B*STEP_B; + xx2 += 2 * STEP_B * STEP_B; bptr++; cptr++; } dist1 += xx1; - xx1 += 2*STEP_G*STEP_G; + xx1 += 2 * STEP_G * STEP_G; } dist0 += xx0; - xx0 += 2*STEP_R*STEP_R; + xx0 += 2 * STEP_R * STEP_R; } } } -void fill_lut (int16 *lut, rgb_color palette[], int max_colors, int r, int g, int b) +void +fill_lut(int16* lut, rgb_color palette[], int max_colors, int r, int g, int b) { - int minr, ming, minb; /* lower left corner of update box */ + int minr, ming, minb; /* lower left corner of update box */ int ir, ig, ib; - register uint8 *cptr; /* pointer into bestcolor[] array */ + register uint8* cptr; /* pointer into bestcolor[] array */ /* This array lists the candidate colormap indexes. */ uint8 colorlist[256]; - int numcolors; /* number of candidate colors */ + int numcolors; /* number of candidate colors */ /* This array holds the actually closest colormap index for each cell. */ - uint8 bestcolor[BOX_R_ELEMS*BOX_G_ELEMS*BOX_B_ELEMS]; - + uint8 bestcolor[BOX_R_ELEMS * BOX_G_ELEMS * BOX_B_ELEMS]; + /* Convert cell coordinates to update box ID */ r >>= BOX_R_LOG; g >>= BOX_G_LOG; b >>= BOX_B_LOG; - + /* Compute true coordinates of update box's origin corner. * Actually we compute the coordinates of the center of the corner * histogram cell, which are the lower bounds of the volume we care about. @@ -403,57 +403,59 @@ void fill_lut (int16 *lut, rgb_color palette[], int max_colors, int r, int g, in minr = (r << BOX_R_SHIFT) + ((1 << R_SHIFT) >> 1); ming = (g << BOX_G_SHIFT) + ((1 << G_SHIFT) >> 1); minb = (b << BOX_B_SHIFT) + ((1 << B_SHIFT) >> 1); - + /* Determine which colormap entries are close enough to be candidates * for the nearest entry to some cell in the update box. */ - numcolors = find_nearby_colors (palette, max_colors, colorlist, minr, ming, minb); - + numcolors = find_nearby_colors(palette, max_colors, colorlist, minr, ming, minb); + /* Determine the actually nearest colors. */ - find_best_colors (palette, numcolors, minr, ming, minb, colorlist, bestcolor); - + find_best_colors(palette, numcolors, minr, ming, minb, colorlist, bestcolor); + /* Save the best color numbers (plus 1) in the main cache array */ - r <<= BOX_R_LOG; /* convert ID back to base cell indexes */ + r <<= BOX_R_LOG; /* convert ID back to base cell indexes */ g <<= BOX_G_LOG; b <<= BOX_B_LOG; - + cptr = bestcolor - 1; - + for (ir = 0; ir < BOX_R_ELEMS; ir++) for (ig = 0; ig < BOX_G_ELEMS; ig++) - for (ib = 0; ib < BOX_B_ELEMS; ib++) - ELEM (lut, (r + ir), (g + ig), (b + ib)) = *(++cptr); + for (ib = 0; ib < BOX_B_ELEMS; ib++) + ELEM(lut, (r + ir), (g + ig), (b + ib)) = *(++cptr); } -status_t addon_make_config (BView **vw, BRect rect) +status_t +addon_make_config(BView** vw, BRect rect) { - view = new QView (rect); + view = new QView(rect); *vw = view; - gLut = new int16 [R_PREC*G_PREC*B_PREC]; + gLut = new int16[R_PREC * G_PREC * B_PREC]; for (int32 i = 0; i < R_PREC; i++) for (int32 j = 0; j < G_PREC; j++) for (int32 k = 0; k < B_PREC; k++) - ELEM (gLut, i, j, k) = -1; // We build the LUT on the fly + ELEM(gLut, i, j, k) = -1; // We build the LUT on the fly return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /* frame */, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /* frame */, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); -// printf ("Bounds: "); -// bounds.PrintToStream(); -// printf ("Frame: "); -// frame->PrintToStream(); - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + // printf ("Bounds: "); + // bounds.PrintToStream(); + // printf ("Frame: "); + // frame->PrintToStream(); + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to Quantize + *outSelection = new Selection(*inSelection); + else // No Selection to Quantize return (0); } if (*outLayer) @@ -462,269 +464,266 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits() - 1; - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits() - 1; + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits() - 1; - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits() - 1; - rgb_color *palette; + float delta = 100.0 / h; // For the Status Bar. + + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits() - 1; + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits() - 1; + rgb_color* palette; if (view->palette() == BACKGROUND) palette = lowpalette(); else palette = highpalette(); - + int numcolors = view->numColors(); - - if (!view->dither()) // Simple quantizer + + if (!view->dither()) // Simple quantizer { - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { bgra_pixel pixel = *(++sbits); - if (!inSelection || *(++mapbits)) - { - uint8 r = RED (pixel); - uint8 g = GREEN (pixel); - uint8 b = BLUE (pixel); -// uint16 appr = ((r << 8) & 0xF700)|((g << 3) & 0x07E0)|((b >> 3) & 0x001F); + if (!inSelection || *(++mapbits)) { + uint8 r = RED(pixel); + uint8 g = GREEN(pixel); + uint8 b = BLUE(pixel); + // uint16 appr = ((r << 8) & 0xF700)|((g << 3) & + // 0x07E0)|((b >> 3) & 0x001F); int rs = r >> R_SHIFT; int gs = g >> G_SHIFT; int bs = b >> B_SHIFT; - if (ELEM (gLut, rs, gs, bs) < 0) // Not filled in yet + if (ELEM(gLut, rs, gs, bs) < 0) // Not filled in yet { - fill_lut (gLut, palette, numcolors, r >> R_SHIFT, g >> G_SHIFT, b >> B_SHIFT); + fill_lut( + gLut, palette, numcolors, r >> R_SHIFT, g >> G_SHIFT, b >> B_SHIFT + ); } - *(++dbits) = rgb2bgra (palette[ELEM (gLut, rs, gs, bs)]); - } - else + *(++dbits) = rgb2bgra(palette[ELEM(gLut, rs, gs, bs)]); + } else *(++dbits) = *(++sbits); } mapbits += mdiff; } - } - else // FS Dither + } else // FS Dither { - - // Foley & Van Dam, pp 572. - // Own note: Probably the errors in the different color channels should be weighted - // according to visual sensibility. But this version is primarily meant to - // be quick. - - uint32 width = bounds.IntegerWidth() + 1; - uint32 slpr = inLayer->BytesPerRow()/4; - bgra_pixel *src = sbits; //(bgra_pixel *) inLayer->Bits() + int (bounds.top)*slpr + int (bounds.left) - 1; - int32 sdif = slpr - width; - uint32 dbpr = (*outLayer)->BytesPerRow()/4; - bgra_pixel *dest = dbits; //(bgra_pixel *) (*outLayer)->Bits() + int (bounds.top)*dbpr + int (bounds.left) - 1; - int32 ddif = dbpr - width; - - int *nera = new int[width]; - int *nega = new int[width]; - int *neba = new int[width]; - int *cera = new int[width]; - int *cega = new int[width]; - int *ceba = new int[width]; - - bzero (nera, width*sizeof(int)); - bzero (nega, width*sizeof(int)); - bzero (neba, width*sizeof(int)); - bzero (cera, width*sizeof(int)); - bzero (cega, width*sizeof(int)); - bzero (ceba, width*sizeof(int)); - + + // Foley & Van Dam, pp 572. + // Own note: Probably the errors in the different color channels should be weighted + // according to visual sensibility. But this version is primarily meant to + // be quick. + + uint32 width = bounds.IntegerWidth() + 1; + uint32 slpr = inLayer->BytesPerRow() / 4; + bgra_pixel* src = sbits; //(bgra_pixel *) inLayer->Bits() + int (bounds.top)*slpr + int + //(bounds.left) - 1; + int32 sdif = slpr - width; + uint32 dbpr = (*outLayer)->BytesPerRow() / 4; + bgra_pixel* dest = dbits; //(bgra_pixel *) (*outLayer)->Bits() + int (bounds.top)*dbpr + + // int (bounds.left) - 1; + int32 ddif = dbpr - width; + + int* nera = new int[width]; + int* nega = new int[width]; + int* neba = new int[width]; + int* cera = new int[width]; + int* cega = new int[width]; + int* ceba = new int[width]; + + bzero(nera, width * sizeof(int)); + bzero(nega, width * sizeof(int)); + bzero(neba, width * sizeof(int)); + bzero(cera, width * sizeof(int)); + bzero(cega, width * sizeof(int)); + bzero(ceba, width * sizeof(int)); + int r, g, b, er, eg, eb, per, peg, peb; uint8 apix; uint32 x, y; rgb_color a; - - for (y = uint32 (bounds.top); y < uint32 (bounds.bottom); y++) - { -// printf ("%ld", y); fflush (stdout); - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + + for (y = uint32(bounds.top); y < uint32(bounds.bottom); y++) { + // printf ("%ld", y); fflush (stdout); + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } x = 0; - + // Special case: First pixel in a row bgra_pixel s = *(++src); - r = clip8 (RED (s) + cera[0]); - g = clip8 (GREEN (s) + cega[0]); - b = clip8 (BLUE (s) + ceba[0]); - + r = clip8(RED(s) + cera[0]); + g = clip8(GREEN(s) + cega[0]); + b = clip8(BLUE(s) + ceba[0]); + cera[0] = 0; cega[0] = 0; ceba[0] = 0; - + // Find the nearest match in the palette and write it out int rs = r >> R_SHIFT; int gs = g >> G_SHIFT; int bs = b >> B_SHIFT; - if (ELEM (gLut, rs, gs, bs) < 0) // Not filled in yet - fill_lut (gLut, palette, numcolors, rs, gs, bs); - apix = ELEM (gLut, rs, gs, bs); + if (ELEM(gLut, rs, gs, bs) < 0) // Not filled in yet + fill_lut(gLut, palette, numcolors, rs, gs, bs); + apix = ELEM(gLut, rs, gs, bs); // And the corresponding RGB color a = palette[apix]; - + if (!inSelection || *(++mapbits)) - *(++dest) = rgb2bgra (a); + *(++dest) = rgb2bgra(a); else *(++dest) = s; - + // Calculate the error terms er = r - a.red; eg = g - a.green; eb = b - a.blue; - - per = 7*er/16; - peg = 7*eg/16; - peb = 7*eb/16; - + + per = 7 * er / 16; + peg = 7 * eg / 16; + peb = 7 * eb / 16; + // Put all the remaining error in the pixels down and down-right // (since there is no pixel down-left...) - nera[x] += er/2; - nega[x] += eg/2; - neba[x] += eb/2; - nera[x + 1] += er/16; - nega[x + 1] += eg/16; - neba[x + 1] += eb/16; - - for (x = 1; x < width - 1; x++) - { -// printf (","); fflush (stdout); + nera[x] += er / 2; + nega[x] += eg / 2; + neba[x] += eb / 2; + nera[x + 1] += er / 16; + nega[x + 1] += eg / 16; + neba[x + 1] += eb / 16; + + for (x = 1; x < width - 1; x++) { + // printf (","); fflush (stdout); // Get one source pixel s = *(++src); - + // Get color components and add errors from previous pixel - r = clip8 (RED (s) + per + cera[x]); - g = clip8 (GREEN (s) + peg + cega[x]); - b = clip8 (BLUE (s) + peb + ceba[x]); - + r = clip8(RED(s) + per + cera[x]); + g = clip8(GREEN(s) + peg + cega[x]); + b = clip8(BLUE(s) + peb + ceba[x]); + cera[x] = 0; cega[x] = 0; ceba[x] = 0; - + // Find the nearest match in the palette and write it out int rs = r >> R_SHIFT; int gs = g >> G_SHIFT; int bs = b >> B_SHIFT; - if (ELEM (gLut, rs, gs, bs) < 0) // Not filled in yet - fill_lut (gLut, palette, numcolors, rs, gs, bs); - apix = ELEM (gLut, rs, gs, bs); + if (ELEM(gLut, rs, gs, bs) < 0) // Not filled in yet + fill_lut(gLut, palette, numcolors, rs, gs, bs); + apix = ELEM(gLut, rs, gs, bs); // And the corresponding RGB color a = palette[apix]; -// printf ("%c.", 8); fflush (stdout); + // printf ("%c.", 8); fflush (stdout); if (!inSelection || *(++mapbits)) - *(++dest) = rgb2bgra (a); + *(++dest) = rgb2bgra(a); else *(++dest) = s; -// printf ("%c:", 8); fflush (stdout); + // printf ("%c:", 8); fflush (stdout); + - // Calculate the error terms er = r - a.red; eg = g - a.green; eb = b - a.blue; - - per = 7*er/16; - peg = 7*eg/16; - peb = 7*eb/16; - - nera[x - 1] += 3*er/16; - nega[x - 1] += 3*eg/16; - neba[x - 1] += 3*eb/16; - nera[x] += 5*er/16; - nega[x] += 5*eg/16; - neba[x] += 5*eb/16; - nera[x + 1] += er/16; - nega[x + 1] += eg/16; - neba[x + 1] += eb/16; + + per = 7 * er / 16; + peg = 7 * eg / 16; + peb = 7 * eb / 16; + + nera[x - 1] += 3 * er / 16; + nega[x - 1] += 3 * eg / 16; + neba[x - 1] += 3 * eb / 16; + nera[x] += 5 * er / 16; + nega[x] += 5 * eg / 16; + neba[x] += 5 * eb / 16; + nera[x + 1] += er / 16; + nega[x + 1] += eg / 16; + neba[x + 1] += eb / 16; } // Special case: Last pixel -// printf ("Writing last pixel - "); fflush (stdout); + // printf ("Writing last pixel - "); fflush (stdout); s = *(++src); -// printf ("1"); fflush (stdout); - + // printf ("1"); fflush (stdout); + // Get color components and add errors from previous pixel - r = clip8 (RED (s) + per + cera[x]); - g = clip8 (GREEN (s) + peg + cega[x]); - b = clip8 (BLUE (s) + peb + ceba[x]); - + r = clip8(RED(s) + per + cera[x]); + g = clip8(GREEN(s) + peg + cega[x]); + b = clip8(BLUE(s) + peb + ceba[x]); + cera[x] = 0; cega[x] = 0; ceba[x] = 0; - + // Find the nearest match in the palette and write it out rs = r >> R_SHIFT; gs = g >> G_SHIFT; bs = b >> B_SHIFT; - if (ELEM (gLut, rs, gs, bs) < 0) // Not filled in yet - fill_lut (gLut, palette, numcolors, rs, gs, bs); - apix = ELEM (gLut, rs, gs, bs); -// printf ("@"); fflush (stdout); + if (ELEM(gLut, rs, gs, bs) < 0) // Not filled in yet + fill_lut(gLut, palette, numcolors, rs, gs, bs); + apix = ELEM(gLut, rs, gs, bs); + // printf ("@"); fflush (stdout); // And the corresponding RGB color a = palette[apix]; - -// printf ("2"); fflush (stdout); + + // printf ("2"); fflush (stdout); if (!inSelection || *(++mapbits)) - *(++dest) = rgb2bgra (a); + *(++dest) = rgb2bgra(a); else *(++dest) = s; -// printf ("Still alive.\n"); - + // printf ("Still alive.\n"); + // Calculate the error terms er = r - a.red; eg = g - a.green; eb = b - a.blue; - + // Put all the error in the pixels down and down-left - nera[x - 1] += er/2; - nega[x - 1] += eg/2; - neba[x - 1] += eb/2; - nera[x] += er/2; - nega[x] += eg/2; - neba[x] += eb/2; - + nera[x - 1] += er / 2; + nega[x - 1] += eg / 2; + neba[x - 1] += eb / 2; + nera[x] += er / 2; + nega[x] += eg / 2; + neba[x] += eb / 2; + // Switch the scratch data - int *tmp; - tmp = cera; cera = nera; nera = tmp; - tmp = cega; cega = nega; nega = tmp; - tmp = ceba; ceba = neba; neba = tmp; - + int* tmp; + tmp = cera; + cera = nera; + nera = tmp; + tmp = cega; + cega = nega; + nega = tmp; + tmp = ceba; + ceba = neba; + neba = tmp; + dest += ddif; - src += sdif; + src += sdif; mapbits += mdiff; } // Special case: Last line @@ -732,30 +731,29 @@ status_t process (Layer *inLayer, Selection *inSelection, er = 0; eg = 0; eb = 0; - -// printf ("Entering last line...\n"); - for (x = 0; x < width - 1; x++) - { + + // printf ("Entering last line...\n"); + for (x = 0; x < width - 1; x++) { // Get one source pixel bgra_pixel s = *(++src); - + // Get color components and add errors from previous pixel - r = clip8 (RED (s) + er + cera[x]); - g = clip8 (GREEN (s) + eg + cega[x]); - b = clip8 (BLUE (s) + eb + ceba[x]); - + r = clip8(RED(s) + er + cera[x]); + g = clip8(GREEN(s) + eg + cega[x]); + b = clip8(BLUE(s) + eb + ceba[x]); + // Find the nearest match in the palette and write it out int rs = r >> R_SHIFT; int gs = g >> G_SHIFT; int bs = b >> B_SHIFT; - if (ELEM (gLut, rs, gs, bs) < 0) // Not filled in yet - fill_lut (gLut, palette, numcolors, rs, gs, bs); - apix = ELEM (gLut, rs, gs, bs); + if (ELEM(gLut, rs, gs, bs) < 0) // Not filled in yet + fill_lut(gLut, palette, numcolors, rs, gs, bs); + apix = ELEM(gLut, rs, gs, bs); // And the corresponding RGB color a = palette[apix]; if (!inSelection || *(++mapbits)) - *(++dest) = rgb2bgra (a); + *(++dest) = rgb2bgra(a); else *(++dest) = s; @@ -766,39 +764,38 @@ status_t process (Layer *inLayer, Selection *inSelection, } // Last but not least, the bottom right pixel. bgra_pixel s = *(++src); - - r = clip8 (RED (s) + er + cera[x]); - g = clip8 (GREEN (s) + eg + cega[x]); - b = clip8 (BLUE (s) + eb + ceba[x]); - + + r = clip8(RED(s) + er + cera[x]); + g = clip8(GREEN(s) + eg + cega[x]); + b = clip8(BLUE(s) + eb + ceba[x]); + int rs = r >> R_SHIFT; int gs = g >> G_SHIFT; int bs = b >> B_SHIFT; - if (ELEM (gLut, rs, gs, bs) < 0) // Not filled in yet - fill_lut (gLut, palette, numcolors, rs, gs, bs); - apix = ELEM (gLut, rs, gs, bs); + if (ELEM(gLut, rs, gs, bs) < 0) // Not filled in yet + fill_lut(gLut, palette, numcolors, rs, gs, bs); + apix = ELEM(gLut, rs, gs, bs); if (!inSelection || *(++mapbits)) - *(++dest) = rgb2bgra (palette[apix]); + *(++dest) = rgb2bgra(palette[apix]); else *(++dest) = s; - - delete [] nera; - delete [] nega; - delete [] neba; - delete [] cera; - delete [] cega; - delete [] ceba; + + delete[] nera; + delete[] nega; + delete[] neba; + delete[] cera; + delete[] cega; + delete[] ceba; } - delete [] palette; + delete[] palette; break; } - case M_SELECT: - { + case M_SELECT: { break; } default: - fprintf (stderr, "Quantize: Unknown mode\n"); + fprintf(stderr, "Quantize: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -806,7 +803,7 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); - + if (final) addon_done(); return (error); diff --git a/source/add-ons/Ripple/Ripple.cpp b/source/add-ons/Ripple/Ripple.cpp index ddfc7ae..5f5df71 100644 --- a/source/add-ons/Ripple/Ripple.cpp +++ b/source/add-ons/Ripple/Ripple.cpp @@ -8,97 +8,116 @@ #include #include -#define RANGE(lb,x,ub) (((x) < (lb)) ? (lb) : (((x) > (ub)) ? (ub) : (x))) +#define RANGE(lb, x, ub) (((x) < (lb)) ? (lb) : (((x) > (ub)) ? (ub) : (x))) -#define RADIAL 0 -#define ANGULAR 1 +#define RADIAL 0 +#define ANGULAR 1 -bgra_pixel interpolate (float x, float y, bgra_pixel p0, bgra_pixel p1, bgra_pixel p2, bgra_pixel p3); +bgra_pixel +interpolate(float x, float y, bgra_pixel p0, bgra_pixel p1, bgra_pixel p2, bgra_pixel p3); -float gAmplitude; -float gWavelength; -float gPhase; -float gDecay; -float gXscale; -float gYscale; -int gRippleType; -bool gInvDecay; +float gAmplitude; +float gWavelength; +float gPhase; +float gDecay; +float gXscale; +float gYscale; +int gRippleType; +bool gInvDecay; class RippleView : public BView { -public: - RippleView (BRect rect) : BView (rect, "ripple view", B_FOLLOW_ALL, B_WILL_DRAW) - { - gAmplitude = 10; - gWavelength = 25; - gPhase = 0; - gDecay = 0; - gXscale = 1; - gYscale = 1; - gRippleType = RADIAL; - gInvDecay = false; - ResizeTo (188, 216); - Slider *aSlid = new Slider (BRect (8, 8, 180, 24), 68, "Amplitude", 0, 100, 1, new BMessage ('rplA')); - Slider *wSlid = new Slider (BRect (8, 28, 180, 44), 68, "Wavelength", 1, 100, 1, new BMessage ('rplW')); - Slider *pSlid = new Slider (BRect (8, 48, 180, 64), 68, "Phase", 0, 360, 1, new BMessage ('rplP')); - Slider *dSlid = new Slider (BRect (8, 68, 180, 84), 68, "Decay", 0, 1, 0.01, new BMessage ('rplD'), B_HORIZONTAL, 0, "%.2f"); - Slider *xSlid = new Slider (BRect (8, 88, 180, 104), 68, "X Scale", 0, 2, 0.01, new BMessage ('rplX'), B_HORIZONTAL, 0, "%.2f"); - Slider *ySlid = new Slider (BRect (8, 108, 180, 124), 68, "Y Scale", 0, 2, 0.01, new BMessage ('rplY'), B_HORIZONTAL, 0, "%.2f"); - AddChild (aSlid); - AddChild (wSlid); - AddChild (pSlid); - AddChild (dSlid); - AddChild (xSlid); - AddChild (ySlid); - aSlid->SetValue (10); - wSlid->SetValue (25); - pSlid->SetValue (0); - dSlid->SetValue (0); - xSlid->SetValue (1); - ySlid->SetValue (1); - iD = new BCheckBox (BRect (8, 130, 180, 154), "invdecay", "Inverse Decay", new BMessage ('invD')); - AddChild (iD); - iD->SetValue (false); - BBox *type = new BBox (BRect (4, 158, 180, 212), "type"); - type->SetLabel ("Type"); - AddChild (type); - BRadioButton *tA = new BRadioButton (BRect (8, 13, 164, 30), "ang", "Angular", new BMessage ('rptA')); - BRadioButton *tR = new BRadioButton (BRect (8, 30, 164, 47), "rad", "Radial", new BMessage ('rptR')); - type->AddChild (tA); - type->AddChild (tR); - tR->SetValue (true); - } -virtual ~RippleView () {} -virtual void MessageReceived (BMessage *msg); - -BCheckBox *iD; + public: + RippleView(BRect rect) : BView(rect, "ripple view", B_FOLLOW_ALL, B_WILL_DRAW) + { + gAmplitude = 10; + gWavelength = 25; + gPhase = 0; + gDecay = 0; + gXscale = 1; + gYscale = 1; + gRippleType = RADIAL; + gInvDecay = false; + ResizeTo(188, 216); + Slider* aSlid = + new Slider(BRect(8, 8, 180, 24), 68, "Amplitude", 0, 100, 1, new BMessage('rplA')); + Slider* wSlid = + new Slider(BRect(8, 28, 180, 44), 68, "Wavelength", 1, 100, 1, new BMessage('rplW')); + Slider* pSlid = + new Slider(BRect(8, 48, 180, 64), 68, "Phase", 0, 360, 1, new BMessage('rplP')); + Slider* dSlid = new Slider( + BRect(8, 68, 180, 84), 68, "Decay", 0, 1, 0.01, new BMessage('rplD'), B_HORIZONTAL, 0, + "%.2f" + ); + Slider* xSlid = new Slider( + BRect(8, 88, 180, 104), 68, "X Scale", 0, 2, 0.01, new BMessage('rplX'), B_HORIZONTAL, + 0, "%.2f" + ); + Slider* ySlid = new Slider( + BRect(8, 108, 180, 124), 68, "Y Scale", 0, 2, 0.01, new BMessage('rplY'), B_HORIZONTAL, + 0, "%.2f" + ); + AddChild(aSlid); + AddChild(wSlid); + AddChild(pSlid); + AddChild(dSlid); + AddChild(xSlid); + AddChild(ySlid); + aSlid->SetValue(10); + wSlid->SetValue(25); + pSlid->SetValue(0); + dSlid->SetValue(0); + xSlid->SetValue(1); + ySlid->SetValue(1); + iD = new BCheckBox( + BRect(8, 130, 180, 154), "invdecay", "Inverse Decay", new BMessage('invD') + ); + AddChild(iD); + iD->SetValue(false); + BBox* type = new BBox(BRect(4, 158, 180, 212), "type"); + type->SetLabel("Type"); + AddChild(type); + BRadioButton* tA = + new BRadioButton(BRect(8, 13, 164, 30), "ang", "Angular", new BMessage('rptA')); + BRadioButton* tR = + new BRadioButton(BRect(8, 30, 164, 47), "rad", "Radial", new BMessage('rptR')); + type->AddChild(tA); + type->AddChild(tR); + tR->SetValue(true); + } + + virtual ~RippleView() {} + + virtual void MessageReceived(BMessage* msg); + + BCheckBox* iD; }; -void RippleView::MessageReceived (BMessage *msg) +void +RippleView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'rplW': - gWavelength = msg->FindFloat ("value"); -// printf ("Wavelength %f\n", fWavelength); + gWavelength = msg->FindFloat("value"); + // printf ("Wavelength %f\n", fWavelength); break; case 'rplA': - gAmplitude = msg->FindFloat ("value"); -// printf ("Amplitude %f\n", fAmplitude); + gAmplitude = msg->FindFloat("value"); + // printf ("Amplitude %f\n", fAmplitude); break; case 'rplP': - gPhase = msg->FindFloat ("value"); -// printf ("Phase %f\n", fPhase); + gPhase = msg->FindFloat("value"); + // printf ("Phase %f\n", fPhase); break; case 'rplD': - gDecay = msg->FindFloat ("value"); -// printf ("Decay %f\n", fDecay); + gDecay = msg->FindFloat("value"); + // printf ("Decay %f\n", fDecay); break; case 'rplX': - gXscale = msg->FindFloat ("value"); + gXscale = msg->FindFloat("value"); break; case 'rplY': - gYscale = msg->FindFloat ("value"); + gYscale = msg->FindFloat("value"); break; case 'rptA': gRippleType = ANGULAR; @@ -110,244 +129,240 @@ void RippleView::MessageReceived (BMessage *msg) gInvDecay = iD->Value(); break; default: - BView::MessageReceived (msg); + BView::MessageReceived(msg); return; } addon_preview(); } -bgra_pixel interpolate (float x, float y, bgra_pixel p0, bgra_pixel p1, bgra_pixel p2, bgra_pixel p3) +bgra_pixel +interpolate(float x, float y, bgra_pixel p0, bgra_pixel p1, bgra_pixel p2, bgra_pixel p3) { float au, ru, gu, bu, ad, rd, gd, bd; - ru = x*RED(p0) + (1 - x)*RED(p1); - rd = x*RED(p3) + (1 - x)*RED(p2); - gu = x*GREEN(p0) + (1 - x)*GREEN(p1); - gd = x*GREEN(p3) + (1 - x)*GREEN(p2); - bu = x*BLUE(p0) + (1 - x)*BLUE(p1); - bd = x*BLUE(p3) + (1 - x)*BLUE(p2); - au = x*ALPHA(p0) + (1 - x)*ALPHA(p1); - ad = x*ALPHA(p3) + (1 - x)*ALPHA(p2); - return (PIXEL(y*ru + (1 - y)*rd, y*gu + (1 - y)*gd, y*bu + (1 - y)*bd, y*au + (1 - y)*ad)); + ru = x * RED(p0) + (1 - x) * RED(p1); + rd = x * RED(p3) + (1 - x) * RED(p2); + gu = x * GREEN(p0) + (1 - x) * GREEN(p1); + gd = x * GREEN(p3) + (1 - x) * GREEN(p2); + bu = x * BLUE(p0) + (1 - x) * BLUE(p1); + bd = x * BLUE(p3) + (1 - x) * BLUE(p2); + au = x * ALPHA(p0) + (1 - x) * ALPHA(p1); + ad = x * ALPHA(p3) + (1 - x) * ALPHA(p2); + return (PIXEL( + y * ru + (1 - y) * rd, y * gu + (1 - y) * gd, y * bu + (1 - y) * bd, y * au + (1 - y) * ad + )); } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Ripple"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998-2001 ∑ Sum Software"); - strcpy (info->description, "Maps the image onto rippling fluid"); - info->type = BECASSO_TRANSFORMER; - info->index = index; - info->version = 0; - info->release = 7; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_2x2 | PREVIEW_MOUSE; - info->flags = 0; + strcpy(info->name, "Ripple"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998-2001 ∑ Sum Software"); + strcpy(info->description, "Maps the image onto rippling fluid"); + info->type = BECASSO_TRANSFORMER; + info->index = index; + info->version = 0; + info->release = 7; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_2x2 | PREVIEW_MOUSE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new RippleView (rect); + *view = new RippleView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect *frame, bool final, BPoint point, uint32 buttons) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* frame, bool final, BPoint point, uint32 buttons +) { static BPoint center; - + int error = ADDON_OK; BRect bounds = inLayer->Bounds(); - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to ripple! + *outSelection = new Selection(*inSelection); + else // No Selection to ripple! return (error); } if (*outLayer) (*outLayer)->Lock(); if (*outSelection) (*outSelection)->Lock(); - -// frame->PrintToStream(); - + + // frame->PrintToStream(); + uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; uint32 mdiff = 0; - float amplitude = gAmplitude/(buttons ? 2 : 1); - float wavelength = gWavelength/(buttons ? 2 : 1); - float phase = gPhase*M_PI/180.0; - float decay = gDecay; - int type = gRippleType; - int invdecay = gInvDecay; + float amplitude = gAmplitude / (buttons ? 2 : 1); + float wavelength = gWavelength / (buttons ? 2 : 1); + float phase = gPhase * M_PI / 180.0; + float decay = gDecay; + int type = gRippleType; + int invdecay = gInvDecay; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits(); - mbpr = inSelection->BytesPerRow(); + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits(); + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } - - if (point != BPoint (-1, -1)) - { + + if (point != BPoint(-1, -1)) { center = point; -// printf ("Center set to (%.0f, %.0f\n)", center.x, center.y); + // printf ("Center set to (%.0f, %.0f\n)", center.x, center.y); } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. + float delta = 100.0 / h; // For the Status Bar. - switch (mode) - { - case M_DRAW: - { + switch (mode) { + case M_DRAW: { int32 row, col; uint32 pprs, pprd; bgra_pixel *s, *d; int32 firstRow, lastRow, firstCol, lastCol; int32 cx, cy; float scale_x, scale_y, redwavelength, scaleparam; - - pprs = inLayer->BytesPerRow()/4; - pprd = (*outLayer)->BytesPerRow()/4; - - s = (bgra_pixel *) inLayer->Bits(); - d = (bgra_pixel *) (*outLayer)->Bits(); - - firstRow = int32 (frame->top); - lastRow = int32 (frame->bottom); - firstCol = int32 (frame->left); - lastCol = int32 (frame->right); - - cx = int32 (center.x); //(lastCol - firstCol)/2; - cy = int32 (center.y); //(lastRow - firstRow)/2; - + + pprs = inLayer->BytesPerRow() / 4; + pprd = (*outLayer)->BytesPerRow() / 4; + + s = (bgra_pixel*)inLayer->Bits(); + d = (bgra_pixel*)(*outLayer)->Bits(); + + firstRow = int32(frame->top); + lastRow = int32(frame->bottom); + firstCol = int32(frame->left); + lastCol = int32(frame->right); + + cx = int32(center.x); //(lastCol - firstCol)/2; + cy = int32(center.y); //(lastRow - firstRow)/2; + scale_x = gXscale; scale_y = gYscale; /* This here is for non-square images, to keep the ripples circular */ -// scale_x = scale_y = 1.0; -// if (w < h) -// scale_x = (float) h/w; -// else if (w > h) -// scale_y = (float) w/h; - - redwavelength = wavelength/(2.0*M_PI); - scaleparam = hypot (h, w); - + // scale_x = scale_y = 1.0; + // if (w < h) + // scale_x = (float) h/w; + // else if (w > h) + // scale_y = (float) w/h; + + redwavelength = wavelength / (2.0 * M_PI); + scaleparam = hypot(h, w); + for (row = 0; row < firstRow; row++) - memcpy (d + row*pprd, s + row*pprs, inLayer->BytesPerRow()); - - for (row = firstRow; row <= lastRow; row++) - { -// printf ("%d ", row); fflush (stdout); + memcpy(d + row * pprd, s + row * pprs, inLayer->BytesPerRow()); + + for (row = firstRow; row <= lastRow; row++) { + // printf ("%d ", row); fflush (stdout); float r, dx, dy; - bgra_pixel *dl = d + row*pprd - 1; - dy = (row - cy)*scale_y; - - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + bgra_pixel* dl = d + row * pprd - 1; + dy = (row - cy) * scale_y; + + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - bgra_pixel *sl = s + row*pprs - 1; + bgra_pixel* sl = s + row * pprs - 1; for (col = 0; col < firstCol; col++) *(++dl) = *(++sl); - grey_pixel *ml = mapbits + row*mbpr + firstCol - 1; - - for (col = firstCol; col <= lastCol; col++) - { - if (!inSelection || *(++ml)) - { + grey_pixel* ml = mapbits + row * mbpr + firstCol - 1; + + for (col = firstCol; col <= lastCol; col++) { + if (!inSelection || *(++ml)) { float delta, nx, ny, mx, my; uint32 p0, p1, p2, p3; uint32 inx, iny; - dx = (col - cx)*scale_x; - r = hypot (dx, dy); /* Distance to center of ripples */ - delta = amplitude*((decay != 0.0) ? (invdecay ? (r/scaleparam)/decay : (1 - decay)*(scaleparam - r)/scaleparam): 1.0)*sin (r/redwavelength + phase); - if (type == RADIAL) - { - nx = (delta + dx)/scale_x + cx; - ny = (delta + dy)/scale_y + cy; - } - else // ANGULAR + dx = (col - cx) * scale_x; + r = hypot(dx, dy); /* Distance to center of ripples */ + delta = + amplitude * + ((decay != 0.0) ? (invdecay ? (r / scaleparam) / decay + : (1 - decay) * (scaleparam - r) / scaleparam) + : 1.0) * + sin(r / redwavelength + phase); + if (type == RADIAL) { + nx = (delta + dx) / scale_x + cx; + ny = (delta + dy) / scale_y + cy; + } else // ANGULAR { float nr = r + delta; - float ang = atan2 (dx, dy); - nx = nr*sin(ang) + cx; - ny = nr*cos(ang) + cy; + float ang = atan2(dx, dy); + nx = nr * sin(ang) + cx; + ny = nr * cos(ang) + cy; } - nx = RANGE (firstCol, nx, lastCol); - ny = RANGE (firstRow, ny, lastRow); - + nx = RANGE(firstCol, nx, lastCol); + ny = RANGE(firstRow, ny, lastRow); + /* Use simple (2D) interpolation here to get rid of ugly aliasing */ - mx = 1 - fmod (nx, 1.0); - my = 1 - fmod (ny, 1.0); - - iny = (uint32) ny; - inx = (uint32) nx; - if (final) - { - p0 = (s + iny*pprs)[inx]; - p1 = (s + iny*pprs)[inx + (inx < w ? 1 : 0)]; - p2 = (s + (iny + (iny < h ? 1 : 0))*pprs)[inx + (inx < w ? 1 : 0)]; - p3 = (s + (iny + (iny < h ? 1 : 0))*pprs)[inx]; - - *(++dl) = interpolate (mx, my, p0, p1, p2, p3); - } - else - { - p0 = (s + iny*pprs)[inx]; + mx = 1 - fmod(nx, 1.0); + my = 1 - fmod(ny, 1.0); + + iny = (uint32)ny; + inx = (uint32)nx; + if (final) { + p0 = (s + iny * pprs)[inx]; + p1 = (s + iny * pprs)[inx + (inx < w ? 1 : 0)]; + p2 = (s + (iny + (iny < h ? 1 : 0)) * pprs)[inx + (inx < w ? 1 : 0)]; + p3 = (s + (iny + (iny < h ? 1 : 0)) * pprs)[inx]; + + *(++dl) = interpolate(mx, my, p0, p1, p2, p3); + } else { + p0 = (s + iny * pprs)[inx]; *(++dl) = p0; } - + ++sl; - } - else + } else *(++dl) = *(++sl); } - sl = s + row*pprs + lastCol; + sl = s + row * pprs + lastCol; for (col = lastCol + 1; col < w; col++) *(++dl) = *(++sl); - } for (row = lastRow + 1; row < h; row++) - memcpy (d + row*pprd, s + row*pprs, inLayer->BytesPerRow()); - + memcpy(d + row * pprd, s + row * pprs, inLayer->BytesPerRow()); + break; } - case M_SELECT: - { + case M_SELECT: { break; } default: - fprintf (stderr, "Ripple: Unknown mode\n"); + fprintf(stderr, "Ripple: Unknown mode\n"); error = ADDON_UNKNOWN; } diff --git a/source/add-ons/Scale/Scale.cpp b/source/add-ons/Scale/Scale.cpp index 65ef8da..e4dd6f3 100644 --- a/source/add-ons/Scale/Scale.cpp +++ b/source/add-ons/Scale/Scale.cpp @@ -5,42 +5,48 @@ #include #include -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Scale"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998-2001 ∑ Sum Software"); - strcpy (info->description, "Resize a selection of the canvas"); - info->type = BECASSO_TRANSFORMER; - info->index = index; - info->version = 1; - info->release = 1; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE | PREVIEW_MOUSE | LAYER_AND_SELECTION; - info->flags = 0; + strcpy(info->name, "Scale"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998-2001 ∑ Sum Software"); + strcpy(info->description, "Resize a selection of the canvas"); + info->type = BECASSO_TRANSFORMER; + info->index = index; + info->version = 1; + info->release = 1; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE | PREVIEW_MOUSE | LAYER_AND_SELECTION; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = NULL; // Scale has no GUI + *view = NULL; // Scale has no GUI return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect *frame, bool final, BPoint point, uint32 buttons) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* frame, bool final, BPoint point, uint32 buttons +) { // We don't use the StatusBar in the present incarnation of the Scale add-on, // because everything happens interactively and the final anti-aliased drawing @@ -49,104 +55,118 @@ status_t process (Layer *inLayer, Selection *inSelection, // a given BStatusBar object. static bool entry = false; - static BPoint firstpoint = BPoint (-1, -1); - static BPoint lastpoint = BPoint (-1, -1); - static Layer *oLayer = NULL; - static Selection *oSelection = NULL; + static BPoint firstpoint = BPoint(-1, -1); + static BPoint lastpoint = BPoint(-1, -1); + static Layer* oLayer = NULL; + static Selection* oSelection = NULL; static BRect oBounds = EmptyRect; static int varcorner = -1; static BRect newrect; int error = ADDON_OK; - - if (/*!inLayer || */!inSelection) - { - printf ("Scale only works with a valid selection ATM.\n"); + + if (/*!inLayer || */ !inSelection) { + printf("Scale only works with a valid selection ATM.\n"); return (error); } - - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = inLayer;//new Layer (*inLayer); + + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = inLayer; // new Layer (*inLayer); if (*outSelection == NULL) - *outSelection = inSelection;//new Selection (*inSelection); + *outSelection = inSelection; // new Selection (*inSelection); -// if (*outLayer) -// (*outLayer)->Lock(); -// if (*outSelection) -// (*outSelection)->Lock(); - - if (final) - { + // if (*outLayer) + // (*outLayer)->Lock(); + // if (*outSelection) + // (*outSelection)->Lock(); + + if (final) { // This means the user has clicked "Apply". // Set up our local cutout copies of the original layer and selection. // We still do this (although Becasso (as of 1.3) passes add-ons a "clean" // layer each time) because it saves us the work of cutting out the selected part. - -// firstpoint = point; + + // firstpoint = point; oBounds = *frame; BRect bounds = oBounds; // oBounds.PrintToStream(); - bounds.OffsetTo (B_ORIGIN); - oLayer = new Layer (bounds, "tmpLayer"); - oSelection = new Selection (bounds); - BView *view = new BView (bounds, "tmp view", 0, 0); + bounds.OffsetTo(B_ORIGIN); + oLayer = new Layer(bounds, "tmpLayer"); + oSelection = new Selection(bounds); + BView* view = new BView(bounds, "tmp view", 0, 0); oSelection->Lock(); - oSelection->AddChild (view); - view->DrawBitmap (inSelection, BPoint (-oBounds.left, -oBounds.top)); + oSelection->AddChild(view); + view->DrawBitmap(inSelection, BPoint(-oBounds.left, -oBounds.top)); view->Sync(); - oSelection->RemoveChild (view); + oSelection->RemoveChild(view); oSelection->Unlock(); entry = true; -// float dlt = ((frame->left - firstpoint.x)*(frame->left - firstpoint.x) + (frame->top - firstpoint.y)*(frame->top - firstpoint.y)); -// float drt = ((frame->right - firstpoint.x)*(frame->right - firstpoint.x) + (frame->top - firstpoint.y)*(frame->top - firstpoint.y)); -// float dlb = ((frame->left - firstpoint.x)*(frame->left - firstpoint.x) + (frame->bottom - firstpoint.y)*(frame->bottom - firstpoint.y)); -// float drb = ((frame->right - firstpoint.x)*(frame->right - firstpoint.x) + (frame->bottom - firstpoint.y)*(frame->bottom - firstpoint.y)); -// varcorner = 0; // LeftTop -// if (drt < dlt) varcorner = 1; // RightTop -// if (dlb < drt && dlb < dlt) varcorner = 2; // LeftBottom -// if (drb < dlb && drb < drt && drb < dlt) varcorner = 3; // RightBottom - printf ("Scale: final - setup done\n"); + // float dlt = ((frame->left - firstpoint.x)*(frame->left - firstpoint.x) + (frame->top + //- firstpoint.y)*(frame->top - firstpoint.y)); float drt = ((frame->right - + // firstpoint.x)*(frame->right - firstpoint.x) + (frame->top - firstpoint.y)*(frame->top - + // firstpoint.y)); float dlb = ((frame->left - firstpoint.x)*(frame->left - + // firstpoint.x) + (frame->bottom - firstpoint.y)*(frame->bottom - firstpoint.y)); + // float drb = ((frame->right + //- firstpoint.x)*(frame->right - firstpoint.x) + (frame->bottom - + // firstpoint.y)*(frame->bottom - firstpoint.y)); varcorner = 0; // LeftTop if + // (drt < dlt) varcorner = 1; // RightTop if (dlb < drt && dlb < dlt) varcorner = + // 2; // LeftBottom if (drb < dlb && drb < drt && drb < dlt) varcorner = 3; // + // RightBottom + printf("Scale: final - setup done\n"); } - - if (!final && buttons && !entry) // First entry of a realtime drag + + if (!final && buttons && !entry) // First entry of a realtime drag { // Set up our local cutout copies of the original layer and selection. // We still do this (although Becasso (as of 1.3) passes add-ons a "clean" // layer each time) because it saves us the work of cutting out the selected part. - + firstpoint = point; oBounds = *frame; BRect bounds = oBounds; // oBounds.PrintToStream(); - bounds.OffsetTo (B_ORIGIN); - oLayer = new Layer (bounds, "tmpLayer"); - oSelection = new Selection (bounds); - BView *view = new BView (bounds, "tmp view", 0, 0); + bounds.OffsetTo(B_ORIGIN); + oLayer = new Layer(bounds, "tmpLayer"); + oSelection = new Selection(bounds); + BView* view = new BView(bounds, "tmp view", 0, 0); oSelection->Lock(); - oSelection->AddChild (view); - view->DrawBitmap (inSelection, BPoint (-oBounds.left, -oBounds.top)); + oSelection->AddChild(view); + view->DrawBitmap(inSelection, BPoint(-oBounds.left, -oBounds.top)); view->Sync(); - oSelection->RemoveChild (view); + oSelection->RemoveChild(view); oSelection->Unlock(); - + entry = true; - float dlt = ((frame->left - firstpoint.x)*(frame->left - firstpoint.x) + (frame->top - firstpoint.y)*(frame->top - firstpoint.y)); - float drt = ((frame->right - firstpoint.x)*(frame->right - firstpoint.x) + (frame->top - firstpoint.y)*(frame->top - firstpoint.y)); - float dlb = ((frame->left - firstpoint.x)*(frame->left - firstpoint.x) + (frame->bottom - firstpoint.y)*(frame->bottom - firstpoint.y)); - float drb = ((frame->right - firstpoint.x)*(frame->right - firstpoint.x) + (frame->bottom - firstpoint.y)*(frame->bottom - firstpoint.y)); + float dlt = + ((frame->left - firstpoint.x) * (frame->left - firstpoint.x) + + (frame->top - firstpoint.y) * (frame->top - firstpoint.y)); + float drt = + ((frame->right - firstpoint.x) * (frame->right - firstpoint.x) + + (frame->top - firstpoint.y) * (frame->top - firstpoint.y)); + float dlb = + ((frame->left - firstpoint.x) * (frame->left - firstpoint.x) + + (frame->bottom - firstpoint.y) * (frame->bottom - firstpoint.y)); + float drb = + ((frame->right - firstpoint.x) * (frame->right - firstpoint.x) + + (frame->bottom - firstpoint.y) * (frame->bottom - firstpoint.y)); varcorner = 0; // LeftTop - if (drt < dlt) varcorner = 1; // RightTop - if (dlb < drt && dlb < dlt) varcorner = 2; // LeftBottom - if (drb < dlb && drb < drt && drb < dlt) varcorner = 3; // RightBottom + if (drt < dlt) + varcorner = 1; // RightTop + if (dlb < drt && dlb < dlt) + varcorner = 2; // LeftBottom + if (drb < dlb && drb < drt && drb < dlt) + varcorner = 3; // RightBottom } if (buttons) lastpoint = point; - if (mode == M_DRAW) - { + if (mode == M_DRAW) { oLayer->Lock(); inLayer->Lock(); inSelection->Lock(); - CutOrCopy (*outLayer ? *outLayer : inLayer, oLayer, inSelection, int (oBounds.left), int (oBounds.top), true); + CutOrCopy( + *outLayer ? *outLayer : inLayer, oLayer, inSelection, int(oBounds.left), + int(oBounds.top), true + ); inSelection->Unlock(); inLayer->Unlock(); oLayer->Unlock(); @@ -155,10 +175,9 @@ status_t process (Layer *inLayer, Selection *inSelection, BRect lframe = *frame; newrect = lframe; BRect bounds = lframe; - bounds.OffsetTo (B_ORIGIN); -// lastpoint = point; - switch (varcorner) - { + bounds.OffsetTo(B_ORIGIN); + // lastpoint = point; + switch (varcorner) { case 0: newrect.left = lastpoint.x; newrect.top = lastpoint.y; @@ -177,63 +196,62 @@ status_t process (Layer *inLayer, Selection *inSelection, } if (newrect.right <= newrect.left || newrect.bottom <= newrect.top) return (0); - + rgb_color hi = highcolor(); rgb_color lo = lowcolor(); - + if (*outLayer) (*outLayer)->Lock(); if (*outSelection) (*outSelection)->Lock(); - switch (mode) - { - case M_DRAW: - { - if (*outLayer && buttons) // The user is dragging. + switch (mode) { + case M_DRAW: { + if (*outLayer && buttons) // The user is dragging. { - printf ("Dragging\n"); + printf("Dragging\n"); BRect newbounds = newrect; - newbounds.OffsetTo (B_ORIGIN); - Layer *sLayer = new Layer (newbounds, "Scaled Layer"); - BView *view = new BView (newbounds, "tmp view", 0, 0); - view->SetHighColor (contrastingcolor (lo, hi)); + newbounds.OffsetTo(B_ORIGIN); + Layer* sLayer = new Layer(newbounds, "Scaled Layer"); + BView* view = new BView(newbounds, "tmp view", 0, 0); + view->SetHighColor(contrastingcolor(lo, hi)); sLayer->Lock(); - sLayer->AddChild (view); - view->DrawBitmap (oLayer, oLayer->Bounds(), newbounds); - view->StrokeRect (newbounds); + sLayer->AddChild(view); + view->DrawBitmap(oLayer, oLayer->Bounds(), newbounds); + view->StrokeRect(newbounds); view->Sync(); - sLayer->RemoveChild (view); + sLayer->RemoveChild(view); delete view; - AddWithAlpha (sLayer, (*outLayer), int (newrect.left), int (newrect.top)); + AddWithAlpha(sLayer, (*outLayer), int(newrect.left), int(newrect.top)); delete sLayer; - } - else if (entry) // The user has released the mouse. Clean up. + } else if (entry) // The user has released the mouse. Clean up. // N.B. We also get here when "Apply" is clicked. { - printf ("Clean up\n"); - firstpoint = BPoint (-1, -1); + printf("Clean up\n"); + firstpoint = BPoint(-1, -1); BRect newbounds = newrect; - newbounds.OffsetTo (B_ORIGIN); + newbounds.OffsetTo(B_ORIGIN); // newrect.PrintToStream(); - BView *view = new BView (inLayer->Bounds(), "tmp view", 0, 0); - Layer *sLayer = new Layer (newbounds, "Scaled Layer"); - Selection *sSelection = new Selection (newbounds); - Scale (oLayer, oSelection, sLayer, sSelection); - AddWithAlpha (sLayer, (*outLayer) ? (*outLayer) : inLayer, int (newrect.left), int (newrect.top)); + BView* view = new BView(inLayer->Bounds(), "tmp view", 0, 0); + Layer* sLayer = new Layer(newbounds, "Scaled Layer"); + Selection* sSelection = new Selection(newbounds); + Scale(oLayer, oSelection, sLayer, sSelection); + AddWithAlpha( + sLayer, (*outLayer) ? (*outLayer) : inLayer, int(newrect.left), int(newrect.top) + ); if (*outSelection) - (*outSelection)->AddChild (view); + (*outSelection)->AddChild(view); else - inSelection->AddChild (view); + inSelection->AddChild(view); - view->SetLowColor (SELECT_NONE); - view->FillRect (inLayer->Bounds(), B_SOLID_LOW); - view->DrawBitmap (sSelection, newrect.LeftTop()); + view->SetLowColor(SELECT_NONE); + view->FillRect(inLayer->Bounds(), B_SOLID_LOW); + view->DrawBitmap(sSelection, newrect.LeftTop()); view->Sync(); if (*outSelection) - (*outSelection)->RemoveChild (view); + (*outSelection)->RemoveChild(view); else - inSelection->RemoveChild (view); + inSelection->RemoveChild(view); delete view; delete sLayer; delete sSelection; @@ -245,43 +263,41 @@ status_t process (Layer *inLayer, Selection *inSelection, } break; } - case M_SELECT: - { - if (*outSelection && buttons) // The user is dragging. + case M_SELECT: { + if (*outSelection && buttons) // The user is dragging. { BRect newbounds = newrect; - newbounds.OffsetTo (B_ORIGIN); - BView *view = new BView (inSelection->Bounds(), "tmp view", 0, 0); - (*outSelection)->AddChild (view); - view->SetLowColor (SELECT_NONE); - view->FillRect (inLayer->Bounds(), B_SOLID_LOW); - view->DrawBitmapAsync (oSelection, oSelection->Bounds(), newrect); + newbounds.OffsetTo(B_ORIGIN); + BView* view = new BView(inSelection->Bounds(), "tmp view", 0, 0); + (*outSelection)->AddChild(view); + view->SetLowColor(SELECT_NONE); + view->FillRect(inLayer->Bounds(), B_SOLID_LOW); + view->DrawBitmapAsync(oSelection, oSelection->Bounds(), newrect); view->Sync(); - (*outSelection)->RemoveChild (view); + (*outSelection)->RemoveChild(view); delete view; - } - else if (entry) // The user has released the mouse. Clean up. + } else if (entry) // The user has released the mouse. Clean up. // N.B. We also get here when "Apply" is clicked. { - firstpoint = BPoint (-1, -1); + firstpoint = BPoint(-1, -1); BRect newbounds = newrect; - newbounds.OffsetTo (B_ORIGIN); + newbounds.OffsetTo(B_ORIGIN); // newrect.PrintToStream(); - BView *view = new BView (inLayer->Bounds(), "tmp view", 0, 0); - Selection *sSelection = new Selection (newbounds); - Scale (NULL, oSelection, NULL, sSelection); + BView* view = new BView(inLayer->Bounds(), "tmp view", 0, 0); + Selection* sSelection = new Selection(newbounds); + Scale(NULL, oSelection, NULL, sSelection); if (*outSelection) - (*outSelection)->AddChild (view); + (*outSelection)->AddChild(view); else - inSelection->AddChild (view); - view->SetLowColor (SELECT_NONE); - view->FillRect (inLayer->Bounds(), B_SOLID_LOW); - view->DrawBitmap (sSelection, newrect.LeftTop()); + inSelection->AddChild(view); + view->SetLowColor(SELECT_NONE); + view->FillRect(inLayer->Bounds(), B_SOLID_LOW); + view->DrawBitmap(sSelection, newrect.LeftTop()); view->Sync(); if (*outSelection) - (*outSelection)->RemoveChild (view); + (*outSelection)->RemoveChild(view); else - inSelection->RemoveChild (view); + inSelection->RemoveChild(view); delete view; delete sSelection; entry = false; @@ -293,7 +309,7 @@ status_t process (Layer *inLayer, Selection *inSelection, break; } default: - fprintf (stderr, "Scale: Unknown mode\n"); + fprintf(stderr, "Scale: Unknown mode\n"); error = 1; } diff --git a/source/add-ons/Sepia/Sepia.cpp b/source/add-ons/Sepia/Sepia.cpp index 7cdbf58..c64c1ad 100644 --- a/source/add-ons/Sepia/Sepia.cpp +++ b/source/add-ons/Sepia/Sepia.cpp @@ -7,138 +7,146 @@ #include #include -rgb_color gFg; -rgb_color gBg; -int gMode; +rgb_color gFg; +rgb_color gBg; +int gMode; -#define DUO_BW 0 -#define DUO_SEPIA 1 -#define DUO_FB 2 +#define DUO_BW 0 +#define DUO_SEPIA 1 +#define DUO_FB 2 class SepiaView : public BView { -public: - SepiaView (BRect rect); -virtual ~SepiaView () {}; + public: + SepiaView(BRect rect); + virtual ~SepiaView(){}; -virtual void MessageReceived (BMessage *msg); + virtual void MessageReceived(BMessage* msg); }; -SepiaView::SepiaView (BRect rect) -: BView (rect, "sepia_view", B_FOLLOW_ALL, B_WILL_DRAW) +SepiaView::SepiaView(BRect rect) : BView(rect, "sepia_view", B_FOLLOW_ALL, B_WILL_DRAW) { - ResizeTo (188, 80); - - BBox *mode = new BBox (BRect (8, 4, 180, 78), "mode"); - mode->SetLabel ("Colors"); - AddChild (mode); - - BRadioButton *rbBW = new BRadioButton (BRect (4, 14, 170, 30), "bw", "Black/White", new BMessage ('clBW')); - BRadioButton *rbSP = new BRadioButton (BRect (4, 32, 170, 48), "sepia", "Sepia", new BMessage ('clSP')); - BRadioButton *rbFB = new BRadioButton (BRect (4, 50, 170, 66), "fg", "Foreground/Background", new BMessage ('clFB')); - mode->AddChild (rbBW); - mode->AddChild (rbSP); - mode->AddChild (rbFB); - - rbBW->SetValue (true); + ResizeTo(188, 80); + + BBox* mode = new BBox(BRect(8, 4, 180, 78), "mode"); + mode->SetLabel("Colors"); + AddChild(mode); + + BRadioButton* rbBW = + new BRadioButton(BRect(4, 14, 170, 30), "bw", "Black/White", new BMessage('clBW')); + BRadioButton* rbSP = + new BRadioButton(BRect(4, 32, 170, 48), "sepia", "Sepia", new BMessage('clSP')); + BRadioButton* rbFB = new BRadioButton( + BRect(4, 50, 170, 66), "fg", "Foreground/Background", new BMessage('clFB') + ); + mode->AddChild(rbBW); + mode->AddChild(rbSP); + mode->AddChild(rbFB); + + rbBW->SetValue(true); gFg.red = gFg.green = gFg.blue = 0; gBg.red = gBg.green = gBg.blue = 255; gMode = DUO_BW; } -void SepiaView::MessageReceived (BMessage *msg) +void +SepiaView::MessageReceived(BMessage* msg) { - switch (msg->what) - { - case 'clBW': - gFg.red = gFg.green = gFg.blue = 0; - gBg.red = gBg.green = gBg.blue = 255; - gMode = DUO_BW; - break; - - case 'clSP': - gFg.red = 50; - gFg.green = 5; - gFg.blue = 8; // brown - gBg.red = 255; - gBg.green = 255; - gBg.blue = 245; // yellowish - gMode = DUO_SEPIA; - break; - - case 'clFB': - gFg = highcolor(); - gBg = lowcolor(); - gMode = DUO_FB; - break; - - default: - BView::MessageReceived (msg); - return; + switch (msg->what) { + case 'clBW': + gFg.red = gFg.green = gFg.blue = 0; + gBg.red = gBg.green = gBg.blue = 255; + gMode = DUO_BW; + break; + + case 'clSP': + gFg.red = 50; + gFg.green = 5; + gFg.blue = 8; // brown + gBg.red = 255; + gBg.green = 255; + gBg.blue = 245; // yellowish + gMode = DUO_SEPIA; + break; + + case 'clFB': + gFg = highcolor(); + gBg = lowcolor(); + gMode = DUO_FB; + break; + + default: + BView::MessageReceived(msg); + return; } addon_preview(); } #define NEW_WEIGHTS 1 -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "DuoTone"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 2000-2001 ∑ Sum Software"); - strcpy (info->description, "Maps pixel intensities to a background-foreground color scale"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 0; - info->release = 2; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = LAYER_ONLY; + strcpy(info->name, "DuoTone"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 2000-2001 ∑ Sum Software"); + strcpy(info->description, "Maps pixel intensities to a background-foreground color scale"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 0; + info->release = 2; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = LAYER_ONLY; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new SepiaView (rect); + *view = new SepiaView(rect); return B_OK; } -void addon_color_changed (void) +void +addon_color_changed(void) { - if (gMode == DUO_FB) - { + if (gMode == DUO_FB) { gFg = highcolor(); gBg = lowcolor(); } } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); -// printf ("Bounds: "); -// bounds.PrintToStream(); -// printf ("Frame: "); -// frame->PrintToStream(); - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + // printf ("Bounds: "); + // bounds.PrintToStream(); + // printf ("Frame: "); + // frame->PrintToStream(); + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); + *outSelection = new Selection(*inSelection); else return (0); } @@ -148,75 +156,65 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits(); - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits(); + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - - float delta = 100.0/h; // For the Status Bar. - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits() - 1; - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits() - 1; + + float delta = 100.0 / h; // For the Status Bar. + + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits() - 1; + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits() - 1; rgb_color fc = gFg; rgb_color lc = gBg; - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { grey_pixel mp = inSelection ? *(++mapbits) : 255; - if (mp) - { + if (mp) { bgra_pixel p = *(++sbits); - #if defined (NEW_WEIGHTS) - float g = (0.213*RED(p) + 0.715*GREEN(p) + 0.072*BLUE(p))/255.0; - #else - float g = (0.299*RED(p) + 0.587*GREEN(p) + 0.114*BLUE(p))/255.0; - #endif - bgra_pixel gp = PIXEL (g*lc.red + (1 - g)*fc.red, - g*lc.green + (1 - g)*fc.green, - g*lc.blue + (1 - g)*fc.blue, - ALPHA(p)); +#if defined(NEW_WEIGHTS) + float g = (0.213 * RED(p) + 0.715 * GREEN(p) + 0.072 * BLUE(p)) / 255.0; +#else + float g = (0.299 * RED(p) + 0.587 * GREEN(p) + 0.114 * BLUE(p)) / 255.0; +#endif + bgra_pixel gp = PIXEL( + g * lc.red + (1 - g) * fc.red, g * lc.green + (1 - g) * fc.green, + g * lc.blue + (1 - g) * fc.blue, ALPHA(p) + ); if (mp == 255) *(++dbits) = gp; else - *(++dbits) = weighted_average (gp, mp, p, 255 - mp); - } - else + *(++dbits) = weighted_average(gp, mp, p, 255 - mp); + } else *(++dbits) = *(++sbits); } mapbits += mdiff; } break; } - case M_SELECT: - { + case M_SELECT: { // does not make sense to do sepia on a selection break; } default: - fprintf (stderr, "Sepia: Unknown mode\n"); + fprintf(stderr, "Sepia: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -224,7 +222,7 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); - + if (final) addon_done(); diff --git a/source/add-ons/Solarize/Solarize.cpp b/source/add-ons/Solarize/Solarize.cpp index 6729567..468edc8 100644 --- a/source/add-ons/Solarize/Solarize.cpp +++ b/source/add-ons/Solarize/Solarize.cpp @@ -6,86 +6,93 @@ #include "Slider.h" #include -float gThreshold; +float gThreshold; class SolarizeView : public BView { -public: - SolarizeView (BRect rect) : BView (rect, "solarize view", B_FOLLOW_ALL, B_WILL_DRAW) - { - gThreshold = 0; - ResizeTo (188, 26); - Slider *thresholdS = new Slider (BRect (4, 4, 184, 22), 64, "Threshold", 0, 100, 1, new BMessage ('thrS')); - AddChild (thresholdS); - } -virtual ~SolarizeView () {} - -virtual void MessageReceived (BMessage *msg); + public: + SolarizeView(BRect rect) : BView(rect, "solarize view", B_FOLLOW_ALL, B_WILL_DRAW) + { + gThreshold = 0; + ResizeTo(188, 26); + Slider* thresholdS = + new Slider(BRect(4, 4, 184, 22), 64, "Threshold", 0, 100, 1, new BMessage('thrS')); + AddChild(thresholdS); + } + + virtual ~SolarizeView() {} + + virtual void MessageReceived(BMessage* msg); }; -void SolarizeView::MessageReceived (BMessage *msg) +void +SolarizeView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'thrS': - gThreshold = msg->FindFloat ("value"); + gThreshold = msg->FindFloat("value"); addon_preview(); break; default: - BView::MessageReceived (msg); + BView::MessageReceived(msg); } } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Solarize"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1999-2001 ∑ Sum Software"); - strcpy (info->description, "Simulates over-exposure"); - info->type = BECASSO_FILTER; - info->index = index; - info->version = 0; - info->release = 1; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "Solarize"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1999-2001 ∑ Sum Software"); + strcpy(info->description, "Simulates over-exposure"); + info->type = BECASSO_FILTER; + info->index = index; + info->version = 0; + info->release = 1; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new SolarizeView (rect); + *view = new SolarizeView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect * /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* /*frame*/, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; BRect bounds = inLayer->Bounds(); -// printf ("Bounds: "); -// bounds.PrintToStream(); -// printf ("Frame: "); -// frame->PrintToStream(); - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + // printf ("Bounds: "); + // bounds.PrintToStream(); + // printf ("Frame: "); + // frame->PrintToStream(); + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to blur! + *outSelection = new Selection(*inSelection); + else // No Selection to blur! return (0); } if (*outLayer) @@ -94,70 +101,60 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Lock(); uint32 h = bounds.IntegerHeight() + 1; uint32 w = bounds.IntegerWidth() + 1; - grey_pixel *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - if (inSelection) - { - mapbits = (grey_pixel *) inSelection->Bits(); - mbpr = inSelection->BytesPerRow(); + grey_pixel* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + if (inSelection) { + mapbits = (grey_pixel*)inSelection->Bits(); + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; } if (final) addon_start(); - float delta = 100.0/h; // For the Status Bar. - float threshold = gThreshold/25500; - - switch (mode) - { - case M_DRAW: - { - bgra_pixel *sbits = (bgra_pixel *) inLayer->Bits(); - bgra_pixel *dbits = (bgra_pixel *) (*outLayer)->Bits(); - - for (uint32 y = 0; y < h; y++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + float delta = 100.0 / h; // For the Status Bar. + float threshold = gThreshold / 25500; + + switch (mode) { + case M_DRAW: { + bgra_pixel* sbits = (bgra_pixel*)inLayer->Bits(); + bgra_pixel* dbits = (bgra_pixel*)(*outLayer)->Bits(); + + for (uint32 y = 0; y < h; y++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - for (uint32 x = 0; x < w; x++) - { + for (uint32 x = 0; x < w; x++) { grey_pixel mp = inSelection ? *(++mapbits) : 255; - if (mp) - { + if (mp) { bgra_pixel p = *(++sbits); uchar red = RED(p); uchar green = GREEN(p); uchar blue = BLUE(p); uchar alpha = ALPHA(p); - float intensity = 0.0008333*red + 0.0028055*green + 0.00028275*blue; - if (intensity >= threshold*mp) - *(++dbits) = PIXEL (255 - red, 255 - green, 255 - blue, alpha); + float intensity = 0.0008333 * red + 0.0028055 * green + 0.00028275 * blue; + if (intensity >= threshold * mp) + *(++dbits) = PIXEL(255 - red, 255 - green, 255 - blue, alpha); else *(++dbits) = p; - } - else + } else *(++dbits) = *(++sbits); } mapbits += mdiff; } break; } - case M_SELECT: - { + case M_SELECT: { // no sense to solarize the selection map break; } default: - fprintf (stderr, "Negate: Unknown mode\n"); + fprintf(stderr, "Negate: Unknown mode\n"); error = ADDON_UNKNOWN; } @@ -165,7 +162,7 @@ status_t process (Layer *inLayer, Selection *inSelection, (*outSelection)->Unlock(); if (*outLayer) (*outLayer)->Unlock(); - + if (final) addon_done(); diff --git a/source/add-ons/Tile/Tile.cpp b/source/add-ons/Tile/Tile.cpp index a7cd4a4..62013a2 100644 --- a/source/add-ons/Tile/Tile.cpp +++ b/source/add-ons/Tile/Tile.cpp @@ -18,418 +18,420 @@ class TileView : public BView { -public: - TileView (BRect frame, BBitmap *bitmap); -virtual ~TileView () { delete fBitmap; }; -virtual void SetBitmap (BBitmap *bitmap) { delete fBitmap; fBitmap = bitmap; Invalidate(); }; -virtual void Draw (BRect update); -virtual void KeyDown (const char *bytes, int32 numbytes); -BBitmap *Bitmap () { return fBitmap; }; - -private: -typedef BView inherited; -BBitmap *fBitmap; + public: + TileView(BRect frame, BBitmap* bitmap); + + virtual ~TileView() { delete fBitmap; }; + + virtual void SetBitmap(BBitmap* bitmap) + { + delete fBitmap; + fBitmap = bitmap; + Invalidate(); + }; + + virtual void Draw(BRect update); + virtual void KeyDown(const char* bytes, int32 numbytes); + + BBitmap* Bitmap() { return fBitmap; }; + + private: + typedef BView inherited; + BBitmap* fBitmap; }; -TileView::TileView (BRect frame, BBitmap *bitmap) -: BView (frame, "tileview", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) +TileView::TileView(BRect frame, BBitmap* bitmap) + : BView(frame, "tileview", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) { fBitmap = bitmap; } -void TileView::Draw (BRect update) +void +TileView::Draw(BRect update) { - SetLowColor (DarkGrey); + SetLowColor(DarkGrey); - if (fBitmap) - { + if (fBitmap) { int xs = fBitmap->Bounds().IntegerWidth(); int ys = fBitmap->Bounds().IntegerHeight(); - for (int x = 0; x < Bounds().Width()/xs; x++) - for (int y = 0; y < Bounds().Height()/ys; y++) - DrawBitmapAsync (fBitmap, BPoint (x*xs, y*ys)); - } - else - FillRect (update, B_SOLID_LOW); + for (int x = 0; x < Bounds().Width() / xs; x++) + for (int y = 0; y < Bounds().Height() / ys; y++) + DrawBitmapAsync(fBitmap, BPoint(x * xs, y * ys)); + } else + FillRect(update, B_SOLID_LOW); Sync(); } -void TileView::KeyDown (const char *bytes, int32 numbytes) +void +TileView::KeyDown(const char* bytes, int32 numbytes) { - if (numbytes == 1) - { - if (bytes[0] == B_LEFT_ARROW) - { - BMessage msg ('Til-'); + if (numbytes == 1) { + if (bytes[0] == B_LEFT_ARROW) { + BMessage msg('Til-'); LockLooper(); - Window()->PostMessage (&msg); + Window()->PostMessage(&msg); UnlockLooper(); - } - else if (bytes[0] == B_RIGHT_ARROW) - { - BMessage msg ('Til+'); + } else if (bytes[0] == B_RIGHT_ARROW) { + BMessage msg('Til+'); LockLooper(); - Window()->PostMessage (&msg); + Window()->PostMessage(&msg); UnlockLooper(); - } - else - inherited::KeyDown (bytes, numbytes); - } - else - inherited::KeyDown (bytes, numbytes); + } else + inherited::KeyDown(bytes, numbytes); + } else + inherited::KeyDown(bytes, numbytes); } class TileMainView : public BView { -public: - TileMainView (BRect rect); -virtual ~TileMainView () {} -virtual void MessageReceived (BMessage *msg); + public: + TileMainView(BRect rect); + + virtual ~TileMainView() {} + + virtual void MessageReceived(BMessage* msg); }; class TilesList; -TileView *view; -node_ref tilesRef; -BList *tilesDirList; -TilesList *CurrentTilesEntries; -int32 current_index; -BButton *next, *prev; -BStringView *text; -BPopUpMenu *catalogPU; +TileView* view; +node_ref tilesRef; +BList* tilesDirList; +TilesList* CurrentTilesEntries; +int32 current_index; +BButton *next, *prev; +BStringView* text; +BPopUpMenu* catalogPU; - -TileMainView::TileMainView (BRect rect) -: BView (rect, "tile main view", B_FOLLOW_ALL, B_WILL_DRAW) +TileMainView::TileMainView(BRect rect) : BView(rect, "tile main view", B_FOLLOW_ALL, B_WILL_DRAW) { - ResizeTo (188, 164); + ResizeTo(188, 164); app_info ainfo; - be_app->GetAppInfo (&ainfo); - BEntry appEntry = BEntry (&ainfo.ref); + be_app->GetAppInfo(&ainfo); + BEntry appEntry = BEntry(&ainfo.ref); BEntry appDir; BPath appPath; - appEntry.GetParent (&appDir); - appDir.GetPath (&appPath); + appEntry.GetParent(&appDir); + appDir.GetPath(&appPath); char dirname[B_FILE_NAME_LENGTH]; - strcpy (dirname, appPath.Path()); + strcpy(dirname, appPath.Path()); BDirectory tilesDir; - tilesDir.SetTo (strcat (dirname, "/Tiles")); - tilesDir.GetNodeRef (&tilesRef); + tilesDir.SetTo(strcat(dirname, "/Tiles")); + tilesDir.GetNodeRef(&tilesRef); tilesDirList = new BList(); - catalogPU = new BPopUpMenu ("Catalog"); - BMenuField *catalogMenu = new BMenuField (BRect (8, 4, 180, 30), "catalog", "Catalog:", catalogPU); - catalogMenu->SetDivider (50); - AddChild (catalogMenu); - view = new TileView (BRect (8, 32, 120, 144), NULL); - AddChild (view); - prev = new BButton (BRect (128, 32, 150, 52), "prev", "<", new BMessage ('Til-')); - next = new BButton (BRect (158, 32, 180, 52), "next", ">", new BMessage ('Til+')); - AddChild (prev); - AddChild (next); - text = new BStringView (BRect (8, 146, 180, 160), "title", "(no tile)"); - AddChild (text); + catalogPU = new BPopUpMenu("Catalog"); + BMenuField* catalogMenu = + new BMenuField(BRect(8, 4, 180, 30), "catalog", "Catalog:", catalogPU); + catalogMenu->SetDivider(50); + AddChild(catalogMenu); + view = new TileView(BRect(8, 32, 120, 144), NULL); + AddChild(view); + prev = new BButton(BRect(128, 32, 150, 52), "prev", "<", new BMessage('Til-')); + next = new BButton(BRect(158, 32, 180, 52), "next", ">", new BMessage('Til+')); + AddChild(prev); + AddChild(next); + text = new BStringView(BRect(8, 146, 180, 160), "title", "(no tile)"); + AddChild(text); } class TilesList { -public: - TilesList () { fIndex = 0; } -virtual ~TilesList () {} -virtual void AddItem (BEntry entry) - { - if (fIndex < 4096) - { - entry.GetRef (&(entries[fIndex++])); - } - else - fprintf (stderr, "TilesList: Too many tiles\n"); - } -virtual BEntry ItemAt (int32 index) // NB No error checking here... - { - BEntry entry; - entry.SetTo (&entries[index], true); - return entry; - } -virtual int32 CountItems () { return fIndex; }; -virtual void Reset () { fIndex = 0; }; - -private: -entry_ref entries[4096]; -int32 fIndex; + public: + TilesList() { fIndex = 0; } + + virtual ~TilesList() {} + + virtual void AddItem(BEntry entry) + { + if (fIndex < 4096) { + entry.GetRef(&(entries[fIndex++])); + } else + fprintf(stderr, "TilesList: Too many tiles\n"); + } + + virtual BEntry ItemAt(int32 index) // NB No error checking here... + { + BEntry entry; + entry.SetTo(&entries[index], true); + return entry; + } + + virtual int32 CountItems() { return fIndex; }; + + virtual void Reset() { fIndex = 0; }; + + private: + entry_ref entries[4096]; + int32 fIndex; }; class TilesDir { -public: - TilesDir () - { - fTilesList = new TilesList(); - }; - ~TilesDir () - { - delete fTilesList; - }; -entry_ref fDir; -TilesList *fTilesList; -}; + public: + TilesDir() { fTilesList = new TilesList(); }; + ~TilesDir() { delete fTilesList; }; -void TileMainView::MessageReceived (BMessage *msg) + entry_ref fDir; + TilesList* fTilesList; +}; + +void +TileMainView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'Til-': - if (current_index > 0) - { + if (current_index > 0) { char title[B_FILE_NAME_LENGTH]; char name[B_FILE_NAME_LENGTH]; - BEntry entry = CurrentTilesEntries->ItemAt (--current_index); - view->SetBitmap (entry2bitmap (entry)); - entry.GetName (name); + BEntry entry = CurrentTilesEntries->ItemAt(--current_index); + view->SetBitmap(entry2bitmap(entry)); + entry.GetName(name); if (view->Bitmap()) - sprintf (title, "%s (%i x %i)", name, int (view->Bitmap()->Bounds().Height() + 1), int (view->Bitmap()->Bounds().Width() + 1)); + sprintf( + title, "%s (%i x %i)", name, int(view->Bitmap()->Bounds().Height() + 1), + int(view->Bitmap()->Bounds().Width() + 1) + ); else - sprintf (title, "No handler for %s", name); - text->SetText (title); - next->SetEnabled (true); + sprintf(title, "No handler for %s", name); + text->SetText(title); + next->SetEnabled(true); } if (current_index) - prev->SetEnabled (true); + prev->SetEnabled(true); else - prev->SetEnabled (false); + prev->SetEnabled(false); break; case 'Til+': - if (current_index < CurrentTilesEntries->CountItems() - 1) - { + if (current_index < CurrentTilesEntries->CountItems() - 1) { char title[B_FILE_NAME_LENGTH]; char name[B_FILE_NAME_LENGTH]; - BEntry entry = CurrentTilesEntries->ItemAt (++current_index); - view->SetBitmap (entry2bitmap (entry)); - entry.GetName (name); + BEntry entry = CurrentTilesEntries->ItemAt(++current_index); + view->SetBitmap(entry2bitmap(entry)); + entry.GetName(name); if (view->Bitmap()) - sprintf (title, "%s (%i x %i)", name, int (view->Bitmap()->Bounds().Height() + 1), int (view->Bitmap()->Bounds().Width() + 1)); + sprintf( + title, "%s (%i x %i)", name, int(view->Bitmap()->Bounds().Height() + 1), + int(view->Bitmap()->Bounds().Width() + 1) + ); else - sprintf (title, "No handler for %s", name); - text->SetText (title); - prev->SetEnabled (true); + sprintf(title, "No handler for %s", name); + text->SetText(title); + prev->SetEnabled(true); } if (current_index < CurrentTilesEntries->CountItems() - 1) - next->SetEnabled (true); + next->SetEnabled(true); else - next->SetEnabled (false); + next->SetEnabled(false); break; - case 'TilS': - { - int index = catalogPU->IndexOf (catalogPU->FindMarked()); -// printf ("New catalog: %d\n", index); - CurrentTilesEntries = (TilesList *) ((TilesDir *) tilesDirList->ItemAt (index))->fTilesList; + case 'TilS': { + int index = catalogPU->IndexOf(catalogPU->FindMarked()); + // printf ("New catalog: %d\n", index); + CurrentTilesEntries = (TilesList*)((TilesDir*)tilesDirList->ItemAt(index))->fTilesList; current_index = 0; LockLooper(); view->MakeFocus(); - if (CurrentTilesEntries->CountItems()) - { - view->SetBitmap (entry2bitmap (CurrentTilesEntries->ItemAt (0))); + if (CurrentTilesEntries->CountItems()) { + view->SetBitmap(entry2bitmap(CurrentTilesEntries->ItemAt(0))); char title[B_FILE_NAME_LENGTH]; char name[B_FILE_NAME_LENGTH]; - CurrentTilesEntries->ItemAt(0).GetName (name); + CurrentTilesEntries->ItemAt(0).GetName(name); if (view->Bitmap()) - sprintf (title, "%s (%i x %i)", name, int (view->Bitmap()->Bounds().Height() + 1), int (view->Bitmap()->Bounds().Width() + 1)); + sprintf( + title, "%s (%i x %i)", name, int(view->Bitmap()->Bounds().Height() + 1), + int(view->Bitmap()->Bounds().Width() + 1) + ); else - sprintf (title, "No handler for %s", name); - text->SetText (title); - prev->SetEnabled (true); - next->SetEnabled (true); + sprintf(title, "No handler for %s", name); + text->SetText(title); + prev->SetEnabled(true); + next->SetEnabled(true); } if (current_index == 0) - prev->SetEnabled (false); + prev->SetEnabled(false); if (current_index == CurrentTilesEntries->CountItems() - 1) - next->SetEnabled (false); + next->SetEnabled(false); UnlockLooper(); break; } default: - BView::MessageReceived (msg); + BView::MessageReceived(msg); return; } addon_preview(); } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Tile"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998-2001 ∑ Sum Software"); - strcpy (info->description, "Tile the selection with a texture"); - info->type = BECASSO_GENERATOR; - info->index = index; - info->version = 1; - info->release = 3; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = 0; - info->flags = LAYER_ONLY; + strcpy(info->name, "Tile"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998-2001 ∑ Sum Software"); + strcpy(info->description, "Tile the selection with a texture"); + info->type = BECASSO_GENERATOR; + info->index = index; + info->version = 1; + info->release = 3; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = 0; + info->flags = LAYER_ONLY; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { - TilesDir *adir; - for (uint32 i = 0; (adir = (TilesDir *) tilesDirList->ItemAt (i), adir); i++) + TilesDir* adir; + for (uint32 i = 0; (adir = (TilesDir*)tilesDirList->ItemAt(i), adir); i++) delete adir; delete tilesDirList; return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **vw, BRect rect) +status_t +addon_make_config(BView** vw, BRect rect) { - *vw = new TileMainView (rect); + *vw = new TileMainView(rect); tilesDirList->MakeEmpty(); for (int i = catalogPU->CountItems(); i >= 0; i--) - delete (catalogPU->RemoveItem (i)); - //tilesEntries.Reset(); + delete (catalogPU->RemoveItem(i)); + // tilesEntries.Reset(); BEntry tilefile; BDirectory tilesDir; - tilesDir.SetTo (&tilesRef); + tilesDir.SetTo(&tilesRef); tilesDir.Rewind(); - while (tilesDir.GetNextEntry (&tilefile) != ENOENT) - { + while (tilesDir.GetNextEntry(&tilefile) != ENOENT) { BDirectory subdir; - if (subdir.SetTo (&tilefile) == B_OK) - { + if (subdir.SetTo(&tilefile) == B_OK) { BPath path; - tilefile.GetPath (&path); - catalogPU->AddItem (new BMenuItem (path.Leaf(), new BMessage ('TilS'))); -// printf ("Dir: %s\n", path.Leaf()); + tilefile.GetPath(&path); + catalogPU->AddItem(new BMenuItem(path.Leaf(), new BMessage('TilS'))); + // printf ("Dir: %s\n", path.Leaf()); subdir.Rewind(); - TilesDir *tilesdir = new TilesDir(); + TilesDir* tilesdir = new TilesDir(); BEntry dirent; - subdir.GetEntry (&dirent); - dirent.GetRef (&(tilesdir->fDir)); + subdir.GetEntry(&dirent); + dirent.GetRef(&(tilesdir->fDir)); BEntry tile; - while (subdir.GetNextEntry (&tile) != ENOENT) - { -// BPath tilepath; -// tile.GetPath (&tilepath); -// printf (" %s\n", tilepath.Leaf()); - tilesdir->fTilesList->AddItem (tile); + while (subdir.GetNextEntry(&tile) != ENOENT) { + // BPath tilepath; + // tile.GetPath (&tilepath); + // printf (" %s\n", tilepath.Leaf()); + tilesdir->fTilesList->AddItem(tile); } - tilesDirList->AddItem (tilesdir); + tilesDirList->AddItem(tilesdir); } // It wasn't a directory. Continue. } - BMenuItem *firstitem = catalogPU->ItemAt (0); + BMenuItem* firstitem = catalogPU->ItemAt(0); if (firstitem) - firstitem->SetMarked (true); - CurrentTilesEntries = (TilesList *) ((TilesDir *) tilesDirList->ItemAt(0))->fTilesList; - if (CurrentTilesEntries->CountItems()) - { - view->SetBitmap (entry2bitmap (CurrentTilesEntries->ItemAt (0))); + firstitem->SetMarked(true); + CurrentTilesEntries = (TilesList*)((TilesDir*)tilesDirList->ItemAt(0))->fTilesList; + if (CurrentTilesEntries->CountItems()) { + view->SetBitmap(entry2bitmap(CurrentTilesEntries->ItemAt(0))); char title[B_FILE_NAME_LENGTH]; char name[B_FILE_NAME_LENGTH]; - CurrentTilesEntries->ItemAt(0).GetName (name); + CurrentTilesEntries->ItemAt(0).GetName(name); if (view->Bitmap()) - sprintf (title, "%s (%i x %i)", name, int (view->Bitmap()->Bounds().Height() + 1), int (view->Bitmap()->Bounds().Width() + 1)); + sprintf( + title, "%s (%i x %i)", name, int(view->Bitmap()->Bounds().Height() + 1), + int(view->Bitmap()->Bounds().Width() + 1) + ); else - sprintf (title, "No handler for %s", name); - text->SetText (title); - prev->SetEnabled (true); + sprintf(title, "No handler for %s", name); + text->SetText(title); + prev->SetEnabled(true); } if (current_index == 0) - prev->SetEnabled (false); + prev->SetEnabled(false); if (current_index == CurrentTilesEntries->CountItems()) - next->SetEnabled (false); + next->SetEnabled(false); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect *frame, bool final, BPoint /* point*/, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* frame, bool final, BPoint /* point*/, uint32 /* buttons */ +) { int error = ADDON_OK; if (*outLayer == NULL && mode == M_DRAW) *outLayer = inLayer; -// *outLayer = new Layer (*inLayer); + // *outLayer = new Layer (*inLayer); if (*outSelection == NULL && mode == M_SELECT) - *outSelection = new Selection (inLayer->Bounds()); - + *outSelection = new Selection(inLayer->Bounds()); + if (*outLayer) (*outLayer)->Lock(); if (*outSelection) (*outSelection)->Lock(); - uint32 h = frame->IntegerHeight() + 1; - uint32 w = frame->IntegerWidth() + 1; - uint8 *mapbits = NULL; - uint32 mbpr = 0; - uint32 mdiff = 0; - - switch (mode) - { - case M_DRAW: - { + uint32 h = frame->IntegerHeight() + 1; + uint32 w = frame->IntegerWidth() + 1; + uint8* mapbits = NULL; + uint32 mbpr = 0; + uint32 mdiff = 0; + + switch (mode) { + case M_DRAW: { BRect zeroframe = *frame; - zeroframe.OffsetTo (B_ORIGIN); - BBitmap *b = new BBitmap (zeroframe, B_RGB_32_BIT, true); + zeroframe.OffsetTo(B_ORIGIN); + BBitmap* b = new BBitmap(zeroframe, B_RGB_32_BIT, true); b->Lock(); - BView *v = new BView (zeroframe, "tmp", 0, 0); - b->AddChild (v); - v->SetLowColor (DarkGrey); - if (view->Bitmap()) - { + BView* v = new BView(zeroframe, "tmp", 0, 0); + b->AddChild(v); + v->SetLowColor(DarkGrey); + if (view->Bitmap()) { int xs = view->Bitmap()->Bounds().IntegerWidth(); int ys = view->Bitmap()->Bounds().IntegerHeight(); - for (int x = 0; x < zeroframe.Width()/xs; x++) - for (int y = 0; y < zeroframe.Height()/ys; y++) - { - v->DrawBitmapAsync (view->Bitmap(), BPoint (x*xs, y*ys)); + for (int x = 0; x < zeroframe.Width() / xs; x++) + for (int y = 0; y < zeroframe.Height() / ys; y++) { + v->DrawBitmapAsync(view->Bitmap(), BPoint(x * xs, y * ys)); } - } - else - v->FillRect (zeroframe, B_SOLID_LOW); + } else + v->FillRect(zeroframe, B_SOLID_LOW); v->Sync(); - b->RemoveChild (v); + b->RemoveChild(v); delete v; - uint32 *bd = (uint32 *) b->Bits() - 1; - if (inSelection) - { - mbpr = inSelection->BytesPerRow(); + uint32* bd = (uint32*)b->Bits() - 1; + if (inSelection) { + mbpr = inSelection->BytesPerRow(); mdiff = mbpr - w; - mapbits = (uint8 *) inSelection->Bits() - 1 + int (frame->top)*mbpr + int (frame->left); - for (uint32 y = 0; y < h; y++) - { - for (uint32 x = 0; x < w; x++) - { + mapbits = (uint8*)inSelection->Bits() - 1 + int(frame->top) * mbpr + int(frame->left); + for (uint32 y = 0; y < h; y++) { + for (uint32 x = 0; x < w; x++) { bgra_pixel pixel = *(++bd) & COLOR_MASK; uint8 alpha = *(++mapbits); *(bd) = pixel | (alpha << ALPHA_BPOS); } mapbits += mdiff; } - //memcpy ((*outLayer)->Bits(), inLayer->Bits(), inLayer->BitsLength()); + // memcpy ((*outLayer)->Bits(), inLayer->Bits(), inLayer->BitsLength()); *outLayer = inLayer; - } - else // No selection: tile the entire canvas/ + } else // No selection: tile the entire canvas/ { - for (int i = 0; i < b->BitsLength()/4; i++) + for (int i = 0; i < b->BitsLength() / 4; i++) *(bd) = *(++bd) | ALPHA_MASK; } - AddWithAlpha (b, *outLayer, int (frame->left), int (frame->top)); + AddWithAlpha(b, *outLayer, int(frame->left), int(frame->top)); delete b; break; } - case M_SELECT: - { + case M_SELECT: { break; } default: - fprintf (stderr, "Tile: Unknown mode\n"); + fprintf(stderr, "Tile: Unknown mode\n"); error = ADDON_UNKNOWN; } diff --git a/source/add-ons/Translate/Translate.cpp b/source/add-ons/Translate/Translate.cpp index 060f8c8..7bf2b9b 100644 --- a/source/add-ons/Translate/Translate.cpp +++ b/source/add-ons/Translate/Translate.cpp @@ -9,145 +9,152 @@ class TranslateWindow : public AddOnWindow { -public: - TranslateWindow (BRect rect, becasso_addon_info *info) : AddOnWindow (rect, info) - { - fX = 0; - fY = 0; - }; -virtual ~TranslateWindow () {}; -virtual void MessageReceived (BMessage *msg); -float xAmount () { return (fX); }; -float yAmount () { return (fY); }; - -private: -typedef AddOnWindow inherited; -float fX; -float fY; + public: + TranslateWindow(BRect rect, becasso_addon_info* info) : AddOnWindow(rect, info) + { + fX = 0; + fY = 0; + }; + + virtual ~TranslateWindow(){}; + virtual void MessageReceived(BMessage* msg); + + float xAmount() { return (fX); }; + + float yAmount() { return (fY); }; + + private: + typedef AddOnWindow inherited; + float fX; + float fY; }; -void TranslateWindow::MessageReceived (BMessage *msg) +void +TranslateWindow::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'trlX': - fX = msg->FindFloat ("value"); + fX = msg->FindFloat("value"); break; case 'trlY': - fY = msg->FindFloat ("value"); + fY = msg->FindFloat("value"); break; default: - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); return; } aPreview(); } -TranslateWindow *window; +TranslateWindow* window; -int addon_init (uint32 index, becasso_addon_info *info) +int +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Translate"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998 ∑ Sum Software"); - strcpy (info->description, "Translate a selection of the canvas"); - info->type = BECASSO_TRANSFORMER; - info->index = index; - info->version = 0; - info->release = 1; - info->becasso_version = 1; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - window = new TranslateWindow (BRect (100, 180, 100 + 188, 180 + 116), info); - Slider *xSlid = new Slider (BRect (8, 8, 180, 24), 12, "x", -MAXAMOUNT, MAXAMOUNT, 1, new BMessage ('trlX')); - Slider *ySlid = new Slider (BRect (8, 28, 180, 44), 12, "y", -MAXAMOUNT, MAXAMOUNT, 1, new BMessage ('trlY')); - window->Background()->AddChild (xSlid); - window->Background()->AddChild (ySlid); - xSlid->SetValue (0); - ySlid->SetValue (0); + strcpy(info->name, "Translate"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998 ∑ Sum Software"); + strcpy(info->description, "Translate a selection of the canvas"); + info->type = BECASSO_TRANSFORMER; + info->index = index; + info->version = 0; + info->release = 1; + info->becasso_version = 1; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + window = new TranslateWindow(BRect(100, 180, 100 + 188, 180 + 116), info); + Slider* xSlid = + new Slider(BRect(8, 8, 180, 24), 12, "x", -MAXAMOUNT, MAXAMOUNT, 1, new BMessage('trlX')); + Slider* ySlid = + new Slider(BRect(8, 28, 180, 44), 12, "y", -MAXAMOUNT, MAXAMOUNT, 1, new BMessage('trlY')); + window->Background()->AddChild(xSlid); + window->Background()->AddChild(ySlid); + xSlid->SetValue(0); + ySlid->SetValue(0); window->Run(); return (0); } -int addon_exit (void) +int +addon_exit(void) { return (0); } -int addon_open (BWindow *client, const char *name) +int +addon_open(BWindow* client, const char* name) { char title[B_FILE_NAME_LENGTH]; - sprintf (title, "Translate %s", name); + sprintf(title, "Translate %s", name); window->Lock(); - window->SetTitle (title); + window->SetTitle(title); if (window->IsHidden()) - window->aShow (client); + window->aShow(client); else - window->aActivate (client); + window->aActivate(client); window->Unlock(); return (0); } -int addon_close () +int +addon_close() { window->aClose(); return (0); } -int process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect *frame, bool /* final */, BPoint /* point */, uint32 /* buttons */) +int +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* frame, bool /* final */, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; -// BRect bounds = inLayer->Bounds(); - -// if (*outLayer == NULL && mode== M_DRAW) -// *outLayer = new Layer (*inLayer); - -// if (mode == M_SELECT) -// { -// if (inSelection) -// *outSelection = new Selection (*inSelection); -// else // No Selection to translate! -// return (error); -// } - + // BRect bounds = inLayer->Bounds(); + + // if (*outLayer == NULL && mode== M_DRAW) + // *outLayer = new Layer (*inLayer); + + // if (mode == M_SELECT) + // { + // if (inSelection) + // *outSelection = new Selection (*inSelection); + // else // No Selection to translate! + // return (error); + // } + BRect oldrect = *frame; BRect newrect = oldrect; - oldrect.OffsetBy (-window->xAmount(), -window->yAmount()); - -// if (*outLayer) -// (*outLayer)->Lock(); -// if (*outSelection) -// (*outSelection)->Lock(); - - switch (mode) - { - case M_DRAW: - { - BView *view = new BView (inLayer->Bounds(), "tmpView", 0, 0); - inLayer->AddChild (view); - view->DrawBitmapAsync (inLayer, oldrect, newrect); + oldrect.OffsetBy(-window->xAmount(), -window->yAmount()); + + // if (*outLayer) + // (*outLayer)->Lock(); + // if (*outSelection) + // (*outSelection)->Lock(); + + switch (mode) { + case M_DRAW: { + BView* view = new BView(inLayer->Bounds(), "tmpView", 0, 0); + inLayer->AddChild(view); + view->DrawBitmapAsync(inLayer, oldrect, newrect); view->Sync(); - inLayer->RemoveChild (view); + inLayer->RemoveChild(view); delete view; break; } - case M_SELECT: - { + case M_SELECT: { break; } default: - fprintf (stderr, "Translate: Unknown mode\n"); + fprintf(stderr, "Translate: Unknown mode\n"); error = 1; } -// if (*outSelection) -// (*outSelection)->Unlock(); -// if (*outLayer) -// (*outLayer)->Unlock(); + // if (*outSelection) + // (*outSelection)->Unlock(); + // if (*outLayer) + // (*outLayer)->Unlock(); *frame = newrect; return (error); } - diff --git a/source/add-ons/VideoGrabber/VideoConsumer.cpp b/source/add-ons/VideoGrabber/VideoConsumer.cpp index 5a27a23..33206af 100644 --- a/source/add-ons/VideoGrabber/VideoConsumer.cpp +++ b/source/add-ons/VideoGrabber/VideoConsumer.cpp @@ -19,53 +19,43 @@ #include "VideoConsumer.h" #define M1 ((double)1000000.0) -#define JITTER 20000 +#define JITTER 20000 -#define FUNCTION (void) -#define ERROR printf -#define PROGRESS (void) -#define LOOP (void) +#define FUNCTION (void) +#define ERROR printf +#define PROGRESS (void) +#define LOOP (void) -static status_t SetFileType(BFile * file, int32 translator, uint32 type); +static status_t +SetFileType(BFile* file, int32 translator, uint32 type); -const media_raw_video_format vid_format = { 29.97,1,0,239,B_VIDEO_TOP_LEFT_RIGHT,1,1,{B_RGB16,320,240,320*4,0,0}}; +const media_raw_video_format vid_format = { + 29.97, 1, 0, 239, B_VIDEO_TOP_LEFT_RIGHT, 1, 1, {B_RGB16, 320, 240, 320 * 4, 0, 0} +}; //--------------------------------------------------------------- VideoConsumer::VideoConsumer( - const char * name, - BView *view, - BMediaAddOn *addon, - const int32 internal_id) : - - BMediaNode(name), - BMediaEventLooper(), - BBufferConsumer(B_MEDIA_RAW_VIDEO), - mInternalID(internal_id), - mAddOn(addon), - mConnectionActive(false), - mMyLatency(20000), - mWindow(NULL), - mView(view), - mOurBuffers(false), - mBuffers(NULL), - mRate(1000000), - mImageFormat(0), - mTranslator(0), - fLastIndex(-1) + const char* name, BView* view, BMediaAddOn* addon, const int32 internal_id +) + : + + BMediaNode(name), BMediaEventLooper(), BBufferConsumer(B_MEDIA_RAW_VIDEO), + mInternalID(internal_id), mAddOn(addon), mConnectionActive(false), mMyLatency(20000), + mWindow(NULL), mView(view), mOurBuffers(false), mBuffers(NULL), mRate(1000000), + mImageFormat(0), mTranslator(0), fLastIndex(-1) { AddNodeKind(B_PHYSICAL_OUTPUT); SetEventLatency(0); mWindow = mView->Window(); - - for (uint32 j = 0; j < 3; j++) - { + + for (uint32 j = 0; j < 3; j++) { mBitmap[j] = NULL; mBufferMap[j] = NULL; } - + SetPriority(B_DISPLAY_PRIORITY); - + mImageFormat = 'PNG '; } @@ -75,14 +65,14 @@ VideoConsumer::~VideoConsumer() { Quit(); -// if (mWindow) -// { -// if (mWindow->Lock()) -// { -// mWindow->Close(); -// mWindow = 0; -// } -// } + // if (mWindow) + // { + // if (mWindow->Lock()) + // { + // mWindow->Close(); + // mWindow = 0; + // } + // } DeleteBuffers(); } @@ -93,8 +83,8 @@ VideoConsumer::~VideoConsumer() //--------------------------------------------------------------- -BMediaAddOn * -VideoConsumer::AddOn(int32 *cookie) const +BMediaAddOn* +VideoConsumer::AddOn(int32* cookie) const { // do the right thing if we're ever used with an add-on *cookie = mInternalID; @@ -106,32 +96,32 @@ VideoConsumer::AddOn(int32 *cookie) const // This implementation is required to get around a bug in // the ppc compiler. -void +void VideoConsumer::Start(bigtime_t performance_time) { BMediaEventLooper::Start(performance_time); } -void +void VideoConsumer::Stop(bigtime_t performance_time, bool immediate) { BMediaEventLooper::Stop(performance_time, immediate); } -void +void VideoConsumer::Seek(bigtime_t media_time, bigtime_t performance_time) { BMediaEventLooper::Seek(media_time, performance_time); } -void +void VideoConsumer::TimeWarp(bigtime_t at_real_time, bigtime_t to_performance_time) { BMediaEventLooper::TimeWarp(at_real_time, to_performance_time); } -status_t -VideoConsumer::DeleteHook(BMediaNode *node) +status_t +VideoConsumer::DeleteHook(BMediaNode* node) { return BMediaEventLooper::DeleteHook(node); } @@ -153,124 +143,113 @@ VideoConsumer::NodeRegistered() //--------------------------------------------------------------- status_t -VideoConsumer::RequestCompleted(const media_request_info & info) +VideoConsumer::RequestCompleted(const media_request_info& info) { - switch(info.what) - { - case media_request_info::B_SET_OUTPUT_BUFFERS_FOR: - { - if (info.status != B_OK) - ERROR("VideoConsumer::RequestCompleted: Not using our buffers!\n"); - } - break; - default: - break; + switch (info.what) { + case media_request_info::B_SET_OUTPUT_BUFFERS_FOR: { + if (info.status != B_OK) + ERROR("VideoConsumer::RequestCompleted: Not using our buffers!\n"); + } break; + default: + break; } return B_OK; } - //--------------------------------------------------------------- void -VideoConsumer::BufferReceived(BBuffer * buffer) +VideoConsumer::BufferReceived(BBuffer* buffer) { -// LOOP("VideoConsumer::Buffer #%ld received\n", (uint32) buffer->ID()); + // LOOP("VideoConsumer::Buffer #%ld received\n", (uint32) buffer->ID()); - if (RunState() == B_STOPPED) - { + if (RunState() == B_STOPPED) { buffer->Recycle(); return; } - media_timed_event event(buffer->Header()->start_time, BTimedEventQueue::B_HANDLE_BUFFER, - buffer, BTimedEventQueue::B_RECYCLE_BUFFER); + media_timed_event event( + buffer->Header()->start_time, BTimedEventQueue::B_HANDLE_BUFFER, buffer, + BTimedEventQueue::B_RECYCLE_BUFFER + ); EventQueue()->AddEvent(event); } - //--------------------------------------------------------------- void VideoConsumer::ProducerDataStatus( - const media_destination &for_whom, - int32 status, - bigtime_t at_media_time) + const media_destination& for_whom, int32 status, bigtime_t at_media_time +) { - if (for_whom != mIn.destination) + if (for_whom != mIn.destination) return; } //--------------------------------------------------------------- status_t -VideoConsumer::CreateBuffers( - const media_format & with_format) +VideoConsumer::CreateBuffers(const media_format& with_format) { // delete any old buffers - DeleteBuffers(); + DeleteBuffers(); status_t status = B_OK; // create a buffer group uint32 mXSize = with_format.u.raw_video.display.line_width; - uint32 mYSize = with_format.u.raw_video.display.line_count; -// uint32 mRowBytes = with_format.u.raw_video.display.bytes_per_row; + uint32 mYSize = with_format.u.raw_video.display.line_count; + // uint32 mRowBytes = with_format.u.raw_video.display.bytes_per_row; color_space mColorspace = with_format.u.raw_video.display.format; -// PROGRESS("VideoConsumer::CreateBuffers - Colorspace = %d\n", mColorspace); + // PROGRESS("VideoConsumer::CreateBuffers - Colorspace = %d\n", mColorspace); mBuffers = new BBufferGroup(); status = mBuffers->InitCheck(); - if (B_OK != status) - { + if (B_OK != status) { ERROR("VideoConsumer::CreateBuffers - ERROR CREATING BUFFER GROUP\n"); return status; } // and attach the bitmaps to the buffer group - for (uint32 j=0; j < 3; j++) - { - mBitmap[j] = new BBitmap(BRect(0, 0, (mXSize-1), (mYSize - 1)), mColorspace, false, true); - if (mBitmap[j]->IsValid()) - { + for (uint32 j = 0; j < 3; j++) { + mBitmap[j] = new BBitmap(BRect(0, 0, (mXSize - 1), (mYSize - 1)), mColorspace, false, true); + if (mBitmap[j]->IsValid()) { buffer_clone_info info; if ((info.area = area_for(mBitmap[j]->Bits())) == B_ERROR) - ERROR("VideoConsumer::CreateBuffers - ERROR IN AREA_FOR\n");; + ERROR("VideoConsumer::CreateBuffers - ERROR IN AREA_FOR\n"); + ; info.offset = 0; info.size = (size_t)mBitmap[j]->BitsLength(); info.flags = j; info.buffer = 0; - if ((status = mBuffers->AddBuffer(info)) != B_OK) - { + if ((status = mBuffers->AddBuffer(info)) != B_OK) { ERROR("VideoConsumer::CreateBuffers - ERROR ADDING BUFFER TO GROUP\n"); return status; - }// else PROGRESS("VideoConsumer::CreateBuffers - SUCCESSFUL ADD BUFFER TO GROUP\n"); - } - else - { - ERROR("VideoConsumer::CreateBuffers - ERROR CREATING VIDEO RING BUFFER: %08lx\n", status); + } // else PROGRESS("VideoConsumer::CreateBuffers - SUCCESSFUL ADD BUFFER TO GROUP\n"); + } else { + ERROR( + "VideoConsumer::CreateBuffers - ERROR CREATING VIDEO RING BUFFER: %08lx\n", status + ); return B_ERROR; - } + } } - - BBuffer ** buffList = new BBuffer * [3]; - for (int j = 0; j < 3; j++) buffList[j] = 0; - - if ((status = mBuffers->GetBufferList(3, buffList)) == B_OK) + + BBuffer** buffList = new BBuffer*[3]; + for (int j = 0; j < 3; j++) + buffList[j] = 0; + + if ((status = mBuffers->GetBufferList(3, buffList)) == B_OK) for (int j = 0; j < 3; j++) - if (buffList[j] != NULL) - { + if (buffList[j] != NULL) { mBufferMap[j] = buffList[j]; -// PROGRESS(" j = %d buffer = %08lx\n", j, mBufferMap[j]); - } - else - { + // PROGRESS(" j = %d buffer = %08lx\n", j, mBufferMap[j]); + } else { ERROR("VideoConsumer::CreateBuffers ERROR MAPPING RING BUFFER\n"); return B_ERROR; } else ERROR("VideoConsumer::CreateBuffers ERROR IN GET BUFFER LIST\n"); - + return status; } @@ -279,14 +258,12 @@ VideoConsumer::CreateBuffers( void VideoConsumer::DeleteBuffers() { - if (mBuffers) - { + if (mBuffers) { delete mBuffers; mBuffers = NULL; - + for (uint32 j = 0; j < 3; j++) - if (mBitmap[j]->IsValid()) - { + if (mBitmap[j]->IsValid()) { delete mBitmap[j]; mBitmap[j] = NULL; } @@ -297,10 +274,9 @@ VideoConsumer::DeleteBuffers() status_t VideoConsumer::Connected( - const media_source & producer, - const media_destination & where, - const media_format & with_format, - media_input * out_input) + const media_source& producer, const media_destination& where, const media_format& with_format, + media_input* out_input +) { mIn.source = producer; mIn.format = with_format; @@ -309,12 +285,12 @@ VideoConsumer::Connected( *out_input = mIn; uint32 user_data = 0; - int32 change_tag = 1; + int32 change_tag = 1; if (CreateBuffers(with_format) == B_OK) - BBufferConsumer::SetOutputBuffersFor(producer, mDestination, - mBuffers, (void *)&user_data, &change_tag, true); - else - { + BBufferConsumer::SetOutputBuffersFor( + producer, mDestination, mBuffers, (void*)&user_data, &change_tag, true + ); + else { ERROR("VideoConsumer::Connected - COULDN'T CREATE BUFFERS\n"); return B_ERROR; } @@ -327,12 +303,9 @@ VideoConsumer::Connected( //--------------------------------------------------------------- void -VideoConsumer::Disconnected( - const media_source & producer, - const media_destination & where) +VideoConsumer::Disconnected(const media_source& producer, const media_destination& where) { - if (where == mIn.destination && producer == mIn.source) - { + if (where == mIn.destination && producer == mIn.source) { // disconnect the connection mIn.source = media_source::null; mConnectionActive = false; @@ -342,41 +315,35 @@ VideoConsumer::Disconnected( //--------------------------------------------------------------- status_t -VideoConsumer::AcceptFormat( - const media_destination & dest, - media_format * format) +VideoConsumer::AcceptFormat(const media_destination& dest, media_format* format) { - if (dest != mIn.destination) - { + if (dest != mIn.destination) { ERROR("VideoConsumer::AcceptFormat - BAD DESTINATION\n"); - return B_MEDIA_BAD_DESTINATION; + return B_MEDIA_BAD_DESTINATION; } - + if (format->type == B_MEDIA_NO_TYPE) format->type = B_MEDIA_RAW_VIDEO; - - if (format->type != B_MEDIA_RAW_VIDEO) - { + + if (format->type != B_MEDIA_RAW_VIDEO) { ERROR("VideoConsumer::AcceptFormat - BAD FORMAT\n"); return B_MEDIA_BAD_FORMAT; } if (format->u.raw_video.display.format != B_RGB32 && format->u.raw_video.display.format != B_RGB16 && - format->u.raw_video.display.format != B_RGB15 && - format->u.raw_video.display.format != B_GRAY8 && - format->u.raw_video.display.format != media_raw_video_format::wildcard.display.format) - { + format->u.raw_video.display.format != B_RGB15 && + format->u.raw_video.display.format != B_GRAY8 && + format->u.raw_video.display.format != media_raw_video_format::wildcard.display.format) { ERROR("AcceptFormat - not a format we know about!\n"); return B_MEDIA_BAD_FORMAT; } - - if (format->u.raw_video.display.format == media_raw_video_format::wildcard.display.format) - { + + if (format->u.raw_video.display.format == media_raw_video_format::wildcard.display.format) { format->u.raw_video.display.format = B_RGB16; } - char format_string[256]; + char format_string[256]; string_for_format(*format, format_string, 256); return B_OK; } @@ -384,25 +351,20 @@ VideoConsumer::AcceptFormat( //--------------------------------------------------------------- status_t -VideoConsumer::GetNextInput( - int32 * cookie, - media_input * out_input) +VideoConsumer::GetNextInput(int32* cookie, media_input* out_input) { // custom build a destination for this connection // put connection number in id - if (*cookie < 1) - { + if (*cookie < 1) { mIn.node = Node(); mIn.destination.id = *cookie; sprintf(mIn.name, "Video Consumer"); *out_input = mIn; (*cookie)++; return B_OK; - } - else - { -// ERROR("VideoConsumer::GetNextInput - - BAD INDEX\n"); + } else { + // ERROR("VideoConsumer::GetNextInput - - BAD INDEX\n"); return B_MEDIA_BAD_DESTINATION; } } @@ -418,30 +380,27 @@ VideoConsumer::DisposeInputCookie(int32 /*cookie*/) status_t VideoConsumer::GetLatencyFor( - const media_destination &for_whom, - bigtime_t * out_latency, - media_node_id * out_timesource) + const media_destination& for_whom, bigtime_t* out_latency, media_node_id* out_timesource +) { if (for_whom != mIn.destination) return B_MEDIA_BAD_DESTINATION; - + *out_latency = mMyLatency; *out_timesource = TimeSource()->ID(); return B_OK; } - //--------------------------------------------------------------- status_t VideoConsumer::FormatChanged( - const media_source & producer, - const media_destination & consumer, - int32 from_change_count, - const media_format &format) + const media_source& producer, const media_destination& consumer, int32 from_change_count, + const media_format& format +) { FUNCTION("VideoConsumer::FormatChanged\n"); - + if (consumer != mIn.destination) return B_MEDIA_BAD_DESTINATION; @@ -449,171 +408,159 @@ VideoConsumer::FormatChanged( return B_MEDIA_BAD_SOURCE; mIn.format = format; - + return CreateBuffers(format); } //--------------------------------------------------------------- void -VideoConsumer::HandleEvent( - const media_timed_event *event, - bigtime_t lateness, - bool realTimeEvent) +VideoConsumer::HandleEvent(const media_timed_event* event, bigtime_t lateness, bool realTimeEvent) { -// LOOP("VideoConsumer::HandleEvent\n"); - - BBuffer *buffer; - - switch (event->type) - { - case BTimedEventQueue::B_START: - PROGRESS("VideoConsumer::HandleEvent - START\n"); - break; - case BTimedEventQueue::B_STOP: - PROGRESS("VideoConsumer::HandleEvent - STOP\n"); - EventQueue()->FlushEvents(event->event_time, BTimedEventQueue::B_ALWAYS, true, BTimedEventQueue::B_HANDLE_BUFFER); - break; - case BTimedEventQueue::B_USER_EVENT: - PROGRESS("VideoConsumer::HandleEvent - USER EVENT\n"); - if (RunState() == B_STARTED) - { - PROGRESS("Pushing user event for %.4f, time now %.4f\n", (event->event_time + mRate)/M1, event->event_time/M1); - media_timed_event newEvent(event->event_time + mRate, BTimedEventQueue::B_USER_EVENT); - EventQueue()->AddEvent(newEvent); + // LOOP("VideoConsumer::HandleEvent\n"); + + BBuffer* buffer; + + switch (event->type) { + case BTimedEventQueue::B_START: + PROGRESS("VideoConsumer::HandleEvent - START\n"); + break; + case BTimedEventQueue::B_STOP: + PROGRESS("VideoConsumer::HandleEvent - STOP\n"); + EventQueue()->FlushEvents( + event->event_time, BTimedEventQueue::B_ALWAYS, true, BTimedEventQueue::B_HANDLE_BUFFER + ); + break; + case BTimedEventQueue::B_USER_EVENT: + PROGRESS("VideoConsumer::HandleEvent - USER EVENT\n"); + if (RunState() == B_STARTED) { + PROGRESS( + "Pushing user event for %.4f, time now %.4f\n", (event->event_time + mRate) / M1, + event->event_time / M1 + ); + media_timed_event newEvent(event->event_time + mRate, BTimedEventQueue::B_USER_EVENT); + EventQueue()->AddEvent(newEvent); + } + break; + case BTimedEventQueue::B_HANDLE_BUFFER: + // LOOP("VideoConsumer::HandleEvent - HANDLE BUFFER\n"); + buffer = (BBuffer*)event->pointer; + if (RunState() == B_STARTED && mConnectionActive) { + // see if this is one of our buffers + uint32 index = 0; + mOurBuffers = true; + while (index < 3) + if (buffer == mBufferMap[index]) + break; + else + index++; + + if (index == 3) { + // no, buffers belong to consumer + mOurBuffers = false; + index = 0; } - break; - case BTimedEventQueue::B_HANDLE_BUFFER: - // LOOP("VideoConsumer::HandleEvent - HANDLE BUFFER\n"); - buffer = (BBuffer *) event->pointer; - if (RunState() == B_STARTED && mConnectionActive) - { - // see if this is one of our buffers - uint32 index = 0; - mOurBuffers = true; - while(index < 3) - if (buffer == mBufferMap[index]) - break; - else - index++; - - if (index == 3) - { - // no, buffers belong to consumer - mOurBuffers = false; - index = 0; - } - - if ( (RunMode() == B_OFFLINE) || - ((TimeSource()->Now() > (buffer->Header()->start_time - JITTER)) && - (TimeSource()->Now() < (buffer->Header()->start_time + JITTER))) ) - { - if (!mOurBuffers) - // not our buffers, so we need to copy - memcpy(mBitmap[index]->Bits(), buffer->Data(),mBitmap[index]->BitsLength()); - - if (mWindow->Lock()) - { - uint32 flags; - if ((mBitmap[index]->ColorSpace() == B_GRAY8) && - !bitmaps_support_space(mBitmap[index]->ColorSpace(), &flags)) - { - // handle mapping of GRAY8 until app server knows how - uint32 *start = (uint32 *)mBitmap[index]->Bits(); - int32 size = mBitmap[index]->BitsLength(); - uint32 *end = start + size/4; - for (uint32 *p = start; p < end; p++) - *p = (*p >> 3) & 0x1f1f1f1f; - } - - mView->DrawBitmap(mBitmap[index], mView->Bounds()); - fLastIndex = index; - mWindow->Unlock(); + + if ((RunMode() == B_OFFLINE) || + ((TimeSource()->Now() > (buffer->Header()->start_time - JITTER)) && + (TimeSource()->Now() < (buffer->Header()->start_time + JITTER)))) { + if (!mOurBuffers) + // not our buffers, so we need to copy + memcpy(mBitmap[index]->Bits(), buffer->Data(), mBitmap[index]->BitsLength()); + + if (mWindow->Lock()) { + uint32 flags; + if ((mBitmap[index]->ColorSpace() == B_GRAY8) && + !bitmaps_support_space(mBitmap[index]->ColorSpace(), &flags)) { + // handle mapping of GRAY8 until app server knows how + uint32* start = (uint32*)mBitmap[index]->Bits(); + int32 size = mBitmap[index]->BitsLength(); + uint32* end = start + size / 4; + for (uint32* p = start; p < end; p++) + *p = (*p >> 3) & 0x1f1f1f1f; } + + mView->DrawBitmap(mBitmap[index], mView->Bounds()); + fLastIndex = index; + mWindow->Unlock(); } - else - PROGRESS("VidConsumer::HandleEvent - DROPPED FRAME\n"); - buffer->Recycle(); - } - else - buffer->Recycle(); - break; - default: - ERROR("VideoConsumer::HandleEvent - BAD EVENT\n"); - break; - } + } else + PROGRESS("VidConsumer::HandleEvent - DROPPED FRAME\n"); + buffer->Recycle(); + } else + buffer->Recycle(); + break; + default: + ERROR("VideoConsumer::HandleEvent - BAD EVENT\n"); + break; + } } //--------------------------------------------------------------- -BBitmap * -VideoConsumer::Grab () +BBitmap* +VideoConsumer::Grab() { if (fLastIndex == -1) return 0; - + return (mBitmap[fLastIndex]); } status_t -VideoConsumer::LocalSave(char *filename, BBitmap *bitmap) +VideoConsumer::LocalSave(char* filename, BBitmap* bitmap) { - BFile *output; - + BFile* output; + /* save a local copy of the image in the requested format */ - output =new BFile(); - if (output->SetTo(filename, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE) == B_NO_ERROR) - { + output = new BFile(); + if (output->SetTo(filename, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE) == B_NO_ERROR) { BBitmapStream input(bitmap); - status_t err = BTranslatorRoster::Default()->Translate(&input, NULL, NULL, output, mImageFormat); - if (err == B_OK) - { - err = SetFileType(output, mTranslator, mImageFormat); - if (err != B_OK) - printf ("Error setting type of output file"); - } - else - { - printf ("Error writing output file"); - } - input.DetachBitmap(&bitmap); - output->Unset(); - delete output; - return B_OK; - } - else - { - printf ("Error creating output file"); - return B_ERROR; - } + status_t err = + BTranslatorRoster::Default()->Translate(&input, NULL, NULL, output, mImageFormat); + if (err == B_OK) { + err = SetFileType(output, mTranslator, mImageFormat); + if (err != B_OK) + printf("Error setting type of output file"); + } else { + printf("Error writing output file"); + } + input.DetachBitmap(&bitmap); + output->Unset(); + delete output; + return B_OK; + } else { + printf("Error creating output file"); + return B_ERROR; + } } //--------------------------------------------------------------- status_t -SetFileType(BFile * file, int32 translator, uint32 type) -{ - translation_format * formats; +SetFileType(BFile* file, int32 translator, uint32 type) +{ + translation_format* formats; int32 count; - - status_t err = BTranslatorRoster::Default()->GetOutputFormats(translator, (const translation_format **) &formats, &count); - if (err < B_OK) return err; - const char * mime = NULL; - for (int ix=0; ixGetOutputFormats( + translator, (const translation_format**)&formats, &count + ); + if (err < B_OK) + return err; + const char* mime = NULL; + for (int ix = 0; ix < count; ix++) { + if (formats[ix].type == type) { + mime = formats[ix].MIME; + break; + } + } + if (mime == NULL) { /* this should not happen, but being defensive might be prudent */ + return B_ERROR; + } + + /* use BNodeInfo to set the file type */ + BNodeInfo ninfo(file); + return ninfo.SetType(mime); +} diff --git a/source/add-ons/VideoGrabber/VideoGrabber.cpp b/source/add-ons/VideoGrabber/VideoGrabber.cpp index d6ac9a5..5db1eb6 100644 --- a/source/add-ons/VideoGrabber/VideoGrabber.cpp +++ b/source/add-ons/VideoGrabber/VideoGrabber.cpp @@ -14,59 +14,67 @@ class CaptureWindow : public BWindow { -public: - CaptureWindow (BRect rect) : BWindow (rect, "Video Grabber", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK) {}; -virtual ~CaptureWindow (); -virtual bool QuitRequested () { Hide(); TearDownNodes(); return false; }; - -BBitmap *Grab(); + public: + CaptureWindow(BRect rect) + : BWindow( + rect, "Video Grabber", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK + ){}; + virtual ~CaptureWindow(); + + virtual bool QuitRequested() + { + Hide(); + TearDownNodes(); + return false; + }; -status_t SetUpNodes(); -void TearDownNodes(); + BBitmap* Grab(); -private: + status_t SetUpNodes(); + void TearDownNodes(); -BMediaRoster *fMediaRoster; + private: + BMediaRoster* fMediaRoster; -media_node fTimeSourceNode; -media_node fProducerNode; + media_node fTimeSourceNode; + media_node fProducerNode; -VideoConsumer *fVideoConsumer; + VideoConsumer* fVideoConsumer; -media_output fProducerOut; -media_input fConsumerIn; + media_output fProducerOut; + media_input fConsumerIn; -public: -BView *fVideoView; + public: + BView* fVideoView; }; -void ErrorAlert(const char * message, status_t err); +void +ErrorAlert(const char* message, status_t err); -CaptureWindow::~CaptureWindow () -{ -} +CaptureWindow::~CaptureWindow() {} -BBitmap *CaptureWindow::Grab() +BBitmap* +CaptureWindow::Grab() { - BBitmap *ori = fVideoConsumer->Grab(); - BBitmap *grab = new BBitmap (ori->Bounds(), B_RGBA32, true); + BBitmap* ori = fVideoConsumer->Grab(); + BBitmap* grab = new BBitmap(ori->Bounds(), B_RGBA32, true); grab->Lock(); - BView *v = new BView (ori->Bounds(), "tmp", B_FOLLOW_NONE, B_WILL_DRAW); - grab->AddChild (v); - v->DrawBitmap (ori, B_ORIGIN); // convert to 32 bit + BView* v = new BView(ori->Bounds(), "tmp", B_FOLLOW_NONE, B_WILL_DRAW); + grab->AddChild(v); + v->DrawBitmap(ori, B_ORIGIN); // convert to 32 bit v->Sync(); - grab->RemoveChild (v); + grab->RemoveChild(v); delete v; - uint32 *b = (uint32 *) grab->Bits(); - for (int32 i = 0; i < grab->BitsLength()/4; i++) - { - *(b++) |= (255 << ALPHA_BPOS); // grabbed image is totally transparent by default... + uint32* b = (uint32*)grab->Bits(); + for (int32 i = 0; i < grab->BitsLength() / 4; i++) { + *(b++) |= (255 << ALPHA_BPOS); // grabbed image is totally transparent by default... } grab->Unlock(); return grab; } -status_t CaptureWindow::SetUpNodes() +status_t +CaptureWindow::SetUpNodes() { status_t status = B_OK; @@ -103,11 +111,12 @@ status_t CaptureWindow::SetUpNodes() ErrorAlert("Can't register the video window", status); return status; } -// fPort = fVideoConsumer->ControlPort(); + // fPort = fVideoConsumer->ControlPort(); /* find free producer output */ int32 cnt = 0; - status = fMediaRoster->GetFreeOutputsFor(fProducerNode, &fProducerOut, 1, &cnt, B_MEDIA_RAW_VIDEO); + status = + fMediaRoster->GetFreeOutputsFor(fProducerNode, &fProducerOut, 1, &cnt, B_MEDIA_RAW_VIDEO); if (status != B_OK || cnt < 1) { status = B_RESOURCE_UNAVAILABLE; ErrorAlert("Can't find an available video stream", status); @@ -116,7 +125,9 @@ status_t CaptureWindow::SetUpNodes() /* find free consumer input */ cnt = 0; - status = fMediaRoster->GetFreeInputsFor(fVideoConsumer->Node(), &fConsumerIn, 1, &cnt, B_MEDIA_RAW_VIDEO); + status = fMediaRoster->GetFreeInputsFor( + fVideoConsumer->Node(), &fConsumerIn, 1, &cnt, B_MEDIA_RAW_VIDEO + ); if (status != B_OK || cnt < 1) { status = B_RESOURCE_UNAVAILABLE; ErrorAlert("Can't find an available connection to the video window", status); @@ -127,12 +138,14 @@ status_t CaptureWindow::SetUpNodes() media_format format; format.type = B_MEDIA_RAW_VIDEO; media_raw_video_format vid_format = media_raw_video_format::wildcard; - // { 0, 2, 0, VIDEO_SIZE_Y - 1, B_VIDEO_TOP_LEFT_RIGHT, 1, 1, {B_RGB32, VIDEO_SIZE_X, VIDEO_SIZE_Y, VIDEO_SIZE_X*4, 0, 0}}; + // { 0, 2, 0, VIDEO_SIZE_Y - 1, B_VIDEO_TOP_LEFT_RIGHT, 1, 1, {B_RGB32, VIDEO_SIZE_X, + // VIDEO_SIZE_Y, VIDEO_SIZE_X*4, 0, 0}}; format.u.raw_video = vid_format; /* connect producer to consumer */ - status = fMediaRoster->Connect(fProducerOut.source, fConsumerIn.destination, - &format, &fProducerOut, &fConsumerIn); + status = fMediaRoster->Connect( + fProducerOut.source, fConsumerIn.destination, &format, &fProducerOut, &fConsumerIn + ); if (status != B_OK) { ErrorAlert("Can't connect the video source to the video window", status); return status; @@ -164,14 +177,13 @@ status_t CaptureWindow::SetUpNodes() } initLatency += estimate_max_scheduling_latency(); - BTimeSource *timeSource = fMediaRoster->MakeTimeSourceFor(fProducerNode); + BTimeSource* timeSource = fMediaRoster->MakeTimeSourceFor(fProducerNode); bool running = timeSource->IsRunning(); /* workaround for people without sound cards */ /* because the system time source won't be running */ bigtime_t real = BTimeSource::RealTime(); - if (!running) - { + if (!running) { status = fMediaRoster->StartTimeSource(fTimeSourceNode, real); if (status != B_OK) { timeSource->Release(); @@ -202,22 +214,23 @@ status_t CaptureWindow::SetUpNodes() } return status; - } -void CaptureWindow::TearDownNodes () +void +CaptureWindow::TearDownNodes() { if (!fMediaRoster) return; - if (fVideoConsumer) - { + if (fVideoConsumer) { /* stop */ // printf ("stopping nodes!\n"); fMediaRoster->StopNode(fVideoConsumer->Node(), 0, true); /* disconnect */ - fMediaRoster->Disconnect(fProducerOut.node.node, fProducerOut.source, - fConsumerIn.node.node, fConsumerIn.destination); + fMediaRoster->Disconnect( + fProducerOut.node.node, fProducerOut.source, fConsumerIn.node.node, + fConsumerIn.destination + ); if (fProducerNode != media_node::null) { // printf ("Grabber releasing fProducerNode\n"); @@ -233,7 +246,8 @@ void CaptureWindow::TearDownNodes () // Utility functions //--------------------------------------------------------------- -void ErrorAlert(const char * message, status_t err) +void +ErrorAlert(const char* message, status_t err) { char msg[256]; sprintf(msg, "%s\n%s [%lx]", message, strerror(err), err); @@ -243,62 +257,66 @@ void ErrorAlert(const char * message, status_t err) //--------------------------------------------------------------- -CaptureWindow *window; +CaptureWindow* window; -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "VideoGrabber"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 2000-2001 ∑ Sum Software"); - strcpy (info->description, "Captures images from a video node"); - info->type = BECASSO_CAPTURE; - info->index = index; - info->version = 0; - info->release = 2; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = true; - window = new CaptureWindow (BRect (100, 180, 100 + 168 + 40, 180 + 128)); - BView *bg = new BView (BRect (0, 0, 168 + 40, 128), "bg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); - window->fVideoView = new BView (BRect (4, 4, 4 + 159, 4 + 119), "video", B_FOLLOW_ALL, B_WILL_DRAW); - bg->SetViewColor (LightGrey); - window->AddChild (bg); - bg->AddChild (window->fVideoView); - BMessage *msg = new BMessage (CAPTURE_READY); - msg->AddInt32 ("index", index); - BButton *grab = new BButton (BRect (168, 96, 204, 112), "grab", "Grab", msg); - grab->SetTarget (be_app); - grab->SetResizingMode (B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); - bg->AddChild (grab); + strcpy(info->name, "VideoGrabber"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 2000-2001 ∑ Sum Software"); + strcpy(info->description, "Captures images from a video node"); + info->type = BECASSO_CAPTURE; + info->index = index; + info->version = 0; + info->release = 2; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = true; + window = new CaptureWindow(BRect(100, 180, 100 + 168 + 40, 180 + 128)); + BView* bg = new BView(BRect(0, 0, 168 + 40, 128), "bg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); + window->fVideoView = + new BView(BRect(4, 4, 4 + 159, 4 + 119), "video", B_FOLLOW_ALL, B_WILL_DRAW); + bg->SetViewColor(LightGrey); + window->AddChild(bg); + bg->AddChild(window->fVideoView); + BMessage* msg = new BMessage(CAPTURE_READY); + msg->AddInt32("index", index); + BButton* grab = new BButton(BRect(168, 96, 204, 112), "grab", "Grab", msg); + grab->SetTarget(be_app); + grab->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); + bg->AddChild(grab); window->Run(); return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_open (void) +status_t +addon_open(void) { window->Lock(); if (window->IsHidden()) - window->Show (); + window->Show(); else - window->Activate (); + window->Activate(); window->Unlock(); status_t status = window->SetUpNodes(); - if (status != B_OK) - { - ErrorAlert ("Error setting up nodes", status); + if (status != B_OK) { + ErrorAlert("Error setting up nodes", status); return (1); } return B_OK; } -BBitmap *bitmap (char *title) +BBitmap* +bitmap(char* title) { - strcpy (title, "Frame"); - BBitmap *b = window->Grab(); + strcpy(title, "Frame"); + BBitmap* b = window->Grab(); return (b); } diff --git a/source/add-ons/Wave/Wave.cpp b/source/add-ons/Wave/Wave.cpp index 27b0fb8..cc25f55 100644 --- a/source/add-ons/Wave/Wave.cpp +++ b/source/add-ons/Wave/Wave.cpp @@ -8,76 +8,91 @@ #include #define HORIZONTAL 0 -#define VERTICAL 1 +#define VERTICAL 1 -#define FOREGROUND 0 -#define BACKGROUND 1 +#define FOREGROUND 0 +#define BACKGROUND 1 #define TRANSPARENT 2 -#define IMAGECOLOR 3 +#define IMAGECOLOR 3 -float gPeriods; -float gAmplitude; -float gPhase; -int gDirection; -int gColor; +float gPeriods; +float gAmplitude; +float gPhase; +int gDirection; +int gColor; class WaveView : public BView { -public: - WaveView (BRect rect) : BView (rect, "wave view", B_FOLLOW_ALL, B_WILL_DRAW) - { - gPeriods = 1; - gAmplitude = 0.05; - gPhase = 0; - gDirection = 0; - gColor = BACKGROUND; - ResizeTo (188, 232); - Slider *aSlid = new Slider (BRect (8, 8, 180, 24), 60, "Amplitude", 0, 1, 0.01, new BMessage ('wavA'), B_HORIZONTAL, 30, "%3.2f"); - Slider *pSlid = new Slider (BRect (8, 28, 180, 44), 60, "Periods", 0.25, 20, 0.25, new BMessage ('wavP'), B_HORIZONTAL, 30, "%4.2f"); - Slider *fSlid = new Slider (BRect (8, 48, 180, 64), 60, "Phase", 0, 360, 1, new BMessage ('wavF')); - AddChild (aSlid); - AddChild (pSlid); - AddChild (fSlid); - aSlid->SetValue (0.05); - pSlid->SetValue (1); - fSlid->SetValue (0); - BBox *dir = new BBox (BRect (4, 70, 184, 126), "direction"); - dir->SetLabel ("Direction"); - AddChild (dir); - BRadioButton *dH = new BRadioButton (BRect (8, 13, 164, 30), "hor", "Horizontal", new BMessage ('dirH')); - BRadioButton *dV = new BRadioButton (BRect (8, 30, 164, 47), "ver", "Vertical", new BMessage ('dirV')); - dir->AddChild (dH); - dir->AddChild (dV); - dH->SetValue (true); - BBox *col = new BBox (BRect (4, 136, 184, 228), "color"); - col->SetLabel ("Exposed Pixels"); - AddChild (col); - BRadioButton *cF = new BRadioButton (BRect (8, 13, 164, 30), "hi", "Foreground Color", new BMessage ('colF')); - BRadioButton *cB = new BRadioButton (BRect (8, 30, 164, 47), "lo", "Background Color", new BMessage ('colB')); - BRadioButton *cT = new BRadioButton (BRect (8, 47, 164, 64), "tr", "Transparent", new BMessage ('colT')); - BRadioButton *cI = new BRadioButton (BRect (8, 64, 164, 88), "im", "Original Image", new BMessage ('colI')); - col->AddChild (cF); - col->AddChild (cB); - col->AddChild (cT); - col->AddChild (cI); - cB->SetValue (true); - } -virtual ~WaveView () {} -virtual void MessageReceived (BMessage *msg); + public: + WaveView(BRect rect) : BView(rect, "wave view", B_FOLLOW_ALL, B_WILL_DRAW) + { + gPeriods = 1; + gAmplitude = 0.05; + gPhase = 0; + gDirection = 0; + gColor = BACKGROUND; + ResizeTo(188, 232); + Slider* aSlid = new Slider( + BRect(8, 8, 180, 24), 60, "Amplitude", 0, 1, 0.01, new BMessage('wavA'), B_HORIZONTAL, + 30, "%3.2f" + ); + Slider* pSlid = new Slider( + BRect(8, 28, 180, 44), 60, "Periods", 0.25, 20, 0.25, new BMessage('wavP'), + B_HORIZONTAL, 30, "%4.2f" + ); + Slider* fSlid = + new Slider(BRect(8, 48, 180, 64), 60, "Phase", 0, 360, 1, new BMessage('wavF')); + AddChild(aSlid); + AddChild(pSlid); + AddChild(fSlid); + aSlid->SetValue(0.05); + pSlid->SetValue(1); + fSlid->SetValue(0); + BBox* dir = new BBox(BRect(4, 70, 184, 126), "direction"); + dir->SetLabel("Direction"); + AddChild(dir); + BRadioButton* dH = + new BRadioButton(BRect(8, 13, 164, 30), "hor", "Horizontal", new BMessage('dirH')); + BRadioButton* dV = + new BRadioButton(BRect(8, 30, 164, 47), "ver", "Vertical", new BMessage('dirV')); + dir->AddChild(dH); + dir->AddChild(dV); + dH->SetValue(true); + BBox* col = new BBox(BRect(4, 136, 184, 228), "color"); + col->SetLabel("Exposed Pixels"); + AddChild(col); + BRadioButton* cF = + new BRadioButton(BRect(8, 13, 164, 30), "hi", "Foreground Color", new BMessage('colF')); + BRadioButton* cB = + new BRadioButton(BRect(8, 30, 164, 47), "lo", "Background Color", new BMessage('colB')); + BRadioButton* cT = + new BRadioButton(BRect(8, 47, 164, 64), "tr", "Transparent", new BMessage('colT')); + BRadioButton* cI = + new BRadioButton(BRect(8, 64, 164, 88), "im", "Original Image", new BMessage('colI')); + col->AddChild(cF); + col->AddChild(cB); + col->AddChild(cT); + col->AddChild(cI); + cB->SetValue(true); + } + + virtual ~WaveView() {} + + virtual void MessageReceived(BMessage* msg); }; -void WaveView::MessageReceived (BMessage *msg) +void +WaveView::MessageReceived(BMessage* msg) { - switch (msg->what) - { + switch (msg->what) { case 'wavP': - gPeriods = msg->FindFloat ("value"); + gPeriods = msg->FindFloat("value"); break; case 'wavA': - gAmplitude = msg->FindFloat ("value"); + gAmplitude = msg->FindFloat("value"); break; case 'wavF': - gPhase = msg->FindFloat ("value"); + gPhase = msg->FindFloat("value"); break; case 'dirH': gDirection = HORIZONTAL; @@ -98,83 +113,87 @@ void WaveView::MessageReceived (BMessage *msg) gColor = TRANSPARENT; break; default: - BView::MessageReceived (msg); + BView::MessageReceived(msg); return; } addon_preview(); } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "Wave"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 1998-2001 ∑ Sum Software"); - strcpy (info->description, "Applies a sinusoid wave effect"); - info->type = BECASSO_TRANSFORMER; - info->index = index; - info->version = 1; - info->release = 2; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = PREVIEW_FULLSCALE; - info->flags = 0; + strcpy(info->name, "Wave"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 1998-2001 ∑ Sum Software"); + strcpy(info->description, "Applies a sinusoid wave effect"); + info->type = BECASSO_TRANSFORMER; + info->index = index; + info->version = 1; + info->release = 2; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = PREVIEW_FULLSCALE; + info->flags = 0; return B_OK; } -status_t addon_close (void) +status_t +addon_close(void) { return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_make_config (BView **view, BRect rect) +status_t +addon_make_config(BView** view, BRect rect) { - *view = new WaveView (rect); + *view = new WaveView(rect); return B_OK; } -status_t process (Layer *inLayer, Selection *inSelection, - Layer **outLayer, Selection **outSelection, int32 mode, - BRect *frame, bool final, BPoint /* point */, uint32 /* buttons */) +status_t +process( + Layer* inLayer, Selection* inSelection, Layer** outLayer, Selection** outSelection, int32 mode, + BRect* frame, bool final, BPoint /* point */, uint32 /* buttons */ +) { int error = ADDON_OK; - if (*outLayer == NULL && mode== M_DRAW) - *outLayer = new Layer (*inLayer); - if (mode == M_SELECT) - { + if (*outLayer == NULL && mode == M_DRAW) + *outLayer = new Layer(*inLayer); + if (mode == M_SELECT) { if (inSelection) - *outSelection = new Selection (*inSelection); - else // No Selection to wave! + *outSelection = new Selection(*inSelection); + else // No Selection to wave! return (error); } if (*outLayer) (*outLayer)->Lock(); if (*outSelection) (*outSelection)->Lock(); - - if (mode == M_SELECT) - { + + if (mode == M_SELECT) { *frame = inSelection->Bounds(); } - int firstRow = int (frame->top); - int lastRow = int (frame->bottom); - int firstCol = int (frame->left); - int lastCol = int (frame->right); - + int firstRow = int(frame->top); + int lastRow = int(frame->bottom); + int firstCol = int(frame->left); + int lastCol = int(frame->right); + int w = inLayer->Bounds().IntegerWidth() + 1; int h = inLayer->Bounds().IntegerHeight() + 1; if (final) addon_start(); - + int direction = gDirection; float amplitude = gAmplitude; - float phase = gPhase*M_PI/180.0; + float phase = gPhase * M_PI / 180.0; float periods = gPeriods; int row, col; @@ -185,406 +204,330 @@ status_t process (Layer *inLayer, Selection *inSelection, c = highcolor(); else c.red = c.green = c.blue = c.alpha = 0; - + bool orig = (gColor == IMAGECOLOR); - - bgra_pixel bg = PIXEL (c.red, c.green, c.blue, c.alpha); - switch (mode) - { - case M_DRAW: - { - int pprs = inLayer->BytesPerRow()/4; - int pprd = (*outLayer)->BytesPerRow()/4; - bgra_pixel *s = (bgra_pixel *) inLayer->Bits() - 1; - bgra_pixel *d = (bgra_pixel *) (*outLayer)->Bits() - 1; + bgra_pixel bg = PIXEL(c.red, c.green, c.blue, c.alpha); + + switch (mode) { + case M_DRAW: { + int pprs = inLayer->BytesPerRow() / 4; + int pprd = (*outLayer)->BytesPerRow() / 4; + bgra_pixel* s = (bgra_pixel*)inLayer->Bits() - 1; + bgra_pixel* d = (bgra_pixel*)(*outLayer)->Bits() - 1; - if (direction == 0) /* Horizontal */ + if (direction == 0) /* Horizontal */ { - float delta = 100.0/(lastRow - firstRow); // For the Status Bar. - float iamp = amplitude*(lastCol - firstCol); - float pfac = periods/(lastRow - firstRow)*M_PI*2; - + float delta = 100.0 / (lastRow - firstRow); // For the Status Bar. + float iamp = amplitude * (lastCol - firstCol); + float pfac = periods / (lastRow - firstRow) * M_PI * 2; + for (row = 0; row < firstRow; row++) - memcpy (d + 1 + row*pprd, s + 1 + row*pprs, pprs*4); - - for (row = firstRow; row <= lastRow; row++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + memcpy(d + 1 + row * pprd, s + 1 + row * pprs, pprs * 4); + + for (row = firstRow; row <= lastRow; row++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } - float foffset = iamp*sin ((row - firstRow)*pfac + phase); - bgra_pixel *sl = s + row*pprs + 1; - bgra_pixel *dl = d + row*pprd + 1; - int offset = int (foffset); - uint8 ofac = uint8 (255*fabs (foffset - offset)); - if (foffset >= 0) // Shift right + float foffset = iamp * sin((row - firstRow) * pfac + phase); + bgra_pixel* sl = s + row * pprs + 1; + bgra_pixel* dl = d + row * pprd + 1; + int offset = int(foffset); + uint8 ofac = uint8(255 * fabs(foffset - offset)); + if (foffset >= 0) // Shift right { for (col = 0; col < firstCol; col++) *dl++ = *sl++; - - if (orig) - { + + if (orig) { for (col = firstCol; col < firstCol + offset; col++) *dl++ = *sl++; - } - else - { + } else { for (col = firstCol; col < firstCol + offset; col++) *dl++ = bg; } bgra_pixel a, b; - if (orig) - { + if (orig) { a = *sl; sl -= offset; - } - else + } else a = bg; b = *sl; - for (col = firstCol + offset; col <= lastCol; col++) - { - *dl++ = weighted_average (a, ofac, b, 255 - ofac); + for (col = firstCol + offset; col <= lastCol; col++) { + *dl++ = weighted_average(a, ofac, b, 255 - ofac); a = b; b = *sl++; } sl += offset; for (col = lastCol + 1; col < w; col++) *dl++ = *sl++; - } - else// if (0) // Shift left + } else // if (0) // Shift left { for (col = 0; col < firstCol; col++) *dl++ = *sl++; - + sl -= offset; bgra_pixel a, b; a = *sl++; b = a; - for (col = firstCol; col < lastCol + offset; col++) - { - *dl++ = weighted_average (b, ofac, a, 255 - ofac); + for (col = firstCol; col < lastCol + offset; col++) { + *dl++ = weighted_average(b, ofac, a, 255 - ofac); a = b; b = *sl++; } - if (orig) - { + if (orig) { sl += offset; - *dl++ = weighted_average (*sl, ofac, b, 255 - ofac); + *dl++ = weighted_average(*sl, ofac, b, 255 - ofac); for (col = lastCol + offset; col < lastCol; col++) *dl++ = *sl++; -// sl += offset; - } - else - { - *dl++ = weighted_average (bg, ofac, a, 255 - ofac); - for (col = lastCol + offset; col < lastCol; col++) - { + // sl += offset; + } else { + *dl++ = weighted_average(bg, ofac, a, 255 - ofac); + for (col = lastCol + offset; col < lastCol; col++) { *dl++ = bg; } } for (col = lastCol; col < w; col++) *dl++ = *sl++; } -// else // zero crossing -// { -// for (col = 0; col < w; col++) -// *(++dl) = *(++sl); -// } - } - else // !final + // else // zero crossing + // { + // for (col = 0; col < w; col++) + // *(++dl) = *(++sl); + // } + } else // !final { - int32 offset = int32 (iamp*sin ((row - firstRow)*pfac + phase)); - bgra_pixel *sl = s + row*pprs; - bgra_pixel *dl = d + row*pprd; - if (offset > 0) // Shift right + int32 offset = int32(iamp * sin((row - firstRow) * pfac + phase)); + bgra_pixel* sl = s + row * pprs; + bgra_pixel* dl = d + row * pprd; + if (offset > 0) // Shift right { for (col = 0; col < firstCol; col++) *(++dl) = *(++sl); - if (orig) - { - for (col = firstCol; col < firstCol + offset; col++) - { + if (orig) { + for (col = firstCol; col < firstCol + offset; col++) { *(++dl) = *(++sl); } sl -= offset; - } - else - { - for (col = firstCol; col < firstCol + offset; col++) - { + } else { + for (col = firstCol; col < firstCol + offset; col++) { *(++dl) = bg; } } /* Following breaks when firstCol > offset, actually... */ /* If this can happen, do something smart with max_c. */ - for (col = firstCol + offset; col < lastCol; col++) - { + for (col = firstCol + offset; col < lastCol; col++) { *(++dl) = *(++sl); } sl += offset; - for (col = lastCol; col < w; col++) - { + for (col = lastCol; col < w; col++) { *(++dl) = *(++sl); } - } - else // Shift left + } else // Shift left { for (col = 0; col < firstCol; col++) *(++dl) = *(++sl); - + sl -= offset; - - for (col = firstCol; col < lastCol + offset; col++) - { + + for (col = firstCol; col < lastCol + offset; col++) { *(++dl) = *(++sl); } - if (orig) - { + if (orig) { sl += offset; - for (col = lastCol + offset; col <= lastCol; col++) - { + for (col = lastCol + offset; col <= lastCol; col++) { *(++dl) = *(++sl); } - //sl += offset; - } - else - { - for (col = lastCol + offset; col < lastCol; col++) - { + // sl += offset; + } else { + for (col = lastCol + offset; col < lastCol; col++) { *(++dl) = bg; } } - for (col = lastCol + offset; col < w; col++) - { + for (col = lastCol + offset; col < w; col++) { *(++dl) = *(++sl); } } } } for (row = lastRow + 1; row < h; row++) - memcpy (d + 1 + row*pprd, s + 1 + row*pprs, pprs*4); - } - else /* Vertical */ + memcpy(d + 1 + row * pprd, s + 1 + row * pprs, pprs * 4); + } else /* Vertical */ { - float delta = 100.0/(lastCol - firstCol); // For the Status Bar. - float iamp = amplitude*(lastRow - firstRow); - float pfac = periods/(lastCol - firstCol)*M_PI*2; - - for (col = 0; col < firstCol; col++) - { - bgra_pixel *sl = s + col + 1; - bgra_pixel *dl = d + col + 1; - for (row = 0; row < h; row++) - { + float delta = 100.0 / (lastCol - firstCol); // For the Status Bar. + float iamp = amplitude * (lastRow - firstRow); + float pfac = periods / (lastCol - firstCol) * M_PI * 2; + + for (col = 0; col < firstCol; col++) { + bgra_pixel* sl = s + col + 1; + bgra_pixel* dl = d + col + 1; + for (row = 0; row < h; row++) { *dl = *sl; dl += pprd; sl += pprs; } } - - for (col = firstCol; col <= lastCol + 1; col++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + + for (col = firstCol; col <= lastCol + 1; col++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } - float foffset = -iamp*sin ((col - firstCol)*pfac + phase); - bgra_pixel *sl = s + col + 1; - bgra_pixel *dl = d + col + 1; - int offset = int (foffset); - uint8 ofac = uint8 (255*(foffset - offset)); - if (foffset > 0) // Shift down + float foffset = -iamp * sin((col - firstCol) * pfac + phase); + bgra_pixel* sl = s + col + 1; + bgra_pixel* dl = d + col + 1; + int offset = int(foffset); + uint8 ofac = uint8(255 * (foffset - offset)); + if (foffset > 0) // Shift down { - for (row = 0; row < firstRow; row++) - { + for (row = 0; row < firstRow; row++) { *dl = *sl; dl += pprd; sl += pprs; } - if (orig) - { - for (row = firstRow; row < firstRow + offset; row++) - { + if (orig) { + for (row = firstRow; row < firstRow + offset; row++) { *dl = *sl; dl += pprd; sl += pprs; } - sl -= offset*pprs; - } - else - { - for (row = firstRow; row < firstRow + offset; row++) - { + sl -= offset * pprs; + } else { + for (row = firstRow; row < firstRow + offset; row++) { *dl = bg; dl += pprd; } } bgra_pixel a, b; - if (orig) - { + if (orig) { a = *sl; - //sl -= pprs; - } - else + // sl -= pprs; + } else a = bg; b = *sl; - for (row = firstRow + offset; row <= lastRow; row++) - { - *dl = weighted_average (a, ofac, b, 255 - ofac); + for (row = firstRow + offset; row <= lastRow; row++) { + *dl = weighted_average(a, ofac, b, 255 - ofac); a = b; b = *sl; dl += pprd; sl += pprs; } - sl += offset*pprs; - for (row = lastRow + 1; row < h; row++) - { + sl += offset * pprs; + for (row = lastRow + 1; row < h; row++) { *dl = *sl; dl += pprd; sl += pprs; } - } - else // if (foffset < 0) // Shift up + } else // if (foffset < 0) // Shift up { - for (row = 0; row < firstRow; row++) - { + for (row = 0; row < firstRow; row++) { *dl = *sl; dl += pprd; sl += pprs; } - sl -= offset*pprs; + sl -= offset * pprs; bgra_pixel a, b; a = *sl; sl += pprs; b = a; - for (row = firstRow; row < lastRow + offset; row++) - { - *dl = weighted_average (a, ofac, b, 255 - ofac); + for (row = firstRow; row < lastRow + offset; row++) { + *dl = weighted_average(a, ofac, b, 255 - ofac); a = b; b = *sl; dl += pprd; sl += pprs; } - if (orig) - { - sl += offset*pprs; - *dl = weighted_average (*sl, ofac, b, 255 - ofac); + if (orig) { + sl += offset * pprs; + *dl = weighted_average(*sl, ofac, b, 255 - ofac); dl += pprd; - for (row = lastRow + offset + 1; row <= lastRow; row++) - { + for (row = lastRow + offset + 1; row <= lastRow; row++) { *dl = *sl; dl += pprd; sl += pprs; } - } - else - { - *dl = weighted_average (a, ofac, bg, 255 - ofac); + } else { + *dl = weighted_average(a, ofac, bg, 255 - ofac); dl += pprd; - for (row = lastRow + offset + 1; row <= lastRow; row++) - { + for (row = lastRow + offset + 1; row <= lastRow; row++) { *dl = bg; dl += pprd; } } - for (row = lastRow + 1; row < h; row++) - { + for (row = lastRow + 1; row < h; row++) { *dl = *sl; dl += pprd; sl += pprs; } } - } - else // !final + } else // !final { - int32 offset = int32 (-iamp*sin ((col - firstCol)*pfac + phase)); - bgra_pixel *sl = s + col + 1; - bgra_pixel *dl = d + col + 1; - if (offset > 0) // Shift down + int32 offset = int32(-iamp * sin((col - firstCol) * pfac + phase)); + bgra_pixel* sl = s + col + 1; + bgra_pixel* dl = d + col + 1; + if (offset > 0) // Shift down { - for (row = 0; row < firstRow; row++) - { + for (row = 0; row < firstRow; row++) { *dl = *sl; dl += pprd; sl += pprs; } - if (orig) - { - for (row = firstRow; row < firstRow + offset; row++) - { + if (orig) { + for (row = firstRow; row < firstRow + offset; row++) { *dl = *sl; dl += pprd; sl += pprs; } - sl -= offset*pprs; - } - else - { - for (row = firstRow; row < firstRow + offset; row++) - { + sl -= offset * pprs; + } else { + for (row = firstRow; row < firstRow + offset; row++) { *dl = bg; dl += pprd; } } - for (row = firstRow + offset; row <= lastRow; row++) - { + for (row = firstRow + offset; row <= lastRow; row++) { *dl = *sl; dl += pprd; sl += pprs; } - sl += offset*pprs; - for (row = lastRow + 1; row < h; row++) - { + sl += offset * pprs; + for (row = lastRow + 1; row < h; row++) { *dl = *sl; dl += pprd; sl += pprs; } - } - else // Shift up + } else // Shift up { - for (row = 0; row < firstRow; row++) - { + for (row = 0; row < firstRow; row++) { *dl = *sl; dl += pprd; sl += pprs; } - sl -= offset*pprs; - for (row = firstRow; row <= lastRow + offset; row++) - { + sl -= offset * pprs; + for (row = firstRow; row <= lastRow + offset; row++) { *dl = *sl; dl += pprd; sl += pprs; } - if (orig) - { - sl += offset*pprs; - for (row = lastRow + offset + 1; row <= lastRow; row++) - { + if (orig) { + sl += offset * pprs; + for (row = lastRow + offset + 1; row <= lastRow; row++) { *dl = *sl; dl += pprd; sl += pprs; } - } - else - { - for (row = lastRow + offset + 1; row <= lastRow; row++) - { + } else { + for (row = lastRow + offset + 1; row <= lastRow; row++) { *dl = bg; dl += pprd; } } - for (row = lastRow + 1; row < h; row ++) - { + for (row = lastRow + 1; row < h; row++) { *dl = *sl; dl += pprd; sl += pprs; @@ -593,12 +536,10 @@ status_t process (Layer *inLayer, Selection *inSelection, } } - for (col = lastCol + 1; col < w; col++) - { - bgra_pixel *sl = s + col + 1; - bgra_pixel *dl = d + col + 1; - for (row = 0; row < h; row++) - { + for (col = lastCol + 1; col < w; col++) { + bgra_pixel* sl = s + col + 1; + bgra_pixel* dl = d + col + 1; + for (row = 0; row < h; row++) { *dl = *sl; dl += pprd; sl += pprs; @@ -607,211 +548,169 @@ status_t process (Layer *inLayer, Selection *inSelection, } break; } - case M_SELECT: - { + case M_SELECT: { int pprs = inSelection->BytesPerRow(); int pprd = (*outSelection)->BytesPerRow(); - grey_pixel *s = (grey_pixel *) inSelection->Bits() - 1; - grey_pixel *d = (grey_pixel *) (*outSelection)->Bits() - 1; + grey_pixel* s = (grey_pixel*)inSelection->Bits() - 1; + grey_pixel* d = (grey_pixel*)(*outSelection)->Bits() - 1; - if (direction == 0) /* Horizontal */ + if (direction == 0) /* Horizontal */ { - float delta = 100.0/(lastRow - firstRow); // For the Status Bar. - float iamp = amplitude*(lastCol - firstCol); - float pfac = periods/(lastRow - firstRow)*M_PI*2; - + float delta = 100.0 / (lastRow - firstRow); // For the Status Bar. + float iamp = amplitude * (lastCol - firstCol); + float pfac = periods / (lastRow - firstRow) * M_PI * 2; + for (row = 0; row < firstRow; row++) - memcpy (d + 1 + row*pprd, s + 1 + row*pprs, pprs); - - for (row = firstRow; row <= lastRow; row++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + memcpy(d + 1 + row * pprd, s + 1 + row * pprs, pprs); + + for (row = firstRow; row <= lastRow; row++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - int32 offset = int32 (iamp*sin ((row - firstRow)*pfac + phase)); - grey_pixel *sl = s + row*pprs; - grey_pixel *dl = d + row*pprd; - if (offset > 0) // Shift right + int32 offset = int32(iamp * sin((row - firstRow) * pfac + phase)); + grey_pixel* sl = s + row * pprs; + grey_pixel* dl = d + row * pprd; + if (offset > 0) // Shift right { for (col = 0; col < firstCol; col++) *(++dl) = *(++sl); - if (orig) - { - for (col = firstCol; col < firstCol + offset; col++) - { + if (orig) { + for (col = firstCol; col < firstCol + offset; col++) { *(++dl) = *(++sl); } sl -= offset; - } - else - { - for (col = firstCol; col < firstCol + offset; col++) - { + } else { + for (col = firstCol; col < firstCol + offset; col++) { *(++dl) = bg; } } /* Following breaks when firstCol > offset, actually... */ /* If this can happen, do something smart with max_c. */ - for (col = firstCol + offset; col < lastCol; col++) - { + for (col = firstCol + offset; col < lastCol; col++) { *(++dl) = *(++sl); } sl += offset; - for (col = lastCol; col < w; col++) - { + for (col = lastCol; col < w; col++) { *(++dl) = *(++sl); } - } - else // Shift left + } else // Shift left { for (col = 0; col < firstCol; col++) *(++dl) = *(++sl); - + sl -= offset; - - for (col = firstCol; col < lastCol + offset; col++) - { + + for (col = firstCol; col < lastCol + offset; col++) { *(++dl) = *(++sl); } - if (orig) - { + if (orig) { sl += offset; - for (col = lastCol + offset; col <= lastCol; col++) - { + for (col = lastCol + offset; col <= lastCol; col++) { *(++dl) = *(++sl); } - //sl += offset; - } - else - { - for (col = lastCol + offset; col < lastCol; col++) - { + // sl += offset; + } else { + for (col = lastCol + offset; col < lastCol; col++) { *(++dl) = bg; } } - for (col = lastCol + offset; col < w; col++) - { + for (col = lastCol + offset; col < w; col++) { *(++dl) = *(++sl); } } } for (row = lastRow + 1; row < h; row++) - memcpy (d + 1 + row*pprd, s + 1 + row*pprs, pprs*4); - } - else /* Vertical */ + memcpy(d + 1 + row * pprd, s + 1 + row * pprs, pprs * 4); + } else /* Vertical */ { - float delta = 100.0/(lastCol - firstCol); // For the Status Bar. - float iamp = amplitude*(lastRow - firstRow); - float pfac = periods/(lastCol - firstCol)*M_PI*2; - - for (col = 0; col < firstCol; col++) - { - grey_pixel *sl = s + col + 1; - grey_pixel *dl = d + col + 1; - for (row = 0; row < h; row++) - { + float delta = 100.0 / (lastCol - firstCol); // For the Status Bar. + float iamp = amplitude * (lastRow - firstRow); + float pfac = periods / (lastCol - firstCol) * M_PI * 2; + + for (col = 0; col < firstCol; col++) { + grey_pixel* sl = s + col + 1; + grey_pixel* dl = d + col + 1; + for (row = 0; row < h; row++) { *dl = *sl; dl += pprd; sl += pprs; } } - - for (col = firstCol; col <= lastCol + 1; col++) - { - if (final) - { - addon_update_statusbar (delta); - if (addon_stop()) - { + + for (col = firstCol; col <= lastCol + 1; col++) { + if (final) { + addon_update_statusbar(delta); + if (addon_stop()) { error = ADDON_ABORT; break; } } - int32 offset = int32 (-iamp*sin ((col - firstCol)*pfac + phase)); - grey_pixel *sl = s + col + 1; - grey_pixel *dl = d + col + 1; - if (offset > 0) // Shift down + int32 offset = int32(-iamp * sin((col - firstCol) * pfac + phase)); + grey_pixel* sl = s + col + 1; + grey_pixel* dl = d + col + 1; + if (offset > 0) // Shift down { - for (row = 0; row < firstRow; row++) - { + for (row = 0; row < firstRow; row++) { *dl = *sl; dl += pprd; sl += pprs; } - if (orig) - { - for (row = firstRow; row < firstRow + offset; row++) - { + if (orig) { + for (row = firstRow; row < firstRow + offset; row++) { *dl = *sl; dl += pprd; sl += pprs; } - sl -= offset*pprs; - } - else - { - for (row = firstRow; row < firstRow + offset; row++) - { + sl -= offset * pprs; + } else { + for (row = firstRow; row < firstRow + offset; row++) { *dl = bg; dl += pprd; } } - for (row = firstRow + offset; row <= lastRow; row++) - { + for (row = firstRow + offset; row <= lastRow; row++) { *dl = *sl; dl += pprd; sl += pprs; } - sl += offset*pprs; - for (row = lastRow + 1; row < h; row++) - { + sl += offset * pprs; + for (row = lastRow + 1; row < h; row++) { *dl = *sl; dl += pprd; sl += pprs; } - } - else // Shift up + } else // Shift up { - for (row = 0; row < firstRow; row++) - { + for (row = 0; row < firstRow; row++) { *dl = *sl; dl += pprd; sl += pprs; } - sl -= offset*pprs; - for (row = firstRow; row <= lastRow + offset; row++) - { + sl -= offset * pprs; + for (row = firstRow; row <= lastRow + offset; row++) { *dl = *sl; dl += pprd; sl += pprs; } - if (orig) - { - sl += offset*pprs; - for (row = lastRow + offset + 1; row <= lastRow; row++) - { + if (orig) { + sl += offset * pprs; + for (row = lastRow + offset + 1; row <= lastRow; row++) { *dl = *sl; dl += pprd; sl += pprs; } - } - else - { - for (row = lastRow + offset + 1; row <= lastRow; row++) - { + } else { + for (row = lastRow + offset + 1; row <= lastRow; row++) { *dl = bg; dl += pprd; } } - for (row = lastRow + 1; row < h; row ++) - { + for (row = lastRow + 1; row < h; row++) { *dl = *sl; dl += pprd; sl += pprs; @@ -819,12 +718,10 @@ status_t process (Layer *inLayer, Selection *inSelection, } } - for (col = lastCol + 1; col < w; col++) - { - grey_pixel *sl = s + col + 1; - grey_pixel *dl = d + col + 1; - for (row = 0; row < h; row++) - { + for (col = lastCol + 1; col < w; col++) { + grey_pixel* sl = s + col + 1; + grey_pixel* dl = d + col + 1; + for (row = 0; row < h; row++) { *dl = *sl; dl += pprd; sl += pprs; @@ -834,7 +731,7 @@ status_t process (Layer *inLayer, Selection *inSelection, break; } default: - fprintf (stderr, "Blur: Unknown mode\n"); + fprintf(stderr, "Blur: Unknown mode\n"); error = ADDON_UNKNOWN; } diff --git a/source/add-ons/WinGrab/WinGrab.cpp b/source/add-ons/WinGrab/WinGrab.cpp index 5acd0c8..d6a0d11 100644 --- a/source/add-ons/WinGrab/WinGrab.cpp +++ b/source/add-ons/WinGrab/WinGrab.cpp @@ -18,175 +18,224 @@ class CaptureWindow : public BWindow { -public: - CaptureWindow (BRect rect) : BWindow (rect, "WinGrab", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK) {}; -virtual ~CaptureWindow () {}; -virtual bool QuitRequested () { Hide(); return false; }; - -int fIndex; -BCheckBox *fActivateCB; -BCheckBox *fBorderCB; + public: + CaptureWindow(BRect rect) + : BWindow( + rect, "WinGrab", B_TITLED_WINDOW, + B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK + ){}; + virtual ~CaptureWindow(){}; + + virtual bool QuitRequested() + { + Hide(); + return false; + }; + + int fIndex; + BCheckBox* fActivateCB; + BCheckBox* fBorderCB; }; -CaptureWindow *window; -BMessenger theGrabbee; +CaptureWindow* window; +BMessenger theGrabbee; -status_t window_for_messenger (BMessenger mgr, BMessenger *window, BLooper *us); -status_t recurse_views (BMessenger view, BMessenger mgr, BMessenger *result); -const char *nstr (char *d, const char *s, const int n); +status_t +window_for_messenger(BMessenger mgr, BMessenger* window, BLooper* us); +status_t +recurse_views(BMessenger view, BMessenger mgr, BMessenger* result); +const char* +nstr(char* d, const char* s, const int n); class GrabView : public BView { -public: - GrabView (BRect rect, const char *name) - : BView (rect, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW) - { - fCamera = new BBitmap (BRect (0, 0, 31, 31), B_COLOR_8_BIT); - uchar data[32*32] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x06, 0x00, 0x06, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0b, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x2c, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x2a, 0x2a, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x09, 0x2c, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x05, 0x05, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x05, 0x05, 0x05, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x05, 0x05, 0x05, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x05, 0x05, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x07, 0x07, 0x07, 0x07, 0x00, 0x07, 0x0f, 0x0f, 0x09, 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x07, 0x05, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x07, 0x07, 0x07, 0x0a, 0x0a, 0x0c, 0x07, 0x07, 0x0f, 0x09, 0x09, 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x07, 0x0c, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x09, 0x40, 0x09, 0x00, 0x0f, 0x0f, 0x0f, 0x0c, 0x08, 0x07, 0x07, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0x40, 0x40, 0x40, 0x40, 0x07, 0x0f, 0x0f, 0x0f, 0x07, 0x00, 0x09, 0x40, 0x40, 0x09, 0x00, 0x0b, 0x00, 0x06, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x09, 0xff, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x09, 0x3f, 0x40, 0x40, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x00, 0x40, 0x3f, 0x40, 0x40, 0x40, 0x40, 0x06, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x09, 0x3f, 0x40, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x00, 0x40, 0x3f, 0x40, 0x40, 0x40, 0x40, 0x00, 0x0f, 0x0b, 0x07, 0x00, 0x0f, 0x0f, 0x09, 0x3f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x06, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x0b, 0x07, 0x07, 0x00, 0x0f, 0x0f, 0x0f, 0x09, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x07, 0x07, 0x00, 0x09, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x09, 0x40, 0x40, 0x40, 0x40, 0x40, 0x0f, 0x00, 0x00, 0x09, 0x09, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x09, 0x09, 0x40, 0x40, 0x40, 0x00, 0xff, 0xff, 0xff, 0x00, 0x09, 0x09, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x00, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x09, 0x07, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff - }; - uint8 *dp = (uint8 *) fCamera->Bits(); - for (int32 i = 0; i < 32*32; i++) - { - *dp++ = data[i]; - } - } - ~GrabView () {} -virtual void Draw (BRect update); -virtual void MouseDown (BPoint point); -virtual void MessageReceived (BMessage *msg); - -private: -typedef BView inherited; -BBitmap *fCamera; -}; + public: + GrabView(BRect rect, const char* name) + : BView(rect, name, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW) + { + fCamera = new BBitmap(BRect(0, 0, 31, 31), B_COLOR_8_BIT); + uchar data[32 * 32] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x0f, 0x06, 0x00, 0x06, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x0b, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x00, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x2c, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x2a, 0x2a, 0x0f, + 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x0f, 0x09, 0x2c, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x05, 0x05, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x05, 0x05, 0x05, 0x09, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x05, 0x05, 0x05, + 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, + 0x0f, 0x08, 0x05, 0x05, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x07, 0x07, 0x07, 0x07, 0x00, 0x07, 0x0f, + 0x0f, 0x09, 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x07, 0x05, 0x0f, 0x0f, 0x09, 0x00, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x07, 0x07, 0x07, 0x0a, + 0x0a, 0x0c, 0x07, 0x07, 0x0f, 0x09, 0x09, 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x0f, 0x0f, + 0x0f, 0x0f, 0x00, 0x0b, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x00, 0x07, 0x0c, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x09, 0x40, 0x09, 0x00, 0x0f, + 0x0f, 0x0f, 0x0c, 0x08, 0x07, 0x07, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x40, 0x40, 0x40, 0x40, 0x07, 0x0f, 0x0f, 0x0f, 0x07, 0x00, 0x09, + 0x40, 0x40, 0x09, 0x00, 0x0b, 0x00, 0x06, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x09, 0xff, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x0f, 0x0f, + 0x0f, 0x0f, 0x00, 0x09, 0x3f, 0x40, 0x40, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, + 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x40, 0x3f, 0x40, 0x40, + 0x40, 0x40, 0x06, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x09, 0x3f, 0x40, 0x0f, 0x00, 0x0b, + 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x40, 0x3f, 0x40, 0x40, 0x40, 0x40, 0x00, 0x0f, 0x0b, 0x07, 0x00, 0x0f, 0x0f, 0x09, + 0x3f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x06, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x0b, 0x07, 0x07, + 0x00, 0x0f, 0x0f, 0x0f, 0x09, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, + 0x00, 0x07, 0x07, 0x00, 0x09, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, + 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x09, 0x40, + 0x40, 0x40, 0x40, 0x40, 0x0f, 0x00, 0x00, 0x09, 0x09, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x09, 0x09, 0x40, 0x40, 0x40, 0x00, 0xff, 0xff, 0xff, 0x00, 0x09, 0x09, + 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x00, 0x09, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x09, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, + 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, + 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, + 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x00, 0x09, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, 0x00, 0x0b, 0x09, 0x09, + 0x08, 0x08, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x09, 0x07, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff + }; + uint8* dp = (uint8*)fCamera->Bits(); + for (int32 i = 0; i < 32 * 32; i++) { + *dp++ = data[i]; + } + } + + ~GrabView() {} + virtual void Draw(BRect update); + virtual void MouseDown(BPoint point); + virtual void MessageReceived(BMessage* msg); + + private: + typedef BView inherited; + BBitmap* fCamera; +}; -void GrabView::MouseDown (BPoint /*point*/) +void +GrabView::MouseDown(BPoint /*point*/) { - BBitmap *dragmap = new BBitmap (fCamera); - BMessage *dragmsg = new BMessage (B_GET_PROPERTY); - dragmsg->AddSpecifier ("Window"); - DragMessage (dragmsg, dragmap, B_OP_OVER, BPoint (15, 15)); + BBitmap* dragmap = new BBitmap(fCamera); + BMessage* dragmsg = new BMessage(B_GET_PROPERTY); + dragmsg->AddSpecifier("Window"); + DragMessage(dragmsg, dragmap, B_OP_OVER, BPoint(15, 15)); delete dragmsg; } -const char *nstr (char *d, const char *s, const int n) +const char* +nstr(char* d, const char* s, const int n) { d[0] = 0; for (int i = 0; i < n; i++) - strcat (d, s); + strcat(d, s); return d; } #define MAX_DEPTH 64 -status_t recurse_views (BMessenger view, BMessenger mgr, BMessenger *result) +status_t +recurse_views(BMessenger view, BMessenger mgr, BMessenger* result) { static int depth = 0; static bool found = false; static int viewnumber[MAX_DEPTH]; - + // printf ("Entering depth %d\n", depth); depth++; BMessage reply; - BMessage *msg = NULL; - - msg = new BMessage (B_GET_PROPERTY); - msg->AddSpecifier ("InternalName"); + BMessage* msg = NULL; + + msg = new BMessage(B_GET_PROPERTY); + msg->AddSpecifier("InternalName"); for (int i = depth - 2; i >= 0; i--) - msg->AddSpecifier ("View", viewnumber[i]); + msg->AddSpecifier("View", viewnumber[i]); - view.SendMessage (msg, &reply); + view.SendMessage(msg, &reply); delete msg; - -// char indent[80]; -// printf ("%sInternal Name: %s ", nstr (indent, " ", depth), reply.FindString ("result")); -// fflush (stdout); - if (view == mgr) - { + // char indent[80]; + // printf ("%sInternal Name: %s ", nstr (indent, " ", depth), reply.FindString ("result")); + // fflush (stdout); + + if (view == mgr) { *result = view; -// printf ("Found!\n"); + // printf ("Found!\n"); found = true; depth--; - return B_OK; // Found it + return B_OK; // Found it } - + // Check the children of the view int num_views; - msg = new BMessage (B_COUNT_PROPERTIES); - msg->AddSpecifier ("View"); - for (int i = depth - 2; i >= 0; i--) - { - msg->AddSpecifier ("View", viewnumber[i]); - } - view.SendMessage (msg, &reply); + msg = new BMessage(B_COUNT_PROPERTIES); + msg->AddSpecifier("View"); + for (int i = depth - 2; i >= 0; i--) { + msg->AddSpecifier("View", viewnumber[i]); + } + view.SendMessage(msg, &reply); delete msg; - num_views = reply.FindInt32 ("result"); -// printf ("(%i Children)\n", num_views); - - for (int j = 0; j < num_views; j++) - { -// printf ("[%i]", j); fflush (stdout); + num_views = reply.FindInt32("result"); + // printf ("(%i Children)\n", num_views); + + for (int j = 0; j < num_views; j++) { + // printf ("[%i]", j); fflush (stdout); BMessenger theview; - msg = new BMessage (B_GET_PROPERTY); + msg = new BMessage(B_GET_PROPERTY); viewnumber[depth - 1] = j; - - for (int i = depth - 1; i >= 0; i--) - { - msg->AddSpecifier ("View", viewnumber[i]); + + for (int i = depth - 1; i >= 0; i--) { + msg->AddSpecifier("View", viewnumber[i]); } - view.SendMessage (msg, &reply); + view.SendMessage(msg, &reply); delete msg; - reply.FindMessenger ("result", &theview); - - if (mgr == theview) - { + reply.FindMessenger("result", &theview); + + if (mgr == theview) { *result = theview; -// printf ("It's a kid...\n"); + // printf ("It's a kid...\n"); found = true; depth--; return B_OK; - } - else - { - if (recurse_views (view, mgr, result) == B_OK) - { -// printf ("Found in a kid\n"); + } else { + if (recurse_views(view, mgr, result) == B_OK) { + // printf ("Found in a kid\n"); depth--; return B_OK; } @@ -197,280 +246,278 @@ status_t recurse_views (BMessenger view, BMessenger mgr, BMessenger *result) return B_ERROR; } -status_t window_for_messenger (BMessenger mgr, BMessenger *window, BLooper *us) +status_t +window_for_messenger(BMessenger mgr, BMessenger* window, BLooper* us) { - BMessage *msg = new BMessage (B_GET_SUPPORTED_SUITES); + BMessage* msg = new BMessage(B_GET_SUPPORTED_SUITES); BMessage reply; // Check to see if it ain't us ourselves..! - BLooper *looper; - mgr.Target (&looper); + BLooper* looper; + mgr.Target(&looper); if (looper == us) return B_ERROR; - - mgr.SendMessage (msg, &reply); + + mgr.SendMessage(msg, &reply); delete msg; int i = 0; - const char *suite; + const char* suite; bool supported = false; - while (reply.FindString ("suites", i++, &suite) == B_OK) - { - if (!strcmp (suite, "suite/vnd.Be-window")) + while (reply.FindString("suites", i++, &suite) == B_OK) { + if (!strcmp(suite, "suite/vnd.Be-window")) supported = true; } - - if (supported) // The thing _is_ a window! + + if (supported) // The thing _is_ a window! { *window = mgr; return B_OK; } - - msg = new BMessage (B_GET_PROPERTY); - msg->AddSpecifier ("InternalName"); - mgr.SendMessage (msg, &reply); + + msg = new BMessage(B_GET_PROPERTY); + msg->AddSpecifier("InternalName"); + mgr.SendMessage(msg, &reply); delete msg; -// printf ("Internal name: %s\n", reply.FindString ("result")); - + // printf ("Internal name: %s\n", reply.FindString ("result")); + // Alas. Walk along all the windows of the app, and compare BMessengers of // all the views within those. It sucks, but such is life. team_id team = mgr.Team(); - - BMessenger app (NULL, team); - msg = new BMessage (B_COUNT_PROPERTIES); - msg->AddSpecifier ("Window"); - app.SendMessage (msg, &reply); + + BMessenger app(NULL, team); + msg = new BMessage(B_COUNT_PROPERTIES); + msg->AddSpecifier("Window"); + app.SendMessage(msg, &reply); delete msg; - - int num_windows = reply.FindInt32 ("result"); - -// printf ("This app has %i windows\n", num_windows); - for (int i = 0; i < num_windows; i++) - { - if (looper // The camera was dropped on one of our own windows, so tread with caution... - && be_app->WindowAt(i)->Looper() == us) - { + + int num_windows = reply.FindInt32("result"); + + // printf ("This app has %i windows\n", num_windows); + for (int i = 0; i < num_windows; i++) { + if (looper // The camera was dropped on one of our own windows, so tread with caution... + && be_app->WindowAt(i)->Looper() == us) { // skip this one - } - else - { + } else { BMessenger thewin; - msg = new BMessage (B_GET_PROPERTY); - msg->AddSpecifier ("Window", i); - app.SendMessage (msg, &reply); + msg = new BMessage(B_GET_PROPERTY); + msg->AddSpecifier("Window", i); + app.SendMessage(msg, &reply); delete msg; - reply.FindMessenger ("result", &thewin); - + reply.FindMessenger("result", &thewin); + int num_views; - msg = new BMessage (B_COUNT_PROPERTIES); - msg->AddSpecifier ("View"); - thewin.SendMessage (msg, &reply); + msg = new BMessage(B_COUNT_PROPERTIES); + msg->AddSpecifier("View"); + thewin.SendMessage(msg, &reply); delete msg; - num_views = reply.FindInt32 ("result"); - - msg = new BMessage (B_GET_PROPERTY); - msg->AddSpecifier ("Title"); - thewin.SendMessage (msg, &reply); + num_views = reply.FindInt32("result"); + + msg = new BMessage(B_GET_PROPERTY); + msg->AddSpecifier("Title"); + thewin.SendMessage(msg, &reply); delete msg; - -// printf ("Window %i (%s) has %i view(s)\n", i, reply.FindString ("result"), num_views); - for (int j = 0; j < num_views; j++) - { + + // printf ("Window %i (%s) has %i view(s)\n", i, reply.FindString ("result"), + // num_views); + for (int j = 0; j < num_views; j++) { BMessenger theview; - msg = new BMessage (B_GET_PROPERTY); - msg->AddSpecifier ("View", j); - thewin.SendMessage (msg, &reply); + msg = new BMessage(B_GET_PROPERTY); + msg->AddSpecifier("View", j); + thewin.SendMessage(msg, &reply); delete msg; - reply.FindMessenger ("result", &theview); - + reply.FindMessenger("result", &theview); + BMessenger result; - if (recurse_views (theview, mgr, &result) == B_OK) - { + if (recurse_views(theview, mgr, &result) == B_OK) { *window = thewin; return B_OK; } } } - } + } -// printf ("Not found!\n"); + // printf ("Not found!\n"); beep(); return B_ERROR; } -void GrabView::MessageReceived (BMessage *msg) +void +GrabView::MessageReceived(BMessage* msg) { - switch (msg->what) - { -// case 'Bdrg': -// break; - case B_MESSAGE_NOT_UNDERSTOOD: - { -// printf ("Message not understood by target...\n"); + switch (msg->what) { + // case 'Bdrg': + // break; + case B_MESSAGE_NOT_UNDERSTOOD: { + // printf ("Message not understood by target...\n"); BMessenger grabtarget = msg->ReturnAddress(); - if (grabtarget.IsValid()) - { + if (grabtarget.IsValid()) { BMessage reply; - BMessage *msg = new BMessage (B_GET_PROPERTY); - msg->AddSpecifier ("Title"); - grabtarget.SendMessage (msg, &reply); + BMessage* msg = new BMessage(B_GET_PROPERTY); + msg->AddSpecifier("Title"); + grabtarget.SendMessage(msg, &reply); reply.PrintToStream(); delete msg; } break; } - case B_REPLY: - { + case B_REPLY: { BMessenger AppWindow; - if (msg->FindMessenger ("result", &AppWindow) == B_OK) - { - if (window_for_messenger (AppWindow, &theGrabbee, Window()) == B_OK) - { - BMessage *msg = new BMessage (CAPTURE_READY); - msg->AddInt32 ("index", window->fIndex); - be_app->PostMessage (msg); + if (msg->FindMessenger("result", &AppWindow) == B_OK) { + if (window_for_messenger(AppWindow, &theGrabbee, Window()) == B_OK) { + BMessage* msg = new BMessage(CAPTURE_READY); + msg->AddInt32("index", window->fIndex); + be_app->PostMessage(msg); delete msg; - } - else - printf ("Couldn't find the window.\n"); + } else + printf("Couldn't find the window.\n"); } break; } case 'actv': -// printf ("Activate\n"); + // printf ("Activate\n"); break; case 'brdr': -// printf ("Border\n"); + // printf ("Border\n"); break; default: msg->PrintToStream(); - inherited::MessageReceived (msg); + inherited::MessageReceived(msg); } } -void GrabView::Draw (BRect update) +void +GrabView::Draw(BRect update) { - SetLowColor (218, 218, 218); - FillRect (update, B_SOLID_LOW); - SetDrawingMode (B_OP_OVER); - DrawBitmap (fCamera); + SetLowColor(218, 218, 218); + FillRect(update, B_SOLID_LOW); + SetDrawingMode(B_OP_OVER); + DrawBitmap(fCamera); } -status_t addon_init (uint32 index, becasso_addon_info *info) +status_t +addon_init(uint32 index, becasso_addon_info* info) { - strcpy (info->name, "WinGrab"); - strcpy (info->author, "Sander Stoks"); - strcpy (info->copyright, "© 2000-2001 ∑ Sum Software"); - strcpy (info->description, "Grab a screen shot of a window"); - info->type = BECASSO_CAPTURE; - info->index = index; - info->version = 0; - info->release = 2; - info->becasso_version = 2; - info->becasso_release = 0; - info->does_preview = true; - BRect rect (100, 180, 100 + 188, 180 + 72); - window = new CaptureWindow (rect); - rect.OffsetTo (B_ORIGIN); - BView *bg = new BView (rect, "bg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); - bg->SetViewColor (LightGrey); - window->AddChild (bg); -// BMessage *msg = new BMessage (CAPTURE_READY); -// msg->AddInt32 ("index", index); -// BButton *grab = new BButton (BRect (128, 40, 180, 64), "grab", "Grab", msg); -// grab->SetTarget (be_app); -// bg->AddChild (grab); - GrabView *gv = new GrabView (BRect (8, 8, 8 + 32, 8 + 32), "GrabView"); - bg->AddChild (gv); - window->fActivateCB = new BCheckBox (BRect (48, rect.top + 2, rect.right - 4, rect.top + 18), "activate", "Activate", new BMessage ('actv')); - window->fBorderCB = new BCheckBox (BRect (48, rect.top + 20, rect.right - 4, rect.top + 36), "border", "Include Frame", new BMessage ('brdr')); - bg->AddChild (window->fActivateCB); - bg->AddChild (window->fBorderCB); - window->fActivateCB->SetValue (false); - window->fBorderCB->SetValue (true); - bg->AddChild (new BStringView (BRect (rect.left + 4, rect.bottom - 20, rect.right - 4, rect.bottom - 4), "dragtext", "Drag Camera onto a Window")); + strcpy(info->name, "WinGrab"); + strcpy(info->author, "Sander Stoks"); + strcpy(info->copyright, "© 2000-2001 ∑ Sum Software"); + strcpy(info->description, "Grab a screen shot of a window"); + info->type = BECASSO_CAPTURE; + info->index = index; + info->version = 0; + info->release = 2; + info->becasso_version = 2; + info->becasso_release = 0; + info->does_preview = true; + BRect rect(100, 180, 100 + 188, 180 + 72); + window = new CaptureWindow(rect); + rect.OffsetTo(B_ORIGIN); + BView* bg = new BView(rect, "bg", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); + bg->SetViewColor(LightGrey); + window->AddChild(bg); + // BMessage *msg = new BMessage (CAPTURE_READY); + // msg->AddInt32 ("index", index); + // BButton *grab = new BButton (BRect (128, 40, 180, 64), "grab", "Grab", msg); + // grab->SetTarget (be_app); + // bg->AddChild (grab); + GrabView* gv = new GrabView(BRect(8, 8, 8 + 32, 8 + 32), "GrabView"); + bg->AddChild(gv); + window->fActivateCB = new BCheckBox( + BRect(48, rect.top + 2, rect.right - 4, rect.top + 18), "activate", "Activate", + new BMessage('actv') + ); + window->fBorderCB = new BCheckBox( + BRect(48, rect.top + 20, rect.right - 4, rect.top + 36), "border", "Include Frame", + new BMessage('brdr') + ); + bg->AddChild(window->fActivateCB); + bg->AddChild(window->fBorderCB); + window->fActivateCB->SetValue(false); + window->fBorderCB->SetValue(true); + bg->AddChild(new BStringView( + BRect(rect.left + 4, rect.bottom - 20, rect.right - 4, rect.bottom - 4), "dragtext", + "Drag Camera onto a Window" + )); window->fIndex = index; window->Run(); return B_OK; } -status_t addon_exit (void) +status_t +addon_exit(void) { return B_OK; } -status_t addon_open (void) +status_t +addon_open(void) { window->Lock(); if (window->IsHidden()) - window->Show (); + window->Show(); else - window->Activate (); + window->Activate(); window->Unlock(); return B_OK; } -BBitmap *bitmap (char *title) +BBitmap* +bitmap(char* title) { - if (theGrabbee.IsValid()) - { + if (theGrabbee.IsValid()) { BMessage reply; - BMessage *msg = new BMessage (B_GET_PROPERTY); - msg->AddSpecifier ("Title"); - theGrabbee.SendMessage (msg, &reply); - const char *result = reply.FindString ("result"); + BMessage* msg = new BMessage(B_GET_PROPERTY); + msg->AddSpecifier("Title"); + theGrabbee.SendMessage(msg, &reply); + const char* result = reply.FindString("result"); if (result) - strcpy (title, result); + strcpy(title, result); else - strcpy (title, "Grabbed Window"); + strcpy(title, "Grabbed Window"); delete msg; - - if (window->fActivateCB->Value()) - { - msg = new BMessage (B_SET_PROPERTY); - msg->AddSpecifier ("Active"); - msg->AddBool ("data", true); - theGrabbee.SendMessage (msg, &reply); - snooze (500000); // give the window time to paint + + if (window->fActivateCB->Value()) { + msg = new BMessage(B_SET_PROPERTY); + msg->AddSpecifier("Active"); + msg->AddBool("data", true); + theGrabbee.SendMessage(msg, &reply); + snooze(500000); // give the window time to paint delete msg; } - - msg = new BMessage (B_GET_PROPERTY); - msg->AddSpecifier ("Frame"); - theGrabbee.SendMessage (msg, &reply); + + msg = new BMessage(B_GET_PROPERTY); + msg->AddSpecifier("Frame"); + theGrabbee.SendMessage(msg, &reply); delete msg; BRect frame; - if (reply.FindRect ("result", &frame) != B_OK) - { + if (reply.FindRect("result", &frame) != B_OK) { beep(); return 0; } int tab = 0; - if (window->fBorderCB->Value()) - { - msg = new BMessage (B_GET_PROPERTY); - msg->AddSpecifier ("Look"); - theGrabbee.SendMessage (msg, &reply); - - window_look look = (window_look) reply.FindInt32 ("result"); - switch (look) - { + if (window->fBorderCB->Value()) { + msg = new BMessage(B_GET_PROPERTY); + msg->AddSpecifier("Look"); + theGrabbee.SendMessage(msg, &reply); + + window_look look = (window_look)reply.FindInt32("result"); + switch (look) { case B_BORDERED_WINDOW_LOOK: - frame.InsetBy (-1, -1); + frame.InsetBy(-1, -1); break; case B_TITLED_WINDOW_LOOK: case B_DOCUMENT_WINDOW_LOOK: - frame.InsetBy (-5, -5); + frame.InsetBy(-5, -5); frame.top -= 19; tab = 19; break; case B_MODAL_WINDOW_LOOK: - frame.InsetBy (-5, -5); + frame.InsetBy(-5, -5); frame.PrintToStream(); break; case B_FLOATING_WINDOW_LOOK: - frame.InsetBy (-3, -3); + frame.InsetBy(-3, -3); frame.top -= 15; tab = 15; break; @@ -480,51 +527,51 @@ BBitmap *bitmap (char *title) } BScreen screen; - BBitmap *bs = NULL; - if (frame.left < 0) frame.left = 0; - if (frame.top < 0) frame.top = 0; - if (frame.right > screen.Frame().right) frame.right = screen.Frame().right; - if (frame.bottom > screen.Frame().bottom) frame.bottom = screen.Frame().bottom; - screen.GetBitmap (&bs, false, &frame); - + BBitmap* bs = NULL; + if (frame.left < 0) + frame.left = 0; + if (frame.top < 0) + frame.top = 0; + if (frame.right > screen.Frame().right) + frame.right = screen.Frame().right; + if (frame.bottom > screen.Frame().bottom) + frame.bottom = screen.Frame().bottom; + screen.GetBitmap(&bs, false, &frame); + // This exercise is necessary because the grabbed image has // all kinds of weird stuff in its alpha channel. - - frame.OffsetTo (B_ORIGIN); - BBitmap *b = new BBitmap (frame, B_RGB_32_BIT, true); - BView *v = new BView (frame, "tmp view", 0, 0); + + frame.OffsetTo(B_ORIGIN); + BBitmap* b = new BBitmap(frame, B_RGB_32_BIT, true); + BView* v = new BView(frame, "tmp view", 0, 0); b->Lock(); - b->AddChild (v); - v->DrawBitmap (bs, B_ORIGIN); - b->RemoveChild (v); + b->AddChild(v); + v->DrawBitmap(bs, B_ORIGIN); + b->RemoveChild(v); b->Unlock(); delete v; delete bs; - - bgra_pixel *s = (bgra_pixel *) b->Bits() - 1; - for (int32 i = (frame.IntegerWidth() + 1)*(frame.IntegerHeight() + 1); i > 0; i--) - { + + bgra_pixel* s = (bgra_pixel*)b->Bits() - 1; + for (int32 i = (frame.IntegerWidth() + 1) * (frame.IntegerHeight() + 1); i > 0; i--) { *s = *(++s) | ALPHA_MASK; } - + // correct for the tab - if (tab) - { - s = (bgra_pixel *) b->Bits() + b->BytesPerRow()/4 + 1; + if (tab) { + s = (bgra_pixel*)b->Bits() + b->BytesPerRow() / 4 + 1; bgra_pixel tc = *s; int32 tw = 2; while (*(s++) == tc) tw++; - for (int32 h = 0; h < tab; h++) - { - s = (bgra_pixel *) b->Bits() + h*b->BytesPerRow()/4 + tw - 1; + for (int32 h = 0; h < tab; h++) { + s = (bgra_pixel*)b->Bits() + h * b->BytesPerRow() / 4 + tw - 1; for (int32 w = tw; w <= b->Bounds().IntegerWidth(); w++) *s = *(++s) & COLOR_MASK; } } - + return (b); - } - else + } else return (NULL); } diff --git a/source/be-sfx.cpp b/source/be-sfx.cpp index d56d6c3..c9e03fb 100644 --- a/source/be-sfx.cpp +++ b/source/be-sfx.cpp @@ -10,14 +10,10 @@ #if !defined(DEBUG) /* #define DEBUG 1 /* debugging output */ - #define DEBUG 0 /* no debugging (faster) */ +#define DEBUG 0 /* no debugging (faster) */ #endif -SoundEffect::SoundEffect( - bool swap_data, - short * pointer, - int numFrames, - int nLoops) +SoundEffect::SoundEffect(bool swap_data, short* pointer, int numFrames, int nLoops) { fPointer = pointer; fFrames = numFrames; @@ -30,81 +26,63 @@ SoundEffect::SoundEffect( } } - SoundEffect::~SoundEffect() { - if (fPointer != NULL) /* superclasses may do different things */ + if (fPointer != NULL) /* superclasses may do different things */ free(fPointer); } - -short * -SoundEffect::GetBuffer( - int & numFrames, - int & numLoops) +short* +SoundEffect::GetBuffer(int& numFrames, int& numLoops) { numFrames = fFrames; numLoops = fLoops; return fPointer; } - -short * -SoundEffect8_11::Convert8_11( - char * buffer, - int size, - int loop, - bool toggle) +short* +SoundEffect8_11::Convert8_11(char* buffer, int size, int loop, bool toggle) { - int rsize = size*8; /* 11->44, 8->16 */ - short * ret = (short *)malloc(rsize); + int rsize = size * 8; /* 11->44, 8->16 */ + short* ret = (short*)malloc(rsize); short prev; - short * out = ret; + short* out = ret; -/* if you are playing sounds in a loop that should not glitch, */ -/* you should use this code to make sure the last and first samples butt */ + /* if you are playing sounds in a loop that should not glitch, */ + /* you should use this code to make sure the last and first samples butt */ if (loop != 0) if (toggle) - prev = buffer[size-1]-128; + prev = buffer[size - 1] - 128; else - prev = buffer[size-1]; + prev = buffer[size - 1]; else prev = 0; - for (int ix=0; ix44 */ +SoundEffect8_11::SoundEffect8_11(char* buffer, int size, int loop, bool toggle) + : SoundEffect(false, Convert8_11(buffer, size, loop, toggle), size * 4, loop) /* 11->44 */ { if (buffer != NULL) - free(buffer); /* since we eat an already allocated malloc() block (say, from FindResource()) */ + free(buffer + ); /* since we eat an already allocated malloc() block (say, from FindResource()) */ } - -EffectsPlayer::EffectsPlayer( - int bgVolume, - int nChannels) : - BSubscriber("be-sfx by h+"), - fLock("sfx locker") +EffectsPlayer::EffectsPlayer(int bgVolume, int nChannels) + : BSubscriber("be-sfx by h+"), fLock("sfx locker") { /* set up the area used for remembering what's being played */ fPlayList = new PlayingEffect[nChannels]; @@ -118,12 +96,11 @@ EffectsPlayer::EffectsPlayer( if (!fInit) fInit = fOutput->SetSamplingRate(44100.0); if (!fInit) - fInit = fOutput->SetStreamBuffers(1024, 3); /* minimize latency */ + fInit = fOutput->SetStreamBuffers(1024, 3); /* minimize latency */ if (!fInit) fInit = EnterStream(0, false, this, PlayHook, NULL, true); } - EffectsPlayer::~EffectsPlayer() { if (!fInit) @@ -133,42 +110,41 @@ EffectsPlayer::~EffectsPlayer() delete fOutput; } - effect_id -EffectsPlayer::StartEffect( - SoundEffect * effect, - int volume, - int pan) +EffectsPlayer::StartEffect(SoundEffect* effect, int volume, int pan) { /* test for init conditions */ - if (fInit) return B_ERROR; - if (volume < 1) return -1; - fLock.Lock(); /* keep locked for atomic update */ - if (nPlaying >= fPlaySize) - { + if (fInit) + return B_ERROR; + if (volume < 1) + return -1; + fLock.Lock(); /* keep locked for atomic update */ + if (nPlaying >= fPlaySize) { int found = 0; - int toplay = fPlayList[0].frames-fPlayList[0].offset; + int toplay = fPlayList[0].frames - fPlayList[0].offset; /* find someone to kick out */ /* we kick out the sound with the least amount left to play */ - for (int ix=1; ixGetBuffer(fPlayList[nPlaying].frames, fPlayList[nPlaying].loop); + fPlayList[nPlaying].data = + effect->GetBuffer(fPlayList[nPlaying].frames, fPlayList[nPlaying].loop); fPlayList[nPlaying].offset = 0; - fPlayList[nPlaying].lvol = volume * ((pan > 0) ? (127.0-pan)/127.0 : 1.0); - fPlayList[nPlaying].rvol = volume * ((pan < 0) ? (127.0+pan)/127.0 : 1.0); + fPlayList[nPlaying].lvol = volume * ((pan > 0) ? (127.0 - pan) / 127.0 : 1.0); + fPlayList[nPlaying].rvol = volume * ((pan < 0) ? (127.0 + pan) / 127.0 : 1.0); effect_id id = ++fNextEffect; fPlayList[nPlaying].id = id; nPlaying++; @@ -176,33 +152,28 @@ EffectsPlayer::StartEffect( return id; } - bool -EffectsPlayer::IsPlaying( - effect_id effect) +EffectsPlayer::IsPlaying(effect_id effect) { /* try to find given sound instance */ bool ret = false; fLock.Lock(); - for (int ix=0; ix fPlayList[ix].lvol) ? fPlayList[ix].rvol : - fPlayList[ix].lvol); + vol = + ((fPlayList[ix].rvol > fPlayList[ix].lvol) ? fPlayList[ix].rvol + : fPlayList[ix].lvol); if (pan < 0) - pan = ((fPlayList[ix].rvol >= fPlayList[ix].lvol) ? - (127 - 127 * fPlayList[ix].lvol / fPlayList[ix].rvol) : - (127 * fPlayList[ix].rvol / fPlayList[ix].lvol - 127)); - fPlayList[nPlaying].lvol = vol * ((pan > 0) ? (127.0-pan)/127.0 : 1.0); - fPlayList[nPlaying].rvol = vol * ((pan < 0) ? (127.0+pan)/127.0 : 1.0); + pan = + ((fPlayList[ix].rvol >= fPlayList[ix].lvol) + ? (127 - 127 * fPlayList[ix].lvol / fPlayList[ix].rvol) + : (127 * fPlayList[ix].rvol / fPlayList[ix].lvol - 127)); + fPlayList[nPlaying].lvol = vol * ((pan > 0) ? (127.0 - pan) / 127.0 : 1.0); + fPlayList[nPlaying].rvol = vol * ((pan < 0) ? (127.0 + pan) / 127.0 : 1.0); break; } fLock.Unlock(); } - void -EffectsPlayer::SoundCompleted( - effect_id /* effect */, - int /* reason */) +EffectsPlayer::SoundCompleted(effect_id /* effect */, int /* reason */) { /* do nothing */ } - void -EffectsPlayer::SetVolume( - int volume) /* 0->15 */ +EffectsPlayer::SetVolume(int volume) /* 0->15 */ { fVolume = volume; - if (fVolume > 15) fVolume = 15; - if (fVolume < 0) fVolume = 0; + if (fVolume > 15) + fVolume = 15; + if (fVolume < 0) + fVolume = 0; } - int EffectsPlayer::GetVolume() { return fVolume; } - void -EffectsPlayer::SetBackgroundVolume( - int bgVolume) +EffectsPlayer::SetBackgroundVolume(int bgVolume) { fBGVolume = bgVolume; - if (fBGVolume > 15) fBGVolume = 15; - if (fBGVolume < 0) fBGVolume = 0; + if (fBGVolume > 15) + fBGVolume = 15; + if (fBGVolume < 0) + fBGVolume = 0; } - int EffectsPlayer::GetBackgroundVolume() { return fBGVolume; } - void -EffectsPlayer::Mix( - short * buffer, - int numFrames) +EffectsPlayer::Mix(short* buffer, int numFrames) { if (fVolume < 1) - return; /* don't affect when sound is off */ - fLock.Lock(); /* we keep it locked during the entire mix, since we are list heavy */ - /* A significant amount of cycles are expended to traverse the list when many */ + return; /* don't affect when sound is off */ + fLock.Lock(); /* we keep it locked during the entire mix, since we are list heavy */ + /* A significant amount of cycles are expended to traverse the list when many */ /* items are being played. However, this function is only called about 100 times a */ /* second, so it's not that bad. */ #if DEBUG @@ -310,67 +272,57 @@ EffectsPlayer::Mix( /* added in SoundCompleted() would get added to the currently */ /* playing last sample of the completed sound. Not good. */ - effect_id * list = (effect_id *)alloca(sizeof(effect_id)*fPlaySize); + effect_id* list = (effect_id*)alloca(sizeof(effect_id) * fPlaySize); int nNotify = 0; - for (int ix=0; ix= fPlayList[iz].frames) - { - if (fPlayList[iz].loop > 0) - { + if (offset >= fPlayList[iz].frames) { + if (fPlayList[iz].loop > 0) { /* loop a predetermined number of times */ fPlayList[iz].loop--; fPlayList[iz].offset = 0; list[nNotify++] = fPlayList[iz].id; - } - else if (fPlayList[iz].loop < 0) - { + } else if (fPlayList[iz].loop < 0) { /* loop forever (until manually stopped) */ fPlayList[iz].offset = 0; list[nNotify++] = fPlayList[iz].id; - } - else - { + } else { /* kick it out */ - list[nNotify++] = -fPlayList[iz].id; /* to know what kind of notify */ - memcpy(&fPlayList[iz], &fPlayList[iz+1], sizeof(PlayingEffect)*(nPlaying-iz-1)); + list[nNotify++] = -fPlayList[iz].id; /* to know what kind of notify */ + memcpy( + &fPlayList[iz], &fPlayList[iz + 1], + sizeof(PlayingEffect) * (nPlaying - iz - 1) + ); nPlaying--; - iz--; /* will get incremented in for() clause */ + iz--; /* will get incremented in for() clause */ } - } - else + } else fPlayList[iz].offset = offset; } int left; int right; - curl >>= (22 - fVolume); /* 7 for *127 and up to 15 for volume */ + curl >>= (22 - fVolume); /* 7 for *127 and up to 15 for volume */ curr >>= (22 - fVolume); - if (fBGVolume > 0) - { + if (fBGVolume > 0) { /* let the background in */ - left = buffer[ix*2]; - right = buffer[ix*2+1]; - if (fBGVolume < 15) - { + left = buffer[ix * 2]; + right = buffer[ix * 2 + 1]; + if (fBGVolume < 15) { left = left >> (15 - fBGVolume); right = right >> (15 - fBGVolume); } left += curl; right += curr; - } - else - { + } else { left = curl; right = curr; } @@ -379,41 +331,35 @@ EffectsPlayer::Mix( /* high. Typically, you'll not want the volumes to go above 14 when you have both */ /* background and foreground on; or 13 if you're playing a lot of sounds */ /* simultaneously. */ - if (left < -32768) - { + if (left < -32768) { #if DEBUG lclipped++; #endif left = -32768; } - if (left > 32767) - { + if (left > 32767) { #if DEBUG lclipped++; #endif left = 32767; } - buffer[ix*2] = left; /* write to buffer */ - if (right < -32768) - { + buffer[ix * 2] = left; /* write to buffer */ + if (right < -32768) { #if DEBUG rclipped++; #endif right = -32768; } - if (right > 32767) - { + if (right > 32767) { #if DEBUG rclipped++; #endif right = 32767; } - buffer[ix*2+1] = right; /* write to buffer */ + buffer[ix * 2 + 1] = right; /* write to buffer */ - if (nNotify > 0) - { - for (int ix=0; ix 0) { + for (int ix = 0; ix < nNotify; ix++) { if (list[ix] > 0) SoundCompleted(list[ix], kSoundLooping); else @@ -423,23 +369,17 @@ EffectsPlayer::Mix( } } #if DEBUG - if (rclipped + lclipped > 0) - { + if (rclipped + lclipped > 0) { printf("Clipping: %d left %d right\n", lclipped, rclipped); } #endif fLock.Unlock(); } - bool -EffectsPlayer::PlayHook( - void * userData, - char * buffer, - size_t count, - void * /* header */) +EffectsPlayer::PlayHook(void* userData, char* buffer, size_t count, void* /* header */) { /* stereo, 16 bit stereo samples -> numFrames */ - ((EffectsPlayer *)userData)->Mix((short *)buffer, count/4); + ((EffectsPlayer*)userData)->Mix((short*)buffer, count / 4); return true; } diff --git a/source/be-sfx.h b/source/be-sfx.h index 007da7b..1f274d6 100644 --- a/source/be-sfx.h +++ b/source/be-sfx.h @@ -68,136 +68,98 @@ #include #include - -enum { +enum +{ kLoopForever = -1, kDontLoop = 0 }; class SoundEffect { -public: - - /* set swap_data to true if data is in different byte order than host */ - SoundEffect( - bool swap_data, - short * pointer, - int numFrames, - int nLoops = kDontLoop); - ~SoundEffect(); - - short * GetBuffer( - int & numFrames, - int & numLoops); - -protected: - short * fPointer; - int fFrames; - int fLoops; -}; + public: + /* set swap_data to true if data is in different byte order than host */ + SoundEffect(bool swap_data, short* pointer, int numFrames, int nLoops = kDontLoop); + ~SoundEffect(); + short* GetBuffer(int& numFrames, int& numLoops); -class SoundEffect8_11 : - public SoundEffect -{ -protected: - - /* set toggle to true if sound is in unsigned char format */ - /* this only does linear expansion - mulaw requires another subclass */ - /* No swapping necessary for 8-bit samples... */ -static short * Convert8_11( - char * buffer, - int size, - int loop = kDontLoop, - bool toggle = false); - -public: - SoundEffect8_11( - char * buffer, - int size, - int loops = kDontLoop, - bool toggle = false); + protected: + short* fPointer; + int fFrames; + int fLoops; }; +class SoundEffect8_11 : public SoundEffect +{ + protected: + /* set toggle to true if sound is in unsigned char format */ + /* this only does linear expansion - mulaw requires another subclass */ + /* No swapping necessary for 8-bit samples... */ + static short* Convert8_11(char* buffer, int size, int loop = kDontLoop, bool toggle = false); + + public: + SoundEffect8_11(char* buffer, int size, int loops = kDontLoop, bool toggle = false); +}; typedef int effect_id; -enum { /* reasons for SoundCompleted */ - kSoundDone, /* sound played the last sample */ - kSoundLooping, /* sound will loop to first sample */ - kSoundEvicted, /* sound was evicted by newer sound */ - kSoundStopped /* sound was manually stopped */ +enum +{ /* reasons for SoundCompleted */ + kSoundDone, /* sound played the last sample */ + kSoundLooping, /* sound will loop to first sample */ + kSoundEvicted, /* sound was evicted by newer sound */ + kSoundStopped /* sound was manually stopped */ }; -class EffectsPlayer : - public BSubscriber +class EffectsPlayer : public BSubscriber { -public: - - EffectsPlayer( - int backgroundVolume = 0, - int nChannels = 8); - ~EffectsPlayer(); - - status_t InitCheck() - { - return fInit; - } - - effect_id StartEffect( /* don't delete the effect until the player is gone */ - SoundEffect * effect, - int volume = 127, - int pan = 0); - bool IsPlaying( - effect_id effect); - void StopEffect( - effect_id effect); -virtual void SoundCompleted( - effect_id effect, - int reason); - - void SetEffectVolPan( /* -1 means no change */ - effect_id effect, - int vol = -1, - int pan = -1); - - void SetVolume( - int volume); /* 0->15 */ - int GetVolume(); - void SetBackgroundVolume( - int bgVolume); - int GetBackgroundVolume(); - void Mix( - short * buffer, - int numFrames); - -static bool PlayHook( - void * userData, - char * buffer, - size_t count, - void * /* header */); -protected: - - status_t fInit; - BDACStream * fOutput; - int fVolume; - int fBGVolume; - effect_id fNextEffect; - - struct PlayingEffect { - short * data; - int frames; - int offset; - int lvol; - int rvol; - int loop; - effect_id id; - }; - PlayingEffect * fPlayList; - int nPlaying; - int fPlaySize; - BLocker fLock; + public: + EffectsPlayer(int backgroundVolume = 0, int nChannels = 8); + ~EffectsPlayer(); + + status_t InitCheck() { return fInit; } + + effect_id StartEffect(/* don't delete the effect until the player is gone */ + SoundEffect* effect, int volume = 127, int pan = 0 + ); + bool IsPlaying(effect_id effect); + void StopEffect(effect_id effect); + virtual void SoundCompleted(effect_id effect, int reason); + + void SetEffectVolPan(/* -1 means no change */ + effect_id effect, int vol = -1, int pan = -1 + ); + + void SetVolume(int volume); /* 0->15 */ + int GetVolume(); + void SetBackgroundVolume(int bgVolume); + int GetBackgroundVolume(); + void Mix(short* buffer, int numFrames); + + static bool PlayHook(void* userData, char* buffer, size_t count, void* /* header */); + + protected: + status_t fInit; + BDACStream* fOutput; + int fVolume; + int fBGVolume; + effect_id fNextEffect; + + struct PlayingEffect + { + short* data; + int frames; + int offset; + int lvol; + int rvol; + int loop; + effect_id id; + }; + + PlayingEffect* fPlayList; + int nPlaying; + int fPlaySize; + BLocker fLock; }; #endif /* BE_SFX_H */ - diff --git a/source/cam.c b/source/cam.c index a12ae2c..919e13b 100644 --- a/source/cam.c +++ b/source/cam.c @@ -1,35 +1,67 @@ /* C array for cam.c */ -uchar data[32*32] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x06, 0x00, 0x06, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0b, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x2c, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x2a, 0x2a, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x09, 0x2c, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x05, 0x05, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x05, 0x05, 0x05, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x05, 0x05, 0x05, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x05, 0x05, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x07, 0x07, 0x07, 0x07, 0x00, 0x07, 0x0f, 0x0f, 0x09, 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x07, 0x05, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x07, 0x07, 0x07, 0x0a, 0x0a, 0x0c, 0x07, 0x07, 0x0f, 0x09, 0x09, 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x07, 0x0c, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x09, 0x40, 0x09, 0x00, 0x0f, 0x0f, 0x0f, 0x0c, 0x08, 0x07, 0x07, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x00, 0x40, 0x40, 0x40, 0x40, 0x07, 0x0f, 0x0f, 0x0f, 0x07, 0x00, 0x09, 0x40, 0x40, 0x09, 0x00, 0x0b, 0x00, 0x06, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x09, 0xff, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x09, 0x3f, 0x40, 0x40, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x00, 0x40, 0x3f, 0x40, 0x40, 0x40, 0x40, 0x06, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x09, 0x3f, 0x40, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x00, 0x40, 0x3f, 0x40, 0x40, 0x40, 0x40, 0x00, 0x0f, 0x0b, 0x07, 0x00, 0x0f, 0x0f, 0x09, 0x3f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x06, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x0b, 0x07, 0x07, 0x00, 0x0f, 0x0f, 0x0f, 0x09, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x07, 0x07, 0x00, 0x09, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x09, 0x40, 0x40, 0x40, 0x40, 0x40, 0x0f, 0x00, 0x00, 0x09, 0x09, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x09, 0x09, 0x40, 0x40, 0x40, 0x00, 0xff, 0xff, 0xff, 0x00, 0x09, 0x09, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x00, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x09, 0x07, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff - }; +uchar data[32 * 32] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x06, 0x00, 0x06, 0x0f, 0x0f, 0x09, 0x00, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x0b, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x09, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x2c, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x2a, 0x2a, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x09, 0x2c, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x05, 0x05, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, + 0x0f, 0x0f, 0x0f, 0x05, 0x05, 0x05, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, + 0x0f, 0x0f, 0x08, 0x05, 0x05, 0x05, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, + 0x0f, 0x0f, 0x0f, 0x08, 0x05, 0x05, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0x07, 0x07, 0x07, 0x07, 0x00, 0x07, 0x0f, 0x0f, 0x09, + 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x07, 0x05, 0x0f, 0x0f, 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x07, 0x07, 0x07, 0x0a, 0x0a, 0x0c, 0x07, 0x07, 0x0f, 0x09, + 0x09, 0x00, 0x0f, 0x0f, 0x0f, 0x08, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x07, 0x0c, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x09, + 0x40, 0x09, 0x00, 0x0f, 0x0f, 0x0f, 0x0c, 0x08, 0x07, 0x07, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x00, 0x40, 0x40, 0x40, 0x40, 0x07, 0x0f, 0x0f, 0x0f, 0x07, 0x00, 0x09, + 0x40, 0x40, 0x09, 0x00, 0x0b, 0x00, 0x06, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x09, 0xff, 0x3f, 0x3f, 0x40, 0x40, 0x40, 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x09, + 0x3f, 0x40, 0x40, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x00, 0x40, 0x3f, 0x40, 0x40, 0x40, 0x40, 0x06, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, + 0x09, 0x3f, 0x40, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x00, 0x40, 0x3f, 0x40, 0x40, 0x40, 0x40, 0x00, 0x0f, 0x0b, 0x07, 0x00, 0x0f, + 0x0f, 0x09, 0x3f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x06, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x0b, 0x07, 0x07, 0x00, 0x0f, + 0x0f, 0x0f, 0x09, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x0f, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x07, 0x07, 0x00, 0x09, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x09, 0x40, 0x40, 0x40, 0x40, 0x40, 0x0f, 0x00, 0x00, 0x09, 0x09, 0x0f, + 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x09, 0x09, 0x40, 0x40, 0x40, 0x00, 0xff, 0xff, 0xff, 0x00, 0x09, 0x09, + 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x06, 0x00, 0x09, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x09, + 0x0f, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x09, 0x0f, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x09, 0x0f, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x00, 0x09, 0x0f, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x05, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0x00, 0x09, 0x00, 0x0b, 0x09, 0x09, 0x08, 0x08, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x00, 0x00, 0x09, 0x07, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x0f, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff +}; diff --git a/source/cvtrgb.c b/source/cvtrgb.c index bd9b078..93a87e8 100644 --- a/source/cvtrgb.c +++ b/source/cvtrgb.c @@ -1,56 +1,56 @@ #include -#define max(a,b) ((a)>(b)?(a):(b)) +#define max(a, b) ((a) > (b) ? (a) : (b)) // Format of rgb.txt: // r g bName\n // 0 <= r,g,b <= 255 -int main (void) +int +main(void) { char rgbin[753][60]; unsigned char rgbout[753][60]; int i, j, maxlen; FILE *in, *out; - in = fopen ("rgb.txt", "r"); + in = fopen("rgb.txt", "r"); i = 0; maxlen = 0; - while (!feof (in)) - { - char *p; - fgets (rgbin[i], 59, in); + while (!feof(in)) { + char* p; + fgets(rgbin[i], 59, in); - sscanf (rgbin[i], "%d %d %d", - &rgbout[i][0], &rgbout[i][1], &rgbout[i][2]); + sscanf(rgbin[i], "%d %d %d", &rgbout[i][0], &rgbout[i][1], &rgbout[i][2]); p = rgbin[i]; while (*p++ != '\t') ; while (*++p == '\t') ; - strcpy (&rgbout[i][3], p); // -> Name - rgbout[i][strlen (&rgbout[i][3]) + 2] = 0; - maxlen = max (strlen (&rgbout[i][3]), maxlen); + strcpy(&rgbout[i][3], p); // -> Name + rgbout[i][strlen(&rgbout[i][3]) + 2] = 0; + maxlen = max(strlen(&rgbout[i][3]), maxlen); i++; } - printf ("Max length = %d\n", maxlen); - fclose (in); - - out = fopen ("colors.dat", "wb"); - - printf ("%d items\n", --i); - fprintf (out, "%c%c%c", maxlen, (char) (i % 256), (char) (i/256)); - for (j = 0; j < i; j++) - { + printf("Max length = %d\n", maxlen); + fclose(in); + + out = fopen("colors.dat", "wb"); + + printf("%d items\n", --i); + fprintf(out, "%c%c%c", maxlen, (char)(i % 256), (char)(i / 256)); + for (j = 0; j < i; j++) { rgbout[j][maxlen + 3] = 0; - printf ("%3d %3d %3d %s\n", - (int) rgbout[j][0], (int) rgbout[j][1], (int) rgbout[j][2], - &rgbout[j][3]); - fprintf (out, "%c%c%c%s%c", - (int) rgbout[j][0], (int) rgbout[j][1], (int) rgbout[j][2], - &rgbout[j][3], 0); + printf( + "%3d %3d %3d %s\n", (int)rgbout[j][0], (int)rgbout[j][1], (int)rgbout[j][2], + &rgbout[j][3] + ); + fprintf( + out, "%c%c%c%s%c", (int)rgbout[j][0], (int)rgbout[j][1], (int)rgbout[j][2], + &rgbout[j][3], 0 + ); } - fclose (out); + fclose(out); return 0; } diff --git a/source/debug.c b/source/debug.c index 22891f2..b31a24b 100644 --- a/source/debug.c +++ b/source/debug.c @@ -2,45 +2,42 @@ int DebugLevel; -void verbose (int level, const char *fmt, ...) +void +verbose(int level, const char* fmt, ...) { - if (DebugLevel >= level) - { + if (DebugLevel >= level) { va_list ap; const char *p, *svalue; int ivalue; /* float dvalue; */ - - va_start (ap, fmt); - for (p = fmt; *p; p++) - { - if (*p != '%') - { - putc (*p, stderr); + + va_start(ap, fmt); + for (p = fmt; *p; p++) { + if (*p != '%') { + putc(*p, stderr); continue; } - switch (*++p) - { - case 'd': - ivalue = va_arg (ap, int); - fprintf (stderr, "%d", ivalue); - break; - + switch (*++p) { + case 'd': + ivalue = va_arg(ap, int); + fprintf(stderr, "%d", ivalue); + break; + /*case 'f': dvalue = va_arg (ap, float); fprintf (stderr, "%d", dvalue); break; */ - - case 's': - for (svalue = va_arg (ap, char *); *svalue; svalue++) - putc (*svalue, stderr); - break; - - default: - putc (*p, stderr); - break; + + case 's': + for (svalue = va_arg(ap, char*); *svalue; svalue++) + putc(*svalue, stderr); + break; + + default: + putc(*p, stderr); + break; } - va_end (ap); + va_end(ap); } } } \ No newline at end of file diff --git a/source/debug.cpp b/source/debug.cpp index 8bb355d..7a2f1ef 100644 --- a/source/debug.cpp +++ b/source/debug.cpp @@ -5,45 +5,42 @@ int DebugLevel; #pragma export off -void verbose (int level, const char *fmt, ...) +void +verbose(int level, const char* fmt, ...) { - if (DebugLevel >= level) - { + if (DebugLevel >= level) { va_list ap; const char *p, *svalue; int ivalue; /* float dvalue; */ - - va_start (ap, fmt); - for (p = fmt; *p; p++) - { - if (*p != '%') - { - putc (*p, stderr); + + va_start(ap, fmt); + for (p = fmt; *p; p++) { + if (*p != '%') { + putc(*p, stderr); continue; } - switch (*++p) - { - case 'd': - ivalue = va_arg (ap, int); - fprintf (stderr, "%d", ivalue); - break; - + switch (*++p) { + case 'd': + ivalue = va_arg(ap, int); + fprintf(stderr, "%d", ivalue); + break; + /*case 'f': dvalue = va_arg (ap, float); fprintf (stderr, "%d", dvalue); break; */ - - case 's': - for (svalue = va_arg (ap, char *); *svalue; svalue++) - putc (*svalue, stderr); - break; - - default: - putc (*p, stderr); - break; + + case 's': + for (svalue = va_arg(ap, char*); *svalue; svalue++) + putc(*svalue, stderr); + break; + + default: + putc(*p, stderr); + break; } - va_end (ap); + va_end(ap); } } } \ No newline at end of file diff --git a/source/debug.h b/source/debug.h index 0eb1732..b4afaf1 100644 --- a/source/debug.h +++ b/source/debug.h @@ -1,8 +1,9 @@ #include -#if defined (__cplusplus) +#if defined(__cplusplus) extern "C" #endif -void verbose (int level, const char *format, ...); + void + verbose(int level, const char* format, ...); extern int DebugLevel; \ No newline at end of file diff --git a/source/dsc.h b/source/dsc.h index b6ea6a6..0bfbb24 100644 --- a/source/dsc.h +++ b/source/dsc.h @@ -8,93 +8,91 @@ */ #ifndef DSC_H -# define DSC_H +#define DSC_H -# include -# include +#include +#include /* What is the best way to do this? */ -# if ! _GNU_TYPES_H -# if sun +#if !_GNU_TYPES_H +#if sun typedef uint8_t u_int8_t; typedef uint32_t u_int32_t; -# else -# if __BEOS__ -# include -# endif -# endif -# endif +#else +#if __BEOS__ +#include +#endif +#endif +#endif typedef enum { - unknown = 0, - dsc1 = 1, - dsc2 = 2 + unknown = 0, + dsc1 = 1, + dsc2 = 2 } dsc_protocol_t; typedef enum { - unavailable = -1, - normal = 0, - fine = 1, - superfine = 2 + unavailable = -1, + normal = 0, + fine = 1, + superfine = 2 } dsc_quality_t; typedef struct { - int lerror, lerrno; + int lerror, lerrno; } dsc_error; typedef struct { - int fd; - struct termios term; - dsc_protocol_t type; - dsc_error lasterror; - u_int8_t *buf; + int fd; + struct termios term; + dsc_protocol_t type; + dsc_error lasterror; + u_int8_t* buf; } dsc_t; +#define EDSCSERRNO -1 /* see errno value */ +#define EDSCUNKNWN 0 /* unknown error code */ +#define EDSCBPSRNG 1 /* bps out of range */ +#define EDSCNOANSW 2 /* no answer from camera */ +#define EDSCRTMOUT 3 /* read time out */ +#define EDSCNRESET 4 /* could not reset camera */ +#define EDSCBADNUM 5 /* bad image number */ +#define EDSCBADPCL 6 /* bad protocol */ +#define EDSCMAXERR 6 /* highest used error code */ + +#ifndef DSCPAUSE +#define DSCPAUSE 4 /* seconds to wait for camera to redraw screen */ +#endif -# define EDSCSERRNO -1 /* see errno value */ -# define EDSCUNKNWN 0 /* unknown error code */ -# define EDSCBPSRNG 1 /* bps out of range */ -# define EDSCNOANSW 2 /* no answer from camera */ -# define EDSCRTMOUT 3 /* read time out */ -# define EDSCNRESET 4 /* could not reset camera */ -# define EDSCBADNUM 5 /* bad image number */ -# define EDSCBADPCL 6 /* bad protocol */ -# define EDSCMAXERR 6 /* highest used error code */ - -# ifndef DSCPAUSE -# define DSCPAUSE 4 /* seconds to wait for camera to redraw screen */ -# endif - -# define DSCMAXIMAGE 200 /* highest possible number of an image */ +#define DSCMAXIMAGE 200 /* highest possible number of an image */ -# ifdef __cplusplus +#ifdef __cplusplus extern "C" { -# endif +#endif -ssize_t dsc_read(dsc_t*, void*, size_t); -int dsc2_send_cmd(dsc_t*, int, int, int); + ssize_t dsc_read(dsc_t*, void*, size_t); + int dsc2_send_cmd(dsc_t*, int, int, int); -dsc_t* dsc_open(const char*, speed_t, dsc_error*); -int dsc_close(dsc_t*); -int dsc_getindex(dsc_t*, dsc_quality_t*); -int dsc_preview(dsc_t*, int); -int dsc_delete(dsc_t*, int); -ssize_t dsc_requestimage(dsc_t*, int); -ssize_t dsc_readimageblock(dsc_t*, int, void*); + dsc_t* dsc_open(const char*, speed_t, dsc_error*); + int dsc_close(dsc_t*); + int dsc_getindex(dsc_t*, dsc_quality_t*); + int dsc_preview(dsc_t*, int); + int dsc_delete(dsc_t*, int); + ssize_t dsc_requestimage(dsc_t*, int); + ssize_t dsc_readimageblock(dsc_t*, int, void*); -const char* dsc_strerror(const dsc_error*); + const char* dsc_strerror(const dsc_error*); -# ifdef __cplusplus +#ifdef __cplusplus } -# endif - #endif +#endif diff --git a/source/gen_key.c b/source/gen_key.c index 0f8718a..d8df22f 100644 --- a/source/gen_key.c +++ b/source/gen_key.c @@ -7,53 +7,57 @@ #include #include -#define KEYFILE_MASK 0x87, 0xF6, 0xA1, 0x7C, 0xD6, 0x3A, 0x87, 0xE6, 0x0E, 0x84, 0xF6, 0xCA, 0x81, 0xBF, 0x76, 0x12, \ - 0xE8, 0x3D, 0xF7, 0x6A, 0x29, 0xC3, 0x84, 0xB5, 0x6B, 0xC3, 0x4A, 0x8F, 0x76, 0xD9, 0x8A, 0x76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xA7, 0xA5, 0xC9, 0x87, 0x2A, 0x8F, 0xF7, 0x6D, 0x48, 0x7D, 0xE6, 0x25, 0xED, 0x54, \ + 0x9B, 0xC3, 0x6A, 0xA5, 0x98, 0x64, 0xAC, 0x10, 0xD9, 0x8F, 0xE7, 0x30, 0xA9, 0x54, 0xE4, \ + 0x5C, 0xD4, 0x35, 0xA4, 0x35, 0xFF, 0x26, 0x4F, 0x87, 0xEA, 0x65, 0x3B, 0xDE, 0x48, 0x76, \ + 0x1E, 0xB8, 0x72, 0xC5, 0xD8, 0x5E, 0x8A, 0x24 #define KEYFILE "Keyfile" -#define REG_NONE 0 -#define REG_CD 1 -#define REG_ESD 2 -#define REG_HAS_14 14 +#define REG_NONE 0 +#define REG_CD 1 +#define REG_ESD 2 +#define REG_HAS_14 14 -int main (int argc, char *argv[]) +int +main(int argc, char* argv[]) { char keyString[256]; char nameString[128]; - struct tm *tms; + struct tm* tms; time_t tm; int i, vlen; unsigned long sum; - FILE *kf; + FILE* kf; char wbuffer[256]; - char *schar; + char* schar; char Version[] = "2.0"; - char xAlphaMask[256] = { KEYFILE_MASK }; - char filler[] = "Well done, you have cracked the keyfile code! Please don't pass it on, I need to eat too - Sander"; + char xAlphaMask[256] = {KEYFILE_MASK}; + char filler[] = "Well done, you have cracked the keyfile code! Please don't pass it on, I " + "need to eat too - Sander"; - if (argc != 2) - { - printf ("Generate Keyfile for Becasso 1.5 registration\n"); - printf ("Usage: gen_key \n"); - printf ("(Quote ; it will probably contain spaces)\n"); + if (argc != 2) { + printf("Generate Keyfile for Becasso 1.5 registration\n"); + printf("Usage: gen_key \n"); + printf("(Quote ; it will probably contain spaces)\n"); return 2; } - - strncpy (nameString, argv[1], 127); - for (i = 0; i <= strlen (nameString); i++) - keyString[2*i] = nameString[i]; + strncpy(nameString, argv[1], 127); + + for (i = 0; i <= strlen(nameString); i++) + keyString[2 * i] = nameString[i]; for (i = strlen(nameString) + 1; i < 128; i++) - keyString[2*i] = rand() & 0xFF; - tm = time (NULL); - tms = localtime (&tm); - + keyString[2 * i] = rand() & 0xFF; + tm = time(NULL); + tms = localtime(&tm); + vlen = strlen(Version); keyString[1] = vlen; keyString[3] = tms->tm_year; @@ -63,35 +67,34 @@ int main (int argc, char *argv[]) keyString[11] = 42; keyString[13] = REG_ESD; for (i = 0; i <= vlen; i++) - keyString[2*i + 15] = Version[i]; + keyString[2 * i + 15] = Version[i]; for (i = 0; i < strlen(filler); i++) - keyString[2*i + 2*vlen + 15] = filler[i]; + keyString[2 * i + 2 * vlen + 15] = filler[i]; sum = 0; for (i = 0; i < 252; i++) sum += keyString[i]; - schar = (char *)(&sum); + schar = (char*)(&sum); keyString[252] = schar[0]; keyString[253] = schar[1]; keyString[254] = schar[2]; keyString[255] = schar[3]; for (i = 0; i < 255; i++) wbuffer[i] = keyString[i] ^ xAlphaMask[i]; - + #ifdef WRITE_TO_FILE - kf = fopen (KEYFILE, "wb"); + kf = fopen(KEYFILE, "wb"); #else kf = stdout; #endif if (kf) - fwrite (wbuffer, 1, 255, kf); - else - { - fprintf (stderr, "Couldn't open %s for writing\n", KEYFILE); + fwrite(wbuffer, 1, 255, kf); + else { + fprintf(stderr, "Couldn't open %s for writing\n", KEYFILE); return 1; } #ifdef WRITE_TO_FILE - fclose (kf); + fclose(kf); #endif - + return 0; } \ No newline at end of file diff --git a/source/hsv.cpp b/source/hsv.cpp index 829ef32..7542007 100644 --- a/source/hsv.cpp +++ b/source/hsv.cpp @@ -1,29 +1,29 @@ #include "hsv.h" #include #include -#include "BecassoAddOn.h" // For HUE_UNDEF +#include "BecassoAddOn.h" // For HUE_UNDEF -IMPEXP hsv_color rgb2hsv (rgb_color c) +IMPEXP hsv_color +rgb2hsv(rgb_color c) { hsv_color res; - float r = float (c.red)/255; - float g = float (c.green)/255; - float b = float (c.blue)/255; - float max = max_c (max_c (r, g), b); - float min = min_c (min_c (r, g), b); + float r = float(c.red) / 255; + float g = float(c.green) / 255; + float b = float(c.blue) / 255; + float max = max_c(max_c(r, g), b); + float min = min_c(min_c(r, g), b); res.value = max; - res.saturation = (max != 0.0) ? ((max - min)/max) : 0.0; + res.saturation = (max != 0.0) ? ((max - min) / max) : 0.0; if (res.saturation == 0.0) res.hue = HUE_UNDEF; - else - { + else { float delta = max - min; if (r == max) - res.hue = (g - b)/delta; + res.hue = (g - b) / delta; else if (g == max) - res.hue = 2.0 + (b - r)/delta; + res.hue = 2.0 + (b - r) / delta; else if (b == max) - res.hue = 4.0 + (r - g)/delta; + res.hue = 4.0 + (r - g) / delta; res.hue *= 60.0; if (res.hue < 0.0) res.hue += 360.0; @@ -32,44 +32,38 @@ IMPEXP hsv_color rgb2hsv (rgb_color c) return (res); } -IMPEXP rgb_color hsv2rgb (hsv_color c) +IMPEXP rgb_color +hsv2rgb(hsv_color c) { float r = 0, g = 0, b = 0, h = 0, s = 0, v = 0; rgb_color res; h = c.hue; s = c.saturation; v = c.value; - if (s == 0.0) - { - if (h == HUE_UNDEF) - { + if (s == 0.0) { + if (h == HUE_UNDEF) { r = v; g = v; b = v; - } - else - { -// fprintf (stderr, "Invalid HSV color\n"); + } else { + // fprintf (stderr, "Invalid HSV color\n"); r = v; g = v; b = v; } - } - else - { + } else { float f, p, q, t; int i; - + if (h == 360.0) h = 0.0; h /= 60.0; - i = int (floor (h)); + i = int(floor(h)); f = h - i; - p = v*(1.0 - s); - q = v*(1.0 - s*f); - t = v*(1.0 - s*(1.0 - f)); - switch (i) - { + p = v * (1.0 - s); + q = v * (1.0 - s * f); + t = v * (1.0 - s * (1.0 - f)); + switch (i) { case 0: r = v; g = t; @@ -102,9 +96,9 @@ IMPEXP rgb_color hsv2rgb (hsv_color c) break; } } - res.red = uint8 (r*255); - res.green = uint8 (g*255); - res.blue = uint8 (b*255); + res.red = uint8(r * 255); + res.green = uint8(g * 255); + res.blue = uint8(b * 255); res.alpha = c.alpha; return (res); } @@ -113,7 +107,8 @@ IMPEXP rgb_color hsv2rgb (hsv_color c) #ifndef SIMPLE_DISTANCE -IMPEXP float diff (rgb_color a, rgb_color b) +IMPEXP float +diff(rgb_color a, rgb_color b) // Note: Doesn't take alpha channel into account. // Distance is weighed via 0.213R, 0.715G, and 0.072B. // (Should actually be: 0.2125R, 0.7154G, and 0.0721B) @@ -124,149 +119,162 @@ IMPEXP float diff (rgb_color a, rgb_color b) static long rlut[512]; static long glut[512]; static long blut[512]; - static long *irlut = rlut + 256; - static long *iglut = glut + 256; - static long *iblut = blut + 256; - - if (lutsfilled) - { - int dr = (int) a.red - b.red; - int dg = (int) a.green - b.green; - int db = (int) a.blue - b.blue; - return (sqrt (irlut[dr] + iglut[dg] + iblut[db])/32); // 32 ~ sqrt(1000); 1% error. - } - else - { - for (int i = 0; i < 512; i++) - { - long j = (i - 256)*(i - 256); -#if defined (USE_OLD_WEIGHTS) - rlut[i] = 299*j; - glut[i] = 587*j; - blut[i] = 114*j; + static long* irlut = rlut + 256; + static long* iglut = glut + 256; + static long* iblut = blut + 256; + + if (lutsfilled) { + int dr = (int)a.red - b.red; + int dg = (int)a.green - b.green; + int db = (int)a.blue - b.blue; + return (sqrt(irlut[dr] + iglut[dg] + iblut[db]) / 32); // 32 ~ sqrt(1000); 1% error. + } else { + for (int i = 0; i < 512; i++) { + long j = (i - 256) * (i - 256); +#if defined(USE_OLD_WEIGHTS) + rlut[i] = 299 * j; + glut[i] = 587 * j; + blut[i] = 114 * j; #else - rlut[i] = 213*j; - glut[i] = 715*j; - blut[i] = 072*j; + rlut[i] = 213 * j; + glut[i] = 715 * j; + blut[i] = 072 * j; #endif } lutsfilled = true; - return (diff (a, b)); + return (diff(a, b)); } } #else -IMPEXP float cdiff (rgb_color a, rgb_color b) +IMPEXP float +cdiff(rgb_color a, rgb_color b) // Note: Doesn't take alpha channel into account. { - return (sqrt ((a.red - b.red)*(a.red - b.red) + (a.green - b.green)*(a.green - b.green) - + (a.blue - b.blue)*(a.blue - b.blue))); + return (sqrt( + (a.red - b.red) * (a.red - b.red) + (a.green - b.green) * (a.green - b.green) + + (a.blue - b.blue) * (a.blue - b.blue) + )); } #endif -IMPEXP uchar clipchar (float x) +IMPEXP uchar +clipchar(float x) { - return ((x < 0) ? 0 : ((x > 255) ? 255 : uchar (x))); + return ((x < 0) ? 0 : ((x > 255) ? 255 : uchar(x))); } -IMPEXP uchar clipchar (int x) +IMPEXP uchar +clipchar(int x) { return ((x < 0) ? 0 : ((x > 255) ? 255 : x)); } -IMPEXP float clipone (float x) +IMPEXP float +clipone(float x) { return ((x < 0) ? 0 : ((x > 1) ? 1 : x)); } -IMPEXP float clipdegr (float x) +IMPEXP float +clipdegr(float x) { if (x < 0) - return (clipdegr (x + 360)); + return (clipdegr(x + 360)); if (x > 360) - return (clipdegr (x - 360)); + return (clipdegr(x - 360)); return x; } -IMPEXP bgra_pixel cmyk2bgra (cmyk_pixel x) +IMPEXP bgra_pixel +cmyk2bgra(cmyk_pixel x) // Alpha is always set to 255 { int r, g, b; - r = g = b = 255 - BLACK (x); - b -= YELLOW (x); - g -= MAGENTA (x); - r -= CYAN (x); - return (PIXEL (r, g, b, 255)); + r = g = b = 255 - BLACK(x); + b -= YELLOW(x); + g -= MAGENTA(x); + r -= CYAN(x); + return (PIXEL(r, g, b, 255)); } -IMPEXP cmyk_pixel bgra2cmyk (bgra_pixel x) +IMPEXP cmyk_pixel +bgra2cmyk(bgra_pixel x) // Alpha is lost { int c, m, y, k; - y = 255 - BLUE (x); - m = 255 - GREEN (x); - c = 255 - RED (x); - k = min_c (min_c (c, m), y); + y = 255 - BLUE(x); + m = 255 - GREEN(x); + c = 255 - RED(x); + k = min_c(min_c(c, m), y); y -= k; m -= k; c -= k; - return (PIXEL (y, m, c, k)); + return (PIXEL(y, m, c, k)); } -IMPEXP rgb_color bgra2rgb (bgra_pixel c) +IMPEXP rgb_color +bgra2rgb(bgra_pixel c) { rgb_color res; - res.blue = BLUE (c); - res.green = GREEN (c); - res.red = RED (c); - res.alpha = ALPHA (c); + res.blue = BLUE(c); + res.green = GREEN(c); + res.red = RED(c); + res.alpha = ALPHA(c); return (res); } -IMPEXP rgb_color cmyk2rgb (cmyk_pixel c) +IMPEXP rgb_color +cmyk2rgb(cmyk_pixel c) { - return (bgra2rgb (cmyk2bgra (c))); + return (bgra2rgb(cmyk2bgra(c))); } -IMPEXP hsv_color bgra2hsv (bgra_pixel c) +IMPEXP hsv_color +bgra2hsv(bgra_pixel c) { - return (rgb2hsv (bgra2rgb (c))); + return (rgb2hsv(bgra2rgb(c))); } -IMPEXP hsv_color cmyk2hsv (cmyk_pixel c) +IMPEXP hsv_color +cmyk2hsv(cmyk_pixel c) { - return (rgb2hsv (cmyk2rgb (c))); + return (rgb2hsv(cmyk2rgb(c))); } -IMPEXP bgra_pixel rgb2bgra (rgb_color c) +IMPEXP bgra_pixel +rgb2bgra(rgb_color c) { -#if defined (__POWERPC__) - return (((c.blue << 24) & 0xFF000000) | - ((c.green << 16) & 0x00FF0000) | - ((c.red << 8) & 0x0000FF00) | - ((c.alpha ) & 0x000000FF)); +#if defined(__POWERPC__) + return ( + ((c.blue << 24) & 0xFF000000) | ((c.green << 16) & 0x00FF0000) | + ((c.red << 8) & 0x0000FF00) | ((c.alpha) & 0x000000FF) + ); #else - return (((c.blue) & 0x000000FF) | - ((c.green << 8) & 0x0000FF00) | - ((c.red << 16) & 0x00FF0000) | - ((c.alpha << 24) & 0xFF000000)); + return ( + ((c.blue) & 0x000000FF) | ((c.green << 8) & 0x0000FF00) | ((c.red << 16) & 0x00FF0000) | + ((c.alpha << 24) & 0xFF000000) + ); #endif } -IMPEXP bgra_pixel hsv2bgra (hsv_color c) +IMPEXP bgra_pixel +hsv2bgra(hsv_color c) { - return (rgb2bgra (hsv2rgb (c))); + return (rgb2bgra(hsv2rgb(c))); } -IMPEXP cmyk_pixel rgb2cmyk (rgb_color c) +IMPEXP cmyk_pixel +rgb2cmyk(rgb_color c) { - return (bgra2cmyk (rgb2bgra (c))); + return (bgra2cmyk(rgb2bgra(c))); } -IMPEXP cmyk_pixel hsv2cmyk (hsv_color c) +IMPEXP cmyk_pixel +hsv2cmyk(hsv_color c) { - return (bgra2cmyk (hsv2bgra (c))); + return (bgra2cmyk(hsv2bgra(c))); } diff --git a/source/hsv.h b/source/hsv.h index c4d6277..c2124a1 100644 --- a/source/hsv.h +++ b/source/hsv.h @@ -1,14 +1,21 @@ #ifndef HSV_H #define HSV_H -#include "AddOnSupport.h" // For hsv_color +#include "AddOnSupport.h" // For hsv_color -rgb_color hsv2rgb (hsv_color c); -hsv_color rgb2hsv (rgb_color c); -float diff (rgb_color a, rgb_color b); -uchar clipchar (float x); -uchar clipchar (int x); -float clipone (float x); -float clipdegr (float x); +rgb_color +hsv2rgb(hsv_color c); +hsv_color +rgb2hsv(rgb_color c); +float +diff(rgb_color a, rgb_color b); +uchar +clipchar(float x); +uchar +clipchar(int x); +float +clipone(float x); +float +clipdegr(float x); -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/source/mmx.c b/source/mmx.c index 94a6b84..d094c39 100644 --- a/source/mmx.c +++ b/source/mmx.c @@ -2,32 +2,33 @@ #include #include -#if defined (__MWCC__) +#if defined(__MWCC__) // It is horrible, but GCC has a completely different assembly syntax. // We'll have to use an external module (mmx_gcc.asm) -int mmx_available (void) +int +mmx_available(void) { -#if defined (__INTEL__) +#if defined(__INTEL__) int available; - int *aPtr = &available; - + int* aPtr = &available; + asm { pusha - mov edi, aPtr // This is where we'll store the result - mov eax, 1 // request for feature flags - cpuid // check... - test edx, 0x00800000 // test for MMX - jnz present // it's there - mov [edi], 0 // say it ain't so + mov edi, aPtr // This is where we'll store the result + mov eax, 1 // request for feature flags + cpuid // check... + test edx, 0x00800000 // test for MMX + jnz present // it's there + mov [edi], 0 // say it ain't so jmp end present: - mov [edi], 1 // rejoice! + mov [edi], 1 // rejoice! end: popa } - + return available; #else return false; @@ -36,109 +37,118 @@ int mmx_available (void) #endif // defined (__MWCC__) -#if defined (__GNUC__) && defined (__INTEL__) -void mmx_alpha_blend_diff_ga (uint64 ga_64, uint32 *s, uint32 *d, int height, int difference, int width); -void mmx_alpha_blend_nodiff_ga (uint64 ga_64, uint32 *s, uint32 *d, int size); -void mmx_alpha_blend_diff (uint32 *s, uint32 *d, int height, int difference, int width); -void mmx_alpha_blend_nodiff (uint32 *s, uint32 *d, int size); +#if defined(__GNUC__) && defined(__INTEL__) +void +mmx_alpha_blend_diff_ga(uint64 ga_64, uint32* s, uint32* d, int height, int difference, int width); +void +mmx_alpha_blend_nodiff_ga(uint64 ga_64, uint32* s, uint32* d, int size); +void +mmx_alpha_blend_diff(uint32* s, uint32* d, int height, int difference, int width); +void +mmx_alpha_blend_nodiff(uint32* s, uint32* d, int size); #endif -#if defined (__GNUC__) && defined (__x86_64__) -void mmx_alpha_blend_diff_ga (uint64 ga_64, uint32 *s, uint32 *d, int height, int difference, int width) {}; -void mmx_alpha_blend_nodiff_ga (uint64 ga_64, uint32 *s, uint32 *d, int size) {}; -void mmx_alpha_blend_diff (uint32 *s, uint32 *d, int height, int difference, int width) {}; -void mmx_alpha_blend_nodiff (uint32 *s, uint32 *d, int size) {}; +#if defined(__GNUC__) && defined(__x86_64__) +void +mmx_alpha_blend_diff_ga(uint64 ga_64, uint32* s, uint32* d, int height, int difference, int width){ +}; +void +mmx_alpha_blend_nodiff_ga(uint64 ga_64, uint32* s, uint32* d, int size){}; +void +mmx_alpha_blend_diff(uint32* s, uint32* d, int height, int difference, int width){}; +void +mmx_alpha_blend_nodiff(uint32* s, uint32* d, int size){}; #endif -void mmx_alpha_blend (bgra_pixel *src, bgra_pixel *dest, int ga, int w, int l, int t, int r, int b) +void +mmx_alpha_blend(bgra_pixel* src, bgra_pixel* dest, int ga, int w, int l, int t, int r, int b) // src and dest point to 32 bit pixel bitmaps, of equal width (w). // the rectangle (l,t,r,b) is blended onto dest. { -#if defined (__INTEL__) +#if defined(__INTEL__) bgra_pixel *s, *d; int width, height; int size, difference; uint64 ga_64, ga_s64; - + // Setup s and d so that they point to the upper left pixel of the // rectangle to be blended. - s = src + t*w + l; - d = dest + t*w + l; - + s = src + t * w + l; + d = dest + t * w + l; + // Compute the width and height of the rectangle to blend, // as well as the actual number of pixels - width = r - l + 1; - height = b - t + 1; - size = width*height; - difference = 4*(w - width); + width = r - l + 1; + height = b - t + 1; + size = width * height; + difference = 4 * (w - width); // Precompute ga_64 into 00ga 00ga 00ga 00ga ga_s64 = ga; ga_64 = (ga_s64 << 48) | (ga_s64 << 32) | (ga_s64 << 16) | ga_s64; - /* printf ("d: %d; l: %d t: %d r: %d b: %d; w: %d; width = %d, height = %d\n", + /* printf ("d: %d; l: %d t: %d r: %d b: %d; w: %d; width = %d, height = %d\n", difference, l, t, r, b, w, width, height);*/ - + // Here comes the dirty work. - if (difference) - { -#if defined (__MWCC__) + if (difference) { +#if defined(__MWCC__) uint64 ff_64 = 0x00FF00FF00FF00FFLL; - uint64 z_64 = 0x0000000000000000LL; + uint64 z_64 = 0x0000000000000000LL; asm { pusha - mov esi, s // source pointer - mov edi, d // dest pointer - mov ebx, height // number of rows - mov edx, difference // "makeup" - movq mm0, ga_64 // mm0 = 00ga 00ga 00ga 00ga - movq mm1, ff_64 // mm1 = 00FF 00FF 00FF 00FF + mov esi, s // source pointer + mov edi, d // dest pointer + mov ebx, height // number of rows + mov edx, difference // "makeup" + movq mm0, ga_64 // mm0 = 00ga 00ga 00ga 00ga + movq mm1, ff_64 // mm1 = 00FF 00FF 00FF 00FF fullloop: - mov ecx, width // # pixels per row + mov ecx, width // # pixels per row rowloop: - mov eax, [esi] // src pixel - - // Prepare alpha vector, source, and dest pixels - // The strange "interleaving" is to facilitate pairing (faster) - movd mm4, [edi] // mm4 = 0000 0000 dadr dgdb - shr eax, 16 // eax = 0000 sasr - movd mm3, [esi] // mm3 = 0000 0000 sasr sgsb - mov al, ah // eax = 0000 sasa - punpcklbw mm3, mm7 // mm3 = sa00 sr00 sg00 sb00 - shl eax, 8 // eax = 00sa sa00 - punpcklbw mm4, mm7 // mm4 = da00 dr00 dg00 db00 - mov al, ah // eax = 00sa sasa - movq mm5, mm1 // mm5 = 00FF 00FF 00FF 00FF - shl eax, 8 // eax = sasa sa00 - mov al, ah // eax = sasa sasa - movd mm2, eax // mm6 = 0000 0000 sasa sasa - punpcklbw mm2, mm7 // mm2 = 00sa 00sa 00sa 00sa - pmullw mm2, mm0 // mm2 = global_alpha*local_alpha - psrlw mm2, 8 // mm2 = ga*la/255 = alpha - pmullw mm3, mm2 // mm3 = src*alpha - psubw mm5, mm2 // mm5 = 1 - alpha - - // Calculate alpha*src + (255 - alpha)*dest - pmullw mm4, mm5 // mm4 = dest*(255 - alpha) - paddw mm3, mm4 // mm3 = 255*result - psrlw mm3, 8 // mm3 ~ result - - // Store the resulting pixel - packuswb mm3, mm3 // mm3 = xxxx xxxx rarr rgrb + mov eax, [esi] // src pixel + + // Prepare alpha vector, source, and dest pixels + // The strange "interleaving" is to facilitate pairing (faster) + movd mm4, [edi] // mm4 = 0000 0000 dadr dgdb + shr eax, 16 // eax = 0000 sasr + movd mm3, [esi] // mm3 = 0000 0000 sasr sgsb + mov al, ah // eax = 0000 sasa + punpcklbw mm3, mm7 // mm3 = sa00 sr00 sg00 sb00 + shl eax, 8 // eax = 00sa sa00 + punpcklbw mm4, mm7 // mm4 = da00 dr00 dg00 db00 + mov al, ah // eax = 00sa sasa + movq mm5, mm1 // mm5 = 00FF 00FF 00FF 00FF + shl eax, 8 // eax = sasa sa00 + mov al, ah // eax = sasa sasa + movd mm2, eax // mm6 = 0000 0000 sasa sasa + punpcklbw mm2, mm7 // mm2 = 00sa 00sa 00sa 00sa + pmullw mm2, mm0 // mm2 = global_alpha*local_alpha + psrlw mm2, 8 // mm2 = ga*la/255 = alpha + pmullw mm3, mm2 // mm3 = src*alpha + psubw mm5, mm2 // mm5 = 1 - alpha + + // Calculate alpha*src + (255 - alpha)*dest + pmullw mm4, mm5 // mm4 = dest*(255 - alpha) + paddw mm3, mm4 // mm3 = 255*result + psrlw mm3, 8 // mm3 ~ result + + // Store the resulting pixel + packuswb mm3, mm3 // mm3 = xxxx xxxx rarr rgrb opaque: - movd [edi], mm3 // store result + movd [edi], mm3 // store result add edi, 4 add esi, 4 - loop rowloop // Finish this row + loop rowloop // Finish this row add esi, edx - add edi, edx // Add the Makeup - dec ebx // More rows? - jnz fullloop // do them... + add edi, edx // Add the Makeup + dec ebx // More rows? + jnz fullloop // do them... end: emms @@ -146,60 +156,58 @@ void mmx_alpha_blend (bgra_pixel *src, bgra_pixel *dest, int ga, int w, int l, i } #else if (ga == 255) - mmx_alpha_blend_diff (s, d, height, difference, width); + mmx_alpha_blend_diff(s, d, height, difference, width); else - mmx_alpha_blend_diff_ga (ga_64, s, d, height, difference, width); + mmx_alpha_blend_diff_ga(ga_64, s, d, height, difference, width); #endif - } - else - { -#if defined (__MWCC__) + } else { +#if defined(__MWCC__) uint64 ff_64 = 0x00FF00FF00FF00FFLL; - uint64 z_64 = 0x0000000000000000LL; + uint64 z_64 = 0x0000000000000000LL; asm { pusha - mov esi, s // source pointer - mov edi, d // dest pointer - mov ecx, size // total # of pixels - movq mm0, ga_64 // mm0 = 00ga 00ga 00ga 00ga - movq mm1, ff_64 // mm1 = 00FF 00FF 00FF 00FF - movq mm7, z_64 // mm7 = 0000 0000 0000 0000 + mov esi, s // source pointer + mov edi, d // dest pointer + mov ecx, size // total # of pixels + movq mm0, ga_64 // mm0 = 00ga 00ga 00ga 00ga + movq mm1, ff_64 // mm1 = 00FF 00FF 00FF 00FF + movq mm7, z_64 // mm7 = 0000 0000 0000 0000 fullloop2: - mov eax, [esi] // src pixel - - // Prepare alpha vector, source, and dest pixels - // The strange "interleaving" is to facilitate pairing (faster) - movd mm4, [edi] // mm4 = 0000 0000 dadr dgdb - shr eax, 16 // eax = 0000 sasr - movd mm3, [esi] // mm3 = 0000 0000 sasr sgsb - mov al, ah // eax = 0000 sasa - punpcklbw mm3, mm7 // mm3 = sa00 sr00 sg00 sb00 - shl eax, 8 // eax = 00sa sa00 - punpcklbw mm4, mm7 // mm4 = da00 dr00 dg00 db00 - mov al, ah // eax = 00sa sasa - movq mm5, mm1 // mm5 = 00FF 00FF 00FF 00FF - movd mm2, eax // mm6 = 0000 0000 00sa sasa - punpcklbw mm2, mm7 // mm2 = 0000 00sa 00sa 00sa - pmullw mm2, mm0 // mm2 = global_alpha*local_alpha - psrlw mm2, 8 // mm2 = ga*la/255 = alpha - pmullw mm3, mm2 // mm3 = src*alpha - psubw mm5, mm2 // mm5 = 1 - alpha - - // Calculate alpha*src + (255 - alpha)*dest - pmullw mm4, mm5 // mm4 = dest*(255 - alpha) - paddw mm3, mm4 // mm3 = 255*result - psrlw mm3, 8 // mm3 ~ result - - // Store the resulting pixel - packuswb mm3, mm3 // mm3 = xxxx xxxx rarr rgrb + mov eax, [esi] // src pixel + + // Prepare alpha vector, source, and dest pixels + // The strange "interleaving" is to facilitate pairing (faster) + movd mm4, [edi] // mm4 = 0000 0000 dadr dgdb + shr eax, 16 // eax = 0000 sasr + movd mm3, [esi] // mm3 = 0000 0000 sasr sgsb + mov al, ah // eax = 0000 sasa + punpcklbw mm3, mm7 // mm3 = sa00 sr00 sg00 sb00 + shl eax, 8 // eax = 00sa sa00 + punpcklbw mm4, mm7 // mm4 = da00 dr00 dg00 db00 + mov al, ah // eax = 00sa sasa + movq mm5, mm1 // mm5 = 00FF 00FF 00FF 00FF + movd mm2, eax // mm6 = 0000 0000 00sa sasa + punpcklbw mm2, mm7 // mm2 = 0000 00sa 00sa 00sa + pmullw mm2, mm0 // mm2 = global_alpha*local_alpha + psrlw mm2, 8 // mm2 = ga*la/255 = alpha + pmullw mm3, mm2 // mm3 = src*alpha + psubw mm5, mm2 // mm5 = 1 - alpha + + // Calculate alpha*src + (255 - alpha)*dest + pmullw mm4, mm5 // mm4 = dest*(255 - alpha) + paddw mm3, mm4 // mm3 = 255*result + psrlw mm3, 8 // mm3 ~ result + + // Store the resulting pixel + packuswb mm3, mm3 // mm3 = xxxx xxxx rarr rgrb opaque2: - movd [edi], mm3 // store result + movd [edi], mm3 // store result add edi, 4 add esi, 4 - loop fullloop2 // Next pixel + loop fullloop2 // Next pixel end2: emms @@ -207,12 +215,12 @@ void mmx_alpha_blend (bgra_pixel *src, bgra_pixel *dest, int ga, int w, int l, i } #else if (ga == 255) - mmx_alpha_blend_nodiff (s, d, size); + mmx_alpha_blend_nodiff(s, d, size); else - mmx_alpha_blend_nodiff_ga (ga_64, s, d, size); + mmx_alpha_blend_nodiff_ga(ga_64, s, d, size); #endif } #else - fprintf (stderr, "MMX code called on non-Intel CPU?!\n"); + fprintf(stderr, "MMX code called on non-Intel CPU?!\n"); #endif } diff --git a/source/mmx.h b/source/mmx.h index 0e47453..15e4c6d 100644 --- a/source/mmx.h +++ b/source/mmx.h @@ -3,12 +3,14 @@ typedef uint32 bgra_pixel; -#if defined (__cplusplus) +#if defined(__cplusplus) extern "C" #endif -int mmx_available (void); + int + mmx_available(void); -#if defined (__cplusplus) +#if defined(__cplusplus) extern "C" #endif -void mmx_alpha_blend (bgra_pixel *src, bgra_pixel *dest, int ga, int w, int l, int t, int r, int b); + void + mmx_alpha_blend(bgra_pixel* src, bgra_pixel* dest, int ga, int w, int l, int t, int r, int b); diff --git a/source/scale.c b/source/scale.c index af79673..c45c879 100644 --- a/source/scale.c +++ b/source/scale.c @@ -8,230 +8,202 @@ #define TOL (1E-6) #define OMTOL (1 - TOL) -long gcd (long p, long q) +long +gcd(long p, long q) { - long r; - while (r = p % q, r) - { - p = q; - q = r; - } - return q; + long r; + while (r = p % q, r) { + p = q; + q = r; + } + return q; } -bool scale_p (picture *src, picture *dest) +bool +scale_p(picture* src, picture* dest) { - double xscale, yscale; - float *mtmp; - int x, y, nb, nbx, nby, msx, msy, mdx, mdy; + double xscale, yscale; + float* mtmp; + int x, y, nb, nbx, nby, msx, msy, mdx, mdy; - xscale = (double) dest->x/src->x; - yscale = (double) dest->y/src->y; - nbx = gcd (dest->x, src->x); - nby = gcd (dest->y, src->y); - mdx = dest->x/nbx; - mdy = dest->y/nby; - msx = src->x/nbx; - msy = src->y/nby; + xscale = (double)dest->x / src->x; + yscale = (double)dest->y / src->y; + nbx = gcd(dest->x, src->x); + nby = gcd(dest->y, src->y); + mdx = dest->x / nbx; + mdy = dest->y / nby; + msx = src->x / nbx; + msy = src->y / nby; - printf ("src: [%d, %d]; dest: [%d, %d]; xscale = %f, yscale = %f\n", - src->x, src->y, dest->x, dest->y, xscale, yscale); - mtmp = (float *) malloc (dest->x * src->y * sizeof (float)); - // mtmp contains the horizontally scaled image - printf ("xscale = %f\n", xscale); - if (xscale < 1) // Shrink horizontally - { - float *srcdata = src->data; - float *destdata = mtmp; - printf ("Shrink horizontally.\n"); - printf ("nbx = %i, msx = %i, mdx = %i\n", nbx, msx, mdx); - for (y = 0; y < src->y; y++) - { - float *srcline = srcdata + y*src->x; - float *destline = destdata + y*dest->x; - for (nb = 0; nb < nbx; nb++) - { - int s = 1; - int d = 1; - bool stillinblock = TRUE; - float alpha, beta; - float r = 0; - while (stillinblock) - { - while (s*mdx < d*msx) - { - r += *(srcline++)*mdx/msx; - s++; - } - if (s*mdx != d*msx) - { - beta = (float) s*mdx/msx - d; - alpha = (float) mdx/msx - beta; - r += alpha* *(srcline); - *(destline++) = r; - d++; - r = beta* *(srcline++); - s++; - } - else - { - r += *(srcline++)*mdx/msx; - *(destline++) = r; - stillinblock = FALSE; - } - } - } - } - } - else if (xscale > 1) // Stretch horizontally - { - float *srcdata = src->data; - float *destdata = mtmp; - printf ("Stretch horizontally.\n"); - printf ("nbx = %i, msx = %i, mdx = %i\n", nbx, msx, mdx); - for (y = 0; y < src->y; y++) - { - float *destline = destdata + y*dest->x; - float *srcline = srcdata + y*src->x; - for (nb = 0; nb < nbx; nb++) - { - int s = 1; - int d = 1; - bool stillinblock = TRUE; - float alpha, beta; - while (stillinblock) - { - while (d*msx < s*mdx) - { - *(destline++) = *srcline; - d++; - } - if (d*msx != s*mdx) - { - alpha = (float) d*msx/mdx - s; - beta = 1 - alpha; - *(destline++) = alpha*(*srcline) + beta*(*(srcline+1)); - srcline++; - s++; - d++; - } - else - { - *(destline++) = *(srcline++); - stillinblock = FALSE; - } - } - } - } - } - else // No scaling in x-dimension -> copy to temp bitmap. - { - printf ("No scaling in x-dimension -> copy to temp bitmap.\n"); - memcpy (mtmp, src->data, src->x*src->y*sizeof (float)); - } - printf ("yscale = %f\n", yscale); - if (yscale < 1) // Shrink vertically - { - float *srcdata = mtmp; - float *destdata = dest->data; - int line = dest->x; - printf ("Shrink vertically\n"); - printf ("nby = %i, msy = %i, mdy = %i\n", nby, msy, mdy); - for (x = 0; x < dest->x; x++) - { - float *destcol = destdata + x; - float *srccol = srcdata + x; - for (nb = 0; nb< nby; nb++) - { - int s = 1; - int d = 1; - bool stillinblock = TRUE; - float alpha, beta; - float r = 0; - while (stillinblock) - { - while (s*mdy < d*msy) - { - r += *srccol * mdy/msy; - srccol += line; - s++; - } - if (s*mdy != d*msy) - { - beta = (float) s*mdy/msy - d; - alpha = (float) mdy/msy - beta; - r += alpha* *srccol; - *destcol = r; - destcol += line; - d++; - r = beta* *srccol; - srccol += line; - s++; - } - else - { - r += *srccol * mdy/msy; - srccol += line; - *destcol = r; - destcol += line; - stillinblock = FALSE; - } - } - } - } - } - else if (yscale > 1) // Stretch vertically - { - float *srcdata = mtmp; - float *destdata = dest->data; - int line = dest->x; - printf ("Stretch vertically\n"); - printf ("nby = %i, msy = %i, mdy = %i\n", nby, msy, mdy); - for (x = 0; x < dest->x; x++) - { - float *destcol = destdata + x; - float *srccol = srcdata + x; - for (nb = 0; nb < nby; nb++) - { - int s = 1; - int d = 1; - bool stillinblock = FALSE; - float alpha, beta; - while (stillinblock) - { - while (d*msy < s*mdy) - { - *destcol = *srccol; - destcol += line; - d++; - } - if (d*msy != s*mdy) - { - alpha = (float) d*msy/mdy - s; - beta = 1 - alpha; - *destcol = alpha* *srccol + beta* *(srccol + line); - destcol += line; - d++; - srccol += line; - s++; - } - else - { - *destcol = *srccol; - destcol += line; - srccol += line; - stillinblock = FALSE; - } - } - } - } - } - else // No scaling in y-dimension -> Just copy the bitmap to dest. - { - printf ("No scaling in y-dimension -> Just copy the bitmap to dest.\n"); - memcpy (dest->data, mtmp, dest->x*dest->y*sizeof (float)); - } - printf ("Done.\n"); - free (mtmp); printf ("Freed.\n"); - return 0; + printf( + "src: [%d, %d]; dest: [%d, %d]; xscale = %f, yscale = %f\n", src->x, src->y, dest->x, + dest->y, xscale, yscale + ); + mtmp = (float*)malloc(dest->x * src->y * sizeof(float)); + // mtmp contains the horizontally scaled image + printf("xscale = %f\n", xscale); + if (xscale < 1) // Shrink horizontally + { + float* srcdata = src->data; + float* destdata = mtmp; + printf("Shrink horizontally.\n"); + printf("nbx = %i, msx = %i, mdx = %i\n", nbx, msx, mdx); + for (y = 0; y < src->y; y++) { + float* srcline = srcdata + y * src->x; + float* destline = destdata + y * dest->x; + for (nb = 0; nb < nbx; nb++) { + int s = 1; + int d = 1; + bool stillinblock = TRUE; + float alpha, beta; + float r = 0; + while (stillinblock) { + while (s * mdx < d * msx) { + r += *(srcline++) * mdx / msx; + s++; + } + if (s * mdx != d * msx) { + beta = (float)s * mdx / msx - d; + alpha = (float)mdx / msx - beta; + r += alpha * *(srcline); + *(destline++) = r; + d++; + r = beta * *(srcline++); + s++; + } else { + r += *(srcline++) * mdx / msx; + *(destline++) = r; + stillinblock = FALSE; + } + } + } + } + } else if (xscale > 1) // Stretch horizontally + { + float* srcdata = src->data; + float* destdata = mtmp; + printf("Stretch horizontally.\n"); + printf("nbx = %i, msx = %i, mdx = %i\n", nbx, msx, mdx); + for (y = 0; y < src->y; y++) { + float* destline = destdata + y * dest->x; + float* srcline = srcdata + y * src->x; + for (nb = 0; nb < nbx; nb++) { + int s = 1; + int d = 1; + bool stillinblock = TRUE; + float alpha, beta; + while (stillinblock) { + while (d * msx < s * mdx) { + *(destline++) = *srcline; + d++; + } + if (d * msx != s * mdx) { + alpha = (float)d * msx / mdx - s; + beta = 1 - alpha; + *(destline++) = alpha * (*srcline) + beta * (*(srcline + 1)); + srcline++; + s++; + d++; + } else { + *(destline++) = *(srcline++); + stillinblock = FALSE; + } + } + } + } + } else // No scaling in x-dimension -> copy to temp bitmap. + { + printf("No scaling in x-dimension -> copy to temp bitmap.\n"); + memcpy(mtmp, src->data, src->x * src->y * sizeof(float)); + } + printf("yscale = %f\n", yscale); + if (yscale < 1) // Shrink vertically + { + float* srcdata = mtmp; + float* destdata = dest->data; + int line = dest->x; + printf("Shrink vertically\n"); + printf("nby = %i, msy = %i, mdy = %i\n", nby, msy, mdy); + for (x = 0; x < dest->x; x++) { + float* destcol = destdata + x; + float* srccol = srcdata + x; + for (nb = 0; nb < nby; nb++) { + int s = 1; + int d = 1; + bool stillinblock = TRUE; + float alpha, beta; + float r = 0; + while (stillinblock) { + while (s * mdy < d * msy) { + r += *srccol * mdy / msy; + srccol += line; + s++; + } + if (s * mdy != d * msy) { + beta = (float)s * mdy / msy - d; + alpha = (float)mdy / msy - beta; + r += alpha * *srccol; + *destcol = r; + destcol += line; + d++; + r = beta * *srccol; + srccol += line; + s++; + } else { + r += *srccol * mdy / msy; + srccol += line; + *destcol = r; + destcol += line; + stillinblock = FALSE; + } + } + } + } + } else if (yscale > 1) // Stretch vertically + { + float* srcdata = mtmp; + float* destdata = dest->data; + int line = dest->x; + printf("Stretch vertically\n"); + printf("nby = %i, msy = %i, mdy = %i\n", nby, msy, mdy); + for (x = 0; x < dest->x; x++) { + float* destcol = destdata + x; + float* srccol = srcdata + x; + for (nb = 0; nb < nby; nb++) { + int s = 1; + int d = 1; + bool stillinblock = FALSE; + float alpha, beta; + while (stillinblock) { + while (d * msy < s * mdy) { + *destcol = *srccol; + destcol += line; + d++; + } + if (d * msy != s * mdy) { + alpha = (float)d * msy / mdy - s; + beta = 1 - alpha; + *destcol = alpha * *srccol + beta * *(srccol + line); + destcol += line; + d++; + srccol += line; + s++; + } else { + *destcol = *srccol; + destcol += line; + srccol += line; + stillinblock = FALSE; + } + } + } + } + } else // No scaling in y-dimension -> Just copy the bitmap to dest. + { + printf("No scaling in y-dimension -> Just copy the bitmap to dest.\n"); + memcpy(dest->data, mtmp, dest->x * dest->y * sizeof(float)); + } + printf("Done.\n"); + free(mtmp); + printf("Freed.\n"); + return 0; } diff --git a/source/sfx.cpp b/source/sfx.cpp index ded41e0..17ea975 100644 --- a/source/sfx.cpp +++ b/source/sfx.cpp @@ -1,19 +1,19 @@ -#if defined (EASTER_EGG_SFX) +#if defined(EASTER_EGG_SFX) #include "sfx.h" #include #include #ifndef MIN -#define MIN(x,y) ((x)<(y)?(x):(y)) +#define MIN(x, y) ((x) < (y) ? (x) : (y)) #endif -EffectsPlayer::EffectsPlayer (SoundEffect8_11 *fx) +EffectsPlayer::EffectsPlayer(SoundEffect8_11* fx) { media_raw_audio_format format; format.format = media_raw_audio_format::B_AUDIO_FLOAT; format.frame_rate = 11000; format.channel_count = 2; -#if defined (__INTEL__) +#if defined(__INTEL__) format.byte_order = 2; #else format.byte_order = 1; @@ -24,106 +24,101 @@ EffectsPlayer::EffectsPlayer (SoundEffect8_11 *fx) cookie->size = fx->size(); cookie->buf = fx->data(); cookie->parent = this; - - myPlayer = new BSoundPlayer (&format, "Easter Egg", BufferProc, NULL, cookie); -// printf ("bufsize: %ld\n", format.buffer_size); - -// myPlayer = new BSoundPlayer (&format, "Easter Egg"); + myPlayer = new BSoundPlayer(&format, "Easter Egg", BufferProc, NULL, cookie); + + // printf ("bufsize: %ld\n", format.buffer_size); + + // myPlayer = new BSoundPlayer (&format, "Easter Egg"); myPlayer->Start(); - myPlayer->SetVolume (0.5); - myPlayer->SetHasData (false); + myPlayer->SetVolume(0.5); + myPlayer->SetHasData(false); } -EffectsPlayer::~EffectsPlayer () +EffectsPlayer::~EffectsPlayer() { -// printf ("~EffectsPlayer\n"); + // printf ("~EffectsPlayer\n"); if (myPlayer) - myPlayer->Stop (false); -// printf ("Stopped BSoundPlayer...\n"); + myPlayer->Stop(false); + // printf ("Stopped BSoundPlayer...\n"); delete myPlayer; delete cookie; -// printf ("Deleted BSoundPlayer...\n"); + // printf ("Deleted BSoundPlayer...\n"); } -void EffectsPlayer::StartEffect () +void +EffectsPlayer::StartEffect() { -// printf ("Starting sound effect...\n"); -/* media_raw_audio_format format = effect->sound()->Format(); - printf ("format = %ld\n", format.format); - if (format.format != media_raw_audio_format::B_AUDIO_FLOAT) - printf ("HEY!!\n"); - myPlayer->StartPlaying (effect->sound()); -*/ - //myPlayer->Start(); - myPlayer->SetHasData (true); + // printf ("Starting sound effect...\n"); + /* media_raw_audio_format format = effect->sound()->Format(); + printf ("format = %ld\n", format.format); + if (format.format != media_raw_audio_format::B_AUDIO_FLOAT) + printf ("HEY!!\n"); + myPlayer->StartPlaying (effect->sound()); + */ + // myPlayer->Start(); + myPlayer->SetHasData(true); } -void BufferProc (void *theCookie, void *buffer, size_t size, const media_raw_audio_format &format) +void +BufferProc(void* theCookie, void* buffer, size_t size, const media_raw_audio_format& format) { -// printf ("BufferProc (%p, %ld)\n", buffer, size); + // printf ("BufferProc (%p, %ld)\n", buffer, size); size_t i, j; - float *buf = (float *) buffer; + float* buf = (float*)buffer; uint32 channel_count = format.channel_count; - size_t num_frames = size/(4*channel_count); - cookie_record *cookie = (cookie_record *) theCookie; - - if (format.format != media_raw_audio_format::B_AUDIO_FLOAT) - { - printf ("Hey!!\n"); + size_t num_frames = size / (4 * channel_count); + cookie_record* cookie = (cookie_record*)theCookie; + + if (format.format != media_raw_audio_format::B_AUDIO_FLOAT) { + printf("Hey!!\n"); return; } - + int32 pos = cookie->pos; - num_frames = MIN (num_frames, (cookie->size - pos)/channel_count); -// printf ("%p, %ld, %ld\n", cookie->buf, cookie->size, float_size); - if (num_frames) - { - for (i = 0; i < num_frames*channel_count; i += channel_count) - { - for (j = 0; j < channel_count; j++) - { -// printf ("%f\n", buf[i + j]); - buf[i + j] = cookie->buf[pos + i + j]; - } + num_frames = MIN(num_frames, (cookie->size - pos) / channel_count); + // printf ("%p, %ld, %ld\n", cookie->buf, cookie->size, float_size); + if (num_frames) { + for (i = 0; i < num_frames * channel_count; i += channel_count) { + for (j = 0; j < channel_count; j++) { + // printf ("%f\n", buf[i + j]); + buf[i + j] = cookie->buf[pos + i + j]; + } } -// for (i = num_frames - 1; i < size/4/channel_count; i += channel_count) -// { -// for (j = 0; j < channel_count; j++) -// buf[i + j] = 0.0; -// } - cookie->pos += channel_count*num_frames; - } - else - { -// printf ("Done.\n"); - cookie->parent->player()->SetHasData (false); - //cookie->parent->player()->Stop(); + // for (i = num_frames - 1; i < size/4/channel_count; i += channel_count) + // { + // for (j = 0; j < channel_count; j++) + // buf[i + j] = 0.0; + // } + cookie->pos += channel_count * num_frames; + } else { + // printf ("Done.\n"); + cookie->parent->player()->SetHasData(false); + // cookie->parent->player()->Stop(); cookie->pos = 0; } -} +} //=========== -SoundEffect8_11::SoundEffect8_11 (void *data, size_t size) +SoundEffect8_11::SoundEffect8_11(void* data, size_t size) { - myData = new float [2*size]; - unsigned char *cd = (unsigned char *) data; - for (int i = 0; i < size; i++) - { + myData = new float[2 * size]; + unsigned char* cd = (unsigned char*)data; + for (int i = 0; i < size; i++) { // pan from left to right // (some day that is - it seems to be broken using (1 - pan)...) - float val = (float (cd[i]) - 127.0)/300.0; - float pan = float (i)/size; - myData[2*i] = val*(pan); //? - myData[2*i + 1] = val*(pan); + float val = (float(cd[i]) - 127.0) / 300.0; + float pan = float(i) / size; + myData[2 * i] = val * (pan); //? + myData[2 * i + 1] = val * (pan); } - fSize = size; // in frames, not bytes!! + fSize = size; // in frames, not bytes!! } -SoundEffect8_11::~SoundEffect8_11 () +SoundEffect8_11::~SoundEffect8_11() { -// printf ("~SE\n"); + // printf ("~SE\n"); delete myData; } diff --git a/source/sfx.h b/source/sfx.h index 9a8492c..b1cc2ea 100644 --- a/source/sfx.h +++ b/source/sfx.h @@ -4,45 +4,50 @@ #include #include -void BufferProc (void *theCookie, void *buffer, size_t size, const media_raw_audio_format &format); +void +BufferProc(void* theCookie, void* buffer, size_t size, const media_raw_audio_format& format); class SoundEffect8_11 { -public: - SoundEffect8_11 (void *data, size_t size); - ~SoundEffect8_11 (); -BSound *sound () { return mySound; }; -float *data () { return myData; }; -int size () { return fSize; }; - -private: -BSound *mySound; -float *myData; -int fSize; + public: + SoundEffect8_11(void* data, size_t size); + ~SoundEffect8_11(); + + BSound* sound() { return mySound; }; + + float* data() { return myData; }; + + int size() { return fSize; }; + + private: + BSound* mySound; + float* myData; + int fSize; }; class EffectsPlayer; typedef struct cookie_record { - int32 pos; - int32 size; - float *buf; - EffectsPlayer *parent; + int32 pos; + int32 size; + float* buf; + EffectsPlayer* parent; } cookie_record; class EffectsPlayer { -public: - EffectsPlayer (SoundEffect8_11 *effect); -virtual ~EffectsPlayer (); -void StartEffect (); -BSoundPlayer *player() { return myPlayer; }; - -private: -BSoundPlayer *myPlayer; -BSound *myEffect; -cookie_record *cookie; + public: + EffectsPlayer(SoundEffect8_11* effect); + virtual ~EffectsPlayer(); + void StartEffect(); + + BSoundPlayer* player() { return myPlayer; }; + + private: + BSoundPlayer* myPlayer; + BSound* myEffect; + cookie_record* cookie; }; #endif diff --git a/source/undo_entry.h b/source/undo_entry.h index d3ac9aa..7406e3c 100644 --- a/source/undo_entry.h +++ b/source/undo_entry.h @@ -6,23 +6,23 @@ typedef struct { -int32 type; -int32 layer; -int32 next; -SBitmap *bitmap; -SBitmap *sbitmap; -char fName[MAXLAYERNAME]; -int fMode; -uchar fGlobalAlpha; -bool fHide; + int32 type; + int32 layer; + int32 next; + SBitmap* bitmap; + SBitmap* sbitmap; + char fName[MAXLAYERNAME]; + int fMode; + uchar fGlobalAlpha; + bool fHide; } undo_entry; -#define UNDO_DRAW 1 -#define UNDO_SELECT 2 -#define UNDO_SWITCH 3 -#define UNDO_RESIZED 4 -#define UNDO_MERGE 5 -#define UNDO_LDEL 6 -#define UNDO_BOTH 7 +#define UNDO_DRAW 1 +#define UNDO_SELECT 2 +#define UNDO_SWITCH 3 +#define UNDO_RESIZED 4 +#define UNDO_MERGE 5 +#define UNDO_LDEL 6 +#define UNDO_BOTH 7 #endif \ No newline at end of file