1 /* 2 * Copyright 2006-2011, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 #ifndef STYLE_VIEW_H 9 #define STYLE_VIEW_H 10 11 12 #include "IconBuild.h" 13 #include "Observer.h" 14 15 #include <Referenceable.h> 16 #include <View.h> 17 18 19 class BMenu; 20 class BMenuField; 21 class CommandStack; 22 class CurrentColor; 23 class GradientControl; 24 25 _BEGIN_ICON_NAMESPACE 26 class Gradient; 27 class Style; 28 _END_ICON_NAMESPACE 29 30 _USING_ICON_NAMESPACE 31 32 33 // TODO: write lock the document when changing something... 34 35 enum { 36 MSG_STYLE_TYPE_CHANGED = 'stch', 37 }; 38 39 class StyleView : public BView, public Observer { 40 public: 41 StyleView(BRect frame); 42 virtual ~StyleView(); 43 44 // BView interface 45 virtual void AttachedToWindow(); 46 virtual void FrameResized(float width, float height); 47 virtual void MessageReceived(BMessage* message); 48 49 virtual BSize MinSize(); 50 51 // Observer interface 52 virtual void ObjectChanged(const Observable* object); 53 54 // StyleView 55 void SetStyle(Style* style); 56 void SetCommandStack(CommandStack* stack); 57 void SetCurrentColor(CurrentColor* color); 58 59 private: 60 void _SetGradient(Gradient* gradient, 61 bool forceControlUpdate = false, 62 bool sendMessage = false); 63 void _MarkType(BMenu* menu, int32 type) const; 64 void _SetStyleType(int32 type); 65 void _SetGradientType(int32 type); 66 void _AdoptCurrentColor(rgb_color color); 67 void _TransferGradientStopColor(); 68 69 private: 70 CommandStack* fCommandStack; 71 CurrentColor* fCurrentColor; 72 73 Style* fStyle; 74 BReference<Gradient> fGradient; 75 bool fIgnoreCurrentColorNotifications; 76 bool fIgnoreControlGradientNotifications; 77 78 GradientControl* fGradientControl; 79 BMenuField* fStyleType; 80 BMenuField* fGradientType; 81 82 BRect fPreviousBounds; 83 }; 84 85 86 #endif // STYLE_VIEW_H 87