kexthighscore_tab.h
00001 /* 00002 This file is part of the TDE games library 00003 Copyright (C) 2002 Nicolas Hadacek (hadacek@kde.org) 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KEXTHIGHSCORE_TAB_H 00021 #define KEXTHIGHSCORE_TAB_H 00022 00023 #include <tqcombobox.h> 00024 #include <tqmemarray.h> 00025 00026 class TQLabel; 00027 class TDEListView; 00028 00029 00030 namespace KExtHighscore 00031 { 00032 00033 //----------------------------------------------------------------------------- 00034 class PlayersCombo : public TQComboBox 00035 { 00036 Q_OBJECT 00037 00038 public: 00039 PlayersCombo(TQWidget *parent = 0, const char *name = 0); 00040 00041 void load(); 00042 00043 signals: 00044 void playerSelected(uint i); 00045 void allSelected(); 00046 void noneSelected(); 00047 00048 private slots: 00049 void activatedSlot(int i); 00050 }; 00051 00052 //----------------------------------------------------------------------------- 00053 class AdditionalTab : public TQWidget 00054 { 00055 Q_OBJECT 00056 00057 public: 00058 AdditionalTab(TQWidget *parent, const char *name); 00059 00060 virtual void load(); 00061 00062 private slots: 00063 void playerSelected(uint i) { display(i) ; } 00064 void allSelected(); 00065 00066 protected: 00067 void init(); 00068 static TQString percent(uint n, uint total, bool withBraces = false); 00069 virtual void display(uint i) = 0; 00070 00071 private: 00072 PlayersCombo *_combo; 00073 }; 00074 00075 //----------------------------------------------------------------------------- 00076 class StatisticsTab : public AdditionalTab 00077 { 00078 Q_OBJECT 00079 00080 public: 00081 StatisticsTab(TQWidget *parent); 00082 00083 void load(); 00084 00085 private: 00086 enum Count { Total = 0, Won, Lost, Draw, Nb_Counts }; 00087 static const char *COUNT_LABELS[Nb_Counts]; 00088 enum Trend { CurrentTrend = 0, WonTrend, LostTrend, Nb_Trends }; 00089 static const char *TREND_LABELS[Nb_Trends]; 00090 struct Data { 00091 uint count[Nb_Counts]; 00092 double trend[Nb_Trends]; 00093 }; 00094 TQMemArray<Data> _data; 00095 TQLabel *_nbs[Nb_Counts], *_percents[Nb_Counts], *_trends[Nb_Trends]; 00096 00097 TQString percent(const Data &, Count) const; 00098 void display(uint i); 00099 }; 00100 00101 //----------------------------------------------------------------------------- 00102 class HistogramTab : public AdditionalTab 00103 { 00104 Q_OBJECT 00105 00106 public: 00107 HistogramTab(TQWidget *parent); 00108 00109 void load(); 00110 00111 private: 00112 TQMemArray<uint> _counts; 00113 TQMemArray<uint> _data; 00114 TDEListView *_list; 00115 00116 void display(uint i); 00117 }; 00118 00119 } // namespace 00120 00121 #endif