2 * Copyright 2004-2015, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
30 class DataView
: public BView
{
32 DataView(DataEditor
& editor
);
35 virtual void DetachedFromWindow();
36 virtual void AttachedToWindow();
37 virtual void MessageReceived(BMessage
* message
);
38 virtual void Draw(BRect updateRect
);
40 virtual void MouseDown(BPoint where
);
41 virtual void MouseMoved(BPoint where
, uint32 transit
,
42 const BMessage
* message
);
43 virtual void MouseUp(BPoint where
);
45 virtual void KeyDown(const char* bytes
, int32 numBytes
);
47 virtual void WindowActivated(bool active
);
48 virtual void MakeFocus(bool focus
);
49 virtual void FrameResized(float width
, float height
);
50 virtual void SetFont(const BFont
* font
,
51 uint32 properties
= B_FONT_ALL
);
52 virtual void GetPreferredSize(float* _width
, float* _height
);
54 bool FontSizeFitsBounds() const { return fFitFontSize
; }
55 float FontSize() const;
56 void SetFontSize(float point
);
58 void UpdateScroller();
60 void MakeVisible(int32 position
);
61 void SetSelection(int32 start
, int32 end
,
62 view_focus focus
= kNoFocus
);
63 void GetSelection(int32
& start
, int32
& end
);
64 void InvalidateRange(int32 start
, int32 end
);
66 base_type
Base() const { return fBase
; }
67 void SetBase(base_type type
);
69 const uint8
* DataAt(int32 start
);
71 static int32
WidthForFontSize(float size
);
74 BRect
DataBounds(bool inView
= false) const;
75 BRect
SelectionFrame(view_focus which
, int32 start
,
77 int32
PositionAt(view_focus focus
, BPoint point
,
78 view_focus
* _newFocus
= NULL
);
80 void DrawSelectionFrame(view_focus which
);
81 void DrawSelectionBlock(view_focus which
, int32 start
,
83 void DrawSelectionBlock(view_focus which
);
84 void DrawSelection(bool frameOnly
= false);
85 void SetActive(bool active
);
86 void SetFocus(view_focus which
);
88 void UpdateFromEditor(BMessage
* message
= NULL
);
89 void ConvertLine(char* line
, off_t offset
,
90 const uint8
* buffer
, size_t size
);
92 bool AcceptsDrop(const BMessage
* message
);
93 void InitiateDrag(view_focus focus
);
110 int32 fMouseSelectionStart
;
111 int32 fKeySelectionStart
;
114 int32 fDragMessageSize
;
115 int32 fStoredStart
, fStoredEnd
;
118 static const uint32 kMsgBaseType
= 'base';
119 static const uint32 kMsgUpdateData
= 'updt';
120 static const uint32 kMsgSetSelection
= 'ssel';
123 static const uint32 kDataViewCursorPosition
= 'curs';
124 static const uint32 kDataViewSelection
= 'dsel';
125 static const uint32 kDataViewPreferredSize
= 'dvps';
127 extern bool is_valid_utf8(uint8
* data
, size_t size
);
129 #endif /* DATA_VIEW_H */