📄 inlinetag.java
字号:
if(type==KXmlParser.TEXT) // text of text area { value = StringUtil.proccessUrl(parser.getText(),true); parser.next(); //progress the parsing once more since TEXT was handled here. } } catch (Exception e) { Log.logWarn("Failed to get text for tag "+name+".",e); return; } // now add the textarea to the container. InputComponent textarea = new InputComponent(InputComponent.TEXT); if(sizeStr!=null) { try{ int s = Integer.parseInt(sizeStr); textarea.setMaxLen(s); }catch(Exception e){} } textarea.setName(name); textarea.setValue(value); textarea.setInitialValue(value); textarea.setEnabled(enabled); textarea.setMaxWidth(parentBlockTag.getContainerWidth()); if(rowsStr!=null) { try{textarea.setRows(Integer.parseInt(rowsStr.trim()));}catch(NumberFormatException e){ Log.logWarn("Failed to parse textarea rows number "+rowsStr,e); } } else textarea.setRows(5);// default. if(colsStr!=null) { try{textarea.setSize(Integer.parseInt(colsStr.trim()));}catch(NumberFormatException e){ Log.logWarn("Failed to parse textarea cols number "+colsStr,e); } } textarea.setSize(2000);// well its a phone... 2k characters should be enough :) copyStyle(textarea); textarea.setBackgroundColor(FireScreen.getTheme().getIntProperty("bg.color")); int []minSize = textarea.getMinSize(); textarea.setPrefSize(minSize[0],minSize[1]); openForm.addInputComponent(textarea); parentBlockTag.handleComponent(this,textarea); return; } if(TAG_BIG.equals(name)) { int s = font.getSize(); if(s==Font.SIZE_MEDIUM) s = Font.SIZE_LARGE; else if(s==Font.SIZE_SMALL) s = Font.SIZE_MEDIUM; font = Font.getFont(font.getFace(),font.getStyle(),s); return; } if(TAG_CENTER.equals(name)) { layout |= FireScreen.CENTER; return; } if(TAG_SMALL.equals(name)) { int s = font.getSize(); if(s==Font.SIZE_MEDIUM) s = Font.SIZE_SMALL; else if(s==Font.SIZE_LARGE) s = Font.SIZE_MEDIUM; font = Font.getFont(font.getFace(),font.getStyle(),s); return; } if(TAG_TT.equals(name)) { font = Font.getFont(Font.FACE_MONOSPACE,font.getStyle(),font.getSize()); return; } if(TAG_U.equals(name)) { font = Font.getFont(font.getFace(),font.getStyle()|Font.STYLE_UNDERLINED,font.getSize()); return; } } public void handleTagEnd(Browser browser,Page page, KXmlParser parser) { if(TAG_SELECT.equals(name)) { Form openForm = page.getOpenForm(); if(openForm==null || parentBlockTag==null) // ignore input elements outside forms { return; } gr.fire.browser.util.Command menu = openForm.getMenuCommand(); if(menu==null) // error { Log.logWarn("Found closing </select> tag but i dont remember one opening."); return; } InputComponent menuSwitch = new InputComponent(InputComponent.MENU); String menuName = menu.getName(); menuSwitch.setName(menuName); menuSwitch.setEnabled(menu.isEnabled()); menuSwitch.setLayout(FireScreen.VCENTER|FireScreen.CENTER); menuSwitch.setMaxWidth(parentBlockTag.getContainerWidth()); copyStyle(menuSwitch); String text = " ... "; int menuWidth=font.stringWidth(text); int menuHeight=font.getHeight(); if(menuName!=null) { Vector primitivesVector = openForm.getPrimitivesVector(); for(int i=0;i<primitivesVector.size();++i) { InputComponent p = (InputComponent)primitivesVector.elementAt(i); if(menuName.equals(p.getName())) { // add to panel int[] ms = p.getPrefSize(); if(ms[0]>menuWidth) menuWidth=ms[0]; if(ms[1]>menuHeight) menuHeight=ms[1]; if(p.isChecked() && menu.isMultiple()==false) text = p.getText(); // set the value of the selected item } } } menuSwitch.setText(text); menuSwitch.setPrefSize(menuWidth,menuHeight); openForm.addInputComponent(menuSwitch); openForm.setMenuCommand(null); parentBlockTag.handleComponent(this,menuSwitch); return; } } private void handleInputComponent(Form form,KXmlParser parser) { /* * Input primitive can be * "text" | "password" | "checkbox" | "radio" | "submit" | "reset" | "hidden" | * "button" | "phonenumber" | "url" | "numeric" | "decimal" | "email" | */ String type = parser.getAttributeValue(null,"type"); String name = parser.getAttributeValue(null,"name"); String value= parser.getAttributeValue(null,"value"); boolean checked = (parser.getAttributeValue(null,"checked")!=null); boolean enabled = (parser.getAttributeValue(null,"disabled")==null) && (parser.getAttributeValue(null,"readonly")==null); if(value!=null) value = StringUtil.proccessUrl(value,true); InputComponent input = null; boolean setBackgroundColor = false; if(type==null) type="text"; // default else type = type.toLowerCase(); if(type.equals("text")) { input=new InputComponent(InputComponent.TEXT); input.setInitialValue(value); setBackgroundColor=true;// set textfield to default bg color }else if(type.equals("password")) { input=new InputComponent(InputComponent.TEXT); input.setTextConstraints(TextField.PASSWORD); input.setInitialValue(value); setBackgroundColor=true;// set textfield to default bg color } else if(type.equals("checkbox")) { input=new InputComponent(InputComponent.CHECKBOX); input.setInitialValue(checked?"":null); setBackgroundColor=true; input.setChecked(checked); } else if(type.equals("radio")) { input=new InputComponent(InputComponent.RADIO); input.setInitialValue(checked?"":null); setBackgroundColor=true; input.setChecked(checked); } else if(type.equals("submit")) { input=new InputComponent(InputComponent.SUBMIT); input.setLayout(FireScreen.VCENTER|FireScreen.CENTER); if(value==null) value="submit"; } else if(type.equals("reset")) { input=new InputComponent(InputComponent.RESET); input.setLayout(FireScreen.VCENTER|FireScreen.CENTER); if(value==null) value="reset"; } else if(type.equals("button")) { input=new InputComponent(InputComponent.BUTTON); input.setLayout(FireScreen.VCENTER|FireScreen.CENTER); if(value==null) value=""; } else if(type.equals("hidden")) { input=new InputComponent(InputComponent.HIDDEN); } else if(type.equals("phonenumber")) { input=new InputComponent(InputComponent.TEXT); input.setTextConstraints(TextField.PHONENUMBER); input.setInitialValue(value); setBackgroundColor=true;// set textfield to default bg color } else if(type.equals("url")) { input=new InputComponent(InputComponent.TEXT); input.setTextConstraints(TextField.URL); input.setInitialValue(value); setBackgroundColor=true;// set textfield to default bg color } else if(type.equals("email")) { input=new InputComponent(InputComponent.TEXT); input.setTextConstraints(TextField.EMAILADDR); input.setInitialValue(value); setBackgroundColor=true;// set textfield to default bg color } else if(type.equals("numeric")) { input=new InputComponent(InputComponent.TEXT); input.setTextConstraints(TextField.NUMERIC); input.setInitialValue(value); setBackgroundColor=true;// set textfield to default bg color } else if(type.equals("decimal")) { input=new InputComponent(InputComponent.TEXT); input.setTextConstraints(TextField.DECIMAL); input.setInitialValue(value); setBackgroundColor=true;// set textfield to default bg color } else // any other types are not supported { return; } input.setEnabled(enabled); input.setMaxWidth(parentBlockTag.getContainerWidth()); String size = parser.getAttributeValue(null,"size"); if(size!=null) { try{ input.setSize(Integer.parseInt(size)); }catch(NumberFormatException e) { Log.logWarn("Failed to parse size attribute",e); } } String maxLen = parser.getAttributeValue(null,"maxlength"); if(maxLen!=null) { try{ input.setMaxLen(Integer.parseInt(maxLen)); }catch(NumberFormatException e) { Log.logWarn("Failed to parse maxlength attribute",e); } } input.setName(name); input.setValue(value); copyStyle(input); if(setBackgroundColor) input.setBackgroundColor(FireScreen.getTheme().getIntProperty("bg.alt1.color")); int []minSize = input.getMinSize(); input.setPrefSize(minSize[0],minSize[1]); form.addInputComponent(input); // add the input primitive to the container. if(input.getType()!=InputComponent.HIDDEN) { parentBlockTag.handleComponent(this,input); } } public void handleText(Tag topLevelTag, String txt) { // The text will be handled by my parent block element. if(parentBlockTag==null) { Log.logWarn("Cannot handle text outside a Block element"); Log.logWarn("Ignoring: "+txt); return; } parentBlockTag.handleText(topLevelTag,txt); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -