EditorStock.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // SuperTux Editor
  2. // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. using System;
  17. using Gtk;
  18. public static class EditorStock
  19. {
  20. static Gtk.IconFactory stock = new Gtk.IconFactory ();
  21. public static string Eye = "eye";
  22. public static string EyeHalf = "eye-half";
  23. public static string ToolSelect = "ToolSelect";
  24. public static string ToolTiles = "ToolTiles";
  25. public static string ToolObjects = "ToolObjects";
  26. public static string ToolBrush = "ToolBrush";
  27. public static string ToolFill = "ToolFill";
  28. public static string ToolReplace = "ToolReplace";
  29. public static string ToolPath = "ToolPath";
  30. public static string Camera = "Camera";
  31. public static string CameraMenuImage = "Camera";
  32. /// <summary>Icon for windows and dialogs</summary>
  33. public static Gdk.Pixbuf WindowIcon;
  34. static EditorStock ()
  35. {
  36. // Load Window icon.
  37. WindowIcon = Gdk.Pixbuf.LoadFromResource ("supertux-editor.png");
  38. AddIcon (Eye, Gtk.IconSize.Menu, "stock-eye-12.png");
  39. AddIcon (EyeHalf, Gtk.IconSize.Menu, "stock-eye-half-12.png");
  40. // HACK: This is needed to make tool icons show up on Windows, no idea why.
  41. // TODO: test if this is still needed with additional SizeWildcarded.
  42. // SizeWildcarded only gives fuzzy images, at least for stock-eye-12.png
  43. // It looks like windows are confusing large and small toolbar size ("SmallToolbar" causes 2x bigger buttons that "LargeToolbar"), bug in GTK for windows? bug in windows themselves?
  44. #if WINDOWS
  45. Gtk.IconSize ToolBarIconSize = Gtk.IconSize.SmallToolbar;
  46. #else
  47. Gtk.IconSize ToolBarIconSize = Gtk.IconSize.LargeToolbar;
  48. #endif
  49. AddIcon(ToolSelect, ToolBarIconSize, "stock-tool-select-24.png");
  50. AddIcon(ToolTiles, ToolBarIconSize, "stock-tool-tiles-24.png");
  51. AddIcon(ToolObjects, ToolBarIconSize, "stock-tool-objects-24.png");
  52. AddIcon(ToolBrush, ToolBarIconSize, "stock-tool-brush-24.png");
  53. AddIcon(ToolFill, ToolBarIconSize, "stock-tool-fill-24.png");
  54. AddIcon(ToolReplace, ToolBarIconSize, "stock-tool-replace-24.png");
  55. AddIcon(ToolPath, ToolBarIconSize, "stock-tool-path-24.png");
  56. AddIcon(Camera, ToolBarIconSize, "stock-camera-24.png");
  57. stock.AddDefault();
  58. }
  59. static void AddIcon (string stockid, Gtk.IconSize iconSize, string resource)
  60. {
  61. Gtk.IconSet iconset = stock.Lookup (stockid);
  62. if (iconset == null) {
  63. iconset = new Gtk.IconSet ();
  64. Gdk.Pixbuf img = Gdk.Pixbuf.LoadFromResource (resource);
  65. //no scaling in the given size, ...
  66. IconSource source = new IconSource ();
  67. source.Size = iconSize;
  68. source.SizeWildcarded = false;
  69. source.Pixbuf = img;
  70. iconset.AddSource (source);
  71. //... but allow to use the image for all other sizes, too.
  72. source = new IconSource ();
  73. source.SizeWildcarded = true;
  74. source.Pixbuf = img;
  75. iconset.AddSource (source);
  76. stock.Add (stockid, iconset);
  77. }
  78. }
  79. }
  80. /* EOF */