1#ifndef SOANY_MATERIALLIST_H 2#define SOANY_MATERIALLIST_H 3 4// @configure_input@ 5 6/**************************************************************************\ 7 * Copyright (c) Kongsberg Oil & Gas Technologies AS 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions are 12 * met: 13 * 14 * Redistributions of source code must retain the above copyright notice, 15 * this list of conditions and the following disclaimer. 16 * 17 * Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in the 19 * documentation and/or other materials provided with the distribution. 20 * 21 * Neither the name of the copyright holder nor the names of its 22 * contributors may be used to endorse or promote products derived from 23 * this software without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36\**************************************************************************/ 37 38#include <Inventor/@Gui@/So@Gui@MaterialList.h> 39 40class SbPList; 41class SoMaterial; 42 43// ************************************************************************* 44 45#define SO@GUI@_BUILTIN_MATERIALS 0x0001 46 47struct So@Gui@Material { 48 const char * name; 49 const char * data; 50}; 51 52struct So@Gui@MaterialGroup { 53 const char * name; 54 short numMaterials; 55 So@Gui@Material ** materials; 56 @WIDGET@ menuitem; 57}; 58 59struct So@Gui@MaterialDirectory { 60 short flags; 61 short numGroups; 62 So@Gui@MaterialGroup ** groups; 63 short current; 64}; 65 66// ************************************************************************* 67 68class SO@GUI@_DLL_API SoAnyMaterialList { 69public: 70 SoAnyMaterialList(const char * const dir); 71 ~SoAnyMaterialList(void); 72 73 void addCallback( 74 So@Gui@MaterialListCB * const callback, void * const closure); 75 void removeCallback( 76 So@Gui@MaterialListCB * const callback, void * const closure); 77 void invokeCallbacks(SoMaterial * material); 78 79 const char * getMaterialDirectoryPath(void) const; 80 So@Gui@MaterialDirectory * getMaterialDirectory(void); 81 82private: 83 void setupBuiltinMaterials(So@Gui@MaterialDirectory * const index) const; 84 void freeMaterialDirectory(void); 85 86 static char ** getNonemptySubdirs(const char * const path); 87 static char ** getRegularFiles(const char * const path); 88 89 static int qsort_comparator(const void * itemA, const void * itemB); 90 91private: 92 SbPList * callbacks; 93 char * dirpath; 94 So@Gui@MaterialDirectory * directory; 95 96}; // class SoAnyMaterialList 97 98// ************************************************************************* 99 100#endif // ! SOANY_MATERIALLIST_H 101