1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 #include "PropertyEditorView.h" 10 11 #include <stdio.h> 12 13 #include "Property.h" 14 #include "PropertyItemView.h" 15 16 // constructor 17 PropertyEditorView::PropertyEditorView() 18 : BView(BRect(0.0, 0.0, 10.0, 10.0), "property item", 19 B_FOLLOW_LEFT | B_FOLLOW_TOP, 20 B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE), 21 fParent(NULL), 22 fSelected(false) 23 { 24 } 25 26 // destructor 27 PropertyEditorView::~PropertyEditorView() 28 { 29 } 30 31 // Draw 32 void 33 PropertyEditorView::Draw(BRect updateRect) 34 { 35 // just draw background 36 FillRect(Bounds(), B_SOLID_LOW); 37 } 38 39 // MouseDown 40 void 41 PropertyEditorView::MouseDown(BPoint where) 42 { 43 if (fParent) { 44 // forward click 45 fParent->MouseDown(ConvertToParent(where)); 46 } 47 } 48 49 // MouseUp 50 void 51 PropertyEditorView::MouseUp(BPoint where) 52 { 53 if (fParent) { 54 // forward click 55 fParent->MouseUp(ConvertToParent(where)); 56 } 57 } 58 59 // MouseMoved 60 void 61 PropertyEditorView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) 62 { 63 if (fParent) { 64 // forward click 65 fParent->MouseMoved(ConvertToParent(where), transit, dragMessage); 66 } 67 } 68 69 // PreferredHeight 70 float 71 PropertyEditorView::PreferredHeight() const 72 { 73 font_height fh; 74 GetFontHeight(&fh); 75 76 float height = floorf(4.0 + fh.ascent + fh.descent); 77 78 return height; 79 } 80 81 // SetSelected 82 void 83 PropertyEditorView::SetSelected(bool selected) 84 { 85 fSelected = selected; 86 } 87 88 // SetItemView 89 void 90 PropertyEditorView::SetItemView(PropertyItemView* parent) 91 { 92 fParent = parent; 93 if (fParent) { 94 BFont font; 95 fParent->GetFont(&font); 96 SetFont(&font); 97 SetLowColor(fParent->LowColor()); 98 } 99 } 100 101 // ValueChanged 102 void 103 PropertyEditorView::ValueChanged() 104 { 105 if (fParent) 106 fParent->UpdateObject(); 107 } 108 109