1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef LISTVIEWBUILDER_HXX_INCLUDED
29 #define LISTVIEWBUILDER_HXX_INCLUDED
30 
31 //------------------------------------
32 // include
33 //------------------------------------
34 
35 #if defined _MSC_VER
36 #pragma warning(push, 1)
37 #endif
38 #include <windows.h>
39 #if defined _MSC_VER
40 #pragma warning(pop)
41 #endif
42 
43 #include <string>
44 #include <memory>
45 #include "document_statistic.hxx"
46 
47 //------------------------------------
48 //
49 //------------------------------------
50 
51 class list_view_builder;
52 typedef std::auto_ptr<list_view_builder> list_view_builder_ptr;
53 
54 // factory method for list_view_builder
55 list_view_builder_ptr create_list_view_builder(
56     HWND hwnd_lv, const std::wstring& col1, const std::wstring& col2);
57 
58 //------------------------------------
59 //
60 //------------------------------------
61 
62 class list_view_builder
63 {
64 public:
65     virtual ~list_view_builder();
66 
67     void build(statistic_group_list_t& gl);
68 
69 protected:
70     list_view_builder(
71         HWND hwnd_list_view,
72         const std::wstring& column1_title,
73         const std::wstring& column2_title);
74 
75     virtual void setup_list_view();
76     virtual void insert_group(const std::wstring& title);
77     virtual void insert_item(const std::wstring& title, const std::wstring& value, bool is_editable);
78 
79     HWND get_list_view() const;
80     int get_current_row() const;
81 
82     int  row_index_;
83 
84 private:
85     HWND hwnd_list_view_;
86     std::wstring column1_title_;
87     std::wstring column2_title_;
88 
89     friend list_view_builder_ptr create_list_view_builder(HWND hwnd_lv, const std::wstring& col1, const std::wstring& col2);
90 };
91 
92 //------------------------------------
93 //
94 //------------------------------------
95 
96 class winxp_list_view_builder : public list_view_builder
97 {
98 protected:
99     winxp_list_view_builder(
100         HWND hwnd_list_view,
101         const std::wstring& column1_title,
102         const std::wstring& column2_title);
103 
104     virtual void setup_list_view();
105     virtual void insert_group(const std::wstring& name);
106     virtual void insert_item(const std::wstring& title, const std::wstring& value, bool is_editable);
107 
108 private:
109     int  group_count_;
110     int  row_count_;
111 
112     friend list_view_builder_ptr create_list_view_builder(HWND hwnd_lv, const std::wstring& col1, const std::wstring& col2);
113 };
114 
115 #endif
116