uitest.he
来自「维信SDK文档。源码要求为至少5个C或Java源码」· HE 代码 · 共 1,117 行 · 第 1/3 页
HE
1,117 行
"year" => 2007, "stars" => 3, "image" => "list_flight_of_fury.png", "tagline" => "A flight plan to freedom...", "plot" => "Shot at Castel Studios in Bucharest: John (Seagal), is sent in to recover a stolen Stealth Bomber. His trusty sidekick Rojar (ALki David) and John's ever faithful Jessica (Ciera Payton), fight the rebel forces of Banansistan, led by the vivacious Ellianna (Katie Jones)." ], ["name" => "Attack Force", "year" => 2006, "stars" => 3, "image" => "list_attack_force.png", "tagline" => "It's humanity's greatest hope... and our last chance.", "plot" => "Marshall Lawson loses his strike-team in a cold-blooded and seemingly random attack. After this he takes it upon himself to investigate the suspicious circumstances of the brutal killings. Soon he uncovers CTX Majestic, a covert military operation so secret, that now the military wants Marshall eliminated. Resolute in his pursuit, Marshall engages in a merciless battle with a drug dealer operation that appears to be secretly funded by a rogue arm of the military." ], ["name" => "Shadow Man", "year" => 2006, "stars" => 4, "image" => "list_shadow_man.png", "tagline" => "Either you're with him... or you're dead.", "plot" => "An intelligence operative discovers that no one is what they seem in the shadowy world of espionage." ], ["name" => "Mercenary for Justice", "year" => 2006, "stars" => 4, "image" => "list_mercenary_for_justice.png", "tagline" => "This time, he's not for hire.", "plot" => "Seagal plays a CIA covert operative who is forced into helping a team of mercenaries stage a jailbreak for a wealthy client when his best friend's wife and son are kidnapped by the same mercenaries. All the while the CIA are in pursuit in an attempt to silence Seagal." ], ["name" => "Black Dawn", "year" => 2005, "stars" => 4, "image" => "list_black_dawn.png", "tagline" => "It's always darkest before dawn.", "plot" => "Jonathan Cold returns, this time he goes Undercover to stop a group of Terrorists before they bomb Los Angeles." ] ]; Flow content = new Flow(getStyle("default")); content.setPreferredSize(-100, -100); content.add(createHeaderText("Movie list")); foreach (Value movie : data) { Flow itemFlow = new Flow(getStyle("list.bg")); itemFlow.setFlags(VISIBLE|FOCUSABLE|LINEFEED); itemFlow.setPreferredWidth(-100); itemFlow.setData(movie); itemFlow.setAction(CMD_SHOW); Picture pic = new Picture(getStyle("list.img"), getImage(String(movie.image))); pic.setFlags(VISIBLE); pic.setPreferredWidth(-25); itemFlow.add(pic); { Flow textFlow = new Flow(getStyle("default")); textFlow.setPreferredWidth(-100); textFlow.setFlags(VISIBLE); Label name = new Label(getStyle("list.name"), movie.name); name.setPreferredWidth(-75); name.setFlags(VISIBLE|LINEFEED); textFlow.add(name); Text tag = new Text(getStyle("list.tag"), movie.tagline); tag.setPreferredWidth(-75); tag.setFlags(VISIBLE|LINEFEED); textFlow.add(tag); itemFlow.add(textFlow); } content.add(itemFlow); } final Shell shell = getViewShell(content); shell.setActionHandler(myActionHandler); Shell movieView(Value movie) { Flow view = new Flow(getStyle("default")); view.setPreferredSize(-100, -100); view.add(createHeaderText(movie.name)); Flow starsFlow = new Flow(getStyle("list.star")); starsFlow.setFlags(VISIBLE|LINEFEED); starsFlow.setPreferredWidth(-100); Image starImage = getImage("list_star.png"); for (int i=0; i<int(movie.stars); i++) { Picture star = new Picture(getStyle("list.star"), starImage); starsFlow.add(star); } view.add(starsFlow); Text plot = new Text(getStyle("list.plot"), movie.plot); plot.setFlags(VISIBLE); plot.setPreferredWidth(-100); view.add(plot); return getViewShell(view); } void myActionHandler(final Shell shell, final Component source, final int action) { if (action == CMD_BACK) { //same logic works for both views, re-use ;) popShell(shell); } else if (action == CMD_SHOW) { pushShell(movieView(Value(source.getData()))); } } return shell; } //----- Shell createMenu() { final int CMD_FILE = MAX_CMD_ID+1; final int CMD_FILE_NEW = MAX_CMD_ID+11; final int CMD_FILE_OPEN = MAX_CMD_ID+12; final int CMD_FILE_EXIT = MAX_CMD_ID+13; final int CMD_EDIT = MAX_CMD_ID+2; final int CMD_VIEW = MAX_CMD_ID+3; final int CMD_WINDOW = MAX_CMD_ID+4; final int CMD_HELP = MAX_CMD_ID+5; //Note that OPEN_SETTINGS is declared in Helium API //Events with OPEN_SETTINGS id are captured and consumed //by the framework, firing it will open Widget's //setting view Menu menu = new Menu().begin(CMD_FILE, "File") .add(CMD_FILE_NEW, "New") .add(CMD_FILE_OPEN, "Open") .add(CMD_FILE_EXIT, "Exit") .end() .add(CMD_EDIT, "Edit") .add(CMD_VIEW, "View") .add(OPEN_SETTINGS, "Settings") .add(CMD_WINDOW, "Window") .add(CMD_HELP, "Help"); Flow content = new Flow(getStyle("default")); content.setPreferredSize(-100, -100); //item #0 content.add(createHeaderText("Menus can contain submenus, items/submenus can be disabled/enabled according to focused element")); addLabel("I have menu"); //item #1 addLabel("I don't have have menu at all"); //item #2 addLabel("I have only Settings-menu"); //item #3 final Shell shell = new Shell(content); shell.setStyle(getStyle("maxi")); shell.setSoftKeyHandler(mySoftKeyHandler); shell.setActionHandler(myActionHandler); shell.setMenuHandler(myMenuHandler); void addLabel(String name) { Label label = new Label(getStyle("mainLabel"), name); label.setPreferredWidth(-100); label.setFlags(VISIBLE|FOCUSABLE|LINEFEED); content.add(label); } MenuItem mySoftKeyHandler(final Shell shell, final Component focused, final int key) { if (key == SOFTKEY_BACK) { return BACK; } else if (key == SOFTKEY_OK) { int index = focused.getParent().indexOf(focused); if (index == 2) { //this element didn't have menu, so don't display open menu-softkey return null; } else { return new MenuItem(OPEN_MENU, "Menu"); } } return null; } void myActionHandler(final Shell shell, final Component source, final int action) { if (action == CMD_BACK) { popShell(shell); } else if (action == FOCUS_CHANGED) { //make system refresh soft keys each time focus is changed shell.updateMenu(); } else if (action > MAX_CMD_ID) { setBubble(null, "This feature is not implemented."); } } Menu myMenuHandler(Shell shell, Component source) { menu.reset(); int index = source.getParent().indexOf(source); if (index == 2) { return null; } else if (index == 3) { //note that disabling a MenuItem disables also it's //child-menus menu.enable(CMD_FILE, false); menu.enable(CMD_EDIT, false); menu.enable(CMD_VIEW, false); menu.enable(CMD_WINDOW, false); menu.enable(CMD_HELP, false); } return menu; } return shell; } //----- Shell createPicture() { Menu m_menu = new Menu().add(MAX_CMD_ID+1, "Picture 1") .add(MAX_CMD_ID+2, "Picture 2") .add(MAX_CMD_ID+3, "Picture 3"); Flow content = new Flow(getStyle("picture.bg")); content.setPreferredSize(-100, -100); Picture pic = new Picture(getStyle("picture.frame"), getImage("picture_1.png")); pic.repaint(true); content.add(pic); final Shell shell = new Shell(content); shell.setStyle(getStyle("maxi")); shell.setSoftKeyHandler(mySoftKeyHandler); shell.setActionHandler(myActionHandler); shell.setMenuHandler(myMenuHandler); MenuItem mySoftKeyHandler(final Shell shell, final Component focused, final int key) { if (key == SOFTKEY_BACK) { return BACK; } else if (key == SOFTKEY_OK) { return new MenuItem(OPEN_MENU, "Change"); } return null; } void myActionHandler(final Shell shell, final Component source, final int action) { if (action == CMD_BACK) { popShell(shell); } else if (action >= MAX_CMD_ID+1 && action <= MAX_CMD_ID+3) { Image img = getImage("picture_" + (action-MAX_CMD_ID) + ".png"); pic.setImage(img); pic.repaint(true); flushScreen(false); int x, int y = pic.getSize(); } } Menu myMenuHandler(Shell shell, Component source) { return m_menu.reset(); } return shell; } //----- Shell createProgress() { int current = 0; int maximum = 10; //create progress Prompt with 10 steps Prompt prompt = new Prompt(null, "This is progress", null, CANCEL); prompt.setProgress(current, maximum); prompt.setActionHandler(myActionHandler); prompt.push(); //schedule (start) Timer that notifies time-handler once a second //(1000ms) to update the current progress Timer timer = schedule(0, 1000, myTimerHandler); void myTimerHandler(Timer timer) { prompt.setProgress(current++ % maximum, maximum); //repaint screen, no need to recalculate component dimensions flushScreen(false); } void myActionHandler(Shell shell, Component source, int action) { if (action == CMD_CANCEL) { //always remember to cancel your timers when your widget/shell //exists or they'll run there forever! if (timer != null) { timer.cancel(); timer = null; } popShell(shell); } } return null; } //----- Shell createPrompt() { final int CMD_LEFT = MAX_CMD_ID+1; final int CMD_RIGHT = MAX_CMD_ID+2; //softkey labels MenuItem left = new MenuItem(CMD_LEFT, "Maybe"); MenuItem right = new MenuItem(CMD_RIGHT, "Why not"); Prompt prompt = new Prompt(null, "To be, or not to be?", left, right); prompt.setProgress(0, 0); prompt.setActionHandler(myActionHandler); prompt.push(); void myActionHandler(final Shell shell, final Component source, final int action) { if (action == CMD_LEFT || action == CMD_RIGHT) { popShell(shell); } } return null; } //----- Shell createSliding() { Flow content = new Flow(getStyle("default")); content.setPreferredSize(-100, -100); content.add(createHeaderText("Click number keys to see different transitions between views...")); final Shell shell = new Shell(content); shell.setStyle(getStyle("maxi")); shell.setSoftKeyHandler(defaultSoftKeyHandler); shell.setActionHandler(defaultActionHandler); shell.setKeyHandler(myKeyHandler);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?