fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / dlg / assclass.cxx
blobc23004ac22f660dd5b5c62d1c791a4354f31831c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <tools/debug.hxx>
22 #include <vcl/ctrl.hxx>
24 #include "assclass.hxx"
26 Assistent::Assistent(int nNoOfPages)
27 : mnPages(nNoOfPages), mnCurrentPage(1)
29 if(mnPages > MAX_PAGES)
30 mnPages = MAX_PAGES;
32 mpPageStatus.reset(new bool[mnPages]);
34 for(int i=0; i < mnPages; ++i)
35 mpPageStatus[i] = true;
38 bool Assistent::InsertControl(int nDestPage,Control* pUsedControl)
40 DBG_ASSERT( (nDestPage > 0) && (nDestPage <= mnPages), "Page not aviable!");
42 if((nDestPage>0)&&(nDestPage<=mnPages))
44 maPages[nDestPage-1].push_back(pUsedControl);
45 pUsedControl->Hide();
46 pUsedControl->Disable();
47 return true;
50 return false;
53 bool Assistent::NextPage()
55 if(mnCurrentPage<mnPages)
57 int nPage = mnCurrentPage+1;
58 while(nPage <= mnPages && !mpPageStatus[nPage-1])
59 nPage++;
61 if(nPage <= mnPages)
62 return GotoPage(nPage);
65 return false;
69 bool Assistent::PreviousPage()
71 if(mnCurrentPage>1)
73 int nPage = mnCurrentPage-1;
74 while(nPage >= 0 && !mpPageStatus[nPage-1])
75 nPage--;
77 if(nPage >= 0)
78 return GotoPage(nPage);
80 return false;
84 bool Assistent::GotoPage(const int nPageToGo)
86 DBG_ASSERT( (nPageToGo > 0) && (nPageToGo <= mnPages), "Page not aviable!");
88 if((nPageToGo>0)&&(nPageToGo<=mnPages)&&mpPageStatus[nPageToGo-1])
90 int nIndex=mnCurrentPage-1;
92 std::vector<Control*>::iterator iter = maPages[nIndex].begin();
93 std::vector<Control*>::iterator iterEnd = maPages[nIndex].end();
95 for(; iter != iterEnd; ++iter)
97 (*iter)->Disable();
98 (*iter)->Hide();
101 mnCurrentPage=nPageToGo;
102 nIndex=mnCurrentPage-1;
104 iter = maPages[nIndex].begin();
105 iterEnd = maPages[nIndex].end();
107 for(; iter != iterEnd; ++iter)
109 (*iter)->Enable();
110 (*iter)->Show();
113 return true;
116 return false;
120 bool Assistent::IsLastPage() const
122 if(mnCurrentPage == mnPages)
123 return true;
125 int nPage = mnCurrentPage+1;
126 while(nPage <= mnPages && !mpPageStatus[nPage-1])
127 nPage++;
129 return nPage > mnPages;
133 bool Assistent::IsFirstPage() const
135 if(mnCurrentPage == 1)
136 return true;
138 int nPage = mnCurrentPage-1;
139 while(nPage > 0 && !mpPageStatus[nPage-1])
140 nPage--;
142 return nPage == 0;
145 int Assistent::GetCurrentPage() const
147 return mnCurrentPage;
150 bool Assistent::IsEnabled( int nPage ) const
152 DBG_ASSERT( (nPage>0) && (nPage <= mnPages), "Page not aviable!" );
154 return (nPage>0) && (nPage <= mnPages && mpPageStatus[nPage-1]);
157 void Assistent::EnablePage( int nPage )
159 DBG_ASSERT( (nPage>0) && (nPage <= mnPages), "Page not aviable!" );
161 if((nPage>0) && (nPage < mnPages && !mpPageStatus[nPage-1]))
163 mpPageStatus[nPage-1] = true;
167 void Assistent::DisablePage( int nPage )
169 DBG_ASSERT( (nPage>0) && (nPage <= mnPages), "Page not aviable!" );
171 if((nPage>0) && (nPage <= mnPages && mpPageStatus[nPage-1]))
173 mpPageStatus[nPage-1] = false;
174 if(mnCurrentPage == nPage)
175 GotoPage(1);
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */