| 61 | | public: |
| 62 | | BTextView(BRect frame, |
| 63 | | const char *name, |
| 64 | | BRect textRect, |
| 65 | | uint32 resizeMask, |
| 66 | | uint32 flags = B_WILL_DRAW | B_PULSE_NEEDED); |
| 67 | | BTextView(BRect frame, |
| 68 | | const char *name, |
| 69 | | BRect textRect, |
| 70 | | const BFont *initialFont, |
| 71 | | const rgb_color *initialColor, |
| 72 | | uint32 resizeMask, |
| 73 | | uint32 flags); |
| 74 | | BTextView(BMessage *data); |
| 75 | | virtual ~BTextView(); |
| 76 | | |
| 77 | | static BArchivable* Instantiate(BMessage *data); |
| 78 | | virtual status_t Archive(BMessage *data, bool deep = true) const; |
| 79 | | |
| 80 | | virtual void AttachedToWindow(); |
| 81 | | virtual void DetachedFromWindow(); |
| 82 | | virtual void Draw(BRect inRect); |
| 83 | | virtual void MouseDown(BPoint where); |
| 84 | | virtual void MouseUp(BPoint where); |
| 85 | | virtual void MouseMoved(BPoint where, |
| 86 | | uint32 code, |
| 87 | | const BMessage *message); |
| 88 | | virtual void WindowActivated(bool state); |
| 89 | | virtual void KeyDown(const char *bytes, int32 numBytes); |
| 90 | | virtual void Pulse(); |
| 91 | | virtual void FrameResized(float width, float height); |
| 92 | | virtual void MakeFocus(bool focusState = true); |
| 93 | | virtual void MessageReceived(BMessage *message); |
| 94 | | virtual BHandler* ResolveSpecifier(BMessage *message, |
| 95 | | int32 index, |
| 96 | | BMessage *specifier, |
| 97 | | int32 form, |
| 98 | | const char *property); |
| 99 | | virtual status_t GetSupportedSuites(BMessage *data); |
| 100 | | virtual status_t Perform(perform_code d, void *arg); |
| 101 | | |
| 102 | | void SetText(const char *inText, |
| 103 | | const text_run_array *inRuns = NULL); |
| 104 | | void SetText(const char *inText, |
| 105 | | int32 inLength, |
| 106 | | const text_run_array *inRuns = NULL); |
| 107 | | void SetText(BFile *inFile, |
| 108 | | int32 startOffset, |
| 109 | | int32 inLength, |
| 110 | | const text_run_array *inRuns = NULL); |
| 111 | | |
| 112 | | void Insert(const char *inText, |
| 113 | | const text_run_array *inRuns = NULL); |
| 114 | | void Insert(const char *inText, |
| 115 | | int32 inLength, |
| 116 | | const text_run_array *inRuns = NULL); |
| 117 | | void Insert(int32 startOffset, |
| 118 | | const char *inText, |
| 119 | | int32 inLength, |
| 120 | | const text_run_array *inRuns = NULL); |
| 121 | | |
| 122 | | void Delete(); |
| 123 | | void Delete(int32 startOffset, int32 endOffset); |
| 124 | | |
| 125 | | const char* Text() const; |
| 126 | | int32 TextLength() const; |
| 127 | | void GetText(int32 offset, |
| 128 | | int32 length, |
| 129 | | char *buffer) const; |
| 130 | | uchar ByteAt(int32 offset) const; |
| 131 | | |
| 132 | | int32 CountLines() const; |
| 133 | | int32 CurrentLine() const; |
| 134 | | void GoToLine(int32 lineNum); |
| 135 | | |
| 136 | | virtual void Cut(BClipboard *clipboard); |
| 137 | | virtual void Copy(BClipboard *clipboard); |
| 138 | | virtual void Paste(BClipboard *clipboard); |
| 139 | | void Clear(); |
| 140 | | |
| 141 | | virtual bool AcceptsPaste(BClipboard *clipboard); |
| 142 | | virtual bool AcceptsDrop(const BMessage *inMessage); |
| 143 | | |
| 144 | | virtual void Select(int32 startOffset, int32 endOffset); |
| 145 | | void SelectAll(); |
| 146 | | void GetSelection(int32 *outStart, int32 *outEnd) const; |
| 147 | | |
| 148 | | void SetFontAndColor(const BFont *inFont, |
| 149 | | uint32 inMode = B_FONT_ALL, |
| 150 | | const rgb_color *inColor = NULL); |
| 151 | | void SetFontAndColor(int32 startOffset, |
| 152 | | int32 endOffset, |
| 153 | | const BFont *inFont, |
| 154 | | uint32 inMode = B_FONT_ALL, |
| 155 | | const rgb_color *inColor = NULL); |
| 156 | | |
| 157 | | void GetFontAndColor(int32 inOffset, |
| 158 | | BFont *outFont, |
| 159 | | rgb_color *outColor = NULL) const; |
| 160 | | void GetFontAndColor(BFont *outFont, |
| 161 | | uint32 *outMode, |
| 162 | | rgb_color *outColor = NULL, |
| 163 | | bool *outEqColor = NULL) const; |
| 164 | | |
| 165 | | void SetRunArray(int32 startOffset, |
| 166 | | int32 endOffset, |
| 167 | | const text_run_array *inRuns); |
| 168 | | text_run_array* RunArray(int32 startOffset, |
| 169 | | int32 endOffset, |
| 170 | | int32 *outSize = NULL) const; |
| 171 | | |
| 172 | | int32 LineAt(int32 offset) const; |
| 173 | | int32 LineAt(BPoint point) const; |
| 174 | | BPoint PointAt(int32 inOffset, float *outHeight = NULL) const; |
| 175 | | int32 OffsetAt(BPoint point) const; |
| 176 | | int32 OffsetAt(int32 line) const; |
| 177 | | |
| 178 | | virtual void FindWord(int32 inOffset, |
| 179 | | int32 *outFromOffset, |
| 180 | | int32 *outToOffset); |
| 181 | | |
| 182 | | virtual bool CanEndLine(int32 offset); |
| 183 | | |
| 184 | | float LineWidth(int32 lineNum = 0) const; |
| 185 | | float LineHeight(int32 lineNum = 0) const; |
| 186 | | float TextHeight(int32 startLine, int32 endLine) const; |
| 187 | | |
| 188 | | void GetTextRegion(int32 startOffset, |
| 189 | | int32 endOffset, |
| 190 | | BRegion *outRegion) const; |
| 191 | | |
| 192 | | virtual void ScrollToOffset(int32 inOffset); |
| 193 | | void ScrollToSelection(); |
| 194 | | |
| 195 | | void Highlight(int32 startOffset, int32 endOffset); |
| 196 | | |
| 197 | | void SetTextRect(BRect rect); |
| 198 | | BRect TextRect() const; |
| 199 | | void SetStylable(bool stylable); |
| 200 | | bool IsStylable() const; |
| 201 | | void SetTabWidth(float width); |
| 202 | | float TabWidth() const; |
| 203 | | void MakeSelectable(bool selectable = true); |
| 204 | | bool IsSelectable() const; |
| 205 | | void MakeEditable(bool editable = true); |
| 206 | | bool IsEditable() const; |
| 207 | | void SetWordWrap(bool wrap); |
| 208 | | bool DoesWordWrap() const; |
| 209 | | void SetMaxBytes(int32 max); |
| 210 | | int32 MaxBytes() const; |
| 211 | | void DisallowChar(uint32 aChar); |
| 212 | | void AllowChar(uint32 aChar); |
| 213 | | void SetAlignment(alignment flag); |
| 214 | | alignment Alignment() const; |
| 215 | | void SetAutoindent(bool state); |
| 216 | | bool DoesAutoindent() const; |
| 217 | | void SetColorSpace(color_space colors); |
| 218 | | color_space ColorSpace() const; |
| 219 | | void MakeResizable(bool resize, BView *resizeView = NULL); |
| 220 | | bool IsResizable() const; |
| 221 | | void SetDoesUndo(bool undo); |
| 222 | | bool DoesUndo() const; |
| 223 | | void HideTyping(bool enabled); |
| 224 | | bool IsTypingHidden(void) const; |
| 225 | | |
| 226 | | virtual void ResizeToPreferred(); |
| 227 | | virtual void GetPreferredSize(float *width, float *height); |
| 228 | | virtual void AllAttached(); |
| 229 | | virtual void AllDetached(); |
| 230 | | |
| 231 | | |
| 232 | | static text_run_array* AllocRunArray(int32 entryCount, int32 *outSize = NULL); |
| 233 | | static text_run_array* CopyRunArray(const text_run_array *orig, int32 countDelta = 0); |
| 234 | | static void FreeRunArray(text_run_array *array); |
| 235 | | static void * FlattenRunArray(const text_run_array *inArray, int32 *outSize = NULL); |
| 236 | | static text_run_array* UnflattenRunArray(const void *data, int32 *outSize = NULL); |
| 237 | | |
| 238 | | protected: |
| 239 | | virtual void InsertText(const char *inText, |
| 240 | | int32 inLength, |
| 241 | | int32 inOffset, |
| 242 | | const text_run_array *inRuns); |
| 243 | | virtual void DeleteText(int32 fromOffset, int32 toOffset); |
| 244 | | |
| 245 | | public: |
| 246 | | virtual void Undo(BClipboard *clipboard); |
| 247 | | undo_state UndoState(bool *isRedo) const; |
| 248 | | |
| 249 | | protected: |
| 250 | | void _ScrollToOffset(int32 nOffset, bool useHorz, bool useVert); |
| 251 | | virtual void GetDragParameters(BMessage *drag, |
| 252 | | BBitmap **bitmap, |
| 253 | | BPoint *point, |
| 254 | | BHandler **handler); |
| 255 | | |
| 256 | | /*----- Private or reserved -----------------------------------------*/ |
| 257 | | private: |
| 258 | | friend status_t _init_interface_kit_(); |
| 259 | | friend class _BTextTrackState_; |
| 260 | | |
| 261 | | virtual void _ReservedTextView3(); |
| 262 | | virtual void _ReservedTextView4(); |
| 263 | | virtual void _ReservedTextView5(); |
| 264 | | virtual void _ReservedTextView6(); |
| 265 | | virtual void _ReservedTextView7(); |
| 266 | | virtual void _ReservedTextView8(); |
| 267 | | virtual void _ReservedTextView9(); |
| 268 | | virtual void _ReservedTextView10(); |
| 269 | | virtual void _ReservedTextView11(); |
| 270 | | virtual void _ReservedTextView12(); |
| 271 | | |
| 272 | | void InitObject(BRect textRect, |
| 273 | | const BFont *initialFont, |
| 274 | | const rgb_color *initialColor); |
| 275 | | |
| 276 | | void HandleBackspace(); |
| 277 | | void HandleArrowKey(uint32 inArrowKey); |
| 278 | | void HandleDelete(); |
| 279 | | void HandlePageKey(uint32 inPageKey); |
| 280 | | void HandleAlphaKey(const char *bytes, int32 numBytes); |
| 281 | | |
| 282 | | void Refresh(int32 fromOffset, |
| 283 | | int32 toOffset, |
| 284 | | bool erase, |
| 285 | | bool scroll); |
| 286 | | void RecalculateLineBreaks(int32 *startLine, int32 *endLine); |
| 287 | | int32 FindLineBreak(int32 fromOffset, |
| 288 | | float *outAscent, |
| 289 | | float *outDescent, |
| 290 | | float *ioWidth); |
| 291 | | |
| 292 | | float StyledWidth(int32 fromOffset, |
| 293 | | int32 length, |
| 294 | | float *outAscent = NULL, |
| 295 | | float *outDescent = NULL) const; |
| 296 | | float StyledWidthUTF8Safe(int32 fromOffset, |
| 297 | | int32 numChars, |
| 298 | | float *outAscent = NULL, |
| 299 | | float *outDescent = NULL) const; |
| 300 | | |
| 301 | | float ActualTabWidth(float location) const; |
| 302 | | |
| 303 | | void DoInsertText(const char *inText, |
| 304 | | int32 inLength, |
| 305 | | int32 inOffset, |
| 306 | | const text_run_array *inRuns, |
| 307 | | _BTextChangeResult_ *outResult); |
| 308 | | void DoDeleteText(int32 fromOffset, |
| 309 | | int32 toOffset, |
| 310 | | _BTextChangeResult_ *outResult); |
| 311 | | |
| 312 | | void _DrawLine(BView *view, const int32 &startLine, |
| 313 | | const int32 &startOffset, |
| 314 | | const bool &erase, |
| 315 | | BRect &eraseRect, |
| 316 | | BRegion &inputRegion); |
| 317 | | void DrawLines(int32 startLine, |
| 318 | | int32 endLine, |
| 319 | | int32 startOffset = -1, |
| 320 | | bool erase = false); |
| 321 | | void DrawCaret(int32 offset); |
| 322 | | void _ShowCaret(); |
| 323 | | void _HideCaret(); |
| 324 | | void InvertCaret(); |
| 325 | | void DragCaret(int32 offset); |
| 326 | | |
| 327 | | void StopMouseTracking(); |
| 328 | | bool PerformMouseUp(BPoint where); |
| 329 | | bool PerformMouseMoved(BPoint where, |
| 330 | | uint32 code); |
| 331 | | |
| 332 | | void TrackMouse(BPoint where, const BMessage *message, |
| 333 | | bool force = false); |
| 334 | | |
| 335 | | void TrackDrag(BPoint where); |
| 336 | | void InitiateDrag(); |
| 337 | | bool MessageDropped(BMessage *inMessage, |
| 338 | | BPoint where, |
| 339 | | BPoint offset); |
| 340 | | |
| 341 | | void PerformAutoScrolling(); |
| 342 | | void UpdateScrollbars(); |
| 343 | | void AutoResize(bool doRedraw = true); |
| 344 | | |
| 345 | | void NewOffscreen(float padding = 0.0F); |
| 346 | | void DeleteOffscreen(); |
| 347 | | |
| 348 | | void Activate(); |
| 349 | | void Deactivate(); |
| 350 | | |
| 351 | | void NormalizeFont(BFont *font); |
| 352 | | |
| 353 | | void _SetRunArray(int32 startOffset, int32 endOffset, |
| 354 | | const text_run_array *inRuns); |
| 355 | | |
| 356 | | uint32 CharClassification(int32 offset) const; |
| 357 | | int32 NextInitialByte(int32 offset) const; |
| 358 | | int32 PreviousInitialByte(int32 offset) const; |
| 359 | | |
| 360 | | bool GetProperty(BMessage *specifier, |
| 361 | | int32 form, |
| 362 | | const char *property, |
| 363 | | BMessage *reply); |
| 364 | | bool SetProperty(BMessage *specifier, |
| 365 | | int32 form, |
| 366 | | const char *property, |
| 367 | | BMessage *reply); |
| 368 | | bool CountProperties(BMessage *specifier, |
| 369 | | int32 form, |
| 370 | | const char *property, |
| 371 | | BMessage *reply); |
| 372 | | |
| 373 | | void HandleInputMethodChanged(BMessage *message); |
| 374 | | void HandleInputMethodLocationRequest(); |
| 375 | | void CancelInputMethod(); |
| 376 | | |
| 377 | | static void LockWidthBuffer(); |
| 378 | | static void UnlockWidthBuffer(); |
| 379 | | |
| | 50 | public: |
| | 51 | BTextView(BRect frame, const char* name, BRect textRect, |
| | 52 | uint32 resizeMask, uint32 flags = B_WILL_DRAW | B_PULSE_NEEDED); |
| | 53 | BTextView(BRect frame, const char* name, BRect textRect, |
| | 54 | const BFont* initialFont, const rgb_color* initialColor, |
| | 55 | uint32 resizeMask, uint32 flags); |
| | 56 | BTextView(BMessage* data); |
| | 57 | virtual ~BTextView(); |
| | 58 | |
| | 59 | static BArchivable* Instantiate(BMessage* data); |
| | 60 | virtual status_t Archive(BMessage* data, bool deep = true) const; |
| | 61 | |
| | 62 | virtual void AttachedToWindow(); |
| | 63 | virtual void DetachedFromWindow(); |
| | 64 | virtual void Draw(BRect inRect); |
| | 65 | virtual void MouseDown(BPoint where); |
| | 66 | virtual void MouseUp(BPoint where); |
| | 67 | virtual void MouseMoved(BPoint where, uint32 code, |
| | 68 | const BMessage* message); |
| | 69 | virtual void WindowActivated(bool state); |
| | 70 | virtual void KeyDown(const char* bytes, int32 numBytes); |
| | 71 | virtual void Pulse(); |
| | 72 | virtual void FrameResized(float width, float height); |
| | 73 | virtual void MakeFocus(bool focusState = true); |
| | 74 | virtual void MessageReceived(BMessage* message); |
| | 75 | |
| | 76 | virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, |
| | 77 | BMessage* specifier, int32 form, const char* property); |
| | 78 | virtual status_t GetSupportedSuites(BMessage* data); |
| | 79 | virtual status_t Perform(perform_code d, void* arg); |
| | 80 | |
| | 81 | void SetText(const char* inText, const text_run_array* inRuns = NULL); |
| | 82 | void SetText(const char* inText, int32 inLength, |
| | 83 | const text_run_array* inRuns = NULL); |
| | 84 | void SetText(BFile* inFile, int32 startOffset, int32 inLength, |
| | 85 | const text_run_array* inRuns = NULL); |
| | 86 | |
| | 87 | void Insert(const char* inText, const text_run_array* inRuns = NULL); |
| | 88 | void Insert(const char* inText, int32 inLength, const text_run_array* inRuns = NULL); |
| | 89 | void Insert(int32 startOffset, const char* inText, int32 inLength, const text_run_array* inRuns = NULL); |
| | 90 | |
| | 91 | void Delete(); |
| | 92 | void Delete(int32 startOffset, int32 endOffset); |
| | 93 | |
| | 94 | const char* Text() const; |
| | 95 | int32 TextLength() const; |
| | 96 | void GetText(int32 offset, int32 length, char* buffer) const; |
| | 97 | uint8 ByteAt(int32 offset) const; |
| | 98 | |
| | 99 | int32 CountLines() const; |
| | 100 | int32 CurrentLine() const; |
| | 101 | void GoToLine(int32 lineNum); |
| | 102 | |
| | 103 | virtual void Cut(BClipboard* clipboard); |
| | 104 | virtual void Copy(BClipboard* clipboard); |
| | 105 | virtual void Paste(BClipboard* clipboard); |
| | 106 | void Clear(); |
| | 107 | |
| | 108 | virtual bool AcceptsPaste(BClipboard* clipboard); |
| | 109 | virtual bool AcceptsDrop(const BMessage* inMessage); |
| | 110 | |
| | 111 | virtual void Select(int32 startOffset, int32 endOffset); |
| | 112 | void SelectAll(); |
| | 113 | void GetSelection(int32* outStart, int32* outEnd) const; |
| | 114 | |
| | 115 | void SetFontAndColor(const BFont* inFont, uint32 inMode = B_FONT_ALL, |
| | 116 | const rgb_color* inColor = NULL); |
| | 117 | void SetFontAndColor(int32 startOffset, int32 endOffset, |
| | 118 | const BFont* inFont, uint32 inMode = B_FONT_ALL, |
| | 119 | const rgb_color* inColor = NULL); |
| | 120 | |
| | 121 | void GetFontAndColor(int32 inOffset, BFont* outFont, |
| | 122 | rgb_color* outColor = NULL) const; |
| | 123 | void GetFontAndColor(BFont* outFont, uint32* sameProperties, |
| | 124 | rgb_color* outColor = NULL, bool* sameColor = NULL) const; |
| | 125 | |
| | 126 | void SetRunArray(int32 startOffset, int32 endOffset, |
| | 127 | const text_run_array* inRuns); |
| | 128 | text_run_array* RunArray(int32 startOffset, int32 endOffset, |
| | 129 | int32* outSize = NULL) const; |
| | 130 | |
| | 131 | int32 LineAt(int32 offset) const; |
| | 132 | int32 LineAt(BPoint point) const; |
| | 133 | BPoint PointAt(int32 inOffset, float* outHeight = NULL) const; |
| | 134 | int32 OffsetAt(BPoint point) const; |
| | 135 | int32 OffsetAt(int32 line) const; |
| | 136 | |
| | 137 | virtual void FindWord(int32 inOffset, int32* outFromOffset, |
| | 138 | int32* outToOffset); |
| | 139 | |
| | 140 | virtual bool CanEndLin |