xref: /aoo41x/main/sd/source/ui/dlg/assclass.cxx (revision 79aad27f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sd.hxx"
26 
27 
28 #include <tools/list.hxx>
29 #include <tools/debug.hxx>
30 #include <vcl/ctrl.hxx>
31 
32 #include "assclass.hxx"
33 
34 
Assistent(int nNoOfPages)35 Assistent::Assistent(int nNoOfPages)
36 {
37 	mnPages=nNoOfPages;
38 	if(mnPages>MAX_PAGES)
39 	{
40 		mnPages=MAX_PAGES;
41 	}
42 
43 	mpPageStatus = new bool[mnPages];
44 
45 	for(sal_uInt8 i=0;i<mnPages;i++)
46 	{
47 		mpPages[i]=new List();
48 		mpPageStatus[i] = sal_True;
49 	}
50 	mnCurrentPage=1;
51 }
52 
53 
54 
InsertControl(int nDestPage,Control * pUsedControl)55 bool Assistent::InsertControl(int nDestPage,Control* pUsedControl)
56 {
57 	DBG_ASSERT( (nDestPage > 0) && (nDestPage <= mnPages), "Seite nicht vorhanden!");
58 	if((nDestPage>0)&&(nDestPage<=mnPages))
59 	{
60 		mpPages[nDestPage-1]->Insert(pUsedControl,LIST_APPEND);
61 		pUsedControl->Hide();
62 		pUsedControl->Disable();
63 		return true;
64 	}
65 	else
66 	{
67 		return false;
68 	}
69 }
70 
71 
NextPage()72 bool Assistent::NextPage()
73 {
74 	if(mnCurrentPage<mnPages)
75 	{
76 		int nPage = mnCurrentPage+1;
77 		while(nPage <= mnPages && !mpPageStatus[nPage-1])
78 		  nPage++;
79 
80 		if(nPage <= mnPages)
81 			return GotoPage(nPage);
82 	}
83 	return false;
84 }
85 
86 
PreviousPage()87 bool Assistent::PreviousPage()
88 {
89 	if(mnCurrentPage>1)
90 	{
91 		int nPage = mnCurrentPage-1;
92 		while(nPage >= 0 && !mpPageStatus[nPage-1])
93 			nPage--;
94 
95 		if(nPage >= 0)
96 			return GotoPage(nPage);
97 	}
98 	return false;
99 }
100 
101 
GotoPage(const int nPageToGo)102 bool Assistent::GotoPage(const int nPageToGo)
103 {
104 	DBG_ASSERT( (nPageToGo > 0) && (nPageToGo <= mnPages), "Seite nicht vorhanden!");
105 
106 	if((nPageToGo>0)&&(nPageToGo<=mnPages)&&mpPageStatus[nPageToGo-1])
107 	{
108 		int i;
109 		Control* pCurControl;
110 		int nIndex=mnCurrentPage-1;
111 
112 		for(i=0;i<(int)mpPages[nIndex]->Count();i++)
113 		{
114 			pCurControl=(Control*)mpPages[nIndex]->GetObject(i);
115 			pCurControl->Disable();
116 			pCurControl->Hide();
117 				//schaltet die Controls der vorherigen Seite
118 				//zurueck
119 		}
120 		mnCurrentPage=nPageToGo;
121 		nIndex=mnCurrentPage-1;
122 		for(i=0;i<(int)mpPages[nIndex]->Count();i++)
123 		{
124 
125 			pCurControl=(Control*)mpPages[nIndex]->GetObject(i);
126 			pCurControl->Enable();
127 			pCurControl->Show();
128 				//zeigt die neue Seite im Fenster an
129 		}
130 		return true;
131 	}
132 	else
133 	{
134 		return false;
135 	}
136 }
137 
138 
IsLastPage()139 bool Assistent::IsLastPage()
140 {
141 	if(mnCurrentPage==mnPages)
142 	{
143 		return true;
144 	}
145 	else
146 	{
147 		int nPage = mnCurrentPage+1;
148 		while(nPage <= mnPages && !mpPageStatus[nPage-1])
149 			nPage++;
150 
151 		return nPage > mnPages;
152 	}
153 }
154 
155 
IsFirstPage()156 bool Assistent::IsFirstPage()
157 {
158 	if(mnCurrentPage==1)
159 	{
160 		return true;
161 	}
162 	else
163 	{
164 		int nPage = mnCurrentPage-1;
165 		while(nPage > 0 && !mpPageStatus[nPage-1])
166 			nPage--;
167 
168 		return nPage == 0;
169 	}
170 }
171 
172 
173 
GetCurrentPage()174 int Assistent::GetCurrentPage()
175 {
176 	return mnCurrentPage;
177 }
178 
~Assistent()179 Assistent::~Assistent()
180 {
181 	for( int i=0;i<mnPages;i++)
182 	{
183 		delete mpPages[i];
184 	}
185 
186 	delete [] mpPageStatus;
187 }
188 
IsEnabled(int nPage)189 bool Assistent::IsEnabled( int nPage )
190 {
191 	DBG_ASSERT( (nPage>0) && (nPage <= mnPages), "Seite nicht vorhanden!" );
192 
193 	return (nPage>0) && (nPage <= mnPages && mpPageStatus[nPage-1]);
194 }
195 
EnablePage(int nPage)196 void Assistent::EnablePage( int nPage )
197 {
198 	DBG_ASSERT( (nPage>0) && (nPage <= mnPages), "Seite nicht vorhanden!" );
199 
200 	if((nPage>0) && (nPage < mnPages && !mpPageStatus[nPage-1]))
201 	{
202 		mpPageStatus[nPage-1] = true;
203 	}
204 }
205 
DisablePage(int nPage)206 void Assistent::DisablePage( int nPage )
207 {
208 	DBG_ASSERT( (nPage>0) && (nPage <= mnPages), "Seite nicht vorhanden!" );
209 
210 	if((nPage>0) && (nPage <= mnPages && mpPageStatus[nPage-1]))
211 	{
212 		mpPageStatus[nPage-1] = false;
213 		if(mnCurrentPage == nPage)
214 			GotoPage(1);
215 	}
216 }
217