Clapkit
Loading...
Searching...
No Matches
ckTextArea.h
Go to the documentation of this file.
1/*
2 *
3 * Clapkit
4 * ----------------------------------------------------------------------
5 * A wrapper for creating a 'generalized' app for Classic MacOS
6 * that (hopefully) can be ported easily to other platforms.
7 *
8 * CKTextArea
9 * ----------------------------------------------------------------------
10 * Defines a large text area, with or without scrollbars and editing enabled.
11 *
12 */
13
14#pragma once
15
16#include "ckApp.h"
17#include "ckTextField.h"
18#include <TextEdit.h>
19
24class CKTextArea : public CKTextField {
25
26 public:
27 CKTextArea(const CKControlInitParams& params);
29
30 virtual void PrepareForDraw();
31 virtual void Redraw();
32
33 virtual void RaisePropertyChange(const char* propertyName);
34 virtual bool HandleEvent(const CKEvent& evt);
35
39 virtual void __UpdateTextScroll(int vDelta, int hDelta);
40
44 virtual int __GetLineHeight() {
45 if (!this->__teHandle) {
46 return 0;
47 }
48 HLock((Handle)this->__teHandle);
49 // TODO: Instead of hard-coding first line,
50 // maybe we should determine what line is visible on top
51 // and use that.
52 int oneLinePixels = TEGetHeight(1, 0, this->__teHandle);
53 HUnlock((Handle)this->__teHandle);
54 return oneLinePixels;
55 };
56
60 virtual int __GetPageHeight() {
61 if (!this->__teHandle) {
62 return 0;
63 }
64 HLock((Handle)this->__teHandle);
65 TEPtr te = *(this->__teHandle);
66 int onePagePixels = te->viewRect.bottom - te->viewRect.top;
67 HUnlock((Handle)this->__teHandle);
68 return onePagePixels;
69 };
70
71 protected:
72 virtual void ResizeTE();
73 virtual void TECreated();
74
76 private:
77 virtual void __SetupScrollbars(bool removeOnly = false);
78 virtual void __HandleScrollBarClick(ControlHandle ctl, CKPoint point);
79
80 protected:
81 ControlHandle __vScrollBar = nullptr;
82 ControlHandle __hScrollBar = nullptr;
83 bool __needsFullRedraw = true;
84
85 public:
87};
TEHandle __teHandle
Definition ckLabel.h:64
Defines an observable value.
Definition ckProperty.h:60
Defines a multi-line text area that can optionally be editable.
Definition ckTextArea.h:24
virtual void ResizeTE()
Definition ckTextArea.cpp:122
ControlHandle __vScrollBar
Definition ckTextArea.h:81
virtual int __GetPageHeight()
This is only to be called from the UPPs for the scrollbar.
Definition ckTextArea.h:60
virtual void Redraw()
Definition ckTextArea.cpp:205
ControlHandle __hScrollBar
Definition ckTextArea.h:82
void __SyncScrollbarsFromTE()
Definition ckTextArea.cpp:439
CKProperty< CKScrollType > scrollType
Definition ckTextArea.h:86
virtual void TECreated()
Definition ckTextArea.cpp:157
virtual bool HandleEvent(const CKEvent &evt)
Definition ckTextArea.cpp:371
bool __needsFullRedraw
Definition ckTextArea.h:83
virtual int __GetLineHeight()
This is only to be called from the UPPs for the scrollbar.
Definition ckTextArea.h:44
virtual void __UpdateTextScroll(int vDelta, int hDelta)
This is only to be called from the UPPs for the scrollbar.
Definition ckTextArea.cpp:429
virtual void RaisePropertyChange(const char *propertyName)
Definition ckTextArea.cpp:358
~CKTextArea()
Definition ckTextArea.cpp:117
virtual void PrepareForDraw()
Definition ckTextArea.cpp:162
Defines a one-line editable text field.
Definition ckTextField.h:24
Initialization parameters for a CKControl.
Definition ckControl.h:27
Defines an event raised by the framework, mostly for user actions.
Definition ckTypes.h:496
Defines a point on the screen.
Definition ckTypes.h:122