A lot of style fixes, fixed a lot of warnings in RunView and Theme classes.
This commit is contained in:
parent
f21d11a4fc
commit
14fee07aeb
|
@ -4,8 +4,9 @@
|
||||||
#include "RunView.h"
|
#include "RunView.h"
|
||||||
|
|
||||||
|
|
||||||
CayaRenderView::CayaRenderView(const char *name, const char* smileyConfig) :
|
CayaRenderView::CayaRenderView(const char *name, const char* smileyConfig)
|
||||||
RunView( BRect(0, 0, 1, 1), name, fTheme = new Theme(name, COL_MAX_COLORS + 1, COL_MAX_COLORS + 1, MAX_RENDERS + 1), B_FOLLOW_ALL, B_WILL_DRAW )
|
:
|
||||||
|
RunView(BRect(0, 0, 1, 1), name, fTheme = new Theme(name, COL_MAX_COLORS + 1, COL_MAX_COLORS + 1, MAX_RENDERS + 1), B_FOLLOW_ALL, B_WILL_DRAW )
|
||||||
{
|
{
|
||||||
if (smileyConfig)
|
if (smileyConfig)
|
||||||
Emoticor::Get()->LoadConfig(smileyConfig);
|
Emoticor::Get()->LoadConfig(smileyConfig);
|
||||||
|
|
|
@ -106,8 +106,8 @@ struct FontColor {
|
||||||
// G++ is stupid. We only need 2 bits
|
// G++ is stupid. We only need 2 bits
|
||||||
// for fWhich, but the compiler has a bug
|
// for fWhich, but the compiler has a bug
|
||||||
// and warns us against fWhich == 2
|
// and warns us against fWhich == 2
|
||||||
int16 fWhich : 3;
|
int fWhich;
|
||||||
int16 fIndex : 13;
|
int fIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Line {
|
struct Line {
|
||||||
|
@ -343,11 +343,11 @@ RunView::Draw (BRect frame)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float indent (fTheme->TextMargin());
|
float indent (fTheme->TextMargin());
|
||||||
int place (0);
|
int place = 0;
|
||||||
|
|
||||||
int16 fore (0);
|
int fore = 0;
|
||||||
int16 back (0);
|
int back = 0;
|
||||||
int16 font (0);
|
int font = 0;
|
||||||
|
|
||||||
height = line->fTop;
|
height = line->fTop;
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ RunView::Draw (BRect frame)
|
||||||
if (line->fFcs[fore].fOffset > place)
|
if (line->fFcs[fore].fOffset > place)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
hi_color = fTheme->ForegroundAt (line->fFcs[fore].fIndex);
|
hi_color = fTheme->ForegroundAt(line->fFcs[fore].fIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
++fore;
|
++fore;
|
||||||
|
@ -390,8 +390,8 @@ RunView::Draw (BRect frame)
|
||||||
if (line->fFcs[back].fOffset > place)
|
if (line->fFcs[back].fOffset > place)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
low_color = fTheme->BackgroundAt(
|
||||||
low_color = fTheme->BackgroundAt (line->fFcs[back].fIndex);
|
line->fFcs[back].fIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
++back;
|
++back;
|
||||||
|
@ -2018,13 +2018,13 @@ Line::FigureEdges (
|
||||||
// but BFont::GetEdges doesn't seem to work as we'd like
|
// but BFont::GetEdges doesn't seem to work as we'd like
|
||||||
|
|
||||||
int16 i;
|
int16 i;
|
||||||
float size = 0;
|
int size = 0;
|
||||||
|
|
||||||
// if(tr)
|
// if(tr)
|
||||||
size = tr->Size();
|
size = tr->Size();
|
||||||
|
|
||||||
|
|
||||||
float incrementor = (fEdge_count > 0) ? fEdges[fEdge_count - 1] : 0;
|
int incrementor = (fEdge_count > 0) ? fEdges[fEdge_count - 1] : 0;
|
||||||
|
|
||||||
for (i = 0; i < ccount; ++i) {
|
for (i = 0; i < ccount; ++i) {
|
||||||
incrementor += eshift[i] * size;
|
incrementor += eshift[i] * size;
|
||||||
|
|
|
@ -97,23 +97,23 @@ class RunView : public BView
|
||||||
Line* fWorking;
|
Line* fWorking;
|
||||||
Line* fLines[LINE_COUNT];
|
Line* fLines[LINE_COUNT];
|
||||||
int16 fLine_count,
|
int16 fLine_count,
|
||||||
fClickCount;
|
fClickCount;
|
||||||
|
|
||||||
char* fStamp_format;
|
char* fStamp_format;
|
||||||
char* fClipping_name;
|
char* fClipping_name;
|
||||||
|
|
||||||
SelectPos fSp_start, fSp_end;
|
SelectPos fSp_start, fSp_end;
|
||||||
|
|
||||||
int32 fTracking;
|
int32 fTracking;
|
||||||
SelectPos fTrack_offset;
|
SelectPos fTrack_offset;
|
||||||
BMessageRunner* fOff_view_runner;
|
BMessageRunner* fOff_view_runner;
|
||||||
bigtime_t fOff_view_time;
|
bigtime_t fOff_view_time;
|
||||||
|
|
||||||
bool fResizedirty;
|
bool fResizedirty;
|
||||||
bool fFontsdirty;
|
bool fFontsdirty;
|
||||||
BPopUpMenu* fMyPopUp;
|
BPopUpMenu* fMyPopUp;
|
||||||
BPoint fLastClick;
|
BPoint fLastClick;
|
||||||
bigtime_t fLastClickTime;
|
bigtime_t fLastClickTime;
|
||||||
|
|
||||||
|
|
||||||
bool RecalcScrollBar (bool constrain);
|
bool RecalcScrollBar (bool constrain);
|
||||||
|
@ -124,8 +124,9 @@ class RunView : public BView
|
||||||
void CheckURLCursor (BPoint);
|
void CheckURLCursor (BPoint);
|
||||||
void BuildPopUp (void);
|
void BuildPopUp (void);
|
||||||
|
|
||||||
bool CheckClickBounds (const SelectPos&, const BPoint&) const;
|
bool CheckClickBounds (const SelectPos&,
|
||||||
void LoadURL(const char* url);
|
const BPoint&) const;
|
||||||
|
void LoadURL(const char* url);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -137,24 +138,24 @@ public:
|
||||||
uint32 = 0UL);
|
uint32 = 0UL);
|
||||||
virtual ~RunView (void);
|
virtual ~RunView (void);
|
||||||
|
|
||||||
virtual void AttachedToWindow (void);
|
virtual void AttachedToWindow (void);
|
||||||
virtual void DetachedFromWindow (void);
|
virtual void DetachedFromWindow (void);
|
||||||
virtual void FrameResized (float, float);
|
virtual void FrameResized (float, float);
|
||||||
virtual void TargetedByScrollView (BScrollView*);
|
virtual void TargetedByScrollView (BScrollView*);
|
||||||
virtual void Show ();
|
virtual void Show ();
|
||||||
virtual void Draw (BRect);
|
virtual void Draw (BRect);
|
||||||
virtual void MessageReceived (BMessage*);
|
virtual void MessageReceived (BMessage*);
|
||||||
|
|
||||||
virtual void SetViewColor (rgb_color);
|
virtual void SetViewColor (rgb_color);
|
||||||
void SetViewColor (uchar red, uchar green, uchar blue, uchar alpha = 255) {
|
void SetViewColor (uchar red, uchar green, uchar blue, uchar alpha = 255) {
|
||||||
rgb_color color = {red, green, blue, alpha};
|
rgb_color color = {red, green, blue, alpha};
|
||||||
SetViewColor (color);
|
SetViewColor (color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void MouseDown (BPoint);
|
virtual void MouseDown (BPoint);
|
||||||
virtual void MouseMoved (BPoint, uint32, const BMessage*);
|
virtual void MouseMoved (BPoint, uint32, const BMessage*);
|
||||||
virtual void MouseUp (BPoint);
|
virtual void MouseUp (BPoint);
|
||||||
|
|
||||||
|
|
||||||
void Append (const char*, int32, int, int, int);
|
void Append (const char*, int32, int, int, int);
|
||||||
|
|
|
@ -33,32 +33,29 @@
|
||||||
#include "Theme.h"
|
#include "Theme.h"
|
||||||
#include "NormalTextRender.h"
|
#include "NormalTextRender.h"
|
||||||
|
|
||||||
int16 Theme::TimestampFore = 0;
|
int Theme::TimestampFore = 0;
|
||||||
int16 Theme::TimestampBack = 0;
|
int Theme::TimestampBack = 0;
|
||||||
int16 Theme::TimestampFont = 0;
|
int Theme::TimestampFont = 0;
|
||||||
int16 Theme::TimespaceFore = 1;
|
int Theme::TimespaceFore = 1;
|
||||||
int16 Theme::TimespaceBack = 1;
|
int Theme::TimespaceBack = 1;
|
||||||
int16 Theme::TimespaceFont = 1;
|
int Theme::TimespaceFont = 1;
|
||||||
int16 Theme::NormalFore = 2;
|
int Theme::NormalFore = 2;
|
||||||
int16 Theme::NormalBack = 2;
|
int Theme::NormalBack = 2;
|
||||||
int16 Theme::NormalFont = 2;
|
int Theme::NormalFont = 2;
|
||||||
int16 Theme::SelectionBack = 3;
|
int Theme::SelectionBack = 3;
|
||||||
|
|
||||||
//at least we use a 'normal' text render
|
//at least we use a 'normal' text render
|
||||||
|
|
||||||
|
|
||||||
Theme::Theme (
|
Theme::Theme(const char* n, int foreCount, int backCount, int renderCount)
|
||||||
const char* n,
|
:
|
||||||
int16 foreCount,
|
name (NULL),
|
||||||
int16 backCount,
|
fores (NULL),
|
||||||
int16 renderCount)
|
backs (NULL),
|
||||||
: name (NULL),
|
text_renders (NULL),
|
||||||
fores (NULL),
|
fore_count (max_c (foreCount, 4)),
|
||||||
backs (NULL),
|
back_count (max_c (backCount, 4)),
|
||||||
text_renders (NULL),
|
render_count (max_c (renderCount, 4))
|
||||||
fore_count (max_c (foreCount, 4)),
|
|
||||||
back_count (max_c (backCount, 4)),
|
|
||||||
render_count (max_c (renderCount, 4))
|
|
||||||
{
|
{
|
||||||
|
|
||||||
fSoftLineIndent = (float)(MARGIN_WIDTH / 2.0);
|
fSoftLineIndent = (float)(MARGIN_WIDTH / 2.0);
|
||||||
|
@ -86,7 +83,7 @@ Theme::Theme (
|
||||||
|
|
||||||
fores[0] = def_timestamp_fore;
|
fores[0] = def_timestamp_fore;
|
||||||
|
|
||||||
int16 i;
|
int i;
|
||||||
for (i = 1; i < fore_count; ++i)
|
for (i = 1; i < fore_count; ++i)
|
||||||
fores[i] = def_fore;
|
fores[i] = def_fore;
|
||||||
|
|
||||||
|
@ -95,6 +92,7 @@ Theme::Theme (
|
||||||
backs[i] = def_back;
|
backs[i] = def_back;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Theme::~Theme (void)
|
Theme::~Theme (void)
|
||||||
{
|
{
|
||||||
delete_sem (sid);
|
delete_sem (sid);
|
||||||
|
@ -111,13 +109,15 @@ Theme::~Theme (void)
|
||||||
delete [] name;
|
delete [] name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16
|
|
||||||
|
int
|
||||||
Theme::CountForegrounds (void) const
|
Theme::CountForegrounds (void) const
|
||||||
{
|
{
|
||||||
return fore_count;
|
return fore_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16
|
|
||||||
|
int
|
||||||
Theme::CountBackgrounds (void) const
|
Theme::CountBackgrounds (void) const
|
||||||
{
|
{
|
||||||
return back_count;
|
return back_count;
|
||||||
|
@ -130,38 +130,44 @@ Theme::CountFonts (void) const
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int16
|
|
||||||
|
int
|
||||||
Theme::CountTextRenders (void) const
|
Theme::CountTextRenders (void) const
|
||||||
{
|
{
|
||||||
return render_count;
|
return render_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Theme::ReadLock (void)
|
Theme::ReadLock (void)
|
||||||
{
|
{
|
||||||
acquire_sem (sid);
|
acquire_sem (sid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Theme::ReadUnlock (void)
|
Theme::ReadUnlock (void)
|
||||||
{
|
{
|
||||||
release_sem (sid);
|
release_sem (sid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Theme::WriteLock (void)
|
Theme::WriteLock (void)
|
||||||
{
|
{
|
||||||
acquire_sem_etc (sid, NUMBER_THEME_READERS, 0, 0);
|
acquire_sem_etc (sid, NUMBER_THEME_READERS, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Theme::WriteUnlock (void)
|
Theme::WriteUnlock (void)
|
||||||
{
|
{
|
||||||
release_sem_etc (sid, NUMBER_THEME_READERS, 0);
|
release_sem_etc (sid, NUMBER_THEME_READERS, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const rgb_color
|
const rgb_color
|
||||||
Theme::ForegroundAt (int16 which) const
|
Theme::ForegroundAt (int which) const
|
||||||
{
|
{
|
||||||
rgb_color color = {0, 0, 0, 255};
|
rgb_color color = {0, 0, 0, 255};
|
||||||
|
|
||||||
|
@ -171,8 +177,9 @@ Theme::ForegroundAt (int16 which) const
|
||||||
return fores[which];
|
return fores[which];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const rgb_color
|
const rgb_color
|
||||||
Theme::BackgroundAt (int16 which) const
|
Theme::BackgroundAt (int which) const
|
||||||
{
|
{
|
||||||
rgb_color color = {255, 255, 255, 255};
|
rgb_color color = {255, 255, 255, 255};
|
||||||
|
|
||||||
|
@ -192,8 +199,9 @@ Theme::FontAt (int16 which) const
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
TextRender*
|
TextRender*
|
||||||
Theme::TextRenderAt (int16 which)
|
Theme::TextRenderAt (int which)
|
||||||
{
|
{
|
||||||
if ( which < 0 ) {
|
if ( which < 0 ) {
|
||||||
//printf("Theme::TextRenderAt(): which < 0 (%d)\n", which);
|
//printf("Theme::TextRenderAt(): which < 0 (%d)\n", which);
|
||||||
|
@ -207,8 +215,9 @@ Theme::TextRenderAt (int16 which)
|
||||||
return text_renders[which];
|
return text_renders[which];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Theme::SetForeground (int16 which, const rgb_color color)
|
Theme::SetForeground (int which, const rgb_color color)
|
||||||
{
|
{
|
||||||
if (which >= fore_count || which < 0)
|
if (which >= fore_count || which < 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -217,8 +226,9 @@ Theme::SetForeground (int16 which, const rgb_color color)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Theme::SetBackground (int16 which, const rgb_color color)
|
Theme::SetBackground (int which, const rgb_color color)
|
||||||
{
|
{
|
||||||
if (which >= back_count || which < 0)
|
if (which >= back_count || which < 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -229,7 +239,7 @@ Theme::SetBackground (int16 which, const rgb_color color)
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Theme::SetTextRender(int16 which, TextRender* trender)
|
Theme::SetTextRender(int which, TextRender* trender)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
@ -240,24 +250,28 @@ Theme::SetTextRender(int16 which, TextRender* trender)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Theme::AddView (BView* view)
|
Theme::AddView (BView* view)
|
||||||
{
|
{
|
||||||
list.AddItem (view);
|
list.AddItem (view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Theme::RemoveView (BView* view)
|
Theme::RemoveView (BView* view)
|
||||||
{
|
{
|
||||||
list.RemoveItem (view);
|
list.RemoveItem (view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Theme::SetTextMargin(float margin)
|
Theme::SetTextMargin(float margin)
|
||||||
{
|
{
|
||||||
fTextMargin = margin;
|
fTextMargin = margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Theme::SetSoftLineIndent(float indent)
|
Theme::SetSoftLineIndent(float indent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,9 +42,9 @@ class Theme
|
||||||
rgb_color* backs;
|
rgb_color* backs;
|
||||||
TextRender** text_renders; //FIX!!
|
TextRender** text_renders; //FIX!!
|
||||||
|
|
||||||
int16 fore_count;
|
int fore_count;
|
||||||
int16 back_count;
|
int back_count;
|
||||||
int16 render_count;
|
int render_count;
|
||||||
|
|
||||||
BList list;
|
BList list;
|
||||||
sem_id sid;
|
sem_id sid;
|
||||||
|
@ -55,22 +55,18 @@ class Theme
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static int16 TimestampFore;
|
static int TimestampFore;
|
||||||
static int16 TimestampBack;
|
static int TimestampBack;
|
||||||
static int16 TimestampFont;
|
static int TimestampFont;
|
||||||
static int16 TimespaceFore;
|
static int TimespaceFore;
|
||||||
static int16 TimespaceBack;
|
static int TimespaceBack;
|
||||||
static int16 TimespaceFont;
|
static int TimespaceFont;
|
||||||
static int16 NormalFore;
|
static int NormalFore;
|
||||||
static int16 NormalBack;
|
static int NormalBack;
|
||||||
static int16 NormalFont;
|
static int NormalFont;
|
||||||
static int16 SelectionBack;
|
static int SelectionBack;
|
||||||
|
|
||||||
Theme (
|
Theme(const char*, int, int, int);
|
||||||
const char*,
|
|
||||||
int16,
|
|
||||||
int16,
|
|
||||||
int16);
|
|
||||||
virtual ~Theme (void);
|
virtual ~Theme (void);
|
||||||
|
|
||||||
const char* Name (void) const {
|
const char* Name (void) const {
|
||||||
|
@ -82,31 +78,31 @@ public:
|
||||||
void WriteLock (void);
|
void WriteLock (void);
|
||||||
void WriteUnlock (void);
|
void WriteUnlock (void);
|
||||||
|
|
||||||
int16 CountForegrounds (void) const;
|
int CountForegrounds (void) const;
|
||||||
int16 CountBackgrounds (void) const;
|
int CountBackgrounds (void) const;
|
||||||
// int16 CountFonts (void) const;
|
// int16 CountFonts (void) const;
|
||||||
int16 CountTextRenders (void) const;
|
int CountTextRenders (void) const;
|
||||||
|
|
||||||
const rgb_color ForegroundAt (int16) const;
|
const rgb_color ForegroundAt (int) const;
|
||||||
const rgb_color BackgroundAt (int16) const;
|
const rgb_color BackgroundAt (int) const;
|
||||||
|
|
||||||
//const BFont &FontAt (int16) const;
|
//const BFont &FontAt (int16) const;
|
||||||
|
|
||||||
TextRender* TextRenderAt(int16);
|
TextRender* TextRenderAt(int);
|
||||||
|
|
||||||
bool SetForeground (int16, const rgb_color);
|
bool SetForeground (int, const rgb_color);
|
||||||
bool SetForeground (int16 w, uchar r, uchar g, uchar b, uchar a = 255) {
|
bool SetForeground (int w, uchar r, uchar g, uchar b, uchar a = 255) {
|
||||||
rgb_color color = {r, g, b, a};
|
rgb_color color = {r, g, b, a};
|
||||||
return SetForeground (w, color);
|
return SetForeground (w, color);
|
||||||
}
|
}
|
||||||
bool SetBackground (int16, const rgb_color);
|
bool SetBackground (int, const rgb_color);
|
||||||
bool SetBackground (int16 w, uchar r, uchar g, uchar b, uchar a = 255) {
|
bool SetBackground (int w, uchar r, uchar g, uchar b, uchar a = 255) {
|
||||||
rgb_color color = {r, g, b, a};
|
rgb_color color = {r, g, b, a};
|
||||||
return SetBackground (w, color);
|
return SetBackground (w, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
//bool SetFont (int16, const BFont &);
|
//bool SetFont (int16, const BFont &);
|
||||||
bool SetTextRender(int16, TextRender*);
|
bool SetTextRender(int, TextRender*);
|
||||||
|
|
||||||
void SetSoftLineIndent(float indent);
|
void SetSoftLineIndent(float indent);
|
||||||
void SetTextMargin(float margin);
|
void SetTextMargin(float margin);
|
||||||
|
|
Ŝarĝante…
Reference in New Issue