Sheesh! No wonder the styling code wasn't fully working, as we were using different constants for font attributes than the ones used by BeOS R5. Now we use those constants directly. Still not ok, but we are on the right track now (I hope :))
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8738 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7ac08f006f
commit
f6cd639a4b
@ -27,6 +27,8 @@
|
||||
#include "InlineInput.h"
|
||||
#include "StyleBuffer.h"
|
||||
|
||||
#include <View.h> // For B_FONT_FAMILY_AND_STYLE, B_FONT_SIZE, etc.
|
||||
|
||||
|
||||
// _BStyleRunDescBuffer_
|
||||
|
||||
@ -459,24 +461,17 @@ _BStyleBuffer_::SetStyle(uint32 mode, const BFont *fromFont,
|
||||
BFont *toFont, const rgb_color *fromColor,
|
||||
rgb_color *toColor)
|
||||
{
|
||||
if (mode & doFont)
|
||||
if (mode & B_FONT_FAMILY_AND_STYLE)
|
||||
toFont->SetFamilyAndStyle(fromFont->FamilyAndStyle());
|
||||
|
||||
if (mode & doSize) {
|
||||
if (mode & addSize)
|
||||
toFont->SetSize(fromFont->Size());
|
||||
else
|
||||
toFont->SetSize(fromFont->Size());
|
||||
}
|
||||
if (mode & B_FONT_SIZE)
|
||||
toFont->SetSize(fromFont->Size());
|
||||
|
||||
if (mode & doShear)
|
||||
if (mode & B_FONT_SHEAR)
|
||||
toFont->SetShear(fromFont->Shear());
|
||||
|
||||
if (mode & doUnderline)
|
||||
toFont->SetFace(fromFont->Face());
|
||||
|
||||
if (mode & doColor)
|
||||
*toColor = *fromColor;
|
||||
//if (mode & doColor)
|
||||
// *toColor = *fromColor;
|
||||
}
|
||||
|
||||
|
||||
@ -503,7 +498,8 @@ void
|
||||
_BStyleBuffer_::ContinuousGetStyle(BFont *outFont, uint32 *ioMode,
|
||||
rgb_color *outColor, bool *sameColor, int32 fromOffset, int32 toOffset) const
|
||||
{
|
||||
uint32 mode = doAll;
|
||||
uint32 mode = B_FONT_ALL;
|
||||
|
||||
if (fStyleRunDesc.ItemCount() < 1) {
|
||||
if (ioMode)
|
||||
*ioMode = mode;
|
||||
@ -542,42 +538,31 @@ _BStyleBuffer_::ContinuousGetStyle(BFont *outFont, uint32 *ioMode,
|
||||
styleIndex = fStyleRunDesc[i]->index;
|
||||
style = &fStyleRecord[styleIndex]->style;
|
||||
|
||||
if (mode & doFont) {
|
||||
if (mode & B_FONT_FAMILY_AND_STYLE) {
|
||||
if (theStyle.font != style->font)
|
||||
mode &= ~doFont;
|
||||
mode &= ~B_FONT_FAMILY_AND_STYLE;
|
||||
}
|
||||
|
||||
if (mode & doSize) {
|
||||
if (mode & B_FONT_SIZE) {
|
||||
if (theStyle.font.Size() != style->font.Size())
|
||||
mode &= ~doSize;
|
||||
mode &= ~B_FONT_SIZE;
|
||||
}
|
||||
|
||||
if (mode & doShear) {
|
||||
if (mode & B_FONT_SHEAR) {
|
||||
if (theStyle.font.Shear() != style->font.Shear())
|
||||
mode &= ~doShear;
|
||||
mode &= ~B_FONT_SHEAR;
|
||||
}
|
||||
|
||||
if (mode & doUnderline) {
|
||||
// if (theStyle.underline != style->font.underline) {
|
||||
mode &= ~doUnderline;
|
||||
// }
|
||||
}
|
||||
|
||||
if (mode & doColor) {
|
||||
if ( (theStyle.color.red != style->color.red) ||
|
||||
(theStyle.color.green != style->color.green) ||
|
||||
(theStyle.color.blue != style->color.blue) ||
|
||||
(theStyle.color.alpha != style->color.alpha) ) {
|
||||
mode &= ~doColor;
|
||||
oneColor = false;
|
||||
}
|
||||
|
||||
if ( (theStyle.color.red != style->color.red) ||
|
||||
(theStyle.color.green != style->color.green) ||
|
||||
(theStyle.color.blue != style->color.blue) ||
|
||||
(theStyle.color.alpha != style->color.alpha) ) {
|
||||
oneColor = false;
|
||||
}
|
||||
|
||||
if (mode & doExtra) {
|
||||
// if (theStyle.extra != style->font.extra) {
|
||||
mode &= ~doExtra;
|
||||
// }
|
||||
}
|
||||
// TODO: Finish this: handle B_FONT_FACE, B_FONT_FLAGS, etc.
|
||||
// if needed
|
||||
|
||||
}
|
||||
|
||||
if (ioMode)
|
||||
|
@ -27,26 +27,12 @@
|
||||
// Standard Includes -----------------------------------------------------------
|
||||
|
||||
// System Includes -------------------------------------------------------------
|
||||
#include <SupportDefs.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include "TextViewSupportBuffer.h"
|
||||
#include <Font.h>
|
||||
#include <InterfaceDefs.h>
|
||||
#include <SupportDefs.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
#include "TextViewSupportBuffer.h"
|
||||
|
||||
// Local Includes --------------------------------------------------------------
|
||||
|
||||
// Local Defines ---------------------------------------------------------------
|
||||
enum {
|
||||
doFont = 0x00000001, // set font
|
||||
doSize = 0x00000002, // set size
|
||||
doShear = 0x00000004, // set shear
|
||||
doUnderline = 0x00000008, // set underline
|
||||
doColor = 0x00000010, // set color
|
||||
doExtra = 0x00000020, // set the extra field
|
||||
doAll = 0x0000003F, // set everything
|
||||
addSize = 0x00010000 // add size value
|
||||
};
|
||||
|
||||
typedef struct STEStyle {
|
||||
BFont font; // font
|
||||
|
@ -1095,7 +1095,7 @@ BTextView::SetText(BFile *inFile, int32 inOffset, int32 inLength,
|
||||
// apply nullStyle to inserted text
|
||||
fStyles->SyncNullStyle(inOffset);
|
||||
fStyles->SetStyleRange(inOffset, inOffset + inLength,
|
||||
fText->Length(), doAll, NULL, NULL);
|
||||
fText->Length(), B_FONT_ALL, NULL, NULL);
|
||||
}
|
||||
|
||||
fClickOffset = fSelStart = fSelEnd = 0;
|
||||
@ -1605,7 +1605,7 @@ BTextView::SetFontAndColor(const BFont *inFont, uint32 inMode,
|
||||
fStyles->SetStyleRange(fSelStart, fSelEnd, fText->Length(),
|
||||
inMode, &newFont, inColor);
|
||||
|
||||
if (inMode & doFont || inMode & doSize)
|
||||
if (inMode & B_FONT_FAMILY_AND_STYLE || inMode & B_FONT_SIZE)
|
||||
// recalc the line breaks and redraw with new style
|
||||
Refresh(fSelStart, fSelEnd, fSelStart != fSelEnd, false);
|
||||
else
|
||||
@ -1647,7 +1647,7 @@ BTextView::SetFontAndColor(int32 startOffset, int32 endOffset,
|
||||
fStyles->SetStyleRange(startOffset, endOffset, fText->Length(),
|
||||
inMode, &newFont, inColor);
|
||||
|
||||
if (inMode & doFont || inMode & doSize)
|
||||
if (inMode & B_FONT_FAMILY_AND_STYLE || inMode & B_FONT_SIZE)
|
||||
// recalc the line breaks and redraw with new style
|
||||
Refresh(startOffset, endOffset, startOffset != endOffset, false);
|
||||
else
|
||||
@ -1712,7 +1712,7 @@ BTextView::SetRunArray(int32 startOffset, int32 endOffset,
|
||||
}
|
||||
|
||||
fStyles->SetStyleRange(fromOffset, toOffset, textLength,
|
||||
doAll, &theRun->font, &theRun->color);
|
||||
B_FONT_ALL, &theRun->font, &theRun->color);
|
||||
|
||||
theRun++;
|
||||
}
|
||||
@ -2727,7 +2727,7 @@ BTextView::InsertText(const char *inText, int32 inLength, int32 inOffset,
|
||||
// apply nullStyle to inserted text
|
||||
fStyles->SyncNullStyle(inOffset);
|
||||
fStyles->SetStyleRange(inOffset, inOffset + inLength,
|
||||
fText->Length(), doAll, NULL, NULL);
|
||||
fText->Length(), B_FONT_ALL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user