FreeburnPreferences.cpp
上传用户:cnxinhai
上传日期:2013-08-06
资源大小:265k
文件大小:18k
- /* This is the class definition for the Preferences Dialog.
- *
- * Copyright (C) 2001, 2002 Adam Schlag
- */
- /*
- * FreeBurn Software License
- * (based on the Apache Software License)
- *
- * Version 1.1
- *
- * Copyright (c) 2001, 2002 The FreeBurn Project. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * 3. The end-user documentation included with the redistribution, if any, must
- * include the following acknowledgment:
- *
- * "This product includes software developed by the FreeBurn
- * Project (http://freeburn.sourceforge.net/)."
- *
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "FreeBurn" and "FreeBurn Project" must not be
- * used to endorse or promote products derived from this software
- * without prior written permission. For written permission, please
- * contact aschlag@users.sourceforge.net.
- *
- * 5. Products derived from this software may not be called "FreeBurn",
- * nor may "FreeBurn" appear in their name, without prior written
- * permission of the FreeBurn Project.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE FREEBURN PROJECT OR ITS
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the FreeBurn Project. For more
- * information on the FreeBurn Project and FreeBurn, please see
- * <http://freeburn.sourceforge.net/>.
- *
- * This software is distributed with software that is released under the GNU
- * General Public License (GPL). You can find the terms of this license in the
- * file GPL.txt distributed in this package. You can find information on the
- * software distributed with this package in the file PROGRAMS.txt.
- */
- #include <fx.h>
- #include <FXPNGIcon.h>
- #include "FreeBurn.h"
- #include "FreeburnPreferences.h"
- #include "FreeburnDefs.h"
- #include "FreeburnPreferencesText.h"
- #ifndef FREEBURN_ICONS_H
- #include "FreeburnIcons.h"
- #define FREEBURN_ICONS_H
- #endif
- // Message Map for this class
- FXDEFMAP(CFreeburnPreferences) CFreeburnPreferencesMap[]={
- //________Message_Type_______________________ID______________________________Message_Handler___________
- // these handle messages to open a file dialog to find the paths to external programs
- FXMAPFUNC(SEL_COMMAND, CFreeburnPreferences::ID_FINDSHELL, CFreeburnPreferences::onFindShellPath),
- FXMAPFUNC(SEL_COMMAND, CFreeburnPreferences::ID_FINDCDRECORD, CFreeburnPreferences::onFindCdrecordPath),
- FXMAPFUNC(SEL_COMMAND, CFreeburnPreferences::ID_FINDMKISOFS, CFreeburnPreferences::onFindMkisofsPath),
- FXMAPFUNC(SEL_COMMAND, CFreeburnPreferences::ID_FINDCDRDAO, CFreeburnPreferences::onFindCdrdaoPath)
- };
- FXIMPLEMENT(CFreeburnPreferences,FXDialogBox,CFreeburnPreferencesMap,ARRAYNUMBER(CFreeburnPreferencesMap))
- // Construct help dialog box
- CFreeburnPreferences::CFreeburnPreferences(FXWindow *owner, FXint currentTheme):
- FXDialogBox(owner,fbPreferencesTitleText,DECOR_TITLE|DECOR_BORDER, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4)
- {
- // load the theme into the dialog
- m_CurrentTheme = currentTheme;
- // set up the main container for the dialog
- FXVerticalFrame* prefrencesFrame = new FXVerticalFrame(this, LAYOUT_SIDE_TOP|LAYOUT_FILL_X|LAYOUT_FILL_Y);
-
- // set up the content frame
- FXHorizontalFrame* contentFrame = new FXHorizontalFrame(prefrencesFrame, LAYOUT_FILL_X|LAYOUT_FILL_Y);
-
- // set up the switcher buttons frame
- FXVerticalFrame* prefButtonsFrame = new FXVerticalFrame(contentFrame,
- LAYOUT_LEFT|LAYOUT_FILL_Y|FRAME_SUNKEN|PACK_UNIFORM_WIDTH|PACK_UNIFORM_HEIGHT,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-
- // set up the preferences switcher
- FXSwitcher* prefSwitcher = new FXSwitcher(contentFrame, LAYOUT_FILL_X|LAYOUT_FILL_Y);
-
- // load the dialog icons
- m_ProgramsIcon = new FXPNGIcon(getApp(), preferences_programs_png);
- m_ThemesIcon = new FXPNGIcon(getApp(), preferences_theme_png);
- m_DefaultThemeIcon = new FXPNGIcon(getApp(), w_systemset_large_png);
- m_GNOMEThemeIcon = new FXPNGIcon(getApp(), g_systemset_large_png);
- m_KDEThemeIcon = new FXPNGIcon(getApp(), k_systemset_large_png);
- m_XPThemeIcon = new FXPNGIcon(getApp(), xp_systemset_large_png);
-
- // program preferences frame
- FXVerticalFrame* programPrefsFrame = new FXVerticalFrame(prefSwitcher, LAYOUT_FILL_X|LAYOUT_FILL_Y);
- new FXLabel(programPrefsFrame, fbPreferencesProgramTitleText, NULL, LAYOUT_LEFT);
- new FXHorizontalSeparator(programPrefsFrame, SEPARATOR_RIDGE|LAYOUT_FILL_X);
- FXMatrix* programPrefsMatrix = new FXMatrix(programPrefsFrame, 3,
- MATRIX_BY_COLUMNS|PACK_UNIFORM_HEIGHT|LAYOUT_FILL_X|LAYOUT_CENTER_Y);
-
- // fill first matrix row
- new FXLabel(programPrefsMatrix, fbPreferencesProgramShellText, NULL, LAYOUT_LEFT);
- m_shellField = new FXTextField(programPrefsMatrix, 40, this, ID_LAST,
- FRAME_SUNKEN|FRAME_THICK|LAYOUT_CENTER_Y|LAYOUT_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
- m_FindShellButton = new FXButton(programPrefsMatrix, fbPreferencesFindShellText, NULL, this,
- ID_FINDSHELL, BUTTON_NORMAL);
-
- // fill second matrix row
- new FXLabel(programPrefsMatrix, fbPreferencesProgramCdrecordText, NULL, LAYOUT_LEFT);
- m_cdrecordField = new FXTextField(programPrefsMatrix, 40, this, ID_LAST,
- FRAME_SUNKEN|FRAME_THICK|LAYOUT_CENTER_Y|LAYOUT_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
- m_FindCdrecordButton = new FXButton(programPrefsMatrix, fbPreferencesFindCdrecordText, NULL, this,
- ID_FINDCDRECORD, BUTTON_NORMAL);
-
- // fill third matrix row
- new FXLabel(programPrefsMatrix, fbPreferencesProgramMkisofsText, NULL, LAYOUT_LEFT);
- m_mkisofsField = new FXTextField(programPrefsMatrix, 40, this, ID_LAST,
- FRAME_SUNKEN|FRAME_THICK|LAYOUT_CENTER_Y|LAYOUT_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
- m_FindMkisofsButton = new FXButton(programPrefsMatrix, fbPreferencesFindMkisofsText, NULL, this,
- ID_FINDMKISOFS, BUTTON_NORMAL);
-
- // fill fourth matrix row
- new FXLabel(programPrefsMatrix, fbPreferencesProgramCdrdaoText, NULL, LAYOUT_LEFT);
- m_cdrdaoField = new FXTextField(programPrefsMatrix, 40, this, ID_LAST,
- FRAME_SUNKEN|FRAME_THICK|LAYOUT_CENTER_Y|LAYOUT_LEFT|LAYOUT_FILL_COLUMN|LAYOUT_FILL_ROW);
- m_FindCdrdaoButton = new FXButton(programPrefsMatrix, fbPreferencesFindCdrdaoText, NULL, this,
- ID_FINDCDRDAO, BUTTON_NORMAL);
-
- // set the button to call the program preferences frame to the top
- new FXButton(prefButtonsFrame, fbPreferencesProgramButtonText, m_ProgramsIcon, prefSwitcher,
- FXSwitcher::ID_OPEN_FIRST, FRAME_RAISED|ICON_ABOVE_TEXT|LAYOUT_FILL_Y);
-
- // theme preferences frame
-
- // theme preferences container
- FXVerticalFrame* themePrefsFrame = new FXVerticalFrame(prefSwitcher, LAYOUT_FILL_X|LAYOUT_FILL_Y);
- // the panel title
- new FXLabel(themePrefsFrame, fbPreferencesThemeTitleText, NULL, LAYOUT_LEFT);
- // a horizontal ridge
- new FXHorizontalSeparator(themePrefsFrame, SEPARATOR_RIDGE|LAYOUT_FILL_X);
- // horizontal frame to contain the icon theme stuff
- FXHorizontalFrame* iconThemeFrame = new FXHorizontalFrame(themePrefsFrame, LAYOUT_FILL_X);
- // vertical frame to contain the icon theme selection stuff
- FXVerticalFrame* iconSelectionFrame = new FXVerticalFrame(iconThemeFrame);
- // label identifying the icon selection list box
- new FXLabel(iconSelectionFrame, fbPreferencesThemeIconText, NULL, LAYOUT_LEFT);
- // the icon selection list box
- FXListBox* themeBox = new FXListBox(iconSelectionFrame, 4, owner, CFreeBurn::ID_ICONTHEME,
- FRAME_SUNKEN|FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, 0, 0, 175, 40);
- // adding the items to the list box for the four icon themes
- themeBox->appendItem(fbPreferencesThemeDefaultText, m_DefaultThemeIcon, NULL);
- themeBox->appendItem(fbPreferencesThemeGNOMEText, m_GNOMEThemeIcon, NULL);
- themeBox->appendItem(fbPreferencesThemeKDEText, m_KDEThemeIcon, NULL);
- themeBox->appendItem(fbPreferencesThemeXPText, m_XPThemeIcon, NULL);
- // a new vertical frame to contain the icon preview
- FXVerticalFrame* iconPreviewFrame = new FXVerticalFrame(iconThemeFrame, 0, 0, 0, 0, 0, 20);
- // label identifying the icon preview
- new FXLabel(iconPreviewFrame, fbPreferencesThemePreviewText, NULL, LAYOUT_LEFT);
- // label that will contain the icon for the current theme
- m_PreviewLabel = new FXLabel(iconPreviewFrame, NULL, NULL, LAYOUT_LEFT);
- // horizontal line serarating the icon and color theme sections
- new FXHorizontalSeparator(themePrefsFrame, SEPARATOR_LINE|LAYOUT_FILL_X);
- // label identifying the color theme section
- new FXLabel(themePrefsFrame, fbPreferencesThemeColorsText, NULL, LAYOUT_LEFT);
- // matrix to contain the color wells, thier labels, and default buttons
- FXMatrix* colorPrefsMatrix = new FXMatrix(themePrefsFrame, 6,
- MATRIX_BY_COLUMNS|PACK_UNIFORM_HEIGHT|LAYOUT_FILL_X);
- // label identifying the base color
- new FXLabel(colorPrefsMatrix, fbPreferencesThemeBaseColorText, NULL);
- // color well for setting the base color
- new FXColorWell(colorPrefsMatrix, FXRGB(0,0,0), owner, CFreeBurn::ID_BASECOLOR,
- COLORWELL_OPAQUEONLY|FRAME_SUNKEN|FRAME_THICK|LAYOUT_CENTER_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_FILL_COLUMN,
- 0,0,40,24);
- // button for setting the base color back to default
- new FXButton(colorPrefsMatrix, fbPreferencesThemeDefaultColorText, NULL, owner,
- CFreeBurn::ID_BASECOLOR_DEFAULT);
- // label identifying the back color
- new FXLabel(colorPrefsMatrix, fbPreferencesThemeBackColorText, NULL, LABEL_NORMAL, 0, 0, 0, 0, 20);
- // color well for setting the back color
- new FXColorWell(colorPrefsMatrix, FXRGB(0,0,0), owner, CFreeBurn::ID_BACKCOLOR,
- COLORWELL_OPAQUEONLY|FRAME_SUNKEN|FRAME_THICK|LAYOUT_CENTER_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_FILL_COLUMN,
- 0,0,40,24);
- // button for setting the background color back to default
- new FXButton(colorPrefsMatrix, fbPreferencesThemeDefaultColorText, NULL, owner,
- CFreeBurn::ID_BACKCOLOR_DEFAULT);
- // label identifying the border color
- new FXLabel(colorPrefsMatrix, fbPreferencesThemeBordColorText, NULL);
- // color well for setting the border color
- new FXColorWell(colorPrefsMatrix, FXRGB(0,0,0), owner, CFreeBurn::ID_BORDCOLOR,
- COLORWELL_OPAQUEONLY|FRAME_SUNKEN|FRAME_THICK|LAYOUT_CENTER_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_FILL_COLUMN,
- 0,0,40,24);
- // button for setting the border color back to default
- new FXButton(colorPrefsMatrix, fbPreferencesThemeDefaultColorText, NULL, owner,
- CFreeBurn::ID_BORDCOLOR_DEFAULT);
- // label identifying the foreground color
- new FXLabel(colorPrefsMatrix, fbPreferencesThemeForeColorText, NULL, LABEL_NORMAL, 0, 0, 0, 0, 20);
- // color well for setting the foreground color
- new FXColorWell(colorPrefsMatrix, FXRGB(0,0,0), owner, CFreeBurn::ID_FORECOLOR,
- COLORWELL_OPAQUEONLY|FRAME_SUNKEN|FRAME_THICK|LAYOUT_CENTER_Y|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_FILL_COLUMN,
- 0,0,40,24);
- // button for setting the foreground color back to default
- new FXButton(colorPrefsMatrix, fbPreferencesThemeDefaultColorText, NULL, owner,
- CFreeBurn::ID_FORECOLOR_DEFAULT);
-
- // set the button to call the theme preferences frame to the top
- new FXButton(prefButtonsFrame, fbPreferencesThemeButtonText, m_ThemesIcon, prefSwitcher,
- FXSwitcher::ID_OPEN_SECOND, FRAME_RAISED|ICON_ABOVE_TEXT|LAYOUT_FILL_Y);
- // set up the buttons for canceling or accepting changes
- new FXHorizontalSeparator(prefrencesFrame, SEPARATOR_GROOVE|LAYOUT_FILL_X);
- FXHorizontalFrame* buttonFrame = new FXHorizontalFrame(prefrencesFrame, LAYOUT_BOTTOM|LAYOUT_FILL_X|PACK_UNIFORM_WIDTH);
- new FXButton(buttonFrame, fbPreferencesAcceptButtonText, NULL, this, FXDialogBox::ID_ACCEPT,
- BUTTON_DEFAULT|LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK, 0, 0, 0, 0, 20, 20);
- new FXButton(buttonFrame, fbPreferencesCancelButtonText, NULL, this, FXDialogBox::ID_CANCEL,
- LAYOUT_RIGHT|FRAME_RAISED|FRAME_THICK, 0, 0, 0, 0, 20, 20);
- }
- // Clean up
- CFreeburnPreferences::~CFreeburnPreferences()
- {
- // delete the dialog icons
- delete m_ThemesIcon;
- delete m_ProgramsIcon;
- delete m_DefaultThemeIcon;
- delete m_GNOMEThemeIcon;
- delete m_KDEThemeIcon;
- delete m_XPThemeIcon;
- }
- // set the find icon
- void CFreeburnPreferences::setFindIcon(FXIcon* findIcon)
- {
- m_FindShellButton->setIcon(findIcon);
- m_FindCdrecordButton->setIcon(findIcon);
- m_FindMkisofsButton->setIcon(findIcon);
- m_FindCdrdaoButton->setIcon(findIcon);
- }
- FXint CFreeburnPreferences::getThemePrefs()
- {
- return m_CurrentTheme;
- }
- void CFreeburnPreferences::setThemePrefs(FXint theme)
- {
- m_CurrentTheme = theme;
- }
- FXLabel* CFreeburnPreferences::getPreviewLabel()
- {
- return m_PreviewLabel;
- }
- // method for opening a file dialog for setting the path to a UNIX shell program
- long CFreeburnPreferences::onFindShellPath(FXObject*, FXSelector, void*)
- {
- // Setup a file dialog for opening a file
- FXFileDialog openDialog(this, fbFindShellPathTitle);
- openDialog.setSelectMode(SELECTFILE_EXISTING);
- openDialog.setPatternList(fbFindShellPathPatterns);
-
- // If the dialog is not canceled, set the path to the file
- if(openDialog.execute())
- {
- m_shellField->setText(openDialog.getFilename());
- }
- return 1;
- }
- // method for opening a file dialog for setting the path to cdrecord.exe
- long CFreeburnPreferences::onFindCdrecordPath(FXObject*, FXSelector, void*)
- {
- // Setup a file dialog for opening a file
- FXFileDialog openDialog(this, fbFindCdrecordPathTitle);
- openDialog.setSelectMode(SELECTFILE_EXISTING);
- openDialog.setPatternList(fbFindCdrecordPathPatterns);
-
- // If the dialog is not canceled, set the path to the file
- if(openDialog.execute())
- {
- m_cdrecordField->setText(openDialog.getFilename());
- }
- return 1;
- }
- // method for opening a file dialog for setting the path to mkisofs.exe
- long CFreeburnPreferences::onFindMkisofsPath(FXObject*, FXSelector, void*)
- {
- // Setup a file dialog for opening a file
- FXFileDialog openDialog(this, fbFindMkisofsPathTitle);
- openDialog.setSelectMode(SELECTFILE_EXISTING);
- openDialog.setPatternList(fbFindMkisofsPathPatterns);
-
- // If the dialog is not canceled, set the path to the file
- if(openDialog.execute())
- {
- m_mkisofsField->setText(openDialog.getFilename());
- }
- return 1;
- }
- // set the shell string
- void CFreeburnPreferences::setShellString(FXString string)
- {
- m_shellField->setText(string);
- }
- // get the shell string
- FXString CFreeburnPreferences::getShellString()
- {
- return m_shellField->getText();
- }
- // set the cdrecord line string
- void CFreeburnPreferences::setCdrecordString(FXString string)
- {
- m_cdrecordField->setText(string);
- }
- // get the cdrecord line string
- FXString CFreeburnPreferences::getCdrecordString()
- {
- return m_cdrecordField->getText();
- }
- // set the mkisofs line string
- void CFreeburnPreferences::setMkisofsString(FXString string)
- {
- m_mkisofsField->setText(string);
- }
- // get the mkisofs line string
- FXString CFreeburnPreferences::getMkisofsString()
- {
- return m_mkisofsField->getText();
- }
- // set the cdrdao line string
- void CFreeburnPreferences::setCdrdaoString(FXString string)
- {
- m_cdrdaoField->setText(string);
- }
- // get the cdrdao line string
- FXString CFreeburnPreferences::getCdrdaoString()
- {
- return m_cdrdaoField->getText();
- }
- // method for opening a file dialog for setting the path to cdrdao.exe
- long CFreeburnPreferences::onFindCdrdaoPath(FXObject*, FXSelector, void*)
- {
- // Setup a file dialog for opening a file
- FXFileDialog openDialog(this, fbFindCdrdaoPathTitle);
- openDialog.setSelectMode(SELECTFILE_EXISTING);
- openDialog.setPatternList(fbFindCdrdaoPathPatterns);
-
- // If the dialog is not canceled, set the path to the file
- if(openDialog.execute())
- {
- m_cdrdaoField->setText(openDialog.getFilename());
- }
- return 1;
- }