1 /* 2 * Copyright 2009-2012 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * John Scipione <jscipione@gmail.com> 7 * Alex Wilson <yourpalal2@gmail.com> 8 * Artur Wyszynski <harakash@gmail.com> 9 */ 10 11 12 #include "ExtensionsView.h" 13 14 #include <Catalog.h> 15 #include <GL/gl.h> 16 #include <GL/glu.h> 17 #include <GroupLayout.h> 18 #include <GroupLayoutBuilder.h> 19 #include <Locale.h> 20 #include <Message.h> 21 #include <SpaceLayoutItem.h> 22 #include <String.h> 23 24 25 #undef B_TRANSLATION_CONTEXT 26 #define B_TRANSLATION_CONTEXT "Extensions" 27 28 29 ExtensionsView::ExtensionsView() 30 : 31 BGroupView(B_TRANSLATE("Extensions"), B_VERTICAL), 32 fExtensionsList(new BColumnListView("ExtensionsList", 0)) 33 { 34 // add the columns 35 36 float availableColWidth = this->StringWidth("M") * 28; 37 38 fAvailableColumn = new BStringColumn(B_TRANSLATE("Available extensions"), 39 availableColWidth, availableColWidth, availableColWidth, 40 B_TRUNCATE_MIDDLE); 41 fExtensionsList->AddColumn(fAvailableColumn, 0); 42 fExtensionsList->SetSortingEnabled(true); 43 fExtensionsList->SetSortColumn(fAvailableColumn, true, true); 44 45 // add the rows 46 47 _AddExtensionsList(fExtensionsList, (char*)glGetString(GL_EXTENSIONS)); 48 _AddExtensionsList(fExtensionsList, (char*)gluGetString(GLU_EXTENSIONS)); 49 50 // add the list 51 52 AddChild(fExtensionsList); 53 GroupLayout()->SetInsets(5.0, 5.0, 5.0, 5.0); 54 } 55 56 57 ExtensionsView::~ExtensionsView() 58 { 59 BRow *row; 60 while ((row = fExtensionsList->RowAt((int32)0, NULL)) != NULL) { 61 fExtensionsList->RemoveRow(row); 62 delete row; 63 } 64 } 65 66 67 // #pragma mark - 68 69 70 void 71 ExtensionsView::_AddExtensionsList(BColumnListView* fExtensionsList, char* stringList) 72 { 73 if (stringList == NULL) { 74 // empty extensions string 75 return; 76 } 77 78 while (*stringList != '\0') { 79 char extName[255]; 80 int n = strcspn(stringList, " "); 81 strncpy(extName, stringList, n); 82 extName[n] = 0; 83 BRow* row = new BRow(); 84 row->SetField(new BStringField(extName), 0); 85 fExtensionsList->AddRow(row); 86 if (!stringList[n]) 87 break; 88 stringList += (n + 1); 89 // next ! 90 } 91 } 92