Integrated the new scrollview stuff with uiMultilineEntry. Nice and stable now :D
This commit is contained in:
parent
34d54f29b4
commit
923a678e87
|
@ -44,15 +44,24 @@ struct uiMultilineEntry {
|
||||||
uiDarwinControl c;
|
uiDarwinControl c;
|
||||||
NSScrollView *sv;
|
NSScrollView *sv;
|
||||||
intrinsicSizeTextView *tv;
|
intrinsicSizeTextView *tv;
|
||||||
|
struct scrollViewData *d;
|
||||||
void (*onChanged)(uiMultilineEntry *, void *);
|
void (*onChanged)(uiMultilineEntry *, void *);
|
||||||
void *onChangedData;
|
void *onChangedData;
|
||||||
struct scrollViewConstraints constraints;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO events
|
// TODO events
|
||||||
|
|
||||||
// TODO destroy
|
uiDarwinControlAllDefaultsExceptDestroy(uiMultilineEntry, sv)
|
||||||
uiDarwinControlAllDefaults(uiMultilineEntry, sv)
|
|
||||||
|
static void uiMultilineEntryDestroy(uiControl *c)
|
||||||
|
{
|
||||||
|
uiMultilineEntry *e = uiMultilineEntry(c);
|
||||||
|
|
||||||
|
scrollViewFreeData(e->sv, e->d);
|
||||||
|
[e->tv release];
|
||||||
|
[e->sv release];
|
||||||
|
uiFreeControl(uiControl(e));
|
||||||
|
}
|
||||||
|
|
||||||
static void defaultOnChanged(uiMultilineEntry *e, void *data)
|
static void defaultOnChanged(uiMultilineEntry *e, void *data)
|
||||||
{
|
{
|
||||||
|
@ -107,16 +116,10 @@ static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
|
||||||
{
|
{
|
||||||
uiMultilineEntry *e;
|
uiMultilineEntry *e;
|
||||||
NSFont *font;
|
NSFont *font;
|
||||||
|
struct scrollViewCreateParams p;
|
||||||
|
|
||||||
uiDarwinNewControl(uiMultilineEntry, e);
|
uiDarwinNewControl(uiMultilineEntry, e);
|
||||||
|
|
||||||
e->sv = [[NSScrollView alloc] initWithFrame:NSZeroRect];
|
|
||||||
// TODO verify against Interface Builder
|
|
||||||
[e->sv setHasHorizontalScroller:hscroll];
|
|
||||||
[e->sv setHasVerticalScroller:YES];
|
|
||||||
[e->sv setAutohidesScrollers:YES];
|
|
||||||
[e->sv setBorderType:NSBezelBorder];
|
|
||||||
|
|
||||||
e->tv = [[intrinsicSizeTextView alloc] initWithFrame:NSZeroRect];
|
e->tv = [[intrinsicSizeTextView alloc] initWithFrame:NSZeroRect];
|
||||||
// verified against Interface Builder, except for rich text options
|
// verified against Interface Builder, except for rich text options
|
||||||
[e->tv setAllowsDocumentBackgroundColorChange:NO];
|
[e->tv setAllowsDocumentBackgroundColorChange:NO];
|
||||||
|
@ -166,15 +169,14 @@ static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
|
||||||
// let's just set it to the standard control font anyway, just to be safe
|
// let's just set it to the standard control font anyway, just to be safe
|
||||||
[e->tv setFont:font];
|
[e->tv setFont:font];
|
||||||
|
|
||||||
[e->sv setDocumentView:e->tv];
|
memset(&p, 0, sizeof (struct scrollViewCreateParams));
|
||||||
[e->tv setTranslatesAutoresizingMaskIntoConstraints:NO];
|
p.DocumentView = e->tv;
|
||||||
scrollViewConstraintsEstablish(&(e->constraints), e->sv, hscroll, YES, @"uiMultilineEntry");
|
p.BackgroundColor = nil;
|
||||||
// needed to allow horizontal shrinking
|
p.DrawsBackground = YES;
|
||||||
// TODO what about vertical text?
|
p.Bordered = YES;
|
||||||
[e->tv setContentCompressionResistancePriority:NSLayoutPriorityDefaultLow forOrientation:NSLayoutConstraintOrientationHorizontal];
|
p.HScroll = hscroll;
|
||||||
|
p.VScroll = YES;
|
||||||
//TODO:void printinfo(NSScrollView *sv, NSTextView *tv);
|
e->sv = mkScrollView(&p, &(e->d));
|
||||||
//printinfo(e->sv, e->tv);
|
|
||||||
|
|
||||||
uiMultilineEntryOnChanged(e, defaultOnChanged, NULL);
|
uiMultilineEntryOnChanged(e, defaultOnChanged, NULL);
|
||||||
|
|
||||||
|
@ -227,47 +229,7 @@ NSTextView *tv;
|
||||||
} _s;
|
} _s;
|
||||||
_s.sv = sv;
|
_s.sv = sv;
|
||||||
_s.tv = tv;
|
_s.tv = tv;
|
||||||
|
|
||||||
add("NSScrollView");
|
|
||||||
add(" backgroundColor %@", [self.sv backgroundColor]);
|
|
||||||
add(" drawsBackground %d", [self.sv drawsBackground]);
|
|
||||||
add(" borderType %d", [self.sv borderType]);
|
|
||||||
add(" documentCursor %@", [self.sv documentCursor]);
|
|
||||||
add(" hasHorizontalScroller %d", [self.sv hasHorizontalScroller]);
|
|
||||||
add(" hasVerticalScroller %d", [self.sv hasVerticalScroller]);
|
|
||||||
add(" autohidesScrollers %d", [self.sv autohidesScrollers]);
|
|
||||||
add(" hasHorizontalRuler %d", [self.sv hasHorizontalRuler]);
|
|
||||||
add(" hasVerticalRuler %d", [self.sv hasVerticalRuler]);
|
|
||||||
add(" rulersVisible %d", [self.sv rulersVisible]);
|
|
||||||
add(" automaticallyAdjustsContentInsets %d",
|
|
||||||
[self.sv automaticallyAdjustsContentInsets]);
|
|
||||||
add(" contentInsets %@",
|
|
||||||
edgeInsetsStr([self.sv contentInsets]));
|
|
||||||
add(" scrollerInsets %@",
|
|
||||||
edgeInsetsStr([self.sv scrollerInsets]));
|
|
||||||
add(" scrollerKnobStyle %d", [self.sv scrollerKnobStyle]);
|
|
||||||
add(" scrollerStyle %d", [self.sv scrollerStyle]);
|
|
||||||
add(" lineScroll %g", [self.sv lineScroll]);
|
|
||||||
add(" horizontalLineScroll %g", [self.sv horizontalLineScroll]);
|
|
||||||
add(" verticalLineScroll %g", [self.sv verticalLineScroll]);
|
|
||||||
add(" pageScroll %g", [self.sv pageScroll]);
|
|
||||||
add(" horizontalPageScroll %g", [self.sv horizontalPageScroll]);
|
|
||||||
add(" verticalPageScroll %g", [self.sv verticalPageScroll]);
|
|
||||||
add(" scrollsDynamically %d", [self.sv scrollsDynamically]);
|
|
||||||
add(" findBarPosition %d", [self.sv findBarPosition]);
|
|
||||||
add(" usesPredominantAxisScrolling %d",
|
|
||||||
[self.sv usesPredominantAxisScrolling]);
|
|
||||||
add(" horizontalScrollElasticity %d",
|
|
||||||
[self.sv horizontalScrollElasticity]);
|
|
||||||
add(" verticalScrollElasticity %d",
|
|
||||||
[self.sv verticalScrollElasticity]);
|
|
||||||
add(" allowsMagnification %d", [self.sv allowsMagnification]);
|
|
||||||
add(" magnification %g", [self.sv magnification]);
|
|
||||||
add(" maxMagnification %g", [self.sv maxMagnification]);
|
|
||||||
add(" minMagnification %g", [self.sv minMagnification]);
|
|
||||||
|
|
||||||
add("");
|
|
||||||
|
|
||||||
add("NSTextView");
|
add("NSTextView");
|
||||||
add(" textContainerInset %@",
|
add(" textContainerInset %@",
|
||||||
NSStringFromSize([self.tv textContainerInset]));
|
NSStringFromSize([self.tv textContainerInset]));
|
||||||
|
|
|
@ -33,11 +33,11 @@ NSScrollView *mkScrollView(struct scrollViewCreateParams *p, struct scrollViewDa
|
||||||
[sv setScrollerKnobStyle:NSScrollerKnobStyleDefault];
|
[sv setScrollerKnobStyle:NSScrollerKnobStyleDefault];
|
||||||
// the scroller style is documented as being set by default for us
|
// the scroller style is documented as being set by default for us
|
||||||
// TODO verify line and page for programmatically created NSTextView
|
// TODO verify line and page for programmatically created NSTextView
|
||||||
[sv scrollsDynamically:YES];
|
[sv setScrollsDynamically:YES];
|
||||||
[sv setFindBarPosition:NSScrollViewFindBarPositionAboveContent];
|
[sv setFindBarPosition:NSScrollViewFindBarPositionAboveContent];
|
||||||
[sv setUsesPredominantAxisScrolling:NO];
|
[sv setUsesPredominantAxisScrolling:NO];
|
||||||
[sv setHorizontalElasticity:NSScrollElasticityAutomatic];
|
[sv setHorizontalScrollElasticity:NSScrollElasticityAutomatic];
|
||||||
[sv setVerticalElasticity:NSScrollElasticityAutomatic];
|
[sv setVerticalScrollElasticity:NSScrollElasticityAutomatic];
|
||||||
[sv setAllowsMagnification:NO];
|
[sv setAllowsMagnification:NO];
|
||||||
|
|
||||||
[p->DocumentView setTranslatesAutoresizingMaskIntoConstraints:NO];
|
[p->DocumentView setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||||
|
|
|
@ -115,6 +115,7 @@ struct scrollViewCreateParams {
|
||||||
BOOL HScroll;
|
BOOL HScroll;
|
||||||
BOOL VScroll;
|
BOOL VScroll;
|
||||||
};
|
};
|
||||||
|
struct scrollViewData;
|
||||||
extern NSScrollView *mkScrollView(struct scrollViewCreateParams *p, struct scrollViewData **dout);
|
extern NSScrollView *mkScrollView(struct scrollViewCreateParams *p, struct scrollViewData **dout);
|
||||||
extern void scrollViewSetScrolling(NSScrollView *sv, struct scrollViewData *d, BOOL hscroll, BOOL vscroll);
|
extern void scrollViewSetScrolling(NSScrollView *sv, struct scrollViewData *d, BOOL hscroll, BOOL vscroll);
|
||||||
extern void scrollViewFreeData(NSScrollView *sv, struct scrollViewData *d);
|
extern void scrollViewFreeData(NSScrollView *sv, struct scrollViewData *d);
|
||||||
|
|
Loading…
Reference in New Issue