[Igarden-commit] Garden/source/Preferences FontPrefsPanel.cpp, NONE, 1.1 FontPrefsPanel.h, NONE, 1.
Status: Beta
Brought to you by:
jlbedell
|
From: Jeffrey B. <jlb...@us...> - 2008-04-02 22:27:14
|
Update of /cvsroot/igarden/Garden/source/Preferences In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv8721/Garden/source/Preferences Added Files: FontPrefsPanel.cpp FontPrefsPanel.h Log Message: Initial checkin on mainline --- NEW FILE: FontPrefsPanel.cpp --- //*********************************************************************************************** // // 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 iGarden PrintingPrefsPanel. // // The Initial Developer of the Original Code is Redstart Software. // Portions created by Initial Developer are Copyright (C) 2008 Redstart Software. All Rights Reserved. // // Contributor(s): // Jeffrey Bedell(je...@re...) // #include "RedstartGarden.h" #include "FontPrefsPanel.h" #include <XGPopControl.h> #include "Preferences.h" #include "RGPanelSet.h" #include "carbon.h" #include "resources.h" using namespace yaaf; const short item_ListFontName = 1; const short item_ListFontSize = 2; const short item_ListFontTitle = 3; // --------------------------------------------------------------------------- /// FontPrefsPanel // FontPrefsPanel::FontPrefsPanel( PersistentTags* prefs ) : PreferencesPanel(prefs) { } // --------------------------------------------------------------------------- /// ~FontPrefsPanel // FontPrefsPanel::~FontPrefsPanel() { } // --------------------------------------------------------------------------- /// SetupControls // void FontPrefsPanel::SetupControls( XGView* panelView, XGDialog* /*dialog*/ ) { char fontName[256]; Str255 fontPName; Int32 i; XGPopControl *nameGad, *sizeGad; if(!_prefs->GetStrPref(kListFontPref, sizeof(_fontFamily), _fontFamily)) strcpy(_fontFamily, defaultListFontName); if(!_prefs->GetInt32Pref(kListFontSizePref, _fontSize)) _fontSize = defaultListFontSize; if(_fontSize == 0) _fontSize = defaultListFontSize; sprintf(fontName, "%s %ld", _fontFamily, _fontSize); nameGad = dynamic_cast<XGPopControl*>(panelView->FindViewByID(item_ListFontName)); AssertValidView(nameGad); #if OPT_MACOS short count; MenuHandle fontHdl = ::MacGetMenu(kFontTemplateMenuID); ::AppendResMenu(fontHdl, 'FONT'); count = ::CountMenuItems(fontHdl); for(i = 0; i < count; i++) { ::GetMenuItemText(fontHdl, i+1, fontPName); yaaf::cvtp2c(fontPName); nameGad->Append(reinterpret_cast<char*>(fontPName)); if(strcmp(_fontFamily, reinterpret_cast<char*>(fontPName)) == 0) { nameGad->SetValue(i); } } sizeGad = dynamic_cast<XGPopControl*>(panelView->FindViewByID(item_ListFontSize)); AssertValidView(sizeGad); sizeGad->Append("9"); sizeGad->Append("10"); sizeGad->Append("11"); sizeGad->Append("12"); sizeGad->Append("14"); if(_fontSize == 9) sizeGad->SetValue(0); else if(_fontSize == 10) sizeGad->SetValue(1); else if(_fontSize == 11) sizeGad->SetValue(2); else if(_fontSize == 12) sizeGad->SetValue(3); else if(_fontSize == 14) sizeGad->SetValue(4); #endif } // --------------------------------------------------------------------------- /// GetPanelName // const char* FontPrefsPanel::GetPanelName() { return stx("Fonts"); } // --------------------------------------------------------------------------- /// GetPanelResourceID // int FontPrefsPanel::GetPanelResourceID() { return 197; } // --------------------------------------------------------------------------- /// HandleControlClick // long FontPrefsPanel::HandlePopValue( XGDialog* dialog, XGView* panelView, long arg, long menuItem ) { PanelSet *set; XGView *current; XGPopControl *nameGad; set = dynamic_cast<PanelSet*>(dialog->FindViewByID(32003)); AssertValidView(set); current = set->GetCurrentPanel(); nameGad = dynamic_cast<XGPopControl*>(panelView->FindViewByID(item_ListFontName)); AssertValidView(nameGad); switch(arg) { case item_ListFontName: nameGad->GetItem(menuItem, _fontFamily); _prefs->SetStrPref(kListFontPref, _fontFamily); return 0; break; case item_ListFontSize: if(menuItem == 0) _fontSize = 9; else if(menuItem == 1) _fontSize = 10; else if(menuItem == 2) _fontSize = 11; else if(menuItem == 3) _fontSize = 12; else _fontSize = 14; _prefs->SetInt32Pref(kListFontSizePref, _fontSize); return 0; break; } return -1; } // --------------------------------------------------------------------------- /// ActivatePanel // void FontPrefsPanel::ActivatePanel( XGDialog* /*dialog*/, XGView* panelView ) { } // --------------------------------------------------------------------------- // void PrintingPrefsPanel::DeactivatePanel( XGDialog* dialog, XGView* panelView ) // --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- /// DeactivatePanel // void FontPrefsPanel::DeactivatePanel( XGDialog* /*dialog*/, XGView* /*panelView*/ ) { } --- NEW FILE: FontPrefsPanel.h --- //*********************************************************************************************** // // 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 iGarden Pringing Prefs Panel. // // The Initial Developer of the Original Code is Redstart Software. // Portions created by Initial Developer are Copyright (C) 2004 Redstart Software. All Rights Reserved. // // Contributor(s): // Jeffrey Bedell(je...@re...) // #ifndef __FontPrefsPanel #define __FontPrefsPanel #include "PreferencesPanel.h" class FontPrefsPanel : public PreferencesPanel { public: // methods FontPrefsPanel(PersistentTags* prefs); virtual ~FontPrefsPanel(); virtual void SetupControls(XGView* panelView, XGDialog* dialog); virtual const char* GetPanelName(); virtual int GetPanelResourceID(); virtual long HandlePopValue( XGDialog* /*dialog*/, XGView* /*panelView*/, long arg, long menuItem ); virtual void ActivatePanel(XGDialog* dialog, XGView* panelView); virtual void DeactivatePanel(XGDialog* dialog, XGView* panelView); protected: private: char _fontFamily[256]; long _fontSize; }; #endif |