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
30KB

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