KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWIcon.h,v $ 00004 00005 Copyright (c) Kitware, Inc. 00006 All rights reserved. 00007 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 00013 =========================================================================*/ 00014 // .NAME vtkKWIcon - simple wrapper for icons 00015 // .SECTION Description 00016 // A simple icon wrapper. It can either be used with file KWIcons.h to 00017 // provide a unified interface for internal icons or a wrapper for 00018 // custom icons. The icons are defined with width, height, pixel_size, 00019 // and array of unsigned char values. 00020 00021 #ifndef __vtkKWIcon_h 00022 #define __vtkKWIcon_h 00023 00024 #include "vtkObject.h" 00025 #include "vtkKWWidgets.h" // Needed for export symbols directives 00026 00027 class vtkColorTransferFunction; 00028 class vtkImageData; 00029 00030 class KWWidgets_EXPORT vtkKWIcon : public vtkObject 00031 { 00032 public: 00033 static vtkKWIcon* New(); 00034 vtkTypeRevisionMacro(vtkKWIcon,vtkObject); 00035 void PrintSelf(ostream& os, vtkIndent indent); 00036 void DeepCopy(vtkKWIcon *p); 00037 00038 //BTX 00039 // Description: 00040 // Predefined icons. 00041 enum { 00042 IconAngleTool = 14, 00043 IconBiDimensionalTool = 34, 00044 IconBoundingBox = 13, 00045 IconBrowserBack = 71, 00046 IconBrowserForward = 72, 00047 IconBrowserUp = 70, 00048 IconBugMini = 200, 00049 IconCalculator = 79, 00050 IconCamera = 19, 00051 IconCameraMini = 175, 00052 IconCdRom = 75, 00053 IconColorAlphaSquares = 216, 00054 IconColorBarAnnotation = 12, 00055 IconColorSquares = 18, 00056 IconColumns = 220, 00057 IconCompress = 211, 00058 IconConnection = 1, 00059 IconContourSegment = 33, 00060 IconContourTool = 16, 00061 IconContrast = 212, 00062 IconCornerAnnotation = 11, 00063 IconCropTool = 22, 00064 IconDistanceTool = 15, 00065 IconDocument = 9, 00066 IconDocumentRGBColor = 209, 00067 IconDocumentVolumeProperty = 177, 00068 IconDocumentWindowLevel = 176, 00069 IconEditContrast = 225, 00070 IconEditVolumeProperties = 226, 00071 IconEmpty16x16 = 6, 00072 IconEmpty1x1 = 10, 00073 IconError = 2, 00074 IconErrorMini = 3, 00075 IconErrorRedMini = 4, 00076 IconExpand = 5, 00077 IconExpandLeftMini = 180, 00078 IconExpandMini = 23, 00079 IconExpandRightMini = 178, 00080 IconExpandUpMini = 179, 00081 IconEye = 17, 00082 IconFavorites = 67, 00083 IconFileDelete = 73, 00084 IconFileOpen = 8, 00085 IconFloppy = 7, 00086 IconFloppyDrive = 77, 00087 IconFolder = 20, 00088 IconFolder32 = 65, 00089 IconFolderNew = 74, 00090 IconFolderOpen = 21, 00091 IconFolderXP = 66, 00092 IconGrayscaleSquares = 218, 00093 IconGridLinear = 40, 00094 IconGridLog = 41, 00095 IconHSVDiagram = 207, 00096 IconHardDrive = 76, 00097 IconHeaderAnnotation = 50, 00098 IconHelpBubble = 60, 00099 IconInfoMini = 61, 00100 IconInterpolationBilinear = 215, 00101 IconInterpolationNearest = 217, 00102 IconLock = 62, 00103 IconMagGlass = 63, 00104 IconMinus = 64, 00105 IconMove = 80, 00106 IconMoveH = 81, 00107 IconMoveV = 82, 00108 IconNetDrive = 78, 00109 IconNoIcon = 0, 00110 IconObliqueProbe = 133, 00111 IconOrientationCubeAnnotation = 83, 00112 IconPanHand = 84, 00113 IconParallelProjection = 213, 00114 IconPerspectiveProjection = 214, 00115 IconPlus = 100, 00116 IconPointFinger = 90, 00117 IconPresetAdd = 94, 00118 IconPresetApply = 95, 00119 IconPresetDelete = 96, 00120 IconPresetEmail = 97, 00121 IconPresetFilter = 237, 00122 IconPresetLoad = 210, 00123 IconPresetLocate = 98, 00124 IconPresetNext = 173, 00125 IconPresetPrevious = 174, 00126 IconPresetRewind = 238, 00127 IconPresetUpdate = 99, 00128 IconQuestion = 101, 00129 IconReload = 102, 00130 IconResetCamera = 222, 00131 IconResetContrast = 223, 00132 IconRotate = 105, 00133 IconRows = 219, 00134 IconScaleBarAnnotation = 106, 00135 IconSeedTool = 107, 00136 IconShrink = 103, 00137 IconSideAnnotation = 110, 00138 IconSmallCounterBlue1 = 227, 00139 IconSmallCounterBlue2 = 228, 00140 IconSmallCounterBlue3 = 229, 00141 IconSmallCounterBlue4 = 230, 00142 IconSmallCounterBlue5 = 231, 00143 IconSmallCounterBlue6 = 232, 00144 IconSmallCounterBlue7 = 233, 00145 IconSmallCounterBlue8 = 234, 00146 IconSmallCounterBlue9 = 235, 00147 IconSmallCounterBlue9Plus = 236, 00148 IconSpinDown = 111, 00149 IconSpinLeft = 112, 00150 IconSpinRight = 113, 00151 IconSpinUp = 114, 00152 IconStandardView = 224, 00153 IconStopwatch = 104, 00154 IconTestTube = 190, 00155 IconTime = 208, 00156 IconTransportBeginning = 120, 00157 IconTransportEnd = 121, 00158 IconTransportFastForward = 122, 00159 IconTransportFastForwardToKey = 123, 00160 IconTransportLoop = 124, 00161 IconTransportPause = 125, 00162 IconTransportPlay = 126, 00163 IconTransportPlayBackward = 201, 00164 IconTransportPlayToKey = 127, 00165 IconTransportRewind = 128, 00166 IconTransportRewindToKey = 129, 00167 IconTransportStop = 130, 00168 IconTrashcan = 131, 00169 IconTreeClose = 150, 00170 IconTreeOpen = 151, 00171 IconWarning = 170, 00172 IconWarningMini = 171, 00173 IconWindowLevel = 172, 00174 00175 IconNuvola16x16ActionsColorPicker = 1022, 00176 IconNuvola16x16ActionsConfigure = 1000, 00177 IconNuvola16x16ActionsDecrypted = 1001, 00178 IconNuvola16x16ActionsEditCopy = 1023, 00179 IconNuvola16x16ActionsEditCut = 1024, 00180 IconNuvola16x16ActionsEditPaste = 1025, 00181 IconNuvola16x16ActionsEncrypted = 1019, 00182 IconNuvola16x16ActionsExit = 1002, 00183 IconNuvola16x16ActionsFileClose = 1003, 00184 IconNuvola16x16ActionsFileOpen = 1004, 00185 IconNuvola16x16ActionsFilePrint = 1005, 00186 IconNuvola16x16ActionsFileSave = 1006, 00187 IconNuvola16x16ActionsHelp = 1007, 00188 IconNuvola16x16ActionsHistory = 1026, 00189 IconNuvola16x16ActionsKAlarm = 1027, 00190 IconNuvola16x16ActionsLedBlue = 1031, 00191 IconNuvola16x16ActionsLedGreen = 1032, 00192 IconNuvola16x16ActionsLedLightBlue = 1033, 00193 IconNuvola16x16ActionsLedLightGreen = 1034, 00194 IconNuvola16x16ActionsLedOrange = 1035, 00195 IconNuvola16x16ActionsLedPurple = 1036, 00196 IconNuvola16x16ActionsLedRed = 1037, 00197 IconNuvola16x16ActionsLedYellow = 1038, 00198 IconNuvola16x16ActionsMailGeneric = 1008, 00199 IconNuvola16x16ActionsMessage = 1009, 00200 IconNuvola16x16ActionsMessageBoxCritical = 1010, 00201 IconNuvola16x16ActionsMessageBoxInfo = 1011, 00202 IconNuvola16x16ActionsMessageBoxWarning = 1012, 00203 IconNuvola16x16ActionsNo = 1013, 00204 IconNuvola16x16ActionsRotate = 1014, 00205 IconNuvola16x16ActionsStop = 1015, 00206 IconNuvola16x16ActionsThumbnail = 1016, 00207 IconNuvola16x16ActionsViewBottom = 1018, 00208 IconNuvola16x16ActionsViewFullScreen = 1020, 00209 IconNuvola16x16ActionsViewLeftRight = 1028, 00210 IconNuvola16x16ActionsViewMag = 1017, 00211 IconNuvola16x16ActionsViewRight = 1021, 00212 IconNuvola16x16ActionsViewTopBottom = 1029, 00213 IconNuvola16x16ActionsWindowNew = 1030, 00214 IconNuvola16x16AppsArk = 1300, 00215 IconNuvola16x16AppsBug = 1301, 00216 IconNuvola16x16AppsEmail = 1302, 00217 IconNuvola16x16AppsError = 1303, 00218 IconNuvola16x16AppsKeyboard = 1304, 00219 IconNuvola16x16AppsKTimer = 1305, 00220 IconNuvola16x16DevicesCamera = 1600, 00221 IconNuvola16x16FilesystemsFolderInbox = 1903, 00222 IconNuvola16x16FilesystemsFolderOutbox = 1904, 00223 IconNuvola16x16FilesystemsTrashcanEmpty = 1901, 00224 IconNuvola16x16FilesystemsTrashcanFull = 1902, 00225 00226 IconNuvola22x22ActionsHelp = 3000, 00227 IconNuvola22x22ActionsMessageBoxInfo = 3001, 00228 IconNuvola22x22ActionsMisc = 3002, 00229 IconNuvola22x22ActionsWizard = 3003, 00230 IconNuvola22x22AppsDesigner = 3300, 00231 IconNuvola22x22DevicesCamera = 3600, 00232 IconNuvola22x22FilesystemsFolderBlue = 3900, 00233 00234 IconNuvola48x48ActionsMessageBoxCritical = 5001, 00235 IconNuvola48x48ActionsMessageBoxInfo = 5002, 00236 IconNuvola48x48ActionsMessageBoxWarning = 5003, 00237 IconNuvola48x48ActionsHelp = 5004, 00238 IconNuvola48x48ActionsHistory = 5000, 00239 IconNuvola48x48AppsDownloadManager = 5300, 00240 IconNuvola48x48DevicesMouse = 5600, 00241 IconNuvola48x48FilesystemsFolderBlue = 5900, 00242 00243 IconCrystalProject16x16Actions14LayerDeletelayer = 10000, 00244 IconCrystalProject16x16Actions14LayerNovisible = 10001, 00245 IconCrystalProject16x16Actions14LayerVisible = 10002, 00246 IconCrystalProject16x16ActionsJabberOnline = 10003, 00247 IconCrystalProject16x16ActionsRotate = 10004, 00248 IconCrystalProject16x16AppsCookie = 10300, 00249 IconCrystalProject16x16AppsTutorials = 10301, 00250 00251 IconSilkAccept = 20044, 00252 IconSilkAdd = 20045, 00253 IconSilkApplicationXpTerminal = 20000, 00254 IconSilkArrowRefresh = 20001, 00255 IconSilkAttach = 20002, 00256 IconSilkBinClosed = 20003, 00257 IconSilkBug = 20004, 00258 IconSilkBulletToggleMinus = 20056, 00259 IconSilkBulletTogglePlus = 20057, // 00260 IconSilkCamera = 20005, 00261 IconSilkCancel = 20046, 00262 IconSilkChartCurve = 20006, 00263 IconSilkChartLine = 20007, 00264 IconSilkChartOrganisation = 20008, 00265 IconSilkChartPie = 20009, 00266 IconSilkClock = 20010, 00267 IconSilkCog = 20011, 00268 IconSilkColorSwatch = 20012, 00269 IconSilkColorWheel = 20013, 00270 IconSilkCompress = 20014, 00271 IconSilkCross = 20047, 00272 IconSilkCut = 20048, 00273 IconSilkDate = 20015, 00274 IconSilkDelete = 20049, 00275 IconSilkDisk = 20016, 00276 IconSilkDoorIn = 20017, 00277 IconSilkDoorOut = 20018, 00278 IconSilkEmail = 20019, 00279 IconSilkExclamation = 20020, 00280 IconSilkEye = 20021, 00281 IconSilkFilm = 20022, 00282 IconSilkHelp = 20023, 00283 IconSilkHourglass = 20024, 00284 IconSilkInformation = 20025, 00285 IconSilkKey = 20026, 00286 IconSilkLink = 20027, 00287 IconSilkLock = 20028, 00288 IconSilkMagnifier = 20029, 00289 IconSilkPaintCan = 20031, 00290 IconSilkPaintbrush = 20030, 00291 IconSilkPastePlain = 20050, 00292 IconSilkPill = 20032, 00293 IconSilkPlugin = 20033, 00294 IconSilkStar = 20034, 00295 IconSilkStop = 20035, 00296 IconSilkTelephone = 20051, 00297 IconSilkTextAllCaps = 20052, 00298 IconSilkTextBold = 20053, 00299 IconSilkTextItalic = 20054, 00300 IconSilkTextUnderline = 20055, 00301 IconSilkThumbDown = 20036, 00302 IconSilkThumbUp = 20037, 00303 IconSilkTick = 20038, 00304 IconSilkTime = 20039, 00305 IconSilkWrench = 20040, 00306 IconSilkZoom = 20041, 00307 IconSilkZoomIn = 20042, 00308 IconSilkZoomOut = 20043, 00309 00310 LastIcon 00311 }; 00312 //ETX 00313 00314 // Description: 00315 // Set the icon image based on a predefined icon. 00316 virtual void SetImage(int predefined_icon_index); 00317 00318 // Description: 00319 // Set the icon image based on an existing vtkKWIcon. 00320 virtual void SetImage(vtkKWIcon*); 00321 00322 // Description: 00323 // Set the icon image based on an existing vtkImageData. 00324 // A XZ, YZ slice will be permuted into a XY slice automatically. 00325 virtual void SetImage(vtkImageData*); 00326 00327 // Description: 00328 // Set the icon image from pixel data, eventually zlib and base64. 00329 // If 'buffer_length' is 0, compute it automatically by multiplying 00330 // 'pixel_size', 'width' and 'height' together. 00331 // If ImageOptionFlipVertical is set in 'option', flip the image vertically 00332 //BTX 00333 enum 00334 { 00335 ImageOptionFlipVertical = 1 00336 }; 00337 //ETX 00338 void SetImage(const unsigned char* data, 00339 int width, int height, 00340 int pixel_size, 00341 unsigned long buffer_length = 0, 00342 int options = 0); 00343 00344 // Description: 00345 // Set the icon image to a color transfer function gradient, or a 2-colors 00346 // gradients, or a single color. Borders can be added automatically. 00347 // Return 1 on success, 0 otherwise 00348 //BTX 00349 enum 00350 { 00351 ImageOptionDrawBorder = 1, 00352 ImageOptionDrawDoubleBorder = 2, 00353 ImageOptionDrawVertically = 4 00354 }; 00355 //ETX 00356 virtual int SetImageToGradient(vtkColorTransferFunction *ctf, 00357 int width, int height, 00358 int options = 0); 00359 virtual int SetImageToRGBGradient(double r1, double g1, double b1, 00360 double r2, double g2, double b2, 00361 int width, int height, 00362 int options = 0); 00363 virtual int SetImageToSolidRGBColor(double r, double g, double b, 00364 int width, int height, 00365 int options = 0); 00366 00367 // Description: 00368 // Get the raw image data. 00369 virtual const unsigned char* GetData(); 00370 00371 // Description: 00372 // Get the width of the image. 00373 vtkGetMacro(Width, int); 00374 00375 // Description: 00376 // Get the height of the image. 00377 vtkGetMacro(Height, int); 00378 00379 // Description: 00380 // Get the pixel size of the image. 00381 vtkGetMacro(PixelSize, int); 00382 00383 // Description: 00384 // Fade the icon by a factor. 00385 // If the icon has an alpha channel, this multiplies each element in 00386 // the alpha channel by 'factor'. 00387 virtual void Fade(double factor); 00388 00389 // Description: 00390 // Change the hue to a new hue. 00391 virtual void SetHue(double hue); 00392 00393 // Description: 00394 // Flatten the image against a color. 00395 // If the icon has an alpha channel, this blends the image against 00396 // a 'r', 'g', 'b' background and discards the alpha channel. 00397 virtual void Flatten(double r, double g, double b); 00398 virtual void Flatten(double rgb[3]) 00399 { this->Flatten(rgb[0], rgb[1], rgb[2]); }; 00400 00401 // Description: 00402 // Compose an icon on top of this instance. 00403 // Supports only same size RGBA against same size RGBA at the moment. 00404 // Return 1 on success, 0 otherwise 00405 virtual int Compose(vtkKWIcon *icon); 00406 virtual int Compose(int icon_index); 00407 00408 // Description: 00409 // Trip the top or right portion of an icon (i.e. look for any fully 00410 // transparent area and shift the icon to the top or right). 00411 // Supports only RGBA at the moment. 00412 // Return 1 on success, 0 otherwise 00413 virtual int TrimTop(); 00414 virtual int TrimRight(); 00415 00416 // Description: 00417 // Resize the canvas. The new canvas can be made larger, or smaller 00418 // (thus cropping the current image). The position indicates where the 00419 // original image should be placed in the new canvas. 00420 // Supports pixel size 3 or 4, will create an output with pixel size = 4. 00421 // Return 1 on success, 0 otherwise 00422 //BTX 00423 enum 00424 { 00425 PositionInCanvasCenter = 0, 00426 PositionInCanvasNorthWest = 9, 00427 PositionInCanvasNorth = 1, 00428 PositionInCanvasNorthEast = 3, 00429 PositionInCanvasEast = 2, 00430 PositionInCanvasSouthEast = 6, 00431 PositionInCanvasSouth = 4, 00432 PositionInCanvasSouthWest = 12, 00433 PositionInCanvasWest = 8 00434 }; 00435 //ETX 00436 virtual int ResizeCanvas( 00437 int resized_width, int resized_height, int position); 00438 00439 // Description: 00440 // Resample the icon to a new size. 00441 // If the new 'width' is 0, it will be computed from the new 'height' by 00442 // keeping the aspect ratio of the icon (and vice-versa if height is 0). 00443 // Return 1 on success, 0 otherwise 00444 virtual int ResampleCanvas(int resampled_width, int resampled_height); 00445 00446 // Description: 00447 // Fit (and resample) the icon to a new size. The aspect ratio of the 00448 // icon is kept so that the new icon is not larger in any dimension than 00449 // the new size. 00450 // Return 1 on success, 0 otherwise 00451 virtual int FitCanvas(int fit_width, int fit_height); 00452 00453 protected: 00454 vtkKWIcon(); 00455 ~vtkKWIcon(); 00456 00457 // Description: 00458 // Set icon to the custom data. 00459 void SetData(const unsigned char* data, 00460 int width, int height, 00461 int pixel_size, 00462 int options = 0); 00463 00464 unsigned char* Data; 00465 int Width; 00466 int Height; 00467 int PixelSize; 00468 00469 private: 00470 vtkKWIcon(const vtkKWIcon&); // Not implemented 00471 void operator=(const vtkKWIcon&); // Not implemented 00472 }; 00473 00474 #endif 00475 00476 00477