public class

PenMenu

extends View
java.lang.Object
   ↳ android.view.View
     ↳ com.htc.painting.penmenu15.PenMenu

Summary

Constants
int PENSET_ALL The supported pen set on Pen Menu: All.
int PENSET_SIMPLE The supported pen set on Pen Menu: Only simple pen (the default stroke type supported by Android) and eraser pen are supported.
int STROKE_INVISIBLE Constants for IPaintingView stroke visibility.
int STROKE_VISIBLE Constants for IPaintingView stroke visibility.
[Expand]
Inherited Constants
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
PenMenu(Context context)
PenMenu(Context context, AttributeSet attrs)
PenMenu(Context context, AttributeSet attrs, int defStyle)
Public Methods
void OnRestoreInstanceState(Bundle bundle)
This method is deprecated. plse use onRestoreInstanceState(Bundle)
void OnSaveInstanceState(Bundle bundle)
This method is deprecated. plse use onSaveInstanceState()
void changeState()
Called to switch the show/hide state of the PenMenu alternately.
View findViewById2(int id)
int forceHideStroke(boolean forceHide)
Force to hide the strokes (lower the opacity to the predefined value) on painting view when the value of forceHide is set to true or restore the original state of strokes when the value of forceHide is set to false.
boolean handleKeyEvent(int keyCode, KeyEvent event)
Receive the key event passed by applications.
void hide(boolean playAnimation, boolean turnOffStickyState)
Hide PenMenu.
boolean isDestroyed()
void onDestroy()
Called to let PenMenu do the cleanup, including the registered receiver and allocated resources
void onMenuClosed()
Callback for invoke on Activity#onOptionsMenuClosed or whatever hide the PenMenu by previous onMenuOpened() call.
void onMenuOpened()
Callback for invoke on Activity#onMenuOpened or whatever would overlay with PenMenu to hide the PenMenu.
void onRestoreInstanceState(Bundle bundle)
Called to let PenMenu retrieve the previous saved state and settings.
void onSaveInstanceState(Bundle bundle)
Called to let PenMenu have chance to save current show/hide state and settings before being killed so that the state and settings can be restored later.
void restoreSetting()
Restore current pen settings and history pens settings if any.
void saveSetting()
Save current pen settings and history pens settings if any.
void setActionActive(int actionId, boolean active)
When the applications implement their own painting view and integrate with Pen Menu with different behaviors, they can disable action buttons by calling this function.
void setEraserMode(boolean isEraserMode)
Called to enable/disable the Eraser mode.
void setHighLightConfiguration(IHighlightConfiguration highlightConfig)
void setHintPromptEnabled(boolean enabled)
void setOnActionPerformListener(OnActionPerformListener listener)
Used for registering one listener to Pen Menu.
void setPaintingView(IStrokeNotifyPaintingView paintingView)
Associate HtcPaintingView with PenMenu.
void setPenSetType(int penSetType)
When applications implement their own painting view and integrate with HTC Pen Menu with limited pen set, call this function to grey out the predefined pens enabled on the device.
void setVisibility(int visibility)
void show(boolean playAnimation, boolean turnOnStickyState)
Show PenMenu.
Protected Methods
void onAttachedToWindow()
void onDetachedFromWindow()
[Expand]
Inherited Methods
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.graphics.drawable.Drawable.Callback2
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Constants

public static final int PENSET_ALL

Since: API Level 4.0

The supported pen set on Pen Menu: All. It will enable all pens that can be used in HtcPaintingView

Constant Value: 0 (0x00000000)

public static final int PENSET_SIMPLE

Since: API Level 4.0

The supported pen set on Pen Menu: Only simple pen (the default stroke type supported by Android) and eraser pen are supported.

Constant Value: 1 (0x00000001)

public static final int STROKE_INVISIBLE

Since: API Level 4.0

Constants for IPaintingView stroke visibility. The ID of stroke visibility: STROKE_INVISIBLE. Set stroke to lower opacity value.

Constant Value: 0 (0x00000000)

public static final int STROKE_VISIBLE

Since: API Level 4.0

Constants for IPaintingView stroke visibility. The ID of stroke visibility: STROKE_VISIBLE. Set stroke to original opacity value.

Constant Value: 1 (0x00000001)

Public Constructors

public PenMenu (Context context)

Since: API Level 4.0

public PenMenu (Context context, AttributeSet attrs)

Since: API Level 4.0

public PenMenu (Context context, AttributeSet attrs, int defStyle)

Since: API Level 4.0

Public Methods

public void OnRestoreInstanceState (Bundle bundle)

Since: API Level 4.0

This method is deprecated.
plse use onRestoreInstanceState(Bundle)

public void OnSaveInstanceState (Bundle bundle)

Since: API Level 4.0

This method is deprecated.
plse use onSaveInstanceState()

public void changeState ()

Since: API Level 4.0

Called to switch the show/hide state of the PenMenu alternately.

public View findViewById2 (int id)

Since: API Level 4.0

public int forceHideStroke (boolean forceHide)

Since: API Level 4.0

Force to hide the strokes (lower the opacity to the predefined value) on painting view when the value of forceHide is set to true or restore the original state of strokes when the value of forceHide is set to false. This function is provided for integrated APPs when users want to interact with the contents behind the painting view. For example, users may press the lower hardware button of Pen to enable Text Selection function. The integrated APPs can call this function to hide on-screen strokes. It will provide a clear view to let users do Text Selection.

Parameters
forceHide true to hide the strokes, false to restore the original state of strokes.
Returns
  • The original stroke state: PenMenu.STROKE_VISIBLE or PenMenu.STROKE_INVISIBLE

public boolean handleKeyEvent (int keyCode, KeyEvent event)

Since: API Level 4.0

Receive the key event passed by applications. If the Hardware Pen Button is pressed, PenMenu will then switch the show/hide state alternately.

Parameters
keyCode the key code.
event the key event.
Returns
  • true if PenMune recognized this key code and processed it.

public void hide (boolean playAnimation, boolean turnOffStickyState)

Since: API Level 4.0

Hide PenMenu. Client app can control whether to play animation by playAnimation parameter. And the turnOffStickyState parameter can control whether the sticky state should be forced to turn off. The sticky state is for controlling the behavior to restore PenMenu's previous show/hide state when it is hidden. If this flag is turned off, the PenMenu couldn't show itself.

Parameters
playAnimation true to play hiding animation, false to hide directly without animation.
turnOffStickyState true to turn off stick state, false to keep sticky state unchanged.
See Also
  • {@link #show(boolean, boolean)}

public boolean isDestroyed ()

Since: API Level 4.0

public void onDestroy ()

Since: API Level 4.0

Called to let PenMenu do the cleanup, including the registered receiver and allocated resources

public void onMenuClosed ()

Since: API Level 4.0

Callback for invoke on Activity#onOptionsMenuClosed or whatever hide the PenMenu by previous onMenuOpened() call. Client app should always call this method on its Activity#onOptionsMenuClosed. Note. The method should be called in pair with onMenuOpened()

See Also
  • {@link #onMenuOpened}

public void onMenuOpened ()

Since: API Level 4.0

Callback for invoke on Activity#onMenuOpened or whatever would overlay with PenMenu to hide the PenMenu. Client app should always call this method on its Activity#onMenuOpened. Note. The method should be called in pair with onMenuClosed()

See Also
  • {@link #onMenuClosed}

public void onRestoreInstanceState (Bundle bundle)

Since: API Level 4.0

Called to let PenMenu retrieve the previous saved state and settings. PenMenu will restore its state and settings after device orientation is changed.

Parameters
bundle Bundle in which to place your saved state.

public void onSaveInstanceState (Bundle bundle)

Since: API Level 4.0

Called to let PenMenu have chance to save current show/hide state and settings before being killed so that the state and settings can be restored later. PenMenu will keep its state and setting while device orientation is changed.

Parameters
bundle Bundle in which to place your saved state.

public void restoreSetting ()

Since: API Level 4.0

Restore current pen settings and history pens settings if any. This function is designed for the feature of global pens settings (share the same preferences between all pen integrated APPs). When the setting, using the same pen settings among all pen integrated APPs, is set to true. The integrated APPs is responsible to call this function before activities are back to foreground. Once this is called, PenMune module will then restore pen settings by using the global preferences. If the setting is set to false, called this function will restore pen settings by using the local preferences. The pen integrated activities should call this method at their Activity#onResume() method.

public void saveSetting ()

Since: API Level 4.0

Save current pen settings and history pens settings if any. This function is designed for the feature of global pens settings (share the same preferences between all pen integrated APPs). When the setting, using the same pen settings among all pen integrated APPs, is set to true. The integrated APPs is responsible to call this function before activities switch to background. Once this is called, PenMune module will then save current pen preferences for the next foreground pen-integrated activity. If the setting is set to false, called this function will save pen settings in the local preference. The pen integrated activities should call this method at their Activity#onPause() method.

public void setActionActive (int actionId, boolean active)

Since: API Level 4.0

When the applications implement their own painting view and integrate with Pen Menu with different behaviors, they can disable action buttons by calling this function. For example, when the customized painting view doesn't support Clear All function, call this function to grey out Clear All button. Simply, pass the identification of action button and its new state.

Parameters
actionId the identification of action button to set.
active the state of this button. True means to enable and False to grey out this button.
See Also
  • #CLEAR_ACTION_ID
  • #VISIBLE_ACTION_ID
  • #UNDO_ACTION_ID
  • #REDO_ACTION_ID

public void setEraserMode (boolean isEraserMode)

Since: API Level 4.0

Called to enable/disable the Eraser mode. When pressing the upper buttons on the H/W Pen and the its corresponding function is configured to Eraser, applications can call this function to enable Eraser mode and the size of Eraser mode will be the same as the current size of Eraser Pen. Once the button is released, call this function with false parameter to disable Eraser mode and restore pen to previous setting.

Parameters
isEraserMode true to enable eraser mode. false to disable eraser mode.

public void setHighLightConfiguration (IHighlightConfiguration highlightConfig)

Since: API Level 4.0

public void setHintPromptEnabled (boolean enabled)

public void setOnActionPerformListener (OnActionPerformListener listener)

Since: API Level 4.0

Used for registering one listener to Pen Menu. Once registered, when the action buttons on Pen Menu are tapped by pen, the application will receive notification. The current action buttons are listed below.

  • PenMenu#CLEAR_ACTION_ID
  • PenMenu#VISIBLE_ACTION_ID
  • PenMenu#UNDO_ACTION_ID
  • PenMenu#REDO_ACTION_ID
The application can handle these buttons and override the behavior defined by Htc Painging View.

Parameters
listener The OnActionPerformListener object to register

public void setPaintingView (IStrokeNotifyPaintingView paintingView)

Since: API Level 4.0

Associate HtcPaintingView with PenMenu. Once the association is created, any user actions made on PenMenu will apply to Painting Engine, including Pen settings (stroke, size and color) and actions (redo, undo, clear all and set ink opacity)

Parameters
paintingView the painting view to be associated with PenMenu.

public void setPenSetType (int penSetType)

Since: API Level 4.0

When applications implement their own painting view and integrate with HTC Pen Menu with limited pen set, call this function to grey out the predefined pens enabled on the device. Currently, only following pen set are supported for Pen Menu.

Parameters
penSetType the pen set to be set.

public void setVisibility (int visibility)

Since: API Level

public void show (boolean playAnimation, boolean turnOnStickyState)

Since: API Level 4.0

Show PenMenu. Client app can control whether to play animation by playAnimation parameter. And the turnOnStickyState parameter can control whether the sticky state should be forced to turn on. The sticky state is for controlling the behavior to restore PenMenu's previous state when it is hidden. If this flag is turned off, the method has no effect.

Parameters
playAnimation playAnimation true to play showing animation, false to show directly without animation.
turnOnStickyState true to turn on stick state, false to keep sticky state unchanged.
See Also
  • {@link #hide(boolean, boolean)}

Protected Methods

protected void onAttachedToWindow ()

Since: API Level

protected void onDetachedFromWindow ()

Since: API Level