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.

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