PackageManager: Ported GUI to C
authorMaarten Bosma <maarten@bosma.de>
Sat, 16 Apr 2005 17:09:12 +0000 (17:09 +0000)
committerMaarten Bosma <maarten@bosma.de>
Sat, 16 Apr 2005 17:09:12 +0000 (17:09 +0000)
svn path=/trunk/; revision=14637

rosapps/packmgr/gui/main.c [moved from rosapps/packmgr/gui/main.cpp with 91% similarity]
rosapps/packmgr/gui/main.h

similarity index 91%
rename from rosapps/packmgr/gui/main.cpp
rename to rosapps/packmgr/gui/main.c
index 7e33cca..5cfe8eb 100644 (file)
@@ -111,12 +111,20 @@ int AddItem (int id, const char* name, int parent, int icon)
 // Load the Help from file and display it\r
 void Help (void)\r
 {\r
-       string source;\r
+       int i;\r
+       char buffer [2000];\r
+       FILE* file = fopen ("help.txt", "r");\r
 \r
-       ifstream file("help.txt", ios_base::in);\r
-       getline(file, source, '\0');\r
+       if(!file)\r
+               return;\r
 \r
-       SetText(source.c_str());\r
+       for(i=0; i<2000; i++)\r
+       {\r
+               buffer[i] = getc(file);\r
+               if(!buffer[i]) break;\r
+       }\r
+\r
+       SetText(buffer);\r
 }\r
 \r
 // Create our Controls\r
@@ -225,19 +233,23 @@ int SetButton (DWORD id, BOOL state)
 // Set the text of the text box\r
 int SetText (const char* text) \r
 {\r
+       int i, j;\r
+       char buffer [2000];\r
+\r
        if(!text)\r
                return 1;\r
 \r
-       int i = 0;\r
-       string source = text;\r
-\r
        // the windows does not need "\n"\r
        // for new lines but "\r\n"\r
-       for(i=0; source[i]; i++)\r
-               if(source[i]=='\n' && source[i]!='\r')\r
-                       source.insert (i++, "\r");\r
+       for(i=0,j=0; text[i]; i++,j++)\r
+       {\r
+               buffer[j] = text[i];\r
+               if(buffer[j] == '\n')\r
+                       buffer[++j] = '\r';\r
+       }\r
+       buffer[i] = 0;\r
 \r
-       SetWindowTextA(hEdit, source.c_str());\r
+       SetWindowTextA(hEdit, buffer);\r
 \r
     return 0;\r
 }\r
@@ -279,7 +291,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                                SetText(PML_GetDescription (tree, selected));\r
                        }\r
 \r
-                       else if ((int)(((LPNMHDR)lParam)->code) == NM_RCLICK) // <= ahhh LISP\r
+                       else if ((int)(((LPNMHDR)lParam)->code) == NM_RCLICK) // <= aarrggg LISP\r
                        { \r
                                // which item has been click on\r
                                HTREEITEM item = TreeView_GetDropHilight(hTree);\r
@@ -331,9 +343,6 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
                        // Options\r
                        else if(LOWORD(wParam)==8)\r
                                DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_OPTIONS), hwnd, OptionsProc);\r
-\r
-                       else\r
-                               MessageBox(0,0,0,0);\r
                }\r
                break;\r
 \r
index 0a82ae2..e02f89a 100644 (file)
@@ -5,12 +5,10 @@
 ///////////////////////////////////////////////////\r
 \r
 #include <windows.h>\r
-#include <ntos/keyboard.h>\r
 #include <commctrl.h>\r
-#include <iostream>\r
-#include <fstream>\r
+#include <stdio.h>\r
 \r
-#include <package.hpp>\r
+#include <package.h>\r
 #include "resource.h"\r
 \r
 /* Some Variables */ \r