A lot of style fixes, fixed a lot of warnings in RunView and Theme classes.

This commit is contained in:
barrett 2012-10-18 20:59:15 +00:00
parent f21d11a4fc
commit 14fee07aeb
5 changed files with 110 additions and 98 deletions

View File

@ -4,7 +4,8 @@
#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)

View File

@ -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;
@ -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;

View File

@ -124,7 +124,8 @@ 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&,
const BPoint&) const;
void LoadURL(const char* url); void LoadURL(const char* url);
public: public:

View File

@ -33,26 +33,23 @@
#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,
int16 renderCount)
: name (NULL),
fores (NULL), fores (NULL),
backs (NULL), backs (NULL),
text_renders (NULL), text_renders (NULL),
@ -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)
{ {

View File

@ -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);