The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

812 lines
29KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. END_JUCE_NAMESPACE
  19. extern juce::JUCEApplicationBase* juce_CreateApplication(); // (from START_JUCE_APPLICATION)
  20. BEGIN_JUCE_NAMESPACE
  21. //==============================================================================
  22. JUCE_JNI_CALLBACK (JuceAppActivity, launchApp, void, (JNIEnv* env, jobject activity,
  23. jstring appFile, jstring appDataDir))
  24. {
  25. android.initialise (env, activity, appFile, appDataDir);
  26. DBG (SystemStats::getJUCEVersion());
  27. JUCEApplicationBase::createInstance = &juce_CreateApplication;
  28. initialiseJuce_GUI();
  29. JUCEApplication* app = dynamic_cast <JUCEApplication*> (JUCEApplicationBase::createInstance());
  30. if (! app->initialiseApp (String::empty))
  31. exit (0);
  32. }
  33. JUCE_JNI_CALLBACK (JuceAppActivity, quitApp, void, (JNIEnv* env, jobject activity))
  34. {
  35. JUCEApplicationBase::appWillTerminateByForce();
  36. android.shutdown (env);
  37. }
  38. //==============================================================================
  39. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
  40. METHOD (drawBitmap, "drawBitmap", "([IIIFFIIZLandroid/graphics/Paint;)V") \
  41. METHOD (getClipBounds, "getClipBounds", "()Landroid/graphics/Rect;")
  42. DECLARE_JNI_CLASS (CanvasMinimal, "android/graphics/Canvas");
  43. #undef JNI_CLASS_MEMBERS
  44. //==============================================================================
  45. #define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD) \
  46. METHOD (setViewName, "setViewName", "(Ljava/lang/String;)V") \
  47. METHOD (layout, "layout", "(IIII)V") \
  48. METHOD (getLeft, "getLeft", "()I") \
  49. METHOD (getTop, "getTop", "()I") \
  50. METHOD (getWidth, "getWidth", "()I") \
  51. METHOD (getHeight, "getHeight", "()I") \
  52. METHOD (getLocationOnScreen, "getLocationOnScreen", "([I)V") \
  53. METHOD (bringToFront, "bringToFront", "()V") \
  54. METHOD (requestFocus, "requestFocus", "()Z") \
  55. METHOD (setVisible, "setVisible", "(Z)V") \
  56. METHOD (isVisible, "isVisible", "()Z") \
  57. METHOD (hasFocus, "hasFocus", "()Z") \
  58. METHOD (invalidate, "invalidate", "(IIII)V") \
  59. METHOD (containsPoint, "containsPoint", "(II)Z") \
  60. DECLARE_JNI_CLASS (ComponentPeerView, "com/juce/ComponentPeerView");
  61. #undef JNI_CLASS_MEMBERS
  62. //==============================================================================
  63. class AndroidComponentPeer : public ComponentPeer
  64. {
  65. public:
  66. AndroidComponentPeer (Component* const component, const int windowStyleFlags)
  67. : ComponentPeer (component, windowStyleFlags),
  68. view (android.activity.callObjectMethod (JuceAppActivity.createNewView, component->isOpaque())),
  69. usingAndroidGraphics (false),
  70. fullScreen (false),
  71. sizeAllocated (0)
  72. {
  73. if (isFocused())
  74. handleFocusGain();
  75. }
  76. ~AndroidComponentPeer()
  77. {
  78. if (MessageManager::getInstance()->isThisTheMessageThread())
  79. {
  80. android.activity.callVoidMethod (JuceAppActivity.deleteView, view.get());
  81. }
  82. else
  83. {
  84. class ViewDeleter : public CallbackMessage
  85. {
  86. public:
  87. ViewDeleter (const GlobalRef& view_)
  88. : view (view_)
  89. {
  90. post();
  91. }
  92. void messageCallback()
  93. {
  94. android.activity.callVoidMethod (JuceAppActivity.deleteView, view.get());
  95. }
  96. private:
  97. GlobalRef view;
  98. };
  99. new ViewDeleter (view);
  100. }
  101. view.clear();
  102. }
  103. void* getNativeHandle() const
  104. {
  105. return (void*) view.get();
  106. }
  107. void setVisible (bool shouldBeVisible)
  108. {
  109. if (MessageManager::getInstance()->isThisTheMessageThread())
  110. {
  111. view.callVoidMethod (ComponentPeerView.setVisible, shouldBeVisible);
  112. }
  113. else
  114. {
  115. class VisibilityChanger : public CallbackMessage
  116. {
  117. public:
  118. VisibilityChanger (const GlobalRef& view_, bool shouldBeVisible_)
  119. : view (view_), shouldBeVisible (shouldBeVisible_)
  120. {
  121. post();
  122. }
  123. void messageCallback()
  124. {
  125. view.callVoidMethod (ComponentPeerView.setVisible, shouldBeVisible);
  126. }
  127. private:
  128. GlobalRef view;
  129. bool shouldBeVisible;
  130. };
  131. new VisibilityChanger (view, shouldBeVisible);
  132. }
  133. }
  134. void setTitle (const String& title)
  135. {
  136. view.callVoidMethod (ComponentPeerView.setViewName, javaString (title).get());
  137. }
  138. void setPosition (int x, int y)
  139. {
  140. const Rectangle<int> pos (getBounds());
  141. setBounds (x, y, pos.getWidth(), pos.getHeight(), false);
  142. }
  143. void setSize (int w, int h)
  144. {
  145. const Rectangle<int> pos (getBounds());
  146. setBounds (pos.getX(), pos.getY(), w, h, false);
  147. }
  148. void setBounds (int x, int y, int w, int h, bool isNowFullScreen)
  149. {
  150. if (MessageManager::getInstance()->isThisTheMessageThread())
  151. {
  152. fullScreen = isNowFullScreen;
  153. w = jmax (0, w);
  154. h = jmax (0, h);
  155. view.callVoidMethod (ComponentPeerView.layout, x, y, x + w, y + h);
  156. }
  157. else
  158. {
  159. class ViewMover : public CallbackMessage
  160. {
  161. public:
  162. ViewMover (const GlobalRef& view_, int x_, int y_, int w_, int h_)
  163. : view (view_), x (x_), y (y_), w (w_), h (h_)
  164. {
  165. post();
  166. }
  167. void messageCallback()
  168. {
  169. view.callVoidMethod (ComponentPeerView.layout, x, y, x + w, y + h);
  170. }
  171. private:
  172. GlobalRef view;
  173. int x, y, w, h;
  174. };
  175. new ViewMover (view, x, y, w, h);
  176. }
  177. }
  178. const Rectangle<int> getBounds() const
  179. {
  180. return Rectangle<int> (view.callIntMethod (ComponentPeerView.getLeft),
  181. view.callIntMethod (ComponentPeerView.getTop),
  182. view.callIntMethod (ComponentPeerView.getWidth),
  183. view.callIntMethod (ComponentPeerView.getHeight));
  184. }
  185. const Point<int> getScreenPosition() const
  186. {
  187. return Point<int> (view.callIntMethod (ComponentPeerView.getLeft),
  188. view.callIntMethod (ComponentPeerView.getTop));
  189. }
  190. const Point<int> localToGlobal (const Point<int>& relativePosition)
  191. {
  192. return relativePosition + getScreenPosition();
  193. }
  194. const Point<int> globalToLocal (const Point<int>& screenPosition)
  195. {
  196. return screenPosition - getScreenPosition();
  197. }
  198. void setMinimised (bool shouldBeMinimised)
  199. {
  200. // n/a
  201. }
  202. bool isMinimised() const
  203. {
  204. return false;
  205. }
  206. void setFullScreen (bool shouldBeFullScreen)
  207. {
  208. Rectangle<int> r (shouldBeFullScreen ? Desktop::getInstance().getMainMonitorArea()
  209. : lastNonFullscreenBounds);
  210. if ((! shouldBeFullScreen) && r.isEmpty())
  211. r = getBounds();
  212. // (can't call the component's setBounds method because that'll reset our fullscreen flag)
  213. if (! r.isEmpty())
  214. setBounds (r.getX(), r.getY(), r.getWidth(), r.getHeight(), shouldBeFullScreen);
  215. component->repaint();
  216. }
  217. bool isFullScreen() const
  218. {
  219. return fullScreen;
  220. }
  221. void setIcon (const Image& newIcon)
  222. {
  223. // n/a
  224. }
  225. bool contains (const Point<int>& position, bool trueIfInAChildWindow) const
  226. {
  227. return isPositiveAndBelow (position.getX(), component->getWidth())
  228. && isPositiveAndBelow (position.getY(), component->getHeight())
  229. && ((! trueIfInAChildWindow) || view.callBooleanMethod (ComponentPeerView.containsPoint,
  230. position.getX(), position.getY()));
  231. }
  232. const BorderSize<int> getFrameSize() const
  233. {
  234. // TODO
  235. return BorderSize<int>();
  236. }
  237. bool setAlwaysOnTop (bool alwaysOnTop)
  238. {
  239. // TODO
  240. return false;
  241. }
  242. void toFront (bool makeActive)
  243. {
  244. view.callVoidMethod (ComponentPeerView.bringToFront);
  245. if (makeActive)
  246. grabFocus();
  247. handleBroughtToFront();
  248. }
  249. void toBehind (ComponentPeer* other)
  250. {
  251. // TODO
  252. }
  253. //==============================================================================
  254. void handleMouseDownCallback (float x, float y, int64 time)
  255. {
  256. lastMousePos.setXY ((int) x, (int) y);
  257. currentModifiers = currentModifiers.withoutMouseButtons();
  258. handleMouseEvent (0, lastMousePos, currentModifiers, time);
  259. currentModifiers = currentModifiers.withoutMouseButtons().withFlags (ModifierKeys::leftButtonModifier);
  260. handleMouseEvent (0, lastMousePos, currentModifiers, time);
  261. }
  262. void handleMouseDragCallback (float x, float y, int64 time)
  263. {
  264. lastMousePos.setXY ((int) x, (int) y);
  265. handleMouseEvent (0, lastMousePos, currentModifiers, time);
  266. }
  267. void handleMouseUpCallback (float x, float y, int64 time)
  268. {
  269. lastMousePos.setXY ((int) x, (int) y);
  270. currentModifiers = currentModifiers.withoutMouseButtons();
  271. handleMouseEvent (0, lastMousePos, currentModifiers, time);
  272. }
  273. //==============================================================================
  274. bool isFocused() const
  275. {
  276. return view.callBooleanMethod (ComponentPeerView.hasFocus);
  277. }
  278. void grabFocus()
  279. {
  280. view.callBooleanMethod (ComponentPeerView.requestFocus);
  281. }
  282. void handleFocusChangeCallback (bool hasFocus)
  283. {
  284. if (hasFocus)
  285. handleFocusGain();
  286. else
  287. handleFocusLoss();
  288. }
  289. void textInputRequired (const Point<int>& position)
  290. {
  291. // TODO
  292. }
  293. //==============================================================================
  294. void handlePaintCallback (JNIEnv* env, jobject canvas)
  295. {
  296. #if USE_ANDROID_CANVAS
  297. if (usingAndroidGraphics)
  298. {
  299. AndroidLowLevelGraphicsContext g (canvas);
  300. handlePaint (g);
  301. }
  302. else
  303. #endif
  304. {
  305. jobject rect = env->CallObjectMethod (canvas, CanvasMinimal.getClipBounds);
  306. const int left = env->GetIntField (rect, RectClass.left);
  307. const int top = env->GetIntField (rect, RectClass.top);
  308. const int right = env->GetIntField (rect, RectClass.right);
  309. const int bottom = env->GetIntField (rect, RectClass.bottom);
  310. env->DeleteLocalRef (rect);
  311. const Rectangle<int> clip (left, top, right - left, bottom - top);
  312. const int sizeNeeded = clip.getWidth() * clip.getHeight();
  313. if (sizeAllocated < sizeNeeded)
  314. {
  315. buffer.clear();
  316. sizeAllocated = sizeNeeded;
  317. buffer = GlobalRef (env->NewIntArray (sizeNeeded));
  318. }
  319. jint* dest = env->GetIntArrayElements ((jintArray) buffer.get(), 0);
  320. if (dest != 0)
  321. {
  322. {
  323. Image temp (new PreallocatedImage (clip.getWidth(), clip.getHeight(),
  324. dest, ! component->isOpaque()));
  325. {
  326. JUCE_DEFAULT_SOFTWARE_RENDERER_CLASS g (temp);
  327. g.setOrigin (-clip.getX(), -clip.getY());
  328. handlePaint (g);
  329. }
  330. }
  331. env->ReleaseIntArrayElements ((jintArray) buffer.get(), dest, 0);
  332. env->CallVoidMethod (canvas, CanvasMinimal.drawBitmap, (jintArray) buffer.get(), 0, clip.getWidth(),
  333. (jfloat) clip.getX(), (jfloat) clip.getY(),
  334. clip.getWidth(), clip.getHeight(), true, (jobject) 0);
  335. }
  336. }
  337. }
  338. void repaint (const Rectangle<int>& area)
  339. {
  340. if (MessageManager::getInstance()->isThisTheMessageThread())
  341. {
  342. view.callVoidMethod (ComponentPeerView.invalidate, area.getX(), area.getY(), area.getRight(), area.getBottom());
  343. }
  344. else
  345. {
  346. class ViewRepainter : public CallbackMessage
  347. {
  348. public:
  349. ViewRepainter (const GlobalRef& view_, const Rectangle<int>& area_)
  350. : view (view_), area (area_)
  351. {
  352. post();
  353. }
  354. void messageCallback()
  355. {
  356. view.callVoidMethod (ComponentPeerView.invalidate, area.getX(), area.getY(), area.getRight(), area.getBottom());
  357. }
  358. private:
  359. GlobalRef view;
  360. const Rectangle<int>& area;
  361. };
  362. new ViewRepainter (view, area);
  363. }
  364. }
  365. void performAnyPendingRepaintsNow()
  366. {
  367. // TODO
  368. }
  369. void setAlpha (float newAlpha)
  370. {
  371. // TODO
  372. }
  373. StringArray getAvailableRenderingEngines()
  374. {
  375. StringArray s (ComponentPeer::getAvailableRenderingEngines());
  376. s.add ("Android Canvas Renderer");
  377. return s;
  378. }
  379. #if USE_ANDROID_CANVAS
  380. int getCurrentRenderingEngine() const
  381. {
  382. return usingAndroidGraphics ? 1 : 0;
  383. }
  384. void setCurrentRenderingEngine (int index)
  385. {
  386. if (usingAndroidGraphics != (index > 0))
  387. {
  388. usingAndroidGraphics = index > 0;
  389. component->repaint();
  390. }
  391. }
  392. #endif
  393. //==============================================================================
  394. static AndroidComponentPeer* findPeerForJavaView (jobject viewToFind)
  395. {
  396. for (int i = getNumPeers(); --i >= 0;)
  397. {
  398. AndroidComponentPeer* const ap = static_cast <AndroidComponentPeer*> (getPeer(i));
  399. jassert (dynamic_cast <AndroidComponentPeer*> (getPeer(i)) != 0);
  400. if (ap->view == viewToFind)
  401. return ap;
  402. }
  403. return nullptr;
  404. }
  405. static ModifierKeys currentModifiers;
  406. static Point<int> lastMousePos;
  407. private:
  408. //==============================================================================
  409. GlobalRef view;
  410. GlobalRef buffer;
  411. bool usingAndroidGraphics, fullScreen;
  412. int sizeAllocated;
  413. class PreallocatedImage : public Image::SharedImage
  414. {
  415. public:
  416. //==============================================================================
  417. PreallocatedImage (const int width_, const int height_, jint* data_, bool hasAlpha_)
  418. : Image::SharedImage (Image::ARGB, width_, height_), data (data_), hasAlpha (hasAlpha_)
  419. {
  420. if (hasAlpha_)
  421. zeromem (data_, width * height * sizeof (jint));
  422. }
  423. ~PreallocatedImage()
  424. {
  425. if (hasAlpha)
  426. {
  427. PixelARGB* pix = (PixelARGB*) data;
  428. for (int i = width * height; --i >= 0;)
  429. {
  430. pix->unpremultiply();
  431. ++pix;
  432. }
  433. }
  434. }
  435. Image::ImageType getType() const { return Image::SoftwareImage; }
  436. LowLevelGraphicsContext* createLowLevelContext() { return new JUCE_DEFAULT_SOFTWARE_RENDERER_CLASS (Image (this)); }
  437. void initialiseBitmapData (Image::BitmapData& bm, int x, int y, Image::BitmapData::ReadWriteMode mode)
  438. {
  439. bm.lineStride = width * sizeof (jint);
  440. bm.pixelStride = sizeof (jint);
  441. bm.pixelFormat = Image::ARGB;
  442. bm.data = (uint8*) (data + x + y * width);
  443. }
  444. SharedImage* clone()
  445. {
  446. PreallocatedImage* s = new PreallocatedImage (width, height, 0, hasAlpha);
  447. s->allocatedData.malloc (sizeof (jint) * width * height);
  448. s->data = s->allocatedData;
  449. memcpy (s->data, data, sizeof (jint) * width * height);
  450. return s;
  451. }
  452. //==============================================================================
  453. private:
  454. jint* data;
  455. HeapBlock<jint> allocatedData;
  456. bool hasAlpha;
  457. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PreallocatedImage);
  458. };
  459. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AndroidComponentPeer);
  460. };
  461. ModifierKeys AndroidComponentPeer::currentModifiers = 0;
  462. Point<int> AndroidComponentPeer::lastMousePos;
  463. //==============================================================================
  464. #define JUCE_VIEW_CALLBACK(returnType, javaMethodName, params, juceMethodInvocation) \
  465. JUCE_JNI_CALLBACK (ComponentPeerView, javaMethodName, returnType, params) \
  466. { \
  467. AndroidComponentPeer* const peer = AndroidComponentPeer::findPeerForJavaView (view); \
  468. if (peer != nullptr) \
  469. peer->juceMethodInvocation; \
  470. }
  471. JUCE_VIEW_CALLBACK (void, handlePaint, (JNIEnv* env, jobject view, jobject canvas), handlePaintCallback (env, canvas))
  472. JUCE_VIEW_CALLBACK (void, handleMouseDown, (JNIEnv*, jobject view, jfloat x, jfloat y, jlong time), handleMouseDownCallback ((float) x, (float) y, (int64) time))
  473. JUCE_VIEW_CALLBACK (void, handleMouseDrag, (JNIEnv*, jobject view, jfloat x, jfloat y, jlong time), handleMouseDragCallback ((float) x, (float) y, (int64) time))
  474. JUCE_VIEW_CALLBACK (void, handleMouseUp, (JNIEnv*, jobject view, jfloat x, jfloat y, jlong time), handleMouseUpCallback ((float) x, (float) y, (int64) time))
  475. JUCE_VIEW_CALLBACK (void, viewSizeChanged, (JNIEnv*, jobject view), handleMovedOrResized())
  476. JUCE_VIEW_CALLBACK (void, focusChanged, (JNIEnv*, jobject view, jboolean hasFocus), handleFocusChangeCallback (hasFocus))
  477. //==============================================================================
  478. ComponentPeer* Component::createNewPeer (int styleFlags, void*)
  479. {
  480. return new AndroidComponentPeer (this, styleFlags);
  481. }
  482. //==============================================================================
  483. bool Desktop::canUseSemiTransparentWindows() noexcept
  484. {
  485. return true;
  486. }
  487. Desktop::DisplayOrientation Desktop::getCurrentOrientation() const
  488. {
  489. // TODO
  490. return upright;
  491. }
  492. void Desktop::createMouseInputSources()
  493. {
  494. // This creates a mouse input source for each possible finger
  495. for (int i = 0; i < 10; ++i)
  496. mouseSources.add (new MouseInputSource (i, false));
  497. }
  498. Point<int> MouseInputSource::getCurrentMousePosition()
  499. {
  500. return AndroidComponentPeer::lastMousePos;
  501. }
  502. void Desktop::setMousePosition (const Point<int>& newPosition)
  503. {
  504. // not needed
  505. }
  506. //==============================================================================
  507. bool KeyPress::isKeyCurrentlyDown (const int keyCode)
  508. {
  509. // TODO
  510. return false;
  511. }
  512. void ModifierKeys::updateCurrentModifiers() noexcept
  513. {
  514. currentModifiers = AndroidComponentPeer::currentModifiers;
  515. }
  516. ModifierKeys ModifierKeys::getCurrentModifiersRealtime() noexcept
  517. {
  518. return AndroidComponentPeer::currentModifiers;
  519. }
  520. //==============================================================================
  521. bool Process::isForegroundProcess()
  522. {
  523. return true; // TODO
  524. }
  525. //==============================================================================
  526. void JUCE_CALLTYPE NativeMessageBox::showMessageBoxAsync (AlertWindow::AlertIconType iconType,
  527. const String& title, const String& message,
  528. Component* associatedComponent)
  529. {
  530. android.activity.callVoidMethod (JuceAppActivity.showMessageBox, javaString (title).get(), javaString (message).get(), (jlong) 0);
  531. }
  532. bool JUCE_CALLTYPE NativeMessageBox::showOkCancelBox (AlertWindow::AlertIconType iconType,
  533. const String& title, const String& message,
  534. Component* associatedComponent,
  535. ModalComponentManager::Callback* callback)
  536. {
  537. jassert (callback != 0); // on android, all alerts must be non-modal!!
  538. android.activity.callVoidMethod (JuceAppActivity.showOkCancelBox, javaString (title).get(), javaString (message).get(),
  539. (jlong) (pointer_sized_int) callback);
  540. return false;
  541. }
  542. int JUCE_CALLTYPE NativeMessageBox::showYesNoCancelBox (AlertWindow::AlertIconType iconType,
  543. const String& title, const String& message,
  544. Component* associatedComponent,
  545. ModalComponentManager::Callback* callback)
  546. {
  547. jassert (callback != 0); // on android, all alerts must be non-modal!!
  548. android.activity.callVoidMethod (JuceAppActivity.showYesNoCancelBox, javaString (title).get(), javaString (message).get(),
  549. (jlong) (pointer_sized_int) callback);
  550. return 0;
  551. }
  552. JUCE_JNI_CALLBACK (JuceAppActivity, alertDismissed, void, (JNIEnv* env, jobject activity,
  553. jlong callbackAsLong, jint result))
  554. {
  555. ModalComponentManager::Callback* callback = (ModalComponentManager::Callback*) callbackAsLong;
  556. if (callback != 0)
  557. callback->modalStateFinished (result);
  558. }
  559. //==============================================================================
  560. void Desktop::setScreenSaverEnabled (const bool isEnabled)
  561. {
  562. // TODO
  563. }
  564. bool Desktop::isScreenSaverEnabled()
  565. {
  566. return true;
  567. }
  568. //==============================================================================
  569. void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars)
  570. {
  571. // TODO
  572. }
  573. //==============================================================================
  574. void Desktop::getCurrentMonitorPositions (Array <Rectangle<int> >& monitorCoords, const bool clipToWorkArea)
  575. {
  576. monitorCoords.add (Rectangle<int> (0, 0, android.screenWidth, android.screenHeight));
  577. }
  578. JUCE_JNI_CALLBACK (JuceAppActivity, setScreenSize, void, (JNIEnv* env, jobject activity,
  579. jint screenWidth, jint screenHeight))
  580. {
  581. const bool isSystemInitialised = android.screenWidth != 0;
  582. android.screenWidth = screenWidth;
  583. android.screenHeight = screenHeight;
  584. if (isSystemInitialised)
  585. Desktop::getInstance().refreshMonitorSizes();
  586. }
  587. //==============================================================================
  588. Image juce_createIconForFile (const File& file)
  589. {
  590. return Image::null;
  591. }
  592. //==============================================================================
  593. void* MouseCursor::createMouseCursorFromImage (const Image&, int, int) { return nullptr; }
  594. void* MouseCursor::createStandardMouseCursor (const MouseCursor::StandardCursorType) { return nullptr; }
  595. void MouseCursor::deleteMouseCursor (void* const /*cursorHandle*/, const bool /*isStandard*/) {}
  596. //==============================================================================
  597. void MouseCursor::showInWindow (ComponentPeer*) const {}
  598. void MouseCursor::showInAllWindows() const {}
  599. //==============================================================================
  600. bool DragAndDropContainer::performExternalDragDropOfFiles (const StringArray& files, const bool canMove)
  601. {
  602. return false;
  603. }
  604. bool DragAndDropContainer::performExternalDragDropOfText (const String& text)
  605. {
  606. return false;
  607. }
  608. //==============================================================================
  609. void LookAndFeel::playAlertSound()
  610. {
  611. }
  612. //==============================================================================
  613. void SystemClipboard::copyTextToClipboard (const String& text)
  614. {
  615. const LocalRef<jstring> t (javaString (text));
  616. android.activity.callVoidMethod (JuceAppActivity.setClipboardContent, t.get());
  617. }
  618. String SystemClipboard::getTextFromClipboard()
  619. {
  620. const LocalRef<jstring> text ((jstring) android.activity.callObjectMethod (JuceAppActivity.getClipboardContent));
  621. return juceString (text);
  622. }
  623. //==============================================================================
  624. const int extendedKeyModifier = 0x10000;
  625. const int KeyPress::spaceKey = ' ';
  626. const int KeyPress::returnKey = 0x0d;
  627. const int KeyPress::escapeKey = 0x1b;
  628. const int KeyPress::backspaceKey = 0x7f;
  629. const int KeyPress::leftKey = extendedKeyModifier + 1;
  630. const int KeyPress::rightKey = extendedKeyModifier + 2;
  631. const int KeyPress::upKey = extendedKeyModifier + 3;
  632. const int KeyPress::downKey = extendedKeyModifier + 4;
  633. const int KeyPress::pageUpKey = extendedKeyModifier + 5;
  634. const int KeyPress::pageDownKey = extendedKeyModifier + 6;
  635. const int KeyPress::endKey = extendedKeyModifier + 7;
  636. const int KeyPress::homeKey = extendedKeyModifier + 8;
  637. const int KeyPress::deleteKey = extendedKeyModifier + 9;
  638. const int KeyPress::insertKey = -1;
  639. const int KeyPress::tabKey = 9;
  640. const int KeyPress::F1Key = extendedKeyModifier + 10;
  641. const int KeyPress::F2Key = extendedKeyModifier + 11;
  642. const int KeyPress::F3Key = extendedKeyModifier + 12;
  643. const int KeyPress::F4Key = extendedKeyModifier + 13;
  644. const int KeyPress::F5Key = extendedKeyModifier + 14;
  645. const int KeyPress::F6Key = extendedKeyModifier + 16;
  646. const int KeyPress::F7Key = extendedKeyModifier + 17;
  647. const int KeyPress::F8Key = extendedKeyModifier + 18;
  648. const int KeyPress::F9Key = extendedKeyModifier + 19;
  649. const int KeyPress::F10Key = extendedKeyModifier + 20;
  650. const int KeyPress::F11Key = extendedKeyModifier + 21;
  651. const int KeyPress::F12Key = extendedKeyModifier + 22;
  652. const int KeyPress::F13Key = extendedKeyModifier + 23;
  653. const int KeyPress::F14Key = extendedKeyModifier + 24;
  654. const int KeyPress::F15Key = extendedKeyModifier + 25;
  655. const int KeyPress::F16Key = extendedKeyModifier + 26;
  656. const int KeyPress::numberPad0 = extendedKeyModifier + 27;
  657. const int KeyPress::numberPad1 = extendedKeyModifier + 28;
  658. const int KeyPress::numberPad2 = extendedKeyModifier + 29;
  659. const int KeyPress::numberPad3 = extendedKeyModifier + 30;
  660. const int KeyPress::numberPad4 = extendedKeyModifier + 31;
  661. const int KeyPress::numberPad5 = extendedKeyModifier + 32;
  662. const int KeyPress::numberPad6 = extendedKeyModifier + 33;
  663. const int KeyPress::numberPad7 = extendedKeyModifier + 34;
  664. const int KeyPress::numberPad8 = extendedKeyModifier + 35;
  665. const int KeyPress::numberPad9 = extendedKeyModifier + 36;
  666. const int KeyPress::numberPadAdd = extendedKeyModifier + 37;
  667. const int KeyPress::numberPadSubtract = extendedKeyModifier + 38;
  668. const int KeyPress::numberPadMultiply = extendedKeyModifier + 39;
  669. const int KeyPress::numberPadDivide = extendedKeyModifier + 40;
  670. const int KeyPress::numberPadSeparator = extendedKeyModifier + 41;
  671. const int KeyPress::numberPadDecimalPoint = extendedKeyModifier + 42;
  672. const int KeyPress::numberPadEquals = extendedKeyModifier + 43;
  673. const int KeyPress::numberPadDelete = extendedKeyModifier + 44;
  674. const int KeyPress::playKey = extendedKeyModifier + 45;
  675. const int KeyPress::stopKey = extendedKeyModifier + 46;
  676. const int KeyPress::fastForwardKey = extendedKeyModifier + 47;
  677. const int KeyPress::rewindKey = extendedKeyModifier + 48;