diff --git a/src/prefs/appearance/APRMain.cpp b/src/prefs/appearance/APRMain.cpp index 6dc63b0d87..90a809dda9 100644 --- a/src/prefs/appearance/APRMain.cpp +++ b/src/prefs/appearance/APRMain.cpp @@ -1,3 +1,30 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: APRMain.cpp +// Author: DarkWyrm +// Description: Main file for Appearance +// +// +//------------------------------------------------------------------------------ #include "APRMain.h" #include @@ -7,7 +34,7 @@ APRApplication::APRApplication() BRect rect; // This is just the size and location of the window when Show() is called - rect.Set(100,100,540,345); + rect.Set(100,100,610,345); aprwin=new APRWindow(rect); aprwin->Show(); } diff --git a/src/prefs/appearance/APRMain.h b/src/prefs/appearance/APRMain.h index 31d41eb2b2..004dbbeab0 100644 --- a/src/prefs/appearance/APRMain.h +++ b/src/prefs/appearance/APRMain.h @@ -1,3 +1,30 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: APRMain.h +// Author: DarkWyrm +// Description: Main header for Appearance +// +// +//------------------------------------------------------------------------------ #ifndef APR_WORLD_H #define APR_WORLD_H diff --git a/src/prefs/appearance/APRView.cpp b/src/prefs/appearance/APRView.cpp index 76b493aa00..ce7899ac7b 100644 --- a/src/prefs/appearance/APRView.cpp +++ b/src/prefs/appearance/APRView.cpp @@ -87,6 +87,7 @@ APRView::APRView(const BRect &frame, const char *name, int32 resize, int32 flags wellrect.right=colorwell->Frame().left - 20; colorset_label=new BStringView(wellrect,"colorset_label","Color Set: "); AddChild(colorset_label); + colorset_label->ResizeToPreferred(); colorset_name=new BString(""); @@ -568,6 +569,7 @@ void APRView::SetColorSetName(const char *name) colorset_name->SetTo(name); namestr+=name; colorset_label->SetText(namestr.String()); + colorset_label->ResizeToPreferred(); colorset_label->Invalidate(); } diff --git a/src/prefs/appearance/APRWindow.cpp b/src/prefs/appearance/APRWindow.cpp index 70a1247ad3..c2b5a9922d 100644 --- a/src/prefs/appearance/APRWindow.cpp +++ b/src/prefs/appearance/APRWindow.cpp @@ -1,3 +1,30 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: APRWindow.cpp +// Author: DarkWyrm +// Description: basic Window class for Appearance +// +// +//------------------------------------------------------------------------------ #include #include "APRWindow.h" #include "APRView.h" @@ -12,18 +39,20 @@ APRWindow::APRWindow(BRect frame) tabview=new BTabView(Bounds(),"TabView"); BTab *tab=NULL; - - colors=new APRView(Bounds(),"Colors",B_FOLLOW_ALL, B_WILL_DRAW); - tab=new BTab(colors); - tabview->AddTab(colors,tab); + + + // TODO: Swap Cursors and Colors tabs when we're done developing it + cursors=new CurView(Bounds(),"Cursors",B_FOLLOW_ALL, B_WILL_DRAW); + tab=new BTab(cursors); + tabview->AddTab(cursors,tab); decorators=new DecView(Bounds(),"Decorator",B_FOLLOW_ALL, B_WILL_DRAW); tab=new BTab(decorators); tabview->AddTab(decorators,tab); - cursors=new CurView(Bounds(),"Cursors",B_FOLLOW_ALL, B_WILL_DRAW); - tab=new BTab(cursors); - tabview->AddTab(cursors,tab); + colors=new APRView(Bounds(),"Colors",B_FOLLOW_ALL, B_WILL_DRAW); + tab=new BTab(colors); + tabview->AddTab(colors,tab); AddChild(tabview); decorators->SetColors(colors->settings); diff --git a/src/prefs/appearance/APRWindow.h b/src/prefs/appearance/APRWindow.h index 209a4f1a7c..8d61206da5 100644 --- a/src/prefs/appearance/APRWindow.h +++ b/src/prefs/appearance/APRWindow.h @@ -1,3 +1,30 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: APRWindow.h +// Author: DarkWyrm +// Description: basic Window class for Appearance +// +// +//------------------------------------------------------------------------------ #ifndef APR_WINDOW_H #define APR_WINDOW_H diff --git a/src/prefs/appearance/ColorWell.cpp b/src/prefs/appearance/ColorWell.cpp index 4fbfdf9c77..7b74deb8a3 100644 --- a/src/prefs/appearance/ColorWell.cpp +++ b/src/prefs/appearance/ColorWell.cpp @@ -1,3 +1,29 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: ColorWell.cpp +// Author: DarkWyrm +// Description: Color display class which accepts drops +// +//------------------------------------------------------------------------------ #include "ColorWell.h" ColorWell::ColorWell(BRect frame, BMessage *msg, bool is_rectangle=false) diff --git a/src/prefs/appearance/ColorWell.h b/src/prefs/appearance/ColorWell.h index 238c11a082..e9c83f09e9 100644 --- a/src/prefs/appearance/ColorWell.h +++ b/src/prefs/appearance/ColorWell.h @@ -1,3 +1,29 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: ColorWell.h +// Author: DarkWyrm +// Description: Color display class which accepts drops +// +//------------------------------------------------------------------------------ #ifndef COLORWELL_H_ #define COLORWELL_H_ diff --git a/src/prefs/appearance/ColorWhichItem.cpp b/src/prefs/appearance/ColorWhichItem.cpp index 94f9e87afc..0267797a23 100644 --- a/src/prefs/appearance/ColorWhichItem.cpp +++ b/src/prefs/appearance/ColorWhichItem.cpp @@ -1,3 +1,29 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: ColorWhichItem.cpp +// Author: DarkWyrm +// Description: ListItem class for managing color_which specifiers +// +//------------------------------------------------------------------------------ #include "ColorWhichItem.h" #include diff --git a/src/prefs/appearance/ColorWhichItem.h b/src/prefs/appearance/ColorWhichItem.h index 7f2c14d7ea..a6ac8f9687 100644 --- a/src/prefs/appearance/ColorWhichItem.h +++ b/src/prefs/appearance/ColorWhichItem.h @@ -1,3 +1,29 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: ColorWhichItem.h +// Author: DarkWyrm +// Description: ListItem class for managing color_which specifiers +// +//------------------------------------------------------------------------------ #ifndef COLORWHICH_ITEM_H #define COLORWHICH_ITEM_H diff --git a/src/prefs/appearance/CurView.cpp b/src/prefs/appearance/CurView.cpp index 84f8e67fdd..9f6cb4eba9 100644 --- a/src/prefs/appearance/CurView.cpp +++ b/src/prefs/appearance/CurView.cpp @@ -36,6 +36,8 @@ #include #include "defs.h" #include "ServerConfig.h" +#include +#include #include //#define DEBUG_CURSORSET @@ -48,7 +50,10 @@ CurView::CurView(const BRect &frame, const char *name, int32 resize, int32 flags :BView(frame,name,resize,flags), settings(B_SIMPLE_DATA) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); - + + + cursorset=new CursorSet("Default"); + BMenuBar *mb=new BMenuBar(BRect(0,0,Bounds().Width(),16),"menubar"); settings_menu=new BMenu("Settings"); @@ -73,6 +78,7 @@ CurView::CurView(const BRect &frame, const char *name, int32 resize, int32 flags wellrect.right=wellrect.left+50; cursorset_label=new BStringView(wellrect,"cursorset_label","Cursor Set: "); AddChild(cursorset_label); + cursorset_label->ResizeToPreferred(); cursorset_name=""; @@ -122,6 +128,14 @@ CurView::CurView(const BRect &frame, const char *name, int32 resize, int32 flags AddChild(apply); apply->SetEnabled(false); + cvrect.Set(0,0,48,48); + BPoint pt; + pt.x=scrollview->Frame().right+(Bounds().right-scrollview->Frame().right-cvrect.Width())/2; + pt.y=mb->Frame().bottom+(apply->Frame().top-mb->Frame().bottom-cvrect.Height())/2; + + bmpview=new BitmapView(pt); + AddChild(bmpview); + BEntry entry(COLOR_SET_DIR); entry_ref ref; entry.GetRef(&ref); @@ -137,6 +151,7 @@ CurView::CurView(const BRect &frame, const char *name, int32 resize, int32 flags CurView::~CurView(void) { delete savepanel; + delete cursorset; } void CurView::AllAttached(void) @@ -338,14 +353,26 @@ printf("Loading cursor sets from disk\n"); } int32 count=dir.CountEntries(); - + + BMessage *msg; + CursorSet cs(NULL); + for(int32 i=0;iSetText(namestr.String()); - SetCursorSetName(internal_name.String()); - return; - } -#ifdef DEBUG_CURSORSET -printf("Error unflattening file %s\n",name.String()); -#endif -*/ -} - -void CurView::SaveCursorSet(const BString &name) -{ -/* - // Save the current cursor attributes as a flattened BMessage in the - // cursor set folder - BString path(COLOR_SET_DIR); - path+=name.String(); - -#ifdef DEBUG_CURSORSET -printf("SaveCursorSet: %s\n",path.String()); -#endif - - if(settings.ReplaceString("name",name.String())!=B_OK) - { -#ifdef DEBUG_CURSORSET -printf("SaveCursorSet: Couldn't replace set name in settings\n"); -#endif - } - - BFile file(path.String(),B_READ_WRITE|B_CREATE_FILE|B_ERASE_FILE); - - if(file.InitCheck()!=B_OK) - { -#ifdef DEBUG_CURSORSET -printf("SaveCursorSet: Couldn't open settings file for write\n"); -#endif - } - - if(settings.Flatten(&file)!=B_OK) - { -#ifdef DEBUG_CURSORSET -printf("SaveCursorSet: Couldn't flatten settings to file\n"); -#endif - return; - } - - BMessage *msg=new BMessage(LOAD_CURSORSET); - msg->AddString("name",name.String()); - - if(cursorset_menu->AddItem(new BMenuItem(name.String(),msg))==false) - { -#ifdef DEBUG_CURSORSET -printf("SaveCursorSet: Error in adding item to menu\n"); -#endif - } - SetCursorSetName(name.String()); -*/ -} - void CurView::SetCursorSetName(const char *name) { if(!name) @@ -461,6 +391,7 @@ void CurView::SetCursorSetName(const char *name) cursorset_name=name; namestr+=name; cursorset_label->SetText(namestr.String()); + cursorset_label->ResizeToPreferred(); cursorset_label->Invalidate(); } @@ -474,17 +405,15 @@ void CurView::SaveSettings(void) #ifdef DEBUG_CURSORSET printf("SaveSettings: %s\n",path.String()); #endif - BFile file(path.String(),B_READ_WRITE|B_CREATE_FILE|B_ERASE_FILE); + cursorset->Save(path.String(),B_CREATE_FILE|B_ERASE_FILE); - settings.Flatten(&file); prev_set_name=cursorset_name; revert->SetEnabled(false); - revert->SetEnabled(false); } void CurView::LoadSettings(void) { -/* // Load the current GUI cursor settings from disk. This is done instead of + // Load the current GUI cursor settings from disk. This is done instead of // getting them from the server at this point for testing purposes. Comment // out the #define LOAD_SETTINGS_FROM_DISK line to use the server query code #ifdef DEBUG_CURSORSET @@ -502,10 +431,11 @@ printf("Cursor set folder not found. Creating %s\n",SERVER_SETTINGS_DIR); } BString path(SERVER_SETTINGS_DIR); - path+=COLOR_SETTINGS_NAME; - BFile file(path.String(),B_READ_ONLY); + path+=CURSOR_SETTINGS_NAME; + + status_t stat=cursorset->Load(path.String()); - if(file.InitCheck()!=B_OK) + if(stat!=B_OK) { #ifdef DEBUG_CURSORSET printf("Couldn't open file %s for read\n",path.String()); @@ -514,166 +444,58 @@ printf("Couldn't open file %s for read\n",path.String()); SaveSettings(); return; } - if(settings.Unflatten(&file)==B_OK) - { - settings.FindString("name",&cursorset_name); - SetCursorSetName(cursorset_name.String()); - prev_set_name=cursorset_name; - picker->SetValue(GetCursorFromMessage(&settings,attrstring.String())); -#ifdef DEBUG_CURSORSET -settings.PrintToStream(); -#endif - return; - } -#ifdef DEBUG_CURSORSET -printf("Error unflattening SystemCursors file %s\n",path.String()); -#endif - - // If we get this far, we have encountered an error, so reset the settings - // to the defaults - SetDefaults(); - SaveSettings(); -*/ + + settings.FindString("name",&cursorset_name); + SetCursorSetName(cursorset_name.String()); + prev_set_name=cursorset_name; + return; } void CurView::SetDefaults(void) { -/* -#ifdef DEBUG_CURSORSET -printf("Initializing cursor settings to defaults\n"); -#endif - settings.MakeEmpty(); - settings.AddString("name","Default"); - cursorset_name="Default"; + // The server will perform the necessary work to set defaults, so just ask it to do the + // work for us. It is a synchronous procedure, so we will notify the server and load the cursor + // set 'Default'. + BString string(CURSOR_SET_DIR); + string+="Default"; + + cursorset->Load(string.String()); - ColorWhichItem whichitem(B_PANEL_BACKGROUND_COLOR); - rgb_color col={216,216,216,255}; - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); + port_id port=find_port(SERVER_PORT_NAME); + if(port==B_NAME_NOT_FOUND) + return; + + PortLink link(port); + PortMessage pmsg; + + link.SetOpCode(AS_SET_SYSCURSOR_DEFAULTS); + link.FlushWithReply(&pmsg); - SetRGBColor(&col,0,0,0); - whichitem.SetAttribute((color_which)B_PANEL_TEXT_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,255,255,255); - whichitem.SetAttribute((color_which)B_DOCUMENT_BACKGROUND_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,0,0,0); - whichitem.SetAttribute((color_which)B_DOCUMENT_TEXT_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,245,245,245); - whichitem.SetAttribute((color_which)B_CONTROL_BACKGROUND_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,0,0,0); - whichitem.SetAttribute((color_which)B_CONTROL_TEXT_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,0,0,0); - whichitem.SetAttribute((color_which)B_CONTROL_BORDER_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,115,120,184); - whichitem.SetAttribute((color_which)B_CONTROL_HIGHLIGHT_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,170,50,184); - whichitem.SetAttribute((color_which)B_NAVIGATION_BASE_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,0,0,0); - whichitem.SetAttribute((color_which)B_NAVIGATION_PULSE_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,255,255,255); - whichitem.SetAttribute((color_which)B_SHINE_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,0,0,0); - whichitem.SetAttribute((color_which)B_SHADOW_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,0,0,0); - whichitem.SetAttribute((color_which)B_MENU_SELECTED_BORDER_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,255,255,0); - whichitem.SetAttribute((color_which)B_TOOLTIP_BACKGROUND_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,0,0,0); - whichitem.SetAttribute((color_which)B_TOOLTIP_TEXT_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,0,255,0); - whichitem.SetAttribute((color_which)B_SUCCESS_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,255,0,0); - whichitem.SetAttribute((color_which)B_FAILURE_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,51,102,160); - whichitem.SetAttribute((color_which)B_MENU_SELECTED_BACKGROUND_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - whichitem.SetAttribute(B_PANEL_BACKGROUND_COLOR); - SetRGBColor(&col,216,216,216); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,216,216,216,0); - whichitem.SetAttribute(B_MENU_BACKGROUND_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,0,0,0); - whichitem.SetAttribute(B_MENU_ITEM_TEXT_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,255,255,255); - whichitem.SetAttribute(B_MENU_SELECTED_ITEM_TEXT_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,255,203,0); - whichitem.SetAttribute(B_WINDOW_TAB_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,0,0,0); - whichitem.SetAttribute((color_which)B_WINDOW_TAB_TEXT_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,232,232,232); - whichitem.SetAttribute((color_which)B_INACTIVE_WINDOW_TAB_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - - SetRGBColor(&col,80,80,80); - whichitem.SetAttribute((color_which)B_INACTIVE_WINDOW_TAB_TEXT_COLOR); - settings.AddData(whichitem.Text(),(type_code)'RGBC',&col,sizeof(rgb_color)); - -// BString labelstr("Color Set: "); -// labelstr+=cursorset_name; -// cursorset_label->SetText(labelstr.String()); - SetCursorSetName("Default"); -*/ } -void CurView::NotifyServer(void) +BitmapView::BitmapView(const BPoint &pt) + : BView(BRect(0,0,48,48).OffsetToCopy(pt),"bitmapview",B_FOLLOW_NONE,B_WILL_DRAW) { + bitmap=NULL; + SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); } -rgb_color CurView::GetColorFromMessage(BMessage *msg, const char *name, int32 index=0) +BitmapView::~BitmapView(void) { -/* - // Simple function to do the dirty work of getting an rgb_color from - // a message - rgb_color *col,rcolor={0,0,0,0}; - ssize_t size; - - if(!msg || !name) - return rcolor; - - if(msg->FindData(name,(type_code)'RGBC',index,(const void**)&col,&size)==B_OK) - rcolor=*col; - return rcolor; -*/ + if(bitmap) + delete bitmap; } + +void BitmapView::SetBitmap(BBitmap *bmp) +{ + if(bitmap) + delete bitmap; + bitmap=bmp; +} + +void BitmapView::Draw(BRect r) +{ + if(bitmap) + DrawBitmap(bitmap); +} + diff --git a/src/prefs/appearance/CurView.h b/src/prefs/appearance/CurView.h index 91bcdb440c..69dea15c76 100644 --- a/src/prefs/appearance/CurView.h +++ b/src/prefs/appearance/CurView.h @@ -41,9 +41,22 @@ #include #include #include +#include +#include class APRWindow; +class BitmapView : public BView +{ +public: + BitmapView(const BPoint &pt); + ~BitmapView(void); + void SetBitmap(BBitmap *bmp); + void Draw(BRect r); +protected: + BBitmap *bitmap; +}; + class CurView : public BView { public: @@ -54,13 +67,9 @@ public: void SaveSettings(void); void LoadSettings(void); void SetDefaults(void); - void NotifyServer(void); - rgb_color GetColorFromMessage(BMessage *msg, const char *name, int32 index=0); protected: friend APRWindow; BMenu *LoadCursorSets(void); - void SaveCursorSet(const BString &name); - void LoadCursorSet(const BString &name); void SetCursorSetName(const char *name); BButton *apply,*revert,*defaults; @@ -74,6 +83,8 @@ protected: BFilePanel *savepanel; BString cursorset_name; BString prev_set_name; + CursorSet *cursorset; + BitmapView *bmpview; }; #endif diff --git a/src/prefs/appearance/CursorWhichItem.cpp b/src/prefs/appearance/CursorWhichItem.cpp index 82984bf653..856de3ee86 100644 --- a/src/prefs/appearance/CursorWhichItem.cpp +++ b/src/prefs/appearance/CursorWhichItem.cpp @@ -1,3 +1,29 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: CursorWhichItem.cpp +// Author: DarkWyrm +// Description: ListItem class for managing cursor_which specifiers +// +//------------------------------------------------------------------------------ #include "CursorWhichItem.h" #include diff --git a/src/prefs/appearance/CursorWhichItem.h b/src/prefs/appearance/CursorWhichItem.h index f9bc7ba52c..1a7aa65547 100644 --- a/src/prefs/appearance/CursorWhichItem.h +++ b/src/prefs/appearance/CursorWhichItem.h @@ -1,3 +1,29 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: CursorWhichItem.h +// Author: DarkWyrm +// Description: ListItem class for managing cursor_which specifiers +// +//------------------------------------------------------------------------------ #ifndef COLORWHICH_ITEM_H #define COLORWHICH_ITEM_H diff --git a/src/prefs/appearance/DecView.cpp b/src/prefs/appearance/DecView.cpp index 5ee3529012..6b3c96c342 100644 --- a/src/prefs/appearance/DecView.cpp +++ b/src/prefs/appearance/DecView.cpp @@ -51,8 +51,32 @@ DecView::DecView(BRect frame, const char *name, int32 resize, int32 flags) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + BRect cvrect(0,0,50,25); + + cvrect.OffsetTo(Bounds().right-60,10); + + apply=new BButton(cvrect,"ApplyButton","Apply", + new BMessage(APPLY_SETTINGS),B_FOLLOW_LEFT |B_FOLLOW_TOP, + B_WILL_DRAW | B_NAVIGABLE); + AddChild(apply); + + // set up app_server emulation + driver=new PreviewDriver(); + if(!driver->Initialize()) + printf("Uh-oh... Couldn't initialize graphics module for server emu!\n"); + else + { + preview=driver->View(); + AddChild(preview); + + BRect temp(driver->View()->Bounds()); + + preview->MoveTo(apply->Frame().left-temp.Width()-20,apply->Frame().top); + } + // Set up list of color attributes - declist=new BListView(BRect(10,10,110,110),"DecoratorList"); + cvrect.Set(10,10,preview->Frame().left-20-B_V_SCROLL_BAR_WIDTH, preview->Frame().bottom); + declist=new BListView(cvrect,"DecoratorList"); scrollview=new BScrollView("ScrollView",declist, B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true); @@ -61,28 +85,8 @@ DecView::DecView(BRect frame, const char *name, int32 resize, int32 flags) declist->SetSelectionMessage(new BMessage(DECORATOR_CHOSEN)); - BRect cvrect(0,0,50,25); - - cvrect.OffsetTo(Bounds().right-60, - scrollview->Frame().top); - - apply=new BButton(cvrect,"ApplyButton","Apply", - new BMessage(APPLY_SETTINGS),B_FOLLOW_LEFT |B_FOLLOW_TOP, - B_WILL_DRAW | B_NAVIGABLE); - AddChild(apply); - - // set up app_server emulation - - driver=new PreviewDriver(); - if(!driver->Initialize()) - printf("Uh-oh... Couldn't initialize graphics module for server emu!\n"); - else - { - preview=driver->View(); - AddChild(preview); - preview->MoveTo(scrollview->Frame().right+20,scrollview->Frame().top); - } + // Finish setup ldata.highcolor.SetColor(51,102,160); pat_solid_high=0xFFFFFFFFFFFFFFFFLL; driver->FillRect(preview_bounds,&ldata,(int8*)&pat_solid_high); diff --git a/src/prefs/appearance/Jamfile b/src/prefs/appearance/Jamfile index db32471fef..151bcfe804 100644 --- a/src/prefs/appearance/Jamfile +++ b/src/prefs/appearance/Jamfile @@ -10,7 +10,7 @@ Preference Appearance : CurView.cpp DecView.cpp PreviewDriver.cpp - SysCursorAPI.cpp +# SysCursorAPI.cpp ColorWell.cpp ColorWhichItem.cpp CursorWhichItem.cpp diff --git a/src/prefs/appearance/PreviewDriver.cpp b/src/prefs/appearance/PreviewDriver.cpp index 90fd159a06..ef802841bf 100644 --- a/src/prefs/appearance/PreviewDriver.cpp +++ b/src/prefs/appearance/PreviewDriver.cpp @@ -1,6 +1,33 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: PreviewDriver.cpp +// Author: DarkWyrm +// Description: Class to display decorators from regular BApplications +// +//------------------------------------------------------------------------------ + /* PreviewDriver: - Module based on proto6's ViewDriver for the purpose of Decorator previews. + Module based on app_server's ViewDriver for the purpose of Decorator previews. The concept is to have a view draw a bitmap, which is a "frame buffer" of sorts, utilize a second view to write to it. This cuts out diff --git a/src/prefs/appearance/PreviewDriver.h b/src/prefs/appearance/PreviewDriver.h index 2917d6afa2..565207f560 100644 --- a/src/prefs/appearance/PreviewDriver.h +++ b/src/prefs/appearance/PreviewDriver.h @@ -1,3 +1,29 @@ +//------------------------------------------------------------------------------ +// Copyright (c) 2001-2002, OpenBeOS +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// +// File Name: PreviewDriver.cpp +// Author: DarkWyrm +// Description: Class to display decorators from regular BApplications +// +//------------------------------------------------------------------------------ #ifndef _PREVIEWDRIVER_H_ #define _PREVIEWDRIVER_H_