/* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is Vision. * * The Initial Developer of the Original Code is The Vision Team. * Portions created by The Vision Team are * Copyright (C) 1999, 2000, 2001 The Vision Team. All Rights * Reserved. * * Contributor(s): Rene Gollent * Todd Lair * Andrea Anzani, andrea.anzani@gmail.com */ #define NUMBER_THEME_READERS 1000 #include #include #include #include #include //fix #include #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; //at least we use a 'normal' text render Theme::Theme ( const char *n, int16 foreCount, int16 backCount, int16 renderCount) : name (NULL), fores (NULL), backs (NULL), text_renders (NULL), fore_count (max_c (foreCount, 4)), back_count (max_c (backCount, 4)), render_count (max_c (renderCount, 4)) { fSoftLineIndent = (float)(MARGIN_WIDTH / 2.0); fTextMargin = (float)(MARGIN_WIDTH / 2.0); name = strcpy (new char [strlen (n) + 1], n); fores = new rgb_color [fore_count]; backs = new rgb_color [back_count]; normal_textrender = new NormalTextRender(be_plain_font); text_renders = (TextRender**)malloc(render_count*sizeof(TextRender*)); for ( int i=0; i= fore_count || which < 0) return color; return fores[which]; } const rgb_color Theme::BackgroundAt (int16 which) const { rgb_color color = {255, 255, 255, 255}; if (which >= back_count || which < 0) return color; return backs[which]; } /* const BFont & Theme::FontAt (int16 which) const { if (which >= font_count || which < 0) return *be_plain_font; return fonts[which]; } */ TextRender* Theme::TextRenderAt (int16 which) { if ( which < 0 ){ //printf("Theme::TextRenderAt(): which < 0 (%d)\n", which); return normal_textrender; } if ( which >= render_count ){ //printf("Theme::TextRenderAt(): which >= render_count (%d, %d)\n", which, render_count); return normal_textrender; } return text_renders[which]; } bool Theme::SetForeground (int16 which, const rgb_color color) { if (which >= fore_count || which < 0) return false; fores[which] = color; return true; } bool Theme::SetBackground (int16 which, const rgb_color color) { if (which >= back_count || which < 0) return false; backs[which] = color; return true; } bool Theme::SetTextRender(int16 which,TextRender *trender) { if (which >= render_count || which < 0 || !trender) return false; text_renders[which] = 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) { fSoftLineIndent = indent; }