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,8 +4,9 @@
#include "RunView.h"
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 )
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 )
{
if (smileyConfig)
Emoticor::Get()->LoadConfig(smileyConfig);

View File

@ -106,8 +106,8 @@ struct FontColor {
// G++ is stupid. We only need 2 bits
// for fWhich, but the compiler has a bug
// and warns us against fWhich == 2
int16 fWhich : 3;
int16 fIndex : 13;
int fWhich;
int fIndex;
};
struct Line {
@ -343,11 +343,11 @@ RunView::Draw (BRect frame)
continue;
float indent (fTheme->TextMargin());
int place (0);
int place = 0;
int16 fore (0);
int16 back (0);
int16 font (0);
int fore = 0;
int back = 0;
int font = 0;
height = line->fTop;
@ -378,7 +378,7 @@ RunView::Draw (BRect frame)
if (line->fFcs[fore].fOffset > place)
break;
hi_color = fTheme->ForegroundAt (line->fFcs[fore].fIndex);
hi_color = fTheme->ForegroundAt(line->fFcs[fore].fIndex);
}
++fore;
@ -390,8 +390,8 @@ RunView::Draw (BRect frame)
if (line->fFcs[back].fOffset > place)
break;
low_color = fTheme->BackgroundAt (line->fFcs[back].fIndex);
low_color = fTheme->BackgroundAt(
line->fFcs[back].fIndex);
}
++back;
@ -2018,13 +2018,13 @@ Line::FigureEdges (
// but BFont::GetEdges doesn't seem to work as we'd like
int16 i;
float size = 0;
int size = 0;
// if(tr)
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) {
incrementor += eshift[i] * size;

View File

@ -124,7 +124,8 @@ class RunView : public BView
void CheckURLCursor (BPoint);
void BuildPopUp (void);
bool CheckClickBounds (const SelectPos&, const BPoint&) const;
bool CheckClickBounds (const SelectPos&,
const BPoint&) const;
void LoadURL(const char* url);
public:

View File

@ -33,26 +33,23 @@
#include "Theme.h"
#include "NormalTextRender.h"
int16 Theme::TimestampFore = 0;
int16 Theme::TimestampBack = 0;
int16 Theme::TimestampFont = 0;
int16 Theme::TimespaceFore = 1;
int16 Theme::TimespaceBack = 1;
int16 Theme::TimespaceFont = 1;
int16 Theme::NormalFore = 2;
int16 Theme::NormalBack = 2;
int16 Theme::NormalFont = 2;
int16 Theme::SelectionBack = 3;
int Theme::TimestampFore = 0;
int Theme::TimestampBack = 0;
int Theme::TimestampFont = 0;
int Theme::TimespaceFore = 1;
int Theme::TimespaceBack = 1;
int Theme::TimespaceFont = 1;
int Theme::NormalFore = 2;
int Theme::NormalBack = 2;
int Theme::NormalFont = 2;
int Theme::SelectionBack = 3;
//at least we use a 'normal' text render
Theme::Theme (
const char* n,
int16 foreCount,
int16 backCount,
int16 renderCount)
: name (NULL),
Theme::Theme(const char* n, int foreCount, int backCount, int renderCount)
:
name (NULL),
fores (NULL),
backs (NULL),
text_renders (NULL),
@ -86,7 +83,7 @@ Theme::Theme (
fores[0] = def_timestamp_fore;
int16 i;
int i;
for (i = 1; i < fore_count; ++i)
fores[i] = def_fore;
@ -95,6 +92,7 @@ Theme::Theme (
backs[i] = def_back;
}
Theme::~Theme (void)
{
delete_sem (sid);
@ -111,13 +109,15 @@ Theme::~Theme (void)
delete [] name;
}
int16
int
Theme::CountForegrounds (void) const
{
return fore_count;
}
int16
int
Theme::CountBackgrounds (void) const
{
return back_count;
@ -130,38 +130,44 @@ Theme::CountFonts (void) const
}
*/
int16
int
Theme::CountTextRenders (void) const
{
return render_count;
}
void
Theme::ReadLock (void)
{
acquire_sem (sid);
}
void
Theme::ReadUnlock (void)
{
release_sem (sid);
}
void
Theme::WriteLock (void)
{
acquire_sem_etc (sid, NUMBER_THEME_READERS, 0, 0);
}
void
Theme::WriteUnlock (void)
{
release_sem_etc (sid, NUMBER_THEME_READERS, 0);
}
const rgb_color
Theme::ForegroundAt (int16 which) const
Theme::ForegroundAt (int which) const
{
rgb_color color = {0, 0, 0, 255};
@ -171,8 +177,9 @@ Theme::ForegroundAt (int16 which) const
return fores[which];
}
const rgb_color
Theme::BackgroundAt (int16 which) const
Theme::BackgroundAt (int which) const
{
rgb_color color = {255, 255, 255, 255};
@ -192,8 +199,9 @@ Theme::FontAt (int16 which) const
}
*/
TextRender*
Theme::TextRenderAt (int16 which)
Theme::TextRenderAt (int which)
{
if ( which < 0 ) {
//printf("Theme::TextRenderAt(): which < 0 (%d)\n", which);
@ -207,8 +215,9 @@ Theme::TextRenderAt (int16 which)
return text_renders[which];
}
bool
Theme::SetForeground (int16 which, const rgb_color color)
Theme::SetForeground (int which, const rgb_color color)
{
if (which >= fore_count || which < 0)
return false;
@ -217,8 +226,9 @@ Theme::SetForeground (int16 which, const rgb_color color)
return true;
}
bool
Theme::SetBackground (int16 which, const rgb_color color)
Theme::SetBackground (int which, const rgb_color color)
{
if (which >= back_count || which < 0)
return false;
@ -229,7 +239,7 @@ Theme::SetBackground (int16 which, const rgb_color color)
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;
}
void
Theme::AddView (BView* view)
{
list.AddItem (view);
}
void
Theme::RemoveView (BView* view)
{
list.RemoveItem (view);
}
void
Theme::SetTextMargin(float margin)
{
fTextMargin = margin;
}
void
Theme::SetSoftLineIndent(float indent)
{

View File

@ -42,9 +42,9 @@ class Theme
rgb_color* backs;
TextRender** text_renders; //FIX!!
int16 fore_count;
int16 back_count;
int16 render_count;
int fore_count;
int back_count;
int render_count;
BList list;
sem_id sid;
@ -55,22 +55,18 @@ class Theme
public:
static int16 TimestampFore;
static int16 TimestampBack;
static int16 TimestampFont;
static int16 TimespaceFore;
static int16 TimespaceBack;
static int16 TimespaceFont;
static int16 NormalFore;
static int16 NormalBack;
static int16 NormalFont;
static int16 SelectionBack;
static int TimestampFore;
static int TimestampBack;
static int TimestampFont;
static int TimespaceFore;
static int TimespaceBack;
static int TimespaceFont;
static int NormalFore;
static int NormalBack;
static int NormalFont;
static int SelectionBack;
Theme (
const char*,
int16,
int16,
int16);
Theme(const char*, int, int, int);
virtual ~Theme (void);
const char* Name (void) const {
@ -82,31 +78,31 @@ public:
void WriteLock (void);
void WriteUnlock (void);
int16 CountForegrounds (void) const;
int16 CountBackgrounds (void) const;
int CountForegrounds (void) const;
int CountBackgrounds (void) const;
// int16 CountFonts (void) const;
int16 CountTextRenders (void) const;
int CountTextRenders (void) const;
const rgb_color ForegroundAt (int16) const;
const rgb_color BackgroundAt (int16) const;
const rgb_color ForegroundAt (int) const;
const rgb_color BackgroundAt (int) const;
//const BFont &FontAt (int16) const;
TextRender* TextRenderAt(int16);
TextRender* TextRenderAt(int);
bool SetForeground (int16, const rgb_color);
bool SetForeground (int16 w, uchar r, uchar g, uchar b, uchar a = 255) {
bool SetForeground (int, const rgb_color);
bool SetForeground (int w, uchar r, uchar g, uchar b, uchar a = 255) {
rgb_color color = {r, g, b, a};
return SetForeground (w, color);
}
bool SetBackground (int16, const rgb_color);
bool SetBackground (int16 w, uchar r, uchar g, uchar b, uchar a = 255) {
bool SetBackground (int, const rgb_color);
bool SetBackground (int w, uchar r, uchar g, uchar b, uchar a = 255) {
rgb_color color = {r, g, b, a};
return SetBackground (w, color);
}
//bool SetFont (int16, const BFont &);
bool SetTextRender(int16, TextRender*);
bool SetTextRender(int, TextRender*);
void SetSoftLineIndent(float indent);
void SetTextMargin(float margin);