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