Ticket #2117: 2117.diff
File 2117.diff, 39.2 KB (added by , 15 years ago) |
---|
-
src/add-ons/translators/tiff/TIFFTranslator.cpp
945 945 BView * 946 946 TIFFTranslator::NewConfigView(TranslatorSettings *settings) 947 947 { 948 return new TIFFView(BRect(0, 0, 225, 175), "TIFFTranslator Settings", 949 B_FOLLOW_ALL, B_WILL_DRAW, settings); 948 return new TIFFView("TIFFTranslator Settings", B_WILL_DRAW, settings); 950 949 } -
src/add-ons/translators/tiff/TIFFView.cpp
32 32 #include <stdio.h> 33 33 #include <string.h> 34 34 35 #include <GridLayoutBuilder.h> 36 #include <GroupLayout.h> 37 #include <GroupLayoutBuilder.h> 35 38 #include <MenuBar.h> 36 39 #include <MenuField.h> 37 40 #include <MenuItem.h> … … 73 76 // 74 77 // Returns: 75 78 // --------------------------------------------------------------- 76 TIFFView::TIFFView(const BRect &frame, const char *name, 77 uint32 resize, uint32 flags, TranslatorSettings *settings) 78 : BView(frame, name, resize, flags) 79 TIFFView::TIFFView(const char *name, uint32 flags, TranslatorSettings *settings) 80 : BView(name, flags) 79 81 { 80 82 fSettings = settings; 81 83 82 84 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 83 85 SetLowColor(ViewColor()); 84 86 87 fTitle = new BStringView("title", "TIFF Image Translator"); 88 fTitle->SetFont(be_bold_font); 89 90 char detail[100]; 91 sprintf(detail, "Version %d.%d.%d %s", 92 static_cast<int>(B_TRANSLATION_MAJOR_VERSION(TIFF_TRANSLATOR_VERSION)), 93 static_cast<int>(B_TRANSLATION_MINOR_VERSION(TIFF_TRANSLATOR_VERSION)), 94 static_cast<int>(B_TRANSLATION_REVISION_VERSION(TIFF_TRANSLATOR_VERSION)), 95 __DATE__); 96 fDetail = new BStringView("detail", detail); 97 98 int16 i = 1; 99 fLibTIFF[0] = new BStringView(NULL, "TIFF Library:"); 100 char libtiff[] = TIFFLIB_VERSION_STR; 101 char *tok = strtok(libtiff, "\n"); 102 while (i < 5 && tok) { 103 fLibTIFF[i] = new BStringView(NULL, tok); 104 tok = strtok(NULL, "\n"); 105 i++; 106 } 107 85 108 BPopUpMenu* menu = new BPopUpMenu("pick compression"); 86 109 87 110 uint32 currentCompression = fSettings->SetGetInt32(TIFF_SETTING_COMPRESSION); … … 98 121 // TODO ? - strip encoding is not implemented in libTIFF for this compression 99 122 // add_menu_item(menu, COMPRESSION_JP2000, "JPEG2000", currentCompression); 100 123 101 fCompressionMF = new BMenuField(BRect(20, 50, 215, 70), "compression", 102 "Use Compression:", menu, true); 103 fCompressionMF->ResizeToPreferred(); 104 fCompressionMF->SetDivider( 105 fCompressionMF->StringWidth(fCompressionMF->Label()) + 7); 106 AddChild(fCompressionMF); 124 fCompressionMF = new BMenuField("Use Compression:", menu, NULL); 107 125 126 // Build the layout 127 SetLayout(new BGroupLayout(B_VERTICAL)); 128 129 i = 0; 130 AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) 131 .Add(fTitle) 132 .Add(fDetail) 133 .AddGlue() 134 .Add(fCompressionMF) 135 .AddGlue() 136 .Add(fLibTIFF[0]) 137 .Add(fLibTIFF[1]) 138 .Add(fLibTIFF[2]) 139 .Add(fLibTIFF[3]) 140 // Theses 4 adding above work because we know there are 4 strings 141 // but it's fragile: one string less in the library version and the application breaks 142 .AddGlue() 143 .SetInsets(5, 5, 5, 5) 144 ); 145 146 BFont font; 147 GetFont(&font); 148 SetExplicitPreferredSize(BSize((font.Size() * 350)/12, (font.Size() * 200)/12)); 108 149 } 109 150 110 151 // --------------------------------------------------------------- … … 148 189 fSettings->SetGetInt32(TIFF_SETTING_COMPRESSION, &value); 149 190 fSettings->SaveSettings(); 150 191 } 151 fCompressionMF->ResizeToPreferred();152 192 break; 153 193 } 154 194 default: … … 177 217 fCompressionMF->ResizeToPreferred(); 178 218 } 179 219 180 181 // ---------------------------------------------------------------182 // Draw183 //184 // Draws information about the TIFFTranslator to this view.185 //186 // Preconditions:187 //188 // Parameters: area, not used189 //190 // Postconditions:191 //192 // Returns:193 // ---------------------------------------------------------------194 void195 TIFFView::Draw(BRect area)196 {197 SetFont(be_bold_font);198 font_height fh;199 GetFontHeight(&fh);200 float xbold, ybold;201 xbold = fh.descent + 1;202 ybold = fh.ascent + fh.descent * 2 + fh.leading;203 204 char title[] = "TIFF Image Translator";205 DrawString(title, BPoint(xbold, ybold));206 207 SetFont(be_plain_font);208 font_height plainh;209 GetFontHeight(&plainh);210 float yplain;211 yplain = plainh.ascent + plainh.descent * 2 + plainh.leading;212 213 char detail[100];214 sprintf(detail, "Version %d.%d.%d %s",215 static_cast<int>(B_TRANSLATION_MAJOR_VERSION(TIFF_TRANSLATOR_VERSION)),216 static_cast<int>(B_TRANSLATION_MINOR_VERSION(TIFF_TRANSLATOR_VERSION)),217 static_cast<int>(B_TRANSLATION_REVISION_VERSION(TIFF_TRANSLATOR_VERSION)),218 __DATE__);219 DrawString(detail, BPoint(xbold, yplain + ybold));220 221 int32 lineno = 6;222 DrawString("TIFF Library:", BPoint(xbold, yplain * lineno + ybold));223 lineno += 2;224 225 char libtiff[] = TIFFLIB_VERSION_STR;226 char *tok = strtok(libtiff, "\n");227 while (tok) {228 DrawString(tok, BPoint(xbold, yplain * lineno + ybold));229 lineno++;230 tok = strtok(NULL, "\n");231 }232 } -
src/add-ons/translators/tiff/TIFFMain.cpp
54 54 { 55 55 BApplication app("application/x-vnd.obos-tiff-translator"); 56 56 status_t result; 57 result = LaunchTranslatorWindow(new TIFFTranslator, 58 "TIFF Settings", BRect(0, 0, 225, 175)); 57 result = LaunchTranslatorWindow(new TIFFTranslator, "TIFF Settings"); 59 58 if (result == B_OK) { 60 59 app.Run(); 61 60 return 0; -
src/add-ons/translators/tiff/TIFFView.h
34 34 35 35 #include <View.h> 36 36 #include <MenuField.h> 37 #include <StringView.h> 37 38 #include "TranslatorSettings.h" 38 39 39 40 class TIFFView : public BView { 40 41 public: 41 TIFFView(const BRect &frame, const char *name, uint32 resize, 42 uint32 flags, TranslatorSettings *settings); 42 TIFFView(const char *name, uint32 flags, TranslatorSettings *settings); 43 43 // sets up the view 44 44 45 45 ~TIFFView(); … … 48 48 virtual void AllAttached(); 49 49 virtual void MessageReceived(BMessage *message); 50 50 51 virtual void Draw(BRect area);52 // draws information about the TIFFTranslator53 54 51 enum { 55 52 MSG_COMPRESSION_CHANGED = 'cmch', 56 53 }; 57 54 58 55 private: 56 BStringView* fTitle; 57 BStringView* fDetail; 58 BStringView* fLibTIFF[5]; 59 59 BMenuField* fCompressionMF; 60 60 61 61 TranslatorSettings *fSettings; -
src/add-ons/translators/raw/ConfigView.cpp
9 9 10 10 #include <StringView.h> 11 11 #include <CheckBox.h> 12 #include <GroupLayout.h> 13 #include <GroupLayoutBuilder.h> 12 14 13 15 #include <stdio.h> 14 16 #include <string.h> 15 17 16 18 17 ConfigView::ConfigView( const BRect &frame, uint32 resize,uint32 flags)18 : BView( frame, "RAWTranslator Settings", resize, flags)19 ConfigView::ConfigView(uint32 flags) 20 : BView("RAWTranslator Settings", flags) 19 21 { 20 22 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 21 23 22 font_height fontHeight; 23 be_bold_font->GetHeight(&fontHeight); 24 float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; 24 BStringView *fTitle = new BStringView("title", "RAW Images"); 25 fTitle->SetFont(be_bold_font); 25 26 26 BRect rect(10, 10, 200, 10 + height);27 BStringView *stringView = new BStringView(rect, "title", "RAW Images");28 stringView->SetFont(be_bold_font);29 stringView->ResizeToPreferred();30 AddChild(stringView);31 32 rect.OffsetBy(0, height + 10);33 27 char version[256]; 34 28 sprintf(version, "Version %d.%d.%d, %s", 35 29 int(B_TRANSLATION_MAJOR_VERSION(RAW_TRANSLATOR_VERSION)), 36 30 int(B_TRANSLATION_MINOR_VERSION(RAW_TRANSLATOR_VERSION)), 37 31 int(B_TRANSLATION_REVISION_VERSION(RAW_TRANSLATOR_VERSION)), 38 32 __DATE__); 39 stringView = new BStringView(rect, "version", version); 40 stringView->ResizeToPreferred(); 41 AddChild(stringView); 33 BStringView *fVersion = new BStringView("version", version); 42 34 43 GetFontHeight(&fontHeight);44 height = fontHeight.descent + fontHeight.ascent + fontHeight.leading;35 BStringView *fCopyright = new BStringView("copyright", 36 B_UTF8_COPYRIGHT "2007 Haiku Inc."); 45 37 46 rect.OffsetBy(0, height + 5); 47 stringView = new BStringView(rect, "copyright", B_UTF8_COPYRIGHT "2007 Haiku Inc."); 48 stringView->ResizeToPreferred(); 49 AddChild(stringView); 38 BStringView *fCopyright2 = new BStringView("copyright2", 39 "Based on Dave Coffin's dcraw 8.63"); 50 40 51 rect.OffsetBy(0, height + 10); 52 stringView = new BStringView(rect, "copyright2", "Based on Dave Coffin's dcraw 8.63"); 53 stringView->ResizeToPreferred(); 54 AddChild(stringView); 41 BStringView *fCopyright3 = new BStringView("copyright3", 42 B_UTF8_COPYRIGHT "1997-2007 Dave Coffin"); 55 43 56 rect.OffsetBy(0, height + 5); 57 stringView = new BStringView(rect, "copyright3", B_UTF8_COPYRIGHT "1997-2007 Dave Coffin"); 58 stringView->ResizeToPreferred(); 59 AddChild(stringView); 44 // Build the layout 45 SetLayout(new BGroupLayout(B_HORIZONTAL)); 46 47 AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) 48 .Add(fTitle) 49 .AddGlue() 50 .Add(fVersion) 51 .Add(fCopyright) 52 .AddGlue() 53 .Add(fCopyright2) 54 .Add(fCopyright3) 55 .AddGlue() 56 .SetInsets(5, 5, 5, 5) 57 ); 58 59 BFont font; 60 GetFont(&font); 61 SetExplicitPreferredSize(BSize((font.Size() * 233)/12, (font.Size() * 200)/12)); 60 62 } 61 63 62 64 -
src/add-ons/translators/raw/RAWTranslator.cpp
326 326 BView * 327 327 RAWTranslator::NewConfigView(TranslatorSettings *settings) 328 328 { 329 return new ConfigView( BRect(0, 0, 225, 175));329 return new ConfigView(); 330 330 } 331 331 332 332 -
src/add-ons/translators/raw/main.cpp
15 15 #if SHOW_MODE && TEST_MODE 16 16 # include <Bitmap.h> 17 17 # include <BitmapStream.h> 18 # include <GroupLayout.h> 18 19 # include <String.h> 19 20 # include <View.h> 20 21 # include <Window.h> … … 114 115 if (status == B_OK) 115 116 status = output.DetachBitmap(&bitmap); 116 117 if (status == B_OK) { 117 BWindow* window = new BWindow(BRect(50, 50, 118 bitmap->Bounds().Width() + 50, 119 bitmap->Bounds().Height() + 50), 118 BWindow* window = new BWindow(BRect(0, 0, 1, 1), 120 119 "RAW", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS 121 | B_NOT_RESIZABLE );120 | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS); 122 121 BView* view = new BView(window->Bounds(), NULL, 123 122 B_WILL_DRAW, B_FOLLOW_NONE); 124 123 window->AddChild(view); 124 window->SetLayout(new BGroupLayout(B_HORIZONTAL)); 125 125 window->Show(); 126 126 snooze(300000); 127 127 window->Lock(); … … 140 140 } 141 141 #endif 142 142 143 status_t status = LaunchTranslatorWindow(new RAWTranslator, "RAW Settings", 144 BRect(0, 0, 225, 175)); 143 status_t status = LaunchTranslatorWindow(new RAWTranslator, "RAW Settings"); 145 144 if (status != B_OK) 146 145 return 1; 147 146 -
src/add-ons/translators/raw/ConfigView.h
11 11 12 12 class ConfigView : public BView { 13 13 public: 14 ConfigView(const BRect &frame, uint32 resize = B_FOLLOW_ALL, 15 uint32 flags = B_WILL_DRAW); 14 ConfigView(uint32 flags = B_WILL_DRAW); 16 15 virtual ~ConfigView(); 17 16 }; 18 17 -
src/add-ons/translators/ppm/PPMMain.cpp
9 9 #include <Application.h> 10 10 #include <Alert.h> 11 11 #include <Screen.h> 12 #include <GroupLayout.h> 12 13 13 14 #include <stdio.h> 14 15 … … 20 21 public BWindow 21 22 { 22 23 public: 23 PPMWindow( 24 BRect area) :25 BWindow(area, "PPM Settings", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)24 PPMWindow(BRect area) : 25 BWindow(area, "PPM Settings", B_TITLED_WINDOW, 26 B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) 26 27 { 28 SetLayout(new BGroupLayout(B_HORIZONTAL)); 27 29 } 28 30 ~PPMWindow() 29 31 { … … 39 41 { 40 42 BApplication app("application/x-vnd.hplus-ppm-translator"); 41 43 BView * v = NULL; 42 BRect r(0, 0,225,175);44 BRect r(0, 0, 1, 1); 43 45 if (MakeConfig(NULL, &v, &r)) { 44 46 BAlert * err = new BAlert("Error", "Something is wrong with the PPMTranslator!", "OK"); 45 47 err->Go(); -
src/add-ons/translators/ppm/PPMTranslator.cpp
21 21 #include <MenuItem.h> 22 22 #include <CheckBox.h> 23 23 #include <Bitmap.h> 24 #include <StringView.h> 25 #include <GridLayoutBuilder.h> 26 #include <GroupLayout.h> 27 #include <GroupLayoutBuilder.h> 28 #include <SpaceLayoutItem.h> 24 29 25 30 #include <ctype.h> 26 31 #include <string.h> … … 430 435 { 431 436 public: 432 437 PPMView( 433 const BRect & frame,434 438 const char * name, 435 uint32 resize,436 439 uint32 flags) : 437 BView( frame, name, resize, flags)440 BView(name, flags) 438 441 { 439 442 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 440 443 SetLowColor(ViewColor()); 444 445 mTitle = new BStringView("title", "PPM Image Translator"); 446 mTitle->SetFont(be_bold_font); 447 448 char detail[100]; 449 int ver = static_cast<int>(translatorVersion); 450 sprintf(detail, "Version %d.%d.%d %s", ver >> 8, ((ver >> 4) & 0xf), 451 (ver & 0xf), __DATE__); 452 mDetail = new BStringView("detail", detail); 453 454 mBasedOn = new BStringView("basedOn", 455 "Based on PPMTranslator sample code"); 456 457 mCopyright = new BStringView("copyright", 458 "Sample code copyright 1999, Be Incorporated"); 459 441 460 mMenu = new BPopUpMenu("Color Space"); 442 461 mMenu->AddItem(new BMenuItem("None", CSMessage(B_NO_COLOR_SPACE))); 443 462 mMenu->AddItem(new BMenuItem("RGB 8:8:8 32 bits", CSMessage(B_RGB32))); … … 458 477 mMenu->AddItem(new BMenuItem("RGB 5:5:5 16 bits big-endian", CSMessage(B_RGB15_BIG))); 459 478 mMenu->AddItem(new BMenuItem("RGBA 5:5:5:1 16 bits big-endian", CSMessage(B_RGBA15_BIG))); 460 479 mMenu->AddItem(new BMenuItem("RGB 5:6:5 16 bits big-endian", CSMessage(B_RGB16))); 461 mField = new BMenuField(BRect(10,110,190,130), "Color Space Field", "Input Color Space", mMenu); 462 mField->SetDivider(mField->StringWidth(mField->Label()) + 7); 480 mField = new BMenuField("Input Color Space", mMenu, NULL); 463 481 mField->SetViewColor(ViewColor()); 464 AddChild(mField);465 482 SelectColorSpace(g_settings.out_space); 466 483 BMessage * msg = new BMessage(CHANGE_ASCII); 467 mAscii = new BCheckBox( BRect(10,135,170,155), "Write ASCII","Write ASCII", msg);468 if (g_settings.write_ascii) {484 mAscii = new BCheckBox("Write ASCII", msg); 485 if (g_settings.write_ascii) 469 486 mAscii->SetValue(1); 470 }471 487 mAscii->SetViewColor(ViewColor()); 472 AddChild(mAscii); 488 489 // Build the layout 490 SetLayout(new BGroupLayout(B_HORIZONTAL)); 491 492 AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) 493 .Add(mTitle) 494 .Add(mDetail) 495 .AddGlue() 496 .Add(mBasedOn) 497 .Add(mCopyright) 498 .AddGlue() 499 .Add(BGridLayoutBuilder(10, 10) 500 .Add(mField->CreateLabelLayoutItem(), 0, 0) 501 .Add(mField->CreateMenuBarLayoutItem(), 1, 0) 502 .Add(mAscii, 0, 1) 503 ) 504 .AddGlue() 505 .SetInsets(5, 5, 5, 5) 506 ); 507 508 BFont font; 509 GetFont(&font); 510 SetExplicitPreferredSize(BSize((font.Size() * 350)/12, (font.Size() * 200)/12)); 473 511 } 474 512 ~PPMView() 475 513 { … … 481 519 CHANGE_ASCII 482 520 }; 483 521 484 virtual void Draw(485 BRect area)486 {487 SetFont(be_bold_font);488 font_height fh;489 GetFontHeight(&fh);490 float xbold, ybold;491 xbold = fh.descent + 1;492 ybold = fh.ascent + fh.descent * 2 + fh.leading;493 494 char title[] = "PPM Image Translator";495 DrawString(title, BPoint(xbold, ybold));496 497 SetFont(be_plain_font);498 font_height plainh;499 GetFontHeight(&plainh);500 float yplain;501 yplain = plainh.ascent + plainh.descent * 2 + plainh.leading;502 503 char detail[100];504 int ver = static_cast<int>(translatorVersion);505 sprintf(detail, "Version %d.%d.%d %s", ver >> 8, ((ver >> 4) & 0xf),506 (ver & 0xf), __DATE__);507 DrawString(detail, BPoint(xbold, yplain + ybold));508 509 DrawString("Based on PPMTranslator sample code",510 BPoint(xbold, yplain * 3 + ybold));511 DrawString("Sample code copyright 1999, Be Incorporated",512 BPoint(xbold, yplain * 4 + ybold));513 }514 522 virtual void MessageReceived( 515 523 BMessage * message) 516 524 { … … 559 567 } 560 568 561 569 private: 570 BStringView * mTitle; 571 BStringView * mDetail; 572 BStringView * mBasedOn; 573 BStringView * mCopyright; 562 574 BPopUpMenu * mMenu; 563 575 BMenuField * mField; 564 576 BCheckBox * mAscii; … … 604 616 BView * * outView, 605 617 BRect * outExtent) 606 618 { 607 PPMView * v = new PPMView( BRect(0,0,225,175), "PPMTranslator Settings", B_FOLLOW_ALL, B_WILL_DRAW);619 PPMView * v = new PPMView("PPMTranslator Settings", B_WILL_DRAW); 608 620 *outView = v; 621 v->ResizeTo(v->ExplicitPreferredSize());; 609 622 *outExtent = v->Bounds(); 610 623 if (ioExtension) { 611 624 v->SetSettings(ioExtension); -
src/add-ons/translators/exr/ConfigView.cpp
10 10 11 11 #include <StringView.h> 12 12 #include <CheckBox.h> 13 #include <GroupLayout.h> 14 #include <GroupLayoutBuilder.h> 15 #include <SpaceLayoutItem.h> 13 16 14 17 #include <stdio.h> 15 18 #include <string.h> 16 19 17 20 18 ConfigView::ConfigView( const BRect &frame, uint32 resize,uint32 flags)19 : BView( frame, "EXRTranslator Settings", resize, flags)21 ConfigView::ConfigView(uint32 flags) 22 : BView("EXRTranslator Settings", flags) 20 23 { 21 24 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 22 25 23 font_height fontHeight; 24 be_bold_font->GetHeight(&fontHeight); 25 float height = fontHeight.descent + fontHeight.ascent + fontHeight.leading; 26 BStringView *fTitle = new BStringView("title", "EXR Images"); 27 fTitle->SetFont(be_bold_font); 26 28 27 BRect rect(10, 10, 200, 10 + height);28 BStringView *stringView = new BStringView(rect, "title", "EXR Images");29 stringView->SetFont(be_bold_font);30 stringView->ResizeToPreferred();31 AddChild(stringView);32 33 rect.OffsetBy(0, height + 10);34 29 char version[256]; 35 30 sprintf(version, "Version %d.%d.%d, %s", 36 31 int(B_TRANSLATION_MAJOR_VERSION(EXR_TRANSLATOR_VERSION)), 37 32 int(B_TRANSLATION_MINOR_VERSION(EXR_TRANSLATOR_VERSION)), 38 33 int(B_TRANSLATION_REVISION_VERSION(EXR_TRANSLATOR_VERSION)), 39 34 __DATE__); 40 stringView = new BStringView(rect, "version", version); 41 stringView->ResizeToPreferred(); 42 AddChild(stringView); 35 BStringView *fVersion = new BStringView("version", version); 43 36 44 GetFontHeight(&fontHeight);45 height = fontHeight.descent + fontHeight.ascent + fontHeight.leading;37 BStringView *fCopyright = new BStringView("copyright", 38 B_UTF8_COPYRIGHT "2008 Haiku Inc."); 46 39 47 rect.OffsetBy(0, height + 5); 48 stringView = new BStringView(rect, "copyright", B_UTF8_COPYRIGHT "2008 Haiku Inc."); 49 stringView->ResizeToPreferred(); 50 AddChild(stringView); 40 BStringView *fCopyright2 = new BStringView("copyright2", 41 "Based on OpenEXR (http://www.openexr.com)"); 51 42 52 rect.OffsetBy(0, height + 10); 53 stringView = new BStringView(rect, "copyright2", "Based on OpenEXR (http://www.openexr.com)"); 54 stringView->ResizeToPreferred(); 55 AddChild(stringView); 43 BStringView *fCopyright3 = new BStringView("copyright3", 44 B_UTF8_COPYRIGHT "2006, Industrial Light & Magic,"); 56 45 57 rect.OffsetBy(0, height + 5); 58 stringView = new BStringView(rect, "copyright3", B_UTF8_COPYRIGHT "2006, Industrial Light & Magic, a division of Lucasfilm " 59 "Entertainment Company Ltd"); 60 stringView->ResizeToPreferred(); 61 AddChild(stringView); 46 BStringView *fCopyright4 = new BStringView("copyright4", 47 "a division of Lucasfilm Entertainment Company Ltd"); 48 49 // Build the layout 50 SetLayout(new BGroupLayout(B_HORIZONTAL)); 51 52 AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) 53 .Add(fTitle) 54 .Add(fVersion) 55 .AddGlue() 56 .Add(fCopyright) 57 .Add(fCopyright2) 58 .AddGlue() 59 .Add(fCopyright3) 60 .Add(fCopyright4) 61 .AddGlue() 62 .SetInsets(5, 5, 5, 5) 63 ); 64 65 BFont font; 66 GetFont(&font); 67 SetExplicitPreferredSize(BSize((font.Size() * 400)/12, (font.Size() * 200)/12)); 62 68 } 63 69 64 70 -
src/add-ons/translators/exr/main.cpp
16 16 BApplication app("application/x-vnd.haiku-exr-translator"); 17 17 18 18 status_t result; 19 result = LaunchTranslatorWindow(new EXRTranslator, "EXR Settings" , BRect(0, 0, 225, 175));19 result = LaunchTranslatorWindow(new EXRTranslator, "EXR Settings"); 20 20 if (result != B_OK) 21 21 return 1; 22 22 -
src/add-ons/translators/exr/ConfigView.h
11 11 12 12 class ConfigView : public BView { 13 13 public: 14 ConfigView(const BRect &frame, uint32 resize = B_FOLLOW_ALL, 15 uint32 flags = B_WILL_DRAW); 14 ConfigView(uint32 flags = B_WILL_DRAW); 16 15 virtual ~ConfigView(); 17 16 }; 18 17 -
src/add-ons/translators/exr/EXRTranslator.cpp
229 229 BView * 230 230 EXRTranslator::NewConfigView(TranslatorSettings *settings) 231 231 { 232 return new ConfigView( BRect(0, 0, 225, 175));232 return new ConfigView(); 233 233 } 234 234 235 235 -
src/add-ons/translators/gif/GIFView.cpp
18 18 #include <stdio.h> 19 19 #include <stdlib.h> 20 20 21 #include <GridLayoutBuilder.h> 22 #include <GroupLayout.h> 23 #include <GroupLayoutBuilder.h> 21 24 #include <InterfaceKit.h> 22 25 #include <String.h> 23 26 … … 30 33 extern char translatorName[]; 31 34 32 35 // constructor 33 GIFView::GIFView( BRect rect,const char *name)34 : BView( rect, name, B_FOLLOW_ALL, B_WILL_DRAW)36 GIFView::GIFView(const char *name) 37 : BView(name, B_WILL_DRAW) 35 38 { 36 39 SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 37 38 font_height fh;39 be_bold_font->GetHeight(&fh);40 BRect r(10, 15, 10 + be_bold_font->StringWidth(translatorName),41 15 + fh.ascent + fh.descent);42 40 43 BStringView *title = new BStringView( r,"Title", translatorName);41 BStringView *title = new BStringView("Title", translatorName); 44 42 title->SetFont(be_bold_font); 45 AddChild(title);46 43 47 44 char version_string[100]; 48 45 sprintf(version_string, "v%d.%d.%d %s", (int)(translatorVersion >> 8), (int)((translatorVersion >> 4) & 0xf), 49 46 (int)(translatorVersion & 0xf), __DATE__); 50 be_plain_font->GetHeight(&fh); 51 r.bottom = r.top + fh.ascent + fh.descent; 52 r.left = r.right + 2.0 * r.Height(); 53 r.right = r.left + be_plain_font->StringWidth(version_string); 47 BStringView *version = new BStringView("Version", version_string); 54 48 55 BStringView *version = new BStringView(r, "Version", version_string);56 version->SetFont(be_plain_font);57 AddChild(version);58 59 49 const char *copyrightString = "©2003 Daniel Switkin, software@switkin.com"; 60 r.top = r.bottom + 5; 61 r.left = 10; 62 r.bottom = r.top + fh.ascent + fh.descent; 63 r.right = rect.right - 10; 50 BStringView *copyright = new BStringView("Copyright", copyrightString); 64 51 65 BStringView *copyright = new BStringView(r, "Copyright", copyrightString);66 copyright->ResizeToPreferred();67 AddChild(copyright);68 69 52 // menu fields (Palette & Colors) 70 53 fWebSafeMI = new BMenuItem("Websafe", new BMessage(GV_WEB_SAFE), 0, 0); 71 54 fBeOSSystemMI = new BMenuItem("BeOS System", new BMessage(GV_BEOS_SYSTEM), 0, 0); … … 89 72 count *= 2; 90 73 } 91 74 fColorCount256MI = fColorCountMI[7]; 92 93 r.top = r.bottom + 14;94 r.bottom = r.top + 24;95 fPaletteMF = new BMenuField(r, "PaletteMenuField", "Palette",96 fPaletteM, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE);97 AddChild(fPaletteMF);98 75 99 r.top = r.bottom + 5; 100 r.bottom = r.top + 24; 101 fColorCountMF = new BMenuField(r, "ColorCountMenuField", "Colors", 102 fColorCountM, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE); 103 AddChild(fColorCountMF); 76 fPaletteMF = new BMenuField("Palette", fPaletteM, NULL); 104 77 105 // align menu fields 106 float maxLabelWidth = ceilf(max_c(be_plain_font->StringWidth("Colors"), 107 be_plain_font->StringWidth("Palette"))); 108 fPaletteMF->SetDivider(maxLabelWidth + 7); 109 fColorCountMF->SetDivider(maxLabelWidth + 7); 78 fColorCountMF = new BMenuField("Colors", fColorCountM, NULL); 110 79 111 // check boxen 112 r.top = fColorCountMF->Frame().bottom + 5; 113 r.bottom = r.top + 10; 114 fUseDitheringCB = new BCheckBox(r, "UseDithering", "Use dithering", 80 // check boxes 81 fUseDitheringCB = new BCheckBox("Use dithering", 115 82 new BMessage(GV_USE_DITHERING)); 116 AddChild(fUseDitheringCB);117 83 118 r.top = fUseDitheringCB->Frame().bottom + 2; 119 r.bottom = r.top + 10; 120 fInterlacedCB = new BCheckBox(r, "Interlaced", "Write interlaced images", 84 fInterlacedCB = new BCheckBox("Write interlaced images", 121 85 new BMessage(GV_INTERLACED)); 122 AddChild(fInterlacedCB); 123 124 r.top = fInterlacedCB->Frame().bottom + 2; 125 r.bottom = r.top + 10; 126 fUseTransparentCB = new BCheckBox(r, "UseTransparent", "Write transparent images", 86 87 fUseTransparentCB = new BCheckBox("Write transparent images", 127 88 new BMessage(GV_USE_TRANSPARENT)); 128 AddChild(fUseTransparentCB);129 89 130 90 // radio buttons 131 r.top = fUseTransparentCB->Frame().bottom + 2; 132 r.bottom = r.top + 10; 133 r.right = r.left + be_plain_font->StringWidth("Automatic (from alpha channel)") + 20; 134 fUseTransparentAutoRB = new BRadioButton(r, "UseTransparentAuto", "Automatic (from alpha channel)", 91 fUseTransparentAutoRB = new BRadioButton("Automatic (from alpha channel)", 135 92 new BMessage(GV_USE_TRANSPARENT_AUTO)); 136 AddChild(fUseTransparentAutoRB); 137 138 r.top = fUseTransparentAutoRB->Frame().bottom + 0; 139 r.bottom = r.top + 10; 140 r.left = 10; 141 r.right = r.left + be_plain_font->StringWidth("Use RGB color") + 20; 142 fUseTransparentColorRB = new BRadioButton(r, "UseTransparentColor", "Use RGB color", 93 94 fUseTransparentColorRB = new BRadioButton("Use RGB color", 143 95 new BMessage(GV_USE_TRANSPARENT_COLOR)); 144 AddChild(fUseTransparentColorRB);145 146 r.left = r.right + 1;147 r.right = r.left + 30;148 fTransparentRedTC = new BTextControl(r, "TransparentRed", "", "0",149 new BMessage(GV_TRANSPARENT_RED));150 AddChild(fTransparentRedTC);151 fTransparentRedTC->SetDivider(0);152 153 r.left = r.right + 5;154 r.right = r.left + 30;155 fTransparentGreenTC = new BTextControl(r, "TransparentGreen", "", "0",156 new BMessage(GV_TRANSPARENT_GREEN));157 AddChild(fTransparentGreenTC);158 fTransparentGreenTC->SetDivider(0);159 160 r.left = r.right + 5;161 r.right = r.left + 30;162 fTransparentBlueTC = new BTextControl(r, "TransparentBlue", "", "0",163 new BMessage(GV_TRANSPARENT_BLUE));164 AddChild(fTransparentBlueTC);165 fTransparentBlueTC->SetDivider(0);166 96 97 fTransparentRedTC = new BTextControl("", "0", new BMessage(GV_TRANSPARENT_RED)); 98 99 fTransparentGreenTC = new BTextControl("", "0", new BMessage(GV_TRANSPARENT_GREEN)); 100 101 fTransparentBlueTC = new BTextControl("", "0", new BMessage(GV_TRANSPARENT_BLUE)); 102 167 103 BTextView *tr = fTransparentRedTC->TextView(); 168 104 BTextView *tg = fTransparentGreenTC->TextView(); 169 105 BTextView *tb = fTransparentBlueTC->TextView(); … … 176 112 } 177 113 } 178 114 179 RestorePrefs();115 SetLayout(new BGroupLayout(B_HORIZONTAL)); 180 116 181 if (copyright->Frame().right + 10 > Bounds().Width()) 182 ResizeTo(copyright->Frame().right + 10, Bounds().Height()); 117 AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) 118 .Add(BGridLayoutBuilder(10, 10) 119 .Add(title, 0, 0) 120 .Add(version, 1, 0) 121 ) 122 .Add(copyright) 123 .AddGlue() 124 125 .Add(BGridLayoutBuilder(10, 10) 126 .Add(fPaletteMF->CreateLabelLayoutItem(), 0, 0) 127 .Add(fPaletteMF->CreateMenuBarLayoutItem(), 1, 0) 128 129 .Add(fColorCountMF->CreateLabelLayoutItem(), 0, 1) 130 .Add(fColorCountMF->CreateMenuBarLayoutItem(), 1, 1) 131 ) 132 .AddGlue() 133 134 .Add(fUseDitheringCB) 135 .Add(fInterlacedCB) 136 .Add(fUseTransparentCB) 137 138 .Add(fUseTransparentAutoRB) 139 .Add(BGridLayoutBuilder(10, 10) 140 .Add(fUseTransparentColorRB, 0, 0) 141 .Add(fTransparentRedTC, 1, 0) 142 .Add(fTransparentGreenTC, 2, 0) 143 .Add(fTransparentBlueTC, 3, 0) 144 ) 145 .AddGlue() 146 .SetInsets(5, 5, 5, 5) 147 ); 148 149 BFont font; 150 GetFont(&font); 151 SetExplicitPreferredSize(BSize((font.Size() * 400)/12, (font.Size() * 300)/12)); 152 153 RestorePrefs(); 183 154 } 184 155 185 156 -
src/add-ons/translators/gif/GIFView.h
44 44 45 45 class GIFView : public BView { 46 46 public: 47 GIFView( BRect rect,const char* name);47 GIFView(const char* name); 48 48 virtual ~GIFView(); 49 49 50 50 virtual void MessageReceived(BMessage* message); -
src/add-ons/translators/gif/GIFTranslator.cpp
61 61 status_t 62 62 MakeConfig(BMessage *ioExtension, BView **outView, BRect *outExtent) 63 63 { 64 outExtent->Set(0, 0, 239, 239); 65 GIFView *gifview = new GIFView(*outExtent, "TranslatorView"); 64 GIFView *gifview = new GIFView("TranslatorView"); 66 65 *outView = gifview; 66 gifview->ResizeTo(gifview->ExplicitPreferredSize()); 67 *outExtent = gifview->Bounds(); 67 68 return B_OK; 68 69 } 69 70 -
src/add-ons/translators/gif/GIFWindow.cpp
16 16 #include "GIFWindow.h" 17 17 #include "GIFView.h" 18 18 #include <Application.h> 19 #include <GroupLayout.h> 19 20 20 21 GIFWindow::GIFWindow(BRect rect, const char *name) : 21 BWindow(rect, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 22 B_CURRENT_WORKSPACE) { 23 24 BRect r(Bounds()); 25 gifview = new GIFView(r, "GIFView"); 22 BWindow(rect, name, B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE 23 | B_AUTO_UPDATE_SIZE_LIMITS, B_CURRENT_WORKSPACE) { 24 SetLayout(new BGroupLayout(B_HORIZONTAL)); 25 gifview = new GIFView("GIFView"); 26 26 AddChild(gifview); 27 27 } 28 28 -
src/add-ons/translators/shared/TranslatorWindow.cpp
31 31 32 32 #include <Screen.h> 33 33 #include <Alert.h> 34 #include <GroupLayout.h> 34 35 #include "TranslatorWindow.h" 35 36 36 37 // --------------------------------------------------------------- … … 48 49 // --------------------------------------------------------------- 49 50 TranslatorWindow::TranslatorWindow(BRect area, const char *title) 50 51 : BWindow(area, title, B_TITLED_WINDOW, 51 B_NOT_RESIZABLE | B_NOT_ZOOMABLE )52 B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) 52 53 { 54 SetLayout(new BGroupLayout(B_HORIZONTAL)); 55 // Set the layout on layout window 56 // Do nothing for a non-layout window 53 57 } 54 58 55 59 // --------------------------------------------------------------- … … 85 89 translator = NULL; 86 90 87 91 TranslatorWindow *wnd = new TranslatorWindow(rect, title); 88 view->ResizeTo(rect.Width(), rect.Height());89 92 wnd->AddChild(view); 90 93 BPoint wndpt = B_ORIGIN; 91 94 { -
src/add-ons/translators/shared/BaseTranslator.cpp
641 641 642 642 BView *view = NewConfigView(AcquireSettings()); 643 643 // implemented in derived class 644 644 645 if (view) { 645 646 *outView = view; 647 if ((view->Flags() & B_SUPPORTS_LAYOUT) != 0) 648 view->ResizeTo(view->ExplicitPreferredSize()); 649 646 650 *outExtent = view->Bounds(); 647 651 648 652 return B_OK; -
src/add-ons/translators/shared/TranslatorWindow.h
48 48 }; 49 49 50 50 status_t 51 LaunchTranslatorWindow(BTranslator *translator, const char *title, BRect rect); 51 LaunchTranslatorWindow(BTranslator *translator, const char *title, 52 BRect rect = BRect(0, 0, 1, 1)); 52 53 53 54 #endif // #ifndef TRANSLATORWINDOW_H 54 55 -
src/add-ons/translators/tga/TGAMain.cpp
49 49 { 50 50 BApplication app("application/x-vnd.obos-tga-translator"); 51 51 status_t result; 52 result = LaunchTranslatorWindow(new TGATranslator, 53 "TGA Settings", BRect(0, 0, 225, 175)); 52 result = LaunchTranslatorWindow(new TGATranslator, "TGA Settings"); 54 53 if (result == B_OK) { 55 54 app.Run(); 56 55 return 0; -
src/add-ons/translators/tga/TGATranslator.cpp
2188 2188 BView * 2189 2189 TGATranslator::NewConfigView(TranslatorSettings *settings) 2190 2190 { 2191 return new TGAView(BRect(0, 0, 225, 175), "TGATranslator Settings", 2192 B_FOLLOW_ALL, B_WILL_DRAW, settings); 2191 return new TGAView("TGATranslator Settings", B_WILL_DRAW, settings); 2193 2192 } 2194 2193 -
src/add-ons/translators/tga/TGAView.cpp
30 30 31 31 #include <stdio.h> 32 32 #include <string.h> 33 #include <GroupLayout.h> 34 #include <GroupLayoutBuilder.h> 35 #include <SpaceLayoutItem.h> 33 36 #include "TGAView.h" 34 37 #include "TGATranslator.h" 35 38 … … 46 49 // 47 50 // Returns: 48 51 // --------------------------------------------------------------- 49 TGAView::TGAView(const BRect &frame, const char *name, 50 uint32 resize, uint32 flags, TranslatorSettings *settings) 51 : BView(frame, name, resize, flags) 52 TGAView::TGAView(const char *name, uint32 flags, TranslatorSettings *settings) 53 : BView(name, flags) 52 54 { 53 55 fSettings = settings; 54 56 … … 57 59 58 60 BMessage *pmsg; 59 61 int32 val; 60 62 63 fTitle = new BStringView("title", "TGA Image Translator"); 64 fTitle->SetFont(be_bold_font); 65 66 char detail[100]; 67 sprintf(detail, "Version %d.%d.%d %s", 68 static_cast<int>(B_TRANSLATION_MAJOR_VERSION(TGA_TRANSLATOR_VERSION)), 69 static_cast<int>(B_TRANSLATION_MINOR_VERSION(TGA_TRANSLATOR_VERSION)), 70 static_cast<int>(B_TRANSLATION_REVISION_VERSION(TGA_TRANSLATOR_VERSION)), 71 __DATE__); 72 fDetail = new BStringView("detail", detail); 73 fWrittenBy = new BStringView("writtenby", 74 "Written by the Haiku Translation Kit Team"); 75 61 76 pmsg = new BMessage(CHANGE_IGNORE_ALPHA); 62 fpchkIgnoreAlpha = new BCheckBox(BRect(10, 45, 180, 62), 63 "Ignore TGA alpha channel", 64 "Ignore TGA alpha channel", pmsg); 77 fpchkIgnoreAlpha = new BCheckBox("Ignore TGA alpha channel", pmsg); 65 78 val = (fSettings->SetGetBool(TGA_SETTING_IGNORE_ALPHA)) ? 1 : 0; 66 79 fpchkIgnoreAlpha->SetValue(val); 67 80 fpchkIgnoreAlpha->SetViewColor(ViewColor()); 68 AddChild(fpchkIgnoreAlpha);69 81 70 82 pmsg = new BMessage(CHANGE_RLE); 71 fpchkRLE = new BCheckBox(BRect(10, 67, 180, 84), 72 "Save with RLE Compression", 73 "Save with RLE Compression", pmsg); 83 fpchkRLE = new BCheckBox("Save with RLE Compression", pmsg); 74 84 val = (fSettings->SetGetBool(TGA_SETTING_RLE)) ? 1 : 0; 75 85 fpchkRLE->SetValue(val); 76 86 fpchkRLE->SetViewColor(ViewColor()); 77 AddChild(fpchkRLE); 87 88 // Build the layout 89 SetLayout(new BGroupLayout(B_HORIZONTAL)); 90 91 AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) 92 .Add(fTitle) 93 .Add(fDetail) 94 .AddGlue() 95 .Add(fpchkIgnoreAlpha) 96 .Add(fpchkRLE) 97 .AddGlue() 98 .Add(fWrittenBy) 99 .AddGlue() 100 .SetInsets(5, 5, 5, 5) 101 ); 102 103 BFont font; 104 GetFont(&font); 105 SetExplicitPreferredSize(BSize((font.Size() * 333)/12, (font.Size() * 200)/12)); 78 106 } 79 107 80 108 // --------------------------------------------------------------- … … 157 185 break; 158 186 } 159 187 } 160 161 // ---------------------------------------------------------------162 // Draw163 //164 // Draws information about the TGATranslator to this view.165 //166 // Preconditions:167 //168 // Parameters: area, not used169 //170 // Postconditions:171 //172 // Returns:173 // ---------------------------------------------------------------174 void175 TGAView::Draw(BRect area)176 {177 SetFont(be_bold_font);178 font_height fh;179 GetFontHeight(&fh);180 float xbold, ybold;181 xbold = fh.descent + 1;182 ybold = fh.ascent + fh.descent * 2 + fh.leading;183 184 char title[] = "TGA Image Translator";185 DrawString(title, BPoint(xbold, ybold));186 187 SetFont(be_plain_font);188 font_height plainh;189 GetFontHeight(&plainh);190 float yplain;191 yplain = plainh.ascent + plainh.descent * 2 + plainh.leading;192 193 char detail[100];194 sprintf(detail, "Version %d.%d.%d %s",195 static_cast<int>(B_TRANSLATION_MAJOR_VERSION(TGA_TRANSLATOR_VERSION)),196 static_cast<int>(B_TRANSLATION_MINOR_VERSION(TGA_TRANSLATOR_VERSION)),197 static_cast<int>(B_TRANSLATION_REVISION_VERSION(TGA_TRANSLATOR_VERSION)),198 __DATE__);199 DrawString(detail, BPoint(xbold, yplain + ybold));200 /* char copyright[] = "© 2002 Haiku Project";201 DrawString(copyright, BPoint(xbold, yplain * 2 + ybold));202 */203 char writtenby[] = "Written by the Haiku Translation Kit Team";204 DrawString(writtenby, BPoint(xbold, yplain * 7 + ybold));205 } -
src/add-ons/translators/tga/TGAView.h
33 33 34 34 #include <View.h> 35 35 #include <CheckBox.h> 36 #include <StringView.h> 36 37 #include "TranslatorSettings.h" 37 38 38 39 class TGAView : public BView { 39 40 public: 40 TGAView(const BRect &frame, const char *name, uint32 resize, 41 uint32 flags, TranslatorSettings *settings); 41 TGAView(const char *name, uint32 flags, TranslatorSettings *settings); 42 42 // sets up the view 43 43 44 44 ~TGAView(); … … 46 46 47 47 virtual void AllAttached(); 48 48 virtual void MessageReceived(BMessage *message); 49 50 virtual void Draw(BRect area);51 // draws information about the TGATranslator52 49 53 50 enum { CHANGE_RLE, CHANGE_IGNORE_ALPHA }; 54 51 private: 52 BStringView *fTitle; 53 BStringView *fDetail; 54 BStringView *fWrittenBy; 55 55 BCheckBox *fpchkIgnoreAlpha; 56 56 BCheckBox *fpchkRLE; 57 57