MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / initMenuBar

Method initMenuBar

CodenameOne/src/com/codename1/ui/MenuBar.java:133–228  ·  view source on GitHub ↗
(Form parent)

Source from the content-addressed store, hash-verified

131 ///
132 /// - `parent`: the associated Form
133 protected void initMenuBar(Form parent) {
134 this.parent = parent;
135 selectMenuItem = createMenuSelectCommand();
136 cancelMenuItem = createMenuCancelCommand();
137 UIManager manager = parent.getUIManager();
138 LookAndFeel lf = manager.getLookAndFeel();
139 //don't minimize the app if it's a Dialog
140 minimizeOnBack = manager.isThemeConstant("minimizeOnBackBool", true) && !(parent instanceof Dialog);
141 hideEmptyCommands = manager.isThemeConstant("hideEmptyCommandsBool", false);
142 menuStyle = manager.getComponentStyle("Menu");
143 setUIID("SoftButton");
144 menuCommand = new Command(manager.localize("menu", "Menu"), lf.getMenuIcons()[2]);
145 // use the slide transition by default
146 if (lf.getDefaultMenuTransitionIn() != null || lf.getDefaultMenuTransitionOut() != null) {
147 transitionIn = lf.getDefaultMenuTransitionIn();
148 transitionOut = lf.getDefaultMenuTransitionOut();
149 } else {
150 transitionIn = CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, true, 300, true);
151 transitionOut = CommonTransitions.createSlide(CommonTransitions.SLIDE_VERTICAL, false, 300, true);
152 }
153 menuCellRenderer = lf.getMenuRenderer();
154 int softkeyCount = Display.getInstance().getImplementation().getSoftkeyCount();
155 thirdSoftButton = Display.getInstance().isThirdSoftButton();
156
157 int commandBehavior = getCommandBehavior();
158 if (softkeyCount > 1 && commandBehavior < Display.COMMAND_BEHAVIOR_BUTTON_BAR) {
159 if (thirdSoftButton) {
160 setLayout(new GridLayout(1, 3));
161 soft = new Button[]{createSoftButton("SoftButtonCenter"), createSoftButton("SoftButtonLeft"), createSoftButton("SoftButtonRight")};
162 main = soft[0];
163 left = soft[1];
164 right = soft[2];
165 if (parent.isRTL()) {
166 right.setUIID("SoftButtonLeft");
167 left.setUIID("SoftButtonRight");
168 addComponent(right);
169 addComponent(main);
170 addComponent(left);
171 } else {
172 addComponent(left);
173 addComponent(main);
174 addComponent(right);
175 }
176 if (isReverseSoftButtons()) {
177 Button b = soft[1];
178 soft[1] = soft[2];
179 soft[2] = b;
180 }
181 } else {
182 setLayout(new GridLayout(1, 2));
183 soft = new Button[]{createSoftButton("SoftButtonLeft"), createSoftButton("SoftButtonRight")};
184 main = soft[0];
185 left = soft[0];
186 right = soft[1];
187 if (parent.isRTL()) {
188 right.setUIID("SoftButtonLeft");
189 left.setUIID("SoftButtonRight");
190 addComponent(right);

Calls 15

getLookAndFeelMethod · 0.95
isThemeConstantMethod · 0.95
getComponentStyleMethod · 0.95
localizeMethod · 0.95
getMenuIconsMethod · 0.95
createSlideMethod · 0.95
getMenuRendererMethod · 0.95
getInstanceMethod · 0.95