StyledEdit: add menu to underline text
Eases testing of B_UNDERSCORE_FACE Change-Id: If3e1f247a984b81e9262136ca30139851cfa19a2 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4244 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
a43cf8d4a3
commit
40a12ac67e
@ -54,7 +54,8 @@ const uint32 FONT_STYLE = 'FSch';
|
|||||||
const uint32 FONT_COLOR = 'Fcol';
|
const uint32 FONT_COLOR = 'Fcol';
|
||||||
const uint32 kMsgSetItalic = 'Fita';
|
const uint32 kMsgSetItalic = 'Fita';
|
||||||
const uint32 kMsgSetBold = 'Fbld';
|
const uint32 kMsgSetBold = 'Fbld';
|
||||||
const uint32 kMsgSetFontDown = 'Fsdw';
|
const uint32 kMsgSetUnderline = 'Fuln';
|
||||||
|
const uint32 kMsgSetFontDown = 'Fsdw';
|
||||||
const uint32 kMsgSetFontUp = 'Fsup';
|
const uint32 kMsgSetFontUp = 'Fsup';
|
||||||
|
|
||||||
const rgb_color palette[] = {
|
const rgb_color palette[] = {
|
||||||
|
@ -376,6 +376,7 @@ StyledEditWindow::MessageReceived(BMessage* message)
|
|||||||
font.SetFamilyAndStyle(fontFamily, fontStyle);
|
font.SetFamilyAndStyle(fontFamily, fontStyle);
|
||||||
fItalicItem->SetMarked((font.Face() & B_ITALIC_FACE) != 0);
|
fItalicItem->SetMarked((font.Face() & B_ITALIC_FACE) != 0);
|
||||||
fBoldItem->SetMarked((font.Face() & B_BOLD_FACE) != 0);
|
fBoldItem->SetMarked((font.Face() & B_BOLD_FACE) != 0);
|
||||||
|
fUnderlineItem->SetMarked((font.Face() & B_UNDERSCORE_FACE) != 0);
|
||||||
|
|
||||||
_SetFontStyle(fontFamily, fontStyle);
|
_SetFontStyle(fontFamily, fontStyle);
|
||||||
break;
|
break;
|
||||||
@ -400,6 +401,7 @@ StyledEditWindow::MessageReceived(BMessage* message)
|
|||||||
font.SetFamilyAndStyle(fontFamily, fontStyle);
|
font.SetFamilyAndStyle(fontFamily, fontStyle);
|
||||||
fItalicItem->SetMarked((font.Face() & B_ITALIC_FACE) != 0);
|
fItalicItem->SetMarked((font.Face() & B_ITALIC_FACE) != 0);
|
||||||
fBoldItem->SetMarked((font.Face() & B_BOLD_FACE) != 0);
|
fBoldItem->SetMarked((font.Face() & B_BOLD_FACE) != 0);
|
||||||
|
fUnderlineItem->SetMarked((font.Face() & B_UNDERSCORE_FACE) != 0);
|
||||||
|
|
||||||
_SetFontStyle(fontFamily, fontStyle);
|
_SetFontStyle(fontFamily, fontStyle);
|
||||||
break;
|
break;
|
||||||
@ -474,6 +476,23 @@ StyledEditWindow::MessageReceived(BMessage* message)
|
|||||||
_SetFontStyle(family, style);
|
_SetFontStyle(family, style);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case kMsgSetUnderline:
|
||||||
|
{
|
||||||
|
uint32 sameProperties;
|
||||||
|
BFont font;
|
||||||
|
fTextView->GetFontAndColor(&font, &sameProperties);
|
||||||
|
|
||||||
|
if (fUnderlineItem->IsMarked())
|
||||||
|
font.SetFace(B_REGULAR_FACE);
|
||||||
|
fUnderlineItem->SetMarked(!fUnderlineItem->IsMarked());
|
||||||
|
|
||||||
|
font_family family;
|
||||||
|
font_style style;
|
||||||
|
font.GetFamilyAndStyle(&family, &style);
|
||||||
|
|
||||||
|
_SetFontStyle(family, style);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case FONT_COLOR:
|
case FONT_COLOR:
|
||||||
{
|
{
|
||||||
ssize_t colorLength;
|
ssize_t colorLength;
|
||||||
@ -742,6 +761,7 @@ StyledEditWindow::MenusBeginning()
|
|||||||
|
|
||||||
fBoldItem->SetMarked((font.Face() & B_BOLD_FACE) != 0);
|
fBoldItem->SetMarked((font.Face() & B_BOLD_FACE) != 0);
|
||||||
fItalicItem->SetMarked((font.Face() & B_ITALIC_FACE) != 0);
|
fItalicItem->SetMarked((font.Face() & B_ITALIC_FACE) != 0);
|
||||||
|
fUnderlineItem->SetMarked((font.Face() & B_UNDERSCORE_FACE) != 0);
|
||||||
|
|
||||||
switch (fTextView->Alignment()) {
|
switch (fTextView->Alignment()) {
|
||||||
case B_ALIGN_LEFT:
|
case B_ALIGN_LEFT:
|
||||||
@ -1213,6 +1233,10 @@ StyledEditWindow::_InitWindow(uint32 encoding)
|
|||||||
new BMessage(kMsgSetItalic));
|
new BMessage(kMsgSetItalic));
|
||||||
fItalicItem->SetShortcut('I', 0);
|
fItalicItem->SetShortcut('I', 0);
|
||||||
|
|
||||||
|
fUnderlineItem = new BMenuItem(B_TRANSLATE("Underline"),
|
||||||
|
new BMessage(kMsgSetUnderline));
|
||||||
|
fUnderlineItem->SetShortcut('U', 0);
|
||||||
|
|
||||||
fFontMenu = new BMenu(B_TRANSLATE("Font"));
|
fFontMenu = new BMenu(B_TRANSLATE("Font"));
|
||||||
fCurrentFontItem = 0;
|
fCurrentFontItem = 0;
|
||||||
fCurrentStyleItem = 0;
|
fCurrentStyleItem = 0;
|
||||||
@ -1226,6 +1250,7 @@ StyledEditWindow::_InitWindow(uint32 encoding)
|
|||||||
.AddItem(B_TRANSLATE("Decrease size"), kMsgSetFontDown, '-')
|
.AddItem(B_TRANSLATE("Decrease size"), kMsgSetFontDown, '-')
|
||||||
.AddItem(fBoldItem)
|
.AddItem(fBoldItem)
|
||||||
.AddItem(fItalicItem)
|
.AddItem(fItalicItem)
|
||||||
|
.AddItem(fUnderlineItem)
|
||||||
.AddSeparator()
|
.AddSeparator()
|
||||||
.End();
|
.End();
|
||||||
|
|
||||||
@ -1879,9 +1904,12 @@ StyledEditWindow::_SetFontStyle(const char* fontFamily, const char* fontStyle)
|
|||||||
if (fItalicItem->IsMarked())
|
if (fItalicItem->IsMarked())
|
||||||
face |= B_ITALIC_FACE;
|
face |= B_ITALIC_FACE;
|
||||||
|
|
||||||
|
if (fUnderlineItem->IsMarked())
|
||||||
|
face |= B_UNDERSCORE_FACE;
|
||||||
|
|
||||||
font.SetFace(face);
|
font.SetFace(face);
|
||||||
|
|
||||||
fTextView->SetFontAndColor(&font, B_FONT_FAMILY_AND_STYLE);
|
fTextView->SetFontAndColor(&font, B_FONT_FAMILY_AND_STYLE | B_FONT_FACE);
|
||||||
|
|
||||||
BMenuItem* superItem;
|
BMenuItem* superItem;
|
||||||
superItem = fFontMenu->FindItem(fontFamily);
|
superItem = fFontMenu->FindItem(fontFamily);
|
||||||
|
@ -126,6 +126,7 @@ private:
|
|||||||
|
|
||||||
BMenuItem* fBoldItem;
|
BMenuItem* fBoldItem;
|
||||||
BMenuItem* fItalicItem;
|
BMenuItem* fItalicItem;
|
||||||
|
BMenuItem* fUnderlineItem;
|
||||||
|
|
||||||
BMenuItem* fWrapItem;
|
BMenuItem* fWrapItem;
|
||||||
BMenuItem* fAlignLeft;
|
BMenuItem* fAlignLeft;
|
||||||
|
Loading…
Reference in New Issue
Block a user