diff --git a/rosapps/devutils/vmingw/.cvsignore b/rosapps/devutils/vmingw/.cvsignore new file mode 100644 index 00000000000..94d6bf97040 --- /dev/null +++ b/rosapps/devutils/vmingw/.cvsignore @@ -0,0 +1,6 @@ +*.o +*.sym +*.coff +*.exe +*.ini +*.bat diff --git a/rosapps/devutils/vmingw/CList.cpp b/rosapps/devutils/vmingw/CList.cpp new file mode 100644 index 00000000000..a9666805be4 --- /dev/null +++ b/rosapps/devutils/vmingw/CList.cpp @@ -0,0 +1,328 @@ +/******************************************************************** +* Class: CList.cpp. This is part of WinUI. +* +* Purpose: A simple way to create doubly linked lists. +* +* Authors: Originally coded by Claude Catonio. +* +* License: Original code was public domain. +* Present revised CList classes are covered by GNU General Public License. +* +* Revisions: +* Manu B. 10/05/01 Terms was translated to English. +* Manu B. 10/16/01 Add CList::Destroy(CNode *node) method. +* Manu B. 11/12/01 Add InsertBefore/InsertAfter methods. +* Manu B. 11/17/01 First() & Last() now returns an integer value. +* Manu B. 11/19/01 CNode::Destroy() returns next node by default. +* Manu B. 12/28/01 Simplify CList, add InsertSorted(). +* Manu B. 03/13/02 Suppress CNode methods, next and prev are public. +* Manu B. 03/28/02 Add Compare(). +* +********************************************************************/ +#include "CList.h" + +/******************************************************************** +* Class: CList. +* +* Purpose: List management. +* +* Revisions: +* +********************************************************************/ +CList::~CList(){ + //MessageBox (0, "CList", "destructor", MB_OK); + while (first != NULL){ + current = first; + first = first->next; + delete current; + } + current = last = first; + count = 0; +} + +/******************************************************************** +* Browse the list. +********************************************************************/ +CNode * CList::First(){ + current = first; +return current; +} + +CNode * CList::Last(){ + current = last; +return current; +} + +CNode * CList::Prev(){ + // Empty list ? + if (first != NULL){ + if(current->prev == NULL){ + // No previous node. + return NULL; + }else{ + // A previous one. + current = current->prev; + return current; + } + } +return NULL; +} + +CNode * CList::Next(){ + // Empty list ? + if (first != NULL){ + if(current->next == NULL){ + // No next node. + return NULL; + }else{ + // A next one. + current = current->next; + return current; + } + } +return NULL; +} + +/******************************************************************** +* Insert nodes. +********************************************************************/ +void CList::InsertFirst(CNode *node){ + if(first == NULL){ + // Empty list. + first = last = node; + }else{ + // Set node pointers. + node->prev = NULL; + node->next = first; + // Insert in the list. + first->prev = node; + first = node; + } + // Set current node, increment the node counter. + current = node; + count++; +} + +void CList::InsertLast(CNode *node){ + if(first == NULL){ + // Empty list. + first = last = node; + }else{ + // Set node pointers. + node->prev = last; + node->next = NULL; + // Insert in the list. + last->next = node; + last = node; + } + // Set current node, increment the node counter. + current = node; + count++; +} + +void CList::InsertBefore(CNode *node){ + if(first == NULL){ + // Empty list. + first = last = node; + }else{ + if (current == first) + first = node; + // Set node pointers. + node->prev = current->prev; + node->next = current; + // Insert in the list. + if (node->prev) + node->prev->next = node; + current->prev = node; + } + // Set current node, increment the node counter. + current = node; + count++; +} + +void CList::InsertAfter(CNode *node){ + if(first == NULL){ + // Empty list. + first = last = node; + }else{ + if (current == last) + last = node; + // Set node pointers. + node->prev = current; + node->next = current->next; + // Insert in the list. + if (node->next) + node->next->prev = node; + current->next = node; + } + // Set current node, increment the node counter. + current = node; + count++; +} + +bool CList::InsertSorted(CNode * newNode){ + // Get the current node. + CNode * currentNode = GetCurrent(); + int cmpResult; + + if(!currentNode){ + // The list is empty, InsertFirst() and return. + InsertFirst(newNode); + return true; + } + + // Compare new node and current node data to know if we must parse Up + // or Down from current node. + cmpResult = Compare(newNode, currentNode); + + // Search Up ----------------------------------------------------------------- + if (cmpResult == -1){ + // Parse the list while there's a previous node. + while (Prev()){ + currentNode = GetCurrent(); + cmpResult = Compare(newNode, currentNode); + + if (cmpResult == 1){ + // Correct position found. + InsertAfter(newNode); + return true; + }else if (cmpResult == 0){ + // Don't add a file twice. + return false; + } + } + // There's no previous node, so insert first. + InsertFirst(newNode); + return true; + } + // Search Down -------------------------------------------------------------- + else if (cmpResult == 1){ + // Parse the list while there's a next node. + while (Next()){ + currentNode = GetCurrent(); + cmpResult = Compare(newNode, currentNode); + + if (cmpResult == -1){ + // Correct position found. + InsertBefore(newNode); + return true; + }else if (cmpResult == 0){ + // Don't add a file twice. + return false; + } + } + // There's no next node, so insert last. + InsertLast(newNode); + return true; + } + // Don't add a file twice (cmpResult == 0) ------------------------------------- +return false; +} + + +int CList::InsertSorted_New(CNode * newNode){ + int cmpResult; + + /* Get the current node */ + CNode * currentNode = GetCurrent(); + if(!currentNode) + return EMPTY_LIST; + + /* Parse up or down ? */ + cmpResult = Compare(newNode, currentNode); + + /* -Up- */ + if (cmpResult == -1){ + // Parse the list while there's a previous node. + while (Prev()){ + currentNode = GetCurrent(); + cmpResult = Compare(newNode, currentNode); + + if (cmpResult == 1){ + // Correct position found. + return INSERT_AFTER; + }else if (cmpResult == 0){ + // Don't add a file twice. + return FILE_FOUND; + } + } + // There's no previous node, so insert first. + return INSERT_FIRST; + + /* -Down- */ + }else if (cmpResult == 1){ + // Parse the list while there's a next node. + while (Next()){ + currentNode = GetCurrent(); + cmpResult = Compare(newNode, currentNode); + + if (cmpResult == -1){ + // Correct position found. + return INSERT_BEFORE; + }else if (cmpResult == 0){ + // Don't add a file twice. + return FILE_FOUND; + } + } + // There's no next node, so insert last. + return INSERT_LAST; + } + // Don't add a file twice (cmpResult == 0) ------------------------------------- +return FILE_FOUND; +} + + +/******************************************************************** +* Destroy nodes. +********************************************************************/ +void CList::DestroyCurrent(){ +// CNode * node = current; + Destroy(current); +} + +void CList::Destroy(CNode * node){ + // Empty list ? + if (current != NULL){ + // Detach node from the list. + if (node->next != NULL) + node->next->prev = node->prev; + if (node->prev != NULL) + node->prev->next = node->next; + + // Set current node. + if(node->next != NULL) + current = node->next; + else + current = node->prev; + + if (current == NULL){ + // Now, the list is empty. + first = last = NULL; + + }else if (first == node){ + // Detached node was first. + first = current; + + }else if (last == node){ + // Detached node was last. + last = current; + } + delete node; + count--; + } +} + +void CList::DestroyList(){ + while (first != NULL){ + current = first; + first = first->next; + delete current; + } + current = last = first; + count = 0; +} + +int CList::Length(){ +return count; +} + diff --git a/rosapps/devutils/vmingw/CList.h b/rosapps/devutils/vmingw/CList.h new file mode 100644 index 00000000000..ac06e127575 --- /dev/null +++ b/rosapps/devutils/vmingw/CList.h @@ -0,0 +1,79 @@ +/******************************************************************** +* Module: CList.h. This is part of WinUI. +* +* License: WinUI is covered by GNU General Public License, +* Copyright (C) 2001 Manu B. +* See license.htm for more details. +* +********************************************************************/ +#ifndef CLIST_H +#define CLIST_H + +#include + +/******************************************************************** +* Generic CNode. +********************************************************************/ +class CNode +{ + public: + CNode() {next = prev = NULL; /*type = 0;*/}; + virtual ~CNode() {}; + + CNode * prev; + CNode * next; + long type; + + protected: + + private: +}; + +/******************************************************************** +* Generic List. +********************************************************************/ +#define FILE_FOUND 0 +#define EMPTY_LIST 1 +#define INSERT_FIRST 2 +#define INSERT_LAST 3 +#define INSERT_BEFORE 4 +#define INSERT_AFTER 5 + +class CList +{ + public: + CList() {first = last = current = NULL; count = 0;}; + virtual ~CList(); + + CNode * GetCurrent() {return current;}; + CNode * First(); + CNode * Last(); + CNode * Prev(); + CNode * Next(); + + void InsertFirst(CNode *node); + void InsertLast(CNode *node); + void InsertBefore(CNode *node); + void InsertAfter(CNode *node); + bool InsertSorted(CNode * newNode); + int InsertSorted_New(CNode * newNode); + + void DestroyCurrent(); + void Destroy(CNode * node); + void DestroyList(); + + int Length(); + + protected: + virtual int Compare(CNode *, CNode *) {return 0;}; + + CNode *first; + CNode *last; + CNode *current; + int count; + + private: +}; + +#endif + diff --git a/rosapps/devutils/vmingw/GNU-GPL.txt b/rosapps/devutils/vmingw/GNU-GPL.txt new file mode 100644 index 00000000000..a3f6b12eec4 --- /dev/null +++ b/rosapps/devutils/vmingw/GNU-GPL.txt @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/rosapps/devutils/vmingw/Makefile.ros b/rosapps/devutils/vmingw/Makefile.ros new file mode 100644 index 00000000000..c075b61f3b2 --- /dev/null +++ b/rosapps/devutils/vmingw/Makefile.ros @@ -0,0 +1,29 @@ +# $Id: Makefile.ros,v 1.1 2003/01/07 17:59:20 robd Exp $ +# + +PATH_TO_TOP = ../../../reactos + +TARGET_TYPE = program + +TARGET_APPTYPE = console + +TARGET_NAME = vmingw + +TARGET_CFLAGS = -D_WIN32_IE=0x0400 + +TARGET_SDKLIBS = user32.a comctl32.a ole32.a + +TARGET_OBJECTS = \ + CList.o\ + editor.o\ + main.o\ + process.o\ + project.o\ + rsrc.o\ + winui.o + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/rosapps/devutils/vmingw/SciLexer.dll b/rosapps/devutils/vmingw/SciLexer.dll new file mode 100644 index 00000000000..f1a143b9fbc Binary files /dev/null and b/rosapps/devutils/vmingw/SciLexer.dll differ diff --git a/rosapps/devutils/vmingw/SciLexer.h b/rosapps/devutils/vmingw/SciLexer.h new file mode 100644 index 00000000000..591bd06aa1a --- /dev/null +++ b/rosapps/devutils/vmingw/SciLexer.h @@ -0,0 +1,300 @@ +// Scintilla source code edit control +/** @file SciLexer.h + ** Interface to the added lexer functions in the SciLexer version of the edit control. + **/ +// Copyright 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +// Most of this file is automatically generated from the Scintilla.iface interface definition +// file which contains any comments about the definitions. HFacer.py does the generation. + +#ifndef SCILEXER_H +#define SCILEXER_H + +// SciLexer features - not in standard Scintilla + +//++Autogenerated -- start of section automatically generated from Scintilla.iface +#define SCLEX_CONTAINER 0 +#define SCLEX_NULL 1 +#define SCLEX_PYTHON 2 +#define SCLEX_CPP 3 +#define SCLEX_HTML 4 +#define SCLEX_XML 5 +#define SCLEX_PERL 6 +#define SCLEX_SQL 7 +#define SCLEX_VB 8 +#define SCLEX_PROPERTIES 9 +#define SCLEX_ERRORLIST 10 +#define SCLEX_MAKEFILE 11 +#define SCLEX_BATCH 12 +#define SCLEX_XCODE 13 +#define SCLEX_LATEX 14 +#define SCLEX_LUA 15 +#define SCLEX_DIFF 16 +#define SCLEX_CONF 17 +#define SCLEX_PASCAL 18 +#define SCLEX_AVE 19 +#define SCLEX_ADA 20 +#define SCLEX_LISP 21 +#define SCLEX_RUBY 22 +#define SCLEX_EIFFEL 23 +#define SCLEX_EIFFELKW 24 +#define SCLEX_TCL 25 +#define SCLEX_AUTOMATIC 1000 +#define SCE_P_DEFAULT 0 +#define SCE_P_COMMENTLINE 1 +#define SCE_P_NUMBER 2 +#define SCE_P_STRING 3 +#define SCE_P_CHARACTER 4 +#define SCE_P_WORD 5 +#define SCE_P_TRIPLE 6 +#define SCE_P_TRIPLEDOUBLE 7 +#define SCE_P_CLASSNAME 8 +#define SCE_P_DEFNAME 9 +#define SCE_P_OPERATOR 10 +#define SCE_P_IDENTIFIER 11 +#define SCE_P_COMMENTBLOCK 12 +#define SCE_P_STRINGEOL 13 +#define SCE_C_DEFAULT 0 +#define SCE_C_COMMENT 1 +#define SCE_C_COMMENTLINE 2 +#define SCE_C_COMMENTDOC 3 +#define SCE_C_NUMBER 4 +#define SCE_C_WORD 5 +#define SCE_C_STRING 6 +#define SCE_C_CHARACTER 7 +#define SCE_C_UUID 8 +#define SCE_C_PREPROCESSOR 9 +#define SCE_C_OPERATOR 10 +#define SCE_C_IDENTIFIER 11 +#define SCE_C_STRINGEOL 12 +#define SCE_C_VERBATIM 13 +#define SCE_C_REGEX 14 +#define SCE_C_COMMENTLINEDOC 15 +#define SCE_C_WORD2 16 +#define SCE_H_DEFAULT 0 +#define SCE_H_TAG 1 +#define SCE_H_TAGUNKNOWN 2 +#define SCE_H_ATTRIBUTE 3 +#define SCE_H_ATTRIBUTEUNKNOWN 4 +#define SCE_H_NUMBER 5 +#define SCE_H_DOUBLESTRING 6 +#define SCE_H_SINGLESTRING 7 +#define SCE_H_OTHER 8 +#define SCE_H_COMMENT 9 +#define SCE_H_ENTITY 10 +#define SCE_H_TAGEND 11 +#define SCE_H_XMLSTART 12 +#define SCE_H_XMLEND 13 +#define SCE_H_SCRIPT 14 +#define SCE_H_ASP 15 +#define SCE_H_ASPAT 16 +#define SCE_H_CDATA 17 +#define SCE_H_QUESTION 18 +#define SCE_H_VALUE 19 +#define SCE_H_XCCOMMENT 20 +#define SCE_H_SGML 21 +#define SCE_HJ_START 40 +#define SCE_HJ_DEFAULT 41 +#define SCE_HJ_COMMENT 42 +#define SCE_HJ_COMMENTLINE 43 +#define SCE_HJ_COMMENTDOC 44 +#define SCE_HJ_NUMBER 45 +#define SCE_HJ_WORD 46 +#define SCE_HJ_KEYWORD 47 +#define SCE_HJ_DOUBLESTRING 48 +#define SCE_HJ_SINGLESTRING 49 +#define SCE_HJ_SYMBOLS 50 +#define SCE_HJ_STRINGEOL 51 +#define SCE_HJ_REGEX 52 +#define SCE_HJA_START 55 +#define SCE_HJA_DEFAULT 56 +#define SCE_HJA_COMMENT 57 +#define SCE_HJA_COMMENTLINE 58 +#define SCE_HJA_COMMENTDOC 59 +#define SCE_HJA_NUMBER 60 +#define SCE_HJA_WORD 61 +#define SCE_HJA_KEYWORD 62 +#define SCE_HJA_DOUBLESTRING 63 +#define SCE_HJA_SINGLESTRING 64 +#define SCE_HJA_SYMBOLS 65 +#define SCE_HJA_STRINGEOL 66 +#define SCE_HJA_REGEX 67 +#define SCE_HB_START 70 +#define SCE_HB_DEFAULT 71 +#define SCE_HB_COMMENTLINE 72 +#define SCE_HB_NUMBER 73 +#define SCE_HB_WORD 74 +#define SCE_HB_STRING 75 +#define SCE_HB_IDENTIFIER 76 +#define SCE_HB_STRINGEOL 77 +#define SCE_HBA_START 80 +#define SCE_HBA_DEFAULT 81 +#define SCE_HBA_COMMENTLINE 82 +#define SCE_HBA_NUMBER 83 +#define SCE_HBA_WORD 84 +#define SCE_HBA_STRING 85 +#define SCE_HBA_IDENTIFIER 86 +#define SCE_HBA_STRINGEOL 87 +#define SCE_HP_START 90 +#define SCE_HP_DEFAULT 91 +#define SCE_HP_COMMENTLINE 92 +#define SCE_HP_NUMBER 93 +#define SCE_HP_STRING 94 +#define SCE_HP_CHARACTER 95 +#define SCE_HP_WORD 96 +#define SCE_HP_TRIPLE 97 +#define SCE_HP_TRIPLEDOUBLE 98 +#define SCE_HP_CLASSNAME 99 +#define SCE_HP_DEFNAME 100 +#define SCE_HP_OPERATOR 101 +#define SCE_HP_IDENTIFIER 102 +#define SCE_HPA_START 105 +#define SCE_HPA_DEFAULT 106 +#define SCE_HPA_COMMENTLINE 107 +#define SCE_HPA_NUMBER 108 +#define SCE_HPA_STRING 109 +#define SCE_HPA_CHARACTER 110 +#define SCE_HPA_WORD 111 +#define SCE_HPA_TRIPLE 112 +#define SCE_HPA_TRIPLEDOUBLE 113 +#define SCE_HPA_CLASSNAME 114 +#define SCE_HPA_DEFNAME 115 +#define SCE_HPA_OPERATOR 116 +#define SCE_HPA_IDENTIFIER 117 +#define SCE_HPHP_DEFAULT 118 +#define SCE_HPHP_HSTRING 119 +#define SCE_HPHP_SIMPLESTRING 120 +#define SCE_HPHP_WORD 121 +#define SCE_HPHP_NUMBER 122 +#define SCE_HPHP_VARIABLE 123 +#define SCE_HPHP_COMMENT 124 +#define SCE_HPHP_COMMENTLINE 125 +#define SCE_HPHP_HSTRING_VARIABLE 126 +#define SCE_HPHP_OPERATOR 127 +#define SCE_PL_DEFAULT 0 +#define SCE_PL_ERROR 1 +#define SCE_PL_COMMENTLINE 2 +#define SCE_PL_POD 3 +#define SCE_PL_NUMBER 4 +#define SCE_PL_WORD 5 +#define SCE_PL_STRING 6 +#define SCE_PL_CHARACTER 7 +#define SCE_PL_PUNCTUATION 8 +#define SCE_PL_PREPROCESSOR 9 +#define SCE_PL_OPERATOR 10 +#define SCE_PL_IDENTIFIER 11 +#define SCE_PL_SCALAR 12 +#define SCE_PL_ARRAY 13 +#define SCE_PL_HASH 14 +#define SCE_PL_SYMBOLTABLE 15 +#define SCE_PL_REGEX 17 +#define SCE_PL_REGSUBST 18 +#define SCE_PL_LONGQUOTE 19 +#define SCE_PL_BACKTICKS 20 +#define SCE_PL_DATASECTION 21 +#define SCE_PL_HERE_DELIM 22 +#define SCE_PL_HERE_Q 23 +#define SCE_PL_HERE_QQ 24 +#define SCE_PL_HERE_QX 25 +#define SCE_PL_STRING_Q 26 +#define SCE_PL_STRING_QQ 27 +#define SCE_PL_STRING_QX 28 +#define SCE_PL_STRING_QR 29 +#define SCE_PL_STRING_QW 30 +#define SCE_L_DEFAULT 0 +#define SCE_L_COMMAND 1 +#define SCE_L_TAG 2 +#define SCE_L_MATH 3 +#define SCE_L_COMMENT 4 +#define SCE_LUA_DEFAULT 0 +#define SCE_LUA_COMMENT 1 +#define SCE_LUA_COMMENTLINE 2 +#define SCE_LUA_COMMENTDOC 3 +#define SCE_LUA_NUMBER 4 +#define SCE_LUA_WORD 5 +#define SCE_LUA_STRING 6 +#define SCE_LUA_CHARACTER 7 +#define SCE_LUA_LITERALSTRING 8 +#define SCE_LUA_PREPROCESSOR 9 +#define SCE_LUA_OPERATOR 10 +#define SCE_LUA_IDENTIFIER 11 +#define SCE_LUA_STRINGEOL 12 +#define SCE_ERR_DEFAULT 0 +#define SCE_ERR_PYTHON 1 +#define SCE_ERR_GCC 2 +#define SCE_ERR_MS 3 +#define SCE_ERR_CMD 4 +#define SCE_ERR_BORLAND 5 +#define SCE_ERR_PERL 6 +#define SCE_ERR_NET 7 +#define SCE_ERR_LUA 8 +#define SCE_ERR_DIFF_CHANGED 10 +#define SCE_ERR_DIFF_ADDITION 11 +#define SCE_ERR_DIFF_DELETION 12 +#define SCE_ERR_DIFF_MESSAGE 13 +#define SCE_BAT_DEFAULT 0 +#define SCE_BAT_COMMENT 1 +#define SCE_BAT_WORD 2 +#define SCE_BAT_LABEL 3 +#define SCE_BAT_HIDE 4 +#define SCE_BAT_COMMAND 5 +#define SCE_BAT_IDENTIFIER 6 +#define SCE_BAT_OPERATOR 7 +#define SCE_MAKE_DEFAULT 0 +#define SCE_MAKE_COMMENT 1 +#define SCE_MAKE_PREPROCESSOR 2 +#define SCE_MAKE_IDENTIFIER 3 +#define SCE_MAKE_OPERATOR 4 +#define SCE_MAKE_TARGET 5 +#define SCE_MAKE_IDEOL 9 +#define SCE_CONF_DEFAULT 0 +#define SCE_CONF_COMMENT 1 +#define SCE_CONF_NUMBER 2 +#define SCE_CONF_IDENTIFIER 3 +#define SCE_CONF_EXTENSION 4 +#define SCE_CONF_PARAMETER 5 +#define SCE_CONF_STRING 6 +#define SCE_CONF_OPERATOR 7 +#define SCE_CONF_IP 8 +#define SCE_CONF_DIRECTIVE 9 +#define SCE_AVE_DEFAULT 0 +#define SCE_AVE_COMMENT 1 +#define SCE_AVE_NUMBER 2 +#define SCE_AVE_WORD 3 +#define SCE_AVE_KEYWORD 4 +#define SCE_AVE_STATEMENT 5 +#define SCE_AVE_STRING 6 +#define SCE_AVE_ENUM 7 +#define SCE_AVE_STRINGEOL 8 +#define SCE_AVE_IDENTIFIER 9 +#define SCE_AVE_OPERATOR 10 +#define SCE_ADA_DEFAULT 0 +#define SCE_ADA_COMMENT 1 +#define SCE_ADA_NUMBER 2 +#define SCE_ADA_WORD 3 +#define SCE_ADA_STRING 4 +#define SCE_ADA_CHARACTER 5 +#define SCE_ADA_OPERATOR 6 +#define SCE_ADA_IDENTIFIER 7 +#define SCE_ADA_STRINGEOL 8 +#define SCE_LISP_DEFAULT 0 +#define SCE_LISP_COMMENT 1 +#define SCE_LISP_NUMBER 2 +#define SCE_LISP_KEYWORD 3 +#define SCE_LISP_STRING 6 +#define SCE_LISP_STRINGEOL 8 +#define SCE_LISP_IDENTIFIER 9 +#define SCE_LISP_OPERATOR 10 +#define SCE_EIFFEL_DEFAULT 0 +#define SCE_EIFFEL_COMMENTLINE 1 +#define SCE_EIFFEL_NUMBER 2 +#define SCE_EIFFEL_WORD 3 +#define SCE_EIFFEL_STRING 4 +#define SCE_EIFFEL_CHARACTER 5 +#define SCE_EIFFEL_OPERATOR 6 +#define SCE_EIFFEL_IDENTIFIER 7 +#define SCE_EIFFEL_STRINGEOL 8 +//--Autogenerated -- end of section automatically generated from Scintilla.iface + +#endif diff --git a/rosapps/devutils/vmingw/Scintilla.h b/rosapps/devutils/vmingw/Scintilla.h new file mode 100644 index 00000000000..0185d3e5be6 --- /dev/null +++ b/rosapps/devutils/vmingw/Scintilla.h @@ -0,0 +1,599 @@ +// Scintilla source code edit control +/** @file Scintilla.h + ** Interface to the edit control. + **/ +// Copyright 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +// Most of this file is automatically generated from the Scintilla.iface interface definition +// file which contains any comments about the definitions. HFacer.py does the generation. + +#ifndef SCINTILLA_H +#define SCINTILLA_H + +// Compile-time configuration options +#define MACRO_SUPPORT 1 // Comment out to remove macro hooks + +#if PLAT_WIN +#ifdef STATIC_BUILD +void Scintilla_RegisterClasses(HINSTANCE hInstance); +#endif +#endif + +// Here should be placed typedefs for uptr_t, an unsigned integer type large enough to +// hold a pointer and sptr_t, a signed integer large enough to hold a pointer. +// May need to be changed for 64 bit platforms. +typedef unsigned long uptr_t; +typedef long sptr_t; + +typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam); + +//++Autogenerated -- start of section automatically generated from Scintilla.iface +#define INVALID_POSITION -1 +#define SCI_START 2000 +#define SCI_OPTIONAL_START 3000 +#define SCI_LEXER_START 4000 +#define SCI_ADDTEXT 2001 +#define SCI_ADDSTYLEDTEXT 2002 +#define SCI_INSERTTEXT 2003 +#define SCI_CLEARALL 2004 +#define SCI_CLEARDOCUMENTSTYLE 2005 +#define SCI_GETLENGTH 2006 +#define SCI_GETCHARAT 2007 +#define SCI_GETCURRENTPOS 2008 +#define SCI_GETANCHOR 2009 +#define SCI_GETSTYLEAT 2010 +#define SCI_REDO 2011 +#define SCI_SETUNDOCOLLECTION 2012 +#define SCI_SELECTALL 2013 +#define SCI_SETSAVEPOINT 2014 +#define SCI_GETSTYLEDTEXT 2015 +#define SCI_CANREDO 2016 +#define SCI_MARKERLINEFROMHANDLE 2017 +#define SCI_MARKERDELETEHANDLE 2018 +#define SCI_GETUNDOCOLLECTION 2019 +#define SCWS_INVISIBLE 0 +#define SCWS_VISIBLEALWAYS 1 +#define SCWS_VISIBLEAFTERINDENT 2 +#define SCI_GETVIEWWS 2020 +#define SCI_SETVIEWWS 2021 +#define SCI_POSITIONFROMPOINT 2022 +#define SCI_POSITIONFROMPOINTCLOSE 2023 +#define SCI_GOTOLINE 2024 +#define SCI_GOTOPOS 2025 +#define SCI_SETANCHOR 2026 +#define SCI_GETCURLINE 2027 +#define SCI_GETENDSTYLED 2028 +#define SC_EOL_CRLF 0 +#define SC_EOL_CR 1 +#define SC_EOL_LF 2 +#define SCI_CONVERTEOLS 2029 +#define SCI_GETEOLMODE 2030 +#define SCI_SETEOLMODE 2031 +#define SCI_STARTSTYLING 2032 +#define SCI_SETSTYLING 2033 +#define SCI_GETBUFFEREDDRAW 2034 +#define SCI_SETBUFFEREDDRAW 2035 +#define SCI_SETTABWIDTH 2036 +#define SCI_GETTABWIDTH 2121 +#define SC_CP_UTF8 65001 +#define SCI_SETCODEPAGE 2037 +#define SCI_SETUSEPALETTE 2039 +#define MARKER_MAX 31 +#define SC_MARK_CIRCLE 0 +#define SC_MARK_ROUNDRECT 1 +#define SC_MARK_ARROW 2 +#define SC_MARK_SMALLRECT 3 +#define SC_MARK_SHORTARROW 4 +#define SC_MARK_EMPTY 5 +#define SC_MARK_ARROWDOWN 6 +#define SC_MARK_MINUS 7 +#define SC_MARK_PLUS 8 +#define SC_MARK_VLINE 9 +#define SC_MARK_LCORNER 10 +#define SC_MARK_TCORNER 11 +#define SC_MARK_BOXPLUS 12 +#define SC_MARK_BOXPLUSCONNECTED 13 +#define SC_MARK_BOXMINUS 14 +#define SC_MARK_BOXMINUSCONNECTED 15 +#define SC_MARK_LCORNERCURVE 16 +#define SC_MARK_TCORNERCURVE 17 +#define SC_MARK_CIRCLEPLUS 18 +#define SC_MARK_CIRCLEPLUSCONNECTED 19 +#define SC_MARK_CIRCLEMINUS 20 +#define SC_MARK_CIRCLEMINUSCONNECTED 21 +#define SC_MARKNUM_FOLDEREND 25 +#define SC_MARKNUM_FOLDEROPENMID 26 +#define SC_MARKNUM_FOLDERMIDTAIL 27 +#define SC_MARKNUM_FOLDERTAIL 28 +#define SC_MARKNUM_FOLDERSUB 29 +#define SC_MARKNUM_FOLDER 30 +#define SC_MARKNUM_FOLDEROPEN 31 +#define SCI_MARKERDEFINE 2040 +#define SCI_MARKERSETFORE 2041 +#define SCI_MARKERSETBACK 2042 +#define SCI_MARKERADD 2043 +#define SCI_MARKERDELETE 2044 +#define SCI_MARKERDELETEALL 2045 +#define SCI_MARKERGET 2046 +#define SCI_MARKERNEXT 2047 +#define SCI_MARKERPREVIOUS 2048 +#define SC_MARGIN_SYMBOL 0 +#define SC_MARGIN_NUMBER 1 +#define SCI_SETMARGINTYPEN 2240 +#define SCI_GETMARGINTYPEN 2241 +#define SCI_SETMARGINWIDTHN 2242 +#define SCI_GETMARGINWIDTHN 2243 +#define SCI_SETMARGINMASKN 2244 +#define SCI_GETMARGINMASKN 2245 +#define SCI_SETMARGINSENSITIVEN 2246 +#define SCI_GETMARGINSENSITIVEN 2247 +#define STYLE_DEFAULT 32 +#define STYLE_LINENUMBER 33 +#define STYLE_BRACELIGHT 34 +#define STYLE_BRACEBAD 35 +#define STYLE_CONTROLCHAR 36 +#define STYLE_INDENTGUIDE 37 +#define STYLE_MAX 127 +#define SC_CHARSET_ANSI 0 +#define SC_CHARSET_DEFAULT 1 +#define SC_CHARSET_BALTIC 186 +#define SC_CHARSET_CHINESEBIG5 136 +#define SC_CHARSET_EASTEUROPE 238 +#define SC_CHARSET_GB2312 134 +#define SC_CHARSET_GREEK 161 +#define SC_CHARSET_HANGUL 129 +#define SC_CHARSET_MAC 77 +#define SC_CHARSET_OEM 255 +#define SC_CHARSET_RUSSIAN 204 +#define SC_CHARSET_SHIFTJIS 128 +#define SC_CHARSET_SYMBOL 2 +#define SC_CHARSET_TURKISH 162 +#define SC_CHARSET_JOHAB 130 +#define SC_CHARSET_HEBREW 177 +#define SC_CHARSET_ARABIC 178 +#define SC_CHARSET_VIETNAMESE 163 +#define SC_CHARSET_THAI 222 +#define SCI_STYLECLEARALL 2050 +#define SCI_STYLESETFORE 2051 +#define SCI_STYLESETBACK 2052 +#define SCI_STYLESETBOLD 2053 +#define SCI_STYLESETITALIC 2054 +#define SCI_STYLESETSIZE 2055 +#define SCI_STYLESETFONT 2056 +#define SCI_STYLESETEOLFILLED 2057 +#define SCI_STYLERESETDEFAULT 2058 +#define SCI_STYLESETUNDERLINE 2059 +#define SC_CASE_MIXED 0 +#define SC_CASE_UPPER 1 +#define SC_CASE_LOWER 2 +#define SCI_STYLESETCASE 2060 +#define SCI_STYLESETCHARACTERSET 2066 +#define SCI_SETSELFORE 2067 +#define SCI_SETSELBACK 2068 +#define SCI_SETCARETFORE 2069 +#define SCI_ASSIGNCMDKEY 2070 +#define SCI_CLEARCMDKEY 2071 +#define SCI_CLEARALLCMDKEYS 2072 +#define SCI_SETSTYLINGEX 2073 +#define SCI_STYLESETVISIBLE 2074 +#define SCI_GETCARETPERIOD 2075 +#define SCI_SETCARETPERIOD 2076 +#define SCI_SETWORDCHARS 2077 +#define SCI_BEGINUNDOACTION 2078 +#define SCI_ENDUNDOACTION 2079 +#define INDIC_MAX 7 +#define INDIC_PLAIN 0 +#define INDIC_SQUIGGLE 1 +#define INDIC_TT 2 +#define INDIC_DIAGONAL 3 +#define INDIC_STRIKE 4 +#define INDIC0_MASK 32 +#define INDIC1_MASK 64 +#define INDIC2_MASK 128 +#define INDICS_MASK INDIC0_MASK | INDIC1_MASK | INDIC2_MASK +#define SCI_INDICSETSTYLE 2080 +#define SCI_INDICGETSTYLE 2081 +#define SCI_INDICSETFORE 2082 +#define SCI_INDICGETFORE 2083 +#define SCI_SETSTYLEBITS 2090 +#define SCI_GETSTYLEBITS 2091 +#define SCI_SETLINESTATE 2092 +#define SCI_GETLINESTATE 2093 +#define SCI_GETMAXLINESTATE 2094 +#define SCI_GETCARETLINEVISIBLE 2095 +#define SCI_SETCARETLINEVISIBLE 2096 +#define SCI_GETCARETLINEBACK 2097 +#define SCI_SETCARETLINEBACK 2098 +#define SCI_AUTOCSHOW 2100 +#define SCI_AUTOCCANCEL 2101 +#define SCI_AUTOCACTIVE 2102 +#define SCI_AUTOCPOSSTART 2103 +#define SCI_AUTOCCOMPLETE 2104 +#define SCI_AUTOCSTOPS 2105 +#define SCI_AUTOCSETSEPARATOR 2106 +#define SCI_AUTOCGETSEPARATOR 2107 +#define SCI_AUTOCSELECT 2108 +#define SCI_AUTOCSETCANCELATSTART 2110 +#define SCI_AUTOCGETCANCELATSTART 2111 +#define SCI_AUTOCSETFILLUPS 2112 +#define SCI_AUTOCSETCHOOSESINGLE 2113 +#define SCI_AUTOCGETCHOOSESINGLE 2114 +#define SCI_AUTOCSETIGNORECASE 2115 +#define SCI_AUTOCGETIGNORECASE 2116 +#define SCI_USERLISTSHOW 2117 +#define SCI_AUTOCSETAUTOHIDE 2118 +#define SCI_AUTOCGETAUTOHIDE 2119 +#define SCI_SETINDENT 2122 +#define SCI_GETINDENT 2123 +#define SCI_SETUSETABS 2124 +#define SCI_GETUSETABS 2125 +#define SCI_SETLINEINDENTATION 2126 +#define SCI_GETLINEINDENTATION 2127 +#define SCI_GETLINEINDENTPOSITION 2128 +#define SCI_GETCOLUMN 2129 +#define SCI_SETHSCROLLBAR 2130 +#define SCI_GETHSCROLLBAR 2131 +#define SCI_SETINDENTATIONGUIDES 2132 +#define SCI_GETINDENTATIONGUIDES 2133 +#define SCI_SETHIGHLIGHTGUIDE 2134 +#define SCI_GETHIGHLIGHTGUIDE 2135 +#define SCI_GETLINEENDPOSITION 2136 +#define SCI_GETCODEPAGE 2137 +#define SCI_GETCARETFORE 2138 +#define SCI_GETUSEPALETTE 2139 +#define SCI_GETREADONLY 2140 +#define SCI_SETCURRENTPOS 2141 +#define SCI_SETSELECTIONSTART 2142 +#define SCI_GETSELECTIONSTART 2143 +#define SCI_SETSELECTIONEND 2144 +#define SCI_GETSELECTIONEND 2145 +#define SCI_SETPRINTMAGNIFICATION 2146 +#define SCI_GETPRINTMAGNIFICATION 2147 +#define SC_PRINT_NORMAL 0 +#define SC_PRINT_INVERTLIGHT 1 +#define SC_PRINT_BLACKONWHITE 2 +#define SC_PRINT_COLOURONWHITE 3 +#define SC_PRINT_COLOURONWHITEDEFAULTBG 4 +#define SCI_SETPRINTCOLOURMODE 2148 +#define SCI_GETPRINTCOLOURMODE 2149 +#define SCFIND_WHOLEWORD 2 +#define SCFIND_MATCHCASE 4 +#define SCFIND_WORDSTART 0x00100000 +#define SCFIND_REGEXP 0x00200000 +#define SCI_FINDTEXT 2150 +#define SCI_FORMATRANGE 2151 +#define SCI_GETFIRSTVISIBLELINE 2152 +#define SCI_GETLINE 2153 +#define SCI_GETLINECOUNT 2154 +#define SCI_SETMARGINLEFT 2155 +#define SCI_GETMARGINLEFT 2156 +#define SCI_SETMARGINRIGHT 2157 +#define SCI_GETMARGINRIGHT 2158 +#define SCI_GETMODIFY 2159 +#define SCI_SETSEL 2160 +#define SCI_GETSELTEXT 2161 +#define SCI_GETTEXTRANGE 2162 +#define SCI_HIDESELECTION 2163 +#define SCI_POINTXFROMPOSITION 2164 +#define SCI_POINTYFROMPOSITION 2165 +#define SCI_LINEFROMPOSITION 2166 +#define SCI_POSITIONFROMLINE 2167 +#define SCI_LINESCROLL 2168 +#define SCI_SCROLLCARET 2169 +#define SCI_REPLACESEL 2170 +#define SCI_SETREADONLY 2171 +#define SCI_NULL 2172 +#define SCI_CANPASTE 2173 +#define SCI_CANUNDO 2174 +#define SCI_EMPTYUNDOBUFFER 2175 +#define SCI_UNDO 2176 +#define SCI_CUT 2177 +#define SCI_COPY 2178 +#define SCI_PASTE 2179 +#define SCI_CLEAR 2180 +#define SCI_SETTEXT 2181 +#define SCI_GETTEXT 2182 +#define SCI_GETTEXTLENGTH 2183 +#define SCI_GETDIRECTFUNCTION 2184 +#define SCI_GETDIRECTPOINTER 2185 +#define SCI_SETOVERTYPE 2186 +#define SCI_GETOVERTYPE 2187 +#define SCI_SETCARETWIDTH 2188 +#define SCI_GETCARETWIDTH 2189 +#define SCI_SETTARGETSTART 2190 +#define SCI_GETTARGETSTART 2191 +#define SCI_SETTARGETEND 2192 +#define SCI_GETTARGETEND 2193 +#define SCI_REPLACETARGET 2194 +#define SCI_REPLACETARGETRE 2195 +#define SCI_SEARCHINTARGET 2197 +#define SCI_SETSEARCHFLAGS 2198 +#define SCI_GETSEARCHFLAGS 2199 +#define SCI_CALLTIPSHOW 2200 +#define SCI_CALLTIPCANCEL 2201 +#define SCI_CALLTIPACTIVE 2202 +#define SCI_CALLTIPPOSSTART 2203 +#define SCI_CALLTIPSETHLT 2204 +#define SCI_CALLTIPSETBACK 2205 +#define SCI_VISIBLEFROMDOCLINE 2220 +#define SCI_DOCLINEFROMVISIBLE 2221 +#define SC_FOLDLEVELBASE 0x400 +#define SC_FOLDLEVELWHITEFLAG 0x1000 +#define SC_FOLDLEVELHEADERFLAG 0x2000 +#define SC_FOLDLEVELNUMBERMASK 0x0FFF +#define SCI_SETFOLDLEVEL 2222 +#define SCI_GETFOLDLEVEL 2223 +#define SCI_GETLASTCHILD 2224 +#define SCI_GETFOLDPARENT 2225 +#define SCI_SHOWLINES 2226 +#define SCI_HIDELINES 2227 +#define SCI_GETLINEVISIBLE 2228 +#define SCI_SETFOLDEXPANDED 2229 +#define SCI_GETFOLDEXPANDED 2230 +#define SCI_TOGGLEFOLD 2231 +#define SCI_ENSUREVISIBLE 2232 +#define SCI_SETFOLDFLAGS 2233 +#define SCI_ENSUREVISIBLEENFORCEPOLICY 2234 +#define SCI_SETTABINDENTS 2260 +#define SCI_GETTABINDENTS 2261 +#define SCI_SETBACKSPACEUNINDENTS 2262 +#define SCI_GETBACKSPACEUNINDENTS 2263 +#define SC_TIME_FOREVER 10000000 +#define SCI_SETMOUSEDWELLTIME 2264 +#define SCI_GETMOUSEDWELLTIME 2265 +#define SCI_LINEDOWN 2300 +#define SCI_LINEDOWNEXTEND 2301 +#define SCI_LINEUP 2302 +#define SCI_LINEUPEXTEND 2303 +#define SCI_CHARLEFT 2304 +#define SCI_CHARLEFTEXTEND 2305 +#define SCI_CHARRIGHT 2306 +#define SCI_CHARRIGHTEXTEND 2307 +#define SCI_WORDLEFT 2308 +#define SCI_WORDLEFTEXTEND 2309 +#define SCI_WORDRIGHT 2310 +#define SCI_WORDRIGHTEXTEND 2311 +#define SCI_HOME 2312 +#define SCI_HOMEEXTEND 2313 +#define SCI_LINEEND 2314 +#define SCI_LINEENDEXTEND 2315 +#define SCI_DOCUMENTSTART 2316 +#define SCI_DOCUMENTSTARTEXTEND 2317 +#define SCI_DOCUMENTEND 2318 +#define SCI_DOCUMENTENDEXTEND 2319 +#define SCI_PAGEUP 2320 +#define SCI_PAGEUPEXTEND 2321 +#define SCI_PAGEDOWN 2322 +#define SCI_PAGEDOWNEXTEND 2323 +#define SCI_EDITTOGGLEOVERTYPE 2324 +#define SCI_CANCEL 2325 +#define SCI_DELETEBACK 2326 +#define SCI_TAB 2327 +#define SCI_BACKTAB 2328 +#define SCI_NEWLINE 2329 +#define SCI_FORMFEED 2330 +#define SCI_VCHOME 2331 +#define SCI_VCHOMEEXTEND 2332 +#define SCI_ZOOMIN 2333 +#define SCI_ZOOMOUT 2334 +#define SCI_DELWORDLEFT 2335 +#define SCI_DELWORDRIGHT 2336 +#define SCI_LINECUT 2337 +#define SCI_LINEDELETE 2338 +#define SCI_LINETRANSPOSE 2339 +#define SCI_LOWERCASE 2340 +#define SCI_UPPERCASE 2341 +#define SCI_LINESCROLLDOWN 2342 +#define SCI_LINESCROLLUP 2343 +#define SCI_MOVECARETINSIDEVIEW 2401 +#define SCI_LINELENGTH 2350 +#define SCI_BRACEHIGHLIGHT 2351 +#define SCI_BRACEBADLIGHT 2352 +#define SCI_BRACEMATCH 2353 +#define SCI_GETVIEWEOL 2355 +#define SCI_SETVIEWEOL 2356 +#define SCI_GETDOCPOINTER 2357 +#define SCI_SETDOCPOINTER 2358 +#define SCI_SETMODEVENTMASK 2359 +#define EDGE_NONE 0 +#define EDGE_LINE 1 +#define EDGE_BACKGROUND 2 +#define SCI_GETEDGECOLUMN 2360 +#define SCI_SETEDGECOLUMN 2361 +#define SCI_GETEDGEMODE 2362 +#define SCI_SETEDGEMODE 2363 +#define SCI_GETEDGECOLOUR 2364 +#define SCI_SETEDGECOLOUR 2365 +#define SCI_SEARCHANCHOR 2366 +#define SCI_SEARCHNEXT 2367 +#define SCI_SEARCHPREV 2368 +#define CARET_SLOP 0x01 +#define CARET_CENTER 0x02 +#define CARET_STRICT 0x04 +#define CARET_XEVEN 0x08 +#define CARET_XJUMPS 0x10 +#define SCI_SETCARETPOLICY 2369 +#define SCI_LINESONSCREEN 2370 +#define SCI_USEPOPUP 2371 +#define SCI_SELECTIONISRECTANGLE 2372 +#define SCI_SETZOOM 2373 +#define SCI_GETZOOM 2374 +#define SCI_CREATEDOCUMENT 2375 +#define SCI_ADDREFDOCUMENT 2376 +#define SCI_RELEASEDOCUMENT 2377 +#define SCI_GETMODEVENTMASK 2378 +#define SCI_SETFOCUS 2380 +#define SCI_GETFOCUS 2381 +#define SCI_SETSTATUS 2382 +#define SCI_GETSTATUS 2383 +#define SCI_SETMOUSEDOWNCAPTURES 2384 +#define SCI_GETMOUSEDOWNCAPTURES 2385 +#define SC_CURSORNORMAL -1 +#define SC_CURSORWAIT 3 +#define SCI_SETCURSOR 2386 +#define SCI_GETCURSOR 2387 +#define SCI_WORDPARTLEFT 2390 +#define SCI_WORDPARTLEFTEXTEND 2391 +#define SCI_WORDPARTRIGHT 2392 +#define SCI_WORDPARTRIGHTEXTEND 2393 +#define VISIBLE_SLOP 0x01 +#define VISIBLE_STRICT 0x04 +#define SCI_SETVISIBLEPOLICY 2394 +#define SCI_DELLINELEFT 2395 +#define SCI_DELLINERIGHT 2396 +#define SCI_GRABFOCUS 2400 +#define SCI_STARTRECORD 3001 +#define SCI_STOPRECORD 3002 +#define SCI_SETLEXER 4001 +#define SCI_GETLEXER 4002 +#define SCI_COLOURISE 4003 +#define SCI_SETPROPERTY 4004 +#define SCI_SETKEYWORDS 4005 +#define SCI_SETLEXERLANGUAGE 4006 +#define SC_MOD_INSERTTEXT 0x1 +#define SC_MOD_DELETETEXT 0x2 +#define SC_MOD_CHANGESTYLE 0x4 +#define SC_MOD_CHANGEFOLD 0x8 +#define SC_PERFORMED_USER 0x10 +#define SC_PERFORMED_UNDO 0x20 +#define SC_PERFORMED_REDO 0x40 +#define SC_LASTSTEPINUNDOREDO 0x100 +#define SC_MOD_CHANGEMARKER 0x200 +#define SC_MOD_BEFOREINSERT 0x400 +#define SC_MOD_BEFOREDELETE 0x800 +#define SC_MODEVENTMASKALL 0xF77 +#define SCEN_CHANGE 768 +#define SCEN_SETFOCUS 512 +#define SCEN_KILLFOCUS 256 +#define SCK_DOWN 300 +#define SCK_UP 301 +#define SCK_LEFT 302 +#define SCK_RIGHT 303 +#define SCK_HOME 304 +#define SCK_END 305 +#define SCK_PRIOR 306 +#define SCK_NEXT 307 +#define SCK_DELETE 308 +#define SCK_INSERT 309 +#define SCK_ESCAPE 7 +#define SCK_BACK 8 +#define SCK_TAB 9 +#define SCK_RETURN 13 +#define SCK_ADD 310 +#define SCK_SUBTRACT 311 +#define SCK_DIVIDE 312 +#define SCMOD_SHIFT 1 +#define SCMOD_CTRL 2 +#define SCMOD_ALT 4 +#define SCN_STYLENEEDED 2000 +#define SCN_CHARADDED 2001 +#define SCN_SAVEPOINTREACHED 2002 +#define SCN_SAVEPOINTLEFT 2003 +#define SCN_MODIFYATTEMPTRO 2004 +#define SCN_KEY 2005 +#define SCN_DOUBLECLICK 2006 +#define SCN_UPDATEUI 2007 +#define SCN_CHECKBRACE 2007 +#define SCN_MODIFIED 2008 +#define SCN_MACRORECORD 2009 +#define SCN_MARGINCLICK 2010 +#define SCN_NEEDSHOWN 2011 +#define SCN_POSCHANGED 2012 +#define SCN_PAINTED 2013 +#define SCN_USERLISTSELECTION 2014 +#define SCN_URIDROPPED 2015 +#define SCN_DWELLSTART 2016 +#define SCN_DWELLEND 2017 +//--Autogenerated -- end of section automatically generated from Scintilla.iface + +// Optional module for macro recording +#ifdef MACRO_SUPPORT +typedef void (tMacroRecorder)(unsigned int iMessage, unsigned long wParam, + long lParam, void *userData); +#endif + +// These structures are defined to be exactly the same shape as the Win32 +// CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs. +// So older code that treats Scintilla as a RichEdit will work. + +struct CharacterRange { + long cpMin; + long cpMax; +}; + +struct TextRange { + struct CharacterRange chrg; + char *lpstrText; +}; + +struct TextToFind { + struct CharacterRange chrg; + char *lpstrText; + struct CharacterRange chrgText; +}; + +#ifdef PLATFORM_H + +// This structure is used in printing and requires some of the graphics types +// from Platform.h. Not needed by most client code. + +struct RangeToFormat { + SurfaceID hdc; + SurfaceID hdcTarget; + PRectangle rc; + PRectangle rcPage; + CharacterRange chrg; +}; + +#endif + +struct NotifyHeader { + // hwndFrom is really an environment specifc window handle or pointer + // but most clients of Scintilla.h do not have this type visible. + //WindowID hwndFrom; + void *hwndFrom; + unsigned int idFrom; + unsigned int code; +}; + +struct SCNotification { + struct NotifyHeader nmhdr; + int position; // SCN_STYLENEEDED, SCN_MODIFIED, SCN_DWELLSTART, SCN_DWELLEND + int ch; // SCN_CHARADDED, SCN_KEY + int modifiers; // SCN_KEY + int modificationType; // SCN_MODIFIED + const char *text; // SCN_MODIFIED + int length; // SCN_MODIFIED + int linesAdded; // SCN_MODIFIED +#ifdef MACRO_SUPPORT + int message; // SCN_MACRORECORD + uptr_t wParam; // SCN_MACRORECORD + sptr_t lParam; // SCN_MACRORECORD +#endif + int line; // SCN_MODIFIED + int foldLevelNow; // SCN_MODIFIED + int foldLevelPrev; // SCN_MODIFIED + int margin; // SCN_MARGINCLICK + int listType; // SCN_USERLISTSELECTION + int x; // SCN_DWELLSTART, SCN_DWELLEND + int y; // SCN_DWELLSTART, SCN_DWELLEND +}; + +#define SC_MASK_FOLDERS ((1< +#include +#include "commctrl.h" +#include "commdlg.h" +#include "editor.h" +#include "rsrc.h" + +extern CMessageBox MsgBox; + +int Minimum(int a, int b); +int Maximum(int a, int b); + +int Minimum(int a, int b){ + if (a < b) + return a; + else + return b; +} + +int Maximum(int a, int b){ + if (a > b) + return a; + else + return b; +} + +void EnsureRangeVisible(HWND hwndCtrl, int posStart, int posEnd, bool enforcePolicy){ + int lineStart = SendMessage(hwndCtrl, SCI_LINEFROMPOSITION, Minimum(posStart, posEnd), 0); + int lineEnd = SendMessage(hwndCtrl, SCI_LINEFROMPOSITION, Maximum(posStart, posEnd), 0); + for (int line = lineStart; line <= lineEnd; line++){ + SendMessage(hwndCtrl, + enforcePolicy ? SCI_ENSUREVISIBLEENFORCEPOLICY : SCI_ENSUREVISIBLE, line, 0); + } +} + +int LengthDocument(HWND hwndCtrl){ +return SendMessage(hwndCtrl, SCI_GETLENGTH, 0, 0); +} + +CharacterRange GetSelection(HWND hwndCtrl){ + CharacterRange crange; + crange.cpMin = SendMessage(hwndCtrl, SCI_GETSELECTIONSTART, 0, 0); + crange.cpMax = SendMessage(hwndCtrl, SCI_GETSELECTIONEND, 0, 0); +return crange; +} + + +/******************************************************************** +* Class: CChooseFontDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CChooseFontDlg::CChooseFontDlg(){ + ZeroMemory(&lf, sizeof(LOGFONT)); +/* lf.lfHeight; + lf.lfWidth; + lf.lfEscapement; + lf.lfOrientation; + lf.lfWeight; + lf.lfItalic; + lf.lfUnderline; + lf.lfStrikeOut; + lf.lfCharSet; + lf.lfOutPrecision; + lf.lfClipPrecision; + lf.lfQuality; + lf.lfPitchAndFamily; + lf.lfFaceName[LF_FACESIZE];*/ + + cf.lStructSize = sizeof(CHOOSEFONT); + cf.hwndOwner = 0; + cf.hDC = NULL; + cf.lpLogFont = &lf;//&(Profile.LogFont); + cf.iPointSize = 0; + cf.Flags = /*CF_INITTOLOGFONTSTRUCT + |*/ CF_SCREENFONTS | CF_EFFECTS + /*| CF_ENABLEHOOK*/; + cf.rgbColors = 0;//Profile.rgbForeColor; + cf.lCustData = 0; + cf.lpfnHook = NULL; + cf.lpTemplateName = NULL; + cf.hInstance = NULL; + cf.lpszStyle = NULL; + cf.nFontType = SCREEN_FONTTYPE; + cf.nSizeMin = 0; + cf.nSizeMax = 0; +} + +CChooseFontDlg::~CChooseFontDlg(){ +} + +bool CChooseFontDlg::Create(CWindow * pWindow){ + cf.hwndOwner = pWindow->_hWnd; +return ChooseFont(&cf); +} + + +/*bool ChooseNewFont(HWND hWndListBox){ + static CHOOSEFONT cf; + static BOOL bFirstTime = TRUE; + HFONT hFont; + if(bFirstTime){ + bFirstTime = false; + } + if(ChooseFont(&cf)){ + HDC hDC; + hFont = CreateFontIndirect( &(Profile.LogFont) ); + hDC = GetDC( hWndListBox ); + SelectObject( hDC, hFont ); + Profile.rgbForeColor = cf.rgbColors; + InvalidateRect( hWndListBox, NULL, TRUE ); + SendMessage( hWndListBox, WM_CTLCOLORLISTBOX, (DWORD) hDC, (LONG) hWndListBox ); + SendMessage( hWndListBox, WM_SETFONT, (DWORD) hFont, TRUE ); + ReleaseDC( hWndListBox, hDC ); + } +return true; +}*/ + + +/******************************************************************** +* Class: CFindReplaceDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CFindReplaceDlg::CFindReplaceDlg(){ + pEditor = NULL; + hEditor = 0; + resId = 0; + *findWhat = '\0'; + *replaceWhat = '\0'; + + bWholeWord = false; + bMatchCase = true; + bRegExp = false; + bWrapFind = false; + bUnSlash = false; + bReverseFind = false; + bHavefound = false; +} + +CFindReplaceDlg::~CFindReplaceDlg(){ +} + +HWND CFindReplaceDlg::Find(CScintilla * pEditor){ + if (_hWnd || !pEditor) + return 0; +return CreateParam(pEditor, IDD_FIND, (long) IDD_FIND); +} + +HWND CFindReplaceDlg::Replace(CScintilla * pEditor){ + if (_hWnd || !pEditor) + return 0; +return CreateParam(pEditor, IDD_REPLACE, (long) IDD_REPLACE); +} + +LRESULT CALLBACK CFindReplaceDlg::CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam){ + switch(Message){ + case WM_INITDIALOG: + return OnInitDialog((HWND) wParam, lParam); + + case WM_COMMAND: + OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND) lParam); + break; + + case WM_CLOSE: + EndDlg(0); + break; + } +return FALSE; +} + +BOOL CFindReplaceDlg::OnInitDialog(HWND, LPARAM lInitParam){ + // Set pointers. + pEditor = (CEditor *) _pParent; + if (pEditor == NULL) + return TRUE; + + hEditor = pEditor->_hWnd; + resId = lInitParam; + + hFindWhat = GetItem(IDC_FINDWHAT); + hWholeWord = GetItem(IDC_WHOLEWORD); + hMatchCase = GetItem(IDC_MATCHCASE); + hRegExp = GetItem(IDC_REGEXP); + hWrap = GetItem(IDC_WRAP); + hUnSlash = GetItem(IDC_UNSLASH); + + if (resId == IDD_FIND) + return Find_OnInitDialog(); + else if (resId == IDD_REPLACE) + return Replace_OnInitDialog(); +return FALSE; +} + +BOOL CFindReplaceDlg::Find_OnInitDialog(void){ + + hUp = GetItem(IDC_DIRECTIONUP); + hDown = GetItem(IDC_DIRECTIONDOWN); + + SetItemText(hFindWhat, findWhat); + //FillComboFromMemory(wFindWhat, memFinds); + if (bWholeWord) + ::SendMessage(hWholeWord, BM_SETCHECK, BST_CHECKED, 0); + if (bMatchCase) + ::SendMessage(hMatchCase, BM_SETCHECK, BST_CHECKED, 0); + if (bRegExp) + ::SendMessage(hRegExp, BM_SETCHECK, BST_CHECKED, 0); + if (bWrapFind) + ::SendMessage(hWrap, BM_SETCHECK, BST_CHECKED, 0); + if (bUnSlash) + ::SendMessage(hUnSlash, BM_SETCHECK, BST_CHECKED, 0); + + if (bReverseFind) { + ::SendMessage(hUp, BM_SETCHECK, BST_CHECKED, 0); + } else { + ::SendMessage(hDown, BM_SETCHECK, BST_CHECKED, 0); + } +return TRUE; +} + +BOOL CFindReplaceDlg::Replace_OnInitDialog(void){ + SetItemText(hFindWhat, findWhat); + //FillComboFromMemory(wFindWhat, sci->memFinds); + + hReplaceWith = GetItem(IDC_REPLACEWITH); + SetItemText(hReplaceWith, replaceWhat); + //FillComboFromMemory(wReplaceWith, sci->memReplaces); + + if (bWholeWord) + ::SendMessage(hWholeWord, BM_SETCHECK, BST_CHECKED, 0); + if (bMatchCase) + ::SendMessage(hMatchCase, BM_SETCHECK, BST_CHECKED, 0); + if (bRegExp) + ::SendMessage(hRegExp, BM_SETCHECK, BST_CHECKED, 0); + if (bWrapFind) + ::SendMessage(hWrap, BM_SETCHECK, BST_CHECKED, 0); + if (bUnSlash) + ::SendMessage(hUnSlash, BM_SETCHECK, BST_CHECKED, 0); + if ((findWhat) != '\0'){ + ::SetFocus(hReplaceWith); + return FALSE; + } +return TRUE; +} + +BOOL CFindReplaceDlg::OnCommand(WORD, WORD wID, HWND){ + if (resId == IDD_FIND) + return Find_OnCommand(wID); + else if (resId == IDD_REPLACE) + return Replace_OnCommand(wID); +return FALSE; +} + +BOOL CFindReplaceDlg::Find_OnCommand(WORD wID){ + switch (wID){ + case IDOK: + char s[200]; + GetItemText(hFindWhat, s, sizeof(s)); + strcpy(findWhat, s); + //memFinds.Insert(s); + bWholeWord = BST_CHECKED == + ::SendMessage(hWholeWord, BM_GETCHECK, 0, 0); + bMatchCase = BST_CHECKED == + ::SendMessage(hMatchCase, BM_GETCHECK, 0, 0); + bRegExp = BST_CHECKED == + ::SendMessage(hRegExp, BM_GETCHECK, 0, 0); + bWrapFind = BST_CHECKED == + ::SendMessage(hWrap, BM_GETCHECK, 0, 0); + bUnSlash = BST_CHECKED == + ::SendMessage(hUnSlash, BM_GETCHECK, 0, 0); + bReverseFind = BST_CHECKED == + ::SendMessage(hUp, BM_GETCHECK, 0, 0); + + FindNext(bReverseFind, true); + return TRUE; + + case IDCANCEL: + EndDlg(IDCANCEL); + return FALSE; + } +return FALSE; +} + +BOOL CFindReplaceDlg::Replace_OnCommand(WORD wID){ + if (wID == IDCANCEL){ + EndDlg(IDCANCEL); + return FALSE; + }else{ + return HandleReplaceCommand(wID); + } +return FALSE; +} + +void CFindReplaceDlg::FindNext(bool reverseDirection, bool showWarnings){ + if (!hEditor){ + MsgBox.DisplayWarning("Can't get editor handle"); + return; + } + + if (!findWhat[0]) { // nothing to found + //Find(hEditor); + return; + } + char findTarget[FR_MAX_LEN + 1]; + strcpy(findTarget, findWhat); + + // for C conversions -> int lenFind = UnSlashAsNeeded(findTarget, unSlash, regExp); + int lenFind = strlen(findTarget); // normal return of UnSlashAsNeeded + + if (lenFind == 0) + return; + + CharacterRange cr = GetSelection(hEditor); + int startPosition = cr.cpMax; + int endPosition = LengthDocument(hEditor); + + if (reverseDirection){ + startPosition = cr.cpMin - 1; + endPosition = 0; + } + + int flags = (bWholeWord ? SCFIND_WHOLEWORD : 0) | + (bMatchCase ? SCFIND_MATCHCASE : 0) | + (bRegExp ? SCFIND_REGEXP : 0); + + ::SendMessage(hEditor, SCI_SETTARGETSTART, startPosition, 0); + ::SendMessage(hEditor, SCI_SETTARGETEND, endPosition, 0); + ::SendMessage(hEditor, SCI_SETSEARCHFLAGS, flags, 0); + int posFind = ::SendMessage(hEditor, SCI_SEARCHINTARGET, lenFind, (LPARAM) findTarget); + + if (posFind == -1 && bWrapFind){ // not found with wrapFind + + // Failed to find in indicated direction + // so search from the beginning (forward) or from the end (reverse) + // unless wrapFind is false + if (reverseDirection){ + startPosition = LengthDocument(hEditor); + endPosition = 0; + } else { + startPosition = 0; + endPosition = LengthDocument(hEditor); + } + ::SendMessage(hEditor, SCI_SETTARGETSTART, startPosition, 0); + ::SendMessage(hEditor, SCI_SETTARGETEND, endPosition, 0); + posFind = ::SendMessage(hEditor, SCI_SEARCHINTARGET, lenFind, (LPARAM) findTarget); + } + if (posFind == -1){ // not found + bHavefound = false; + if (showWarnings){ + + /*warn that not found + WarnUser(warnNotFound);*/ + + if (strlen(findWhat) > FR_MAX_LEN) + findWhat[FR_MAX_LEN] = '\0'; + char msg[FR_MAX_LEN + 50]; + strcpy(msg, "Cannot find the string \""); + strcat(msg, findWhat); + strcat(msg, "\"."); + if (_hWnd){ + MsgBox.DisplayWarning(msg); + }else{ + MessageBox(0, msg, "Message", MB_OK); + } + } + }else{ // found + bHavefound = true; + int start = ::SendMessage(hEditor, SCI_GETTARGETSTART, 0, 0); + int end = ::SendMessage(hEditor, SCI_GETTARGETEND, 0, 0); + EnsureRangeVisible(hEditor, start, end, true); + ::SendMessage(hEditor, SCI_SETSEL, start, end); + } +} + +BOOL CFindReplaceDlg::HandleReplaceCommand(int cmd){ + if (!hEditor){ + MsgBox.DisplayWarning("Can't get editor handle"); + return false; + } + + if ((cmd == IDOK) || (cmd == IDC_REPLACE) || (cmd == IDC_REPLACEALL) || (cmd == IDC_REPLACEINSEL)) { + GetItemText(hFindWhat, findWhat, sizeof(findWhat)); + //props.Set("find.what", findWhat); + //memFinds.Insert(findWhat); + + bWholeWord = BST_CHECKED == + ::SendMessage(hWholeWord, BM_GETCHECK, 0, 0); + bMatchCase = BST_CHECKED == + ::SendMessage(hMatchCase, BM_GETCHECK, 0, 0); + bRegExp = BST_CHECKED == + ::SendMessage(hRegExp, BM_GETCHECK, 0, 0); + bWrapFind = BST_CHECKED == + ::SendMessage(hWrap, BM_GETCHECK, 0, 0); + bUnSlash = BST_CHECKED == + ::SendMessage(hUnSlash, BM_GETCHECK, 0, 0); + } + if ((cmd == IDC_REPLACE) || (cmd == IDC_REPLACEALL) || (cmd == IDC_REPLACEINSEL)) { + GetItemText(hReplaceWith, replaceWhat, sizeof(replaceWhat)); + //memReplaces.Insert(replaceWhat); + } + + if (cmd == IDOK) { + FindNext(bReverseFind, true); // Find next + } else if (cmd == IDC_REPLACE) { + if (bHavefound){ + ReplaceOnce(); + } else { + CharacterRange crange = GetSelection(hEditor); + ::SendMessage(hEditor, SCI_SETSEL, crange.cpMin, crange.cpMin); + FindNext(bReverseFind, true); + if (bHavefound){ + ReplaceOnce(); + } + } + } else if ((cmd == IDC_REPLACEALL) || (cmd == IDC_REPLACEINSEL)){ + ReplaceAll(cmd == IDC_REPLACEINSEL); + } +return TRUE; +} + +void CFindReplaceDlg::ReplaceOnce(void){ + if (bHavefound){ + char replaceTarget[FR_MAX_LEN + 1]; + strcpy(replaceTarget, replaceWhat); + // for C conversions -> int replaceLen = UnSlashAsNeeded(replaceTarget, unSlash, regExp); + int replaceLen = strlen(replaceTarget); // normal return of UnSlashAsNeeded + + CharacterRange cr = GetSelection(hEditor); + ::SendMessage(hEditor, SCI_SETTARGETSTART, cr.cpMin, 0); + ::SendMessage(hEditor, SCI_SETTARGETEND, cr.cpMax, 0); + int lenReplaced = replaceLen; + if (bRegExp) + lenReplaced = ::SendMessage(hEditor, SCI_REPLACETARGETRE, replaceLen, (LPARAM) replaceTarget); + else // Allow \0 in replacement + ::SendMessage(hEditor, SCI_REPLACETARGET, replaceLen, (LPARAM) replaceTarget); + ::SendMessage(hEditor, SCI_SETSEL, cr.cpMin + lenReplaced, cr.cpMin); + bHavefound = false; + } + FindNext(bReverseFind, true); +} + +void CFindReplaceDlg::ReplaceAll(bool inSelection){ + char findTarget[FR_MAX_LEN + 1]; + strcpy(findTarget, findWhat); + + // for C conversions -> int findLen = UnSlashAsNeeded(findTarget, unSlash, regExp); + int findLen = strlen(findTarget); // normal return of UnSlashAsNeeded + + if (findLen == 0) { + MessageBox(_hWnd, "Find string for \"Replace All\" must not be empty.", "Message", MB_OK | MB_ICONWARNING); + return; + } + + CharacterRange cr = GetSelection(hEditor); + int startPosition = cr.cpMin; + int endPosition = cr.cpMax; + if (inSelection) { + if (startPosition == endPosition) { + MessageBox(_hWnd, "Selection for \"Replace in Selection\" must not be empty.", "Message", MB_OK | MB_ICONWARNING); + return; + } + } else { + endPosition = LengthDocument(hEditor); + if (bWrapFind) { + // Whole document + startPosition = 0; + } + // If not wrapFind, replace all only from caret to end of document + } + + char replaceTarget[FR_MAX_LEN + 1]; + strcpy(replaceTarget, replaceWhat); + + // for C conversions -> int replaceLen = UnSlashAsNeeded(replaceTarget, unSlash, regExp); + int replaceLen = strlen(replaceTarget); // normal return of UnSlashAsNeeded + + int flags = (bWholeWord ? SCFIND_WHOLEWORD : 0) | + (bMatchCase ? SCFIND_MATCHCASE : 0) | + (bRegExp ? SCFIND_REGEXP : 0); + ::SendMessage(hEditor, SCI_SETTARGETSTART, startPosition, 0); + ::SendMessage(hEditor, SCI_SETTARGETEND, endPosition, 0); + ::SendMessage(hEditor, SCI_SETSEARCHFLAGS, flags, 0); + int posFind = ::SendMessage(hEditor, SCI_SEARCHINTARGET, findLen, (LPARAM) findTarget); + if ((findLen == 1) && bRegExp && (findTarget[0] == '^')) { + // Special case for replace all start of line so it hits the first line + posFind = startPosition; + ::SendMessage(hEditor, SCI_SETTARGETSTART, startPosition, 0); + ::SendMessage(hEditor, SCI_SETTARGETEND, startPosition, 0); + } + if ((posFind != -1) && (posFind <= endPosition)) { + int lastMatch = posFind; + ::SendMessage(hEditor, SCI_BEGINUNDOACTION, 0, 0); + while (posFind != -1) { + int lenTarget = ::SendMessage(hEditor, SCI_GETTARGETEND, 0, 0) - ::SendMessage(hEditor, SCI_GETTARGETSTART, 0, 0); + int lenReplaced = replaceLen; + if (bRegExp) + lenReplaced = ::SendMessage(hEditor, SCI_REPLACETARGETRE, replaceLen, (LPARAM) replaceTarget); + else + ::SendMessage(hEditor, SCI_REPLACETARGET, replaceLen, (LPARAM) replaceTarget); + // Modify for change caused by replacement + endPosition += lenReplaced - lenTarget; + lastMatch = posFind + lenReplaced; + // For the special cases of start of line and end of line + // Something better could be done but there are too many special cases + if (lenTarget <= 0) + lastMatch++; + ::SendMessage(hEditor, SCI_SETTARGETSTART, lastMatch, 0); + ::SendMessage(hEditor, SCI_SETTARGETEND, endPosition, 0); + posFind = ::SendMessage(hEditor, SCI_SEARCHINTARGET, findLen, (LPARAM) findTarget); + } + if (inSelection) + ::SendMessage(hEditor, SCI_SETSEL, startPosition, endPosition); + else + ::SendMessage(hEditor, SCI_SETSEL, lastMatch, lastMatch); + ::SendMessage(hEditor, SCI_ENDUNDOACTION, 0, 0); + } else { + if (strlen(findWhat) > FR_MAX_LEN) + findWhat[FR_MAX_LEN] = '\0'; + char msg[FR_MAX_LEN + 50]; + strcpy(msg, "No replacements because string \""); + strcat(msg, findWhat); + strcat(msg, "\" was not present."); + MessageBox(_hWnd, msg, "Message", MB_OK | MB_ICONWARNING); + } +} + + +/******************************************************************** +* Class: CEditor. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CEditor::CEditor(){ + caretPos = 1; +} + +CEditor::~CEditor(){ +} + +void CEditor::LoadFile(CFileItem * file){ + if (!file || !_hWnd) + return; + + if (file->nFileOffset == 0) + return; // Untitled file. + + SetLexer(file->type); + ::SendMessage(_hWnd, SCI_CANCEL, 0, 0); + ::SendMessage(_hWnd, SCI_SETUNDOCOLLECTION, 0, 0); + + FILE *fp = fopen(file->szFileName, "rb"); + if (fp){ + char data[blockSize]; + int lenFile = fread(data, 1, sizeof(data), fp); + + while (lenFile > 0){ + ::SendMessage(_hWnd, SCI_ADDTEXT, lenFile, (LPARAM) data); + lenFile = fread(data, 1, sizeof(data), fp); + } + + fclose(fp); + + }else{ + MsgBox.DisplayWarning("Can't load file %s", file->szFileName); + } + + ::SendMessage(_hWnd, SCI_SETUNDOCOLLECTION, 1, 0); + ::SendMessage(_hWnd, EM_EMPTYUNDOBUFFER, 0, 0); + ::SendMessage(_hWnd, SCI_SETSAVEPOINT, 0 , 0); + ::SendMessage(_hWnd, SCI_GOTOPOS, 0, 0); +} + +void GetFileType(CFileItem * file){ + if (!file) + return; + + if (file->nFileExtension){ + char * ext = file->szFileName + file->nFileExtension; + // H_FILE ? + if (!stricmp(ext, "h")){ + file->type = H_FILE; + return; + }else if (!stricmp(ext, "hpp")){ + file->type = H_FILE; + return; + }else if (!stricmp(ext, "hxx")){ + file->type = H_FILE; + return; + // C_FILE ? + }else if (!stricmp(ext, "c")){ + file->type = C_FILE; + return; + }else if (!stricmp(ext, "cpp")){ + file->type = C_FILE; + return; + }else if (!stricmp(ext, "cxx")){ + file->type = C_FILE; + return; + // RC_FILE ? + }else if (!stricmp(ext, "rc")){ + file->type = RC_FILE; + return; + } + } + file->type = U_FILE; +return; +} + +void CEditor::SaveFile(char * fullPath){ + if (!_hWnd) + return; + + FILE *fp = fopen(fullPath, "wb"); + if (fp){ + char data[blockSize + 1]; + int lengthDoc = ::SendMessage(_hWnd, SCI_GETLENGTH, 0, 0); + for (int i = 0; i < lengthDoc; i += blockSize) { + int grabSize = lengthDoc - i; + if (grabSize > blockSize) + grabSize = blockSize; + GetRange(i, i + grabSize, data); + fwrite(data, grabSize, 1, fp); + } + fclose(fp); + ::SendMessage(_hWnd, SCI_SETSAVEPOINT, 0, 0); + + }else{ + MsgBox.DisplayWarning("Can't save file %s", fullPath); + } +} + +int CEditor::GetCurrentPos(void){ + int currentPos = ::SendMessage(_hWnd, SCI_GETCURRENTPOS, 0,0); + caretPos = ::SendMessage(_hWnd, SCI_LINEFROMPOSITION, currentPos, 0) + 1; +return caretPos; +} + +void CEditor::GetRange(int start, int end, char *text){ + TextRange tr; + tr.chrg.cpMin = start; + tr.chrg.cpMax = end; + tr.lpstrText = text; + ::SendMessage(_hWnd, SCI_GETTEXTRANGE, 0, (LPARAM) &tr); +} + +void CEditor::SetAStyle(int style, COLORREF fore, COLORREF back, int size, const char *face){ + ::SendMessage(_hWnd, SCI_STYLESETFORE, style, fore); + ::SendMessage(_hWnd, SCI_STYLESETBACK, style, back); + if (size >= 1) + ::SendMessage(_hWnd, SCI_STYLESETSIZE, style, size); + if (face) + ::SendMessage(_hWnd, SCI_STYLESETFONT, style, (LPARAM) face); +} + +void CEditor::DefineMarker(int marker, int markerType, COLORREF fore, COLORREF back) { + ::SendMessage(_hWnd, SCI_MARKERDEFINE, marker, markerType); + ::SendMessage(_hWnd, SCI_MARKERSETFORE, marker, fore); + ::SendMessage(_hWnd, SCI_MARKERSETBACK, marker, back); +} + +void CEditor::SetLexer(int fileType){ + switch (fileType){ + + case H_FILE: + case C_FILE: + case RC_FILE: + SetCppLexer(); + return; + + default: + // Global default style. + SetAStyle(STYLE_DEFAULT, black, white, 10, "Verdana"); + ::SendMessage(_hWnd, SCI_STYLECLEARALL, 0, 0); // Copies to all other styles. + + } +} + +void CEditor::SetCppLexer(void){ + ::SendMessage(_hWnd, SCI_SETLEXER, SCLEX_CPP, 0); + ::SendMessage(_hWnd, SCI_SETSTYLEBITS, 5, 0); + + ::SendMessage(_hWnd, SCI_SETKEYWORDS, 0, (LPARAM) cppKeyWords); + + // Global default style. + SetAStyle(STYLE_DEFAULT, black, white, 10, "Verdana"); + ::SendMessage(_hWnd, SCI_STYLECLEARALL, 0, 0); // Copies to all other styles. + + // C Styles. + SetAStyle(SCE_C_DEFAULT, black, white, 10, "Verdana"); //0 + SetAStyle(SCE_C_COMMENT, Green, white, 0, 0); //1 + SetAStyle(SCE_C_COMMENTLINE, Green, white, 0, 0); //2 + SetAStyle(SCE_C_COMMENTDOC, darkGreen, white, 0, 0); //3 + SetAStyle(SCE_C_NUMBER, Ice, white, 0, 0); //4 + SetAStyle(SCE_C_WORD, darkBlue, white, 0, 0); //5 + ::SendMessage(_hWnd, SCI_STYLESETBOLD, SCE_C_WORD, 1); + SetAStyle(SCE_C_STRING, Purple, white, 0, 0); //6 + SetAStyle(SCE_C_CHARACTER, Purple, white, 0, 0); //7 + SetAStyle(SCE_C_PREPROCESSOR, Olive, white, 0, 0); //9 + SetAStyle(SCE_C_OPERATOR, black, white, 0, 0); //10 + ::SendMessage(_hWnd, SCI_STYLESETBOLD, SCE_C_OPERATOR, 1); +// SetAStyle(SCE_C_STRINGEOL, darkBlue, white, 0, 0); //12 +// SetAStyle(SCE_C_COMMENTLINEDOC, darkBlue, white, 0, 0); //15 +// SetAStyle(SCE_C_WORD2, darkBlue, white, 0, 0); //16 + ::SendMessage(_hWnd, SCI_SETPROPERTY, (long)"fold", (long)"1"); + ::SendMessage(_hWnd, SCI_SETPROPERTY, (long)"fold.compact", (long)"1"); + ::SendMessage(_hWnd, SCI_SETPROPERTY, (long)"fold.symbols", (long)"1"); + + ::SendMessage(_hWnd, SCI_SETFOLDFLAGS, 16, 0); + + // To put the folder markers in the line number region + //SendEditor(SCI_SETMARGINMASKN, 0, SC_MASK_FOLDERS); + + ::SendMessage(_hWnd, SCI_SETMODEVENTMASK, SC_MOD_CHANGEFOLD, 0); + + // Create a margin column for the folding symbols + ::SendMessage(_hWnd, SCI_SETMARGINTYPEN, 2, SC_MARGIN_SYMBOL); + + ::SendMessage(_hWnd, SCI_SETMARGINWIDTHN, 2, /*foldMargin ? foldMarginWidth :*/ 16); + + ::SendMessage(_hWnd, SCI_SETMARGINMASKN, 2, SC_MASK_FOLDERS); + ::SendMessage(_hWnd, SCI_SETMARGINSENSITIVEN, 2, 1); + + DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_MINUS, white, black); + DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_PLUS, white, black); + DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_EMPTY, white, black); + DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_EMPTY, white, black); + DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_EMPTY, white, black); + DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_EMPTY, white, black); + DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_EMPTY, white, black); + +return; +} + +void CEditor::GotoLine(int line, char * /*fileName*/){ + ::SendMessage(_hWnd, SCI_ENSUREVISIBLEENFORCEPOLICY, line, 0); + ::SendMessage(_hWnd, SCI_GOTOLINE, line, 0); +} + +bool CEditor::MarginClick(int position, int modifiers){ + int lineClick = ::SendMessage(_hWnd, SCI_LINEFROMPOSITION, position, 0); + //Platform::DebugPrintf("Margin click %d %d %x\n", position, lineClick, + // ::SendMessage(_hWnd, SCI_GETFOLDLEVEL, lineClick) & SC_FOLDLEVELHEADERFLAG); +/* if ((modifiers & SCMOD_SHIFT) && (modifiers & SCMOD_CTRL)) { + FoldAll(); + } else {*/ + int levelClick = ::SendMessage(_hWnd, SCI_GETFOLDLEVEL, lineClick, 0); + if (levelClick & SC_FOLDLEVELHEADERFLAG) { + if (modifiers & SCMOD_SHIFT) { + // Ensure all children visible + ::SendMessage(_hWnd, SCI_SETFOLDEXPANDED, lineClick, 1); + Expand(lineClick, true, true, 100, levelClick); + } else if (modifiers & SCMOD_CTRL) { + if (::SendMessage(_hWnd, SCI_GETFOLDEXPANDED, lineClick, 0)) { + // Contract this line and all children + ::SendMessage(_hWnd, SCI_SETFOLDEXPANDED, lineClick, 0); + Expand(lineClick, false, true, 0, levelClick); + } else { + // Expand this line and all children + ::SendMessage(_hWnd, SCI_SETFOLDEXPANDED, lineClick, 1); + Expand(lineClick, true, true, 100, levelClick); + } + } else { + // Toggle this line + ::SendMessage(_hWnd, SCI_TOGGLEFOLD, lineClick, 0); + } + } +/* }*/ + return true; +} + +void CEditor::Expand(int &line, bool doExpand, bool force, int visLevels, int level){ + int lineMaxSubord = ::SendMessage(_hWnd, SCI_GETLASTCHILD, line, level & SC_FOLDLEVELNUMBERMASK); + line++; + while (line <= lineMaxSubord) { + if (force) { + if (visLevels > 0) + ::SendMessage(_hWnd, SCI_SHOWLINES, line, line); + else + ::SendMessage(_hWnd, SCI_HIDELINES, line, line); + } else { + if (doExpand) + ::SendMessage(_hWnd, SCI_SHOWLINES, line, line); + } + int levelLine = level; + if (levelLine == -1) + levelLine = ::SendMessage(_hWnd, SCI_GETFOLDLEVEL, line, 0); + if (levelLine & SC_FOLDLEVELHEADERFLAG) { + if (force) { + if (visLevels > 1) + ::SendMessage(_hWnd, SCI_SETFOLDEXPANDED, line, 1); + else + ::SendMessage(_hWnd, SCI_SETFOLDEXPANDED, line, 0); + Expand(line, doExpand, force, visLevels - 1); + } else { + if (doExpand) { + if (!::SendMessage(_hWnd, SCI_GETFOLDEXPANDED, line, 0)) + ::SendMessage(_hWnd, SCI_SETFOLDEXPANDED, line, 1); + Expand(line, true, force, visLevels - 1); + } else { + Expand(line, false, force, visLevels - 1); + } + } + } else { + line++; + } + } +} + diff --git a/rosapps/devutils/vmingw/editor.h b/rosapps/devutils/vmingw/editor.h new file mode 100644 index 00000000000..c098f871963 --- /dev/null +++ b/rosapps/devutils/vmingw/editor.h @@ -0,0 +1,165 @@ +/******************************************************************** +* Module: editor.h. This is part of Visual-MinGW. +* +* License: Visual-MinGW is covered by GNU General Public License, +* Copyright (C) 2001 Manu B. +* See license.htm for more details. +* +*******************************************************************/ +#ifndef EDITOR_H +#define EDITOR_H + +#include "Scintilla.h" +#include "SciLexer.h" +#include "winui.h" + +#define U_FILE 3 +#define H_FILE (U_FILE+1) +#define C_FILE (U_FILE+2) +#define RC_FILE (U_FILE+3) + +// Default block size. +const int blockSize = 131072; + +// Default colors. +const COLORREF black = RGB(0,0,0); +const COLORREF white = RGB(0xff,0xff,0xff); +const COLORREF darkBlue = RGB(0, 0, 0x7f); +const COLORREF Green = RGB(0, 0x7f, 0); +const COLORREF darkGreen = RGB(0x3f, 0x70, 0x3f); +const COLORREF Purple = RGB(0x7f, 0x00, 0x7f); +const COLORREF Ice = RGB(0x00, 0x7f, 0x7f); +const COLORREF Olive = RGB(0x7f, 0x7f, 0x00); + +// Default Cpp keywords. +const char cppKeyWords[] = +"asm auto bool break case catch char class const const_cast continue " +"default delete do double dynamic_cast else enum explicit export extern false float for " +"friend goto if inline int long mutable namespace new operator private protected public " +"register reinterpret_cast return short signed sizeof static static_cast struct switch " +"template this throw true try typedef typeid typename union unsigned using " +"virtual void volatile wchar_t while"; + +void EnsureRangeVisible(HWND hwndCtrl, int posStart, int posEnd, bool enforcePolicy); +int LengthDocument(HWND hwndCtrl); +CharacterRange GetSelection(HWND hwndCtrl); + +class CFileItem : public CNode +{ + public: + CFileItem(); + ~CFileItem(); + + // File name. + char szFileName[MAX_PATH]; + WORD nFileOffset; + WORD nFileExtension; + + // Owner tree view. + CTreeView * pTreeView; + HTREEITEM _hItem; + HTREEITEM _hDirItem; + + // Owner child window. + CMDIChild * pMdiChild; + int show; + bool isInProject; + + protected: + + private: +}; + +void GetFileType(CFileItem * file); + +class CEditor : public CScintilla +{ + public: + CEditor(); + ~CEditor(); + + void LoadFile(CFileItem * file); + void SaveFile(char * fullPath); + int GetCurrentPos(void); + void GotoLine(int line, char * fileName = NULL); + int caretPos; + void SetLexer(int fileType); + void SetCppLexer(void); + bool MarginClick(int position, int modifiers); + + protected: + + private: + void DefineMarker(int marker, int markerType, COLORREF fore, COLORREF back); + void GetRange(int start, int end, char *text); + void SetAStyle(int style, COLORREF fore, COLORREF back, int size, const char *face); + void Expand(int &line, bool doExpand, bool force = false, + int visLevels = 0, int level = -1); +}; + +#define FR_MAX_LEN 200 + +class CFindReplaceDlg : public CDlgBase +{ + public: + CFindReplaceDlg(); + virtual ~CFindReplaceDlg(); + + HWND Find(CScintilla * pEditor); + HWND Replace(CScintilla * pEditor); + + protected: + void FindNext(bool reverseDirection, bool showWarnings); + virtual LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + BOOL OnInitDialog(HWND hwndFocus, LPARAM lInitParam); + BOOL Find_OnInitDialog(void); + BOOL Replace_OnInitDialog(void); + BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hwndCtl); + BOOL Find_OnCommand(WORD wIDl); + BOOL Replace_OnCommand(WORD wID); + BOOL HandleReplaceCommand(int cmd); + void ReplaceOnce(void); + void ReplaceAll(bool inSelection); + + private: + HWND hFindWhat; + HWND hReplaceWith; + HWND hWholeWord; + HWND hMatchCase; + HWND hRegExp; + HWND hWrap; + HWND hUnSlash; + HWND hUp; + HWND hDown; + char findWhat[FR_MAX_LEN + 1]; + char replaceWhat[FR_MAX_LEN + 1]; + + bool bWholeWord; + bool bMatchCase; + bool bRegExp; + bool bWrapFind; + bool bUnSlash; + bool bReverseFind; + bool bHavefound; + + CEditor * pEditor; + HWND hEditor; + int resId; +}; + +class CChooseFontDlg : public CWindow +{ + public: + CChooseFontDlg(); + ~CChooseFontDlg(); + + bool Create(CWindow * pWindow); + + protected: + CHOOSEFONT cf; + LOGFONT lf; + + private: +}; + +#endif diff --git a/rosapps/devutils/vmingw/license.htm b/rosapps/devutils/vmingw/license.htm new file mode 100644 index 00000000000..fefc521bf06 --- /dev/null +++ b/rosapps/devutils/vmingw/license.htm @@ -0,0 +1,121 @@ + + + +Visual-MinGW license agreement. + + + + + +
+ + + + + + + + + + + + +

Visual-MinGW's + license

+ + + +

  + + + + + + + + + + + + +

 

Visual-MinGW + is a C/C++ Integrated Development Environment.
+ Copyright (C) 2001  Manu B.

+

The following license + terms applies to Visual-MinGW:

+

This program is free software; + you can redistribute it and/or modify it + under the
terms of the GNU General Public + License version 2 as published by the Free +
+ Software Foundation.

+

This program is distributed + in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied + warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE.
See + the
GNU + General Public License + for more details.

+

You should have received + a copy of the GNU General Public License
along with this program; + if not, write to the Free Software
Foundation, + Inc., 59 Temple Place - Suite 330, Boston, + MA 02111-1307,USA.

+

 


 

Visual-MinGW + uses Neil Hodgson's + Scintilla + editing component as source + code
+ editor.

+

The + following license terms applies to both + Scintilla + and SciTE.

+

 

License + for Scintilla and SciTE

+ + + +
+ + + + +

 

+

 

Copyright + 1998-2001 by Neil Hodgson <neilh@scintilla.org>

+

All Rights Reserved

+

Permission to use, copy, + modify, and distribute this software and + its
documentation for any purpose and + without fee is hereby granted,
provided + that the above copyright notice appear in + all copies and that
both that copyright + notice and this permission notice appear + in
supporting documentation.

+

NEIL HODGSON DISCLAIMS + ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES + OF MERCHANTABILITY
AND FITNESS, IN + NO EVENT SHALL NEIL HODGSON BE LIABLE FOR + ANY
SPECIAL, INDIRECT OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING + FROM LOSS OF USE, DATA OR PROFITS,
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + OR OTHER
TORTIOUS ACTION, ARISING OUT + OF OR IN CONNECTION WITH THE USE
OR + PERFORMANCE OF THIS SOFTWARE.

+

 

+

 

+

 

+ + + \ No newline at end of file diff --git a/rosapps/devutils/vmingw/license.txt b/rosapps/devutils/vmingw/license.txt new file mode 100644 index 00000000000..efd4e80ea66 --- /dev/null +++ b/rosapps/devutils/vmingw/license.txt @@ -0,0 +1,59 @@ +Visual-MinGW's license +---------------------- + +Visual-MinGW is a C/C++ Integrated Development Environment. +Copyright (C) 2001 Manu B. + +The following license terms applies to Visual-MinGW: + +This program is free software; you can redistribute it and/or modify it under the +terms of the GNU General Public License version 2 as published by the Free +Software Foundation. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. + +-------------------------------------------------------------------------------- + +Visual-MinGW uses Neil Hodgson's Scintilla editing component as source code +editor. + +The following license terms applies to both Scintilla and SciTE. + + +License for Scintilla and SciTE +------------------------------- + +Copyright 1998-2001 by Neil Hodgson + +All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation. + +NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE +OR PERFORMANCE OF THIS SOFTWARE. + + + + + + + + + diff --git a/rosapps/devutils/vmingw/main.cpp b/rosapps/devutils/vmingw/main.cpp new file mode 100644 index 00000000000..17f80dfd6c3 --- /dev/null +++ b/rosapps/devutils/vmingw/main.cpp @@ -0,0 +1,2622 @@ +/******************************************************************** +* Module: main.cpp. This is part of Visual-MinGW. +* +* Purpose: Main module. +* +* Authors: Manu B. +* +* License: Visual-MinGW is a C/C++ Integrated Development Environment. +* Copyright (C) 2001 Manu. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +* USA. +* +* (See license.htm for more details.) +* +* Revisions: +* Manu B. 12/15/01 CFileList created. +* +********************************************************************/ +#include +#include +#include +#include +#include "process.h" +#include "project.h" +#include "main.h" +#include "rsrc.h" + +#define MSG_MODIFIED "Modified" + +CCriticalSection CriticalSection; +extern CMessageBox MsgBox; +CFindReplaceDlg EditorDlg; +void Main_CmdTest(HWND hwnd); + +/* Globals */ +char * g_env_path = NULL; +char * g_vm_path = NULL; +CWinApp winApp; +CProject Project; +CChrono Chrono; + +// File filters & flags. +DWORD singleFileOpen = OFN_EXPLORER | OFN_FILEMUSTEXIST; +DWORD multipleFileOpen = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT; +DWORD fileSave = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | + OFN_OVERWRITEPROMPT; + +char * defFilter = "All Sources\0*.c;*.cpp;*.cxx;*.h;*.hpp;*.hxx;*.rc;*.mingw;*.prj\0" + "C Files\0*.c;*.cpp;*.cxx;*.rc\0" + "Headers\0*.h;*.hpp;*.hxx\0" + "Ini file\0*.ini\0" + "All Files (*.*)\0*.*\0\0"; + +char * prjFilter = "Project Files (*.prj)\0*.prj\0All Files (*.*)\0*.*\0\0"; +char * prjDefExt = "prj"; + +char * srcFilter = "All Sources\0*.c;*.cpp;*.cxx;*.h;*.hpp;*.hxx;*.rc\0" + "C Files\0*.c;*.cpp;*.cxx;*.rc\0" + "Headers\0*.h;*.hpp;*.hxx\0" + "All Files (*.*)\0*.*\0\0"; +char * srcDefExt = "cpp"; + +/* For tests */ + CChooseFontDlg CChooseFont; +void Main_CmdTest(HWND){ + winApp.Process.AddTask( + "sh.exe", + IN_PIPE || OUTERR_PIPE, + LVOUT_ERROR); + winApp.Process.Run(); +/* CChooseFont.Create(&winApp);*/ +return; +} + + +/******************************************************************** +* Class: CFileDlg. +* +* Purpose: A CFileDlgBase for Open/Save dlg boxes. +* +* Revisions: +* +********************************************************************/ +CFileDlg::CFileDlg(){ +} + +CFileDlg::~CFileDlg(){ +} + +bool CFileDlg::Open(CWindow * pWindow, char * pszFileName, DWORD nMaxFile, int fileflag){ + + switch(fileflag){ + // Project file. + case PRJ_FILE: + SetData(prjFilter, prjDefExt, singleFileOpen); + break; + + // Add multiple files to project. + case ADD_SRC_FILE: + Reset(); + SetTitle("Add files to project"); + nMaxFile = 2048; + SetFilterIndex(1); + SetData(srcFilter, srcDefExt, multipleFileOpen); + break; + + default: // SRC_FILE + SetData(defFilter, srcDefExt, singleFileOpen); + SetFilterIndex(1); + break; + } +return OpenFileName(pWindow, pszFileName, nMaxFile); +} + +bool CFileDlg::Save(CWindow * pWindow, char * pszFileName, DWORD nMaxFile, int fileflag){ + Reset(); + + switch(fileflag){ + case SRC_FILE: + SetData(defFilter, srcDefExt, fileSave); + SetFilterIndex(1); + break; + + default: // PRJ_FILE + SetData(prjFilter, prjDefExt, fileSave); + break; + } +return SaveFileName(pWindow, pszFileName, nMaxFile); +} + + +/******************************************************************** +* Class: CPreferencesDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CPreferencesDlg::CPreferencesDlg(){ +} + +CPreferencesDlg::~CPreferencesDlg(){ +} + +int CPreferencesDlg::Create(void){ +return CreateModal(&winApp, IDD_PREFERENCES, (LPARAM) this); +} + +LRESULT CALLBACK CPreferencesDlg::CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam){ + switch(Message){ + case WM_INITDIALOG: + return OnInitDialog((HWND) wParam, lParam); + + case WM_NOTIFY: + OnNotify((int) wParam, (LPNMHDR) lParam); + break; + + case WM_COMMAND: + OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND) lParam); + break; + + case WM_CLOSE: + EndDlg(0); + break; + } +return FALSE; +} + +BOOL CPreferencesDlg::OnInitDialog(HWND, LPARAM){ + // Tab control handle and TCITEM. + _hWndTab = ::GetDlgItem(_hWnd, IDC_PREF_TABS); + tcitem.mask = TCIF_TEXT | TCIF_PARAM; + + // Insert tabs. + HWND hwndChild = EnvDlg.Create(this, IDD_ENVIRON, NULL, (long) NULL); + tcitem.pszText = "Environment"; + tcitem.lParam = (long) &EnvDlg; + ::SendMessage(_hWndTab, TCM_INSERTITEM, 0, (LPARAM)&tcitem); + SetChildPosition(hwndChild); + +/* tcitem.pszText = "General"; + tcitem.lParam = (long) NULL; + ::SendMessage(_hWndTab, TCM_INSERTITEM, 1, (LPARAM)&tcitem); + + tcitem.pszText = "Find in files"; + tcitem.lParam = (long) NULL; + ::SendMessage(_hWndTab, TCM_INSERTITEM, 2, (LPARAM)&tcitem);*/ + + // Show the dialog and default pane. + Show(); + EnvDlg.Show(); + EnvDlg.SetFocus(); +return TRUE; +} + +BOOL CPreferencesDlg::OnCommand(WORD, WORD wID, HWND){ + switch (wID){ + case IDOK: + EnvDlg.OnCommand(0, wID, 0); + EndDlg(IDOK); + return TRUE; + + case IDCANCEL: + EndDlg(IDCANCEL); + return FALSE; + + case IDAPPLY: + EnvDlg.OnCommand(0, wID, 0); + return TRUE; + } +return FALSE; +} + +BOOL CPreferencesDlg::EndDlg(int nResult){ + EnvDlg.EndDlg(0); + EnvDlg.bIsVisible = false; + if (_hWnd){ + BOOL result = ::EndDialog(_hWnd, nResult); + _hWnd = 0; + return result; + } +return false; +} + + +/******************************************************************** +* Class: CEnvDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CEnvDlg::CEnvDlg(){ +} + +CEnvDlg::~CEnvDlg(){ +} + +LRESULT CALLBACK CEnvDlg::CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam){ + switch(Message){ + case WM_INITDIALOG: + return OnInitDialog((HWND) wParam, lParam); + + case WM_COMMAND: + OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND) lParam); + break; + } +return FALSE; +} + +BOOL CEnvDlg::OnInitDialog(HWND, LPARAM){ + bIsVisible = false; + bModified = false; + /* Get control handles */ + hApply = ::GetDlgItem(_pParent->_hWnd, IDAPPLY); + hSetCcBin = GetItem(IDC_SET_CCBIN); + hCcBinDir = GetItem(IDC_CCBIN); + hBrowseCc = GetItem(IDC_BROWSE_CC); + hSetCmdBin = GetItem(IDC_SET_CMDBIN); + hCmdBinDir = GetItem(IDC_CMDBIN); + hBrowseCmd = GetItem(IDC_BROWSE_CMD); + hAutoexec = GetItem(IDC_AUTOEXEC); + hEnvView = GetItem(IDC_ENV_VIEW); + + if (winApp.bSetCcEnv) + ::SendMessage(hSetCcBin, BM_SETCHECK, BST_CHECKED, 0); + if (winApp.bSetCmdEnv) + ::SendMessage(hSetCmdBin, BM_SETCHECK, BST_CHECKED, 0); + if (winApp.bSetDefEnv) + ::SendMessage(hAutoexec, BM_SETCHECK, BST_CHECKED, 0); + + SetItemText(hCcBinDir, winApp.szCcBinDir); + SetItemText(hCmdBinDir, winApp.szCmdBinDir); + SetEnvText(); +/* hCcIncDir = GetItem(IDC_CC_INCDIR); + + SetItemText(hCcIncDir, winApp.includeDir);*/ + bIsVisible = true; +return TRUE; +} + +BOOL CEnvDlg::OnCommand(WORD wNotifyCode, WORD wID, HWND){ + char directory[MAX_PATH]; + + switch (wID){ + case IDC_BROWSE_CC: + if (winApp.ShellDlg.BrowseForFolder(&winApp, directory, "Browse", + BIF_RETURNONLYFSDIRS)){ + SetItemText(hCcBinDir, directory); + } + return TRUE; + + case IDC_BROWSE_CMD: + if (winApp.ShellDlg.BrowseForFolder(&winApp, directory, "Browse", + BIF_RETURNONLYFSDIRS)){ + SetItemText(hCmdBinDir, directory); + } + return TRUE; + + case IDOK: + winApp.bSetCcEnv = + (BST_CHECKED==::SendMessage(hSetCcBin, BM_GETCHECK, 0, 0)); + winApp.bSetCmdEnv = + (BST_CHECKED==::SendMessage(hSetCmdBin, BM_GETCHECK, 0, 0)); + winApp.bSetDefEnv = + (BST_CHECKED==::SendMessage(hAutoexec, BM_GETCHECK, 0, 0)); + + GetItemText(hCcBinDir, winApp.szCcBinDir, MAX_PATH); + GetItemText(hCmdBinDir, winApp.szCmdBinDir, MAX_PATH); +// GetItemText(hCcIncDir, winApp.includeDir, MAX_PATH); + if (bModified) + winApp.SetEnv(); + return TRUE; + + case IDCANCEL: + return FALSE; + + case IDAPPLY: + if (bModified){ + winApp.bSetCcEnv = + (BST_CHECKED==::SendMessage(hSetCcBin, BM_GETCHECK, 0, 0)); + winApp.bSetCmdEnv = + (BST_CHECKED==::SendMessage(hSetCmdBin, BM_GETCHECK, 0, 0)); + winApp.bSetDefEnv = + (BST_CHECKED==::SendMessage(hAutoexec, BM_GETCHECK, 0, 0)); + + GetItemText(hCcBinDir, winApp.szCcBinDir, MAX_PATH); + GetItemText(hCmdBinDir, winApp.szCmdBinDir, MAX_PATH); + winApp.SetEnv(); + SetEnvText(); + bModified = false; + ::EnableWindow(hApply, false); + } + return TRUE; + + default: + if (bIsVisible && !bModified){ + switch(wNotifyCode){ + case EN_CHANGE: + case BN_CLICKED: + bModified = true; + ::EnableWindow(hApply, true); + return TRUE; + } + } + break; + } +return FALSE; +} + +void CEnvDlg::SetEnvText(void){ + if (g_vm_path){ + char * text = (char *) malloc(strlen(g_vm_path)+20); // 10 lines max. + char * start = text; + char * parse = g_vm_path; + while (*parse){ + if (*parse == ';'){ + // Change ';' into CR/LF. + *text = '\r'; + text++; + *text = '\n'; + text++; + parse++; + }else if (*parse == '='){ + // Rewind buffer. + text = start; + parse++; + }else{ + // Copy one char. + *text = *parse; + text++; + parse++; + } + } + *text = '\0'; + SetItemText(hEnvView, start); + free(start); + } +} + + +/******************************************************************** +* Class: CGrepDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CGrepDlg::CGrepDlg(){ + *findWhat = '\0'; + *gDir = '\0'; +} + +CGrepDlg::~CGrepDlg(){ +} + +int CGrepDlg::Create(void){ +return CreateModal(&winApp, IDD_GREP, (LPARAM) this); +} + +LRESULT CALLBACK CGrepDlg::CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam){ + switch(Message){ + case WM_INITDIALOG: + return OnInitDialog((HWND) wParam, lParam); + + case WM_COMMAND: + OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND) lParam); + break; + + case WM_CLOSE: + EndDlg(0); + break; + } +return FALSE; +} + +BOOL CGrepDlg::OnInitDialog(HWND, LPARAM){ + hFindWhat = GetItem(IDC_FINDWHAT); + hgDir = GetItem(IDC_GFILTER); + + SetItemText(hFindWhat, findWhat); + SetItemText(hgDir, gDir); + // Show the dialog and default pane. + Show(); +return TRUE; +} + +BOOL CGrepDlg::OnCommand(WORD, WORD wID, HWND){ + switch (wID){ + case IDOK: + GetItemText(hFindWhat, findWhat, sizeof(findWhat)); + GetItemText(hgDir, gDir, sizeof(gDir)); + FindInFiles(findWhat, gDir); + return TRUE; + + case IDCANCEL: + EndDlg(IDCANCEL); + return FALSE; + } +return FALSE; +} + +void CGrepDlg::FindInFiles(char * findWhat, char * fileFilter){ + if (!findWhat || !fileFilter || winApp.Process.isRunning()) + return; + + winApp.Report.Clear(); + winApp.Report.Append("Grep search...", LVOUT_NORMAL); + + winApp.Process.AddTask("grep -G -n -H ", OUTERR_PIPE, LVOUT_ERROR); + winApp.Process.CmdCat(findWhat); + winApp.Process.CmdCat(" "); + winApp.Process.CmdCat(fileFilter); + + winApp.Process.Run(); +} + + +/******************************************************************** +* Functions: WinMain procedure. +* +* Purpose: Runs the application. +* +* Revisions: +* +********************************************************************/ +int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ +return winApp.Run(hInstance, hPrevInstance, lpCmdLine, nCmdShow); +} + + +/******************************************************************** +* Class: CWinApp. +* +* Purpose: Manages the all application. +* +* Revisions: +* +********************************************************************/ +CWinApp::CWinApp(){ + *iniFileName = '\0'; + hmod = NULL; + *openFilesDir ='\0'; + *projectDir = '\0'; + *includeDir = '\0'; + bSetCcEnv = false; + bSetCmdEnv = false; + bSetDefEnv = false; + *szCcBinDir = '\0'; + *szCmdBinDir = '\0'; + + firstRun = false; + // Child windows dimensions. + deltaY = 0; + tbarHeight = 26; + sbarHeight = 20; + tvWidth = 140; + lvHeight = 120; + + hSplitter = 4; + vSplitter = 4; +} + +CWinApp::~CWinApp(){ +} + +bool CWinApp::CustomInit(void){ + /* Get PATH environment variable */ + char * env_path = getenv("PATH"); + if (env_path) + g_env_path = strdup(env_path); + + SetName("Visual MinGW", APP_VERSION); + MsgBox.SetCaption("Visual MinGW"); + IsWinNT(); + ReadIniFile("visual-mingw.ini"); + + hAccel = LoadAccelerators(_hInst, "ACCELS"); + hmod = LoadLibrary("SciLexer.DLL"); + if (!hmod){ + MsgBox.DisplayFatal("Unable to load SciLexer.DLL"); + return false; + } +return true; +} + +bool CWinApp::Release(void){ + WriteIniFile(); + if (hmod) + FreeLibrary(hmod); + if (g_env_path) + free(g_env_path); +return true; +} + +bool CWinApp::ReadIniFile(char * fileName){ + ParseCmdLine(iniFileName); + strcat(iniFileName, fileName); + + if (!IniFile.Load(iniFileName)){ + /* Create an empty file and fill it */ + firstRun = true; + MsgBox.DisplayWarning("Visual-MinGW first run !\n" + "Step 1: User interface initialization.\n" + "Please report bugs to Visual-MinGW home page.\n" + "See the Readme text for more information."); + FILE * file = fopen(iniFileName, "wb"); + if (!file) + return false; + SaveIniFile(file); + fclose(file); + return false; + } + // [General] section + IniFile.GetString(openFilesDir, "FilesDirectory", "General" ); + IniFile.GetString(projectDir, "ProjectDirectory" ); + bSetDefEnv = IniFile.GetInt( "SetDefEnv" ); + bSetCmdEnv = IniFile.GetInt( "SetBinDir" ); + IniFile.GetString(szCmdBinDir, "BinDir" ); + // [Compiler] section + IniFile.GetString(includeDir, "IncludeDir", "Compiler" ); + bSetCcEnv = IniFile.GetInt( "SetBinDir" ); + IniFile.GetString(szCcBinDir, "BinDir" ); + + SetEnv(); +return true; +} + +void CWinApp::SaveIniFile(FILE * file){ + // [General] + fprintf (file, "\t; Generated automatically by Visual-MinGW.\n"); + fprintf (file, "\t ; http://visual-mingw.sourceforge.net/\n"); + fprintf (file, "[General]\nSignature = 40"); + fprintf (file, "\nFilesDirectory = %s", openFilesDir); + fprintf (file, "\nProjectDirectory = %s", projectDir); + fprintf (file, "\nTvWidth = %d", tvWidth); + fprintf (file, "\nLvHeight = %d", lvHeight); + fprintf (file, "\nSetDefEnv = %d", bSetDefEnv); + fprintf (file, "\nSetBinDir = %d", bSetCmdEnv); + fprintf (file, "\nBinDir = %s", szCmdBinDir); + // [Compiler] + fprintf (file, "\n\n[Compiler]\nIncludeDir = %s", includeDir); + fprintf (file, "\nSetBinDir = %d", bSetCcEnv); + fprintf (file, "\nBinDir = %s", szCcBinDir); +} + +bool CWinApp::WriteIniFile(void){ + if (*iniFileName == '\0') + return false; + FILE * file = fopen(iniFileName, "wb"); + if (!file) + return false; + SaveIniFile(file); + fclose(file); + IniFile.Close(); +return true; +} + +bool CWinApp::SetEnv(void){ + // Free previous variable. + //getenv("PATH="); + // Malloc a buffer. + int len = 0; + if (bSetCcEnv) + len += strlen(winApp.szCcBinDir); + if (bSetCmdEnv) + len += strlen(winApp.szCmdBinDir); + if (bSetDefEnv && g_env_path) + len += strlen(g_env_path); + g_vm_path = (char *) malloc(len+8); + + // Copy the environment variable. + strcpy(g_vm_path, "PATH="); + if (bSetCcEnv && *winApp.szCcBinDir){ + strcat(g_vm_path, winApp.szCcBinDir); + strcat(g_vm_path, ";"); + } + if (bSetCmdEnv && *winApp.szCmdBinDir){ + strcat(g_vm_path, winApp.szCmdBinDir); + strcat(g_vm_path, ";"); + } + if (bSetDefEnv && g_env_path) + strcat(g_vm_path, g_env_path); + + len = strlen(g_vm_path) - 1; + if (g_vm_path[len] == ';') + g_vm_path[len] = '\0'; + if (putenv(g_vm_path) == -1){ + free(g_vm_path); + g_vm_path = NULL; + return false; + } +return true; +} + + +/******************************************************************** +* CWinApp: Create each application's window. +********************************************************************/ +bool CWinApp::CreateUI(void){ + + InitCommonControls(); + + // Custom values. + wc.style = 0; + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.hCursor = NULL; + wc.hbrBackground = //NULL; + (HBRUSH)(COLOR_INACTIVEBORDER + 1); + wc.lpszMenuName = MAKEINTRESOURCE(ID_MENU); + wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); + + if(!MainRegisterEx("main_class")) { + MsgBox.DisplayFatal("Can't Register Main Window"); + return false; + } + + // Custom values. + wc.hbrBackground = NULL; + wc.lpszMenuName = 0; + + if(!ChildRegisterEx("child_class")) { + MsgBox.DisplayFatal("Can't Register MDI Class"); + return false; + } + + // Use a CreateWindowEx like procedure. + HWND hwnd = CreateEx( + this, // Owner class. + 0, + mainClass, + appName, + WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + CW_USEDEFAULT, + 0, + NULL); + + if(!hwnd) { + MsgBox.DisplayFatal("Can't create Main window"); + return false; + } + MsgBox.SetParent(hwnd); + + // SW_SHOWMAXIMIZED. + ::ShowWindow(hwnd, SW_SHOWMAXIMIZED); + ::UpdateWindow(hwnd); + if (firstRun) + FirstRunTest(); + firstRun = false; +return true; +} + +void CWinApp::FirstRunTest(void){ + MsgBox.DisplayWarning("Visual-MinGW first run !\n" + "Step 2: You will now set your environment variables.\n" + "\"Use default environment variables\" should be checked.\n" + "Then Visual-MinGW will try to launch the compiler."); + PreferencesDlg.Create(); + MsgBox.DisplayWarning("Visual-MinGW first run !\n" + "Step 3: Installation checking.\n" + "Try to launch rm and gcc.\n" + "See \"Main\" or \"Log\" report views for results.\n"); + winApp.Report.Clear(); + winApp.Report.Append("Testing for first run...", LVOUT_NORMAL); + + // Put the command line and the run flag in the command stack. + winApp.Process.AddTask("gcc -v", OUTERR_PIPE, LVOUT_NORMAL); + winApp.Process.AddTask("rm --version", OUTERR_PIPE, LVOUT_NORMAL); + winApp.Process.Run(); +return; +} + +void CWinApp::CreateToolbar(void){ + Toolbar.CreateEx( + this, + 0, + WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS + |TBSTYLE_FLAT | TBSTYLE_TOOLTIPS + | CCS_NORESIZE); + + Toolbar.AddBitmap(IDB_TOOLBAR, 15); + + TBBUTTON tbButtons [] = + { { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0}, + { 0, IDM_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0}, + { 1, IDM_OPEN, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0}, + { 2, IDM_SAVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0}, + { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0}, + { 3, IDM_CUT, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0}, + { 4, IDM_COPY, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0}, + { 5, IDM_PASTE, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0}, + { 0, 0, TBSTATE_ENABLED, TBSTYLE_SEP, {0, 0}, 0, 0}, + { 6, IDM_UNDO, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0}, + { 7, IDM_REDO, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0, 0}, 0, 0} }; + + int numbutton = sizeof tbButtons/sizeof tbButtons[0]; + + Toolbar.AddButtons(&tbButtons[0], numbutton); +} + +void CWinApp::CreateSplitter(void){ + MainSplitter.Init(&ChildSplitter, &Report, SPLSTYLE_HORZ, lvHeight, SPLMODE_2); + ChildSplitter.Init(&Manager, &MdiClient, SPLSTYLE_VERT, tvWidth, SPLMODE_1); + + // File Manager. + Manager.Create(this); + // MDI client. + CreateMDI(); + // ListView. + Report.Create(this); +} + +void CWinApp::CreateMDI(void){ + MdiClient.Init(3, ID_FIRSTCHILD); + MdiClient.CreateEx( + this, + WS_EX_CLIENTEDGE, + WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS + | WS_VSCROLL | WS_HSCROLL + ); +} + +HWND CWinApp::CreateChild(char * caption, LPVOID lParam){ + + CChildView * mdiChild = new CChildView; + + HWND hwnd = mdiChild->CreateEx( + &MdiClient, // MUST be an MdiClient *. + WS_EX_MDICHILD, + MDIS_ALLCHILDSTYLES | WS_CHILD | WS_SYSMENU | WS_CAPTION + | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX + | WS_MAXIMIZE, + caption, + 0, + lParam); + + if (!hwnd) + delete mdiChild; +return hwnd; +} + +void CWinApp::CreateStatusBar(void){ + Sbar.CreateEx( + this, + 0, + WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | SBARS_SIZEGRIP); + + int sbWidths[] = {60, 120, -1}; + + int numparts = sizeof sbWidths/sizeof sbWidths[0]; + + Sbar.SetParts(numparts, &sbWidths[0]); +} + +void CWinApp::SendCaretPos(int caretPos) { + // To display the "Line : xxxx" message, we use our standard msgBuf[256]. + sprintf(msgBuf, "Line : %d", caretPos); + Sbar.SendMessage(SB_SETTEXT, 0, (LPARAM) msgBuf); +return; +} + + +/******************************************************************** +* CWinApp: Message handling procedures. +********************************************************************/ +LRESULT CALLBACK CWinApp::CMainWndProc(UINT Message, WPARAM wParam, LPARAM lParam){ + switch(Message){ + case WM_CREATE: + return OnCreate((LPCREATESTRUCT) lParam); + + case WM_PAINT: + return OnPaint((HDC) wParam); + + case WM_SIZE: + return OnSize(wParam, LOWORD(lParam), HIWORD(lParam)); + + case WM_DESTROY: + return OnDestroy(); + + case WM_COMMAND: + return OnCommand(wParam, lParam); + + case WM_CLOSE: + return OnClose(); + + case WM_NOTIFY: + return OnNotify((int) wParam, (LPNMHDR) lParam); + + case WM_LBUTTONDOWN: + return OnLButtonDown((short) LOWORD(lParam), (short) HIWORD(lParam), wParam); + + case WM_MOUSEMOVE: + return OnMouseMove((short) LOWORD(lParam), (short) HIWORD(lParam), wParam); + + case WM_LBUTTONUP: + return OnLButtonUp((short) LOWORD(lParam), (short) HIWORD(lParam), wParam); + + case WM_SETCURSOR: + OnSetCursor((HWND) wParam, (UINT) LOWORD(lParam), (UINT) HIWORD(lParam)); + return DefWindowProc(_hWnd, Message, wParam, lParam); + + default: + return DefFrameProc(_hWnd, MdiClient.GetId(), Message, wParam, lParam); + } +return 0; +} + +BOOL CWinApp::OnCreate(LPCREATESTRUCT){ + // Toolbar. + CreateToolbar(); + // Splitter. + CreateSplitter(); + // Statusbar. + CreateStatusBar(); +return TRUE; +} + +BOOL CWinApp::OnPaint(HDC){ + PAINTSTRUCT ps; + BeginPaint(_hWnd, &ps); + EndPaint(_hWnd, &ps); +return 0; +} + +BOOL CWinApp::OnSize(UINT, int width, int height){ + // TreeView and MDI Client delta-height. + deltaY = height-sbarHeight-lvHeight-vSplitter-tbarHeight; + + if (deltaY>3){ + Toolbar.SetPosition(0, + 0, 0, + width, tbarHeight, + 0); + + MainSplitter.SetPosition(0, + 0, tbarHeight, + width, height-tbarHeight-sbarHeight, + 0); + + Sbar.SetPosition(0, + 0, height-sbarHeight, + width, sbarHeight, + 0); + } + InvalidateRect(_hWnd, NULL, false); +return 0; +} + +BOOL CWinApp::OnDestroy(void){ + PostQuitMessage(0); +return 0; +} + +BOOL CWinApp::OnClose(void){ + if (IDCANCEL == Manager.SaveAll(IDASK)) // Ask to save. + return TRUE; // Cancelled by user. + ::DestroyWindow(_hWnd); +return 0; +} + +BOOL CWinApp::OnNotify(int idCtrl, LPNMHDR notify){ + Manager.OnNotify(idCtrl, notify); + Report.OnNotify(idCtrl, notify); +return 0; +} + +BOOL CWinApp::OnLButtonDown(short xPos, short yPos, UINT){ + MainSplitter.OnLButtonDown(_hWnd, xPos, yPos); + ChildSplitter.OnLButtonDown(_hWnd, xPos, yPos); +return 0; +} + +BOOL CWinApp::OnMouseMove(short xPos, short yPos, UINT){ + MainSplitter.OnMouseMove(_hWnd, xPos, yPos); + ChildSplitter.OnMouseMove(_hWnd, xPos, yPos); +return 0; +} + +BOOL CWinApp::OnLButtonUp(short xPos, short yPos, UINT){ + MainSplitter.OnLButtonUp(_hWnd, xPos, yPos); + ChildSplitter.OnLButtonUp(_hWnd, xPos, yPos); +return 0; +} + +BOOL CWinApp::OnSetCursor(HWND, UINT nHittest, UINT){ + if (nHittest == HTCLIENT) { + if (MainSplitter.OnSetCursor(_hWnd, 0)){ + return 0; + }else if (ChildSplitter.OnSetCursor(_hWnd, 0)){ + return 0; + }else{ + ::SetCursor(::LoadCursor(NULL, IDC_ARROW)); + } + } +return 0; +} + + +/******************************************************************** +* CWinApp: Dispatch command messages. +********************************************************************/ +BOOL CWinApp::OnCommand(WPARAM wParam, LPARAM lParam){ + int wID = LOWORD(wParam); + + switch (wID){ + /* File Menu */ + case IDM_NEW: + Manager.FilesView.New(); + break; + + case IDM_OPEN: + Manager.OpenFileDialog(); + break; + + case IDM_NEW_PROJECT: + Manager.NewProjectDialog(); + break; + + case IDM_OPEN_PROJECT: + Manager.OpenProjectDialog(); + break; + + case IDM_SAVE_PROJECT: + Manager.SaveProjectFiles(IDYES); + break; + + case IDM_CLOSE_PROJECT: + Manager.CloseProject(); + break; + + case IDM_PREFERENCES: + PreferencesDlg.Create(); + break; + + case IDM_QUIT: + PostMessage(_hWnd, WM_CLOSE, 0, 0); + break; + + /* Find Menu */ + case IDM_GREP: + GrepDlg.Create(); + break; + + /* Window Menu */ + case IDM_CASCADE: + PostMessage(MdiClient.GetId(), WM_MDICASCADE, 0, 0); + break; + case IDM_TILEHORZ: + PostMessage(MdiClient.GetId(), WM_MDITILE, MDITILE_HORIZONTAL, 0); + break; + case IDM_TILEVERT: + PostMessage(MdiClient.GetId(), WM_MDITILE, MDITILE_VERTICAL, 0); + break; + case IDM_ARRANGE: + PostMessage(MdiClient.GetId(), WM_MDIICONARRANGE, 0, 0); + break; + + /* Project Menu */ + case IDM_NEW_MODULE: + Project.NewModuleDlg(); + break; + + case IDM_ADD: + Project.AddFiles(); + break; + + case IDM_REMOVE_FILE: + Manager.RemoveProjectFile(); + break; + + case IDM_REMOVE_MODULE: + Manager.RemoveProjectModule(); + break; + + case IDM_OPTION: + Project.OptionsDlg(); + break; + + case IDM_ZIP_SRCS: + Project.ZipSrcs(); + break; + + case IDM_EXPLORE: + Project.Explore(_hWnd); + break; + + /* Build Menu */ + case IDM_BUILD: + Project.Build(); + break; + + case IDM_REBUILDALL: + Project.RebuildAll(); + break; + + case IDM_RUN_TARGET: + Project.RunTarget(); + break; + + case IDM_MKCLEAN: + Project.MakeClean(); + break; + + case IDM_MKF_BUILD: + Project.BuildMakefile(); + break; + + case IDM_RUN_CMD: + winApp.Process.CommandDlg.Create(); + break; + + case IDM_TEST: + Main_CmdTest(_hWnd); + break; + + default:{ + if (wID >= ID_FIRSTCHILD){ + DefFrameProc(_hWnd, MdiClient.GetId(), WM_COMMAND, wParam, lParam); + }else{ + HWND hChildWindow = (HWND) MdiClient.SendMessage(WM_MDIGETACTIVE); + + if (hChildWindow) + ::SendMessage(hChildWindow, WM_COMMAND, wParam, lParam); + } + } + } +return TRUE; +} + + +/******************************************************************** +* CWinApp: Handles child messages. +********************************************************************/ +LRESULT CALLBACK CWinApp::CChildWndProc(CWindow * pWnd, UINT Message, WPARAM wParam, LPARAM lParam){ + + CChildView * childView = (CChildView *) pWnd; + HWND hwndChild = childView->_hWnd; + + switch(Message){ + case WM_CREATE: + childView->OnCreate((LPCREATESTRUCT) lParam); + break; + + case WM_SIZE: + childView->OnSize(wParam, LOWORD(lParam), HIWORD(lParam)); + break; + + case WM_COMMAND: + childView->OnCommand(wParam, lParam); + break; + + case WM_DESTROY: + childView->OnDestroy(); + break; + + case WM_CLOSE: + if (childView->OnClose()){ + MdiClient.SendMessage(WM_MDIDESTROY,(WPARAM) hwndChild, 0); + } + return true; + + case WM_NOTIFY: + childView->OnNotify((int) wParam, (LPNMHDR) lParam); + break; + + case WM_SETFOCUS: + childView->OnSetFocus((HWND) wParam); + break; + + case WM_MDIACTIVATE: + childView->OnActivate((HWND) wParam, (HWND) lParam); + break; + } +return DefMDIChildProc(hwndChild, Message, wParam, lParam); +} + + +/******************************************************************** +* Class: CChildView. +* +* Purpose: MDI child window class. +* +* Revisions: +* +********************************************************************/ +CChildView::CChildView(){ + modified = false; +} + +CChildView::~CChildView(){ +} + +bool CChildView::OnCreate(LPCREATESTRUCT){ + CFileItem * file = (CFileItem *) GetLong(GWL_USERDATA); + + // Create Scintilla Editor Control. + HWND hwnd = Editor.CreateEx( + this, + 0, + WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS + | WS_VSCROLL | WS_HSCROLL); + + if (!hwnd) + return false; // @@TODO need to manage creation failure. + + // Set window handles + file->pMdiChild = this; + + // Load a file if there is one to load. + Editor.LoadFile(file); +return true; +} + +bool CChildView::OnSize(UINT wParam, int width, int height){ + if(wParam != SIZE_MINIMIZED){ + Editor.SetPosition(0, + 0, + 0, + width, + height, + 0); + } +return true; +} + +BOOL CChildView::OnClose(void){ + if (modified){ + int decision = MsgBox.AskToSave(true); + switch (decision){ + case IDCANCEL: + return FALSE; + + case IDYES: + CmdSave(); + break; + } + } +return TRUE; +} + +BOOL CChildView::OnDestroy(void){ + CFileItem * file = (CFileItem*) GetLong(GWL_USERDATA); + + if (file){ + if (!file->isInProject){ + // A simple file. + winApp.Manager.FilesView.CloseFile(file); + }else{ + // A project one. + file->pMdiChild = NULL; + //modified = false; + } + } +return 0; +} + +BOOL CChildView::OnNotify(int, LPNMHDR notify){ + SCNotification * notification = (SCNotification *) notify; + + // Notify Message from Current Editor Control. + if (notify->hwndFrom == Editor._hWnd){ + switch (notify->code){ + case SCN_UPDATEUI: + Editor.GetCurrentPos(); + winApp.SendCaretPos(Editor.caretPos); + break; + + case SCN_SAVEPOINTREACHED: + modified = false; + winApp.Sbar.WriteString("", 1); + break; + + case SCN_SAVEPOINTLEFT: + modified = true; + winApp.Sbar.WriteString(MSG_MODIFIED, 1); + break; + + case SCN_MARGINCLICK: + if (notification->margin == 2) + Editor.MarginClick(notification->position, notification->modifiers); + break; + } + } +return 0; +} + +BOOL CChildView::OnSetFocus(HWND){ + CFileItem * file = (CFileItem*) GetLong(GWL_USERDATA); + if (!file) + return false; + // Select corresponding TreeView item. + CTreeView * pTreeView = file->pTreeView; + + if(!pTreeView) + return false; + + pTreeView->SendMessage(TVM_SELECTITEM, (WPARAM)TVGN_CARET, (LPARAM)file->_hItem); + + // Set Focus on Editor Control. + Editor.SetFocus(); + + // Display "Modified" message or nothing in the Status Bar. + winApp.SendCaretPos(Editor.caretPos); + + if(modified) + winApp.Sbar.SendMessage(SB_SETTEXT, 1, (LPARAM) MSG_MODIFIED); + else + winApp.Sbar.SendMessage(SB_SETTEXT, 1, (LPARAM) ""); + + int selectedTab = winApp.Manager.SendMessage(TCM_GETCURSEL); + + if (file->isInProject == true && selectedTab != PROJECT_TAB){ + winApp.Manager.SendMessage(TCM_SETCURFOCUS, PROJECT_TAB); + }else if (file->isInProject == false && selectedTab != FILES_TAB){ + winApp.Manager.SendMessage(TCM_SETCURFOCUS, FILES_TAB); + } +return 0; +} + +BOOL CChildView::OnActivate(HWND, HWND hwndChildAct){ + HMENU hMenu; + HMENU hFileMenu; + BOOL EnableFlag; + HWND hwndMain = winApp._hWnd; + + hMenu = GetMenu(hwndMain); + + if(_hWnd == hwndChildAct){ + EnableFlag = TRUE; //being activated + }else{ + EnableFlag = FALSE; //being de-activated + } + // Menu items. + EnableMenuItem(hMenu, 1, MF_BYPOSITION | (EnableFlag ? MF_ENABLED : MF_GRAYED)); + EnableMenuItem(hMenu, 3, MF_BYPOSITION | (EnableFlag ? MF_ENABLED : MF_GRAYED)); + + // Sub-menu items. + hFileMenu = GetSubMenu(hMenu, 0); + EnableMenuItem(hFileMenu, IDM_SAVE, MF_BYCOMMAND | (EnableFlag ? MF_ENABLED : MF_GRAYED)); + EnableMenuItem(hFileMenu, IDM_SAVEAS, MF_BYCOMMAND | (EnableFlag ? MF_ENABLED : MF_GRAYED)); + hFileMenu = GetSubMenu(hMenu, 2); + EnableMenuItem(hFileMenu, IDM_FIND, MF_BYCOMMAND | (EnableFlag ? MF_ENABLED : MF_GRAYED)); + EnableMenuItem(hFileMenu, IDM_REPLACE, MF_BYCOMMAND | (EnableFlag ? MF_ENABLED : MF_GRAYED)); + DrawMenuBar(hwndMain); +return 0; +} + +void CChildView::CmdSave(void){ + CFileItem * file = (CFileItem*) GetLong(GWL_USERDATA); + + if (!file) + return; + /* Untitled file ? */ + if (file->nFileOffset == 0){ + CmdSaveAs(); + return; + } + + if (!file->isInProject){ + // A simple file. + Editor.SaveFile(file->szFileName); + }else{ + // A project one. + Project.szDirBuffer[Project.nFileOffset - 1] = '\\'; + strcpy(&Project.szDirBuffer[Project.nFileOffset], file->szFileName); + Editor.SaveFile(Project.szDirBuffer); + Project.szDirBuffer[Project.nFileOffset - 1] = '\0'; + } +} + +void CChildView::CmdSaveAs(void){ + CFileItem * file = (CFileItem*) GetLong(GWL_USERDATA); + if (!file) + return; + + char fileName[MAX_PATH]; + if (!winApp.FileDlg.Save(&winApp, fileName, MAX_PATH, SRC_FILE)) //@@ + return; // canceled by user + + ::SetWindowText(_hWnd, fileName); + strcpy(file->szFileName, fileName); + + Editor.SaveFile(file->szFileName); + //@@ TODO we need to check for errors +} + +BOOL CChildView::OnCommand(WPARAM wParam, LPARAM){ + CFileItem * file = (CFileItem*) GetLong(GWL_USERDATA); + + if(!file) + return false; + + switch (LOWORD(wParam)){ + case IDM_SAVE: + CmdSave(); + break; + + case IDM_SAVEAS: + CmdSaveAs(); + break; + + case IDM_SAVEALL: + winApp.Manager.SaveAll(IDYES); // Silent. + break; + +/* case IDM_CLOSE: + PostMessage(pWnd, WM_CLOSE, 0, 0); + break; +*/ + // To Scintilla control. + case IDM_FIND: + EditorDlg.Find(&Editor); + break; + + case IDM_REPLACE: + EditorDlg.Replace(&Editor); + break; + + case IDM_CUT: + Editor.SendMessage(SCI_CUT); + break; + case IDM_COPY: + Editor.SendMessage(SCI_COPY); + break; + case IDM_PASTE: + Editor.SendMessage(SCI_PASTE); + break; + case IDM_UNDO: + Editor.SendMessage(SCI_UNDO); + break; + case IDM_REDO: + Editor.SendMessage(SCI_REDO); + break; + case IDM_SELECTALL: + Editor.SendMessage(SCI_SELECTALL); + break; + } +return TRUE; +} + + +/******************************************************************** +* Class: CManager. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CManager::CManager(){ +} + +CManager::~CManager(){ +} + +void CManager::OpenFileDialog(void){ + CFileItem * file = new CFileItem; + + /* Show the "Open file" dialog */ + winApp.FileDlg.Reset(); + winApp.FileDlg.SetInitialDir(winApp.openFilesDir); + + if(!winApp.FileDlg.Open(&winApp, file->szFileName, MAX_PATH, SRC_FILE)){ + delete file; + return; // canceled by user + } + + /* Get file information */ + file->nFileExtension = winApp.FileDlg.GetFileExtension(); + file->nFileOffset = winApp.FileDlg.GetFileOffset(); + GetFileType(file); + // Copy file directory. + strncpy(winApp.openFilesDir, file->szFileName, (file->nFileOffset - 1)); + winApp.openFilesDir[file->nFileOffset-1] = '\0'; + + /* Load the file */ + if(!OpenFile(file)){ + delete file; + MsgBox.DisplayString("This file is already opened."); + } +} + +bool CManager::OpenFile(CFileItem * file){ + if (!file) + return false; + + if (!file->isInProject){ + if (!FilesView.OpenFile(file)) + return false; + }else{ + if (!ProjectView.OpenFile(file)) + return false; + } +return true; +} + +bool CManager::NewProjectDialog(void){ + if(IDYES == Project.CloseDecision()) + CloseProject(); + + char fileName[MAX_PATH]; + WORD fileOffset; + *fileName = '\0'; + + + if (!winApp.FileDlg.Save(&winApp, fileName, MAX_PATH, PRJ_FILE)){ + return false; // canceled by user + } + // Copy prj file's directory. + fileOffset = winApp.FileDlg.GetFileOffset(); + + ProjectView.CreateRoot("Project"); + if (!Project.New(fileName, fileOffset)){ + ProjectView.DestroyRoot(); + ProjectView.DestroyList(); + return false; + } +return true; +} + +bool CManager::OpenProjectDialog(void){ + if(IDYES == Project.CloseDecision()) + CloseProject(); + + char fileName[MAX_PATH]; + WORD offset; + *fileName = '\0'; + + // Load default values. + winApp.FileDlg.Reset(); + winApp.FileDlg.SetInitialDir(winApp.projectDir); + + if (!winApp.FileDlg.Open(&winApp, fileName, MAX_PATH, PRJ_FILE)){ + return false; // canceled by user + } + // Copy project file's directory. + offset = winApp.FileDlg.GetFileOffset(); + + // Initialize project tree view. + ProjectView.CreateRoot(fileName+offset); + + if (!Project.Open(fileName, offset)){ + ProjectView.DestroyRoot(); + ProjectView.DestroyList(); + return false; + } +return true; +} + +bool CManager::CloseProject(void){ +return ProjectView.Close(); +} + +void CManager::RemoveProjectFile(void){ + ProjectView.RemoveFile(); +} + +void CManager::RemoveProjectModule(void){ + ProjectView.RemoveModule(); +} + +int CManager::SaveProjectFiles(int decision){ +return ProjectView.SaveAll(decision); +} + +int CManager::SaveAll(int decision){ + /* Save open files ? */ + decision = FilesView.SaveAll(decision); + /* Save project files ? */ + decision = ProjectView.SaveAll(decision); +return decision; +} + +void CManager::CreateImageList(void){ + // Create an empty image list. + ImgList.Create(16, 16, ILC_COLORDDB|ILC_MASK, 8, 1); + + // Load treeview bmp and add it to the image list. + CBitmap tvBitmap; + tvBitmap.Load(this, IDB_TREEVIEW); + ImgList.AddMasked(&tvBitmap, RGB(255,0,255)); + + // We no longer need treeview bmp. + tvBitmap.Destroy(); +} + +void CManager::Create(CWindow * pParent){ + // Create the Tab Control. + CreateEx( + pParent, + WS_EX_CLIENTEDGE, + WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS + | TCS_BOTTOM | TCS_FOCUSNEVER); + + // Give it the default font, create tabs, select first one and show the control. + SendMessage(WM_SETFONT, (long) GetStockObject(DEFAULT_GUI_FONT), 0); + + InsertItem(FILES_TAB, TCIF_TEXT, 0, 0, "Files", 16, 0, 0); + InsertItem(PROJECT_TAB, TCIF_TEXT, 0, 0, "Project", 16, 0, 0); + Show(); + + // Create an Image list and then the Project TreeView. + CreateImageList(); + ProjectView.Create(this, &ImgList); + SetItem_Param(PROJECT_TAB, (long) &ProjectView); + FilesView.Create(this, &ImgList); + SetItem_Param(FILES_TAB, (long) &FilesView); +} + +bool CManager::SetPosition(HWND, int x, int y, int width, int height, UINT){ + /* Overwrites CTabCtrl::SetPosition() so that all child windows are also resized */ + + // Tab Control. + ::SetWindowPos(_hWnd, 0, + x, + y, + width, + height, + 0); + // Child windows. + RECT Rect; + ::GetClientRect(_hWnd, &Rect); + ProjectView.SetPosition(0, Rect.top +5, Rect.left +5, + Rect.right-10, Rect.bottom-30, 0); + + FilesView.SetPosition(0, Rect.top +5, Rect.left +5, + Rect.right-10, Rect.bottom-30, 0); +return true; +} + +BOOL CManager::OnNotify(int, LPNMHDR notify){ + // Dispatch messages. + switch (notify->code){ + // Tab Control. + case TCN_SELCHANGING: + OnSelChanging(notify); + break; + + case TCN_SELCHANGE: + OnSelChange(notify); + break; + + // TreeView. + case TVN_SELCHANGED: + Tv_OnSelchanged((LPNMTREEVIEW) notify); + break; + } +return TRUE; +} + +void CManager::OnSelChanging(LPNMHDR notify){ + if (_hWnd == notify->hwndFrom){ + CTreeView * pTreeView = (CTreeView *) GetItem_Param(GetCurSel()); + if (pTreeView){ + pTreeView->Hide(); + } + } +} + +void CManager::OnSelChange(LPNMHDR notify){ + if (_hWnd == notify->hwndFrom){ + CTreeView * pTreeView = (CTreeView *) GetItem_Param(GetCurSel()); + if (pTreeView){ + pTreeView->Show(); + } + } +} + +void CManager::Tv_OnSelchanged(LPNMTREEVIEW notify){ + // Get lParam of current tree item. + CFileItem * file = (CFileItem *) notify->itemNew.lParam; + + if (file){ + CChildView * pMdiChild = (CChildView *) file->pMdiChild; + + if(pMdiChild){ + // An editor, focus it. + ::SetFocus((HWND) pMdiChild->_hWnd); + }else{ + // No editor, the item is part of a project. + Project.SwitchCurrentDir(); + winApp.CreateChild(file->szFileName, file); + } + } +} + + +/******************************************************************** +* Class: CFilesView. +* +* Purpose: Open files TreeView. +* +* Revisions: +* +********************************************************************/ +CFilesView::CFilesView(){ + hRoot = NULL; +} + +CFilesView::~CFilesView(){ +} + +void CFilesView::New(void){ + CFileItem * file = new CFileItem; + if(!winApp.Manager.OpenFile(file)){ + delete file; + MsgBox.DisplayString("Untitled file already exist."); + } +} + +bool CFilesView::OpenFile(CFileItem * file){ + if (!file) + return false; + + int listAction; + char * fileName = file->szFileName + file->nFileOffset; + + /* Untitled file ? */ + if (file->nFileOffset == 0){ + //@@TODO add a counter to get Untitled01, 02, etc... + strcpy(file->szFileName, "Untitled"); + } + + /* Check if this file is already opened */ + listAction = InsertSorted_New(file); + + if (listAction == FILE_FOUND){ + /* Focus the editor window */ + CFileItem * currentFile = (CFileItem *) GetCurrent(); + if (currentFile){ + CMDIChild * pMdiChild = currentFile->pMdiChild; + if (pMdiChild) + pMdiChild->SetFocus(); + } + return false; + } + + /* Create the editor window */ + if (!winApp.CreateChild(file->szFileName, file)){ + MsgBox.DisplayFatal("Can't create child window"); + return false; + } + // Note: A WM_SETFOCUS message will be send to the child window. + + /* Append the file to the list */ + InsertLast(file); + + /* Create a Tree View item */ + file->_hItem = CreateItem( + hRoot, //@@ use a GetRootItem() ? + TVI_LAST, + file->type, + fileName, + (LPARAM) file); + + file->pTreeView = this; +return true; +} + +void CFilesView::CloseFile(CFileItem * file){ + SendMessage(TVM_DELETEITEM, 0, (LPARAM) file->_hItem); + Destroy(file); +} + +int CFilesView::SaveAll(int decision){ + if (decision == IDNO || decision == IDCANCEL) + return decision; + CFileItem * file = (CFileItem*) First(); + while (file){ + if (file->pMdiChild){ + CChildView * childView = (CChildView *) file->pMdiChild; + /* Modified ? */ + if (childView->modified){ + /* Ask ? */ + if (decision == IDASK){ + decision = MsgBox.AskToSave(true); // Cancel button. + if (decision != IDYES) + return decision; // IDNO or IDCANCEL. + } + childView->CmdSave(); + } + } + file = (CFileItem*) Next(); + } +return decision; +} + +HWND CFilesView::Create(CWindow * pParent, CImageList * imgList){ + // Create TreeView. + CreateEx( + pParent, + WS_EX_CLIENTEDGE, + WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS + | TVS_EDITLABELS | TVS_HASLINES | TVS_HASBUTTONS, + 0, + (void*) 12); + + // Assign the image list to the treeview control. + SendMessage(TVM_SETIMAGELIST, (long)TVSIL_NORMAL, (long) imgList->GetId()); + hRoot = CreateItem(TVI_ROOT, TVI_LAST, WORKSPACE, "Workspace", 0); +return _hWnd; +} + + +/******************************************************************** +* Class: CProjectView. +* +* Purpose: Project TreeView. +* +* Revisions: +* +********************************************************************/ +CProjectView::CProjectView(){ + hRoot = NULL; +} + +CProjectView::~CProjectView(){ +} + +CFileItem * CProjectView::NewFile(char * name){ + CFileItem * current = (CFileItem *) GetCurrent(); + CFileItem * srcFile = new CFileItem; + + // Copy directory name. + if (current){ + strncpy(srcFile->szFileName, current->szFileName, current->nFileOffset); + srcFile->nFileOffset = current->nFileOffset; + }else{ + // No files in the project yet, use makefile directory. + strcpy(srcFile->szFileName, Project.Makefile.mkfDir); + srcFile->nFileOffset = strlen(srcFile->szFileName)+1; + } + + srcFile->szFileName[srcFile->nFileOffset - 1] = '\\'; + + // Append file name. + strcpy(&srcFile->szFileName[srcFile->nFileOffset], name); + //MsgBox.DisplayString(srcFile->szFileName); + + if (::CheckFile(srcFile)){ + ::GetFileType(srcFile); + srcFile->isInProject = true; + HANDLE hFile; + hFile = ::CreateFile(srcFile->szFileName, + 0, + 0, + NULL, + CREATE_NEW, + FILE_ATTRIBUTE_ARCHIVE, + NULL); + + if (hFile != INVALID_HANDLE_VALUE){ + CloseHandle(hFile); + // Try to add new file to the project. + if(OpenFile(srcFile)){ + Project.modified = true; + return srcFile; + } + } + } + delete srcFile; +return NULL; +} + +bool CProjectView::OpenFile(CFileItem * file){ + if (!file) + return false; + + int listAction; + char * fileName = file->szFileName + file->nFileOffset; + + /* Check if this file is already opened */ + listAction = InsertSorted_New(file); + + if (listAction == FILE_FOUND){ + /* Focus the editor window */ + CFileItem * currentFile = (CFileItem *) GetCurrent(); + if (currentFile){ + CMDIChild * pMdiChild = currentFile->pMdiChild; + if (!pMdiChild){ + /* Create a child window */ + Project.SwitchCurrentDir(); + winApp.CreateChild(file->szFileName, file); + }else{ + pMdiChild->SetFocus(); + } + } + return false; + } + + file->_hDirItem = hRoot; + CreateSubDirItem(file); + + if (listAction == EMPTY_LIST){ + InsertFirst(file); + }else if (listAction == INSERT_FIRST){ + InsertFirst(file); + }else if (listAction == INSERT_LAST){ + InsertLast(file); + }else if (listAction == INSERT_BEFORE){ + InsertBefore(file); + }else if (listAction == INSERT_AFTER){ + InsertAfter(file); + } + + /* Create the file icon */ + file->_hItem = CreateItem( + file->_hDirItem, + TVI_SORT, + file->type, + fileName, + (LPARAM) file); + + file->pTreeView = this; + + /* Create an editor view */ + if (file->show){ + winApp.CreateChild(file->szFileName, file); + } +return true; +} + +bool CProjectView::Close(){ + if (Project.NoProject()) + return false; + + int decision = IDASK; + decision = SaveAll(decision); + if (decision == IDCANCEL) + return false; + + // Parse the list while there's a next node. + CFileItem * srcFile = (CFileItem *) First(); + while(srcFile){ + DestroyFile(srcFile, decision); + srcFile = (CFileItem *) Next(); + } + Project.loaded = false; + + DestroyRoot(); + DestroyList(); + winApp.Report.Clear(); +return true; +} + +void CProjectView::RemoveFile(void){ + if (Project.NoProject()) + return; + + CFileItem * srcFile = (CFileItem *) GetSelectedItemParam(); + + if (srcFile){ + if (srcFile->pMdiChild) + DestroyFile(srcFile); + TreeView_DeleteItem(_hWnd, srcFile->_hItem); + if (!TreeView_GetChild(_hWnd, srcFile->_hDirItem)) + TreeView_DeleteItem(_hWnd, srcFile->_hDirItem); +/* else + TreeView_SelectItem(_hWnd, srcFile->_hDirItem);*/ + Destroy(srcFile); + + // we need to save prj file before exit. + //@@ Project.CloseFile, modified & buildMakefile should be private. + Project.modified = true; + Project.buildMakefile = true; + }else{ + MsgBox.DisplayWarning("No project file selected"); + } +} + +void CProjectView::RemoveModule(void){ + if (Project.NoProject()) + return; + + CFileItem * srcFile = (CFileItem *) GetSelectedItemParam(); + CFileItem * otherFile; + + if (srcFile){ + if (srcFile->prev){ + otherFile = (CFileItem *) srcFile->prev; + if (otherFile->nFileExtension != 0){ + if (0 == strnicmp(srcFile->szFileName, otherFile->szFileName, otherFile->nFileExtension)){ + if (otherFile->pMdiChild) + DestroyFile(otherFile); + TreeView_DeleteItem(_hWnd, otherFile->_hItem); + Destroy(otherFile); + } + } + } + if (srcFile->next){ + otherFile = (CFileItem *) srcFile->next; + if (otherFile->nFileExtension != 0){ + if (0 == strnicmp(srcFile->szFileName, otherFile->szFileName, otherFile->nFileExtension)){ + if (otherFile->pMdiChild) + DestroyFile(otherFile); + TreeView_DeleteItem(_hWnd, otherFile->_hItem); + Destroy(otherFile); + } + } + } + if (srcFile->pMdiChild) + DestroyFile(srcFile); + TreeView_DeleteItem(_hWnd, srcFile->_hItem); + Destroy(srcFile); + + // we need to save prj file before exit. + //@@ Project.CloseFile, modified & buildMakefile should be private. + Project.modified = true; + Project.buildMakefile = true; + }else{ + MsgBox.DisplayWarning("No project file selected"); + } +} + +int CProjectView::DestroyFile(CFileItem * file, int decision){ + if (file && file->pMdiChild){ + CChildView * pMdiChild = (CChildView *) file->pMdiChild; + + if (pMdiChild->modified && decision != IDNO){ + // Ask ? + if (decision == IDASK){ + decision = MsgBox.AskToSave(true); // (Cancel button) + if (decision == IDCANCEL) + return decision; + } + pMdiChild->CmdSave(); + } + + if (pMdiChild->_hWnd) // have an editor window, so destroy it. + winApp.MdiClient.SendMessage(WM_MDIDESTROY, (WPARAM)pMdiChild->_hWnd, 0); + } +return decision; +} + +int CProjectView::SaveAll(int decision){ + if (!Project.loaded) + return 0; + + if (decision == IDNO || decision == IDCANCEL) + return decision; + + CFileItem * file = (CFileItem*) First(); + while (file){ + if (file->pMdiChild){ + CChildView * childView = (CChildView *) file->pMdiChild; + /* Modified ? */ + if (childView->modified){ + /* Ask ? */ + if (decision == IDASK){ + decision = MsgBox.AskToSave(true); // Cancel button. + if (decision != IDYES) + return decision; // IDNO or IDCANCEL. + } + childView->CmdSave(); + } + } + file = (CFileItem*) Next(); + } + + if (Project.modified) + return Project.SavePrjFile(decision); +return decision; +} + +bool CProjectView::CreateSubDirItem(CFileItem * file){ + /* Initialize _hDirItem and get a pointer to current file */ + file->_hDirItem = hRoot; + CFileItem * currentFile = (CFileItem *) GetCurrent(); + + /* See if our new file is in the same directory than current file */ + if (currentFile){ + // There's some files in the list. + if (file->nFileOffset == currentFile->nFileOffset){ + // Same directory length, we may have found the directory. + if (0 == strnicmp(file->szFileName, currentFile->szFileName, currentFile->nFileOffset)){ + /* We have found the directory, then copy _hDirItem */ + file->_hDirItem = currentFile->_hDirItem; + return true; + } + } + } + + /* We need to parse the tree view and create directory icons */ + char * parse = file->szFileName; + if (*parse == '.' && *(parse+1) == '\\'){ + /* This is a valid relative path */ + char dir[MAX_PATH]; + strcpy(dir, file->szFileName); + parse = dir+2; + char * dirStart; + HTREEITEM hParent = hRoot; + HTREEITEM hFound; + if (*parse){ + for ( ; ; ){ + /* Found each backslash */ + dirStart = parse; + parse = strchr(parse, '\\'); + if (!parse) + break; // No more backslash. + else if (parse == dirStart) + return false; // Avoids an endless loop. + *parse = '\0'; + + /* Find the directory */ + hFound = FindDirItem(hParent, dirStart); + if (!hFound){ + /* Append a new directory icon */ + hParent = CreateDirItem(hParent, dirStart); + } + parse++; + } + } + file->_hDirItem = hParent; + } +return true; +} + +HTREEITEM CProjectView::FindDirItem(HTREEITEM hItem, char * dir){ + char buffer[_MAX_DIR]; + HTREEITEM hNext = TreeView_GetChild(_hWnd, hItem); + while (hNext){ + _TvItem.hItem = hNext; + _TvItem.mask = TVIF_HANDLE | TVIF_TEXT; + _TvItem.pszText = buffer; + _TvItem.cchTextMax = _MAX_DIR; + if (TreeView_GetItem(_hWnd, &_TvItem)){ + if (!stricmp(dir, buffer)) + return hNext; + } + hNext = TreeView_GetNextSibling(_hWnd, hNext); + } +return NULL; +} + +HWND CProjectView::Create(CWindow * pParent, CImageList * imgList){ + // Create TreeView. + CreateEx( + pParent, + WS_EX_CLIENTEDGE, + WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS + | TVS_EDITLABELS | TVS_HASLINES | TVS_HASBUTTONS); + + // Assign the image list to the treeview control. + SendMessage(TVM_SETIMAGELIST, (long)TVSIL_NORMAL, (long) imgList->GetId()); +return _hWnd; +} + +void CProjectView::CreateRoot(char * projectName){ + + _pParent->SendMessage(TCM_SETCURFOCUS, 1, 0); + + // Create Root Item. + hRoot = CreateItem(TVI_ROOT, TVI_LAST, PROJECT, projectName, 0); + SendMessage(TVM_EXPAND, (long) TVE_EXPAND, (long) hRoot); +} + +void CProjectView::DestroyRoot(void){ + TreeView_DeleteItem(_hWnd, hRoot); + hRoot = 0; + + _pParent->SendMessage(TCM_SETCURFOCUS, 0, 0); +} + +HTREEITEM CProjectView::CreateDirItem(HTREEITEM hParent, char * dir){ +return CreateItem(hParent, TVI_SORT, DIR, dir, 0); +} + +CFileItem * CProjectView::FindFile(char * szFileName){ + if (!szFileName || !*szFileName) + return NULL; + + char * currentFile; + bool stripDir = true; + if (*szFileName == '.') + stripDir = false; + // Get the current node. + CFileItem * currentNode = (CFileItem *) GetCurrent(); + + if(!currentNode) + return NULL; // The list is empty. + + currentFile = GetFileName(currentNode, stripDir); + int cmpResult = stricmp(szFileName, currentFile); + // Compare names to know if we must parse Up + // or Down from current node. + if (cmpResult == 0){ + return currentNode; // Found ! + } + // Search Up ----------------------------------------------------------------- + else if (cmpResult == -1){ + // Parse the list while there's a previous node. + while (Prev()){ + currentNode = (CFileItem *) GetCurrent(); + currentFile = GetFileName(currentNode, stripDir); + if(!stricmp(szFileName, currentFile)) + return currentNode; // Found ! + } + } + // Search Down -------------------------------------------------------------- + else if (cmpResult == 1){ + // Parse the list while there's a next node. + while (Next()){ + currentNode = (CFileItem *) GetCurrent(); + currentFile = GetFileName(currentNode, stripDir); + if(!stricmp(szFileName, currentFile)) + return currentNode; // Found ! + } + } +return NULL; +} + +char * CProjectView::GetFileName(CFileItem * currentNode, bool flag){ + char * fileName = currentNode->szFileName; + if (flag == true){ + fileName += currentNode->nFileOffset; + } +return fileName; +} + + +/******************************************************************** +* Class: CReport. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CReport::CReport(){ +} + +CReport::~CReport(){ +} + +void CReport::Create(CWindow * pParent){ + // Create the Tab Control. + CreateEx( + pParent, + WS_EX_CLIENTEDGE, + WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS + /*| TCS_BOTTOM*/ | TCS_MULTILINE | TCS_VERTICAL + | TCS_FOCUSNEVER); + + // Give it a smart font, create tabs, select first one and show the control. + SendMessage(WM_SETFONT, (long) GetStockObject(DEFAULT_GUI_FONT), 0); + + InsertItem(REPORT_MAIN_TAB, TCIF_TEXT, 0, 0, "Main", 16, 0, 0); + InsertItem(REPORT_LOG_TAB, TCIF_TEXT, 0, 0, "Log", 16, 0, 0); + Show(); + + // Create an Image list and then the Project TreeView. + MainList.Create(this); + SetItem_Param(REPORT_MAIN_TAB, (long) &MainList); + LogList.Create(this); + SetItem_Param(REPORT_LOG_TAB, (long) &LogList); +} + +bool CReport::SetPosition(HWND, int x, int y, int width, int height, UINT){ + /* Overwrites CTabCtrl::SetPosition() so that all child windows are also resized */ + + // Tab Control. + ::SetWindowPos(_hWnd, 0, + x, + y, + width, + height, + 0); + + // Get tab's display area. + RECT area; + area.left = 0; + area.top = 0; + area.right = width; + area.bottom = height; + ::SendMessage(_hWnd, TCM_ADJUSTRECT, FALSE, (LPARAM) &area); + area.right -= area.left; + area.bottom -= area.top; + /* WS_EX_CLIENTEDGE correction */ + area.top -= 2; + area.right -= 2; + // Borders. + area.left += 3; + area.top += 3; + area.right -= 6; + area.bottom -= 6; + + // Child windows. + MainList.SetPosition(0, area.left, area.top, + area.right, area.bottom, 0); + LogList.SetPosition(0, area.left, area.top, + area.right, area.bottom, 0); +return true; +} + +BOOL CReport::OnNotify(int, LPNMHDR notify){ + // Dispatch messages. + switch (notify->code){ + // Tab Control. + case TCN_SELCHANGING: + OnSelChanging(notify); + break; + + case TCN_SELCHANGE: + OnSelChange(notify); + break; + + // Main list. + case NM_DBLCLK: + MainList.Lv_OnDbClick((LPNMLISTVIEW) notify); + break; + } +return TRUE; +} + +void CReport::OnSelChanging(LPNMHDR notify){ + if (_hWnd == notify->hwndFrom){ + CWindow * pWindow = (CWindow *) GetItem_Param(GetCurSel()); + if (pWindow){ + pWindow->Hide(); + } + } +} + +void CReport::OnSelChange(LPNMHDR notify){ + if (_hWnd == notify->hwndFrom){ + CWindow * pWindow = (CWindow *) GetItem_Param(GetCurSel()); + if (pWindow){ + pWindow->Show(); + } + } +} + +void CReport::Clear(void){ + MainList.Clear(); + LogList.Clear(); +} + +bool CReport::Append(char * line, WORD outputFlag){ + LogList.Append(line, outputFlag); + MainList.Append(line, outputFlag); +return true; +} + + +/******************************************************************** +* Class: CMainList. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CMainList::CMainList(){ +} + +CMainList::~CMainList(){ +} + +void CMainList::Create(CWindow * pParent){ + CreateEx( + pParent, + WS_EX_CLIENTEDGE, + WS_VISIBLE | WS_CHILD| WS_CLIPCHILDREN | WS_CLIPSIBLINGS + | LVS_REPORT); + + SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, + LVS_EX_GRIDLINES, LVS_EX_GRIDLINES); + SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, + LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); + + // Insert columns. + LVCOLUMN lvc; + lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvc.fmt = LVCFMT_LEFT; + + lvc.iSubItem = 0; + lvc.cx = 35; + lvc.pszText = "Line"; + SendMessage(LVM_INSERTCOLUMN, 0, (LPARAM) &lvc); + + lvc.iSubItem = 1; + lvc.cx = 70; + lvc.pszText = "Unit"; + SendMessage(LVM_INSERTCOLUMN, 1, (LPARAM) &lvc); + + lvc.iSubItem = 2; + lvc.cx = 640; + lvc.pszText = "Message"; + SendMessage(LVM_INSERTCOLUMN, 2, (LPARAM) &lvc); +} + +void CMainList::Lv_OnDbClick(LPNMLISTVIEW lpnmlv){ + if (_hWnd == lpnmlv->hdr.hwndFrom){ + char lineBuff[256]; + *lineBuff = '\0'; + char * c = lineBuff; + LV_ITEM lvi; + lvi.mask = LVIF_TEXT; + lvi.iItem = lpnmlv->iItem; + lvi.iSubItem = 0; + lvi.pszText = lineBuff; + lvi.cchTextMax = 256; + lvi.lParam = 0; + if (!SendMessage(LVM_GETITEMTEXT, lpnmlv->iItem, (long) &lvi)) + return; + while(*c){ + if (!isdigit(*c)) + return; + c++; + } + int line = atoi(lineBuff); + + //MsgBox.DisplayLong((long) line); + + lvi.iSubItem = 1; + if (!SendMessage(LVM_GETITEMTEXT, lpnmlv->iItem, (long) &lvi)) + return; + CFileItem * item = winApp.Manager.ProjectView.FindFile(lineBuff); + if (item && item->isInProject){ + CChildView * pMdiChild = (CChildView *) item->pMdiChild; + + if(pMdiChild){ + // An editor, focus it. + ::SetFocus((HWND) pMdiChild->_hWnd); + }else{ + // No editor, the item is part of a project. + Project.SwitchCurrentDir(); + winApp.CreateChild(item->szFileName, item); + } + pMdiChild = (CChildView *) item->pMdiChild; + if (pMdiChild) + pMdiChild->Editor.GotoLine(line-1); + } + } +} + +bool CMainList::Append(char * line, WORD outputFlag){ + int row; + + *szLine = '\0'; + *szUnit = '\0'; + *szMsg = '\0'; + + if (outputFlag == LVOUT_ERROR){ + if (!SplitErrorLine(line)) + return false; + }else if (outputFlag == LVOUT_NORMAL){ + strcpy (szMsg, line); + }else{ + strcpy (szMsg, "Unrecognized outputFlag"); + } + + // Fill in List View columns, first is column 0. + LV_ITEM lvi; + lvi.mask = LVIF_TEXT; // | LVIF_PARAM; + lvi.iItem = 0x7FFF; + lvi.iSubItem = 0; + lvi.pszText = szLine; + lvi.cchTextMax = strlen(lvi.pszText)+1; + lvi.lParam = 0; + + row = SendMessage(LVM_INSERTITEM, 0, (LPARAM) &lvi); + + // Continue with column 1. + lvi.iSubItem = 1; + lvi.pszText = szUnit; + lvi.cchTextMax = strlen(lvi.pszText)+1; + SendMessage(LVM_SETITEMTEXT, (WPARAM)row, (LPARAM)&lvi); + + // Continue with column 2. + lvi.iSubItem = 2; + lvi.pszText = szMsg; + lvi.cchTextMax = strlen(lvi.pszText)+1; + SendMessage(LVM_SETITEMTEXT, (WPARAM)row, (LPARAM)&lvi); + + // Save last row position + lastRow = row+1; + +return true; +} + +bool CMainList::SplitErrorLine(char * line){ + char * chr = line; + char * col; + // line => [unit]:[line_n°]: [error message] + // or => [unit]: [error message] + + if (!*line) + return false; + + /* Unit */ + col = szUnit; + for ( ; ; ){ + if (!*chr){ + /* Not an error line */ + //strcpy(szMsg, szUnit); + *szUnit = '\0'; + return false; + }else if (*chr == ':'){ + if (*(chr+1) == '\\'){ + *col = *chr; + col++; + chr++; + continue; + }else{ + chr++; + break; + } + } + *col = *chr; + col++; + chr++; + } + *col = '\0'; + + /* Line number ? */ + col = szLine; + if (*chr && isdigit(*chr)){ //@@ *chr=0 ? + while (*chr && *chr != ':'){ + *col = *chr; + col++; + chr++; + } + *col = '\0'; + chr++; + } + + /* Message */ + col = szMsg; + if (isspace(*chr)){ + /**col = '>'; + col++; + *col = ' '; + col++;*/ + chr++; + } + + while (*chr){ + *col = *chr; + col++; + chr++; + } + *col = '\0'; +return true; +} + + +/******************************************************************** +* Class: CLogList. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CLogList::CLogList(){ +} + +CLogList::~CLogList(){ +} + +void CLogList::Create(CWindow * pParent){ + CreateEx( + pParent, + WS_EX_CLIENTEDGE, + WS_CHILD| WS_CLIPCHILDREN | WS_CLIPSIBLINGS | LVS_REPORT + | LVS_NOCOLUMNHEADER); + + SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, + LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); + + // Insert columns. + LVCOLUMN lvc; + lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvc.fmt = LVCFMT_LEFT; + + lvc.iSubItem = 0; + lvc.cx = 100; + lvc.pszText = "Message"; + SendMessage(LVM_INSERTCOLUMN, 0, (LPARAM) &lvc); +} + +bool CLogList::SetPosition(HWND hInsertAfter, int x, int y, int width, int height, UINT uFlags){ + ::SendMessage(_hWnd, WM_SETREDRAW, FALSE, 0); + ::SetWindowPos(_hWnd, hInsertAfter, x, y, width, height, uFlags); + ::SendMessage(_hWnd, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM((int) width-22, 0)); + ::SendMessage(_hWnd, WM_SETREDRAW, TRUE, 0); +return true; +} + +bool CLogList::Append(char * line, WORD /*outputFlag*/){ + int row; + + *szMsg = '\0'; + +/* if (outputFlag != LVOUT_ERROR) + return false; +*/ + // Fill in List View columns, first is column 0. + LV_ITEM lvi; + lvi.mask = LVIF_TEXT; // | LVIF_PARAM; + lvi.iItem = 0x7FFF; + lvi.iSubItem = 0; + lvi.pszText = line; + lvi.cchTextMax = strlen(lvi.pszText)+1; + lvi.lParam = 0; + + row = SendMessage(LVM_INSERTITEM, 0, (LPARAM) &lvi); + + // Save last row position + lastRow = row+1; + +return true; +} + + +/******************************************************************** +* Class: CFileItem. +* +* Purpose: Linked List Node for file parameters. +* +* Revisions: +* +********************************************************************/ +CFileItem::CFileItem(){ + type = U_FILE; + + *szFileName = '\0'; + szFileName[MAX_PATH - 1] = '\0'; // security. + nFileOffset = 0; + nFileExtension = 0; + + pTreeView = NULL; + _hDirItem = 0; + _hItem = 0; + + pMdiChild = NULL; + show = 0; + isInProject = false; +} + +CFileItem::~CFileItem(){ +} + + +/******************************************************************** +* Class: CFileList. +* +* Purpose: A CList with a dedicated Compare() procedure. +* +* Revisions: +* +********************************************************************/ +CFileList::CFileList(){ +} + +CFileList::~CFileList(){ +} + +int CFileList::Compare(CNode *node1, CNode *node2){ +return stricmp(((CFileItem *)node1)->szFileName, ((CFileItem *)node2)->szFileName); +} + diff --git a/rosapps/devutils/vmingw/main.h b/rosapps/devutils/vmingw/main.h new file mode 100644 index 00000000000..4aa4cc70a52 --- /dev/null +++ b/rosapps/devutils/vmingw/main.h @@ -0,0 +1,385 @@ +/******************************************************************** +* Module: main.h. This is part of Visual-MinGW. +* +* License: Visual-MinGW is covered by GNU General Public License, +* Copyright (C) 2001 Manu B. +* See license.htm for more details. +* +********************************************************************/ +#ifndef MAIN_H +#define MAIN_H + +#include "CList.h" +#include "winui.h" +#include "editor.h" +#include "process.h" + +#define LVOUT_NORMAL (STDOUT_USER) +#define LVOUT_ERROR (STDOUT_USER+1) +#define IDASK 21 + +#define WORKSPACE 0 +#define PROJECT 1 +#define DIR 2 + +#define PRJ_FILE 0 +#define SRC_FILE 1 +#define ADD_SRC_FILE 2 + +#define FILES_TAB 0 +#define PROJECT_TAB 1 + +#define REPORT_MAIN_TAB 0 +#define REPORT_LOG_TAB 1 + + +class CChildView : public CMDIChild +{ + public: + CChildView(); + virtual ~CChildView(); + + bool modified; + + bool OnCreate(LPCREATESTRUCT lParam); + bool OnSize(UINT wParam, int width, int height); + BOOL OnClose(void); + BOOL OnDestroy(void); + + BOOL OnCommand(WPARAM wParam, LPARAM lParam); + BOOL OnNotify(int idCtrl, LPNMHDR notify); + BOOL OnSetFocus(HWND hwndLoseFocus); + BOOL OnActivate(HWND hwndChildDeact, HWND hwndChildAct); + + void CmdSave(void); + void CmdSaveAs(void); + CEditor Editor; + + protected: + + private: +}; + +class CFileList : public CList +{ + public: + CFileList(); + ~CFileList(); + + protected: + virtual int Compare(CNode *node1, CNode *node2); + + private: +}; + +class CProjectView : public CTreeView, public CFileList +{ + public: + CProjectView(); + ~CProjectView(); + + CFileItem * NewFile(char * name); + bool OpenFile(CFileItem * file); + void RemoveFile(void); + void RemoveModule(void); + int DestroyFile(CFileItem * file, int decision=IDASK); + int SaveAll(int decision); + bool Close(); + + void CreateRoot(char * projectName); + void DestroyRoot(void); + CFileItem * FindFile(char * szFileName); + char * GetFileName(CFileItem * currentNode, bool flag); + + HWND Create(CWindow * pParent, CImageList * imgList); + HTREEITEM CreateDirItem(HTREEITEM hParent, char * dir); + + protected: + + private: + bool CreateSubDirItem(CFileItem * file); + HTREEITEM FindDirItem(HTREEITEM hItem, char * dir); + HTREEITEM hRoot; +}; + +class CFilesView : public CTreeView, public CFileList +{ + public: + CFilesView(); + ~CFilesView(); + + bool OpenFile(CFileItem * file); + void New (void); + void CloseFile(CFileItem * file); + int SaveAll(int decision); + + HWND Create(CWindow * pParent, CImageList * imgList); + + protected: + + private: + HTREEITEM hRoot; +}; + +class CManager : public CTabCtrl +{ + public: + CManager(); + ~CManager(); + + void OpenFileDialog(void); + bool OpenFile(CFileItem * file); + int SaveAll(int silent); + + bool NewProjectDialog(void); + bool OpenProjectDialog(void); + bool CloseProject(void); + int SaveProjectFiles(int decision); + void RemoveProjectFile(void); + void RemoveProjectModule(void); + + void Create(CWindow * pParent); + bool SetPosition(HWND hInsertAfter, int x, int y, int width, int height, UINT uFlags); + + BOOL OnNotify(int idCtrl, LPNMHDR notify); + void Tv_OnDeleteItem(LPNMTREEVIEW notify); + void Tv_OnSelchanged(LPNMTREEVIEW notify); + void OnSelChanging(LPNMHDR notify); + void OnSelChange(LPNMHDR notify); + + CImageList ImgList; + CFilesView FilesView; + CProjectView ProjectView; + + protected: + + private: + void CreateImageList(void); + +}; + +class CLogList : public CListView +{ + public: + CLogList(); + ~CLogList(); + + void Create(CWindow * pParent); + bool SetPosition(HWND hInsertAfter, int x, int y, int width, int height, UINT uFlags); + bool Append(char * line, WORD outputFlag); + + protected: + + private: + char szMsg[1024]; +}; + +class CMainList : public CListView +{ + public: + CMainList(); + ~CMainList(); + + void Create(CWindow * pParent); + void Lv_OnDbClick(LPNMLISTVIEW lpnmlv); + bool Append(char * line, WORD outputFlag); + + protected: + + private: + char szLine[512]; + char szUnit[512]; + char szMsg[512]; + + bool SplitErrorLine(char * line); +}; + +class CReport : public CTabCtrl +{ + public: + CReport(); + ~CReport(); + + bool Append(char * line, WORD outputFlag); + void Clear(void); + void Create(CWindow * pParent); + bool SetPosition(HWND hInsertAfter, int x, int y, int width, int height, UINT uFlags); + + BOOL OnNotify(int idCtrl, LPNMHDR notify); + void OnSelChanging(LPNMHDR notify); + void OnSelChange(LPNMHDR notify); + + CMainList MainList; + CLogList LogList; + + protected: + + private: + void CreateImageList(void); +}; + +class CFileDlg : public CFileDlgBase +{ + public: + CFileDlg(); + ~CFileDlg(); + + bool Open(CWindow * pWindow, char * pszFileName, DWORD nMaxFile, int fileflag); + bool Save(CWindow * pWindow, char * pszFileName, DWORD nMaxFile, int fileflag); + + protected: + + private: +}; + +class CGrepDlg : public CDlgBase +{ + public: + CGrepDlg(); + ~CGrepDlg(); + + int Create(void); + LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + BOOL OnInitDialog(HWND hwndFocus, LPARAM lInitParam); + BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hwndCtl); + void FindInFiles(char * findWhat, char * fileFilter); + char gDir[MAX_PATH]; + char findWhat[200]; + + protected: + + private: + HWND hFindWhat; + HWND hgDir; +}; + +class CEnvDlg : public CDlgBase +{ + public: + CEnvDlg(); + virtual ~CEnvDlg(); + + virtual LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + BOOL OnInitDialog(HWND hwndFocus, LPARAM lInitParam); + BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hwndCtl); + void SetEnvText(void); + bool bIsVisible; + bool bModified; + + protected: + + private: + HWND hApply; + HWND hSetCcBin; + HWND hCcBinDir; + HWND hBrowseCc; + HWND hSetCmdBin; + HWND hCmdBinDir; + HWND hBrowseCmd; + HWND hAutoexec; + HWND hEnvView; +}; + +class CPreferencesDlg : public CTabbedDlg +{ + public: + CPreferencesDlg(); + virtual ~CPreferencesDlg(); + + int Create(void); + BOOL EndDlg(int nResult); + virtual LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + BOOL OnInitDialog(HWND hwndFocus, LPARAM lInitParam); + BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hwndCtl); + + protected: + + private: + CEnvDlg EnvDlg; +}; + +class CWinApp : public CMDIBase +{ + public: + CWinApp(); + ~CWinApp(); + + void FirstRunTest(void); + bool ReadIniFile(char * iniFile); + void SaveIniFile(FILE * file); + bool WriteIniFile(void); + bool CustomInit(void); + bool Release(void); + bool SetEnv(void); + + bool CreateUI(void); + void CreateToolbar(void); + void CreateSplitter(void); + void CreateMDI(void); + HWND CreateChild(char * caption, LPVOID lParam); + void CreateStatusBar(void); + + void SendCaretPos(int caretPos); + + // Main window. + LRESULT CALLBACK CMainWndProc(UINT Message, WPARAM wParam, LPARAM lParam); + + BOOL OnCreate(LPCREATESTRUCT lParam); + BOOL OnPaint(HDC wParam); + BOOL OnSize(UINT wParam, int width, int height); + BOOL OnDestroy(void); + BOOL OnClose (void); + BOOL OnNotify(int idCtrl, LPNMHDR notify); + + BOOL OnLButtonDown(short xPos, short yPos, UINT fwKeys); + BOOL OnMouseMove(short xPos, short yPos, UINT fwKeys); + BOOL OnLButtonUp(short xPos, short yPos, UINT fwKeys); + BOOL OnSetCursor(HWND hwnd, UINT nHittest, UINT wMouseMsg); + + BOOL OnCommand(WPARAM wParam, LPARAM lParam); + + // Child window. + LRESULT CALLBACK CChildWndProc(CWindow * pWnd, UINT Message, WPARAM wParam, LPARAM lParam); + + HMODULE hmod; + char iniFileName[MAX_PATH]; + CIniFile IniFile; + CPreferencesDlg PreferencesDlg; + CGrepDlg GrepDlg; + CShellDlg ShellDlg; + CFileDlg FileDlg; + CProcess Process; + + CToolBar Toolbar; + CSplitter MainSplitter; + CSplitter ChildSplitter; + CManager Manager; + CReport Report; + CStatusBar Sbar; + + /* Preferences */ + char openFilesDir[MAX_PATH]; + char projectDir[MAX_PATH]; + bool bSetCcEnv; + bool bSetCmdEnv; + bool bSetDefEnv; + char szCcBinDir[MAX_PATH]; + char szCmdBinDir[MAX_PATH]; + char includeDir[MAX_PATH]; + + protected: + + private: + bool firstRun; + // Child windows dimensions. + int deltaY; + int tbarHeight; + int sbarHeight; + int tvWidth; + int lvHeight; + + int hSplitter; + int vSplitter; +}; + +#endif diff --git a/rosapps/devutils/vmingw/process.cpp b/rosapps/devutils/vmingw/process.cpp new file mode 100644 index 00000000000..092f41b56ae --- /dev/null +++ b/rosapps/devutils/vmingw/process.cpp @@ -0,0 +1,682 @@ +/******************************************************************** +* Module: process.cpp. This is part of Visual-MinGW. +* +* Purpose: Procedures to invoke MinGW compiler. +* +* Authors: Manu B. +* +* License: Visual-MinGW is covered by GNU General Public License, +* Copyright (C) 2001 Manu B. +* See license.htm for more details. +* +* Note: The following article from MSDN explanes how to handle Callback +* procedures : +* Calling All Members: Member Functions as Callbacks. +* by Dale Rogerson. +* Microsoft Developer Network Technology Group. +* April 30, 1992. +* http://msdn.microsoft.com/archive/default.asp +* +* Revisions: +* +********************************************************************/ +#include +#include +#include +#include +#include +#include "process.h" +#include "project.h" +#include "main.h" +#include "rsrc.h" + +extern CCriticalSection CriticalSection; +extern CMessageBox MsgBox; +char errmsg[128]; + +// For winApp.isWinNT and winApp.Report.Append +extern CWinApp winApp; + +/******************************************************************** +* Class: CCommandDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CCommandDlg::CCommandDlg(){ + *cmdLine = '\0'; +} + +CCommandDlg::~CCommandDlg(){ +} + +HWND CCommandDlg::Create(void){ +return CreateParam(&winApp, IDD_COMMAND, 0); +} + +LRESULT CALLBACK CCommandDlg::CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam){ + switch(Message){ + case WM_INITDIALOG: + return OnInitDialog((HWND) wParam, lParam); + + case WM_COMMAND: + OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND) lParam); + break; + + case WM_CLOSE: + EndDlg(0); + break; + } +return FALSE; +} + +BOOL CCommandDlg::OnInitDialog(HWND, LPARAM){ + hCmdLine = GetItem(IDC_CMDLINE); + + SetItemText(hCmdLine, cmdLine); + // Show the dialog. + Show(); +return TRUE; +} + +BOOL CCommandDlg::OnCommand(WORD, WORD wID, HWND){ + switch (wID){ + case IDOK: + GetItemText(hCmdLine, cmdLine, sizeof(cmdLine)); + //MsgBox.DisplayString(cmdLine); + winApp.Process.CommandLine(cmdLine); + return TRUE; + + case IDCANCEL: + EndDlg(IDCANCEL); + return FALSE; + } +return FALSE; +} + + +/******************************************************************** +* Class: CTask. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CTask::CTask(){ + *cmdLine = '\0'; + *szFileName = '\0'; + creationFlag = 0; + outputFlag = 0; +} + +CTask::~CTask(){ +} + + +/******************************************************************** +* Class: CStack. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CStack::CStack(){ + retBuf = NULL; +} + +CStack::~CStack(){ + DestroyList(); + if (retBuf) + delete retBuf; +} + +void CStack::DetachCurrent(void){ + // Empty list ? + if (current != NULL){ + CNode * node = current; + + // Detach node from the list. + if (node->next != NULL) + node->next->prev = node->prev; + if (node->prev != NULL) + node->prev->next = node->next; + + // Set current node. + if(node->next != NULL) + current = node->next; + else + current = node->prev; + + if (current == NULL){ + // Now, the list is empty. + first = last = NULL; + + }else if (first == node){ + // Detached node was first. + first = current; + + }else if (last == node){ + // Detached node was last. + last = current; + } + count--; + } +} + +/******************************************************************** +* Push/Pop/Flush. +********************************************************************/ +int CStack::Push(CTask * newTask){ + InsertLast(newTask); +return Length(); +} + +CTask * CStack::Pop(void){ + // Delete return buffer. + if (retBuf){ + delete retBuf; + retBuf = NULL; + } + + // Get first node. (FIFO stack) + retBuf = (CTask*) First(); + + // The Stack is empty ? + if (!retBuf) + return NULL; + + // Detach current node from the list. Return a pointer to it. + DetachCurrent(); +return retBuf; +} + +void CStack::Flush(void){ + DestroyList(); + if (retBuf) + delete retBuf; + retBuf = NULL; +} + + +/******************************************************************** +* Class: CPipes. +* +* Purpose: Creates needed pipes, depending on creationFlag. +* Like GNU Make does, we use an Handle array for our pipes. +* Parent Process Side is stdXXX[0] and Child Process Side is stdXXX[1]. +* +* Ex: PARENT ->[0]IN_PIPE[1]-> CHILD_IO ->[1]OUT_PIPE[0]-> PARENT +* ->[1]ERR_PIPE[0]-> PARENT +* Revisions: +* +********************************************************************/ +CPipes::CPipes(){ + hIn[0] = NULL; + hIn[1] = NULL; + hOut[0] = NULL; + hOut[1] = NULL; + hErr[0] = NULL; + hErr[1] = NULL; +} + +CPipes::~CPipes(){ +} + +bool CPipes::Create(WORD creationFlag, bool winNT){ + /* Create needed pipes according to creationFlag */ + /* Parent side of pipes is [0], child side is [1] */ + HANDLE hDup; + SECURITY_ATTRIBUTES sa; + sa.nLength = sizeof(SECURITY_ATTRIBUTES); + sa.bInheritHandle = TRUE; + sa.lpSecurityDescriptor = NULL; + + if (winNT){ + /* Create a security descriptor for Windows NT */ + SECURITY_DESCRIPTOR sd; + if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION)){ + sprintf(errmsg, "vm error: Process.cpp InitializeSecurityDescriptor(winNT) failed (e=%d)", (int)GetLastError()); + winApp.Report.Append(errmsg, LVOUT_ERROR); + return false; + } + if (!SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE)){ + sprintf(errmsg, "vm error: Process.cpp SetSecurityDescriptorDacl(winNT) failed (e=%d)", (int)GetLastError()); + winApp.Report.Append(errmsg, LVOUT_ERROR); + return false; + } + sa.lpSecurityDescriptor = &sd; + } + + /* Input pipe */ + if (!CreatePipe(&hIn[1], &hIn[0], &sa, 0)){ + sprintf(errmsg, "vm error: Process.cpp CreatePipe(In) failed (e=%d)", (int)GetLastError()); + winApp.Report.Append(errmsg, LVOUT_ERROR); + return false; + } + + if (!DuplicateHandle(GetCurrentProcess(), + hIn[0], + GetCurrentProcess(), + &hDup, + 0, + FALSE, + DUPLICATE_SAME_ACCESS)){ + sprintf(errmsg, "vm error: Process.cpp DuplicateHandle(In) failed (e=%d)", (int)GetLastError()); + winApp.Report.Append(errmsg, LVOUT_ERROR); + return false; + } + CloseHandle(hIn[0]); + hIn[0] = hDup; + + /* Output pipe */ + if (!CreatePipe(&hOut[0], &hOut[1], &sa, 0)){ + sprintf(errmsg, "vm error: Process.cpp CreatePipe(Out) failed (e=%d)", (int)GetLastError()); + winApp.Report.Append(errmsg, LVOUT_ERROR); + return false; + } + + if (!DuplicateHandle(GetCurrentProcess(), + hOut[0], + GetCurrentProcess(), + &hDup, + 0, + FALSE, + DUPLICATE_SAME_ACCESS)){ + sprintf(errmsg, "vm error: Process.cpp DuplicateHandle(Out) failed (e=%d)", (int)GetLastError()); + winApp.Report.Append(errmsg, LVOUT_ERROR); + return false; + } + CloseHandle(hOut[0]); + hOut[0] = hDup; + + /* Error pipe */ + if (!(creationFlag & OUTERR_PIPE) && (creationFlag & ERR_PIPE)){ + if (!CreatePipe(&hErr[0], &hErr[1], &sa, 0)){ + sprintf(errmsg, "vm error: Process.cpp CreatePipe(Err) failed (e=%d)", (int)GetLastError()); + winApp.Report.Append(errmsg, LVOUT_ERROR); + return false; + } + + if (!DuplicateHandle(GetCurrentProcess(), + hErr[0], + GetCurrentProcess(), + &hDup, + 0, + FALSE, + DUPLICATE_SAME_ACCESS)){ + sprintf(errmsg, "vm error: Process.cpp DuplicateHandle(Err) failed (e=%d)", (int)GetLastError()); + winApp.Report.Append(errmsg, LVOUT_ERROR); + return false; + } + CloseHandle(hErr[0]); + hErr[0] = hDup; + } +return true; +} + +bool CPipes::CloseChildSide(void){ +return Close(1); +} + +bool CPipes::CloseParentSide(void){ +return Close(0); +} + +bool CPipes::Close(int side){ + + if (side < 0 || side > 1) + return false; + + if (hIn[side]){ + CloseHandle(hIn[side]); + hIn[side] = NULL; + } + + if (hOut[side]){ + CloseHandle(hOut[side]); + hOut[side] = NULL; + } + + if (hErr[side]){ + CloseHandle(hErr[side]); + hErr[side] = NULL; + } +return true; +} + + +/******************************************************************** +* Class: CProcess. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CProcess::CProcess(){ + Running = false; + exitCode = 0; + + pi.hProcess = 0; + pi.hThread = 0; + pi.dwProcessId = 0; + pi.dwThreadId = 0; +} + +CProcess::~CProcess(){ +} + +/******************************************************************** +* Manage Tasks. +********************************************************************/ +bool CProcess::isRunning(void){ + if (Running){ + MsgBox.DisplayWarning("A process is already running !"); + return true; + } +return false; +} + +CTask * CProcess::AddTask(char * cmdLine, WORD creationFlag, WORD outputFlag){ + CTask * newTask = new CTask; + + strcpy(newTask->cmdLine, cmdLine); + newTask->creationFlag = creationFlag; + newTask->outputFlag = outputFlag; + Push(newTask); +return newTask; +} + +bool CProcess::CmdCat(char * cmdLine){ + CTask * task = (CTask*) GetCurrent(); + if (!task) + return false; + + strcat(task->cmdLine, cmdLine); +return true; +} + +/******************************************************************** +* RunNext/Run/RunProcess. +********************************************************************/ +void __cdecl call_thread(void * ptr){ + /* C++ adapter */ + ((CProcess *) ptr)->Run_Thread_Internal(); +} + +void CProcess::Run(void){ + // Check if something is already running before creating a thread. + if (!Running){ + // Call Run_Thread_Internal() + _beginthread(call_thread, 1024 * 1024, (void *) this); + } +} + +void CProcess::Run_Thread_Internal(void){ + exitCode = 0; + /* Execute each task */ + for ( ; ; ){ + /* If previous task returns an error code, abort */ + if (exitCode != 0) + break; + + // Get one task to execute. + currTask = Pop(); + + // Nothing to run. + if (!currTask) + break; + + /* Show command lines ?*/ + winApp.Report.Append(currTask->cmdLine, LVOUT_NORMAL); + + if (RunProcess(currTask)){ + winApp.Report.Append("Abort !", LVOUT_NORMAL); + exitCode = 1; + break; + } + } + + // Successful ? + if (exitCode == 0) + winApp.Report.Append("Performed successfully.", LVOUT_NORMAL); + + Flush(); + Running = false; +return; +} + +bool CProcess::RunProcess(CTask * task){ + if (!task) + return false; + + bool usePipes = task->creationFlag; + STARTUPINFO si = {sizeof(STARTUPINFO), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0}; + + /* PROCESS_INFORMATION */ + pi.hProcess = 0; + pi.hThread = 0; + pi.dwProcessId = 0; + pi.dwThreadId = 0; + + /* Process creation with pipes */ + if (usePipes){ + /* Create needed pipes according to creationFlag */ + if(!Pipes.Create(task->creationFlag, winApp.isWinNT)){ + Pipes.CloseChildSide(); + Pipes.CloseParentSide(); + return false; + } + + si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; + si.wShowWindow = SW_HIDE; + //si.wShowWindow = SW_SHOWNORMAL; + + /* Set pipe handles */ + if (Pipes.hIn[1] != NULL && Pipes.hOut[1] != NULL){ + si.hStdInput = Pipes.hIn[1]; + si.hStdOutput = Pipes.hOut[1]; + if (Pipes.hErr[1] == NULL) + si.hStdError = Pipes.hOut[1]; + else + si.hStdError = Pipes.hErr[1]; + }else{ + sprintf(errmsg, "vm error: Process.cpp Invalid pipe handle"); + winApp.Report.Append(errmsg, LVOUT_ERROR); + Pipes.CloseChildSide(); + Pipes.CloseParentSide(); + return false; + } + } + + /* Create the child process */ + Running = CreateProcess(NULL, + task->cmdLine, + NULL, + NULL, + usePipes, + 0, + NULL, + /*startDir[0] ? startDir :*/ NULL, + &si, + &pi); + + if (!Running){ + /* CreateProcess failed. Close handles and return */ + Pipes.CloseChildSide(); + Pipes.CloseParentSide(); + sprintf(errmsg, "vm error: Process.cpp CreateProcess failed (e=%d)", (int)GetLastError()); + winApp.Report.Append(errmsg, LVOUT_ERROR); + return false; + }else{ + /* Close child process handles */ + Pipes.CloseChildSide(); + + if (!(usePipes & IN_PIPE)){ + /* Don't use the Input pipe */ + ::CloseHandle(Pipes.hIn[0]); + Pipes.hIn[0] = NULL; + } + } + + //sprintf(errmsg, "vm debug: enter io loop"); + //winApp.Report.Append(errmsg, LVOUT_ERROR); + if (usePipes){ + /* Initialize buffers */ + *outBuf = 0; + chr = outBuf; + bool bResult; + for ( ; ; ){ + Sleep(100L); + + bResult = ReadStdOut(task, Pipes.hOut[0]); + if (bResult != NO_ERROR) + break; + + ::GetExitCodeProcess(pi.hProcess, &exitCode); + if (exitCode != STILL_ACTIVE){ + break; + } + } + } + //sprintf(errmsg, "vm debug: exit io loop"); + //winApp.Report.Append(errmsg, LVOUT_ERROR); + + /* The child process is running. Perform I/O until terminated */ + ::WaitForSingleObject(pi.hProcess, INFINITE); + /* Process terminated. Get exit code. */ + ::GetExitCodeProcess(pi.hProcess, &exitCode); + if (exitCode == NO_ERROR){ + return NO_ERROR; + } + /* Close handles */ + Pipes.CloseParentSide(); + ::CloseHandle(pi.hProcess); + if (pi.hThread){ + ::CloseHandle(pi.hThread); + pi.hThread = NULL; + } +return exitCode; +} + +/******************************************************************** +* Pipes input/output. +********************************************************************/ +void CProcess::WriteStdIn(HANDLE hPipe, WORD){ + if (!hPipe) + return; + +return; +} + +void CProcess::ReadStdErr(HANDLE hPipe, WORD){ + if (!hPipe) + return; + +return; +} + +long CProcess::ReadStdOut(CTask * task, HANDLE hPipe){ + if (!task || !hPipe) + return ERROR_INVALID_FUNCTION; + + /* Copy each char and output lines while there is something to read */ + for ( ; ; ){ + // Copy one char, return if nothing available. + if (!ReadOneChar(hPipe, chr)) + break; + + // Ignore CR. + if (*chr == '\r') + continue; + + if (*chr != '\n'){ + chr++; + /* @@TODO Overflow + if ((chr - outBuf) >= max_len) + realloc(buffer);*/ + // End of line + }else if (*chr =='\n'){ + *chr = '\0'; + // Output error lines to List View. + if (task->outputFlag == STDOUT_FILE_APPEND){ + WriteFileAppend(task->szFileName, outBuf, (chr - outBuf)); + }else{ + OutputLine(task->outputFlag, outBuf, (chr - outBuf)); + } + *outBuf = '\0'; + chr = outBuf; + } + } +return NO_ERROR; +} + +int CProcess::ReadOneChar(HANDLE hPipe, char * chrin){ + DWORD bytesRead = 0; + DWORD bytesAvail = 0; + + if (!PeekNamedPipe(hPipe, chrin, (DWORD)1, &bytesRead, &bytesAvail, NULL)) + return 0; + + if (bytesAvail == 0) + return 0; + + if (!ReadFile(hPipe, chrin, (DWORD)1, &bytesRead, NULL)) + return 0; + +return bytesRead; +} + +bool CProcess::CommandLine(char * cmdLine){ + if (!Pipes.hIn[0]) + return false; + if (!Running || !currTask || !currTask->creationFlag) + return false; + int len = strlen(cmdLine); + if (len){ + strcpy(inBuf, cmdLine); + char * s = inBuf; + s+=len; + *s = '\r'; + s++; + *s = '\n'; + s++; + *s = '\0'; + } + DWORD written; + + if (!WriteFile(Pipes.hIn[0], inBuf, strlen(inBuf), &written, 0)) + return false; + +return true; +} + +bool CProcess::WriteFileAppend(char * fileName, char * line, int /*len*/){ + if (!*fileName) + return false; + + /* Append one line of text to a file */ + FILE * file = fopen(fileName, "a"); + if (file){ + fprintf(file, line); + fprintf(file, "\n"); + fclose(file); + return true; + } +return false; +} + +bool CProcess::OutputLine(WORD outputFlag, char * line, int /*len*/){ + /* Output error lines to List View */ + + CriticalSection.Enter(); + winApp.Report.Append(line, outputFlag); + CriticalSection.Leave(); +return true; +} + diff --git a/rosapps/devutils/vmingw/process.h b/rosapps/devutils/vmingw/process.h new file mode 100644 index 00000000000..f6bbaf01550 --- /dev/null +++ b/rosapps/devutils/vmingw/process.h @@ -0,0 +1,146 @@ +/******************************************************************** +* Module: process.h. This is part of Visual-MinGW. +* +* License: Visual-MinGW is covered by GNU General Public License, +* Copyright (C) 2001 Manu B. +* See license.htm for more details. +* +********************************************************************/ +#ifndef PROCESS_H +#define PROCESS_H +#include "winui.h" +#include "CList.h" + + +class CCommandDlg : public CDlgBase +{ + public: + CCommandDlg(); + ~CCommandDlg(); + + HWND Create(void); + LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + BOOL OnInitDialog(HWND hwndFocus, LPARAM lInitParam); + BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hwndCtl); + char cmdLine[1024]; + + protected: + + private: + HWND hCmdLine; +}; + +/******************************************************** + creationFlag truth table + ----------------------------------- + 8 4 2 1 + ------------------ + NO_PIPE 0 0 0 0 + IN_PIPE 0 0 0 1 + OUT_PIPE 0 0 1 0 + ERR_PIPE 0 1 0 0 + OUTERR_PIPE 1 0 1 0 + +*********************************************************/ +#define NO_PIPE 0x0000 +#define IN_PIPE 0x0001 +#define OUT_PIPE 0x0002 +#define ERR_PIPE 0x0004 +#define OUTERR_PIPE 0x000A + +#define STDOUT_NONE 0 +#define STDOUT_FILE_APPEND 1 +#define STDOUT_USER 2 + +class CTask : public CNode +{ + public: + CTask(); + ~CTask(); + + char cmdLine[MAX_PATH]; + char szFileName[MAX_PATH]; + WORD creationFlag; + WORD outputFlag; + + protected: + + private: + +}; + +class CStack : public CList +{ + public: + CStack(); + ~CStack(); + + int Push(CTask * newTask); + CTask * Pop(void); + void Flush(void); + + protected: + + private: + CTask * retBuf; + void DetachCurrent(void); +}; + +class CPipes +{ + public: + CPipes(); + ~CPipes(); + + HANDLE hIn[2]; + HANDLE hOut[2]; + HANDLE hErr[2]; + + bool Create(WORD creationFlag, bool winNT); + bool CloseChildSide(void); + bool CloseParentSide(void); + protected: + + private: + bool Close(int side); +}; + +class CProcess : public CStack +{ + public: + CProcess(); + ~CProcess(); + + bool CommandLine(char * cmdLine); + bool isRunning(void); + CTask * AddTask(char * cmdLine, WORD creationFlag, WORD outputFlag/* = STDOUT_NONE*/); + bool CmdCat(char * cmdLine); + void Run(void); + void Run_Thread_Internal(void); + + CCommandDlg CommandDlg; + protected: + + private: + PROCESS_INFORMATION pi; + bool Running; + DWORD exitCode; + CTask * currTask; + CPipes Pipes; + char * chr; + char inBuf[1024]; + char outBuf[1024]; + char errBuf[1024]; + + bool RunProcess(CTask * task); + + void WriteStdIn(HANDLE hPipe, WORD creationFlag); + void ReadStdErr(HANDLE hPipe, WORD creationFlag); + long ReadStdOut(CTask * task, HANDLE hPipe); + int ReadOneChar(HANDLE hPipe, char * chrin); + + bool WriteFileAppend(char * fileName, char * line, int len=-1); + bool OutputLine(WORD outputFlag, char * line, int len=-1); +}; + +#endif diff --git a/rosapps/devutils/vmingw/project.cpp b/rosapps/devutils/vmingw/project.cpp new file mode 100644 index 00000000000..2b0969f4d3d --- /dev/null +++ b/rosapps/devutils/vmingw/project.cpp @@ -0,0 +1,1453 @@ +/******************************************************************** +* Module: project.cpp. This is part of Visual-MinGW. +* +* Purpose: Procedures to manage a loaded project. +* +* Authors: Manu B. +* +* License: Visual-MinGW is covered by GNU General Public License, +* Copyright (C) 2001 Manu B. +* See license.htm for more details. +* +* Revisions: +* +********************************************************************/ +#include +#include + +#include "project.h" +#include "rsrc.h" + +extern CMessageBox MsgBox; + +// For dialogs. +extern CWinApp winApp; + +WORD AppendPath(char * dirBuffer, WORD offset, char * absolutePath); + +bool CheckFile(CFileItem * file){ + if (!file) + return false; + + char * fileName = file->szFileName; + char * s = fileName; + char * dot = fileName; + char * bkslash = fileName+1; + // Valid relative path ? + if (*dot == '.' && *bkslash == '\\'){ + s+=2; + // Find backslashes & dots. + while (*s != '\0'){ + if (*s == '\\'){ + bkslash = s; + }else if (*s == '.'){ + dot = s; + } + s++; + } + if (*bkslash != '\0'){ + file->nFileOffset = (bkslash - fileName) +1; + }else{ + file->nFileOffset = 0; + return false; + } + + if (dot != fileName) + file->nFileExtension = (dot - fileName) +1; + else + file->nFileExtension = 0; + return true; + } +return false; +} + +WORD AppendPath(char * dirBuffer, WORD offset, char * absolutePath){ + WORD len = 0; + if (absolutePath[0] == '.'){ + if (absolutePath[1] == '\\' && absolutePath[2] != '\0'){ + dirBuffer[offset-1] = '\\'; + strcpy(&dirBuffer[offset], &absolutePath[2]); + len = strlen(&dirBuffer[offset]); + len++; + } + } +return len; +} + + +/******************************************************************** +* Class: COptionsDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +COptionsDlg::COptionsDlg(){ + pProject = NULL; + pMakefile = NULL; +} + +COptionsDlg::~COptionsDlg(){ +} + +LRESULT CALLBACK COptionsDlg::CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam){ + switch(Message){ + case WM_INITDIALOG: + return OnInitDialog((HWND) wParam, lParam); + + case WM_NOTIFY: + OnNotify((int) wParam, (LPNMHDR) lParam); + break; + + case WM_COMMAND: + OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND) lParam); + break; + + case WM_CLOSE: + EndDlg(0); + break; + } +return FALSE; +} + +BOOL COptionsDlg::OnInitDialog(HWND, LPARAM lInitParam){ + // Set pointers. + pProject = (CProject *) lInitParam; + if (pProject == NULL) + return TRUE; + + // Tab control handle and TCITEM. + _hWndTab = ::GetDlgItem(_hWnd, IDC_OPTION_TABS); + tcitem.mask = TCIF_TEXT | TCIF_PARAM; + + // Insert General tab. + HWND hwndChild = GeneralDlg.Create(this, IDD_GENERAL_PANE, NULL, (long) pProject); + tcitem.pszText = "General"; + tcitem.lParam = (long) &GeneralDlg; + ::SendMessage(_hWndTab, TCM_INSERTITEM, 0, + (LPARAM)&tcitem); + SetChildPosition(hwndChild); + + // Insert Compiler tab item. + CompilerDlg.Create(this, IDD_COMPILER, &Pos, (long) pProject); + tcitem.pszText = "Compiler"; + tcitem.lParam = (long) &CompilerDlg; + ::SendMessage(_hWndTab, TCM_INSERTITEM, 1, + (LPARAM)&tcitem); + + // Insert Linker tab. + LinkerDlg.Create(this, IDD_LINKER, &Pos, (long) pProject); + tcitem.pszText = "Linker"; + tcitem.lParam = (long) &LinkerDlg; + ::SendMessage(_hWndTab, TCM_INSERTITEM, 2, + (LPARAM)&tcitem); + + // Insert Archives tab. + ZipDlg.Create(this, IDD_ZIP, &Pos, (long) pProject); + tcitem.pszText = "Archives"; + tcitem.lParam = (long) &ZipDlg; + ::SendMessage(_hWndTab, TCM_INSERTITEM, 3, + (LPARAM)&tcitem); + + // Show the dialog and default pane. + Show(); + GeneralDlg.Show(); + GeneralDlg.SetFocus(); +return TRUE; +} + +BOOL COptionsDlg::OnCommand(WORD wNotifyCode, WORD wID, HWND hwndCtl){ + switch (wID){ + case IDOK: + GeneralDlg.OnCommand(wNotifyCode, wID, hwndCtl); + CompilerDlg.OnCommand(wNotifyCode, wID, hwndCtl); + LinkerDlg.OnCommand(wNotifyCode, wID, hwndCtl); + ZipDlg.OnCommand(wNotifyCode, wID, hwndCtl); + pProject->buildMakefile = true; + pProject->modified = true; + EndDlg(IDOK); + return TRUE; + + case IDCANCEL: + EndDlg(IDCANCEL); + break; + } +return 0; +} + +BOOL COptionsDlg::EndDlg(int nResult){ + GeneralDlg.EndDlg(0); + CompilerDlg.EndDlg(0); + LinkerDlg.EndDlg(0); + ZipDlg.EndDlg(0); + if (_hWnd){ + BOOL result = ::EndDialog(_hWnd, nResult); + _hWnd = 0; + return result; + } +return false; +} + + +/******************************************************************** +* Class: CGeneralDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CGeneralDlg::CGeneralDlg(){ + pProject = NULL; + pMakefile = NULL; +} + +CGeneralDlg::~CGeneralDlg(){ +} + +LRESULT CALLBACK CGeneralDlg::CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam){ + switch(Message){ + case WM_INITDIALOG: + return OnInitDialog((HWND) wParam, lParam); + + case WM_COMMAND: + OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND) lParam); + break; + + case WM_CLOSE: + EndDlg(0); + break; + } +return FALSE; +} + +BOOL CGeneralDlg::OnInitDialog(HWND, LPARAM lInitParam){ + /* Set pointers */ + pProject = (CProject *) lInitParam; + if (pProject == NULL || &pProject->Makefile == NULL) + return TRUE; + pMakefile = &pProject->Makefile; + + /* Get control handles */ + hStatLib = GetItem(IDC_STATLIB); + hDll = GetItem(IDC_DLL); + hConsole = GetItem(IDC_CONSOLE); + hGuiExe = GetItem(IDC_GUIEXE); + hDbgSym = GetItem(IDC_DBGSYM); + hLangC = GetItem(IDC_LANGC); + hLangCpp = GetItem(IDC_LANGCPP); + hMkfName = GetItem(IDC_MKF_NAME); + hMkfDir = GetItem(IDC_MKF_DIR); + hUserMkf = GetItem(IDC_USER_MKF); + hTgtName = GetItem(IDC_TGT_NAME); + hTgtDir = GetItem(IDC_TGT_DIR); + + /* Set buttons state */ + switch(pMakefile->buildWhat){ + case BUILD_STATLIB: + ::SendMessage(hStatLib, BM_SETCHECK, BST_CHECKED, 0); + break; + case BUILD_DLL: + ::SendMessage(hDll, BM_SETCHECK, BST_CHECKED, 0); + break; + case BUILD_EXE: + ::SendMessage(hConsole, BM_SETCHECK, BST_CHECKED, 0); + break; + case BUILD_GUIEXE: + ::SendMessage(hGuiExe, BM_SETCHECK, BST_CHECKED, 0); + break; + } + if (pMakefile->debug) + ::SendMessage(hDbgSym, BM_SETCHECK, BST_CHECKED, 0); + + if (pMakefile->lang == LANGCPP) + ::SendMessage(hLangCpp, BM_SETCHECK, BST_CHECKED, 0); + else + ::SendMessage(hLangC, BM_SETCHECK, BST_CHECKED, 0); + + /* Set text */ + char name[64]; + if (pMakefile->nFileOffset){ + strcpy(name, &pMakefile->szFileName[pMakefile->nFileOffset]); + }else{ + strcpy(name, "noname"); + } + + SetItemText(hMkfName, name); + SetItemText(hMkfDir, pMakefile->mkfDir); + SetItemText(hTgtName, pMakefile->target); + SetItemText(hTgtDir, pMakefile->tgtDir); +return TRUE; +} + +BOOL CGeneralDlg::OnCommand(WORD, WORD wID, HWND){ + switch (wID){ + case IDOK:{ + /* Get text */ + char name[64]; + GetItemText(hMkfName, name, 64); + GetItemText(hMkfDir, pMakefile->mkfDir, MAX_PATH); + GetItemText(hTgtName, pMakefile->target, 64); + GetItemText(hTgtDir, pMakefile->tgtDir, MAX_PATH); + + pMakefile->GetFullPath(pMakefile->szFileName, pProject->nFileOffset, name); + //@@TODO check if directories exist. + + /* Get buttons state */ + char * pExt = strrchr(pMakefile->target, '.'); + if (!pExt){ + int len = strlen(pMakefile->target); + if (!len){ + strcpy(pMakefile->target, "noname"); + len = strlen(pMakefile->target); + } + pExt = pMakefile->target + len; + } + if (BST_CHECKED == ::SendMessage(hStatLib, BM_GETCHECK, 0, 0)){ + pMakefile->buildWhat = BUILD_STATLIB; + strcpy(pExt, ".a"); + }else if (BST_CHECKED == ::SendMessage(hDll, BM_GETCHECK, 0, 0)){ + pMakefile->buildWhat = BUILD_DLL; + strcpy(pExt, ".dll"); + }else if (BST_CHECKED == ::SendMessage(hConsole, BM_GETCHECK, 0, 0)){ + pMakefile->buildWhat = BUILD_EXE; + strcpy(pExt, ".exe"); + }else if (BST_CHECKED == ::SendMessage(hGuiExe, BM_GETCHECK, 0, 0)){ + pMakefile->buildWhat = BUILD_GUIEXE; + strcpy(pExt, ".exe"); + } + pMakefile->debug = + (BST_CHECKED==::SendMessage(hDbgSym, BM_GETCHECK, 0, 0)); + + if (BST_CHECKED == ::SendMessage(hLangCpp, BM_GETCHECK, 0, 0)){ + pMakefile->lang = LANGCPP; + strcpy(pMakefile->cc, "g++"); + }else{ + pMakefile->lang = LANGC; + strcpy(pMakefile->cc, "gcc"); + } + } + return TRUE; + + case IDCANCEL: + return FALSE; + } +return FALSE; +} + + +/******************************************************************** +* Class: CCompilerDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CCompilerDlg::CCompilerDlg(){ + pProject = NULL; + pMakefile = NULL; +} + +CCompilerDlg::~CCompilerDlg(){ +} + +LRESULT CALLBACK CCompilerDlg::CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam){ + switch(Message){ + case WM_INITDIALOG: + return OnInitDialog((HWND) wParam, lParam); + + case WM_COMMAND: + OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND) lParam); + break; + + case WM_CLOSE: + EndDlg(0); + break; + } +return FALSE; +} + +BOOL CCompilerDlg::OnInitDialog(HWND, LPARAM lInitParam){ + // Set pointers. + pProject = (CProject *) lInitParam; + if (pProject == NULL || &pProject->Makefile == NULL) + return TRUE; + pMakefile = &pProject->Makefile; + + hCppFlags = GetItem(IDC_CPPFLAGS); + hWarning = GetItem(IDC_WARNING); + hOptimiz = GetItem(IDC_OPTIMIZ); + hCFlags = GetItem(IDC_CFLAGS); + hIncDirs = GetItem(IDC_INCDIRS); + + SetItemText(hCppFlags, pMakefile->cppFlags); + SetItemText(hWarning, pMakefile->warning); + SetItemText(hOptimiz, pMakefile->optimize); + SetItemText(hCFlags, pMakefile->cFlags); + SetItemText(hIncDirs, pMakefile->incDirs); +return TRUE; +} + +BOOL CCompilerDlg::OnCommand(WORD, WORD wID, HWND){ + switch (wID){ + case IDOK: + GetItemText(hCppFlags, pMakefile->cppFlags, 256); + GetItemText(hWarning, pMakefile->warning, 64); + GetItemText(hOptimiz, pMakefile->optimize, 64); + GetItemText(hCFlags, pMakefile->cFlags, 64); + GetItemText(hIncDirs, pMakefile->incDirs, 256); + return TRUE; + + case IDCANCEL: + return FALSE; + } +return FALSE; +} + + +/******************************************************************** +* Class: CLinkerDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CLinkerDlg::CLinkerDlg(){ + pProject = NULL; + pMakefile = NULL; +} + +CLinkerDlg::~CLinkerDlg(){ +} + +LRESULT CALLBACK CLinkerDlg::CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam){ + switch(Message){ + case WM_INITDIALOG: + return OnInitDialog((HWND) wParam, lParam); + + case WM_COMMAND: + OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND) lParam); + break; + + case WM_CLOSE: + EndDlg(0); + break; + } +return FALSE; +} + +BOOL CLinkerDlg::OnInitDialog(HWND, LPARAM lInitParam){ + // Set pointers. + pProject = (CProject *) lInitParam; + if (pProject == NULL || &pProject->Makefile == NULL) + return TRUE; + pMakefile = &pProject->Makefile; + + hLdStrip = GetItem(IDC_LDSTRIP); + hLdOpts = GetItem(IDC_LDOPTS); + hLdLibs = GetItem(IDC_LDLIBS); + hLibsDirs = GetItem(IDC_LIBDIRS); + + SetItemText(hLdStrip, pMakefile->ldStrip); + SetItemText(hLdOpts, pMakefile->ldOpts); + SetItemText(hLdLibs, pMakefile->ldLibs); + SetItemText(hLibsDirs, pMakefile->libDirs); +return TRUE; +} + +BOOL CLinkerDlg::OnCommand(WORD, WORD wID, HWND){ + switch (wID){ + case IDOK: + GetItemText(hLdStrip, pMakefile->ldStrip, 32); + GetItemText(hLdOpts, pMakefile->ldOpts, 64); + GetItemText(hLdLibs, pMakefile->ldLibs, 64); + GetItemText(hLibsDirs, pMakefile->libDirs, 256); + return TRUE; + + case IDCANCEL: + return FALSE; + } +return FALSE; +} + + +/******************************************************************** +* Class: CZipDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CZipDlg::CZipDlg(){ + pProject = NULL; + pMakefile = NULL; +} + +CZipDlg::~CZipDlg(){ +} + +LRESULT CALLBACK CZipDlg::CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam){ + switch(Message){ + case WM_INITDIALOG: + return OnInitDialog((HWND) wParam, lParam); + + case WM_COMMAND: + OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND) lParam); + break; + + case WM_CLOSE: + EndDlg(0); + break; + } +return FALSE; +} + +BOOL CZipDlg::OnInitDialog(HWND, LPARAM lInitParam){ + // Set pointers. + pProject = (CProject *) lInitParam; + if (pProject == NULL || &pProject->Makefile == NULL) + return TRUE; + pMakefile = &pProject->Makefile; + + hZipDir = GetItem(IDC_ZIP_DIR); + hZipFlags = GetItem(IDC_ZIPFLAGS); + SetItemText(hZipDir, pProject->zipDir); + SetItemText(hZipFlags, pProject->zipFlags); +return TRUE; +} + +BOOL CZipDlg::OnCommand(WORD, WORD wID, HWND){ + switch (wID){ + case IDOK: + GetItemText(hZipDir, pProject->zipDir, MAX_PATH); + GetItemText(hZipFlags, pProject->zipFlags, 256); + return TRUE; + + case IDCANCEL: + return FALSE; + } +return FALSE; +} + + +/******************************************************************** +* Class: CNewModuleDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CNewModuleDlg::CNewModuleDlg(){ + pProject = NULL; +} + +CNewModuleDlg::~CNewModuleDlg(){ +} + +LRESULT CALLBACK CNewModuleDlg::CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam){ + + char fileName[64]; + bool createHeader = true; + HWND wCreateHeader = GetItem(IDC_HEADER); + + switch(Message){ + case WM_INITDIALOG: + pProject = (CProject *) lParam; + if (createHeader) + ::SendMessage(wCreateHeader, BM_SETCHECK, BST_CHECKED, 0); + strcpy(fileName, "new.cpp"); + ::SetDlgItemText(_hWnd, 301, fileName); + return TRUE; + + case WM_COMMAND: + if (LOWORD(wParam) == IDCANCEL){ + fileName[0] = 0; + EndDlg(IDCANCEL); + return FALSE; + }else if(LOWORD(wParam) == IDOK){ + ::GetDlgItemText(_hWnd, 301, fileName, 64); + createHeader = BST_CHECKED == + ::SendMessage(wCreateHeader, BM_GETCHECK, 0, 0); + pProject->NewModule(fileName, createHeader); + EndDlg(IDCANCEL); + return TRUE; + } + break; + + case WM_CLOSE: + EndDlg(0); + break; + } +return FALSE; +} + + +/******************************************************************** +* Class: CProject. +* +* Purpose: Project management. +* +* Revisions: +* +********************************************************************/ +//@@TODO close project Dlg's before closing Project. +CProject::CProject(){ + prjVer = 40; +} + +CProject::~CProject(){ +} + +void CProject::Reset(){ + szFileName[MAX_PATH - 1] = '\0'; // security. + szFileName[0] = '\0'; + szDirBuffer[0] = '\0'; + nFileOffset = 0; + nFileExtension = 0; + + strcpy (zipDir, "."); + strcpy (zipFlags, "*.*"); + numFiles = 0; + loaded = false; + modified = false; + buildMakefile = true; + + compilerName[0] = '\0'; + + Makefile.Init(); +} + +bool CProject::NoProject(void){ + if (!loaded){ + MsgBox.DisplayWarning("No project loaded"); + // Or directly show open project dlg. + return true; + } +return false; +} + +int CProject::CloseDecision(void){ + if (loaded){ + return MsgBox.Ask("Close current project ?", false); + } +return IDNO; +} + +bool CProject::SwitchCurrentDir(void){ + // Switch to Project Directory + szDirBuffer[nFileOffset-1] = '\0'; +return ::SetCurrentDirectory(szDirBuffer); +} + +bool CProject::RelativeToAbsolute(char * relativePath){ + if (*szDirBuffer && nFileOffset){ + if (relativePath[0] == '.' && relativePath[1] == '\\' + && relativePath[2] != '\0'){ + szDirBuffer[nFileOffset-1] = '\\'; + strcpy(&szDirBuffer[nFileOffset], &relativePath[2]); + return true; + } + } +return false; +} + + +/******************************************************************** +* New Project. +********************************************************************/ +bool CProject::New(char * fileName, WORD fileOffset){ + // Load default values. + Reset(); + + // Copy project file's directory. + strcpy(szFileName, fileName); + nFileOffset = fileOffset; + + strncpy(szDirBuffer, szFileName, (nFileOffset - 1)); + szDirBuffer[nFileOffset-1] = '\0'; + strcpy(winApp.projectDir, szDirBuffer); + + // Makefile: Get target name. + nFileExtension = winApp.FileDlg.GetFileExtension(); + strcpy(Makefile.target, &szFileName[nFileOffset]); + char * pExt = strrchr(Makefile.target, '.'); + if (pExt){ + *pExt='\0'; + } + loaded = true; + + AddFiles(); + + Makefile.GetFullPath(szFileName, nFileOffset, "makefile"); + + buildMakefile = true; + OptionsDlg(); + SavePrjFile(IDYES); +return true; +} + +/******************************************************************** +* Open Project. +********************************************************************/ +bool CProject::Open(char * fileName, WORD fileOffset){ + // Initialize project tree view. + Reset(); + + // Copy project file's directory. + strcpy(szFileName, fileName); + nFileOffset = fileOffset; + + strncpy(szDirBuffer, szFileName, (nFileOffset - 1)); + szDirBuffer[nFileOffset-1] = '\0'; + strcpy(winApp.projectDir, szDirBuffer); + + // Load project file in a buffer. + if (!PrjFile.Load(szFileName)){ + MsgBox.DisplayFatal("Can't load project file !"); + //@@ should close inifile ? + return false; + } + + char name[64]; + *name = '\0'; + // [Project] section + int signature = PrjFile.GetInt( "Signature", "Project" ); + if (signature != prjVer){ + MsgBox.DisplayFatal("Bad signature in the project file !"); + return false; + } + + numFiles = PrjFile.GetInt( "NumFiles" ); + PrjFile.GetString(compilerName, "Compiler" ); + buildMakefile = PrjFile.GetInt( "BuildMakefile" ); + + // [Archives] section + PrjFile.GetString(zipDir, "Directory", "Archives" ); + PrjFile.GetString(zipFlags, "Flags"); + + // [Makefile] section + PrjFile.GetString(Makefile.make, "Make", "Makefile" ); + PrjFile.GetString(Makefile.cc, "CC" ); + PrjFile.GetString(Makefile.wres, "WRES" ); + PrjFile.GetString(Makefile.test, "TEST" ); + PrjFile.GetString(name, "Makefile" ); + PrjFile.GetString(Makefile.mkfDir, "MakefileDir"); + PrjFile.GetString(Makefile.target, "Target" ); + PrjFile.GetString(Makefile.tgtDir, "TargetDir" ); + Makefile.buildWhat = PrjFile.GetInt( "Build" ); + Makefile.debug = PrjFile.GetInt( "Debug" ); + Makefile.lang = PrjFile.GetInt( "Lang" ); + PrjFile.GetString(Makefile.cppFlags, "CppFlags" ); + PrjFile.GetString(Makefile.warning, "CcWarning"); + PrjFile.GetString(Makefile.optimize, "CcOptimize"); + PrjFile.GetString(Makefile.cFlags, "CcFlags" ); + PrjFile.GetString(Makefile.incDirs, "IncDirs" ); + PrjFile.GetString(Makefile.ldStrip, "LdStrip" ); + PrjFile.GetString(Makefile.ldOpts, "LdOptions" ); + PrjFile.GetString(Makefile.ldLibs, "LdLibraries"); + PrjFile.GetString(Makefile.libDirs, "LdLibDirs" ); + + Makefile.GetFullPath(szFileName, nFileOffset, name); + + if (numFiles){ + CFileItem * srcFile; + // [FileXX] section + char fileNumber [8]; + char fileSection [16]; + + for (int n=1; n<=numFiles; n++){ + itoa(n, fileNumber, 10); + strcpy(fileSection, "File"); + strcat(fileSection, fileNumber); + + // SrcFile + srcFile = new CFileItem; + srcFile->isInProject = true; + PrjFile.GetString(srcFile->szFileName, "Name", fileSection); + CheckFile(srcFile); + ::GetFileType(srcFile); + srcFile->show = PrjFile.GetInt( "Show" ); + + if(!winApp.Manager.OpenFile(srcFile)){ + delete srcFile; + return false; + } + } + } + loaded = true; +return true; +} + +int CProject::SavePrjFile(int decision){ + if (!loaded || !modified) + return decision; + if (decision == IDNO || decision == IDCANCEL) + return decision; + + /* Ask ? */ + if (decision == IDASK){ + decision = MsgBox.AskToSave(true); // Cancel button. + if (decision != IDYES) + return decision; // IDNO or IDCANCEL. + } + + CProjectView * pProjectView = &winApp.Manager.ProjectView; + FILE * file; + CFileItem * srcFile; + int count = 0; + + numFiles = pProjectView->Length(); + + file = fopen(szFileName, "w"); + if (!file){ + MsgBox.DisplayFatal("Can't save project file !"); + return decision; + } + + // [Project] + fprintf (file, "[Project]\nSignature = %d" , prjVer ); + fprintf (file, "\nNumFiles = %d" , numFiles ); + fprintf (file, "\nCompiler = %s" , compilerName ); + fprintf (file, "\nBuildMakefile = %d" , buildMakefile ); + + // [Archives] + fprintf (file, "\n\n[Archives]\nDirectory = %s" , zipDir ); + fprintf (file, "\nFlags = %s" , zipFlags ); + + // [Makefile] + fprintf (file, "\n\n[Makefile]\nMAKE = %s" , Makefile.make ); + fprintf (file, "\nCC = %s" , Makefile.cc ); + fprintf (file, "\nWRES = %s" , Makefile.wres ); + fprintf (file, "\nTEST = %s" , Makefile.test ); + fprintf (file, "\nMakefile = %s" , &Makefile.szFileName[Makefile.nFileOffset]); + fprintf (file, "\nMakefileDir = %s" , Makefile.mkfDir ); + fprintf (file, "\nTarget = %s" , Makefile.target ); + fprintf (file, "\nTargetDir = %s" , Makefile.tgtDir ); + fprintf (file, "\nBuild = %d" , Makefile.buildWhat ); + fprintf (file, "\nDebug = %d" , Makefile.debug ); + fprintf (file, "\nLang = %d" , Makefile.lang ); + fprintf (file, "\nCppFlags = %s" , Makefile.cppFlags ); + fprintf (file, "\nCcWarning = %s" , Makefile.warning ); + fprintf (file, "\nCcOptimize = %s" , Makefile.optimize ); + fprintf (file, "\nCcFlags = %s" , Makefile.cFlags ); + fprintf (file, "\nIncDirs = %s" , Makefile.incDirs ); + fprintf (file, "\nLdStrip = %s" , Makefile.ldStrip ); + fprintf (file, "\nLdOptions = %s" , Makefile.ldOpts ); + fprintf (file, "\nLdLibraries = %s" , Makefile.ldLibs ); + fprintf (file, "\nLdLibDirs = %s" , Makefile.libDirs ); + + /* [Filexx] */ + srcFile = (CFileItem *) pProjectView->First(); + while (srcFile){ + count++; + fprintf (file, "\n\n[File%d" , count ); + fprintf (file, "]\nName = %s" , srcFile->szFileName ); + fprintf (file, "\nShow = %d" , 0 ); + srcFile = (CFileItem *) pProjectView->Next(); + } + fprintf (file, "\n"); + fclose(file); + modified = false; +return decision; +} + +bool CProject::NewModule(char * name, bool createHeader){ + if (NoProject()) + return false; + + SwitchCurrentDir(); + + CFileItem * srcFile = winApp.Manager.ProjectView.NewFile(name); + if (!srcFile){ + MsgBox.DisplayWarning("Can't create file : %s", name); + return false; + } + if (createHeader && srcFile->type != H_FILE){ + char header[64]; + strcpy(header, name); + char ext[] = "h"; + ChangeFileExt(header, ext); + + if (!winApp.Manager.ProjectView.NewFile(header)){ + MsgBox.DisplayWarning("Can't create file : %s", header); + return false; + } + } +return true; +} + +bool CProject::AddFiles(void){ + if (NoProject()) + return false; + + CFileItem * srcFile; + char srcFiles[2048]; + srcFiles [0] = 0; + WORD fileOffset; + + // Show Open dialog. + if (!winApp.FileDlg.Open(&winApp, srcFiles, 2048, ADD_SRC_FILE)) + return false; // canceled by user + + // Check if srcFiles path includes projectDir. + int n = 0; + int maxlen = nFileOffset - 1; + while (n 2){ + relativePath[nn] = '\\'; + nn++; + } + relativePath[nn] = '\0'; + + // Append each file name. + fileOffset = winApp.FileDlg.GetFileOffset(); + + while (fileOffset){ + // Try to add each file to the project. + srcFile = new CFileItem; + strcpy(srcFile->szFileName, relativePath); + + strcat(srcFile->szFileName, &srcFiles[fileOffset]); + + CheckFile(srcFile); + ::GetFileType(srcFile); + srcFile->show = 0; + srcFile->isInProject = true; + + if(!winApp.Manager.ProjectView.OpenFile(srcFile)){ + delete srcFile; + return false; + } + + fileOffset = winApp.FileDlg.GetNextFileOffset(); + } + modified = true; + buildMakefile = true; + return true; + } + MsgBox.DisplayString("Out of the project"); +return false; +} + +/******************************************************************** +* Dialogs. +********************************************************************/ +bool CProject::OptionsDlg(void){ +/**/ if (NoProject()) + return false; + + _OptionsDlg.CreateModal(&winApp, IDD_OPTION, (LPARAM) this); +return true; +} + +bool CProject::NewModuleDlg(void){ + if (NoProject()) + return false; + + _NewModuleDlg.CreateModal(&winApp, IDD_NEW_MODULE, (LPARAM) this); +return true; +} + +/******************************************************************** +* Project Commands. +********************************************************************/ +void CProject::ZipSrcs(void){ + if (NoProject() || winApp.Process.isRunning()) + return; + + // Switch to Project Directory + SwitchCurrentDir(); + + winApp.Report.Clear(); + + char fileName[64]; + char date[16]; + date[0] = 0; + + // Archive name = zipDir\month+day+year+src.zip + GetDateFormat(LOCALE_USER_DEFAULT, 0, NULL, "MMddyyyy", + date, 16); + + if (*zipDir == '\0') + strcpy (zipDir, "."); + strcpy (fileName, zipDir); + strcat (fileName, "\\"); + strcat (fileName, date); + strcat (fileName, "src"); + strcat (fileName, ".zip"); + + char msgBuf[128]; + sprintf(msgBuf, "Create archive > %s", fileName); + winApp.Report.Append(msgBuf, LVOUT_NORMAL); + + // Put the command line and the run flag in the command stack. + winApp.Process.AddTask( + "zip ", + OUTERR_PIPE, + LVOUT_NORMAL); + + winApp.Process.CmdCat(fileName); + if (*zipFlags){ + winApp.Process.CmdCat(" "); + winApp.Process.CmdCat(zipFlags); + } + + winApp.Process.Run(); +} + +void CProject::Explore(HWND hwnd){ + if (NoProject()) + return; + + if(ShellExecute(hwnd, "explore", szDirBuffer, NULL, NULL, SW_SHOWMAXIMIZED) + < (HINSTANCE) 32){ + MsgBox.DisplayString("Can't launch Explorer"); + return; + } +} + +/******************************************************************** +* Compiler Commands. +********************************************************************/ +void CProject::Build(void){ + if (NoProject() || winApp.Process.isRunning()) + return; + + winApp.Report.Clear(); + winApp.Report.Append("Invoking compiler...", LVOUT_NORMAL); + + // Save modified files + winApp.Manager.ProjectView.SaveAll(IDYES); // Silent. + + // Switch to Makefile Directory + Makefile.SwitchCurrentDir(); + + /* Build makefile ? */ + if (buildMakefile){ + winApp.Report.Append("Building makefile...", LVOUT_NORMAL); + + // Fill buffers and initialize a new process. + Makefile.Build(&winApp.Manager.ProjectView, &winApp.Process); + buildMakefile = false; + modified = true; + } + + // Put the command line and the run flag in the command stack. + winApp.Process.AddTask( + Makefile.make, + OUTERR_PIPE, + LVOUT_ERROR); + + winApp.Process.CmdCat(" -f "); + winApp.Process.CmdCat(&Makefile.szFileName[Makefile.nFileOffset]); + if (Makefile.debug) + winApp.Process.CmdCat(" debug"); + + winApp.Process.Run(); +} + +void CProject::RebuildAll(void){ + if (NoProject() || winApp.Process.isRunning()) + return; + + // Switch to Makefile Directory + Makefile.SwitchCurrentDir(); + + winApp.Report.Clear(); + winApp.Report.Append("Invoking compiler...", LVOUT_NORMAL); + + // Save modified files + winApp.Manager.ProjectView.SaveAll(IDYES); // Silent. + + // Build makefile. + Makefile.Build(&winApp.Manager.ProjectView, &winApp.Process); + buildMakefile = false; + modified = true; + + // Make clean. + winApp.Process.AddTask( + Makefile.make, + OUTERR_PIPE, + LVOUT_ERROR); + + winApp.Process.CmdCat(" -f "); + winApp.Process.CmdCat(&Makefile.szFileName[Makefile.nFileOffset]); + winApp.Process.CmdCat(" clean"); + + // Build. + winApp.Process.AddTask( + Makefile.make, + OUTERR_PIPE, + LVOUT_ERROR); + + winApp.Process.CmdCat(" -f "); + winApp.Process.CmdCat(&Makefile.szFileName[Makefile.nFileOffset]); + if (Makefile.debug) + winApp.Process.CmdCat(" debug"); + + winApp.Process.Run(); +} + +void CProject::RunTarget(void){ + if (NoProject() || winApp.Process.isRunning()) + return; + + if (Makefile.buildWhat == BUILD_STATLIB + || Makefile.buildWhat ==BUILD_DLL) + return; + + winApp.Report.Clear(); + winApp.Report.Append("Run target...", LVOUT_NORMAL); + + // Put the command line and the run flag in the command stack. + winApp.Process.AddTask(szDirBuffer, NO_PIPE, STDOUT_NONE); + winApp.Process.CmdCat("\\"); + if (Makefile.tgtDir[0] == '.'){ + if (Makefile.tgtDir[1] == '.' && Makefile.tgtDir[2] == '\\' + && Makefile.tgtDir[3] != '\0'){ + winApp.Process.CmdCat(&Makefile.tgtDir[3]); + }else{ + // Invalid dir, try ".\target". + winApp.Process.CmdCat("."); + } + } + winApp.Process.CmdCat("\\"); + winApp.Process.CmdCat(Makefile.target); + + winApp.Process.Run(); +} + +void CProject::MakeClean(void){ + if (NoProject() || winApp.Process.isRunning()) + return; + + // Switch to Makefile Directory + Makefile.SwitchCurrentDir(); + + winApp.Report.Clear(); + winApp.Report.Append("Deleting objects...", LVOUT_NORMAL); + + // Put the command line and the output flag in the command stack. + winApp.Process.AddTask( + Makefile.make, + OUTERR_PIPE, + LVOUT_ERROR); + + winApp.Process.CmdCat(" -f "); + winApp.Process.CmdCat(&Makefile.szFileName[Makefile.nFileOffset]); + winApp.Process.CmdCat(" clean"); + + winApp.Process.Run(); +} + +void CProject::BuildMakefile(void){ + if (NoProject() || winApp.Process.isRunning()) + return; + + // Switch to Project Directory + Makefile.SwitchCurrentDir(); + + winApp.Report.Clear(); + winApp.Report.Append("Building makefile...", LVOUT_NORMAL); + + // Fill buffers and initialize a new process. + Makefile.Build(&winApp.Manager.ProjectView, &winApp.Process); + buildMakefile = false; + modified = true; + // Run the process. + winApp.Process.Run(); +} + + +/******************************************************************** +* Class: CMakefile. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CMakefile::CMakefile(){ + Init(); +} + +CMakefile::~CMakefile(){ +} + +void CMakefile::Init(void){ + szFileName[MAX_PATH - 1] = '\0'; // security. + szFileName[0] = '\0'; + nFileOffset = 0; + strcpy (mkfDir, "."); + + strcpy (cc, "gcc"); + strcpy (make, "make"); + strcpy (wres, "windres"); + strcpy (test, "gcc -v"); + + target[0] = '\0'; + strcpy (tgtDir, "."); + buildWhat = BUILD_EXE; + debug = false; + lang = LANGC; + + cppFlags[0] = '\0'; + strcpy (warning, "-W -Wall -pedantic"); + strcpy (optimize, "-O2"); + cFlags[0] = '\0'; + incDirs[0] = '\0'; + + strcpy (ldStrip, "-s"); + ldOpts[0] = '\0'; + ldLibs[0] = '\0'; + libDirs[0] = '\0'; + *arFlags = '\0'; +} + +void CMakefile::GetFullPath(char * prjFileName, WORD offset, char * name){ + // Copy project directory and append makefile relative dir. + strncpy(szFileName, prjFileName, offset); + WORD len = AppendPath(szFileName, offset, mkfDir); + // Increment file offset. + if (len){ + offset += len; + }else{ + strcpy(mkfDir, "."); + } + // Append makefile name. + szFileName[offset-1] = '\\'; + if (*name){ + strcpy(&szFileName[offset], name); + }else{ + strcpy(name, "makefile"); + } + nFileOffset = offset; +} + +bool CMakefile::SwitchCurrentDir(void){ + // Switch to Makefile Directory. + if (nFileOffset < 2) + return false; + szFileName[nFileOffset-1] = '\0'; + bool result = SetCurrentDirectory(szFileName); + szFileName[nFileOffset-1] = '\\'; +return result; +} + +void CMakefile::Build(CProjectView * Tree, CProcess* /*Process*/){ + SrcList2Buffers(Tree); + // Write the first part of the Makefile. + Write(); + + /* Invokes compiler to get dependencies with something like: + "gcc -MM file1.cpp file2.cpp ..." */ + + CTask * task = winApp.Process.AddTask( + depBuf, + OUTERR_PIPE, + STDOUT_FILE_APPEND); + strcpy(task->szFileName, szFileName); +} + +void CMakefile::SrcList2Buffers(CProjectView * Tree){ + + // 1. Begin to fill each buffer. + strcpy(depBuf, cc); + if (*cppFlags != '\0'){ + strcat(depBuf, " "); + strcat(depBuf, cppFlags); + } + strcat(depBuf, " -MM "); + if (*incDirs != '\0'){ + strcat(depBuf, incDirs); + strcat(depBuf, " "); + } + + strcpy(srcBuf, "\nSRCS\t=\\\n"); + strcpy(objBuf, "\nOBJS\t=\\\n"); + resBuf [0] = 0; + + // 2. Parse the module list and retrieve sources files names. + CFileItem* srcFile; + + if(!Tree->First()) + return; // The list is empty, nothing to search. + + do { srcFile = (CFileItem *) Tree->GetCurrent(); + + if (srcFile->type == C_FILE || srcFile->type == RC_FILE){ + // Source files and objects buffers. + strcat (srcBuf, "\t"); + strcat (srcBuf, &srcFile->szFileName[srcFile->nFileOffset]); + strcat (srcBuf, "\\\n"); + + // Change file extension. + char ext[] = "o"; + strcpy(objFile, &srcFile->szFileName[srcFile->nFileOffset]); + ChangeFileExt(objFile, ext); + strcat (objBuf, "\t"); + strcat (objBuf, objFile); + strcat (objBuf, "\\\n"); + + if (srcFile->type == C_FILE){ + // Dependencies buffer. + strcat(depBuf, &srcFile->szFileName[srcFile->nFileOffset]); + strcat(depBuf, " "); + }else if (srcFile->type == RC_FILE){ + // Resource buffer. + strcat (resBuf, objFile); + strcat (resBuf, ": "); + strcat (resBuf, &srcFile->szFileName[srcFile->nFileOffset]); + strcat (resBuf, "\n\n"); + } + } + } while (Tree->Next()); + + int len = strlen(srcBuf); + srcBuf[len-2] = '\n'; + srcBuf[len-1] = 0; + + len = strlen(objBuf); + objBuf[len-2] = '\n'; + objBuf[len-1] = 0; +} + +void CMakefile::Write(void){ + FILE * file; + + file = fopen(szFileName, "w"); + if (!file){ + MsgBox.DisplayString("Can't open file :\r\n%s", szFileName); + return; + } + + /* Signature */ + fprintf (file, "# Generated automatically by Visual-MinGW.\n"); + fprintf (file, "# http://visual-mingw.sourceforge.net/\n"); + + /* Standard defines */ + fprintf (file, "\nCC = %s", cc); + fprintf (file, "\nWRES = %s", wres ); + fprintf (file, "\nDLLWRAP = dllwrap" ); + fprintf (file, "\nCPPFLAGS = %s", cppFlags ); + + if (buildWhat == BUILD_GUIEXE) + fprintf (file, "\nLDBASEFLAGS = -mwindows %s %s", ldOpts, ldLibs ); + else + fprintf (file, "\nLDBASEFLAGS = %s %s", ldOpts, ldLibs ); + fprintf (file, "\nINCDIRS = %s", incDirs ); + fprintf (file, "\nOPTIMIZ = %s", optimize ); + fprintf (file, "\nSTRIP = %s", ldStrip ); + /* Debug symbols ? Language ? */ + fprintf (file, "\n\nifeq ($(MAKECMDGOALS),debug)"); + if (lang == LANGCPP){ + fprintf (file, "\nCXXFLAGS = %s $(INCDIRS) -g %s", warning, cFlags); + fprintf (file, "\nLDFLAGS = $(LDBASEFLAGS)"); + fprintf (file, "\nelse"); + fprintf (file, "\nCXXFLAGS = %s $(INCDIRS) $(OPTIMIZ) %s", warning, cFlags); + fprintf (file, "\nLDFLAGS = $(STRIP) $(LDBASEFLAGS)"); + fprintf (file, "\nendif"); + }else{ + fprintf (file, "\nCFLAGS = %s $(INCDIRS) -g %s", warning, cFlags); + fprintf (file, "\nLDFLAGS = $(LDBASEFLAGS)"); + fprintf (file, "\nelse"); + fprintf (file, "\nCFLAGS = %s $(INCDIRS) $(OPTIMIZ) %s", warning, cFlags); + fprintf (file, "\nLDFLAGS = $(STRIP) $(LDBASEFLAGS)"); + fprintf (file, "\nendif"); + } + /* Directories */ + fprintf (file, "\n\nSRCDIR = %s", mkfDir ); + fprintf (file, "\nBINDIR = %s", tgtDir ); + fprintf (file, "\nLIBDIRS = %s", libDirs ); + /* Rule to compile rc files */ + fprintf (file, "\n\n%c.o : %c.rc\n\t$(WRES) $(CPPFLAGS) $< $@", '%', '%' ); + /* List of objects */ + fprintf (file, "\n%s", objBuf ); + /* Target */ + fprintf (file, "\nTARGET =\t$(BINDIR)\\%s" , target ); + /* all, alldebug */ + fprintf (file, "\n\n# Targets\n" ); + fprintf (file, "all:\t$(TARGET)\n\ndebug:\t$(TARGET)\n\n" ); + /* clean */ + fprintf (file, "cleanobjs:\n\trm -f $(OBJS)\n\n" ); + fprintf (file, "cleanbin:\n\trm -f $(TARGET)\n\n" ); + fprintf (file, "clean:\tcleanobjs cleanbin\n\n" ); + /* Dependencies */ + fprintf (file, "# Dependency rules\n" ); + /* Language */ + if (buildWhat == BUILD_STATLIB){ + fprintf (file, "$(TARGET): $(OBJS)\n\t$(AR) -ru $(BINDIR)\\%s", target); + fprintf (file, " $(OBJS) $(INCDIRS) $(LIBDIRS)\n\n%s", resBuf); + }else if (buildWhat == BUILD_DLL){ + fprintf (file, "$(TARGET): $(OBJS)\n\t$(DLLWRAP) -o $@ $(OBJS) $(LDFLAGS)\n\n" ); + }else if (lang == LANGCPP){ + fprintf (file, "$(TARGET): $(OBJS)\n\t$(CXX) -o $(BINDIR)\\%s", target); + fprintf (file, " $(OBJS) $(INCDIRS) $(LIBDIRS) $(LDFLAGS)\n\n%s",resBuf); + }else{ + fprintf (file, "$(TARGET): $(OBJS)\n\t$(CC) -o $(BINDIR)\\%s", target); + fprintf (file, " $(OBJS) $(INCDIRS) $(LIBDIRS) $(LDFLAGS)\n\n%s",resBuf); + } + fclose(file); +} + + +/******************************************************************** +* Class: CCompiler. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CCompiler::CCompiler(){ + make[0] = '\0'; + cc[0] = '\0'; + cFlags[0] = '\0'; + ldFlags[0] = '\0'; + wres[0] = '\0'; + debug[0] = '\0'; + test[0] = '\0'; +} + +CCompiler::~CCompiler(){ +} + +bool CCompiler::LoadData(char * fullpath){ + Load(fullpath); + // [Common] section + GetString(make, "MAKE", "Common"); + GetString(cc, "CC" ); + GetString(cFlags, "CFLAGS" ); + GetString(ldFlags, "LDFLAGS" ); + GetString(wres, "WRES" ); + GetString(debug, "DEBUG" ); + GetString(test, "TEST" ); +return true; +} + diff --git a/rosapps/devutils/vmingw/project.h b/rosapps/devutils/vmingw/project.h new file mode 100644 index 00000000000..8441579576f --- /dev/null +++ b/rosapps/devutils/vmingw/project.h @@ -0,0 +1,295 @@ +/******************************************************************** +* Module: project.h. This is part of Visual-MinGW. +* +* License: Visual-MinGW is covered by GNU General Public License, +* Copyright (C) 2001 Manu B. +* See license.htm for more details. +* +********************************************************************/ +#ifndef PROJECT_H +#define PROJECT_H + +#include "winui.h" +#include "main.h" +#include "process.h" + +#define BUILD_STATLIB 0 +#define BUILD_DLL 1 +#define BUILD_EXE 2 +#define BUILD_GUIEXE 3 +#define LANGC 0 +#define LANGCPP 1 + +class CProject; +class CMakefile; + +bool CheckFile(CFileItem * file); + +class CGeneralDlg : public CDlgBase +{ + public: + CGeneralDlg(); + virtual ~CGeneralDlg(); + + virtual LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + BOOL OnInitDialog(HWND hwndFocus, LPARAM lInitParam); + BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hwndCtl); + + protected: + + private: + CProject *pProject; + CMakefile *pMakefile; + HWND hStatLib; + HWND hDll; + HWND hConsole; + HWND hGuiExe; + HWND hDbgSym; + HWND hLangC; + HWND hLangCpp; + HWND hMkfName; + HWND hMkfDir; + HWND hUserMkf; + HWND hTgtName; + HWND hTgtDir; +}; + +class CCompilerDlg : public CDlgBase +{ + public: + CCompilerDlg(); + virtual ~CCompilerDlg(); + + virtual LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + BOOL OnInitDialog(HWND hwndFocus, LPARAM lInitParam); + BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hwndCtl); + + protected: + + private: + CProject *pProject; + CMakefile *pMakefile; + HWND hCppFlags; + HWND hWarning; + HWND hOptimiz; + HWND hCFlags; + HWND hIncDirs; +}; + +class CZipDlg : public CDlgBase +{ + public: + CZipDlg(); + virtual ~CZipDlg(); + + virtual LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + BOOL OnInitDialog(HWND hwndFocus, LPARAM lInitParam); + BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hwndCtl); + + protected: + + private: + CProject *pProject; + CMakefile *pMakefile; + HWND hZipDir; + HWND hZipFlags; +}; + +class CLinkerDlg : public CDlgBase +{ + public: + CLinkerDlg(); + virtual ~CLinkerDlg(); + + virtual LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + BOOL OnInitDialog(HWND hwndFocus, LPARAM lInitParam); + BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hwndCtl); + + protected: + + private: + CProject *pProject; + CMakefile *pMakefile; + HWND hLdStrip; + HWND hLdOpts; + HWND hLdLibs; + HWND hLibsDirs; +}; + +class COptionsDlg : public CTabbedDlg +{ + public: + COptionsDlg(); + virtual ~COptionsDlg(); + + BOOL EndDlg(int nResult); + virtual LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + BOOL OnInitDialog(HWND hwndFocus, LPARAM lInitParam); + BOOL OnCommand(WORD wNotifyCode, WORD wID, HWND hwndCtl); + + protected: + + private: + CProject *pProject; + CMakefile *pMakefile; + CGeneralDlg GeneralDlg; + CCompilerDlg CompilerDlg; + CLinkerDlg LinkerDlg; + CZipDlg ZipDlg; +}; + +class CNewModuleDlg : public CDlgBase +{ + public: + CNewModuleDlg(); + virtual ~CNewModuleDlg(); + + virtual LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + + protected: + + private: + CProject *pProject; +}; + +class CCompiler : public CIniFile +{ + public: + CCompiler(); + ~CCompiler(); + + bool LoadData(char * fullpath); + + char make[64]; + + char cc[16]; + char cFlags[64]; + char ldFlags[64]; + char wres[16]; + + char debug[16]; + char test[16]; + + protected: + + private: +}; + +class CMakefile +{ + public: + CMakefile(); + ~CMakefile(); + + void Init(void); + bool SwitchCurrentDir(void); + void GetFullPath(char * prjFileName, WORD offset, char * name); + void Build(CProjectView * Tree, CProcess* Process); + void SrcList2Buffers(CProjectView * Tree); + void Write(void); + + // File. + char szFileName[MAX_PATH]; + WORD nFileOffset; + char mkfDir[MAX_PATH]; + + // Compiler dependent. + char cc[4]; + char make[64]; + char wres[16]; + char test[16]; + + char target[64]; + char tgtDir[MAX_PATH]; + UINT buildWhat; + bool debug; + UINT lang; + + // Compiler data. + char cppFlags[256]; + char warning[64]; + char optimize[64]; + char cFlags[64]; + char incDirs[256]; + + // Linker data. + char ldStrip[32]; + char ldOpts[64]; + char ldLibs[64]; + char libDirs[256]; + + // Archiver. + char arFlags[64]; + + protected: + + private: + // Buffers. + char objFile[64]; + char srcBuf [1024]; + char objBuf [1024]; + char resBuf [1024]; + char depBuf [256]; +}; + +class CProject //: public CIniFile +{ + public: + CProject(); + ~CProject(); + + bool NoProject(void); + int CloseDecision(void); + bool New(char * fileName, WORD fileOffset); + bool Open(char * fileName, WORD fileOffset); + + bool RelativeToAbsolute(char * relativePath); + bool AddFiles(void); + + bool OptionsDlg(void); + bool NewModuleDlg(void); + bool NewModule(char * srcFile, bool createHeader); + + void ZipSrcs(void); + void Explore(HWND hwnd); + + void Build(void); + void RebuildAll(void); + void RunTarget(void); + void MakeClean(void); + void BuildMakefile(void); + + bool SwitchCurrentDir(void); + + CMakefile Makefile; + + /* May be private members */ + int numFiles; + bool loaded; + bool modified; + bool buildMakefile; + int SavePrjFile(int decision); + + char szFileName[MAX_PATH]; + WORD nFileOffset; + WORD nFileExtension; + char szDirBuffer[MAX_PATH]; + + char zipDir[MAX_PATH]; + char zipFlags[256]; + + char compilerName[64]; + + protected: + + private: + void Reset(); + +CIniFile PrjFile; + COptionsDlg _OptionsDlg; + CNewModuleDlg _NewModuleDlg; + + int prjVer; +}; + +#endif diff --git a/rosapps/devutils/vmingw/rsrc.h b/rosapps/devutils/vmingw/rsrc.h new file mode 100644 index 00000000000..2003f47d156 --- /dev/null +++ b/rosapps/devutils/vmingw/rsrc.h @@ -0,0 +1,168 @@ +/******************************************************************** +* Module: resource.h. This is part of Visual-MinGW. +* +* License: Visual-MinGW is covered by GNU General Public License, +* Copyright (C) 2001 Manu B. +* See license.htm for more details. +* +********************************************************************/ +#define APP_VERSION "0.43a" +#define FULL_APP_VERSION "0.43 alpha" + +// Static control ---------------------------- +#define IDC_STATIC -1 + +// Bitmaps ---------------------------------- +#define IDB_TOOLBAR 10 +#define IDB_TREEVIEW 11 + +#define IDAPPLY 20 + +// Preferences Dialog ----------------------- +#define IDD_PREFERENCES 100 +#define IDC_PREF_TABS 101 + +#define IDD_ENVIRON 110 +#define IDC_SET_CCBIN 111 +#define IDC_CCBIN 112 +#define IDC_BROWSE_CC 113 +#define IDC_SET_CMDBIN 114 +#define IDC_CMDBIN 115 +#define IDC_BROWSE_CMD 116 +#define IDC_AUTOEXEC 117 +#define IDC_ENV_VIEW 118 +/*#define IDC_CC_INCDIR 101 +#define IDC_BROWSE 102*/ + +// Find Dialog ------------------------------- +#define IDD_FIND 120 +#define IDC_FINDWHAT 121 +#define IDC_WHOLEWORD 122 +#define IDC_MATCHCASE 123 +#define IDC_REGEXP 124 +#define IDC_WRAP 125 +#define IDC_UNSLASH 126 +#define IDC_DIRECTIONUP 127 +#define IDC_DIRECTIONDOWN 128 + +// Replace ---------------------------------- +#define IDD_REPLACE 130 +#define IDC_REPLACEWITH 131 +#define IDC_REPLACE 132 +#define IDC_REPLACEALL 133 +#define IDC_REPLACEINSEL 134 + +// Find in files ------------------------------- +#define IDD_GREP 135 +#define IDC_GFILTER 136 +#define IDC_GDIR 137 +#define IDC_GBROWSE 139 + +// New module ------------------------------ +#define IDD_NEW_MODULE 140 +#define IDC_HEADER 141 + +// Options ---------------------------------- +#define IDD_OPTION 150 +#define IDC_OPTION_TABS 151 +#define IDC_HELP_BTN 152 + +// General tab --------------------------------- +#define IDD_GENERAL_PANE 160 +#define IDC_STATLIB 161 +#define IDC_DLL 162 +#define IDC_CONSOLE 163 +#define IDC_GUIEXE 164 +#define IDC_DBGSYM 165 +#define IDC_LANGC 166 +#define IDC_LANGCPP 167 +#define IDC_MKF_NAME 168 +#define IDC_MKF_DIR 169 +#define IDC_USER_MKF 170 +#define IDC_TGT_NAME 171 +#define IDC_TGT_DIR 172 + +// Compiler tab ----------------------------- +#define IDD_COMPILER 180 +#define IDC_CPPFLAGS 181 +#define IDC_WARNING 182 +#define IDC_OPTIMIZ 183 +#define IDC_CFLAGS 184 +#define IDC_INCDIRS 185 + +// Linker tab -------------------------------- +#define IDD_LINKER 190 +#define IDC_LDSTRIP 191 +#define IDC_LDOPTS 192 +#define IDC_LDLIBS 193 +#define IDC_LIBDIRS 194 + +#define IDD_ZIP 200 +#define IDC_INFOZIP 201 +#define IDC_TAR_GZIP 202 +#define IDC_TAR_BZ2 203 +#define IDC_ZIP_TEST 204 +#define IDC_ZIP_DIR 205 +#define IDC_ZIPFLAGS 206 +// About ------------------------------------ +#define IDD_ABOUT 210 + +#define IDD_COMMAND 220 +#define IDC_CMDLINE 221 +// Menu ------------------------------------- +#define ID_MENU 1000 +#define IDM_NEW 1001 +#define IDM_OPEN 1002 +//#define IDM_CLOSE 1003 +#define IDM_NEW_PROJECT 1004 +#define IDM_OPEN_PROJECT 1005 +#define IDM_SAVE_PROJECT 1006 +#define IDM_CLOSE_PROJECT 1007 +#define IDM_SAVE 1008 +#define IDM_SAVEAS 1009 +#define IDM_SAVEALL 1010 +#define IDM_PREFERENCES 1011 +#define IDM_PAGESETUP 1012 +#define IDM_PRINT 1013 +#define IDM_QUIT 1014 + +#define IDM_UNDO 1020 +#define IDM_REDO 1021 +#define IDM_CUT 1022 +#define IDM_COPY 1023 +#define IDM_PASTE 1024 +#define IDM_SELECTALL 1025 + +#define IDM_FIND 1030 +#define IDM_REPLACE 1031 +#define IDM_GREP 1032 + +#define IDM_CASCADE 1040 +#define IDM_TILEHORZ 1041 +#define IDM_TILEVERT 1042 +#define IDM_ARRANGE 1043 + +#define IDM_NEW_MODULE 1050 +#define IDM_ADD 1051 +#define IDM_REMOVE_FILE 1052 +#define IDM_REMOVE_MODULE 1053 +#define IDM_OPTION 1054 +#define IDM_ZIP_SRCS 1055 +#define IDM_EXPLORE 1056 + +#define IDM_BUILD 1060 +#define IDM_REBUILDALL 1061 +#define IDM_RUN_TARGET 1062 +#define IDM_MKCLEAN 1063 +#define IDM_MKF_BUILD 1064 +#define IDM_RUN_CMD 1065 + +#define IDM_TEST 1070 + +#define IDM_HELP 1080 +#define IDM_ABOUT 1081 + +#define ID_POPMENU 1100 + +#define ID_FIRSTCHILD 2000 + diff --git a/rosapps/devutils/vmingw/toolbar.bmp b/rosapps/devutils/vmingw/toolbar.bmp new file mode 100644 index 00000000000..17c5497cf7c Binary files /dev/null and b/rosapps/devutils/vmingw/toolbar.bmp differ diff --git a/rosapps/devutils/vmingw/treeview.bmp b/rosapps/devutils/vmingw/treeview.bmp new file mode 100644 index 00000000000..04b147f272f Binary files /dev/null and b/rosapps/devutils/vmingw/treeview.bmp differ diff --git a/rosapps/devutils/vmingw/vmingw.prj b/rosapps/devutils/vmingw/vmingw.prj new file mode 100644 index 00000000000..59188463956 --- /dev/null +++ b/rosapps/devutils/vmingw/vmingw.prj @@ -0,0 +1,91 @@ +[Project] +Signature = 40 +NumFiles = 15 +Compiler = mingw +BuildMakefile = 0 + +[Archives] +Directory = .\zip +Flags = *.prj .\bin\*.dll .\src\*.* .\include\*.h -x *.o + +[Makefile] +MAKE = make +CC = g++ +WRES = windres +TEST = gcc -v +Makefile = makefile +MakefileDir = .\src +Target = visual-mingw.exe +TargetDir = ..\bin +Build = 3 +Debug = 0 +Lang = 1 +CppFlags = -D_WIN32_IE=0x0400 +CcWarning = -W -Wall -pedantic +CcOptimize = -O2 +CcFlags = -fvtable-thunks -fno-rtti +IncDirs = -I ../include +LdStrip = -s +LdOptions = +LdLibraries = -lcomctl32 -lole32 +LdLibDirs = + +[File1] +Name = .\src\ChangeLog +Show = 0 + +[File2] +Name = .\src\CList.cpp +Show = 0 + +[File3] +Name = .\src\CList.h +Show = 0 + +[File4] +Name = .\src\editor.cpp +Show = 0 + +[File5] +Name = .\src\editor.h +Show = 0 + +[File6] +Name = .\src\main.cpp +Show = 0 + +[File7] +Name = .\src\main.h +Show = 0 + +[File8] +Name = .\src\process.cpp +Show = 0 + +[File9] +Name = .\src\process.h +Show = 0 + +[File10] +Name = .\src\project.cpp +Show = 0 + +[File11] +Name = .\src\project.h +Show = 0 + +[File12] +Name = .\src\rsrc.h +Show = 0 + +[File13] +Name = .\src\rsrc.rc +Show = 0 + +[File14] +Name = .\src\winui.cpp +Show = 0 + +[File15] +Name = .\src\winui.h +Show = 0 diff --git a/rosapps/devutils/vmingw/vmingw.rc b/rosapps/devutils/vmingw/vmingw.rc new file mode 100644 index 00000000000..0acb13d92fd --- /dev/null +++ b/rosapps/devutils/vmingw/vmingw.rc @@ -0,0 +1,399 @@ +/******************************************************************** +* Module: rsrc.rc. This is part of Visual-MinGW. +* +* Purpose: Resource file. +* +* Authors: Manu B. +* +* License: Visual-MinGW is covered by GNU General Public License, +* Copyright (C) 2001 Manu B. +* See license.htm for more details. +* +* Revisions: 11/06/01. +* +********************************************************************/ +// For Borland Resource Workshop. (It doesn't like windows.h) +#ifndef WORKSHOP_INVOKED +#include "windows.h" +#endif +#include "rsrc.h" + +ID_MENU MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New" , IDM_NEW + MENUITEM "&Open" , IDM_OPEN + MENUITEM "&Close" , IDM_OPEN, GRAYED + MENUITEM SEPARATOR + MENUITEM "&New Project" , IDM_NEW_PROJECT + MENUITEM "&Open Project" , IDM_OPEN_PROJECT + MENUITEM "&Save Project" , IDM_SAVE_PROJECT + MENUITEM "&Close Project" , IDM_CLOSE_PROJECT + MENUITEM SEPARATOR + MENUITEM "&Save\tCtrl+S" , IDM_SAVE, GRAYED + MENUITEM "Save as" , IDM_SAVEAS, GRAYED + MENUITEM "&Save all" , IDM_SAVEALL + MENUITEM SEPARATOR + MENUITEM "Preferences" , IDM_PREFERENCES + MENUITEM "Page setup" , IDM_PAGESETUP, GRAYED + MENUITEM "&Print" , IDM_PRINT, GRAYED + MENUITEM SEPARATOR + MENUITEM "&Quit" , IDM_QUIT + END + + POPUP "&Edit", GRAYED + BEGIN + MENUITEM "&Undo" , IDM_UNDO + MENUITEM "&Redo" , IDM_REDO + MENUITEM SEPARATOR + MENUITEM "&Cut" , IDM_CUT + MENUITEM "&Copy" , IDM_COPY + MENUITEM "&Paste" , IDM_PASTE + MENUITEM SEPARATOR + MENUITEM "&Select all" , IDM_SELECTALL + END + + POPUP "&Find" + BEGIN + MENUITEM "&Search..." , IDM_FIND, GRAYED + MENUITEM "&Replace" , IDM_REPLACE, GRAYED + MENUITEM "Find in files" , IDM_GREP + END + + POPUP "&Window", GRAYED + BEGIN + MENUITEM "&Cascade" , IDM_CASCADE + MENUITEM "Tile &Horizontal" , IDM_TILEHORZ + MENUITEM "Tile &Vertical" , IDM_TILEVERT + MENUITEM "Arrange &Icons" , IDM_ARRANGE + END + + POPUP "&Project" + BEGIN + MENUITEM "&New Module" , IDM_NEW_MODULE + MENUITEM "&Add files" , IDM_ADD + MENUITEM "&Remove File" , IDM_REMOVE_FILE + MENUITEM "&Remove Module" , IDM_REMOVE_MODULE + MENUITEM "&Options" , IDM_OPTION + MENUITEM "&Create archive" , IDM_ZIP_SRCS + MENUITEM "&Explore" , IDM_EXPLORE + END + + POPUP "&Build" + BEGIN + MENUITEM "&Build" , IDM_BUILD + MENUITEM "&Rebuild All" , IDM_REBUILDALL + MENUITEM "&Run" , IDM_RUN_TARGET + MENUITEM "&Make Clean" , IDM_MKCLEAN + MENUITEM "&Build Makefile" , IDM_MKF_BUILD +#ifdef DEBUG + MENUITEM "&Run command" , IDM_RUN_CMD +#endif + END + +#ifdef DEBUG + POPUP "&Testing" + BEGIN + MENUITEM "a_new_procedure" , IDM_TEST + END +#endif + + POPUP "&?" + BEGIN + MENUITEM "&Help" , IDM_HELP, GRAYED + MENUITEM "&About" , IDM_ABOUT + END +END + +PopupMenu MENU +BEGIN + POPUP "&Editer" + BEGIN + MENUITEM "&Remove" , IDM_REMOVE_MODULE + END +END + +STRINGTABLE DISCARDABLE +BEGIN + IDM_NEW "New" + IDM_OPEN "Open" + IDM_SAVE "Save" + + IDM_CUT "Cut" + IDM_COPY "Copy" + IDM_PASTE "Paste" + + IDM_UNDO "Undo" + IDM_REDO "Redo" + IDM_FIND "Search" + + IDM_PRINT "Print" +END + +IDB_TOOLBAR BITMAP DISCARDABLE "toolbar.bmp" +IDB_TREEVIEW BITMAP DISCARDABLE "treeview.bmp" + +IDD_PREFERENCES DIALOG 0, 0, 283, 197 +STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Program Preferences" +FONT 8, "MS Sans Serif" +BEGIN + PUSHBUTTON "Ok", IDOK, 115, 179, 50, 14 + PUSHBUTTON "Cancel", IDCANCEL, 172, 179, 50, 14 + CONTROL "", IDC_PREF_TABS, "SysTabControl32", 0x0 | WS_CLIPSIBLINGS, 4, 4, 275, 169 + PUSHBUTTON "Apply", IDAPPLY, 229, 179, 50, 14, WS_DISABLED +END + +// "NOT WS_POPUP" is a workaround for windres prior version 2.11.92. +// LCC's weditres doesn't recognize this flag. +IDD_ENVIRON DIALOG 0, 0, 259, 148 +#ifdef __LCC__ +STYLE DS_CONTROL | WS_CHILD +#else +STYLE DS_CONTROL | WS_CHILD | NOT WS_POPUP +#endif +FONT 8, "MS Sans Serif" +BEGIN + GROUPBOX "Path variable", IDC_STATIC, 3, 3, 252, 140 + EDITTEXT IDC_CCBIN, 20, 26, 165, 12, ES_AUTOHSCROLL + AUTOCHECKBOX "Compiler bin directory", IDC_SET_CCBIN, 8, 16, 86, 10 + PUSHBUTTON "Browse", IDC_BROWSE_CC, 197, 25, 45, 14 + EDITTEXT IDC_CMDBIN, 20, 55, 165, 12, ES_AUTOHSCROLL + AUTOCHECKBOX "Default bin directory", IDC_SET_CMDBIN, 8, 45, 86, 10 + PUSHBUTTON "Browse", IDC_BROWSE_CMD, 197, 54, 45, 14 + AUTOCHECKBOX "Use default environment variables", IDC_AUTOEXEC, 8, 75, 125, 10 + EDITTEXT IDC_ENV_VIEW, 8, 88, 242, 49, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY, WS_EX_TRANSPARENT +END + +IDD_FIND DIALOG 0, 0, 236, 92 +STYLE DS_MODALFRAME | WS_VISIBLE | DS_CENTER | DS_3DLOOK | WS_POPUP | WS_CAPTION +CAPTION "Find" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "Fi&nd what:",-1,4,8,42,8 + COMBOBOX IDC_FINDWHAT,47,7,128,50, WS_TABSTOP | CBS_DROPDOWN | CBS_AUTOHSCROLL + AUTOCHECKBOX "Match &whole word only", IDC_WHOLEWORD,4,26,100,10, WS_GROUP | WS_TABSTOP + AUTOCHECKBOX "Match &case", IDC_MATCHCASE,4,38,100,10, WS_GROUP | WS_TABSTOP + AUTOCHECKBOX "Regular &expression", IDC_REGEXP,4,50,100,10, WS_GROUP | WS_TABSTOP + AUTOCHECKBOX "Wrap aroun&d", IDC_WRAP,4,62,100,10, WS_GROUP | WS_TABSTOP + AUTOCHECKBOX "Transform &backslash expressions", IDC_UNSLASH,4,74,150,10, WS_GROUP | WS_TABSTOP + GROUPBOX "Direction",1072,107,26,68,28,WS_GROUP + AUTORADIOBUTTON "&Up",IDC_DIRECTIONUP,111,38,25,12, WS_GROUP + AUTORADIOBUTTON "&Down",IDC_DIRECTIONDOWN,138,38,35,12 + DEFPUSHBUTTON "&Find Next",IDOK,182,5,50,14,WS_GROUP + PUSHBUTTON "Cancel",IDCANCEL,182,23,50,14 +END + +IDD_REPLACE DIALOG 0, 0, 260, 108 +STYLE DS_MODALFRAME | WS_VISIBLE | DS_CENTER | DS_3DLOOK | WS_POPUP | WS_CAPTION +CAPTION "Replace" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "Fi&nd what:",-1,4,9,48,8 + COMBOBOX IDC_FINDWHAT,54,7,114,50,WS_TABSTOP | CBS_DROPDOWN | CBS_AUTOHSCROLL + LTEXT "Re&place with:",-1,4,26,48,8 + COMBOBOX IDC_REPLACEWITH,54,24,114,50,WS_TABSTOP | CBS_DROPDOWN | CBS_AUTOHSCROLL + AUTOCHECKBOX "Match &whole word only", IDC_WHOLEWORD,4,44,100,10, WS_GROUP | WS_TABSTOP + AUTOCHECKBOX "Match &case", IDC_MATCHCASE,4,56,100,10, WS_GROUP | WS_TABSTOP + AUTOCHECKBOX "Regular &expression", IDC_REGEXP,4,68,100,10, WS_GROUP | WS_TABSTOP + AUTOCHECKBOX "Wrap aroun&d", IDC_WRAP,4,80,100,10, WS_GROUP | WS_TABSTOP + AUTOCHECKBOX "Transform &backslash expressions", IDC_UNSLASH,4,92,150,10, WS_GROUP | WS_TABSTOP + DEFPUSHBUTTON "&Find Next",IDOK,174,4,80,14,WS_GROUP + PUSHBUTTON "&Replace",IDC_REPLACE,174,21,80,14 + PUSHBUTTON "Replace &All",IDC_REPLACEALL,174,38,80,14 + PUSHBUTTON "Replace in &Selection",IDC_REPLACEINSEL,174,55,80,14 + PUSHBUTTON "Close",IDCANCEL,174,72,80,14 +END + +IDD_GREP DIALOG 26, 41, 226, 66 +STYLE DS_MODALFRAME | DS_CENTER | DS_3DLOOK | WS_POPUP | WS_CAPTION +CAPTION "Find in Files" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "Fi&nd what:", IDC_STATIC, 5, 8, 35, 8, NOT WS_GROUP + COMBOBOX IDC_FINDWHAT, 40, 7, 120, 50, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_BORDER | WS_TABSTOP + LTEXT "F&iles:", IDC_STATIC, 5, 28, 30, 8, NOT WS_GROUP + COMBOBOX IDC_GFILTER, 40, 27, 120, 50, CBS_DROPDOWN | WS_BORDER | WS_TABSTOP + LTEXT "&Directory:", IDC_STATIC, 5, 48, 30, 8, NOT WS_GROUP + DEFPUSHBUTTON "&Find", IDOK, 168, 6, 50, 14 + PUSHBUTTON "Cancel", IDCANCEL, 168, 26, 50, 14 + COMBOBOX 138, 40, 47, 120, 50, CBS_DROPDOWN | WS_BORDER | WS_TABSTOP + PUSHBUTTON "Browse", IDC_GBROWSE, 168, 46, 50, 14 +END + +IDD_OPTION DIALOGEX 0, 0, 252, 202 +STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Project options" +FONT 8, "MS Sans Serif" +BEGIN + CONTROL "", IDC_OPTION_TABS, "SysTabControl32", 0x8000, 4, 5, 244, 173 + PUSHBUTTON "Ok", IDOK, 79, 184, 50, 14 + PUSHBUTTON "Cancel", IDCANCEL, 141, 184, 50, 14 + PUSHBUTTON "Help", IDC_HELP_BTN, 198, 184, 50, 14 +END + +IDD_GENERAL_PANE DIALOG 0, 0, 230, 139 +#ifdef __LCC__ +STYLE DS_CONTROL | WS_CHILD +#else +STYLE DS_CONTROL | WS_CHILD | NOT WS_POPUP +#endif +FONT 8, "MS Sans Serif" +BEGIN + GROUPBOX "Build what ?", IDC_STATIC, 5, 3, 107, 79 + AUTORADIOBUTTON "Static library", IDC_STATLIB, 12, 15, 59, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "Dll", IDC_DLL, 12, 28, 59, 10 + AUTORADIOBUTTON "Console executable", IDC_CONSOLE, 12, 41, 78, 10 + AUTORADIOBUTTON "GUI executable", IDC_GUIEXE, 12, 54, 65, 10 + AUTOCHECKBOX "Generate debug symbols", IDC_DBGSYM, 12, 67, 97, 10 + GROUPBOX "Language", IDC_STATIC, 5, 86, 107, 46 + AUTORADIOBUTTON "C", IDC_LANGC, 12, 101, 25, 10, WS_GROUP | WS_TABSTOP + AUTORADIOBUTTON "C++", IDC_LANGCPP, 12, 114, 29, 10 + GROUPBOX "Makefile", IDC_STATIC, 120, 3, 104, 67 + LTEXT "Name", IDC_STATIC, 124, 18, 23, 9 + EDITTEXT IDC_MKF_NAME, 156, 16, 61, 12, ES_AUTOHSCROLL + LTEXT "Directory", IDC_STATIC, 124, 35, 30, 9 + EDITTEXT IDC_MKF_DIR, 156, 33, 61, 12, ES_AUTOHSCROLL + AUTOCHECKBOX "User makefile", IDC_USER_MKF, 125, 52, 62, 10, WS_DISABLED + GROUPBOX "Output file", IDC_STATIC, 120, 76, 104, 56 + LTEXT "Name", IDC_STATIC, 124, 95, 23, 9 + EDITTEXT IDC_TGT_NAME, 156, 93, 61, 12, ES_AUTOHSCROLL + LTEXT "Directory", 133, 123, 112, 30, 9 + EDITTEXT IDC_TGT_DIR, 156, 110, 61, 12, ES_AUTOHSCROLL +END + +IDD_COMPILER DIALOG 0, 0, 230, 139 +#ifdef __LCC__ +STYLE DS_CONTROL | WS_CHILD +#else +STYLE DS_CONTROL | WS_CHILD | NOT WS_POPUP +#endif +FONT 8, "MS Sans Serif" +BEGIN + GROUPBOX "Compiler options", IDC_STATIC, 17, 11, 194, 111 + LTEXT "Preprocessor", IDC_STATIC, 22, 25, 46, 9 + EDITTEXT IDC_CPPFLAGS, 67, 24, 138, 12, ES_AUTOHSCROLL + LTEXT "Warning", IDC_STATIC, 22, 42, 31, 9 + EDITTEXT IDC_WARNING, 67, 40, 138, 12, ES_AUTOHSCROLL + LTEXT "Optimization", IDC_STATIC, 22, 58, 42, 9 + EDITTEXT IDC_OPTIMIZ, 67, 56, 138, 12, ES_AUTOHSCROLL + LTEXT "C/C++", IDC_STATIC, 23, 73, 24, 9 + EDITTEXT IDC_CFLAGS, 67, 72, 138, 12, ES_AUTOHSCROLL + LTEXT "Include directories", IDC_STATIC, 22, 92, 61, 9 + EDITTEXT IDC_INCDIRS, 22, 101, 183, 12, ES_AUTOHSCROLL +END + +IDD_LINKER DIALOG 0, 0, 230, 139 +#ifdef __LCC__ +STYLE DS_CONTROL | WS_CHILD +#else +STYLE DS_CONTROL | WS_CHILD | NOT WS_POPUP +#endif +FONT 8, "MS Sans Serif" +BEGIN + GROUPBOX "Linker", IDC_STATIC, 17, 16, 194, 103 + LTEXT "Strip", IDC_STATIC, 23, 37, 18, 9 + EDITTEXT IDC_LDSTRIP, 53, 36, 53, 12, ES_AUTOHSCROLL + LTEXT "Options", IDC_STATIC, 23, 53, 29, 9 + EDITTEXT IDC_LDOPTS, 53, 52, 151, 12, ES_AUTOHSCROLL + LTEXT "Libraries", IDC_STATIC, 23, 69, 34, 9 + EDITTEXT IDC_LDLIBS, 53, 68, 151, 12, ES_AUTOHSCROLL + LTEXT "Library directories", IDC_STATIC, 23, 88, 61, 9 + EDITTEXT IDC_LIBDIRS, 22, 98, 182, 12, ES_AUTOHSCROLL +END + +IDD_ZIP DIALOG 0, 0, 230, 139 +#ifdef __LCC__ +STYLE DS_CONTROL | WS_CHILD +#else +STYLE DS_CONTROL | WS_CHILD | NOT WS_POPUP +#endif +FONT 8, "MS Sans Serif" +BEGIN + GROUPBOX "Archiver", 304, 15, 7, 87, 58 + AUTORADIOBUTTON "Info-ZIP", IDC_INFOZIP, 20, 17, 39, 10, WS_GROUP + AUTORADIOBUTTON "Tar/Gzip", IDC_TAR_GZIP, 20, 32, 46, 10, WS_DISABLED + AUTORADIOBUTTON "Tar/Bz2", IDC_TAR_BZ2, 20, 47, 44, 10, WS_DISABLED + GROUPBOX "Output File", IDC_STATIC, 15, 71, 195, 56 + LTEXT "Directory", IDC_STATIC, 21, 86, 30, 9 + EDITTEXT IDC_ZIP_DIR, 56, 84, 61, 12, ES_AUTOHSCROLL + LTEXT "Options", IDC_STATIC, 21, 109, 29, 9 + EDITTEXT IDC_ZIPFLAGS, 51, 108, 151, 12, ES_AUTOHSCROLL + GROUPBOX "Date format", 207, 112, 7, 97, 58 + AUTORADIOBUTTON "mmddyyyy", 208, 117, 17, 53, 10 + AUTORADIOBUTTON "ddmmyyyy", 209, 117, 32, 49, 10, WS_DISABLED + AUTORADIOBUTTON "yyyymmdd", 211, 117, 47, 50, 10, WS_DISABLED +END + +IDD_NEW_MODULE DIALOG 226, 122, 142, 39 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "New module" +FONT 8, "MS Sans Serif" +BEGIN + EDITTEXT 301, 6, 4, 84, 12, ES_AUTOHSCROLL + AUTOCHECKBOX "Create header", IDC_HEADER, 21, 22, 58, 10 + PUSHBUTTON "Ok", IDOK, 97, 3, 40, 14 + PUSHBUTTON "Cancel", IDCANCEL, 97, 22, 40, 14 +END + +IDD_ABOUT DIALOG 14, 26, 200, 78 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "About this software..." +FONT 8, "MS Sans Serif" +BEGIN + DEFPUSHBUTTON "&OK", IDOK, 140, 18, 50, 14, BS_DEFPUSHBUTTON | WS_GROUP | WS_TABSTOP + ICON 500, IDC_STATIC, 16, 24, 18, 20, WS_GROUP + GROUPBOX "Informations", IDC_STATIC, 4, 3, 192, 70 + LTEXT "Version 0.42a", IDC_STATIC, 57, 15, 67, 52 +END + +IDD_COMMAND DIALOG 0, 0, 216, 45 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog Title" +FONT 8, "MS Sans Serif" +BEGIN + LTEXT "Command line", IDC_STATIC, 5, 8, 48, 9 + EDITTEXT IDC_CMDLINE, 59, 7, 148, 12, ES_AUTOHSCROLL + PUSHBUTTON "Enter", IDOK, 157, 25, 50, 14 +END + +ACCELS ACCELERATORS +BEGIN + "S", IDM_SAVE, VIRTKEY, CONTROL +END + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 0,43,0,0 + PRODUCTVERSION 0,43,0,0 + FILEFLAGSMASK 0x3fL +#ifdef DEBUG + FILEFLAGS VS_FF_PRERELEASE +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "04090000" + BEGIN + VALUE "CompanyName", "Visual-MinGW project\0" + VALUE "FileDescription", "Visual-MinGW\0" + VALUE "FileVersion", FULL_APP_VERSION + VALUE "InternalName", "visual-mingw\0" + VALUE "LegalCopyright", "Copyright (C) 2001 Manu B\0" + VALUE "OriginalFilename", "visual-mingw.exe\0" + VALUE "ProductName", "Visual-MinGW\0" + VALUE "ProductVersion", FULL_APP_VERSION + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 0 + END +END + diff --git a/rosapps/devutils/vmingw/winui.cpp b/rosapps/devutils/vmingw/winui.cpp new file mode 100644 index 00000000000..9b36390ab2a --- /dev/null +++ b/rosapps/devutils/vmingw/winui.cpp @@ -0,0 +1,2117 @@ +/******************************************************************** +* Module: winui.cpp. This is part of WinUI. +* +* Purpose: WinUI main module. Contains procedures relative to User Interface +* and general purpose procedures. +* +* Authors: Manu B. +* +* License: WinUI is covered by GNU General Public License, +* Copyright (C) 2001 Manu B. +* See license.htm for more details. +* +* Revisions: +* Manu B. 11/19/01 OpenDlg & SaveDlg enhancement. +* Manu B. 12/07/01 CIniFile created. +* Manu B. 12/15/01 CWinApp created. +* +********************************************************************/ +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include "winui.h" + +// Callback procedures. +LRESULT CALLBACK MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); +LRESULT CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam); + +// Declare a CMessageBox instance to use anywhere in the whole app. +CMessageBox MsgBox; + + +/******************************************************************** +* Function: char *StpCpy(char *dest, const char *src). +* +* Purpose: stpcpy clone. +* +* Revisions: +* +********************************************************************/ +char *StpCpy(char *dest, const char *src){ + while (*src != '\0'){ + *dest = *src; + src++; + dest++; + } +return dest; +} + +size_t strcpylen(char *dest, const char *src){ + char * start = dest; + while (*src != '\0'){ + *dest = *src; + dest++; + src++; + } + *dest = '\0'; +return (dest-start); +} + + +/******************************************************************** +* Class: CChrono. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CChrono::CChrono(){ + _time = 0; +} + +CChrono::~CChrono(){ +} + +void CChrono::Start(void){ + _time = ::GetTickCount(); +} + +DWORD CChrono::Stop(void){ + DWORD diff = ::GetTickCount() - _time; + _time = 0; +return diff; +} + + +/******************************************************************** +* Class: Base Window class. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CWindow::CWindow(){ + _pParent = NULL; + _hInst = 0; + _hWnd = 0; + _lParam = NULL; +} + +CWindow::~CWindow(){ +} + +HWND CWindow::CreateEx( + CWindow * pWindow, + DWORD dwExStyle, + LPCTSTR lpClassName, + LPCTSTR lpWindowName, + DWORD dwStyle, + int x, int y, int nWidth, int nHeight, + HMENU hMenu, + LPVOID lpParam){ + + // Store a pointer to parent class and to lpParam. + _pParent = pWindow; + _lParam = lpParam; + + // Get parent class handles. + HWND hParent; + HINSTANCE hInst; + + if(_pParent){ + // Have a parent window. + hParent = _pParent->_hWnd; + hInst = _pParent->_hInst; + }else{ + // Parent window is desktop. + hParent = 0; + hInst = GetModuleHandle(NULL); + } + + _hWnd = CreateWindowEx( + dwExStyle, + lpClassName, + lpWindowName, + dwStyle, + x, + y, + nWidth, + nHeight, + hParent, + (HMENU) hMenu, + hInst, + this); // Retrieve lpParam using this->_lParam. + +return _hWnd; +} + +HWND CWindow::GetId(void){ +return _hWnd; +} + +LONG CWindow::SetLong(int nIndex, LONG dwNewLong){ +return ::SetWindowLong(_hWnd, nIndex, dwNewLong); +} + +LONG CWindow::GetLong(int nIndex){ +return ::GetWindowLong(_hWnd, nIndex); +} + +LRESULT CWindow::SendMessage(UINT Msg, WPARAM wParam, LPARAM lParam){ +return ::SendMessage(_hWnd, Msg, wParam, lParam); +} + +bool CWindow::SetPosition(HWND hInsertAfter, int x, int y, int width, int height, UINT uFlags){ +return ::SetWindowPos(_hWnd, hInsertAfter, x, y, width, height, uFlags); +} + +bool CWindow::Show(int nCmdShow){ +return ::ShowWindow(_hWnd, nCmdShow); +} + +bool CWindow::Hide(void){ +return ::ShowWindow(_hWnd, SW_HIDE); +} + +HWND CWindow::SetFocus(void){ +return ::SetFocus(_hWnd); +} + +/******************************************************************** +* Class: CWinBase. +* +* Purpose: Base Application class. +* +* Revisions: +* +********************************************************************/ +CWinBase::CWinBase(){ + hPrevInst = 0; + lpCmdLine = NULL; + nCmdShow = SW_SHOW; + + isWinNT = false; + strcpy( appName, "CWinBase"); +} + +CWinBase::~CWinBase(){ +} + +bool CWinBase::Init(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, + int nCmdShow){ + _hInst = hInstance; + hPrevInst = hPrevInstance; + lpCmdLine = lpCmdLine; + nCmdShow = nCmdShow; +return true; +} + +bool CWinBase::SetName(char * name, char * version){ + strcpy(appName, name); + strcat(appName, " "); + + if(version) + strcat(appName, version); +return true; +} + +bool CWinBase::IsWinNT(void){ + + OSVERSIONINFO osv = {sizeof(OSVERSIONINFO), 0, 0, 0, 0, ""}; + GetVersionEx(&osv); + + isWinNT = (osv.dwPlatformId == VER_PLATFORM_WIN32_NT); +return isWinNT; +} + +void CWinBase::ParseCmdLine(char * outBuff){ + int len = 0; + outBuff[len] = '\0'; + + LPTSTR cmdLine = GetCommandLine(); + + while (*cmdLine){ + if (*cmdLine == '\"'){ + cmdLine++; + while (*cmdLine && *cmdLine != '\"'){ + outBuff[len] = *cmdLine; + len++; + cmdLine++; + } + break; + }else{ + while (*cmdLine && *cmdLine != ' '){ + outBuff[len] = *cmdLine; + len++; + cmdLine++; + } + break; + } + } + outBuff[len] = '\0'; + SplitFileName(outBuff, 0); +return; +} + + +/******************************************************************** +* Class: CSDIBase. +* +* Purpose: Base SDI class. +* +* Revisions: +* +********************************************************************/ +CSDIBase::CSDIBase(){ +mainClass[0] = 0; +hAccel = NULL; +} + +CSDIBase::~CSDIBase(){ +} + +int CSDIBase::Run(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, + int nCmdShow){ + Init(hInstance, hPrevInstance, lpCmdLine, nCmdShow); + if (!CustomInit()){ + Release(); + return 1; + } + + MSG Msg; + if (CreateUI()){ + while(GetMessage(&Msg, NULL, 0, 0)){ + if (!TranslateAccelerator(_hWnd, hAccel, &Msg)){ + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + } + }else{ + MsgBox.DisplayFatal("CreateUI() failed !"); + } + + Release(); +return Msg.wParam; +} + +bool CSDIBase::CustomInit(void){ +return true; +} + +bool CSDIBase::Release(void){ +return true; +} + +bool CSDIBase::CreateUI(void){ +return false; +} + +bool CSDIBase::MainRegisterEx(const char * className){ + strcpy(mainClass, className); + + // Default values. + wc.cbSize = sizeof(WNDCLASSEX); + wc.lpfnWndProc = MainWndProc; + wc.hInstance = _hInst; + wc.lpszClassName = mainClass; + wc.cbClsExtra = 0; + wc.cbWndExtra = sizeof(CSDIBase *); +return RegisterClassEx(&wc); +} + +LRESULT CALLBACK CSDIBase::CMainWndProc(UINT Message, WPARAM wParam, LPARAM lParam){ + + switch (Message){ + case WM_DESTROY: + PostQuitMessage (0); + return 0; + } + +return DefWindowProc(_hWnd, Message, wParam, lParam); +} + +/******************************************************************** +* Callback procedure. +********************************************************************/ +LRESULT CALLBACK MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam){ + // Get a pointer to the CWindow class that owns this window. + CSDIBase * pSdiBase = (CSDIBase *) (GetWindowLong(hwnd, 0)); + + if (pSdiBase == 0){ // The pointer isn't set yet. + if (Message == WM_NCCREATE){ + // First, get the CSDIBase pointer. + pSdiBase = (CSDIBase *) ((CREATESTRUCT *)lParam)->lpCreateParams; + + // Attach pSdiBase and lParam to the window. + SetWindowLong(hwnd, 0, (LONG)(pSdiBase)); + SetWindowLong(hwnd, GWL_USERDATA, (LONG) pSdiBase->_lParam); + + // Store window handle. + pSdiBase->_hWnd = hwnd; + + // Let Windows continue the job. + return pSdiBase->CMainWndProc(Message, wParam, lParam); + }else{ + return DefWindowProc(hwnd, Message, wParam, lParam); + } + } +return pSdiBase->CMainWndProc(Message, wParam, lParam); +} + + +/******************************************************************** +* Class: CMDIBase. +* +* Purpose: Base MDI class. +* +* Revisions: +* +********************************************************************/ +CMDIBase::CMDIBase(){ +} + +CMDIBase::~CMDIBase(){ +} + +bool CMDIBase::ChildRegisterEx(const char * className){ + strcpy(MdiClient.childClass, className); + + // Default values. + wc.cbSize = sizeof(WNDCLASSEX); + wc.lpfnWndProc = ChildWndProc; + wc.hInstance = _hInst; + wc.lpszClassName = className; + wc.cbClsExtra = 0; + wc.cbWndExtra = 8;//sizeof(CMDIBase *); +return RegisterClassEx(&wc); +} + +int CMDIBase::Run(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, + int nCmdShow){ + Init(hInstance, hPrevInstance, lpCmdLine, nCmdShow); + if (!CustomInit()){ + Release(); + return 1; + } + + MSG Msg; + if (CreateUI()){ + while(GetMessage(&Msg, NULL, 0, 0)){ + if (!TranslateAccelerator(_hWnd, hAccel, &Msg)){ + if (!TranslateMDISysAccel(MdiClient.GetId(), &Msg)){ + TranslateMessage(&Msg); + DispatchMessage(&Msg); + } + } + } + }else{ + MsgBox.DisplayFatal("CreateUI() failed !"); + } + + Release(); +return Msg.wParam; +} + +bool CMDIBase::CustomInit(void){ +return true; +} + +bool CMDIBase::Release(void){ +return true; +} + +bool CMDIBase::CreateUI(void){ +return false; +} + +LRESULT CALLBACK CMDIBase::CMainWndProc(UINT, WPARAM, LPARAM){ +return 0; +} + +LRESULT CALLBACK CMDIBase::CChildWndProc(CWindow *, UINT, WPARAM, LPARAM){ +return 0; +} + +/******************************************************************** +* Child window callback procedure. +********************************************************************/ +LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam){ + // Get a pointer to the CWindow class that owns this window. + CMDIChild * pMdiChild = (CMDIChild *) (GetWindowLong(hwnd, 0)); + + if (pMdiChild == 0){ // The pointer isn't set yet. + if (Message == WM_NCCREATE){ + // First, get the CMDIChild pointer. + pMdiChild = (CMDIChild *) ((MDICREATESTRUCT *) ((CREATESTRUCT *)lParam)->lpCreateParams)->lParam; + + // Attach pMdiChild and lParam to the window. + //MsgBox.DisplayLong((long) pMdiChild); + + SetWindowLong(hwnd, 0, (long)(pMdiChild)); + SetWindowLong(hwnd, GWL_USERDATA, (long) pMdiChild->_lParam); + + // Store window handle. + pMdiChild->_hWnd = hwnd; + + // Attach to a childList so that the list can destroy all MdiChild objects. + ((CMDIClient *) pMdiChild->_pParent)->childList.InsertFirst(pMdiChild); + + // Let Windows continue the job. + return pMdiChild->_pFrame->CChildWndProc(pMdiChild, Message, wParam, lParam); + }else{ + return DefWindowProc(hwnd, Message, wParam, lParam); + } + + // Free pMdiChild object. + }else if (Message == WM_NCDESTROY){ + ((CMDIClient *) pMdiChild->_pParent)->childList.Destroy(pMdiChild); + } +return pMdiChild->_pFrame->CChildWndProc(pMdiChild, Message, wParam, lParam); +} + + +/******************************************************************** +* Class: CMDIClient. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CMDIClient::CMDIClient(){ + initialized = false; + childClass[0] = 0; +} + +CMDIClient::~CMDIClient(){ +} + +void CMDIClient::Init(int menuIndex, UINT idFirstChild){ + nPos = menuIndex; + + // ID of first created child. + ccs.idFirstChild = idFirstChild; + initialized = true; +} + +HWND CMDIClient::CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle, UINT resId){ + + if (!pWindow || !initialized) + return 0; + + // Store a pointer to parent class. + _pParent = pWindow; + + // Get parent class handles. + _hInst = _pParent->_hInst; + + // Get our "Window menu" handle. + ccs.hWindowMenu = GetSubMenu(GetMenu(_pParent->_hWnd), nPos); + + _hWnd = CreateWindowEx( + dwExStyle, + "mdiclient", + NULL, + dwStyle, + 0, + 0, + 100, + 100, + _pParent->_hWnd, + (HMENU) resId, + _hInst, + (LPVOID) &ccs); + +return _hWnd; +} + +LPARAM CMDIClient::GetParam(LPARAM lParam){ + MDICREATESTRUCT *mcs = (MDICREATESTRUCT *) ((CREATESTRUCT *) lParam)->lpCreateParams; +return mcs->lParam; +} + + +/******************************************************************** +* Class: CMDIChild. +* +* Purpose: Base Windows Class. +* +* Revisions: +* +********************************************************************/ +CMDIChild::CMDIChild(){ + _pFrame = NULL; +} + +CMDIChild::~CMDIChild(){ +} + +HWND CMDIChild::CreateEx(CMDIClient * pMdiClient, DWORD dwExStyle, DWORD dwStyle, char * caption, UINT resId, LPVOID lParam){ + + if (!pMdiClient || !pMdiClient->initialized) + return 0; + + // Store pointers, lParam and _hInst. + _pParent = pMdiClient; + _pFrame = (CMDIBase *) pMdiClient->_pParent; // Owner of CChildWndProc. + _lParam = lParam; + _hInst = _pParent->_hInst; + + HWND hwnd = CreateWindowEx( + dwExStyle, + pMdiClient->childClass, + caption, + dwStyle, + 0, + 0, + 100, + 100, + _pParent->_hWnd, + (HMENU) resId, + _hInst, + this); + +return hwnd; +} + + +/******************************************************************** +* Class: CDlgBase. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CDlgBase::CDlgBase(){ +} + +CDlgBase::~CDlgBase(){ +} + +HWND CDlgBase::Create(CWindow * pWindow, WORD wResId, RECT * Pos, LPARAM lParam){ + HWND hwnd = 0; + if (pWindow){ + hwnd = CreateParam(pWindow, wResId, lParam); + if (Pos) + SetPosition(0, Pos->left, Pos->top, Pos->right, Pos->bottom, 0); + } +return hwnd; +} + +int CDlgBase::CreateModal(CWindow * pWindow, WORD wResId, LPARAM lParam){ + if (pWindow == NULL) + return 0; + + // Don't create a modal dialog if a modeless one already exists. + else if (_hWnd != 0) + return 0; + + // Store a pointer to parent class. + _pParent = pWindow; + _lParam = (LPVOID) lParam; + + // Get parent class handles. + _hInst = _pParent->_hInst; + +return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(wResId), _pParent->_hWnd, + (DLGPROC) DlgProc, (long) this); +} + +HWND CDlgBase::CreateParam(CWindow * pWindow, WORD wResId, LPARAM lParam){ + if (pWindow == NULL) + return 0; + // Don't create a dialog twice. + else if (_hWnd != 0) + return _hWnd; + + // Store a pointer to parent class. + _pParent = pWindow; + _lParam = (LPVOID) lParam; + + // Get parent class handles. + _hInst = _pParent->_hInst; + + HWND hwnd = CreateDialogParam(_hInst, + MAKEINTRESOURCE(wResId), + _pParent->_hWnd, + (DLGPROC) DlgProc, + (long) this); +return hwnd; +} + +BOOL CDlgBase::EndDlg(int nResult){ + if (_hWnd){ + BOOL result = ::EndDialog(_hWnd, nResult); + _hWnd = 0; + return result; + } +return false; +} + +HWND CDlgBase::GetItem(int nIDDlgItem){ +return ::GetDlgItem(_hWnd, nIDDlgItem); +} + +BOOL CDlgBase::SetItemText(HWND hItem, LPCTSTR lpString){ +return ::SendMessage(hItem, WM_SETTEXT, 0, (long)lpString); +} + +UINT CDlgBase::GetItemText(HWND hItem, LPTSTR lpString, int nMaxCount){ +return ::SendMessage(hItem, WM_GETTEXT, nMaxCount, (long)lpString); +} + +LRESULT CALLBACK CDlgBase::CDlgProc(UINT Message, WPARAM, LPARAM){ + + switch(Message){ + case WM_INITDIALOG: + return TRUE; + + case WM_CLOSE: + EndDlg(0); + break; + } +return FALSE; +} + + +/******************************************************************** +* Class: CTabbedDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CTabbedDlg::CTabbedDlg(){ + _hWndTab = 0; + Pos.left = 0; + Pos.top = 0; + Pos.right = 100; + Pos.bottom = 100; +} + +CTabbedDlg::~CTabbedDlg(){ +} + +bool CTabbedDlg::SetChildPosition(HWND hChild){ + if (!_hWndTab) + return false; + // Get tab's display area. + RECT area; + ::GetWindowRect(_hWndTab, &area); + ::ScreenToClient(_hWnd, (POINT *) &area.left); + ::ScreenToClient(_hWnd, (POINT *) &area.right); + ::SendMessage(_hWndTab, TCM_ADJUSTRECT, FALSE, (LPARAM) &area); + ::CopyRect(&Pos, &area); + + // Get child dialog's rect. + RECT child; + ::GetWindowRect(hChild, &child); + ::ScreenToClient(_hWnd, (POINT *) &child.left); + ::ScreenToClient(_hWnd, (POINT *) &child.right); + + // Center child dialog. + int childWidth = child.right-child.left; + int childHeight = child.bottom-child.top; + int hMargin = ((area.right-area.left)-childWidth)/2; + int vMargin = ((area.bottom-area.top)-childHeight)/2; + Pos.left += hMargin; + Pos.top += vMargin; + Pos.right = childWidth; + Pos.bottom = childHeight; + +return ::SetWindowPos(hChild, 0, Pos.left, Pos.top, Pos.right, Pos.bottom, 0); +} + +void CTabbedDlg::OnNotify(int, LPNMHDR notify){ + // Dispatch tab control messages. + switch (notify->code){ + case TCN_SELCHANGING: + OnSelChanging(notify); + break; + + case TCN_SELCHANGE: + OnSelChange(notify); + break; + } +} + +void CTabbedDlg::OnSelChanging(LPNMHDR notify){ + // Hide child dialog that is deselected. + if (notify->hwndFrom == _hWndTab){ + CWindow * pPaneDlg = (CWindow *) GetParam(); + if (pPaneDlg){ + if (pPaneDlg->_hWnd) + pPaneDlg->Hide(); + } + } +} + +void CTabbedDlg::OnSelChange(LPNMHDR notify){ + // Show child dialog that is selected. + if (notify->hwndFrom == _hWndTab){ + CWindow * pPaneDlg = (CWindow *) GetParam(); + if (pPaneDlg){ + if (pPaneDlg->_hWnd) + pPaneDlg->Show(); + pPaneDlg->SetFocus(); + } + } +} + +LPARAM CTabbedDlg::GetParam(void){ + if (!_hWndTab) + return false; + int iItem = ::SendMessage(_hWndTab, TCM_GETCURSEL, 0, 0); + + tcitem.mask = TCIF_PARAM; + BOOL result = ::SendMessage(_hWndTab, TCM_GETITEM, iItem, (long) &tcitem); + if (result) + return tcitem.lParam; +return 0; +} + + +/******************************************************************** +* Callback procedure. +********************************************************************/ +LRESULT CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam){ + // Get a pointer to the CWindow class that owns this window. + CDlgBase * pDlgBase = (CDlgBase *) (GetWindowLong(hwnd, DWL_USER)); + + if (pDlgBase == 0){ // The pointer isn't set yet. + if (Message == WM_INITDIALOG){ + // First, get the CDlgBase pointer. + pDlgBase = (CDlgBase *) lParam; + + // Attach pDlgBase and lParam to the window. + SetWindowLong(hwnd, DWL_USER, (LONG) pDlgBase); + SetWindowLong(hwnd, GWL_USERDATA, (LONG) pDlgBase->_lParam); + + // Store window handle. + pDlgBase->_hWnd = hwnd; + + // Let Windows continue the job. + return pDlgBase->CDlgProc(Message, wParam, (LONG) pDlgBase->_lParam); + }else{ + return FALSE; + } + } +return pDlgBase->CDlgProc(Message, wParam, lParam); +} + + +/******************************************************************** +* Class: CToolBar. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CToolBar::CToolBar(){ +} + +CToolBar::~CToolBar(){ +} + +HWND CToolBar::CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle, UINT resId){ + + if (!pWindow) + return 0; + + // Store a pointer to parent class. + _pParent = pWindow; + + // Get parent class handles. + _hInst = _pParent->_hInst; + + _hWnd = CreateWindowEx( + dwExStyle, + TOOLBARCLASSNAME, + NULL, + dwStyle, + 0, + 0, + 100, + 100, + _pParent->_hWnd, + (HMENU) resId, + _hInst, + NULL); + + if(_hWnd) + // For backward compatibility. + ::SendMessage(_hWnd, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0); +return _hWnd; +} + +LRESULT CToolBar::AddBitmap(UINT resId, int nBmp, HINSTANCE hInstance){ + if (!_hWnd) + return -1; + + // Add the bitmap containing button images to the toolbar. + TBADDBITMAP tbab; + if (hInstance == HINST_COMMCTRL) + tbab.hInst = hInstance; + else + tbab.hInst = _hInst; + tbab.nID = resId; +return ::SendMessage(_hWnd, TB_ADDBITMAP, (WPARAM) nBmp, (WPARAM) &tbab); +} + +BOOL CToolBar::AddButtons(TBBUTTON * tbButtons, UINT numButtons){ + if (!_hWnd) + return FALSE; + + // Add the buttons to the toolbar. +return ::SendMessage(_hWnd, TB_ADDBUTTONS, (WPARAM) numButtons, (LPARAM) tbButtons); +} + + +/******************************************************************** +* Class: CStatusBar. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CStatusBar::CStatusBar(){ + numParts = 0; +} + +CStatusBar::~CStatusBar(){ +} + +HWND CStatusBar::CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle, UINT resId){ + + if (!pWindow) + return 0; + + // Store a pointer to parent class. + _pParent = pWindow; + + // Get parent class handles. + _hInst = _pParent->_hInst; + + _hWnd = CreateWindowEx( + dwExStyle, + STATUSCLASSNAME, + NULL, + dwStyle, + 0, + 0, + 100, + 100, + _pParent->_hWnd, + (HMENU) resId, + _hInst, + NULL); + +return _hWnd; +} + +void CStatusBar::SetParts(int nParts, int * aWidths){ + numParts = nParts; + ::SendMessage(_hWnd, SB_SETPARTS, nParts, (LPARAM) aWidths); +} + +void CStatusBar::WriteString(char * string, int part){ + if (part <= numParts) + ::SendMessage(_hWnd, SB_SETTEXT, part, (LPARAM) string); +} + +void CStatusBar::WriteLong(long number, int part){ + char longbuf[10]; + itoa (number, longbuf, 10); + WriteString(longbuf, part); +} + + +/******************************************************************** +* Class: CTabCtrl. +* +* Purpose: Tab control. +* +* Revisions: +* +********************************************************************/ +CTabCtrl::CTabCtrl(){ +} + +CTabCtrl::~CTabCtrl(){ +} + +HWND CTabCtrl::CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle, UINT resId, LPVOID lpParam){ + + if (!pWindow) + return 0; + + // TODO also use lpParam for each control ? + // Store a pointer to parent class and to lpParam. + _pParent = pWindow; + _lParam = lpParam; + + // Get parent class handles. + _hInst = _pParent->_hInst; + + _hWnd = CreateWindowEx( + dwExStyle, + WC_TABCONTROL, + NULL, + dwStyle, + 0, + 0, + 100, + 100, + _pParent->_hWnd, + (HMENU) resId, + _hInst, + lpParam); + +return _hWnd; +} + +int CTabCtrl::InsertItem(int iItem, UINT mask, DWORD dwState, DWORD dwStateMask, + LPTSTR pszText, int cchTextMax, int iImage, LPARAM lParam){ + + tcitem.mask = mask; + + #if (_WIN32_IE >= 0x0300) + tcitem.dwState = dwState; + tcitem.dwStateMask = dwStateMask; + #else + tcitem.lpReserved1 = 0; + tcitem.lpReserved2 = 0; + #endif + + tcitem.pszText = pszText; + tcitem.cchTextMax = cchTextMax; + tcitem.iImage = iImage; + tcitem.lParam = lParam; + +return ::SendMessage(_hWnd, TCM_INSERTITEM, iItem, (long) &tcitem); +} + +BOOL CTabCtrl::SetItem_Param(int iItem, LPARAM lParam){ + + tcitem.mask = TCIF_PARAM; + tcitem.lParam = lParam; + +return ::SendMessage(_hWnd, TCM_SETITEM, iItem, (long) &tcitem); +} + +int CTabCtrl::GetCurSel(void){ + +return ::SendMessage(_hWnd, TCM_GETCURSEL, 0, 0); +} + +LPARAM CTabCtrl::GetItem_Param(int iItem){ + + tcitem.mask = TCIF_PARAM; + BOOL result = ::SendMessage(_hWnd, TCM_GETITEM, iItem, (long) &tcitem); + if (result) + return tcitem.lParam; +return 0; +} + + +/******************************************************************** +* Class: CTreeView. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CTreeView::CTreeView(){ +} + +CTreeView::~CTreeView(){ +} + +HWND CTreeView::CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle, UINT resId, LPVOID lpParam){ + + if (!pWindow) + return 0; + + // Store a pointer to parent class. + _pParent = pWindow; + + // Get parent class handles. + _hInst = _pParent->_hInst; + + _hWnd = CreateWindowEx( + dwExStyle, + WC_TREEVIEW, + NULL, + dwStyle, + 0, + 0, + 100, + 100, + _pParent->_hWnd, + (HMENU) resId, + _hInst, + lpParam); + +return _hWnd; +} + +HTREEITEM CTreeView::CreateItem(HTREEITEM hParent, HTREEITEM hInsertAfter, int iImage, LPTSTR pszText, LPARAM lParam){ + + tvi.hParent = hParent; + tvi.hInsertAfter = hInsertAfter; + + tvi.item.mask = TVIF_STATE | TVIF_TEXT | TVIF_IMAGE + | TVIF_SELECTEDIMAGE | TVIF_PARAM ; + tvi.item.stateMask = TVIS_EXPANDED; + tvi.item.state = TVIS_EXPANDED; + tvi.item.pszText = pszText; + tvi.item.iImage = iImage; + tvi.item.iSelectedImage = iImage; + tvi.item.lParam = (LPARAM) lParam; + +return (HTREEITEM) ::SendMessage(_hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvi); +} + +LPARAM CTreeView::GetSelectedItemParam(void){ + _TvItem.hItem = TreeView_GetSelection(_hWnd); + _TvItem.mask = TVIF_PARAM; + _TvItem.lParam = 0; + TreeView_GetItem(_hWnd, (long) &_TvItem); +return _TvItem.lParam; +} + +/******************************************************************** +* Class: CListView. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CListView::CListView(){ + lastRow = 0; +} + +CListView::~CListView(){ +} + +HWND CListView::CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle, UINT resId){ + + if (!pWindow) + return 0; + + // Store a pointer to parent class. + _pParent = pWindow; + + // Get parent class handles. + _hInst = _pParent->_hInst; + + _hWnd = CreateWindowEx( + dwExStyle, + WC_LISTVIEW, + NULL, + dwStyle, + 0, + 0, + 100, + 100, + _pParent->_hWnd, + (HMENU) resId, + _hInst, + NULL); + +return _hWnd; +} + +void CListView::Clear(void){ + // Win9x ListView clear is too slow. + int numitems = ::SendMessage(_hWnd, LVM_GETITEMCOUNT, 0, 0); + for (int n = 0; n < numitems; n++){ + ::SendMessage(_hWnd, LVM_DELETEITEM, (WPARAM) 0, 0); + } + lastRow = 0; +} + + +/******************************************************************** +* Class: CScintilla. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CScintilla::CScintilla(){ +} + +CScintilla::~CScintilla(){ +} + +HWND CScintilla::CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle, UINT resId, LPVOID lpParam){ + + if (!pWindow) + return 0; + + // Store a pointer to parent class. + _pParent = pWindow; + + // Get parent class handles. + _hInst = _pParent->_hInst; + + _hWnd = CreateWindowEx( + dwExStyle, + "Scintilla", + NULL, + dwStyle, + 0, + 0, + 100, + 100, + _pParent->_hWnd, + (HMENU) resId, + _hInst, + lpParam); + +return _hWnd; +} + + +/******************************************************************** +* Class: CSplitter. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CSplitter::CSplitter(){ + Pane1 = NULL; + Pane2 = NULL; + size = 4; + p = 0; + isActive = false; + initialized = false; +} + +CSplitter::~CSplitter(){ +} + +void CSplitter::Init(CWindow * pane1, CWindow * pane2, bool vertical, + int barPos, int barMode){ + Pane1 = pane1; + Pane2 = pane2; + + if(Pane1 && Pane2) + initialized = true; + + isVertical = vertical; + + p = barPos; + mode = barMode; +} + +bool CSplitter::Show(int){ +return false; +} + +bool CSplitter::Hide(void){ +return false; +} + +bool CSplitter::SetPosition(HWND, int x, int y, int width, int height, UINT){ + pos.left = x; + pos.top = y; + pos.right = width; + pos.bottom = height; + + if(isVertical) + SetVertPosition(); + else + SetHorzPosition(); +return true; +} + +void CSplitter::SetVertPosition(void){ + psize = p+size; + + barPos.left = pos.left+p; + barPos.top = pos.top; + barPos.right = size; + barPos.bottom = pos.bottom; + + Pane1->SetPosition(0, + pos.left, + pos.top, + p, + pos.bottom, + 0); + + Pane2->SetPosition(0, + pos.left +psize, + pos.top, + pos.right -psize, + pos.bottom, + 0); +} + +void CSplitter::SetHorzPosition(void){ + psize = p+size; + + barPos.left = pos.left; + barPos.top = pos.top+pos.bottom-psize; + barPos.right = pos.right; + barPos.bottom = size; + + Pane1->SetPosition(0, + pos.left, + pos.top, + pos.right, + pos.bottom -psize, + 0); + + Pane2->SetPosition(0, + pos.left, + pos.top +pos.bottom-p, + pos.right, + p, + 0); +} + +bool CSplitter::HaveMouse(HWND hwnd, short, short){ + POINT ptCursor; + ::GetCursorPos(&ptCursor); + POINT ptClient = ptCursor; + ::ScreenToClient(hwnd, &ptClient); + + if ( ptClient.x >= barPos.left + && ptClient.x <= barPos.left+barPos.right + && ptClient.y >= barPos.top + && ptClient.y <= barPos.top+barPos.bottom){ + return true; + } +return false; +} + +bool CSplitter::OnSetCursor(HWND hwnd, LPARAM){ + if(HaveMouse(hwnd, 0, 0)){ + if (isVertical){ + ::SetCursor(::LoadCursor(NULL, IDC_SIZEWE)); + return true; + }else{ + ::SetCursor(::LoadCursor(NULL, IDC_SIZENS)); + return true; + } + } +return false; +} + +bool CSplitter::OnLButtonDown(HWND hwnd, short xPos, short yPos){ + if (HaveMouse(hwnd, 0, 0)){ + // Begin of mouse capture. + isActive = true; + ::SetCapture(hwnd); + + // Save initial mouse position. + initialPos.x = xPos; + initialPos.y = yPos; + + // Converts bar position for Xor bar. + POINT xorPos; + RECT rect; + xorPos.x = barPos.left; + xorPos.y = barPos.top; + + ClientToWindow(hwnd, &xorPos, &rect); + + // Draw the Xor bar. + HDC hdc; + hdc = GetWindowDC(hwnd); + DrawXorBar(hdc, xorPos.x, xorPos.y, barPos.right, barPos.bottom); + + // Save initial position for future erasing. + initialXorPos.x = xorPos.x; + initialXorPos.y = xorPos.y; + + ReleaseDC(hwnd, hdc); + } +return isActive; +} + +void CSplitter::OnLButtonUp(HWND hwnd, short xPos, short yPos){ + if (isActive) { + + // Erase the Xor bar ********************* + HDC hdc; + hdc = GetWindowDC(hwnd); + DrawXorBar(hdc, initialXorPos.x, initialXorPos.y, barPos.right, barPos.bottom); + ReleaseDC(hwnd, hdc); + + // Move Splitter to new position ******************* + newPos.x = xPos; + newPos.y = yPos; + + if(isVertical) + deltaPos = newPos.x - initialPos.x; + else + deltaPos = newPos.y - initialPos.y;/**/ + + if (deltaPos != 0) + Move(barPos.left + deltaPos, barPos.top + deltaPos); + + // End of capture. + ::ReleaseCapture(); + isActive = false; + } +} + +void CSplitter::OnMouseMove(HWND hwnd, short xPos, short yPos){ + if (isActive) { + newPos.x = xPos; + newPos.y = yPos; + + // Draw the Xor bar ********************* + POINT xorPos; + RECT rect; + + if(isVertical){ + deltaPos = newPos.x - initialPos.x; + xorPos.x = barPos.left + deltaPos; + xorPos.y = barPos.top; + + // Convert coordinates. + ClientToWindow(hwnd, &xorPos, &rect); + + // Convert rect. + OffsetRect(&rect, -rect.left, -rect.top); + + if(xorPos.x < 20) + xorPos.x = 20; + if(xorPos.x > rect.right-24) + xorPos.x = rect.right-24; + }else{ + deltaPos = newPos.y - initialPos.y; + xorPos.x = barPos.left; + xorPos.y = barPos.top + deltaPos; + + // Convert coordinates. + ClientToWindow(hwnd, &xorPos, &rect); + + // Convert rect. + OffsetRect(&rect, -rect.left, -rect.top); + + if(xorPos.y < 20) + xorPos.y = 20; + if(xorPos.y > rect.bottom-24) + xorPos.y = rect.bottom-24; + } + + HDC hdc; + hdc = GetWindowDC(hwnd); + DrawXorBar(hdc, initialXorPos.x, initialXorPos.y, barPos.right, barPos.bottom); + DrawXorBar(hdc, xorPos.x, xorPos.y, barPos.right, barPos.bottom); + initialXorPos.x = xorPos.x; + initialXorPos.y = xorPos.y; + ReleaseDC(hwnd, hdc); + } +} + +void CSplitter::Move(int mouseX, int mouseY){ + + if(isVertical){ + p = mouseX; + SetVertPosition(); + }else{ + p = pos.bottom - size - mouseY+pos.top; + SetHorzPosition(); + } +} + +void CSplitter::ClientToWindow(HWND hwnd, POINT * pt, RECT * rect){ + // Bar position. + ClientToScreen(hwnd, pt); + // Window rect. + GetWindowRect(hwnd, rect); + + // Convert the bar coordinates relative to the top-left of the window. + pt->x -= rect->left; + pt->y -= rect->top; +} + +void CSplitter::DrawXorBar(HDC hdc, int x1, int y1, int width, int height){ + static WORD _dotPatternBmp[8] = + { + 0x00aa, 0x0055, 0x00aa, 0x0055, + 0x00aa, 0x0055, 0x00aa, 0x0055 + }; + + HBITMAP hbm; + HBRUSH hbr, hbrushOld; + + hbm = CreateBitmap(8, 8, 1, 1, _dotPatternBmp); + hbr = CreatePatternBrush(hbm); + + SetBrushOrgEx(hdc, x1, y1, 0); + hbrushOld = (HBRUSH)SelectObject(hdc, hbr); + + PatBlt(hdc, x1, y1, width, height, PATINVERT); + + SelectObject(hdc, hbrushOld); + + DeleteObject(hbr); + DeleteObject(hbm); +} + + +/******************************************************************** +* Class: CBitmap. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CBitmap::CBitmap(){ + hBitmap = NULL; +} + +CBitmap::~CBitmap(){ + if (hBitmap) + DeleteObject(hBitmap); +} + +HBITMAP CBitmap::Load(CWindow * pWindow, LPCTSTR lpBitmapName){ + if (!hBitmap) // Don't create twice. + hBitmap = ::LoadBitmap(pWindow->_hInst, lpBitmapName); +return hBitmap; +} + +HBITMAP CBitmap::Load(CWindow * pWindow, WORD wResId){ + if (!hBitmap) //Don't create twice. + hBitmap = ::LoadBitmap(pWindow->_hInst, MAKEINTRESOURCE(wResId)); +return hBitmap; +} + +BOOL CBitmap::Destroy(void){ + BOOL result = false; + if (hBitmap) + result = DeleteObject(hBitmap); +return result; +} + + +/******************************************************************** +* Class: CImageList. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CImageList::CImageList(){ + hImgList = NULL; +} + +CImageList::~CImageList(){ + if (hImgList) + ImageList_Destroy(hImgList); +} + +HIMAGELIST CImageList::Create(int cx, int cy, UINT flags, int cInitial, int cGrow){ + if (!hImgList) // Don't create twice. + hImgList = ::ImageList_Create(cx, cy, flags, cInitial, cGrow); +return hImgList; +} + +int CImageList::AddMasked(CBitmap * pBitmap, COLORREF crMask){ +return ImageList_AddMasked(hImgList, pBitmap->hBitmap, crMask); +} + + +/******************************************************************** +* Class: CMessageBox. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CMessageBox::CMessageBox(){ + hParent = 0; + strcpy(caption, "CMessageBox"); +} + +CMessageBox::~CMessageBox(){ +} + +void CMessageBox::SetParent(HWND hwnd){ + hParent = hwnd; +} + +void CMessageBox::SetCaption(char * string){ + strcpy(caption, string); +} + +void CMessageBox::DisplayString(char * string, char * substring, UINT uType){ + if(!substring){ + MessageBox (hParent, string, caption, uType); + }else{ + sprintf(msgBuf, string, substring); + MessageBox (hParent, msgBuf, caption, uType); + } +} + +void CMessageBox::DisplayFatal(char * string, char * substring){ + DisplayString(string, substring, MB_OK | MB_ICONERROR); +} + +void CMessageBox::DisplayWarning(char * string, char * substring){ + DisplayString(string, substring, MB_OK | MB_ICONWARNING); +} + +void CMessageBox::DisplayLong(long number){ + char longbuf[10]; + itoa (number, longbuf, 10); + DisplayString(longbuf); +} + +void CMessageBox::DisplayRect(RECT * rect){ + if (!rect) + return; + sprintf(msgBuf, "left: %ld top: %ld right: %ld bottom: %ld", rect->left, rect->top, rect->right, rect->bottom); + MessageBox (hParent, msgBuf, caption, MB_OK); +} + +int CMessageBox::Ask(char * question, bool canCancel){ + + if (canCancel){ + // Cancel button. + return MessageBox(hParent, question, caption, MB_YESNOCANCEL | MB_ICONWARNING); + }else{ + // No cancel. + return MessageBox(hParent, question, caption, MB_YESNO | MB_ICONWARNING); + } +} + +int CMessageBox::AskToSave(bool canCancel){ + + char question[] = "Save changes ?"; + + if (canCancel){ + // Cancel button. + return Ask(question, true); + }else{ + // No cancel. + return Ask(question, false); + } +} + + +/******************************************************************** +* Class: CFileDlgBase. +* +* Purpose: Open/Save Dlg. +* +* Revisions: +* +********************************************************************/ +CFileDlgBase::CFileDlgBase(){ + ofn.lStructSize = sizeof(OPENFILENAME); // DWORD + Reset(); +} + +CFileDlgBase::~CFileDlgBase(){ +} + +void CFileDlgBase::Reset(void){ + // Set methods. + ofn.lpstrTitle = 0; // LPCTSTR + ofn.nFilterIndex = 0; // DWORD + ofn.lpstrFilter = 0; // LPCTSTR + ofn.lpstrDefExt = 0; // LPCTSTR + ofn.Flags = 0; // DWORD + + ofn.lpstrInitialDir = 0; // LPCTSTR + + // Get methods. + nNextFileOffset = 0; + ofn.nFileOffset = 0; // WORD + ofn.nFileExtension = 0; // WORD + + // Unused. + ofn.hInstance = 0; // HINSTANCE + ofn.lpstrCustomFilter = 0; // LPTSTR + ofn.nMaxCustFilter = 0; // DWORD + ofn.lpstrFileTitle = 0; // LPTSTR + ofn.nMaxFileTitle = 0; // DWORD + ofn.lCustData = 0; // DWORD + ofn.lpfnHook = 0; // LPOFNHOOKPROC + ofn.lpTemplateName = 0; // LPCTSTR +} + +void CFileDlgBase::SetData(char * filter, char * defExt, DWORD flags){ + SetFilter(filter); + SetDefExt(defExt); + SetFlags(flags); +} + +void CFileDlgBase::SetTitle(char * title){ + ofn.lpstrTitle = title; +} + +void CFileDlgBase::SetFilterIndex(DWORD filterIndex){ + ofn.nFilterIndex = filterIndex; +} + +void CFileDlgBase::SetFilter(char * filter){ + ofn.lpstrFilter = filter; +} + +void CFileDlgBase::SetDefExt(char * defExt){ + ofn.lpstrDefExt = defExt; +} + +void CFileDlgBase::SetFlags(DWORD flags){ + ofn.Flags = flags; +} + +void CFileDlgBase::SetInitialDir(char * lpstrInitialDir){ + ofn.lpstrInitialDir = lpstrInitialDir; +} + +WORD CFileDlgBase::GetFileOffset(void){ +return ofn.nFileOffset; +} + +WORD CFileDlgBase::GetFileExtension(void){ +return ofn.nFileExtension; +} + +WORD CFileDlgBase::GetNextFileOffset(void){ + // Analyses a "path\0file1\0file2\0file[...]\0\0" string returned by Open/SaveDlg. + char * srcFiles = ofn.lpstrFile; + if (srcFiles){ + if ((ofn.Flags & OFN_ALLOWMULTISELECT) == OFN_ALLOWMULTISELECT){ + // Initialize first call. + if (!nNextFileOffset) + nNextFileOffset = ofn.nFileOffset; + // Parse the string. + while (srcFiles[nNextFileOffset] != '\0') + nNextFileOffset++; + // Get next char. + nNextFileOffset++; + // End of string ? + if (srcFiles[nNextFileOffset] == '\0') + nNextFileOffset = 0; + return nNextFileOffset; + } + } +return 0; +} + +bool CFileDlgBase::OpenFileName(CWindow * pWindow, char * pszFileName, DWORD nMaxFile){ + if (!pWindow) + return false; + + ofn.hwndOwner = pWindow->_hWnd; // HWND + ofn.lpstrFile = pszFileName; // LPTSTR + ofn.nMaxFile = nMaxFile; // DWORD + +return ::GetOpenFileName(&ofn); +} + +bool CFileDlgBase::SaveFileName(CWindow * pWindow, char * pszFileName, DWORD nMaxFile){ + if (!pWindow) + return false; + pszFileName[0] = '\0'; + ofn.hwndOwner = pWindow->_hWnd; // HWND + ofn.lpstrFile = pszFileName; // LPTSTR + ofn.nMaxFile = nMaxFile; // DWORD + +return ::GetSaveFileName(&ofn); +} + + +/******************************************************************** +* Class: CPath. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CPath::CPath(){ +} + +CPath::~CPath(){ +} + +bool CPath::ChangeDirectory(char * dir){ + return SetCurrentDirectory(dir); +} + + +/******************************************************************** +* Paths. +********************************************************************/ +void SplitFileName(char * dirName, char * fileName){ + int n; + int len = strlen (dirName); + + for (n = len; n > 2; n--){ + if (dirName[n] == '\\' ){ + if (fileName) + strcpy (fileName, &dirName[n+1]); + dirName[n+1] = 0; + break; + } + } +} + +bool ChangeFileExt(char * fileName, char * ext){ + int len = strlen(fileName); + for (int n=len; n > 0; n--){ + if (fileName[n] == '.'){ + fileName[n+1] = 0; + strcat(fileName, ext); + return true; + } + } +return false; // No file extension. +} + + +/******************************************************************** +* Class: CIniFile. +* +* Purpose: "GetPrivateProfileString()" like procedure. +* +* Revisions: +* +********************************************************************/ +CIniFile::CIniFile(){ + buffer = NULL; + pcurrent = NULL; + psection = NULL; +} + +CIniFile::~CIniFile(){ + Close(); +} + +void CIniFile::Close(void){ + if (buffer) + free(buffer); + buffer = NULL; + pcurrent = NULL; + psection = NULL; +} + +bool CIniFile::Load(char * fullPath){ + if (buffer) + Close(); + + FILE * file; + + /* FIXME: ZeroMemory because open/close projects can cause + GetString to found data from previous projects. */ +// ZeroMemory(buffer, MAX_BLOC_SIZE); + + file = fopen(fullPath, "rb"); + if (file){ + buffer = (char *) malloc(MAX_BLOC_SIZE); + if (!buffer) + return false; + fread(buffer, 1, MAX_BLOC_SIZE, file); + if (0 != fread(buffer, 1, sizeof(buffer), file)){ + MsgBox.DisplayString("CIniFile ERROR: OVERFOW"); + fclose(file); + Close(); + return false; + } + fclose(file); + + // Initialize current pointer. + pcurrent = buffer; + return true; + } +return false; +} + +int CIniFile::GetInt(char * key, char * section){ + + char integer[32]; + + if (GetString(integer, key, section)){ + return atoi(integer); + } + +return 0; +} + +//****************************************************** +// Reminder : +// GetPrivateProfileString("Section", "Key", "default_string", data, size, iniFilePath); +//****************************************************** +bool CIniFile::GetString(char * data, char * key, char * section){ + /* Copies data and returns true if successfull */ + char *pstop; + if (section){ + /* Parse from pcurrent until the end of buffer */ + pstop = pcurrent; + for ( ; ; ){ + if (*pcurrent == '\0'){ + /* Parse again from beginning to pstop */ + pcurrent = buffer; + for ( ; ; ){ + if (FindSection(pcurrent, section)) + break; // Found ! + if (pcurrent >= pstop) + return false; // Not found ! + } + } + if (FindSection(pcurrent, section)) + break; // Found ! + } + } + + if (psection){ + /* Section Found */ + pstop = pcurrent; + //MsgBox.DisplayString(pcurrent); + for ( ; ; ){ + if (*pcurrent == '\0' || *pcurrent == '['){ + /* Parse again from beginning to pstop */ + pcurrent = psection; + for ( ; ; ){ + if (FindData(pcurrent, key, data)) + break; // Found ! + if (pcurrent >= pstop) + return false; // Not found ! + } + } + if (FindData(pcurrent, key, data)) + break; // Found ! + } + } + //MsgBox.DisplayString(pcurrent); +return true; +} + +bool CIniFile::FindSection(char * s, char * section){ + /* Search the section through one line of text */ + /* Returns true if successful, false otherwise */ + /* This procedure increments current pointer to the end of line */ + + if (!section) + return false; + + bool sectionFound = false; + psection = NULL; + + /* Skip spaces and comments */ + s = SkipUnwanted(s); + + /* End of buffer ? */ + if (*s == '\0'){ + pcurrent = s; + return false; + + /* A section ? */ + }else if (*s == '['){ + s++; + if (*s == '\0'){ + pcurrent = s; + return false; + } + + /* Parse the section name */ + int len = strlen(section); + if (!strncmp(s, section, len)){ + s+=len; + if (*s == ']'){ + /* Section found ! */ + sectionFound = true; + } + } + } + + /* Increment current pointer until the end of current line */ + while (*s != '\0' && *s != '\n') + s++; + pcurrent = s; + + if (sectionFound) + psection = pcurrent; +return sectionFound; +} + +bool CIniFile::FindData(char * s, char * key, char * data){ + /* Search the key through one line of text */ + /* Returns true if successful, false otherwise */ + /* This procedure increments current pointer to the end of line */ + + bool keyFound = false; + /* Skip spaces and comments */ + s = SkipUnwanted(s); + + /* End of buffer ? End of section ? */ + if (*s == '\0' || *s == '['){ + pcurrent = s; + return false; + + /* Search the key */ + }else{ + int len = strlen(key); + /* Compare key and s */ + if (!strncmp(s, key, len)){ + s+=len; + /* Search an '=' sign */ + while (isspace(*s)){ + if (*s == '\n') + break; + s++; + } + + if (*s == '='){ + /* Key found ! */ + keyFound = true; + s++; + while (isspace(*s)){ + if (*s == '\n') + break; + s++; + } + + /* Copy data ! */ + s += CopyData(data, s); + } + } + } + + /* Increment current pointer until the end of current line */ + while (*s != '\0' && *s != '\n') + s++; + pcurrent = s; +return keyFound; +} + +long CIniFile::CopyData(char * data, char * s){ +/* Returns the number of characters copied not including the terminating null char */ + char *pdata = data; + while (*s != '\0' && *s != '\r' && *s != '\n'){ + *pdata = *s; + pdata++; + s++; + + /* @@ Overflow @@ + n++; + if (n == n_max){ + *data = '\0'; + return + }*/ + } + *pdata = '\0'; +return (pdata-data); +} + +char * CIniFile::SkipUnwanted(char *s){ + for ( ; ; ){ + /* End of buffer ? */ + if (*s == '\0') + return s; + if (isspace(*s)){ + /* Skip spaces */ + s++; + }else if (*s == ';'){ + /* Skip comments */ + char * end_of_line = strchr(s, '\n'); + if (end_of_line){ + /* End of comment */ + s = end_of_line+1; + continue; + }else{ + /* End of buffer */ + return end_of_line; + } + /* Done */ + }else{ + return s; + } + } +} + + +/******************************************************************** +* Class: CShellDlg. +* +* Purpose: +* +* Revisions: +* +********************************************************************/ +CShellDlg::CShellDlg(){ + // Get shell task allocator. + if(SHGetMalloc(&pMalloc) == (HRESULT) E_FAIL) + pMalloc = NULL; +} + +CShellDlg::~CShellDlg(){ + // Decrements the reference count. + if (pMalloc) + pMalloc->Release(); +} + +bool CShellDlg::BrowseForFolder(CWindow * pWindow, LPSTR pszDisplayName, + LPCSTR lpszTitle, UINT ulFlags, BFFCALLBACK lpfn, LPARAM lParam, int iImage){ + + // Initialize output buffer. + *pszDisplayName = '\0'; + // BROWSEINFO. + if (!pWindow) + bi.hwndOwner = 0; + else + bi.hwndOwner = pWindow->_hWnd; + bi.pidlRoot = NULL; + bi.pszDisplayName = pszDisplayName; + bi.lpszTitle = lpszTitle; + bi.ulFlags = ulFlags; + bi.lpfn = lpfn; + bi.lParam = lParam; + bi.iImage = iImage; + + LPITEMIDLIST pidl = SHBrowseForFolder(&bi); + if(!pidl) + return false; + + if(!SHGetPathFromIDList(pidl, pszDisplayName)) + return false; + + pMalloc->Free(pidl); +return true; +} + +CCriticalSection::CCriticalSection(){ + ::InitializeCriticalSection(&cs); +} + +CCriticalSection::~CCriticalSection(){ + ::DeleteCriticalSection(&cs); +} + +void CCriticalSection::Enter(){ + ::EnterCriticalSection(&cs); +} + +void CCriticalSection::Leave(){ + ::LeaveCriticalSection(&cs); +} + diff --git a/rosapps/devutils/vmingw/winui.h b/rosapps/devutils/vmingw/winui.h new file mode 100644 index 00000000000..b20ddb8ec58 --- /dev/null +++ b/rosapps/devutils/vmingw/winui.h @@ -0,0 +1,529 @@ +/******************************************************************** +* Module: winui.h. This is part of WinUI. +* +* License: WinUI is covered by GNU General Public License, +* Copyright (C) 2001 Manu B. +* See license.htm for more details. +* +********************************************************************/ +#ifndef WINUI_H +#define WINUI_H + +/* These are patched headers */ +#include "commdlg.h" +#include "commctrl.h" +#include +#include +#include +// OLE. +#include + +#include "CList.h" + +#define SPLSTYLE_HORZ 0 +#define SPLSTYLE_VERT 1 +#define SPLMODE_1 0 +#define SPLMODE_2 1 + +char *StpCpy(char *dest, const char *src); +size_t strcpylen(char *dest, const char *src); + +void SplitFileName(char * dirName, char * fileName); +bool ChangeFileExt(char * fileName, char * ext); + +class CMessageBox +{ + public: + CMessageBox(); + ~CMessageBox(); + + void SetParent(HWND hwnd); + void SetCaption(char * string); + void DisplayString(char * string, char * substring = NULL, UINT uType = MB_OK); + void DisplayWarning(char * string, char * substring = NULL); + void DisplayFatal(char * string, char * substring = NULL); + void DisplayLong(long number); + void DisplayRect(RECT * rect); + int Ask(char * question, bool canCancel); + int AskToSave(bool canCancel); + + protected: + HWND hParent; + char msgBuf[256]; + char caption[64]; + + private: +}; + +class CPath +{ + public: + CPath(); + ~CPath(); + + bool ChangeDirectory(char * dir); + + protected: + + private: + char pathBuf[MAX_PATH]; +}; + +class CWindow +{ + public: + CWindow(); + virtual ~CWindow(); + + virtual HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, + LPCTSTR lpClassName, LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, + int nWidth, int nHeight, HMENU hMenu, LPVOID lpParam); + + HWND GetId(void); + LONG SetLong(int nIndex, LONG dwNewLong); + LONG GetLong(int nIndex); + LRESULT SendMessage(UINT msg, WPARAM wParam = 0, LPARAM lParam = 0); + + virtual bool SetPosition(HWND hInsertAfter, int x, int y, int width, int height, UINT uFlags); + virtual bool Show(int nCmdShow = SW_SHOWNORMAL); + virtual bool Hide(void); + HWND SetFocus(void); + CWindow * _pParent; + HWND _hWnd; + HINSTANCE _hInst; + LPVOID _lParam; + + protected: + + private: +}; + +class CWinBase : public CWindow +{ + public: + CWinBase(); + ~CWinBase(); + + HINSTANCE hPrevInst; + LPSTR lpCmdLine; + int nCmdShow; + + char appName[64]; + char msgBuf[256]; + bool isWinNT; + + bool Init(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, + int nCmdShow); + bool SetName(char * name, char * version = NULL); + void ParseCmdLine(char * outBuff); + bool IsWinNT(void); + + bool ChangeDirectory(char * dir); + + protected: + + private: +}; + +class CSDIBase : public CWinBase +{ + public: + CSDIBase(); + virtual ~CSDIBase(); + + virtual int Run(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); + virtual bool CustomInit(void); + virtual bool Release(void); + virtual bool CreateUI(void); + bool MainRegisterEx(const char * className); + virtual LRESULT CALLBACK CMainWndProc(UINT Message, WPARAM wParam, LPARAM lParam); + + protected: + WNDCLASSEX wc; + HACCEL hAccel; + char mainClass[16]; + + private: +}; + +class CMDIChild; + +class CMDIClient : public CWindow +{ + public: + CMDIClient(); + ~CMDIClient(); + + void Init(int menuIndex, UINT idFirstChild); + HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0); + LPARAM GetParam(LPARAM lParam); + + bool initialized; + char childClass[16]; + CList childList; + + protected: + CLIENTCREATESTRUCT ccs; + int nPos; + + private: +}; + +class UseOle +{ + public: + UseOle(){oleError = OleInitialize(NULL);} + ~UseOle(){OleUninitialize();} + HRESULT GetError(void){return oleError;} + protected: + HRESULT oleError; + private: +}; + +class CMDIBase : public CSDIBase +{ + public: + CMDIBase(); + virtual ~CMDIBase(); + + virtual int Run(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); + virtual bool CustomInit(void); + virtual bool Release(void); + virtual bool CreateUI(void); + bool ChildRegisterEx(const char * className); + virtual LRESULT CALLBACK CMainWndProc(UINT Message, WPARAM wParam, LPARAM lParam); + virtual LRESULT CALLBACK CChildWndProc(CWindow * pWnd, UINT Message, WPARAM wParam, LPARAM lParam); + + CMDIClient MdiClient; + + protected: + UseOle useOle; + + private: +}; + +class CMDIChild : public CNode, public CWindow +{ + public: + CMDIChild(); + virtual ~CMDIChild(); + + HWND CreateEx(CMDIClient * pMdiClient, DWORD dwExStyle, DWORD dwStyle, char * caption, UINT resId = 0, LPVOID lParam = NULL); + + CMDIBase * _pFrame; + + protected: + + private: +}; + +class CFileDlgBase : public CWindow +{ + public: + CFileDlgBase(); + ~CFileDlgBase(); + + void Reset(void); + void SetData(char * filter, char * defExt, DWORD flags); + void SetTitle(char * title); + void SetFilterIndex(DWORD filterIndex); + void SetFilter(char * filter); + void SetDefExt(char * defExt); + void SetFlags(DWORD flags); + void SetInitialDir(char * lpstrInitialDir); + + WORD GetFileOffset(void); + WORD GetFileExtension(void); + WORD GetNextFileOffset(void); + + bool OpenFileName(CWindow * pWindow, char * pszFileName, DWORD nMaxFile); + bool SaveFileName(CWindow * pWindow, char * pszFileName, DWORD nMaxFile); + OPENFILENAME ofn; + + protected: + + WORD nNextFileOffset; + private: +}; + +class CDlgBase : public CWindow +{ + public: + CDlgBase(); + virtual ~CDlgBase(); + + HWND Create(CWindow * pWindow, WORD wResId, RECT * Pos, LPARAM lParam); + int CreateModal(CWindow * pWindow, WORD wResId, LPARAM lParam); + HWND CreateParam(CWindow * pWindow, WORD wResId, LPARAM lParam); + BOOL EndDlg(int nResult); + virtual LRESULT CALLBACK CDlgProc(UINT Message, WPARAM wParam, LPARAM lParam); + HWND GetItem(int nIDDlgItem); + BOOL SetItemText(HWND hItem, LPCTSTR lpString); + UINT GetItemText(HWND hItem, LPTSTR lpString, int nMaxCount); +/* BOOL SetItemInt(HWND hItem, UINT uValue, BOOL bSigned); + UINT GetItemInt(HWND hItem, BOOL *lpTranslated, BOOL bSigned); +*/ + protected: + + private: +}; + +class CTabbedDlg : public CDlgBase +{ + public: + CTabbedDlg(); + virtual ~CTabbedDlg(); + + virtual void OnNotify(int idCtrl, LPNMHDR notify); + virtual void OnSelChanging(LPNMHDR notify); + virtual void OnSelChange(LPNMHDR notify); + virtual bool SetChildPosition(HWND hChild); + + protected: + LPARAM GetParam(void); + HWND _hWndTab; + RECT Pos; + TCITEM tcitem; + + private: +}; + +class CToolBar : public CWindow +{ + public: + CToolBar(); + ~CToolBar(); + + HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0); + LRESULT AddBitmap(UINT resId, int nBmp, HINSTANCE hInstance = 0); + BOOL AddButtons(TBBUTTON * tbButtons, UINT numButtons); + + protected: + + private: +}; + +class CBitmap +{ + public: + CBitmap(); + ~CBitmap(); + + HBITMAP Load(CWindow * pWindow, LPCTSTR lpBitmapName); + HBITMAP Load(CWindow * pWindow, WORD wResId); + BOOL Destroy(void); + + HBITMAP hBitmap; + + protected: + + private: +}; + +class CImageList +{ + public: + CImageList(); + ~CImageList(); + + HIMAGELIST Create(int cx, int cy, UINT flags, int cInitial, int cGrow); + int AddMasked(CBitmap * pBitmap, COLORREF crMask); + HIMAGELIST GetId(void){return hImgList;}; + + protected: + HIMAGELIST hImgList; + + private: +}; + +class CTabCtrl : public CWindow +{ + public: + CTabCtrl(); + ~CTabCtrl(); + + HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0, LPVOID lParam = NULL); + BOOL SetItem_Param(int iItem, LPARAM lParam); + LPARAM GetItem_Param(int iItem); + int GetCurSel(void); + int InsertItem(int iItem, UINT mask, DWORD dwState, DWORD dwStateMask, + LPTSTR pszText, int cchTextMax, int iImage, LPARAM lParam); + + protected: + TCITEM tcitem; + + private: +}; + +class CTreeView : public CWindow +{ + public: + CTreeView(); + ~CTreeView(); + + TVINSERTSTRUCT tvi; + TVITEM _TvItem; + HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0, LPVOID lParam = NULL); + HTREEITEM CreateItem(HTREEITEM hParent, HTREEITEM hInsertAfter, int iImage, LPTSTR pszText, LPARAM lParam); + LPARAM GetSelectedItemParam(void); + + protected: + private: +}; + +class CScintilla : public CWindow +{ + public: + CScintilla(); + ~CScintilla(); + + HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0, LPVOID lParam = NULL); + + protected: + private: +}; + +class CListView : public CWindow +{ + public: + CListView(); + ~CListView(); + + HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0); + void Clear(void); + + protected: + DWORD lastRow; + + private: +}; + +class CStatusBar : public CWindow +{ + public: + CStatusBar(); + ~CStatusBar(); + + HWND CreateEx(CWindow * pWindow, DWORD dwExStyle, DWORD dwStyle = WS_CHILD, UINT resId = 0); + void SetParts(int nParts, int * aWidths); + + void WriteString(char * string, int part); + void WriteLong(long number, int part); + + protected: + + private: + int numParts; +}; + +class CSplitter : public CWindow +{ + public: + CSplitter(); + ~CSplitter(); + + void Init(CWindow * pane1, CWindow * pane2, bool vertical, + int barPos, int barMode); + bool SetPosition(HWND hInsertAfter, int x, int y, int width, int height, UINT uFlags); + bool Show(int nCmdShow = SW_SHOWNORMAL); + bool Hide(void); + bool HaveMouse(HWND hwnd, short xPos, short yPos); + void Move(int mouseX, int mouseY); + bool OnLButtonDown(HWND hwnd, short xPos, short yPos); + void OnMouseMove(HWND hwnd, short xPos, short yPos); + void OnLButtonUp(HWND hwnd, short xPos, short yPos); + bool OnSetCursor(HWND hwnd, LPARAM lParam); + + protected: + void SetVertPosition(void); + void SetHorzPosition(void); + void DrawXorBar(HDC hdc, int x1, int y1, int width, int height); + void ClientToWindow(HWND hwnd, POINT * pt, RECT * rect); + + CWindow * Pane1; + CWindow * Pane2; + int p; + int size; + int psize; + bool isVertical; + int mode; + bool isActive; + RECT pos; + RECT barPos; + int deltaPos; + POINT initialXorPos; + + POINT initialPos; + POINT newPos; + private: + bool initialized; +}; + +#define MAX_BLOC_SIZE 16384 +class CIniFile +{ + public: + CIniFile(); + ~CIniFile(); + + bool Load(char * fullPath); + void Close(void); + bool GetString(char * data, char * key, char * section = NULL); + int GetInt(char * key, char * section = NULL); + + protected: + + private: + + char * buffer; + char * pcurrent; + char * psection; + + bool FindSection(char * pcurrent, char * section); + bool FindData(char * s, char * key, char * data); + long CopyData(char * data, char * s); + char *SkipUnwanted(char *s); +}; + +class CChrono +{ + public: + CChrono(); + ~CChrono(); + + void Start(void); + DWORD Stop(void); + + protected: + DWORD _time; + + private: +}; + +class CShellDlg +{ + public: + CShellDlg(); + ~CShellDlg(); + bool BrowseForFolder(CWindow * pWindow, LPSTR pszDisplayName, LPCSTR lpszTitle, + UINT ulFlags, BFFCALLBACK lpfn=0, LPARAM lParam=0, int iImage=0); + + protected: + IMalloc* pMalloc; + BROWSEINFO bi; + + private: +}; + +class CCriticalSection +{ +public: + CCriticalSection(); + ~CCriticalSection(); + void Enter(); + void Leave(); +private: + CRITICAL_SECTION cs; +}; + +#endif