~ubuntu-branches/ubuntu/karmic/groundhog/karmic

« back to all changes in this revision

Viewing changes to src/highscore_tab.cc

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2004-08-20 23:12:32 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040820231232-18s0op2f9g21ag1z
Tags: 1.4-6
Update Policy Version

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Groundhog -- a simple logic game
2
 
 * Copyright (C) 1998-2001 Maurits Rijk
 
2
 * Copyright (C) 1998-2002 Maurits Rijk
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
16
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
17
 */
18
18
 
19
 
#include <strstream.h>
 
19
#include <sstream>
 
20
#include <string>
 
21
using namespace std;
20
22
 
21
23
#include "highscore_tab.h"
22
24
#include "intl.h"
28
30
 
29
31
   // Create header
30
32
   GtkWidget* label = gtk_label_new(_("Rank"));
31
 
   gtk_widget_show(label);
32
33
   gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
33
34
   
34
35
   label = gtk_label_new(_("Name"));
35
 
   gtk_widget_show(label);
36
36
   gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1);
37
37
   
38
38
   label = gtk_label_new(_("Seconds"));
39
 
   gtk_widget_show(label);
40
39
   gtk_table_attach_defaults(GTK_TABLE(table), label, 2, 3, 0, 1);
41
40
 
42
 
   gtk_widget_show(table);
43
41
 
44
42
   for (int i = 1; i <= 10; i++) {
45
 
      char scratch[16];
46
 
      std::ostrstream ost(scratch, sizeof(scratch));
47
 
      
48
 
      ost << i << std::ends;
49
 
      GtkWidget* index_label = gtk_label_new(scratch);
50
 
      gtk_widget_show(index_label);
 
43
      ostringstream ost;
 
44
      ost << i << ends; // format string
 
45
      string temp = ost.str();  // retrieve formatted string
 
46
 
 
47
      GtkWidget* index_label = gtk_label_new(temp.c_str());
 
48
 
51
49
      gtk_table_attach_defaults(GTK_TABLE(table), index_label, 0, 1, i, i + 1);
52
50
 
53
51
      _names[i] = gtk_label_new(N_(""));
54
 
      gtk_widget_show(_names[i]);
55
52
      gtk_table_attach_defaults(GTK_TABLE(table), _names[i], 1, 2, i, i + 1);
56
53
 
57
54
      _seconds[i] = gtk_label_new(N_(""));
58
 
      gtk_widget_show(_seconds[i]);
59
55
      gtk_table_attach_defaults(GTK_TABLE(table), _seconds[i], 2, 3, i, i + 1);
60
56
   }
61
57
   
62
 
   label = gtk_label_new(tab_name);
 
58
   label = gtk_label_new_with_mnemonic(tab_name);
63
59
   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table, label);
64
60
}
65
61
 
74
70
HighScoreTab::Fill(const ScoreList& slist)
75
71
{
76
72
   int index = 1;
77
 
   for (std::list<Score>::const_iterator i = slist.Begin(); 
 
73
   for (list<Score>::const_iterator i = slist.Begin(); 
78
74
        i != slist.End(); i++) {
79
 
      char scratch[16];
80
 
      std::ostrstream ost(scratch, sizeof(scratch));
81
 
      
82
 
      ost << (*i).GetSeconds() << std::ends;
 
75
      ostringstream ost;
 
76
      ost << (*i).GetSeconds() << ends; // format string
 
77
          string temp = ost.str();                                                      // retrieve string
83
78
 
84
 
      FillOneScore(index++, (*i).GetName().c_str(), scratch);
 
79
      FillOneScore(index++, (*i).GetName().c_str(), temp.c_str());
85
80
   }
86
81
   
87
82
   for (; index <= 10; index++)