Implemented non-wrapping multiline entries in GTK+ and started implementing them in OS X.

This commit is contained in:
Pietro Gagliardi 2016-05-22 14:20:54 -04:00
parent 313ce47833
commit 07cd03452d
2 changed files with 25 additions and 5 deletions

View File

@ -101,7 +101,7 @@ void uiMultilineEntrySetReadOnly(uiMultilineEntry *e, int readonly)
[e->tv setEditable:editable];
}
uiMultilineEntry *uiNewMultilineEntry(void)
static uiMultilineEntry *finishMultilineEntry(BOOL hscroll)
{
uiMultilineEntry *e;
NSFont *font;
@ -110,7 +110,7 @@ uiMultilineEntry *uiNewMultilineEntry(void)
e->sv = [[NSScrollView alloc] initWithFrame:NSZeroRect];
// TODO verify against Interface Builder
[e->sv setHasHorizontalScroller:NO];
[e->sv setHasHorizontalScroller:hscroll];
[e->sv setHasVerticalScroller:YES];
[e->sv setAutohidesScrollers:YES];
[e->sv setBorderType:NSBezelBorder];
@ -173,6 +173,16 @@ uiMultilineEntry *uiNewMultilineEntry(void)
return e;
}
uiMultilineEntry *uiNewMultilineEntry(void)
{
return finishMultilineEntry(NO);
}
uiMultilineEntry *uiNewNonWrappingMultilineEntry(void)
{
return finishMultilineEntry(YES);
}
// TODO
#if 0

View File

@ -81,7 +81,7 @@ void uiMultilineEntrySetReadOnly(uiMultilineEntry *e, int readonly)
gtk_text_view_set_editable(e->textview, editable);
}
uiMultilineEntry *uiNewMultilineEntry(void)
static uiMultilineEntry *finishMultilineEntry(GtkPolicyType hpolicy, GtkWrapMode wrapMode)
{
uiMultilineEntry *e;
@ -91,13 +91,13 @@ uiMultilineEntry *uiNewMultilineEntry(void)
e->scontainer = GTK_CONTAINER(e->widget);
e->sw = GTK_SCROLLED_WINDOW(e->widget);
gtk_scrolled_window_set_policy(e->sw,
GTK_POLICY_NEVER,
hpolicy,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type(e->sw, GTK_SHADOW_IN);
e->textviewWidget = gtk_text_view_new();
e->textview = GTK_TEXT_VIEW(e->textviewWidget);
gtk_text_view_set_wrap_mode(e->textview, GTK_WRAP_WORD);
gtk_text_view_set_wrap_mode(e->textview, wrapMode);
gtk_container_add(e->scontainer, e->textviewWidget);
// and make the text view visible; only the scrolled window's visibility is controlled by libui
@ -110,3 +110,13 @@ uiMultilineEntry *uiNewMultilineEntry(void)
return e;
}
uiMultilineEntry *uiNewMultilineEntry(void)
{
return finishMultilineEntry(GTK_POLICY_NEVER, GTK_WRAP_WORD);
}
uiMultilineEntry *uiNewNonWrappingMultilineEntry(void)
{
return finishMultilineEntry(GTK_POLICY_AUTOMATIC, GTK_WRAP_NONE);
}