I do Win98, as usually.

Here's the patch, I find it very useful for now, that theme for now lacks
other
ways of specifying which mp3 to play (except commandline args - but those
do not even support wildcards...)

I diff'd with -c so one can apply it by hand, not trusting patch.exe to do
job right (and then I don't know if it even would - I have never used PATCH
- except for patching linux kernel, but scripts do that... hmm.

The patch is attached. Probably one will need to update filenames there (or
everything) if one wants this file work with PATCH.EXE.  Teach me diff,
anyone...?


Anyway, this is one messy way to do it.
I specify pContext member in Window class, then in FreeAmpTheme constructor
I initialize it to context after (main) Theme window has been created.
Works for me, but that's real wacky. One should have a better way of
reaching FAContext from Win32Window but I can't think of any.
Now, window procedure in Win32Window looks for WM_DROPFILE requests and
calls DropFiles() then. The DropFiles() proceeds to load files into PLM.
(strange, plm->AddItem(filename) does not work good, but
plm->AddItem(filename,0) works fine. Haven't bothered to look that up yet.
Actually the code for handling WM_DROPFILE is taken from FreeAmpUI. So there.




diff -c -p -r -b -B -t ./include/Window.h 
C:\PROG\freeamp\freex\freeamp-dev\ui\theme\/include/Window.h
*** ./include/Window.h  Thu Oct 07 20:33:51 1999
--- C:\PROG\freeamp\freex\freeamp-dev\ui\theme\/include/Window.h    Fri Oct 08 
23:38:07 1999
*************** using namespace std;
*** 43,48 ****
--- 43,49 ----
  #include "thread.h"
  #include "semaphore.h"
  #include "mutex.h"
+ #include "facontext.h"

  typedef map<string, Control *> ControlMap;
  typedef map<string, Control *>::iterator ControlMapIterator;
*************** class Window
*** 109,114 ****
--- 110,117 ----
        virtual Error GetMousePos(Pos &oMousePos) = 0;
        virtual Error SetWindowPosition(Rect &oWindowRect) = 0;
        virtual Error GetWindowPosition(Rect &oWindowRect) = 0;
+
+           FAContext                                *m_pContext;

      protected:

diff -c -p -r -b -B -t ./src/FreeAmpTheme.cpp 
C:\PROG\freeamp\freex\freeamp-dev\ui\theme\/src/FreeAmpTheme.cpp
*** ./src/FreeAmpTheme.cpp  Thu Oct 07 20:33:57 1999
--- C:\PROG\freeamp\freex\freeamp-dev\ui\theme\/src/FreeAmpTheme.cpp    Sat Oct 09 
01:30:27 1999
*************** FreeAmpTheme::FreeAmpTheme(FAContext * c
*** 82,87 ****
--- 82,88 ----

     LoadFreeAmpTheme();
     SelectWindow(m_oCurrentWindow);
+    m_pWindow->m_pContext=context;
  }

  FreeAmpTheme::~FreeAmpTheme()
diff -c -p -r -b -B -t ./src/Window.cpp 
C:\PROG\freeamp\freex\freeamp-dev\ui\theme\/src/Window.cpp
*** ./src/Window.cpp    Thu Oct 07 20:34:11 1999
--- C:\PROG\freeamp\freex\freeamp-dev\ui\theme\/src/Window.cpp  Fri Oct 08 23:42:07 
1999
*************** Window::Window(Theme *pTheme, string &oN
*** 41,46 ****
--- 41,48 ----
      m_pCanvas = NULL;
      m_pMouseInControl = NULL;
      m_pCaptureControl = NULL;
+
+         m_pContext = NULL;
  }

  Window::~Window(void)
diff -c -p -r -b -B -t ./win32/include/Win32Window.h 
C:\PROG\freeamp\freex\freeamp-dev\ui\theme\/win32/include/Win32Window.h
*** ./win32/include/Win32Window.h   Thu Oct 07 20:34:43 1999
--- C:\PROG\freeamp\freex\freeamp-dev\ui\theme\/win32/include/Win32Window.h Fri Oct 08 
23:26:09 1999
*************** class Win32Window : public Window
*** 61,66 ****
--- 61,67 ----

           virtual HWND  GetWindowHandle(void);
               void  SaveWindowPos(Pos &oPos);
+              void  DropFiles(HDROP dropHandle);

      protected:

diff -c -p -r -b -B -t ./win32/prj/theme.dsp 
C:\PROG\freeamp\freex\freeamp-dev\ui\theme\/win32/prj/theme.dsp
diff -c -p -r -b -B -t ./win32/src/Win32Window.cpp 
C:\PROG\freeamp\freex\freeamp-dev\ui\theme\/win32/src/Win32Window.cpp
*** ./win32/src/Win32Window.cpp Thu Oct 07 20:36:09 1999
--- C:\PROG\freeamp\freex\freeamp-dev\ui\theme\/win32/src/Win32Window.cpp   Sat Oct 09 
01:11:23 1999
***************
*** 22,31 ****
--- 22,35 ----
  ____________________________________________________________________________*/

  #include <stdio.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
  #include "Theme.h"
  #include "Win32Window.h"
  #include "Win32Canvas.h"
  #include "debug.h"
+ #include "playlist.h"
+ #include "errors.h"

  #define DB Debug_v("%s:%d\n", __FILE__, __LINE__);

*************** static LRESULT WINAPI MainWndProc(HWND h
*** 81,86 ****
--- 85,94 ----

              SetTimer(hwnd, 0, 250, NULL);

+             // We want people to be able to drop files on the player
+             DragAcceptFiles(hwnd, TRUE);
+
+
              break;
          }

*************** static LRESULT WINAPI MainWndProc(HWND h
*** 192,197 ****
--- 200,212 ----
              break;
          }

+         case WM_DROPFILES:
+             if(ui->m_pContext) // only if context data are valid
+                 ui->DropFiles((HDROP) wParam);
+             break;
+
+
+
          default:
              result = DefWindowProc( hwnd, msg, wParam, lParam );
              break;
*************** Error Win32Window::Restore(void)
*** 422,424 ****
--- 437,531 ----
      return kError_NoErr;
  }

+ void
+ Win32Window::
+ DropFiles(HDROP dropHandle)
+ {
+     int32 count;
+     char file[MAX_PATH + 1];
+
+     count = DragQueryFile(  dropHandle,
+                             -1L,
+                             file,
+                             sizeof(file));
+
+     //m_target->AcceptEvent(new Event(CMD_Stop));
+
+     for(int32 i = 0; i < count; i++)
+     {
+         DragQueryFile(  dropHandle,
+                         i,
+                         file,
+                         sizeof(file));
+
+         char* pExtension = NULL;
+         vector<char*> fileList;
+         struct _stat st;
+
+         _stat(file, &st);
+
+         if(st.st_mode & _S_IFDIR)
+         {
+             HANDLE findFileHandle = NULL;
+             WIN32_FIND_DATA findData;
+             char findPath[MAX_PATH + 1];
+
+             strcpy(findPath, file);
+             strcat(findPath, "\\*.mp?");
+
+             findFileHandle = FindFirstFile(findPath, &findData);
+
+             if(findFileHandle != INVALID_HANDLE_VALUE)
+             {
+                 do
+                 {
+                     strcpy(findPath, file);
+                     strcat(findPath, "\\");
+                     strcat(findPath, findData.cFileName);
+                     m_pContext->plm->AddItem(findPath);
+
+                 }while(FindNextFile(findFileHandle, &findData));
+
+                 FindClose(findFileHandle);
+             }
+         }
+         else
+         {
+             pExtension = strrchr(file, '.');
+
+             if(pExtension && strcasecmp(pExtension, ".m3u") == 0)
+             {
+                 /*Error error;
+
+                 error = m_plm->ExpandM3U(file, fileList);
+
+                 if(IsError(error))
+                 {
+                     MessageBox(NULL, "Cannot open playlist file", file, MB_OK);
+                 }
+                 else
+                 {
+                     char* item = NULL;
+                     int32 i = 0;
+
+                     while(item = fileList.ItemAt(i++))
+                     {
+                         m_plm->AddItem(item,0);
+                     }
+                 }*/
+             }
+             else
+             {
+                 /*OutputDebugString(file);
+                 OutputDebugString("\r\n");*/
+                 m_pContext->plm->AddItem(file,0);
+             }
+         }
+     }
+
+ //  if(!originalCount)
+ //    {
+ //      m_target->AcceptEvent(new Event(CMD_Play));
+ //  }
+ }

--
Valters "WaTT" Vingolds

Reply via email to