Style.
Add NULL guard to the color schemes struct, although the code was safe neverthless (for now) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37575 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5b3d789879
commit
7071dfc1d1
@ -95,12 +95,12 @@ AppearancePrefView::AppearancePrefView(const char* name,
|
|||||||
fFont = new BMenuField(B_TRANSLATE("Font:"), fontMenu);
|
fFont = new BMenuField(B_TRANSLATE("Font:"), fontMenu);
|
||||||
fFontSize = new BMenuField(B_TRANSLATE("Size:"), sizeMenu);
|
fFontSize = new BMenuField(B_TRANSLATE("Size:"), sizeMenu);
|
||||||
|
|
||||||
BPopUpMenu *schemasPopUp =_MakeColorSchemaMenu(MSG_COLOR_SCHEMA_CHANGED, gPredefinedSchemas,
|
BPopUpMenu* schemasPopUp =_MakeColorSchemaMenu(MSG_COLOR_SCHEMA_CHANGED, gPredefinedSchemas,
|
||||||
gPredefinedSchemas[0]);
|
gPredefinedSchemas[0]);
|
||||||
fColorSchemaField = new BMenuField(B_TRANSLATE("Color schema:"),
|
fColorSchemaField = new BMenuField(B_TRANSLATE("Color schema:"),
|
||||||
schemasPopUp);
|
schemasPopUp);
|
||||||
|
|
||||||
BPopUpMenu *colorsPopUp =_MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable,
|
BPopUpMenu* colorsPopUp =_MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable,
|
||||||
kColorTable[0]);
|
kColorTable[0]);
|
||||||
|
|
||||||
fColorField = new BMenuField(B_TRANSLATE("Color:"),
|
fColorField = new BMenuField(B_TRANSLATE("Color:"),
|
||||||
@ -242,14 +242,17 @@ AppearancePrefView::MessageReceived(BMessage* msg)
|
|||||||
|
|
||||||
case MSG_COLOR_SCHEMA_CHANGED:
|
case MSG_COLOR_SCHEMA_CHANGED:
|
||||||
{
|
{
|
||||||
color_schema *newSchema = NULL;
|
color_schema* newSchema = NULL;
|
||||||
msg->FindPointer("color_schema", (void**)&newSchema);
|
if (msg->FindPointer("color_schema",
|
||||||
if (newSchema == &gCustomSchema)
|
(void**)&newSchema) == B_OK) {
|
||||||
_EnableCustomColors(true);
|
|
||||||
else
|
if (newSchema == &gCustomSchema)
|
||||||
_EnableCustomColors(false);
|
_EnableCustomColors(true);
|
||||||
_ChangeColorSchema(newSchema);
|
else
|
||||||
modified = true;
|
_EnableCustomColors(false);
|
||||||
|
_ChangeColorSchema(newSchema);
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +286,7 @@ AppearancePrefView::_EnableCustomColors(bool enable)
|
|||||||
void
|
void
|
||||||
AppearancePrefView::_ChangeColorSchema(color_schema* schema)
|
AppearancePrefView::_ChangeColorSchema(color_schema* schema)
|
||||||
{
|
{
|
||||||
PrefHandler *pref = PrefHandler::Default();
|
PrefHandler* pref = PrefHandler::Default();
|
||||||
|
|
||||||
pref->setRGB(PREF_TEXT_FORE_COLOR, schema->text_fore_color);
|
pref->setRGB(PREF_TEXT_FORE_COLOR, schema->text_fore_color);
|
||||||
pref->setRGB(PREF_TEXT_BACK_COLOR, schema->text_back_color);
|
pref->setRGB(PREF_TEXT_BACK_COLOR, schema->text_back_color);
|
||||||
@ -295,9 +298,9 @@ AppearancePrefView::_ChangeColorSchema(color_schema* schema)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AppearancePrefView::_SetCurrentColorSchema(BMenuField *field)
|
AppearancePrefView::_SetCurrentColorSchema(BMenuField* field)
|
||||||
{
|
{
|
||||||
PrefHandler *pref = PrefHandler::Default();
|
PrefHandler* pref = PrefHandler::Default();
|
||||||
|
|
||||||
gCustomSchema.text_fore_color = pref->getRGB(PREF_TEXT_FORE_COLOR);
|
gCustomSchema.text_fore_color = pref->getRGB(PREF_TEXT_FORE_COLOR);
|
||||||
gCustomSchema.text_back_color = pref->getRGB(PREF_TEXT_BACK_COLOR);
|
gCustomSchema.text_back_color = pref->getRGB(PREF_TEXT_BACK_COLOR);
|
||||||
@ -306,9 +309,9 @@ AppearancePrefView::_SetCurrentColorSchema(BMenuField *field)
|
|||||||
gCustomSchema.select_fore_color = pref->getRGB(PREF_SELECT_FORE_COLOR);
|
gCustomSchema.select_fore_color = pref->getRGB(PREF_SELECT_FORE_COLOR);
|
||||||
gCustomSchema.select_back_color = pref->getRGB(PREF_SELECT_BACK_COLOR);
|
gCustomSchema.select_back_color = pref->getRGB(PREF_SELECT_BACK_COLOR);
|
||||||
|
|
||||||
const char *currentSchemaName = NULL;
|
const char* currentSchemaName = NULL;
|
||||||
|
|
||||||
color_schema **schemas = const_cast<color_schema**>(gPredefinedSchemas);
|
color_schema** schemas = const_cast<color_schema**>(gPredefinedSchemas);
|
||||||
while (*schemas) {
|
while (*schemas) {
|
||||||
if (gCustomSchema == **schemas) {
|
if (gCustomSchema == **schemas) {
|
||||||
currentSchemaName = (*schemas)->name;
|
currentSchemaName = (*schemas)->name;
|
||||||
@ -319,7 +322,7 @@ AppearancePrefView::_SetCurrentColorSchema(BMenuField *field)
|
|||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int32 i = 0; i < fColorSchemaField->Menu()->CountItems(); i++) {
|
for (int32 i = 0; i < fColorSchemaField->Menu()->CountItems(); i++) {
|
||||||
BMenuItem *item = fColorSchemaField->Menu()->ItemAt(i);
|
BMenuItem* item = fColorSchemaField->Menu()->ItemAt(i);
|
||||||
if (!strcmp(item->Label(), currentSchemaName)) {
|
if (!strcmp(item->Label(), currentSchemaName)) {
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -34,15 +34,16 @@ struct color_schema gCustomSchema = {
|
|||||||
"Custom"
|
"Custom"
|
||||||
};
|
};
|
||||||
|
|
||||||
const color_schema *gPredefinedSchemas[] = {
|
const color_schema* gPredefinedSchemas[] = {
|
||||||
&kBlackOnWhite,
|
&kBlackOnWhite,
|
||||||
&kWhiteOnBlack,
|
&kWhiteOnBlack,
|
||||||
&gCustomSchema,
|
&gCustomSchema,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
color_schema::operator==(const color_schema &schema)
|
color_schema::operator==(const color_schema& schema)
|
||||||
{
|
{
|
||||||
if (text_fore_color == schema.text_fore_color
|
if (text_fore_color == schema.text_fore_color
|
||||||
&& text_back_color == schema.text_back_color
|
&& text_back_color == schema.text_back_color
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
|
|
||||||
struct color_schema {
|
struct color_schema {
|
||||||
const char *name;
|
const char* name;
|
||||||
rgb_color text_fore_color;
|
rgb_color text_fore_color;
|
||||||
rgb_color text_back_color;
|
rgb_color text_back_color;
|
||||||
rgb_color cursor_fore_color;
|
rgb_color cursor_fore_color;
|
||||||
rgb_color cursor_back_color;
|
rgb_color cursor_back_color;
|
||||||
rgb_color select_fore_color;
|
rgb_color select_fore_color;
|
||||||
rgb_color select_back_color;
|
rgb_color select_back_color;
|
||||||
bool operator==(const color_schema &color);
|
bool operator==(const color_schema& color);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ extern const rgb_color kBlack;
|
|||||||
extern const rgb_color kWhite;
|
extern const rgb_color kWhite;
|
||||||
|
|
||||||
extern color_schema gCustomSchema;
|
extern color_schema gCustomSchema;
|
||||||
extern const color_schema *gPredefinedSchemas[];
|
extern const color_schema* gPredefinedSchemas[];
|
||||||
|
|
||||||
|
|
||||||
#endif // _COLORS_H
|
#endif // _COLORS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user