⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 choicegroup.java

📁 j2me is based on j2mepolish, client & server for mobile application. menu sample
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
						Screen scr = getScreen();
						if (scr != null) {
							Command selectCmd = this.selectCommand;
							if (selectCmd == null) {
								selectCmd = List.SELECT_COMMAND;
							}
							scr.callCommandListener( selectCmd );
						}
					}
					return true;
				}
			//#endif
			}
		}
		//#endif
		return processed;
	}
	
	
	//#ifdef polish.hasPointerEvents
	//# /* (non-Javadoc)
	 //# * @see de.enough.polish.ui.Item#handlePointerPressed(int, int)
	 //# */
	//# protected boolean handlePointerPressed(int x, int y) {
		//#ifdef polish.usePopupItem
		//# if (this.isPopup && this.isPopupClosed) {
			//# if (isInContentArea(x, y)) {
				//# openPopup();
				//# return true;
			//# } else {
				//# return false;
			//# }
		//# }
		//#endif
		//# boolean success = super.handlePointerPressed(x, y); // focuses the appropriate item
		//# if (isInContentArea(x, y)) {
			//# success |= handleKeyPressed( -1, Canvas.FIRE );
		//# }
		//# return success;
	//# }
	//#endif
	

	//#if polish.usePopupItem
	//# /* (non-Javadoc)
	 //# * @see de.enough.polish.ui.Item#isInContentArea(int, int)
	 //# */
	//# public boolean isInContentArea(int relX, int relY) {
		//# if (this.isPopup && !this.isPopupClosed) {
			//# if (relY < this.contentY || relY > this.contentY + this.originalContentHeight) {
				//# return false;
			//# }
			//# if (relX < this.contentX || relX > this.contentX + this.originalContentWidth) {
				//# return false;
			//# }
			//# return true;
		//# } else {
			//# return super.isInContentArea(relX, relY);
		//# }
	//# }
	//#endif

	//#if polish.usePopupItem
	//# /* (non-Javadoc)
	 //# * @see de.enough.polish.ui.Item#isInItemArea(int, int)
	 //# */
	//# public boolean isInItemArea(int relX, int relY) {
		//# if (this.isPopup && !this.isPopupClosed) {
			//# if (relY < 0 || relY > (this.itemHeight + (this.originalContentHeight - this.contentHeight)) 
					//# || relX < 0 || relX > (this.itemWidth + (this.originalContentWidth - this.contentWidth)))
			//# {
				//# return false;
			//# }
			//# return true;
		//# } else {
			//# return super.isInItemArea(relX, relY);
		//# }
	//# }
	//#endif

	/**
	 * Sets the select command for this choice group.
	 *
	 * @param command the new select command
	 */
	protected void setSelectCommand(Command command) {
		this.selectCommand = command;
	}
	
	
	//#ifndef tmp.suppressAllCommands
	/**
	 * Sets the command for selecting this (and opening this POPUP) choicegroup.
	 * This implementation only works like described when not all ChoiceGroup command are deactivated
	 * by specifying the <variable name="polish.ChoiceGroup.suppressMarkCommands" value="true"/>
	 * and <variable name="polish.ChoiceGroup.suppressSelectCommand" value="true"/>
	 * preprocessing variables. When all commands are deactivated by the mentioned preprocessing variables,
	 * the implementation of Item is used instead.
	 * 
	 * @param cmd the new command for selecting this choice group
	 */
	public void setDefaultCommand(Command cmd) {
		if (this.choiceType == MULTIPLE) {
			//#ifndef tmp.suppressMarkCommands
				removeCommand( MARK_COMMAND );
			//#endif
		} else {
			//#ifndef tmp.suppressSelectCommand
				removeCommand( List.SELECT_COMMAND );
				if (this.selectCommand != null) {
					removeCommand( this.selectCommand );
				}
			//#endif
		}
		if (this.additionalItemCommandListener == null) {
			this.additionalItemCommandListener = this.itemCommandListener;
		}
		addCommand( cmd );
		this.selectCommand = cmd;
		this.defaultCommand = cmd;
		this.itemCommandListener = this;
	}
	//#endif
	
	//#ifdef polish.usePopupItem
	//# /* (non-Javadoc)
	 //# * @see de.enough.polish.ui.Item#defocus(de.enough.polish.ui.Style)
	 //# */
	//# public void defocus(Style originalStyle) {
		//# if (this.isPopup) {
			//# if (this.isPopupClosed) {
				//# this.popupItem.setStyle( originalStyle );
			//# } else {
				//# this.isPopupClosed = true;
				//# requestInit();
			//# }
			//# setStyle( originalStyle );
			//# // now remove any commands which are associated with this item:
			//# Screen scr = getScreen();
			//# if (scr != null) {
				//# scr.removeItemCommands(this);
			//# }
			//# // change the label-style of this container:
			//#ifdef polish.css.label-style
				//# Style tmpLabelStyle = null;
				//# if ( originalStyle != null) {
					//# tmpLabelStyle = (Style) originalStyle.getObjectProperty(3);
				//# }
				//# if (tmpLabelStyle == null) {
					//# tmpLabelStyle = StyleSheet.labelStyle;
				//# }
				//# if (this.label != null && tmpLabelStyle != null && this.label.style != tmpLabelStyle) {
					//# this.label.setStyle( tmpLabelStyle );
				//# }
			//#endif
		//# } else {
			//# super.defocus(originalStyle);
		//# }
	//# }
	//#endif

	//#ifdef polish.usePopupItem	
	//# /* (non-Javadoc)
	 //# * @see de.enough.polish.ui.Item#focus(de.enough.polish.ui.Style, int)
	 //# */
	//# protected Style focus(Style focusStyle, int direction) {
		//# if (this.isPopup && this.isPopupClosed) {
			//# if (this.focusedStyle != null) {
				//# focusStyle = this.focusedStyle;
			//# }
			//# Style original = this.style;
			//# this.popupItem.setStyle( focusStyle );
			//# setStyle( focusStyle );
			//# // now remove any commands which are associated with this item:
			//# Screen scr = getScreen();
			//# if (scr != null) {
				//# scr.setItemCommands(this);
			//# }
			//# // change the label-style of this container:
			//#ifdef polish.css.label-style
				//# if (this.label != null) {
					//# Style labStyle = (Style) focusStyle.getObjectProperty(3);
					//# if (labStyle != null) {
						//# this.labelStyle = this.label.style;
						//# this.label.setStyle( labStyle );
					//# }
				//# }
			//#endif
			//# return original;
		//# } else {
			//# return super.focus(focusStyle, direction);
		//# }
	//# }
	//#endif

	/* (non-Javadoc)
	 * @see de.enough.polish.ui.Container#setStyle(de.enough.polish.ui.Style, boolean)
	 */
	public void setStyle(Style style, boolean ignoreBackground) {
		super.setStyle(style, ignoreBackground);
		//#ifdef polish.usePopupItem
			//# if (this.isPopup && this.popupItem != null) {
				//# this.popupItem.setStyle( style );
			//# }
			//# if (this.isPopup && this.popupItem.image == null ) {
				//#ifdef polish.css.popup-image
					//# String url = style.getProperty(13);
					//# if (url != null ) {
						//# this.popupItem.setImage( url );
					//# }
				//#endif
				//#ifdef polish.css.popup-color
					//# Integer color = style.getIntProperty(14);
					//# if (color != null) {
						//# this.popupColor = color.intValue();
					//# }
				//#endif
				//#ifdef polish.css.popup-background-color
					//# Integer bgColor = style.getIntProperty(15);
					//# if (bgColor != null) {
						//# this.popupBackgroundColor = bgColor.intValue();
					//# }
				//#endif
				//#if ! tmp.suppressSelectCommand && tmp.supportViewType
					//# if (!this.isSelectCommandAdded && this.choiceType == EXCLUSIVE && this.containerView == null) {
						//# if (this.selectCommand != null) {
							//# addCommand( this.selectCommand );
						//# } else {
							//# addCommand( List.SELECT_COMMAND );
						//# }
						//# this.isSelectCommandAdded = true;				
					//# }
				//#endif
			//# }
		//#endif
		//#ifndef tmp.suppressAllCommands
		if (this.choiceType == MULTIPLE) {
			//#ifndef tmp.suppressMarkCommands
				//#ifdef polish.i18n.useDynamicTranslations
					//# String cmdLabel = "Mark";
					//# if (cmdLabel != MARK_COMMAND.getLabel()) {
						//# MARK_COMMAND = new Command( cmdLabel, Command.ITEM, 9 );
					//# }
					//# cmdLabel = "Unmark";
					//# if (cmdLabel != UNMARK_COMMAND.getLabel()) {
						//# UNMARK_COMMAND = new Command( cmdLabel, Command.ITEM, 10 );
					//# }
				//#endif					
				addCommand( MARK_COMMAND );
				addCommand( UNMARK_COMMAND );
			//#endif
		} else if (this.choiceType == EXCLUSIVE){
			//#if !tmp.suppressSelectCommand
				//#if tmp.supportViewType
					if (this.containerView == null) {
				//#endif
					//#ifdef polish.i18n.useDynamicTranslations
						//# String cmdLabel = "Select";
						//# if (cmdLabel != List.SELECT_COMMAND.getLabel()) {
							//# List.SELECT_COMMAND = new Command( cmdLabel, Command.ITEM, 3 );
						//# }
					//#endif
					addCommand( List.SELECT_COMMAND );
				//#if tmp.supportViewType
					}
				//#endif
			//#endif
		}
		this.itemCommandListener = this;
	//#endif
	}

	//#ifndef tmp.suppressAllCommands
	/* (non-Javadoc)
	 * @see de.enough.polish.ui.ItemCommandListener#commandAction(javax.microedition.lcdui.Command, de.enough.polish.ui.Item)
	 */
	public void commandAction(Command c, Item item) {
		//#if tmp.allowSelectCommand && tmp.allowMarkCommands
		if (c == List.SELECT_COMMAND || c == MARK_COMMAND || c == this.selectCommand  ) {
		//#elif tmp.allowSelectCommand
			//# if (c == List.SELECT_COMMAND || c == this.selectCommand ) {
		//#elif tmp.allowMarkCommands
			//# if (c == MARK_COMMAND || c == this.selectCommand ) {
		//#else
			//#abort Invalid combination of suppressed commands for a ChoiceGroup!
			//# if (false) {
		//#endif
			if (this.focusedIndex != -1) {
				setSelectedIndex( this.focusedIndex, true );
				if ( (this.choiceType != IMPLICIT) 
						//#ifdef polish.usePopupItem
						//# && !(this.isPopup && !this.isPopupClosed)
						//#endif
						&& (this.getScreen() instanceof Form) ) {
					notifyStateChanged();
				}
				//#ifdef polish.usePopupItem
					//# if (this.isPopup) {
						//# if (this.isPopupClosed) {
							//# openPopup();
						//# } else {
							//# closePopup();
						//# }
						//# repaint();
					//# }
				//#endif
			}
			//#ifdef polish.usePopupItem
				//# else if (this.isPopup && this.isPopupClosed) {
					//# openPopup();				
				//# }
			//#endif
		//#ifdef tmp.allowMarkCommands
		} else if (c == UNMARK_COMMAND ) {
			if (this.focusedIndex != -1) {
				setSelectedIndex( this.focusedIndex, false );
				if ( (this.choiceType != IMPLICIT) 
						//#ifdef polish.usePopupItem
						//# && !(this.isPopup && !this.isPopupClosed)
						//#endif
						&& (this.getScreen() instanceof Form) ) {
					notifyStateChanged();
				}
			}
		//#endif
		} else if (this.additionalItemCommandListener != null) {
			this.additionalItemCommandListener.commandAction(c, item);
		}
	}
	//#endif
	
	//#ifndef tmp.suppressAllCommands
	public void setItemCommandListener(ItemCommandListener l) {
		this.additionalItemCommandListener = l;
	}
	//#endif


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -