Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MaximInterface
DisplayIdWindow.cpp
00001 /******************************************************************************* 00002 * Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a 00005 * copy of this software and associated documentation files (the "Software"), 00006 * to deal in the Software without restriction, including without limitation 00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 * and/or sell copies of the Software, and to permit persons to whom the 00009 * Software is furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included 00012 * in all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00017 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00018 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00019 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00020 * OTHER DEALINGS IN THE SOFTWARE. 00021 * 00022 * Except as contained in this notice, the name of Maxim Integrated 00023 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00024 * Products, Inc. Branding Policy. 00025 * 00026 * The mere transfer of this software does not imply any licenses 00027 * of trade secrets, proprietary technology, copyrights, patents, 00028 * trademarks, maskwork rights, or any other form of intellectual 00029 * property whatsoever. Maxim Integrated Products, Inc. retains all 00030 * ownership rights. 00031 *******************************************************************************/ 00032 00033 #include <string> 00034 #include "DisplayIdWindow.hpp" 00035 #include "InitWindow.hpp" 00036 #include "MakeFunction.hpp" 00037 #include "Text.hpp" 00038 #include "WifiConnectWindow.hpp" 00039 #include "WindowManager.hpp" 00040 00041 extern std::string webId; 00042 00043 DisplayIdWindow::DisplayIdWindow(Mode mode) { 00044 backButton.setParent (this); 00045 backButton.setText("Back"); 00046 backButton.setClickedHandler( 00047 makeFunction(this, &DisplayIdWindow::backButtonClicked)); 00048 switch (mode) { 00049 case PreConnectMode: 00050 continueButton.setParent (this); 00051 continueButton.setText("Continue"); 00052 continueButton.setClickedHandler( 00053 makeFunction(this, &DisplayIdWindow::continueButtonClicked)); 00054 continueButton.setFocused(); 00055 break; 00056 00057 case PopupMode: 00058 backButton.setFocused(); 00059 break; 00060 } 00061 } 00062 00063 void DisplayIdWindow::doRender(Bitmap & bitmap, int xOffset, 00064 int yOffset) const { 00065 Text description; 00066 description.setText("Web ID: " + webId); 00067 description.setWordWrap(true); 00068 description.resize(width(), height()); 00069 description.render(bitmap, xOffset + x(), yOffset + y()); 00070 Window::doRender(bitmap, xOffset, yOffset); 00071 } 00072 00073 void DisplayIdWindow::resized() { 00074 backButton.resize(backButton.preferredWidth(), 00075 backButton.preferredHeight()); 00076 backButton.move(0, height() - backButton.height()); 00077 continueButton.resize(continueButton.preferredWidth(), 00078 continueButton.preferredHeight()); 00079 continueButton.move(width() - continueButton.width(), 00080 height() - continueButton.height()); 00081 } 00082 00083 bool DisplayIdWindow::doProcessKey(Key key) { 00084 bool handled; 00085 switch (key) { 00086 case LeftKey: 00087 backButton.setFocused(); 00088 handled = true; 00089 break; 00090 00091 case RightKey: 00092 continueButton.setFocused(); 00093 handled = true; 00094 break; 00095 00096 default: 00097 handled = false; 00098 break; 00099 } 00100 return handled; 00101 } 00102 00103 void DisplayIdWindow::backButtonClicked(Button *) { 00104 if (windowManager()) { 00105 windowManager()->pop(); 00106 if (continueButton.parent()) { 00107 std::auto_ptr<Window> window(new InitWindow(InitWindow::MenuMode)); 00108 windowManager()->push(window); 00109 } 00110 } 00111 } 00112 00113 void DisplayIdWindow::continueButtonClicked(Button *) { 00114 if (windowManager()) { 00115 windowManager()->pop(); 00116 std::auto_ptr<Window> window(new WifiConnectWindow); 00117 windowManager()->push(window); 00118 } 00119 }
Generated on Tue Jul 12 2022 12:06:48 by
1.7.2