The MyPreferences Class
Declared in: myPreferences.h
Library: libBeGUI.so
The MyPreferences Class controls the entire preference regime. It allows each window to recall it's place; remembers the current font and it's family, style and attributes; recalls all the preferences for things like if you want to use color wells and or color controls, or anti-alias the font; and keeps track of all the gadgets' colors. Most of it's members are private, accessed through GetXXX() and SetXXX() functions.
This function uses the Preferences class and PreferenceSet class from libPrefs (see preferences.h), once again, Thanks Jon!
MyPreferences();
This is the constructor. The very first thing constructed in the application is the BApplication, next is the MyPreferences, and finally the MyApp class. Thus, the first thing constructed in which we have any coding control is the first line of this method:
FillGlobalsFromResources();
This call simply sets all global strings to NULL, then, using the BApplication's BResource class method FindString(), fills in all the strings used by the program. This allows the program to be language localized more easily. Currently, all the strings for the Preference stuff are jumbled in with all the application specific strings. At some time I will pull them all out and make a separate resource for Preference strings.
Next, an instance of the Preference class from libPrefs (see preferences.h) is created on the stack, then an instance of the PreferenceSet class. Both are InitCheck()ed, and if that is successful, the application goes on to fill the preference values from disk. The entire code is in myPreferences.cpp and is just a lot of calls to PreferenceSet::GetData(), with default values in case the preferred values do not exist.
~MyPreferences();
This is the destructor. Once again an instance of the Preference class from libPrefs (see preferences.h) is created on the stack, then an instance of the PreferenceSet class. Both are InitCheck()ed, and if that is successful, the application goes on to Make a lot of PreferenceSet::SetData() calls, each of which is verified before any further actions are taken. Finally,
EmptyGlobalsFromResources();
is called which frees all the resource strings allocated in the constructor's call to
FillGlobalsFromResources();
At some time it might be appropriate to change these calls and use BApplication's BResource class method LoadString(), but I had problems with it and the documentation is not yet released, so I am sticking with a tried and true method! :)
void OpenPreferencesPanel(void);
This is the call which the application makes to open the preference panel window. It is fairly smart, opening the panel if closed, activating it and bringing it forward if hidden behind other windows, and unhiding it if it gets hidden.
BFont * GetPreferredFont(void) const;
void SetPreferredFont(const BFont * paramFont);
void SetToPreferredFont(BFont * paramFont);
void SetPreferredFontFromData(FontData * paramFontData);
These are probably the most used class functions, they get and set the application's most widely used (default) font. The last method employs Dianne Hackborn's FontData class (see fontData.cpp).
void GetPreferredBasicColorWindowRect(BRect * paramWindowRect) const;
void GetPreferredFontDisplayWindowRect(BRect * paramWindowRect) const;
void GetPreferredFontPrefWindowRect(BRect * paramWindowRect) const;
void GetPreferredUInt32ReqWindowRect(BRect * paramWindowRect) const;
void GetPreferredListViewWindowRect(BRect * paramWindowRect) const;
void GetPreferredPreferencesWindowRect(BRect * paramWindowRect) const;
void GetPreferredPrefPanelWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorButtonWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorCheckBoxWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorColorControlWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorColorWellWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorFloatControlWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorListViewWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorPictureButtonWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorRadioButtonWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorStatusBarWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorStringDrawerWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorStringGadgetWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorTextViewWindowRect(BRect * paramWindowRect) const;
void GetPreferredSpecificColorUInt32ControlWindowRect(BRect * paramWindowRect) const;
void SetPreferredBasicColorWindowRect(const BRect paramWindowRect);
void SetPreferredFontDisplayWindowRect(const BRect paramWindowRect);
void SetPreferredFontPrefWindowRect(const BRect paramWindowRect);
void SetPreferredUInt32ReqWindowRect(const BRect paramWindowRect);
void SetPreferredListViewWindowRect(const BRect paramWindowRect);
void SetPreferredPreferencesWindowRect(const BRect paramWindowRect);
void SetPreferredPrefPanelWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorButtonWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorCheckBoxWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorColorControlWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorColorWellWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorFloatControlWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorListViewWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorPictureButtonWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorRadioButtonWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorStatusBarWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorStringDrawerWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorStringGadgetWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorTextViewWindowRect(const BRect paramWindowRect);
void SetPreferredSpecificColorUInt32ControlWindowRect(const BRect paramWindowRect);
These are used to get and set the various preferred window positions for the preference panels. They are only methods of accessing private data. C++ seems to stress this--I find it a bit tedious and do not always follow this procedure. :(
void GetPreferredColorWellHighColor(rgb_color * paramRGBColor) const;
void GetPreferredColorWellLowColor(rgb_color * paramRGBColor) const;
void GetPreferredColorWellViewColor(rgb_color * paramRGBColor) const;
void GetPreferredFloatControlHighColor(rgb_color * paramRGBColor) const;
void GetPreferredFloatControlLowColor(rgb_color * paramRGBColor) const;
void GetPreferredFloatControlViewColor(rgb_color * paramRGBColor) const;
void GetPreferredHighColor(rgb_color * paramRGBColor) const;
void GetPreferredLowColor(rgb_color * paramRGBColor) const;
void GetPreferredMyBarColor(rgb_color * paramRGBColor) const;
void GetPreferredMyButtonHighColor(rgb_color * paramRGBColor) const;
void GetPreferredMyButtonLowColor(rgb_color * paramRGBColor) const;
void GetPreferredMyButtonViewColor(rgb_color * paramRGBColor) const;
void GetPreferredMyCheckBoxHighColor(rgb_color * paramRGBColor) const;
void GetPreferredMyCheckBoxLowColor(rgb_color * paramRGBColor) const;
void GetPreferredMyCheckBoxViewColor(rgb_color * paramRGBColor) const;
void GetPreferredMyColorControlHighColor(rgb_color * paramRGBColor) const;
void GetPreferredMyColorControlLowColor(rgb_color * paramRGBColor) const;
void GetPreferredMyColorControlViewColor(rgb_color * paramRGBColor) const;
void GetPreferredMyListViewHighColor(rgb_color * paramRGBColor) const;
void GetPreferredMyListViewLowColor(rgb_color * paramRGBColor) const;
void GetPreferredMyListViewViewColor(rgb_color * paramRGBColor) const;
void GetPreferredMyPictureButtonHighColor(rgb_color * paramRGBColor) const;
void GetPreferredMyPictureButtonLowColor(rgb_color * paramRGBColor) const;
void GetPreferredMyPictureButtonViewColor(rgb_color * paramRGBColor) const;
void GetPreferredMyRadioViewHighColor(rgb_color * paramRGBColor) const;
void GetPreferredMyRadioViewLowColor(rgb_color * paramRGBColor) const;
void GetPreferredMyRadioViewViewColor(rgb_color * paramRGBColor) const;
void GetPreferredMyStatusBarHighColor(rgb_color * paramRGBColor) const;
void GetPreferredMyStatusBarLowColor(rgb_color * paramRGBColor) const;
void GetPreferredMyStatusBarViewColor(rgb_color * paramRGBColor) const;
void GetPreferredMyStringDrawerHighColor(rgb_color * paramRGBColor) const;
void GetPreferredMyStringDrawerLowColor(rgb_color * paramRGBColor) const;
void GetPreferredMyStringDrawerViewColor(rgb_color * paramRGBColor) const;
void GetPreferredMyTextViewHighColor(rgb_color * paramRGBColor) const;
void GetPreferredMyTextViewLowColor(rgb_color * paramRGBColor) const;
void GetPreferredMyTextViewViewColor(rgb_color * paramRGBColor) const;
void GetPreferredStringGadgetHighColor(rgb_color * paramRGBColor) const;
void GetPreferredStringGadgetLowColor(rgb_color * paramRGBColor) const;
void GetPreferredStringGadgetViewColor(rgb_color * paramRGBColor) const;
void GetPreferredUInt32ControlHighColor(rgb_color * paramRGBColor) const;
void GetPreferredUInt32ControlLowColor(rgb_color * paramRGBColor) const;
void GetPreferredUInt32ControlViewColor(rgb_color * paramRGBColor) const;
void GetPreferredViewColor(rgb_color * paramRGBColor) const;
void SetPreferredColorWellHighColor(const rgb_color * paramRGBColor);
void SetPreferredColorWellLowColor(const rgb_color * paramRGBColor);
void SetPreferredColorWellViewColor(const rgb_color * paramRGBColor);
void SetPreferredFloatControlHighColor(const rgb_color * paramRGBColor);
void SetPreferredFloatControlLowColor(const rgb_color * paramRGBColor);
void SetPreferredFloatControlViewColor(const rgb_color * paramRGBColor);
void SetPreferredHighColor(const rgb_color * paramRGBColor);
void SetPreferredLowColor(const rgb_color * paramRGBColor);
void SetPreferredMyBarColor(const rgb_color * paramRGBColor);
void SetPreferredMyButtonHighColor(const rgb_color * paramRGBColor);
void SetPreferredMyButtonLowColor(const rgb_color * paramRGBColor);
void SetPreferredMyButtonViewColor(const rgb_color * paramRGBColor);
void SetPreferredMyCheckBoxHighColor(const rgb_color * paramRGBColor);
void SetPreferredMyCheckBoxLowColor(const rgb_color * paramRGBColor);
void SetPreferredMyCheckBoxViewColor(const rgb_color * paramRGBColor);
void SetPreferredMyColorControlHighColor(const rgb_color * paramRGBColor);
void SetPreferredMyColorControlLowColor(const rgb_color * paramRGBColor);
void SetPreferredMyColorControlViewColor(const rgb_color * paramRGBColor);
void SetPreferredMyListViewHighColor(const rgb_color * paramRGBColor);
void SetPreferredMyListViewLowColor(const rgb_color * paramRGBColor);
void SetPreferredMyListViewViewColor(const rgb_color * paramRGBColor);
void SetPreferredMyPictureButtonHighColor(const rgb_color * paramRGBColor);
void SetPreferredMyPictureButtonLowColor(const rgb_color * paramRGBColor);
void SetPreferredMyPictureButtonViewColor(const rgb_color * paramRGBColor);
void SetPreferredMyRadioViewHighColor(const rgb_color * paramRGBColor);
void SetPreferredMyRadioViewLowColor(const rgb_color * paramRGBColor);
void SetPreferredMyRadioViewViewColor(const rgb_color * paramRGBColor);
void SetPreferredMyStatusBarHighColor(const rgb_color * paramRGBColor);
void SetPreferredMyStatusBarLowColor(const rgb_color * paramRGBColor);
void SetPreferredMyStatusBarViewColor(const rgb_color * paramRGBColor);
void SetPreferredMyStringDrawerHighColor(const rgb_color * paramRGBColor);
void SetPreferredMyStringDrawerLowColor(const rgb_color * paramRGBColor);
void SetPreferredMyStringDrawerViewColor(const rgb_color * paramRGBColor);
void SetPreferredMyTextViewHighColor(const rgb_color * paramRGBColor);
void SetPreferredMyTextViewLowColor(const rgb_color * paramRGBColor);
void SetPreferredMyTextViewViewColor(const rgb_color * paramRGBColor);
void SetPreferredStringGadgetHighColor(const rgb_color * paramRGBColor);
void SetPreferredStringGadgetLowColor(const rgb_color * paramRGBColor);
void SetPreferredStringGadgetViewColor(const rgb_color * paramRGBColor);
void SetPreferredUInt32ControlHighColor(const rgb_color * paramRGBColor);
void SetPreferredUInt32ControlLowColor(const rgb_color * paramRGBColor);
void SetPreferredUInt32ControlViewColor(const rgb_color * paramRGBColor);
void SetPreferredViewColor(const rgb_color * paramRGBColor);
These calls manipulate the private color values stored for the various Gadgets. The six functions that have no specific gadget name related to them set the underlying view's colors (View, High, and Low) for all application windows. They are only methods of accessing private data.
The BeGUI
Book
for version 1.4.2
Copyright © 1998-1999 Ed Musgrove Be Developer #2076. All rights reserved.
edgar@harbornet.com
emusgrov@linknet.kitsap.lib.wa.us
Last modified March 17, 1999.