Mobile API Reference  MicroStrategy 2019
MSIUtility Class Reference

#import <MSIUtility.h>

Inheritance diagram for MSIUtility:

Class Methods

(bool) + stringToRGB:withRed:andGreen:andBlue:
 
(int) + hexStringToInt:
 
(int) + intFromBGRToRGB:
 
(void) + IntToRGB:withRed:andGreen:andBlue:
 
(UIColor *) + colorFromInteger:
 
(UIColor *) + colorFromInteger:rgbReversed:
 
(CGSize) + GetMeasuredTextSize:withFontSize:withFontName:
 
(UIView *) + getRootViewer:
 
(int) + compCGFloat:right:
 
(CGFloat) + GetTextSizeByUILabel:withFontSize:withFontName:
 
(void) + rgbToHsv:withG:andB:andH:andS:andV:
 
(void) + hsvToRgb:withS:andV:andR:andG:andB:
 
(BOOL+ colorIsBright:withGreen:withBlue:
 
(int) + colorAdjust:withDarker:
 
(int) + getCalculatedGradient:
 
(void) + IntToRGB2:withRed:andGreen:andBlue:
 
(void) + colorToRgb:withR:andG:andB:
 
(NSInteger) + getContrastColor:
 
(NSInteger) + darkerHex:percentage:
 
(NSInteger) + getColorInGradientRange:startColor:endColor:
 
(CGSize) + GetTextWidthHeightByUILabel:withFontSize:withFontName:
 
(void) + nextMonth:withYear:toNextMonth:toYear:
 
(void) + lastMonth:withYear:toLastMonth:toYear:
 
(int) + daysOfMonth:withYear:
 
(int) + colorAdjust:withVFactor:
 
(NSString *) + findImageNameFromPath:
 
(float) + getZoomScale
 
(BOOL+ isDashboardZooming
 
(BOOL+ isDuringDoubleTapOrPinchZooming
 
(void) + updateZoomScale:
 
(void) + updateHighScaleFactorToViews:
 
(void) + updateScaleFactorToViews:allWithGivenFactor:
 
(RootViewerContainer *) + getRootViewerContainer
 
(float) + distanceBetween:andPoint:
 
(BOOL+ isLandscape
 
(void) + markIndication:inRect:
 
(bool) + supportRefreshWindowForEveryMoveInGrid
 
(void) + setRotatingStatus:
 
(int) + rotatingStatus
 
(void) + updateSubFieldGroupViewers:
 
(UIImage *) + createGrayScaleImageFromImage:
 
(void) + setIsAirplay:
 
(bool) + IsAirplay
 
(CGRect) + getBestResolution:
 
(float) + getScaleRatio
 
(void) + setScaleRatio:
 
(void) + setSDKScaleRatio:
 
(void) + resetSDKScaleRatio
 
(bool) + willUseLaserPointer
 
(EnumLogOption+ getLogOption
 
(void) + printSubtree:
 
(void) + setLandscape:
 
(void) + setHonestZoomScale:
 
(float) + getHonestZoomScale
 
(float) + getLastHonestZoomScale
 
(void) + setZoomScale:
 
(void) + setIsDuringDoubleTapOrPinchZooming:
 
(void) + setRootViewerContainer:
 
(std::string) + WToString:
 
(float) + inchesToPixles:
 
(float) + inchesToPixles:scaleRatio:
 
(float) + inchesToPixlesWithoutRound:
 
(float) + inchesToPixlesWithoutRound:scaleRatio:
 
(float) + pixelsToInches:
 
(float) + pointsToPixles:scaleRatio:
 
(float) + pointsToPixlesWithoutRound:scaleRatio:
 
(BOOL+ isIPad
 
(NSString *) + getDescriptionStringFromDataSet:
 
(CGSize) + getUISwitchFrameSize
 
(void) + setBarButtonItems:toNavigationItem:atLeft:animated:
 
(BOOL+ isRendering
 
(void) + setIsRendering:
 

Detailed Description

A singleton with a variety of class methods for handling colors, strings, device info, etc.

See also
StringUtils, Generic

Method Documentation

◆ colorAdjust:withDarker:()

+ (int) colorAdjust: (int)  oriColor
withDarker: (BOOL isDarker 

Tune the given color brighter or darker

Parameters
inputoriColor, represent by integer with 'RGB' order
inputisDarker, indicating we should tune the color darker or brighter
Returns
tuned color

◆ colorAdjust:withVFactor:()

+ (int) colorAdjust: (int)  oriColor
withVFactor: (float)  vFactor 

Tune the given color brighter or darker

Parameters
inputoriColor, represent by integer with 'RGB' order
inputvFactor, indicating the percentage of current lightness, if vFactor less than 1, tune oriColor darker, else brighter
Returns
tuned color

◆ colorFromInteger:()

+ (UIColor*) colorFromInteger: (NSInteger)  iValue

Reture UIColor instance from a integer save in 'RGB' order

Parameters
iValue,integerrepresenting a color saved in 'RGB' order
Returns
UIColor instance.

◆ colorFromInteger:rgbReversed:()

+ (UIColor*) colorFromInteger: (NSInteger)  iValue
rgbReversed: (BOOL iIsRGBReversed 

Please note the color info is saved as BGR instead of RGB in the grid and CE Returns UIColor instance from a integer save in 'RGB' order

Parameters
iValue,integerrepresenting a color
iIsRGBReversed,ifiIsRGBReversed is TRUE, indicating color is saved in order 'BGR' in iValue
Returns
UIColor instance.

◆ colorIsBright:withGreen:withBlue:()

+ (BOOL) colorIsBright: (int)  redComp
withGreen: (int)  greenComp
withBlue: (int)  blueComp 

Determine whether the given color is a bright color or not

Parameters
inputredComp, red componet
outputgreenComp, green componet
outputblueComp, blue componet
Returns
TRUE if (redComp,greenComp,blueComp) is a bright color

◆ colorToRgb:withR:andG:andB:()

+ (void) colorToRgb: (UIColor *)  ipColor
withR: (CGFloat *)  opR
andG: (CGFloat *)  opG
andB: (CGFloat *)  opB 

Extract R, G, B values in RGB color space from a UIColor object. The output parameters *opR, *opG, *opB are all in [0, 1].

Parameters
ipColorthe UIColor object.
opRoutput R value in RGB color space.
opGoutput G value in RGB color space.
opBoutput B value in RGB color space.

◆ compCGFloat:right:()

+ (int) compCGFloat: (CGFloat)  iLeft
right: (CGFloat)  iRight 

Compare two float numbers. If the difference between two numbers is inside the accuracy of float number (FLT_EPSILON), they are treated as equal.

Parameters
iLeftthe first number to be compared.
iRightthe second number to be comared.
Returns
1 if iLeft is bigger than iRight; -1 if iLeft is smaller than iRight; 0 if equal.

◆ createGrayScaleImageFromImage:()

+ (UIImage*) createGrayScaleImageFromImage: (UIImage *)  image

This method is used to create a new grayed image based on the source image provided in the parameter.

Parameters
imagethe source image that is to be translated.
Returns
the destination image that is grayed from the source image.

◆ darkerHex:percentage:()

+ (NSInteger) darkerHex: (NSInteger)  hex
percentage: (CGFloat)  prc 

◆ daysOfMonth:withYear:()

+ (int) daysOfMonth: (int)  month
withYear: (int)  year 

Get the number of days in a given month

Parameters
inputmonth, given month ranging from 1 to 12
inputyear, given year represented by four digits
Returns
the number of days in the given month

◆ distanceBetween:andPoint:()

+ (float) distanceBetween: (CGPoint)  a
andPoint: (CGPoint)  b 

Calculate the distace between two CGPoints.

Parameters
athe first CGPoint.
bthe second CGPoint.
Returns
the distance between the two points.

◆ findImageNameFromPath:()

+ (NSString*) findImageNameFromPath: (NSString *)  imagePath

Get file name of image by parsing the given path

Parameters
inputimagePath, the full path of image
Returns
image name.

◆ getBestResolution:()

+ (CGRect) getBestResolution: (UIScreen *)  screen

Get the largest resolution for a screen instance

Parameters
screenthe screen instance
Returns
the largest resolution for a screen instance

◆ getCalculatedGradient:()

+ (int) getCalculatedGradient: (int)  oriColor

◆ getColorInGradientRange:startColor:endColor:()

+ (NSInteger) getColorInGradientRange: (float)  index
startColor: (NSInteger)  iStartColor
endColor: (NSInteger)  iEndColor 

◆ getContrastColor:()

+ (NSInteger) getContrastColor: (NSInteger)  iGivenColor

◆ getDescriptionStringFromDataSet:()

+ (NSString*) getDescriptionStringFromDataSet: (void *)  dataSet

For the scaling to width feature on iPhone. Get the scale ratio for the current layout.

Returns
the value of the scale ratio for the current layout. For the scaling to width feature on iPhone. Set the scale ratio for the current layout. It is calculated in the layout section viewer.
Parameters
ratioThe value of the scale ratio for the current layout. Get description From DataSet, used in accessibility
inputdataSet
Returns
accessibility string from dataSet, read as grid

Provided by category MSIUtility(Internal).

◆ getHonestZoomScale()

+ (float) getHonestZoomScale

Provided by category MSIUtility(Internal).

◆ getLastHonestZoomScale()

+ (float) getLastHonestZoomScale

Provided by category MSIUtility(Internal).

◆ getLogOption()

+ (EnumLogOption) getLogOption

Provided by category MSIUtility(Internal).

◆ GetMeasuredTextSize:withFontSize:withFontName:()

+ (CGSize) GetMeasuredTextSize: (const char *)  ipString
withFontSize: (float)  iFontSize
withFontName: (const char *)  ipFontName 

To layout the text under specified font type and font size.

Parameters
ipString,thetext to layout.
iFontSize,todenote how big the font is.
ipFontName,todenote which font is chosen to render the font. the size (bounding rectangle) of the text.

◆ getRootViewer:()

+ (UIView*) getRootViewer: (UIView *)  iView

Get the root view of the view hierarchy that the specific view is in.

Parameters
iViewthe specific view of the view hierarchy; nil is allowed.
Returns
the root view of the view hierarchy that the specific view is in. If iView is nil, return nil; if iView is the root view, return itself.

◆ getRootViewerContainer()

+ (RootViewerContainer*) getRootViewerContainer

Get the RootViewerContainer view. RootViewerContainer view is the root view for a dashboard.

Returns
the RootViewerContainer view in the view hierarchy.

◆ getScaleRatio()

+ (float) getScaleRatio

◆ GetTextSizeByUILabel:withFontSize:withFontName:()

+ (CGFloat) GetTextSizeByUILabel: (NSString *)  ipString
withFontSize: (float)  iFontSize
withFontName: (NSString *)  ipFontName 

Get text width by set the string to a UILabel and fitToSize.

Parameters
inputipString the NSString to measure
inputiFontSize font size used to display the ipString
inputipFontName font name used to get the font which is used to display the text.
Returns
the width of text with given font and string

◆ GetTextWidthHeightByUILabel:withFontSize:withFontName:()

+ (CGSize) GetTextWidthHeightByUILabel: (NSString *)  ipString
withFontSize: (float)  iFontSize
withFontName: (NSString *)  ipFontName 

Get text size by set the string to a UILabel and fitToSize.

Parameters
inputipString the NSString to measure
inputiFontSize font size used to display the ipString
inputipFontName font name used to get the font which is used to display the text.
Returns
the size of text with given font and string

◆ getUISwitchFrameSize()

+ (CGSize) getUISwitchFrameSize

Get UISwitch frame size.

Provided by category MSIUtility(Internal).

◆ getZoomScale()

+ (float) getZoomScale

Get the current zoom scale of dashboard. The returned value is valid only after current zoom gesture (double-tapping or pinching) ends.

Returns
the current zoom scale of dashboard.

◆ hexStringToInt:()

+ (int) hexStringToInt: (NSString *)  ipString

◆ hsvToRgb:withS:andV:andR:andG:andB:()

+ (void) hsvToRgb: (CGFloat)  iH
withS: (CGFloat)  iS
andV: (CGFloat)  iV
andR: (CGFloat *)  opR
andG: (CGFloat *)  opG
andB: (CGFloat *)  opB 

Convert H, S, V values in HSV color space to R, G, B values in RGB color space. The parameters iH, iS, iV, *opR, *opG, *opB are all in [0, 1].

Parameters
iHinput H value in HSV color space.
iSinput S value in HSV color space.
iVinput V value in HSV color space.
opRoutput R value in RGB color space.
opGoutput G value in RGB color space.
opBoutput B value in RGB color space.

◆ inchesToPixles:()

+ (float) inchesToPixles: (float)  iInches

Map the length in inches to pixles.

Parameters
iInches,theinput length in inches to be mapped.
Returns
the mapped length in pixles.

Provided by category MSIUtility(Internal).

◆ inchesToPixles:scaleRatio:()

+ (float) inchesToPixles: (float)  iInches
scaleRatio: (float)  iScaleRatio 

Provided by category MSIUtility(Internal).

◆ inchesToPixlesWithoutRound:()

+ (float) inchesToPixlesWithoutRound: (float)  iInches

Special case. Need return float without round.

Provided by category MSIUtility(Internal).

◆ inchesToPixlesWithoutRound:scaleRatio:()

+ (float) inchesToPixlesWithoutRound: (float)  iInches
scaleRatio: (float)  iScaleRatio 

Provided by category MSIUtility(Internal).

◆ intFromBGRToRGB:()

+ (int) intFromBGRToRGB: (int)  iValue

Get another integer repsenting the same color from order 'BGR' to 'RGB'

Parameters
inputiValue, represent by integer with 'BGR' order
Returns
the color represented by integer in 'RGB' order

◆ IntToRGB2:withRed:andGreen:andBlue:()

+ (void) IntToRGB2: (int)  iValue
withRed: (CGFloat *)  opRed
andGreen: (CGFloat *)  opGreen
andBlue: (CGFloat *)  opBlue 

Get components of a given color

Parameters
inputiValue, represent by integer with 'RGB' order
outputopRed, red componet of color 'iValue'
outputopGreen, green componet of color 'iValue'
outputopBlue, blue componet of color 'iValue'

◆ IntToRGB:withRed:andGreen:andBlue:()

+ (void) IntToRGB: (int)  iValue
withRed: (CGFloat *)  opRed
andGreen: (CGFloat *)  opGreen
andBlue: (CGFloat *)  opBlue 

Returns components of a given color

Parameters
inputiValue, represent by integer in 'BGR' order
outputopRed, red componet of color 'iValue'
outputopGreen, green componet of color 'iValue'
outputopBlue, blue componet of color 'iValue'

◆ IsAirplay()

+ (bool) IsAirplay

Get whether it is in Airplay mode now

Returns
whether it is Airplay mode now

◆ isDashboardZooming()

+ (BOOL) isDashboardZooming

Check whether the dashboard is not in 100% scale.

Returns
YES if zoom scale of dashboard is not 100%, NO if it is 100% scale.

◆ isDuringDoubleTapOrPinchZooming()

+ (BOOL) isDuringDoubleTapOrPinchZooming

Check whether the dashboard is being zoomed by pinching or double-tapping gesture. Note the end of double-tapping are defined as the end of zooming animation.

Returns
YES if zooming gesture is not finished, NO if zooming gesture is finished.

◆ isIPad()

+ (BOOL) isIPad

Get whether the device is iPad or iPhone.

Returns
true when the device is iPad, false otherwise.

Provided by category MSIUtility(Internal).

◆ isLandscape()

+ (BOOL) isLandscape

Check whether the current view hierarchy is in landscape mode or not.

Returns
YES if the current view hierachy is in landscape mode; Otherwise, NO.

◆ isRendering()

+ (BOOL) isRendering

Get whether app is rendering any dashboard.

Returns
the value of the scale ratio for the current layout.

Provided by category MSIUtility(Internal).

◆ lastMonth:withYear:toLastMonth:toYear:()

+ (void) lastMonth: (int)  month
withYear: (int)  year
toLastMonth: (int *)  lastMonth
toYear: (int *)  lastYear 

Get the value of last month, according to a given month. e.g., input month = 12, year = 2012, output lastMonth = 11, lastYear = 2012

Parameters
inputmonth, given month ranging from 1 to 12
inputyear, given year represented by four digits
outputlastMonth ranging from 1 to 12
outputlastYear represented by four digits

◆ markIndication:inRect:()

+ (void) markIndication: (CGContextRef)  iCurrentContext
inRect: (CGRect)  iRect 

Mark a grid cell with orange triangle flag on the upper right corner

Parameters
iCurrentContextthe CGContext instance where the drawing will happen
iRectthe anchor rectagle within which to draw the orange triangle

◆ nextMonth:withYear:toNextMonth:toYear:()

+ (void) nextMonth: (int)  month
withYear: (int)  year
toNextMonth: (int *)  nextMonth
toYear: (int *)  nextYear 

Get the value of next month, according to a given month. e.g., input month = 12, year = 2012, output nextMonth = 1, nextYear = 2013

Parameters
inputmonth, given month ranging from 1 to 12
inputyear, given year represented by four digits
outputnextMonth ranging from 1 to 12
outputnextYear represented by four digits

◆ pixelsToInches:()

+ (float) pixelsToInches: (float)  iPixels

Map the length in pixles to inches.

Parameters
iPixels,theinput length in pixles to be mapped.
Returns
the mapped length in inches.

Provided by category MSIUtility(Internal).

◆ pointsToPixles:scaleRatio:()

+ (float) pointsToPixles: (float)  iPoints
scaleRatio: (float)  iScaleRatio 

Map the length in points to pixles.

Parameters
iPoints,theinput length in points to be mapped.
Returns
the mapped length in pixles.

Provided by category MSIUtility(Internal).

◆ pointsToPixlesWithoutRound:scaleRatio:()

+ (float) pointsToPixlesWithoutRound: (float)  iPoints
scaleRatio: (float)  iScaleRatio 

Special case. Need return float without round.

Provided by category MSIUtility(Internal).

◆ printSubtree:()

+ (void) printSubtree: (UIView *)  ipView

Provided by category MSIUtility(Internal).

◆ resetSDKScaleRatio()

+ (void) resetSDKScaleRatio

◆ rgbToHsv:withG:andB:andH:andS:andV:()

+ (void) rgbToHsv: (CGFloat)  iR
withG: (CGFloat)  iG
andB: (CGFloat)  iB
andH: (CGFloat *)  opH
andS: (CGFloat *)  opS
andV: (CGFloat *)  opV 

Convert R, G, B values in RGB color space to H, S, V values in HSV color space. The parameters iR, iG, iB, *opH, *opS, *opV are all in [0, 1].

Parameters
iRinput R value in RGB color space.
iGinput G value in RGB color space.
iBinput B value in RGB color space.
opHoutput H value in HSV color space.
opSoutput S value in HSV color space.
opVoutput V value in HSV color space.

◆ rotatingStatus()

+ (int) rotatingStatus

◆ setBarButtonItems:toNavigationItem:atLeft:animated:()

+ (void) setBarButtonItems: (NSArray *)  iButtonArray
toNavigationItem: (UINavigationItem *)  iNavigationItem
atLeft: (BOOL iAtLeft
animated: (BOOL iAnimated 

Set the BarButtonItems to one side of a navigationItem. If iOS is earlier than 5.0, then only the first barButtonItem is set.

Parameters
iButtonArraythe BarButtonItems
iNavigationItemthe navigationItem
iAtLeftwhether set it at the left side
iAnimatedwhether we set the BarButtonItems animatedly

Provided by category MSIUtility(Internal).

◆ setHonestZoomScale:()

+ (void) setHonestZoomScale: (float)  scale

Provided by category MSIUtility(Internal).

◆ setIsAirplay:()

+ (void) setIsAirplay: (bool)  _isAirplay

Set whether it is in Airplay mode now

Parameters
_isAirplaywhether it is Airplay mode now

◆ setIsDuringDoubleTapOrPinchZooming:()

+ (void) setIsDuringDoubleTapOrPinchZooming: (BOOL isDuring

Provided by category MSIUtility(Internal).

◆ setIsRendering:()

+ (void) setIsRendering: (BOOL rendering

Set whether app is rendering a dashboard.

Parameters
ratioThe value of the scale ratio for the current layout.

Provided by category MSIUtility(Internal).

◆ setLandscape:()

+ (void) setLandscape: (BOOL isLandscape

Provided by category MSIUtility(Internal).

◆ setRootViewerContainer:()

+ (void) setRootViewerContainer: (RootViewerContainer *)  iRootView

Provided by category MSIUtility(Internal).

◆ setRotatingStatus:()

+ (void) setRotatingStatus: (int)  status

◆ setScaleRatio:()

+ (void) setScaleRatio: (float)  ratio

◆ setSDKScaleRatio:()

+ (void) setSDKScaleRatio: (float)  ratio

◆ setZoomScale:()

+ (void) setZoomScale: (float)  scale

Provided by category MSIUtility(Internal).

◆ stringToRGB:withRed:andGreen:andBlue:()

+ (bool) stringToRGB: (NSString *)  ipString
withRed: (float *)  opRed
andGreen: (float *)  opGreen
andBlue: (float *)  opBlue 

Map a string value to its corresponding RGB representation.

Parameters
ipString,thestring to be mapped. This one should NOT be null.
opRed,thered component value in the mapped RGB result.
opGreen,thegreen component value in the mapped RGB result.
opBlue,theblue component value in the mapped RGB result.
Returns
TRUE means a successful conversion and FALSE otherwise.

◆ supportRefreshWindowForEveryMoveInGrid()

+ (bool) supportRefreshWindowForEveryMoveInGrid

For grid use, whether we will refresh current window screen for each UIScrollView Move in Grid. Basically, it checked whether it's iPad2 device or not.

Returns
true if we should refresh the grid for every scroll view movement for this device, otherwise false. The every movement is defined by delegate method scrollViewDidScroll

◆ updateHighScaleFactorToViews:()

+ (void) updateHighScaleFactorToViews: (UIView *)  iView

Update the resolution of the given view and its subviews to make them clear (i.e., treat them all as on-screen views).

Use allWithGivenFactor:(CGFloat) to update resolutions.

Parameters
iViewthe specific view of the view hierarchy; nil is not allowed.

◆ updateScaleFactorToViews:allWithGivenFactor:()

+ (void) updateScaleFactorToViews: (UIView *)  iView
allWithGivenFactor: (CGFloat)  iFactor 

Update the resolution of the given view and its subviews to given value.

Parameters
iViewthe specific view of the view hierarchy; nil is not allowed.
iFactorthe given scaleFactor.

◆ updateSubFieldGroupViewers:()

+ (void) updateSubFieldGroupViewers: (UIView *)  ipView

This method is used to update field group viewer's width, if the field group viewer's width mode is by percent

Parameters
thefield group viewer that will be updated

◆ updateZoomScale:()

+ (void) updateZoomScale: (UIView *)  iView

Update the given view and its subviews to proper resolution: make the views on-screen clear and make the views off-screen blurry.

Parameters
iViewthe specific view of the view hierarchy. If you pass nil or an NSNull object, then it will use the content view of RootViewerContainer instead.

◆ willUseLaserPointer()

+ (bool) willUseLaserPointer

Get whether the app will enter laser pointer mode

Returns
whether the app will enter laser pointer mode

◆ WToString:()

+ (string MSIUtility(Internal)): (const wchar_t *)  ipWSource

Provided by category MSIUtility(Internal).