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.

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