~ubuntu-branches/ubuntu/raring/lmms/raring-proposed

« back to all changes in this revision

Viewing changes to plugins/zynaddsubfx/fltk/src/fl_dnd_win32.cxx

  • Committer: Charlie Smotherman
  • Date: 2012-12-05 22:08:38 UTC
  • mfrom: (33.1.7 lmms_0.4.13)
  • Revision ID: cjsmo@cableone.net-20121205220838-09pjfzew9m5023hr
* New  Upstream release.
  - Minor tweaking to ZynAddSubFX, CALF, SWH plugins  and Stefan Fendt's RC
    filters.
  - Added UI fixes: Magnentic effect of knobs and Piano-roll fixes
  - Updated German localization and copyright year
* debian/lmms-common.install:
  - added /usr/share/applications so the lmms.desktop file will correctly
    install (LP: #863366)
  - This should also fix the Software Center not displaying lmms in sound
    and video (LP: #824231)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// "$Id: fl_dnd_win32.cxx 7563 2010-04-28 03:15:47Z greg.ercolano $"
 
2
// "$Id: fl_dnd_win32.cxx 8028 2010-12-14 19:46:55Z AlbrechtS $"
3
3
//
4
4
// Drag & Drop code for the Fast Light Tool Kit (FLTK).
5
5
//
6
 
// Copyright 1998-2009 by Bill Spitzak and others.
 
6
// Copyright 1998-2010 by Bill Spitzak and others.
7
7
//
8
8
// This library is free software; you can redistribute it and/or
9
9
// modify it under the terms of the GNU Library General Public
41
41
#if defined(__CYGWIN__)
42
42
#include <sys/time.h>
43
43
#include <unistd.h>
44
 
#else
45
 
#include <winsock2.h>
46
44
#endif
47
45
 
48
46
extern char *fl_selection_buffer[2];
54
52
 
55
53
Fl_Window *fl_dnd_target_window = 0;
56
54
 
57
 
// All of the following code requires GCC 3.x or a non-GNU compiler...
58
 
#if !defined(__GNUC__) || __GNUC__ >= 3
59
 
 
60
55
#include <ole2.h>
61
56
#include <shellapi.h>
62
57
#include <shlobj.h>
177
172
    HWND hwnd = fl_xid( (Fl_Window*)w );
178
173
    if (fillCurrentDragData(data)) {
179
174
      int old_event = Fl::e_number;
 
175
      char *a, *b;
 
176
      a = b = currDragData;
 
177
      while (*a) { // strip the CRLF pairs
 
178
        if (*a == '\r' && a[1] == '\n') a++;
 
179
        else *b++ = *a++;
 
180
      }
 
181
      *b = 0;
 
182
      Fl::e_text = currDragData;
 
183
      Fl::e_length = b - currDragData;
180
184
      Fl::belowmouse()->handle(Fl::e_number = FL_PASTE); // e_text will be invalid after this call
181
185
      Fl::e_number = old_event;
182
186
      SetForegroundWindow( hwnd );
210
214
 
211
215
    // clear currDrag* for a new drag event
212
216
    clearCurrentDragData();
213
 
 
214
 
    // fill currDrag* with ASCII data, if available
 
217
    
 
218
    currDragRef = data;
 
219
    // fill currDrag* with UTF-8 data, if available
215
220
    FORMATETC fmt = { 0 };
216
221
    STGMEDIUM medium = { 0 };
217
222
    fmt.tymed = TYMED_HGLOBAL;
218
223
    fmt.dwAspect = DVASPECT_CONTENT;
219
224
    fmt.lindex = -1;
 
225
    fmt.cfFormat = CF_UNICODETEXT;
 
226
    // if it is UNICODE text, return a UTF-8-converted copy of it
 
227
    if ( data->GetData( &fmt, &medium )==S_OK )
 
228
    {
 
229
      void *stuff = GlobalLock( medium.hGlobal );
 
230
      unsigned srclen = 0;
 
231
      const wchar_t *wstuff = (const wchar_t *)stuff;
 
232
      while (*wstuff++) srclen++;
 
233
      wstuff = (const wchar_t *)stuff;
 
234
      unsigned utf8len = fl_utf8fromwc(NULL, 0, wstuff, srclen);
 
235
      currDragSize = utf8len;
 
236
      currDragData = (char*)malloc(utf8len + 1);
 
237
      fl_utf8fromwc(currDragData, currDragSize+1, wstuff, srclen+1); // include null-byte
 
238
      GlobalUnlock( medium.hGlobal );
 
239
      ReleaseStgMedium( &medium );
 
240
      currDragResult = 1;
 
241
      return currDragResult;
 
242
    }
220
243
    fmt.cfFormat = CF_TEXT;
221
 
    // if it is ASCII text, return a copy of it
 
244
    // if it is CP1252 text, return a UTF-8-converted copy of it
222
245
    if ( data->GetData( &fmt, &medium )==S_OK )
223
246
    {
 
247
      int len;
 
248
      char *p, *q, *last;
 
249
      unsigned u;
224
250
      void *stuff = GlobalLock( medium.hGlobal );
225
 
      Fl::e_length = strlen((char*)stuff);
226
 
      Fl::e_text = strdup((char*)stuff);
 
251
      currDragData = (char*)malloc(3 * strlen((char*)stuff) + 10);
 
252
      p = (char*)stuff; 
 
253
      last = p + strlen(p);
 
254
      q = currDragData;
 
255
      while (p < last) {
 
256
        u = fl_utf8decode(p, last, &len);
 
257
        p += len;
 
258
        len = fl_utf8encode(u, q);
 
259
        q += len;
 
260
        }
 
261
      *q = 0;
 
262
      currDragSize = q - currDragData;
 
263
      currDragData = (char*)realloc(currDragData, currDragSize + 1);
227
264
      GlobalUnlock( medium.hGlobal );
228
265
      ReleaseStgMedium( &medium );
229
266
      currDragResult = 1;
253
290
        }
254
291
         *dst=0;
255
292
 
256
 
        Fl::e_text = (char*) malloc(nn * 5 + 1);
 
293
        currDragData = (char*) malloc(nn * 5 + 1);
257
294
//      Fl::e_length = fl_unicode2utf(bu, nn, Fl::e_text);
258
 
        Fl::e_length = fl_utf8fromwc(Fl::e_text, (nn*5+1), bu, nn);
259
 
        Fl::e_text[Fl::e_length] = 0;
 
295
        currDragSize = fl_utf8fromwc(currDragData, (nn*5+1), bu, nn);
 
296
        currDragData[currDragSize] = 0;
260
297
        free(bu);
261
298
 
262
299
//    Fl::belowmouse()->handle(FL_DROP);
378
415
    n = 0;
379
416
  }
380
417
 
381
 
  ~FLEnum(void) {
 
418
  virtual ~FLEnum(void) {
382
419
    n = 0;
383
420
  }
384
421
};
413
450
      delete this;
414
451
    return nTemp;
415
452
  }
416
 
  // GetData currently allows ASCII text through Global Memory only
 
453
  // GetData currently allows UNICODE text through Global Memory only
417
454
  HRESULT STDMETHODCALLTYPE GetData( FORMATETC *pformatetcIn, STGMEDIUM *pmedium ) {
418
455
    if ((pformatetcIn->dwAspect & DVASPECT_CONTENT) &&
419
456
        (pformatetcIn->tymed & TYMED_HGLOBAL) &&
420
 
        (pformatetcIn->cfFormat == CF_TEXT))
 
457
        (pformatetcIn->cfFormat == CF_UNICODETEXT))
421
458
    {
422
 
      HGLOBAL gh = GlobalAlloc( GHND, fl_selection_length[0]+1 );
 
459
      int utf16_len = fl_utf8toUtf16(fl_selection_buffer[0], fl_selection_length[0], 0, 0);
 
460
      HGLOBAL gh = GlobalAlloc( GHND, utf16_len * 2 + 2 );
423
461
      char *pMem = (char*)GlobalLock( gh );
424
 
      memmove( pMem, fl_selection_buffer[0], fl_selection_length[0] );
425
 
      pMem[ fl_selection_length[0] ] = 0;
 
462
      fl_utf8toUtf16(fl_selection_buffer[0], fl_selection_length[0], (unsigned short*)pMem, utf16_len + 1);
426
463
//      HGLOBAL gh = GlobalAlloc( GHND| GMEM_SHARE,
427
464
//                            (fl_selection_length[0]+4) * sizeof(short)
428
465
//                            + sizeof(DROPFILES));
464
501
  {
465
502
    if ((pformatetc->dwAspect & DVASPECT_CONTENT) &&
466
503
        (pformatetc->tymed & TYMED_HGLOBAL) &&
467
 
        (pformatetc->cfFormat == CF_TEXT))
 
504
        (pformatetc->cfFormat == CF_UNICODETEXT))
468
505
      return S_OK;
469
506
    return DV_E_FORMATETC;
470
507
  }
486
523
};
487
524
 
488
525
 
489
 
/**
490
 
   Drag and drop whatever is in the cut-copy-paste buffer.
491
 
 
492
 
   Create a selection first using:
493
 
 
494
 
     Fl::copy(const char *stuff, int len, 0)
495
 
*/
496
526
int Fl::dnd()
497
527
{
498
528
  DWORD dropEffect;
519
549
  if ( ret==DRAGDROP_S_DROP ) return 1; // or DD_S_CANCEL
520
550
  return 0;
521
551
}
522
 
#else
523
 
int Fl::dnd()
524
 
{
525
 
  // Always indicate DnD failed when using GCC < 3...
526
 
  return 1;
527
 
}
528
 
#endif // !__GNUC__ || __GNUC__ >= 3
529
 
 
530
552
 
531
553
//
532
 
// End of "$Id: fl_dnd_win32.cxx 7563 2010-04-28 03:15:47Z greg.ercolano $".
 
554
// End of "$Id: fl_dnd_win32.cxx 8028 2010-12-14 19:46:55Z AlbrechtS $".
533
555
//