Cafu Engine
ScrolledMaterialWin.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_SCROLLED_MATERIAL_WIN_HPP_INCLUDED
8 #define CAFU_SCROLLED_MATERIAL_WIN_HPP_INCLUDED
9 
10 #include "Templates/Array.hpp"
11 #include "wx/scrolwin.h"
12 
13 
14 class EditorMaterialI;
15 
16 
17 namespace MaterialBrowser
18 {
19  class DialogT;
20 
21 
22  class ScrolledMaterialWindowT : public wxScrolledWindow
23  {
24  public:
25 
26  // Constructor.
27  ScrolledMaterialWindowT(DialogT* Parent, wxWindowID OurID, const ArrayT<EditorMaterialI*>& Materials);
28 
29  // Recomputes the size of the virtual window.
30  void UpdateVirtualSize();
31 
32  // If NewMat==NULL, this function does nothing.
33  // Otherwise NewMat is selected as the new current material, the material description text is updated,
34  // the window scrolled to the selected material, and finally the window is redrawn.
35  void SelectMaterial(EditorMaterialI* NewMat);
36 
37  /// A helper function exclusively for DialogT::OnButton_ExportDiffMaps().
38  void ExportDiffuseMaps(const wxString& DestinationDir) const;
39 
40 
41  private:
42 
43  struct TexPosEnumT
44  {
45  unsigned long Index; // Current index number of this material position.
46  EditorMaterialI* Mat; // Pointer to material.
47  wxRect MatRect; // The coordinates of this material position in the virtual window.
48  int CurrentX; // The current position. The next material position will be here.
49  int CurrentY;
50  int LargestY; // The largest y-coordinate encountered so far. Needed to know where the next row starts.
51  wxSize ClientSize; // The size of the client area (the visible fraction of the virtual window).
52  };
53 
54 
55  static const int SCROLL_INCREMENT_X;
56  static const int SCROLL_INCREMENT_Y;
57  static const int Padding;
58  static const int MaterialNameBoxHeight;
59 
60  DialogT* m_Parent;
61  const ArrayT<EditorMaterialI*>& m_Materials;
62 
63 
64  TexPosEnumT* EnumTexturePositions(bool Start) const;
65 
66  void OnDraw(wxDC& dc); // Overridden event handler.
67  void OnSize(wxSizeEvent& Event); // My own event handler for resize events.
68  void OnLeftButtonDown(wxMouseEvent& Event); // Left mouse button click handler.
69  void OnLeftButtonDoubleClick(wxMouseEvent& Event); // Left mouse button double click handler.
70 
71  DECLARE_EVENT_TABLE()
72  };
73 }
74 
75 #endif
void ExportDiffuseMaps(const wxString &DestinationDir) const
A helper function exclusively for DialogT::OnButton_ExportDiffMaps().
Definition: ScrolledMaterialWin.cpp:193
Definition: MaterialBrowserDialog.hpp:60
Definition: ScrolledMaterialWin.hpp:22
Definition: EditorMaterial.hpp:21