1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: assclass.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
35 #include <tools/list.hxx>
36 #include <tools/debug.hxx>
37 #include <vcl/ctrl.hxx>
39 #include "assclass.hxx"
42 Assistent::Assistent(int nNoOfPages
)
50 mpPageStatus
= new bool[mnPages
];
52 for(UINT8 i
=0;i
<mnPages
;i
++)
54 mpPages
[i
]=new List();
55 mpPageStatus
[i
] = TRUE
;
62 bool Assistent::InsertControl(int nDestPage
,Control
* pUsedControl
)
64 DBG_ASSERT( (nDestPage
> 0) && (nDestPage
<= mnPages
), "Seite nicht vorhanden!");
65 if((nDestPage
>0)&&(nDestPage
<=mnPages
))
67 mpPages
[nDestPage
-1]->Insert(pUsedControl
,LIST_APPEND
);
69 pUsedControl
->Disable();
79 bool Assistent::NextPage()
81 if(mnCurrentPage
<mnPages
)
83 int nPage
= mnCurrentPage
+1;
84 while(nPage
<= mnPages
&& !mpPageStatus
[nPage
-1])
88 return GotoPage(nPage
);
94 bool Assistent::PreviousPage()
98 int nPage
= mnCurrentPage
-1;
99 while(nPage
>= 0 && !mpPageStatus
[nPage
-1])
103 return GotoPage(nPage
);
109 bool Assistent::GotoPage(const int nPageToGo
)
111 DBG_ASSERT( (nPageToGo
> 0) && (nPageToGo
<= mnPages
), "Seite nicht vorhanden!");
113 if((nPageToGo
>0)&&(nPageToGo
<=mnPages
)&&mpPageStatus
[nPageToGo
-1])
116 Control
* pCurControl
;
117 int nIndex
=mnCurrentPage
-1;
119 for(i
=0;i
<(int)mpPages
[nIndex
]->Count();i
++)
121 pCurControl
=(Control
*)mpPages
[nIndex
]->GetObject(i
);
122 pCurControl
->Disable();
124 //schaltet die Controls der vorherigen Seite
127 mnCurrentPage
=nPageToGo
;
128 nIndex
=mnCurrentPage
-1;
129 for(i
=0;i
<(int)mpPages
[nIndex
]->Count();i
++)
132 pCurControl
=(Control
*)mpPages
[nIndex
]->GetObject(i
);
133 pCurControl
->Enable();
135 //zeigt die neue Seite im Fenster an
146 bool Assistent::IsLastPage()
148 if(mnCurrentPage
==mnPages
)
154 int nPage
= mnCurrentPage
+1;
155 while(nPage
<= mnPages
&& !mpPageStatus
[nPage
-1])
158 return nPage
> mnPages
;
163 bool Assistent::IsFirstPage()
171 int nPage
= mnCurrentPage
-1;
172 while(nPage
> 0 && !mpPageStatus
[nPage
-1])
181 int Assistent::GetCurrentPage()
183 return mnCurrentPage
;
186 Assistent::~Assistent()
188 for( int i
=0;i
<mnPages
;i
++)
193 delete [] mpPageStatus
;
196 bool Assistent::IsEnabled( int nPage
)
198 DBG_ASSERT( (nPage
>0) && (nPage
<= mnPages
), "Seite nicht vorhanden!" );
200 return (nPage
>0) && (nPage
<= mnPages
&& mpPageStatus
[nPage
-1]);
203 void Assistent::EnablePage( int nPage
)
205 DBG_ASSERT( (nPage
>0) && (nPage
<= mnPages
), "Seite nicht vorhanden!" );
207 if((nPage
>0) && (nPage
< mnPages
&& !mpPageStatus
[nPage
-1]))
209 mpPageStatus
[nPage
-1] = true;
213 void Assistent::DisablePage( int nPage
)
215 DBG_ASSERT( (nPage
>0) && (nPage
<= mnPages
), "Seite nicht vorhanden!" );
217 if((nPage
>0) && (nPage
<= mnPages
&& mpPageStatus
[nPage
-1]))
219 mpPageStatus
[nPage
-1] = false;
220 if(mnCurrentPage
== nPage
)