/* * $Id: propertydata.h,v 1.8 2005/12/02 12:47:52 ozawa Exp $ * * Copyright 2003- ONGS Inc. All rights reserved. * * author: Masanori OZAWA (ozawa@ongs.co.jp) * version: $Revision: 1.8 $ * * 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. * * THIS SOFTWARE IS PROVIDED BY ONGS INC ``AS IS'' AND ANY EXPRESS 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 ONGS INC OR 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. * * The views and conclusions contained in the software and documentation are * those of the authors and should not be interpreted as representing official * policies, either expressed or implied, of the ONGS Inc. * */ #ifndef ___PROPERTYDATA_H #define ___PROPERTYDATA_H #include "gtkmm.h" #include "libxml/parser.h" #include "libxml/tree.h" #define DEFAULT_FONTNAME "Gothic 10" #define DEFAULT_WRAPMODE Gtk::WRAP_NONE; #define PTYPE_NICKNAME "Nickname" #define PTYPE_BG_COLOR "Background-Color" #define PTYPE_FG_COLOR "Foreground-Color" #define PTYPE_FONTNAME "FontName" #define PTYPE_WRAPMODE "WrapMode" #define PTYPE_PRINT_COMMAND "PrintCommand" #define PTYPE_ENABLE_NETWORK "EnableNetwork" #define PTYPE_BROADCAST_ADDR "BroadcastAddr" #define PTYPE_STICK_WND "StickWnd" #define PTYPE_TRAYICON "TrayIcon" #define PTYPE_HIDEMAINWND "HideMainWnd" #define MAX_NICKNAME_LEN 40 // 40文字(バイトではない) typedef std::list BroadcastList; extern Glib::ustring getPropertyFilePath(); class PropertyData { public: /** * コンストラクタ */ PropertyData(); /** * コピーコンストラクタ */ PropertyData(const PropertyData& data); /** * デストラクタ */ virtual ~PropertyData(); public: /** * ブロードキャストアドレスを追加します。 * * @param szAddr ブロードキャストアドレス */ void addBroadcastAddr(Glib::ustring szAddr); /** * ブロードキャストアドレスの一覧を空にします。 */ void clearBroadcastList(); /** * 背景色を取得します。 * * @return 背景色を戻します。 * 戻される背景色は参照アクセスのみ可能です。 * 変更は禁止です。 */ const GdkColor* getBackground() const; /** * ブロードキャストアドレスの一覧を取得します。 * * @return ブロードキャストアドレスの一覧 */ const BroadcastList& getBroadcastList() const; /** * フォント名を取得します。 * * @return フォント名を戻します。 */ Glib::ustring getFontName() const; /** * 前景色を取得します。 * * @return 前景色を戻します。 * 戻される前景色は参照アクセスのみ可能です。 * 変更は禁止です。 */ const GdkColor* getForeground() const; /** * ニックネームを取得します。 * * @return ニックネームを戻します。 */ Glib::ustring getNickName() const; /** * 印刷用のコマンドを取得します。 * * @return 印刷用のコマンドを戻します。 */ Glib::ustring getPrintCommand() const; /** * 折り返しモードを取得します。 * * @return 折り返しモード */ Gtk::WrapMode getWrapMode() const; /** * ネットワーク機能を利用するか調べます。 * * @return ネットワーク機能が有効な場合は true を戻します。 */ bool isEnableNetwork() const; /** * メインウィンドウを非表示にするか調べます。 * * @return メインウィンドウを非表示にする場合は true を戻します。 */ bool isHideMainWnd() const; /** * ウィンドウを張り付け状態にするか調べます。 * * @return 張り付け状態にする場合は true を戻します。 */ bool isStickWindow() const; /** * トレイアイコンを有効にするか調べます。 * * @return トレイアイコンを有効にする場合は true を戻します。 */ bool isTrayIcon() const; /** * ブロードキャストアドレスの一覧を設定します。 * * @param broadcastList ブロードキャストアドレスの一覧 */ void setBroadcastList(const BroadcastList& broadcastList); /** * 背景色を設定します。 * * @param pColor 背景色 */ void setBackground(const GdkColor* pColor); /** * ネットワーク機能を利用するか設定します。 * * @param bEnable ネットワーク機能を有効にする場合は true を指定します。 */ void setEnableNetwork(bool bEnable); /** * フォント名を設定します。 * * @param szFontName フォント名 */ void setFontName(Glib::ustring szFontName); /** * 前景色を設定します。 * * @param pColor 前景色 */ void setForeground(const GdkColor* pColor); /** * メインウィンドウを非表示にするか設定します。 * * @param bHideMainWnd メインウィンドウを非表示にする場合は true を指定します。 */ void setHideMainWnd(bool bHideMainWnd); /** * ニックネームを設定します。 * * @param szNickName ニックネーム */ void setNickName(const Glib::ustring szNickName); /** * 印刷用のコマンドを取得します。 * * @param szPrintCommand 印刷用のコマンド */ void setPrintCommand(const Glib::ustring szPrintCommand); /** * ウィンドウを張り付け状態にするか設定します。 * * @param bPaste 張り付け状態にする場合は true を指定します。 */ void setStickWindow(bool bPaste); /** * トレイアイコンを表示するか設定します。 * * @param bTrayIcon トレイアイコンを表示する場合は true を指定します。 */ void setTrayIcon(bool bTrayIcon); /** * 折り返しモードを設定します。 * * @param nWrapMode 折り返しモード */ void setWrapMode(Gtk::WrapMode nWrapMode); public: /** * 複写 */ PropertyData& operator=(const PropertyData& data); /** * 等価比較 */ bool operator==(const PropertyData& data) const; /** * 非等価比較 */ bool operator!=(const PropertyData& data) const; public: /** * プロパティを取得します。 * * @return プロパティ */ static const PropertyData& get(); /** * プロパティを設定/保存します。 * * @param property 新しいプロパティ * @param save ファイルに保存する場合は true を指定します。 */ static void set(const PropertyData& property, bool save = false); public: /** * シリアライズ化されたプロパティからプロパティオブジェクトを * 構築します。 * * @param pData シリアライズ後のバイト列 * @return プロパティオブジェクト。 * 不要になった段階で破棄する必要があります。 */ static PropertyData buildObject(const char* pData); /** * プロパティオブジェクトをシリアライズします。 * * @param property プロパティオブジェクト * @return シリアライズ後のバイト列。 * 不要になった段階で破棄する必要があります。 */ static char* toSerializedString(const PropertyData& property); private: /** * 付箋紙のプロパティを読み込みます。 * * @return ロードした付箋紙のプロパティを戻します。 */ static PropertyData loadProperty(); /** * 付箋紙のプロパティを保存します。 * * @param property 付箋紙プロパティ * @return 保存に成功した場合は true を戻します。 */ static bool saveProperty(const PropertyData& property); private: /** * 付箋紙のプロパティをXMLから読み込みます。 * * @param document XML * @param property プロパティの保存先オブジェクト * @return ロードに成功した場合はtrueを戻します。 */ static bool loadFromXML(const xmlDocPtr document, PropertyData& property); /** * 付箋紙のプロパティをXMLに変換します。 * * @param property 付箋紙プロパティ * @return 変換後のXML。不要になった時点で解放する必要があります。 */ static xmlDocPtr toXML(const PropertyData& property); private: /** * ロード済みのプロパティ */ static PropertyData m_cProperty; private: /** * ニックネーム */ Glib::ustring m_szNickName; /** * 前景・背景色 */ GdkColor m_cForeground; GdkColor m_cBackground; /** * フォント情報名 */ Glib::ustring m_szFontName; /** * 折り返しモード */ Gtk::WrapMode m_nWrapMode; /** * ネットワーク機能の有効フラグ */ bool m_bEnableNetwork; /** * 印刷コマンド */ Glib::ustring m_szPrintCommand; /** * ブロードキャストアドレスの一覧 */ BroadcastList m_cBroadcastList; /** * ウィンドウの貼り付けフラグ */ bool m_bStickWindow; /** * トレイアイコンの表示フラグ */ bool m_bTrayIcon; /** * メインウィンドウの表示フラグ */ bool m_bHideMainWnd; }; #endif