initiaql check-in, moved repository -- no-longer a fork of
haikuarchives/yab
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
bison.c
|
||||||
|
bison.h
|
||||||
|
flex.c
|
||||||
|
bison.output
|
||||||
|
yab
|
||||||
|
*.o
|
||||||
131
Documentation/ARTISTIC
Normal file
131
Documentation/ARTISTIC
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The "Artistic License"
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The intent of this document is to state the conditions under which a
|
||||||
|
Package may be copied, such that the Copyright Holder maintains some
|
||||||
|
semblance of artistic control over the development of the package,
|
||||||
|
while giving the users of the package the right to use and distribute
|
||||||
|
the Package in a more-or-less customary fashion, plus the right to make
|
||||||
|
reasonable modifications.
|
||||||
|
|
||||||
|
Definitions:
|
||||||
|
|
||||||
|
"Package" refers to the collection of files distributed by the
|
||||||
|
Copyright Holder, and derivatives of that collection of files
|
||||||
|
created through textual modification.
|
||||||
|
|
||||||
|
"Standard Version" refers to such a Package if it has not been
|
||||||
|
modified, or has been modified in accordance with the wishes
|
||||||
|
of the Copyright Holder as specified below.
|
||||||
|
|
||||||
|
"Copyright Holder" is whoever is named in the copyright or
|
||||||
|
copyrights for the package.
|
||||||
|
|
||||||
|
"You" is you, if you're thinking about copying or distributing
|
||||||
|
this Package.
|
||||||
|
|
||||||
|
"Reasonable copying fee" is whatever you can justify on the
|
||||||
|
basis of media cost, duplication charges, time of people involved,
|
||||||
|
and so on. (You will not be required to justify it to the
|
||||||
|
Copyright Holder, but only to the computing community at large
|
||||||
|
as a market that must bear the fee.)
|
||||||
|
|
||||||
|
"Freely Available" means that no fee is charged for the item
|
||||||
|
itself, though there may be fees involved in handling the item.
|
||||||
|
It also means that recipients of the item may redistribute it
|
||||||
|
under the same conditions they received it.
|
||||||
|
|
||||||
|
1. You may make and give away verbatim copies of the source form of the
|
||||||
|
Standard Version of this Package without restriction, provided that you
|
||||||
|
duplicate all of the original copyright notices and associated disclaimers.
|
||||||
|
|
||||||
|
2. You may apply bug fixes, portability fixes and other modifications
|
||||||
|
derived from the Public Domain or from the Copyright Holder. A Package
|
||||||
|
modified in such a way shall still be considered the Standard Version.
|
||||||
|
|
||||||
|
3. You may otherwise modify your copy of this Package in any way, provided
|
||||||
|
that you insert a prominent notice in each changed file stating how and
|
||||||
|
when you changed that file, and provided that you do at least ONE of the
|
||||||
|
following:
|
||||||
|
|
||||||
|
a) place your modifications in the Public Domain or otherwise make them
|
||||||
|
Freely Available, such as by posting said modifications to Usenet or
|
||||||
|
an equivalent medium, or placing the modifications on a major archive
|
||||||
|
site such as uunet.uu.net, or by allowing the Copyright Holder to include
|
||||||
|
your modifications in the Standard Version of the Package.
|
||||||
|
|
||||||
|
b) use the modified Package only within your corporation or organization.
|
||||||
|
|
||||||
|
c) rename any non-standard executables so the names do not conflict
|
||||||
|
with standard executables, which must also be provided, and provide
|
||||||
|
a separate manual page for each non-standard executable that clearly
|
||||||
|
documents how it differs from the Standard Version.
|
||||||
|
|
||||||
|
d) make other distribution arrangements with the Copyright Holder.
|
||||||
|
|
||||||
|
4. You may distribute the programs of this Package in object code or
|
||||||
|
executable form, provided that you do at least ONE of the following:
|
||||||
|
|
||||||
|
a) distribute a Standard Version of the executables and library files,
|
||||||
|
together with instructions (in the manual page or equivalent) on where
|
||||||
|
to get the Standard Version.
|
||||||
|
|
||||||
|
b) accompany the distribution with the machine-readable source of
|
||||||
|
the Package with your modifications.
|
||||||
|
|
||||||
|
c) give non-standard executables non-standard names, and clearly
|
||||||
|
document the differences in manual pages (or equivalent), together
|
||||||
|
with instructions on where to get the Standard Version.
|
||||||
|
|
||||||
|
d) make other distribution arrangements with the Copyright Holder.
|
||||||
|
|
||||||
|
5. You may charge a reasonable copying fee for any distribution of this
|
||||||
|
Package. You may charge any fee you choose for support of this
|
||||||
|
Package. You may not charge a fee for this Package itself. However,
|
||||||
|
you may distribute this Package in aggregate with other (possibly
|
||||||
|
commercial) programs as part of a larger (possibly commercial) software
|
||||||
|
distribution provided that you do not advertise this Package as a
|
||||||
|
product of your own. You may embed this Package's interpreter within
|
||||||
|
an executable of yours (by linking); this shall be construed as a mere
|
||||||
|
form of aggregation, provided that the complete Standard Version of the
|
||||||
|
interpreter is so embedded.
|
||||||
|
|
||||||
|
6. The scripts and library files supplied as input to or produced as
|
||||||
|
output from the programs of this Package do not automatically fall
|
||||||
|
under the copyright of this Package, but belong to whoever generated
|
||||||
|
them, and may be sold commercially, and may be aggregated with this
|
||||||
|
Package. If such scripts or library files are aggregated with this
|
||||||
|
Package via the so-called "undump" or "unexec" methods of producing a
|
||||||
|
binary executable image, then distribution of such an image shall
|
||||||
|
neither be construed as a distribution of this Package nor shall it
|
||||||
|
fall under the restrictions of Paragraphs 3 and 4, provided that you do
|
||||||
|
not represent such an executable image as a Standard Version of this
|
||||||
|
Package.
|
||||||
|
|
||||||
|
7. C subroutines (or comparably compiled subroutines in other
|
||||||
|
languages) supplied by you and linked into this Package in order to
|
||||||
|
emulate subroutines and variables of the language defined by this
|
||||||
|
Package shall not be considered part of this Package, but are the
|
||||||
|
equivalent of input as in Paragraph 6, provided these subroutines do
|
||||||
|
not change the language in any way that would cause it to fail the
|
||||||
|
regression tests for the language.
|
||||||
|
|
||||||
|
8. Aggregation of this Package with a commercial distribution is always
|
||||||
|
permitted provided that the use of this Package is embedded; that is,
|
||||||
|
when no overt attempt is made to make this Package's interfaces visible
|
||||||
|
to the end user of the commercial distribution. Such use shall not be
|
||||||
|
construed as a distribution of this Package.
|
||||||
|
|
||||||
|
9. The name of the Copyright Holder may not be used to endorse or promote
|
||||||
|
products derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
The End
|
||||||
65
Documentation/Advanced/HowToMakeABuildFactory.txt
Normal file
65
Documentation/Advanced/HowToMakeABuildFactory.txt
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
1. check AutoFooter if all files are there, add new files when necessary
|
||||||
|
|
||||||
|
2. generate flex.c and bison.c by typing:
|
||||||
|
flex -i -I -L -s -t yabasic.flex >flex.c
|
||||||
|
perl -i -n -e 'if (!/^\#include\s+<unistd.h>\s+$$/) {print if $$i;$$i++}' flex.c
|
||||||
|
bison -d -l -t -v --output-file bison.c yabasic.bison
|
||||||
|
|
||||||
|
3. edit flex.c as follows:
|
||||||
|
- add the headers (after #include<stdio.h>) and the static declaration
|
||||||
|
#include <zlib.h>
|
||||||
|
#include "program.h"
|
||||||
|
static int isparsed = 0;
|
||||||
|
- replace the default input buffer size
|
||||||
|
#define YY_BUF_SIZE 16384
|
||||||
|
with
|
||||||
|
#define YY_BUF_SIZE PROGLEN
|
||||||
|
- search for
|
||||||
|
#define YY_INPUT(buf,result,max_size) \
|
||||||
|
replace the last lines of this define
|
||||||
|
else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
|
||||||
|
&& ferror( yyin ) ) \
|
||||||
|
YY_FATAL_ERROR( "input in flex scanner failed" );
|
||||||
|
with
|
||||||
|
else if ( ((result = zread( buf, 1, max_size, yyin )) == 0) && !ferror( yyin ) ) \
|
||||||
|
YY_FATAL_ERROR( "input in flex scanner failed" );
|
||||||
|
- add to the function
|
||||||
|
static int yy_get_next_buffer()
|
||||||
|
after
|
||||||
|
int ret_val;
|
||||||
|
the following line
|
||||||
|
if(isparsed) return EOB_ACT_END_OF_FILE;
|
||||||
|
- add the function zread at the end of flex.c:
|
||||||
|
int zread(char* dest, size_t memb_size, size_t num_memb, FILE *file)
|
||||||
|
{
|
||||||
|
long destlen = PROGLEN;
|
||||||
|
if(isparsed==1)
|
||||||
|
return 0;
|
||||||
|
isparsed = 1;
|
||||||
|
uncompress(dest,&destlen,myProg,sizeof(myProg));
|
||||||
|
return destlen;
|
||||||
|
}
|
||||||
|
- NOTE: you only have to go through this process when new commands have been added to
|
||||||
|
yabasic.flex. Otherwise you can just take the modified flex.c from the last BuildFactory.
|
||||||
|
|
||||||
|
4. edit main.c as follows:
|
||||||
|
- search for the function
|
||||||
|
int isbound(void)
|
||||||
|
delete the whole function and replace it with:
|
||||||
|
int isbound(void)
|
||||||
|
{
|
||||||
|
FILE *interpreter;
|
||||||
|
if (!interpreter_path || !interpreter_path[0]) {
|
||||||
|
error(FATAL,"interpreter_path is not set !");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!(interpreter=fopen(interpreter_path,"r"))) {
|
||||||
|
sprintf(string,"Couldn't open '%s' to check, if it is bound: %s",interpreter_path,my_strerror(errno));
|
||||||
|
error(WARNING,string);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
44
Documentation/ChangeLog
Normal file
44
Documentation/ChangeLog
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
yab Version 1.7.4.1 Changes from version 1.7
|
||||||
|
-LOCALIZE doesn't work again due to changes in haiku.
|
||||||
|
-TEXTCONTROL added more options for set options.
|
||||||
|
yab Version 1.7 Changes from Version 1.6
|
||||||
|
- COLUMNBOX updated to Haiku style (thanks Stargater!)
|
||||||
|
- STATUSBAR didn't follow LAYOUT, fixed now
|
||||||
|
- RESTORE Label$ allows for dynamic label strings
|
||||||
|
- various ATTRIBUTE commands
|
||||||
|
- Localization now works again, see Localizer how it is done
|
||||||
|
- reorganized localization commands are now:
|
||||||
|
LOCALIZE mime$, LOCALIZE STOP, LOCALIZE, TRANSLATE$ and MENU TRANSLATE$
|
||||||
|
- SUBMENU SET "Remove" now implemented
|
||||||
|
- yab cleaned up (a bit at least)
|
||||||
|
- yab IDE cleaned up
|
||||||
|
- BuildFactory cleaned up
|
||||||
|
- yab-Commands documentation cleaned up
|
||||||
|
|
||||||
|
yab Version 1.6 Changes from Version 1.5
|
||||||
|
- removed all ZETA and BeOS dependencies
|
||||||
|
- SPINCONTROL look updated to Haiku style
|
||||||
|
- CALENDAR look updated to Haiku style and code refactored
|
||||||
|
- TABVIEW look updated to Haiku style
|
||||||
|
- TABVIEW now supports bottom tabs (like it did on ZETA)
|
||||||
|
- Haiku native tooltips are now used; they still suck, but this finally
|
||||||
|
resolves the race condition bug (this should also resolve the hanging
|
||||||
|
BuildFactory, thx to clasqm for reporting)
|
||||||
|
- using "copy" for an empty selection in TEXTEDIT does not clear the
|
||||||
|
clipboard anymore (thx to streakx for reporting)
|
||||||
|
- Haiku forced a minimum button height, yab does not like force (thx to
|
||||||
|
Lelldorin for reporting)
|
||||||
|
- Title in BOXVIEW is now shown correctly (thx to Lelldorin for reporting)
|
||||||
|
- Window flags don't reset anymore after calling WINDOW SET (thx to clasqm
|
||||||
|
for reporting)
|
||||||
|
|
||||||
|
Known problems:
|
||||||
|
- Tooltips cannot be unset, they cannot change color, they steal focus (fixed on
|
||||||
|
new Haiku builds), they suck (blame the Haiku team ;))
|
||||||
|
- Tooltips do not work for all Widgets
|
||||||
|
- Spincontrol cannot move shift-tab backwards
|
||||||
|
|
||||||
|
Other Fixes (1.6):
|
||||||
|
- Scrolling in the yab IDE works again with new Haiku builds (the bug in Haiku
|
||||||
|
got fixed, thx to leszek for reporting, thx for zooey for fixing)
|
||||||
|
|
||||||
30
Documentation/Credits
Normal file
30
Documentation/Credits
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
Credits
|
||||||
|
|
||||||
|
yab is yabasic for Haiku done by Jan Bungeroth (jan@be-logos.org).
|
||||||
|
|
||||||
|
yab would not be possible without a lot of support. Thanks go to (in no particular order):
|
||||||
|
|
||||||
|
Source Code:
|
||||||
|
Marc-Oliver Ihm (yabasic)
|
||||||
|
Alex Sarikov (CalendarControl)
|
||||||
|
William Kakes (URLView)
|
||||||
|
YNOP (SplitPane)
|
||||||
|
DarkWyrm (Spinner)
|
||||||
|
Brent Miszalski (TexView)
|
||||||
|
Michael Lloyd Lee (AutoTextView)
|
||||||
|
Marco Nelissen (BubbleHelper)
|
||||||
|
Marc Flerackers and Stephan Assmus (Haiku TabView)
|
||||||
|
Axel Dörfler (Haiku tooltips)
|
||||||
|
|
||||||
|
Alpha and Beta Testing and Feature Nagging:
|
||||||
|
Michel Clasquin
|
||||||
|
bbjimmy
|
||||||
|
Lelldorin
|
||||||
|
lorglas
|
||||||
|
Ralf Schuelke
|
||||||
|
DasJott
|
||||||
|
Lukas Linemayr
|
||||||
|
and others
|
||||||
|
|
||||||
|
Translation:
|
||||||
|
Begasus for the Dutch yab-IDE locale
|
||||||
22
Documentation/License
Normal file
22
Documentation/License
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
Licensing yab or your yab program
|
||||||
|
|
||||||
|
yab is distributed under the Artistic License which is an
|
||||||
|
approved open source license. Read the file ARTISTIC for
|
||||||
|
details.
|
||||||
|
|
||||||
|
Basically the Artistic License allows you to:
|
||||||
|
- bind your program to yab and release it under any license you wish;
|
||||||
|
especially you are allowed to sell your program commercially, when bound
|
||||||
|
- compile your program with the BuildFactory and release it under any license you wish;
|
||||||
|
especially you are allowed to sell your program commercially
|
||||||
|
- copy and distribute yab freely
|
||||||
|
- copy or distribute yab as part of a distribution
|
||||||
|
- modify yab
|
||||||
|
- distribute a modified yab freely without releasing the source code
|
||||||
|
|
||||||
|
For distributing a modified yab commercially, you should contact me first.
|
||||||
|
The following parts of yab are not allowed in commercially modified
|
||||||
|
versions without the permission of the authors:
|
||||||
|
SplitPane
|
||||||
|
|
||||||
|
Changes to CalanderControl have to be republished under GPL.
|
||||||
12
Documentation/TODO
Normal file
12
Documentation/TODO
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
ToDo
|
||||||
|
|
||||||
|
Features:
|
||||||
|
- LPT and COM signal send/receive, specific request by lorglas
|
||||||
|
- Layout
|
||||||
|
|
||||||
|
Bugs:
|
||||||
|
- drop file bug ide
|
||||||
|
- strings cannot handle chr$(0)
|
||||||
|
- TEXTEDIT selection somehow buggy, seems to be a Haiku issue
|
||||||
|
- SOUND commands don't work because of a missing API call in Haiku
|
||||||
|
- printing seems to be broken (further testing needed)
|
||||||
835
Documentation/yab-Commands
Normal file
835
Documentation/yab-Commands
Normal file
@@ -0,0 +1,835 @@
|
|||||||
|
-= A =-
|
||||||
|
|
||||||
|
ALERT Text$, ButtonLabel$, Type$
|
||||||
|
Opens an alert window with Text$ and the button Label$ of type Type$
|
||||||
|
Type$ = "none/info/idea/warning/stop"
|
||||||
|
Selected = ALERT Text$, Button1$, Button2$, Button3$, Type$
|
||||||
|
A more general Alert window. Specify a text and up to three buttons.
|
||||||
|
If Button2$ or Button3$ is set to "", the button is not shown.
|
||||||
|
The selected button is returned, where Selected = 1 is the left, 2 the middle and 3 the right button.
|
||||||
|
Type$ = "none/info/idea/warning/stop"
|
||||||
|
ATTRIBUTE SET Type$, Name$, Value$, Filename$
|
||||||
|
Set the attribute Name$ of type Type$ for the file Filename$ with the string Value$.
|
||||||
|
These are valid types Type$:
|
||||||
|
"String", "Int", "Long", "Double", "Float", "Mime", "Bool"
|
||||||
|
ues a value$ of "true" or "false" for Bool type attributes
|
||||||
|
ATTRIBUTE CLEAR Name$, Filename$
|
||||||
|
Delete the attribute Name$ from file Filename$.
|
||||||
|
Value$ = ATTRIBUTE GET$ Name$, Filename$
|
||||||
|
Get the string value of the attribute Name$ for file Filename$.
|
||||||
|
Returns "true" or "false" for "Bool" type attributes.
|
||||||
|
Value = ATTRIBUTE GET Name$, Filename$
|
||||||
|
Get the number value of the attribute Name$ for file Filename$.
|
||||||
|
|
||||||
|
|
||||||
|
-= B =-
|
||||||
|
|
||||||
|
BITMAP Width, Height, ID$
|
||||||
|
Creates a new bitmap in memory, you can draw on it
|
||||||
|
A bitmap is always initialized with a white transparent background
|
||||||
|
color = BITMAP COLOR x,y, ID$, ColorPart$
|
||||||
|
ColorPart$ = "red" or "green" or "blue"
|
||||||
|
Returns the color of the pixel at position (x,y) of the bitmap ID$
|
||||||
|
BITMAP GET x1, y1 to x2, y2, Target_bitmap$, Source_bitmap$
|
||||||
|
Copies specified area of Source_bitmap$ to Target_bitmap$.
|
||||||
|
BITMAP GET IconSize, Bitmap$, File$
|
||||||
|
Copies the icon, shown in Tracker, of File$ in the specified IconSize onto Bitmap$.
|
||||||
|
BITMAP GET ID$, Option$, Path$
|
||||||
|
copies an icon to a bitmap
|
||||||
|
An Option can be:
|
||||||
|
"Path" = Path$ must be the path to a file
|
||||||
|
"Mime" or "Mime16" = Path$ must be the mimetype of the file which icon is to be swown.
|
||||||
|
The resulting bitmap is 16 to 16.
|
||||||
|
"Mime32" = Path$ must be the mimetype of the file which icon is to be swown.
|
||||||
|
The resulting bitmap is 32 to 32.
|
||||||
|
BITMAP GET ID$, Option$
|
||||||
|
Option$ = "height" or "width" delivers height and width of bitmap ID$
|
||||||
|
BITMAP REMOVE Bitmap$
|
||||||
|
Removes Bitmap$ from memory
|
||||||
|
ErrCode = BITMAP IMAGE ImageFile$, Bitmap$
|
||||||
|
Load image file ImageFIle$ into a new Bitmap called Bitmap$
|
||||||
|
ErrCode = BITMAP SAVE Bitmap$, FileName$, Format$
|
||||||
|
Saves a bitmap as FileName$ (overwrites existing ones!) in a Format$ of one of the following:
|
||||||
|
{"png", "tiff", "ppm", "bmp", "jpeg", "tga"}
|
||||||
|
ErrCode = 0 everything worked fine
|
||||||
|
ErrCode = 1 file could not be saved
|
||||||
|
BOXVIEW x1,y1 TO x2,y2, ID$, Label$, LineType, View$
|
||||||
|
Adds a box, note: the actual view of the BOXVIEW (where you can place your widgets) is at
|
||||||
|
(x1+5,y1+10) to (x2-5,y2-5). This may be a subject of change!
|
||||||
|
LineType = 0 means no border
|
||||||
|
LineType = 1 means simple line border
|
||||||
|
LineType = 2 means fancy line border
|
||||||
|
BUTTON x1,y1 TO x2,y2, ID$, Label$, View$
|
||||||
|
Sets a button at position (x1,y1) to (x2,y2) with label Label$ on the view View$
|
||||||
|
BUTTON IMAGE x,y, ID$, EnabledPressed$, EnabledNormal$, Disabled$, View$
|
||||||
|
Create an image button at (x,y) on View$ with three files:
|
||||||
|
EnabledNormal$ The image of the released button
|
||||||
|
EnabledPressed$ The image of the pressed button
|
||||||
|
Disabled$ The image of the disabled button (you can put in an empty string "" if you don't need a
|
||||||
|
disabled button)
|
||||||
|
|
||||||
|
|
||||||
|
-= C =-
|
||||||
|
|
||||||
|
CALENDAR x,y, ID$, Format$, Date$, View$
|
||||||
|
Open a calendar widget at (x,y), giving the format, the date and put that on the view View$.
|
||||||
|
Format$ = ("DDMMYYYY" or "MMDDYYYY") + ("." or "/" or "-"); default: "DDMMYYYY."
|
||||||
|
CALENDAR SET Calendar$, Date$
|
||||||
|
Set the date according to the current format (DDMMYYYY or MMDDYYYY).
|
||||||
|
date$ = CALENDAR GET$ Calendar$
|
||||||
|
Get the current date selected in Calendar$.
|
||||||
|
CANVAS x1,y1 to x2,y2, ID$, View$
|
||||||
|
A canvas is a special view for flicker-free drawing. It always shows a bitmap
|
||||||
|
and thus cannot be resized. However, it does not have a drawing queue, so you
|
||||||
|
do not need DRAW FLUSH
|
||||||
|
A canvas is always initialized with a white background
|
||||||
|
CHECKBOX x1,y1, ID$, Label$, IsActivated, View$
|
||||||
|
Display a checkbox at (x1,y1) with Label$ on View$; if IsActivated is set to 0, the checkbox is
|
||||||
|
off else it is on.
|
||||||
|
CHECKBOX SET CheckBox$, IsActivated
|
||||||
|
(De-)Activate the check box CheckBox$.
|
||||||
|
CHECKBOX IMAGE x,y, ID$, EnabledOn$, EnabledOff$, DisabledOn$, DisabledOff$, IsActivated, View$
|
||||||
|
Create an image checkbox at (x,y) on View$ with four files:
|
||||||
|
EnabledNormal$ The image of the released checkbox
|
||||||
|
EnabledPressed$ The image of the pressed checkbox
|
||||||
|
DisabledNormal$ The image of the normal disabled checkbox (you can put in an empty string ""
|
||||||
|
if you don't need a disabled button)
|
||||||
|
DisabledPressed$ The image of the pressed disabled checkbox (you can put in an empty string ""
|
||||||
|
if you don't need a disabled button)
|
||||||
|
Set isActivated to true/false when the checkbox should be on/off.
|
||||||
|
CLIPBOARD COPY Text$
|
||||||
|
Copy Text$ to the system clipboard.
|
||||||
|
Text$ = CLIPBOARD PASTE$
|
||||||
|
Paste ASCII text from the system clipboard into Text$.
|
||||||
|
COLORCONTROL x,y, ID$, View$
|
||||||
|
Create a color control widget at x,y. Note: it's width is 276 and it's height is 54 pixels.
|
||||||
|
COLORCONTROL SET ColorControl$, r,g,b
|
||||||
|
Set the color control ID$ to the color r,g,b.
|
||||||
|
Value = COLORCONTROL GET ColorControl$, "Red|Blue|Green"
|
||||||
|
Get the currently selected red/green/blue value of the colorcontrol.
|
||||||
|
COLUMNBOX x1,y1 TO x2,y2, ID$, HasHScrollbar, Option$, View$
|
||||||
|
HasHScrollbar is true, when the columnbox should get a horizontal scrollbar (it always has a vertical).
|
||||||
|
Option$ affects all columns! The columns can be made movable, resizable, removable
|
||||||
|
Option$ = "movable, resizable, popup, removable"
|
||||||
|
Option$ = "no-border" sets up the columnbox without border
|
||||||
|
COLUMNBOX COLUMN ColumnBox$, Name$, Position, MaxWidth, MinWidth, Width, Option$
|
||||||
|
Option$ = "align-left, align-center, align-right"
|
||||||
|
COLUMNBOX ADD ColumnBox$, Column, Row, Height, Item$
|
||||||
|
If Item$ = "__Icon__="+FileName$ then the image file FileName$ will be shown,
|
||||||
|
if Item$ = "__Path__="+FileName$ then the large Trackericon of the file FileName$ will be shown
|
||||||
|
if Item$ = "__Mime__="+Signature$ then the small icon of the mime type Signature$ will be shown
|
||||||
|
COLUMNBOX SELECT ColumnBox$, Row
|
||||||
|
Selects Row of ColumnBox$.
|
||||||
|
Row = 0 means deselect.
|
||||||
|
COLUMNBOX REMOVE ColumnBox$, Row
|
||||||
|
Removes the entries in Row of ColumnBox$
|
||||||
|
COLUMNBOX CLEAR ColumnBox$
|
||||||
|
Removes all entries of ColumnBox$.
|
||||||
|
COLUMNBOX COLOR ColumnBox$, Option$, r,g,b
|
||||||
|
Option$ = "selection-text, non-focus-selection, selection, text, row-divider, background"
|
||||||
|
n = COLUMNBOX COUNT ColumnBox$
|
||||||
|
Returns the number of entries in ColumnBox$.
|
||||||
|
Item$ = COLUMNBOX GET$ ColumnBox$, Column, Row
|
||||||
|
Returns the entry at Row in Column of Columbox$.
|
||||||
|
|
||||||
|
|
||||||
|
-= D =-
|
||||||
|
|
||||||
|
DRAW TEXT x1,y1, Text$, View$
|
||||||
|
Draws text at position (x1,y1) on View$
|
||||||
|
DRAW RECT x1,y1 TO x2,y2, View$
|
||||||
|
Draws a rectangle from (x1,y1) to (x2,y2) in the current high color on View$
|
||||||
|
DRAW BITMAP x,y, Bitmap$, Mode$, View$
|
||||||
|
Draw a bitmap on a view, another bitmap or a canvas.
|
||||||
|
Possible Mode$:
|
||||||
|
"Copy" -- copy the bitmap to the target ignoring transparency
|
||||||
|
"Alpha" -- copy the bitmap to the target supporting transparency
|
||||||
|
DRAW BITMAP x1,y1 TO x2,y2, Bitmap$, Mode$, View$
|
||||||
|
Draws and scales the bitmap Bitmap$.
|
||||||
|
If x2 is set to -1, the width is scaled according to the height;
|
||||||
|
if y2 is set to -1, the height is scaled according to the width;
|
||||||
|
if x2 and y2 are set to -1, the image is not scaled at all (this is like DRAW BITMAP x,y, Bitmap$, Mode$, View$).
|
||||||
|
Possible Mode$:
|
||||||
|
"Copy" -- copy the bitmap to the target ignoring transparency
|
||||||
|
"Alpha" -- copy the bitmap to the target supporting transparency
|
||||||
|
DRAW DOT x1,y1, View$
|
||||||
|
DRAW LINE x1,y1 TO x2,y2, View$
|
||||||
|
DRAW CIRCLE x1,y1, Radius, View$
|
||||||
|
DRAW CURVE x1,y1, x2,y2, x3,y3, x4,y4, View$
|
||||||
|
DRAW ELLIPSE x1,y1, xRadius, yRadius, View$
|
||||||
|
DRAW FLUSH View$
|
||||||
|
Deletes all former drawing commands from the drawing queue on View$
|
||||||
|
LoadError = DRAW IMAGE x,y, ImageFile$, View$
|
||||||
|
Draws the image ImageFile$ at position x,y on View$, returns LoadError
|
||||||
|
LoadError:
|
||||||
|
0 = success
|
||||||
|
1 = file not found
|
||||||
|
2 = translator roster not found
|
||||||
|
3 = translation failed
|
||||||
|
4 = ditaching bitmap failed
|
||||||
|
err = DRAW IMAGE x1,y1 TO x2,y2, Image$, View$
|
||||||
|
Draws and scales the image file Image$. Transparent images are set correctly now.
|
||||||
|
If x2 is set to -1, the width is scaled according to the height;
|
||||||
|
if y2 is set to -1, the height is scaled according to the width;
|
||||||
|
if x2 and y2 are set to -1, the image is not scaled at all (this is like DRAW IMAGE x1,y1, Image$, View$).
|
||||||
|
Width = DRAW GET "Text-Width", Text$, View$
|
||||||
|
Return the width in pixel of the string Text$ in the current font of View$.
|
||||||
|
Height = DRAW GET "Max-Text-Height", View$
|
||||||
|
Return the maximum height in pixel of the current font of View$. This is the size of the font plus
|
||||||
|
how far characters can descend below the baseline.
|
||||||
|
FontFamilies$ = DRAW GET$ "FontFamily"
|
||||||
|
Returns a list of all installed fonts separated by "|".
|
||||||
|
FontStyles$ = DRAW GET$ FontFamily$
|
||||||
|
Returns a list of all font styles for a font FontFamily$ separated by "|".
|
||||||
|
DRAW SET FillOrStroke, Pattern$
|
||||||
|
FillOrStroke = 0 means fill
|
||||||
|
FillOrStroke = 1 means stroke
|
||||||
|
Pattern$ is a 8x8 1 bit map; one line is one character
|
||||||
|
Pattern$ = "HighSolidFill" means solid fill with the current high color
|
||||||
|
Pattern$ = "LowSolidFill" means solid fill with the current low color (default)
|
||||||
|
Pattern$ = "CheckeredFill" means checkered fill
|
||||||
|
DRAW SET Color$, r,g,b, View$
|
||||||
|
Color$ is one of the following:
|
||||||
|
"BGColor", r,g,b (216,216,216 default)
|
||||||
|
"HighColor", r,g,b (0,0,0 default)
|
||||||
|
"LowColor", r,g,b (216,216,216 default)
|
||||||
|
DRAW SET Color$, Option$, View$
|
||||||
|
Option$ is one of the following:
|
||||||
|
"Panel-Background-Color"
|
||||||
|
"Panel-Text-Color"
|
||||||
|
"Panel-Link-Color"
|
||||||
|
"Menu-Background-Color"
|
||||||
|
"Menu-Selection-Background-Color"
|
||||||
|
"Menu-Item-Text-Color"
|
||||||
|
"Menu-Selected-Item-Text-Color"
|
||||||
|
"Keyboard-Navigation-Color"
|
||||||
|
"Jan-Favorite-Color"
|
||||||
|
|
||||||
|
To those options the following can be added:
|
||||||
|
"Lighten-1-Tint"
|
||||||
|
"Lighten-2-Tint"
|
||||||
|
"Lighten-Max-Tint"
|
||||||
|
"Darken-1-Tint"
|
||||||
|
"Darken-2-Tint"
|
||||||
|
"Darken-3-Tint"
|
||||||
|
"Darken-4-Tint"
|
||||||
|
"Darken-Max-Tint"
|
||||||
|
"Disabled-Label-Tint"
|
||||||
|
"Disabled-Mark-Tint"
|
||||||
|
"Highlight-Background-Tint"
|
||||||
|
|
||||||
|
Example:
|
||||||
|
draw set "bgcolor", "Menu-Background-Color, Lighten-1-Tint", View$
|
||||||
|
|
||||||
|
DRAW SET Font$, View$
|
||||||
|
Set the drawing font on View$.
|
||||||
|
Font$ = FontFamily$ + "," + FontStyle$ + "," + Size + "," + FontOption$ + "," Rotation + "," + Shear
|
||||||
|
where FontOption$ can contain the following options (only used when supported by the font):
|
||||||
|
FontOption$ = "bold" or "italic" or "outlined" or "underscore" or "strikeout" or "regular" (regular is default)
|
||||||
|
where Rotation is between 0.0 (default) and 360.0
|
||||||
|
where Shear is between 45.0 (slanted to right) and 135.0 (slanted to left) with 90.0 default
|
||||||
|
|
||||||
|
or Font$ = "system-plain" for the plain system font,
|
||||||
|
or Font$ = "system-bold" for the bold system font,
|
||||||
|
or Font$ = "system-fixed" for the fixed system font
|
||||||
|
DRAW SET "Alpha", Alpha-Value
|
||||||
|
Sets the Alpha-Channel for the transparency of the drawing colors. Use this before setting the color
|
||||||
|
with DRAW COLOR.
|
||||||
|
Alpha-Value is a value between 0 and 255 where 0 is total transparency and 255 is opaque.
|
||||||
|
Note: When Alpha-Value is below 255, use only HighSolidFill, patterns are ignored!
|
||||||
|
Note: Transparent drawing (that is Alpha-Value below 255) is not printed (see PRINTER) correctly!
|
||||||
|
DROPBOX x1,y1 TO x2,y2, ID$, Label$, View$
|
||||||
|
Adds an empty dropbox (BMenuField) at (x1,y1) to (x2,y2) known as ID$ and with a label on View$.
|
||||||
|
DROPBOX ADD DropBox$, Item$
|
||||||
|
Add Item$ to the dropbox. Use Item$ = "--" for a separator.
|
||||||
|
DROPBOX CLEAR DropBox$
|
||||||
|
Clear the drop box from all items.
|
||||||
|
n = DROPBOX COUNT DropBox$
|
||||||
|
Count the number of items.
|
||||||
|
Item$ = DROPBOX GET$ DropBox$, Position
|
||||||
|
Get the item at Position.
|
||||||
|
DROPBOX REMOVE DropBox$, Position
|
||||||
|
Removes item number Position.
|
||||||
|
Note: If the removed item was marked, the item before it will be marked instead. You will NOT get
|
||||||
|
a message that the marked item has changed. If the first item will be deleted, the next item in
|
||||||
|
the drop box will be marked.
|
||||||
|
Note: Each time an item was removed, the drop box count will change too!
|
||||||
|
DROPBOX SELECT DropBox$, Position
|
||||||
|
Select the item at position Position. Counting starts at 0.
|
||||||
|
|
||||||
|
|
||||||
|
-= F =-
|
||||||
|
|
||||||
|
File$ = FILEPANEL Mode$, Title$, Directory$
|
||||||
|
Mode$ = "Load-File"
|
||||||
|
Mode$ = "Load-Directory"
|
||||||
|
Mode$ = "Load-File-and-Directory"
|
||||||
|
Mode$ = "Save-File"
|
||||||
|
Opens a filepanel in Directory$. According to the Mode$, you can either select a file,
|
||||||
|
a directory or both for loading or select/enter a file for saving. The selected file is File$.
|
||||||
|
File$ = FILEPANEL Mode$, Title$, Directory$, Filename$
|
||||||
|
Same as above, except that you can provide preset Filename$ for the mode "Save-File"
|
||||||
|
|
||||||
|
|
||||||
|
-= I =-
|
||||||
|
|
||||||
|
State = ISMOUSEIN(View$)
|
||||||
|
State = 0 the mouse cursor is not in the view View$
|
||||||
|
State = 1 the mouse cursor is in the view View$
|
||||||
|
|
||||||
|
|
||||||
|
-= K =-
|
||||||
|
|
||||||
|
Msg$ = KEYBOARD MESSAGE$(View$)
|
||||||
|
Works like INKEY$ on the command line (well, nearly; it does not wait for input as inkey$ does).
|
||||||
|
|
||||||
|
|
||||||
|
-= L =-
|
||||||
|
|
||||||
|
LAUNCH FileName$
|
||||||
|
Launch the program FileName$ or the associated executable
|
||||||
|
LAYOUT Layout$, WindowOfView$
|
||||||
|
Set the layout for all views on the window of View$. The layout will affect all following new widgets,
|
||||||
|
but not the already created. Draw commands are not affected by the layout, put them on an own view.
|
||||||
|
Layout$ (not case sensitive):
|
||||||
|
"Standard" = default layout, all widgets follow bottom and right side of the window
|
||||||
|
except for listboxes and textedit which follow all sides.
|
||||||
|
"All" = follow all sides (widgets resize)
|
||||||
|
"None" = follow the top and the left side (equals "top, left")
|
||||||
|
-OR- Layout$ is a combination of a horizontal and a vertical command (e.g. "Right, Top" etc.).
|
||||||
|
Horizontal:
|
||||||
|
"Left" = follow left side (default, when no other horizontal layout is given)
|
||||||
|
"Right" = follow the right side
|
||||||
|
"Left, Right" = follow the left and the right side (resize)
|
||||||
|
"H-Center" = follow the horizontal center
|
||||||
|
Vertical:
|
||||||
|
"Top" = follow the top side (default, when no other vertical layout is given)
|
||||||
|
"Bottom" = follow the bottom side
|
||||||
|
"Top, Bottom" = follow the top and bottom side (resize)
|
||||||
|
"V-Center" = follow the vertical center
|
||||||
|
|
||||||
|
LISTBOX x1,y1 TO x2,y2, ID$, ScrollbarType, View$
|
||||||
|
Adds an empty listbox at (x1,y1) to (x2,y2) known as ID$ and with a ScrollbarType on View$.
|
||||||
|
ScrollbarType:
|
||||||
|
0 = none
|
||||||
|
1 = vertical scrollbars
|
||||||
|
2 = horizontal scrollbars
|
||||||
|
3 = vertical & horizontal scrollbars
|
||||||
|
LISTBOX ADD ListBox$, Item$
|
||||||
|
Add the item Item$ to the listbox; note: this replaces ITEM ADD, which is obsolete and will be removed.
|
||||||
|
LISTBOX ADD ListBox$, Position, Item$
|
||||||
|
Add the item Item$ at the position Position.
|
||||||
|
LISTBOX CLEAR ListBox$
|
||||||
|
removes all entries in ListBox$.
|
||||||
|
n = LISTBOX COUNT ListBox$
|
||||||
|
Count the number of entries in the list box ListBox$
|
||||||
|
Entry$ = LISTBOX GET$ ListBox$, Row
|
||||||
|
Returns the Entry$ of Row in ListBox$.
|
||||||
|
LISTBOX REMOVE ListBox$, Item$
|
||||||
|
Removes an item Item$ from the Listbox ID$.
|
||||||
|
LISTBOX REMOVE ListBox$, Position
|
||||||
|
Remove the item at position Position.
|
||||||
|
LISTBOX SELECT ListBox$, Position
|
||||||
|
Select the item at position Position.
|
||||||
|
Position = 0 means deselect
|
||||||
|
LISTBOX SORT Listbox$
|
||||||
|
Sort the entries of ListBox$ alphabetically.
|
||||||
|
LOCALIZE Mimetype$
|
||||||
|
Initialize automatic translation and use the locale mimetype Mimetype$. See also the Localizer help program.
|
||||||
|
LOCALIZE STOP
|
||||||
|
Turn automatic translation off.
|
||||||
|
LOCALIZE
|
||||||
|
Turn automatic translation on again.
|
||||||
|
|
||||||
|
|
||||||
|
-= M =-
|
||||||
|
|
||||||
|
MENU Head$, Menu$, Shortcut$, View$
|
||||||
|
Add a menu to the menubar with the menu head Head$, the menu item Menu$ and the shortcut Shortcut$
|
||||||
|
on View$.
|
||||||
|
Shortcut$ can contain the following modifiers at the beginning and the shortcut character at the end:
|
||||||
|
Modifiers$+ShortcutCharacter$
|
||||||
|
"S" for the shift key
|
||||||
|
"C" for the control key
|
||||||
|
"O" for the option key (on most keyboards probably the Windows button)
|
||||||
|
These modifiers can be combined, but the following combinations do not work:
|
||||||
|
"SO", "SC" and "SCO"
|
||||||
|
Note: The command key (ALT) is always part of the shortcut.
|
||||||
|
MENU SET MenuHead$, SetRadioMode, View$
|
||||||
|
Put the menu in radio mode, so up to one item is marked.
|
||||||
|
Note: you have to set the first marked item yourself.
|
||||||
|
MENU SET MenuHead$, MenuItem$, Option$, View$
|
||||||
|
Enable/Disable or mark/unmark or remove a menu item.
|
||||||
|
Option$ = "Disable|Enable|Mark|Plain|Remove"
|
||||||
|
Translation$ = MENU TRANSLATE$(Source$)
|
||||||
|
Translation$ holds the translation of Source$. Different to TRANSLATE$, the Source$ is splitted at colons : and
|
||||||
|
and the string parts are translated separatly. This is useful for comparing translated menu messages.
|
||||||
|
E.g.
|
||||||
|
if(myMenuMessage$ = menu translate$("File:Open")) ...
|
||||||
|
msg$ = MESSAGE$
|
||||||
|
Collects the messages generated by the GUI elements.
|
||||||
|
Arrived = MESSAGE SEND Application$, Message$
|
||||||
|
Send a string to the yab application with signature Application$
|
||||||
|
(default signature is: "application/x-vnd.yab-app", you can change the signature when you add
|
||||||
|
a comment in the first or second line of your program like this:
|
||||||
|
// mimetype "application/x-vnd.myapp"
|
||||||
|
Note: this does not work for bound programs currently!)
|
||||||
|
The destination yab application will produce a message$ stating:
|
||||||
|
_Scripting:...|
|
||||||
|
where the ... are the Message$.
|
||||||
|
The command returns one of the following error codes:
|
||||||
|
0: Message was delivered
|
||||||
|
1: The destination program was not found
|
||||||
|
2: The target's message queue is full
|
||||||
|
3: Time out, the message never made it to the target
|
||||||
|
4: An other error occurred
|
||||||
|
mouse$ = MOUSE MESSAGE$(View$)
|
||||||
|
Returns the state of the mouse related to View$.
|
||||||
|
It consists out of X:Y:LMB:MMB:RMB (where MB is the corresponding left, middle, right mousebutton).
|
||||||
|
mouse$ = MOUSE MESSAGE$
|
||||||
|
Returns the state of the mouse related to the application.
|
||||||
|
It consists out of VIEW:X:Y:LMB:MMB:RMB (where VIEW is the View$ the mouse is over, MB is the
|
||||||
|
corresponding left, middle, right mousebutton).
|
||||||
|
MOUSE SET Option$
|
||||||
|
Hide or show the mouse cursor for this application.
|
||||||
|
Option$ = "Hide" -- hide the mouse cursor
|
||||||
|
Option$ = "Show" -- show the mouse cursor
|
||||||
|
Option$ = "Obscure" -- hide the mouse cursor until the mouse is moved
|
||||||
|
|
||||||
|
|
||||||
|
-= O =-
|
||||||
|
|
||||||
|
OPTION SET View$, "Auto-Resize"
|
||||||
|
Automatically resize the view View$ to preferred (when this is supported by the view).
|
||||||
|
OPTION SET View$, "Focus", HasFocus
|
||||||
|
Set/remove the focus of View$ (when this is supported by the view).
|
||||||
|
OPTION SET Control$, "Enabled", IsEnabled
|
||||||
|
Enable/disable the control Control$.
|
||||||
|
OPTION SET Control$, "Label", NewLabel$
|
||||||
|
Give a Control a new label.
|
||||||
|
OPTION SET Control$, "Visible", IsVisible
|
||||||
|
Set the control Control$ unvisible or visible
|
||||||
|
Note: The following widgets are controls:
|
||||||
|
CHECKBOX, RADIOBUTTON, SLIDER, TEXTCONTROL, BUTTON, COLORCONTROL, SPINCONTROL, CALENDAR
|
||||||
|
OPTION COLOR View$, "BGColor", r,g,b
|
||||||
|
Set the background color of any view (note: this is different to DRAW SET!)
|
||||||
|
|
||||||
|
|
||||||
|
-= P =-
|
||||||
|
|
||||||
|
x = PEEK("DesktopWidth")
|
||||||
|
Returns the current X-resolution of the current desktop
|
||||||
|
y = PEEK("DesktopHeight")
|
||||||
|
Returns the current Y-resolution of the current desktop
|
||||||
|
x = PEEK("Deskbar-x")
|
||||||
|
Returns the position of the left side of the Deskbar
|
||||||
|
y = PEEK("Deskbar-y")
|
||||||
|
Returns the position of the top side of the Deskbar
|
||||||
|
w = PEEK("DeskbarWidth")
|
||||||
|
Returns the height of the Deskbar
|
||||||
|
h = PEEK("DeskbarHeight")
|
||||||
|
Returns the width of the Deskbar
|
||||||
|
p = PEEK("Deskbarposition")
|
||||||
|
Returns the position of the Deskbar as follows (clockwise):
|
||||||
|
1 = top-left
|
||||||
|
2 = top
|
||||||
|
3 = top-right
|
||||||
|
4 = bottom-right
|
||||||
|
5 = bottom
|
||||||
|
6 = bottom-left
|
||||||
|
i = PEEK("Deskbarexpanded")
|
||||||
|
Returns true if the Deskbar is expanded (only possibe in position 1 and 3) and false if not.
|
||||||
|
Height = PEEK("menuheight")
|
||||||
|
Returns the height of the menu (which is related to the user's font settings).
|
||||||
|
This returns the height only when any window already has a menu, otherwise it returns -1.
|
||||||
|
Width = PEEK("scrollbarwidth")
|
||||||
|
Returns the width of the scrollbars.
|
||||||
|
Different to "menuheight", it returns the correct width even if no scrollbars are used.
|
||||||
|
Height = PEEK("tabheight")
|
||||||
|
Returns the height of the tabfield.
|
||||||
|
Directory$ = PEEK$("directory")
|
||||||
|
Returns application directory. Use this in the following way:
|
||||||
|
if (peek("isbound")) then
|
||||||
|
Directory$ = peek$("directory")
|
||||||
|
else
|
||||||
|
Directory$ = system$("pwd")
|
||||||
|
endif
|
||||||
|
TrackerItem$ = PEEK$("refsreceived")
|
||||||
|
Returns TrackerItem which you used 'open with...' your application on.
|
||||||
|
Selected$ = POPUPMENU x,y, MenuItems$, View$
|
||||||
|
Pop up a menu at position (x,y) on View$ with the menu items MenuItems$ which are separated
|
||||||
|
by "|". Waits until an item is selected and returns it's label as Selected$.
|
||||||
|
PRINTER SETUP SetupFile$
|
||||||
|
Setup the printing enviroment and store it in file named SetupFile$.
|
||||||
|
PrintingError = PRINTER JobName$, SetupFile$, View$
|
||||||
|
Load the settings from SetupFile$ (or ask for them when the file is invalid) and print
|
||||||
|
the view View$ as the job named JobName$.
|
||||||
|
Note: Alpha transparency is not printed correctly!
|
||||||
|
Note: Due to a bug in BeOS and ZETA, there are probably problems printing CHECKBOX IMAGE and
|
||||||
|
BUTTON IMAGE images, use DRAW IMAGE instead!
|
||||||
|
Note: currently untested in Haiku
|
||||||
|
Error codes for PrintingError:
|
||||||
|
0 = No Problems
|
||||||
|
1 = Page setup failed (probably communication problems with the print server)
|
||||||
|
2 = The configuration file was loaded but page setup failed
|
||||||
|
3 = The view View$ was not found
|
||||||
|
4 = The number of pages is 0 or less
|
||||||
|
5 = The printing was canceled or something went wrong with printing
|
||||||
|
Note: PrintingError = 4 can happen because of a bug in the PDF printing driver; although
|
||||||
|
a page size is shown, none is selected. If this happens, you may want to call a PRINTER SETUP
|
||||||
|
for the user and try to print again.
|
||||||
|
Note: When an error with code 1,2,3 or 4 occurs, you can be shure that nothing was sent to the printer yet.
|
||||||
|
|
||||||
|
|
||||||
|
-= R =-
|
||||||
|
|
||||||
|
RADIOBUTTON x1,y1, ID$, Label$, IsActivated, View$
|
||||||
|
Add a radio button at (x1,y1) and Label$ on View$. If isActivated is set to 0, the radio button is
|
||||||
|
off else it is on. Radio buttons should be grouped together in one view.
|
||||||
|
RADIOBUTTON SET RadioButton$, IsActivated
|
||||||
|
(De-)Activate the radio button RadioButton$.
|
||||||
|
|
||||||
|
|
||||||
|
-= S =-
|
||||||
|
|
||||||
|
SCREENSHOT x1, y1 to x2, y2, Bitmap$
|
||||||
|
Takes a screenshot and copies the specified region of the desktop onto Bitmap$, which will be created!
|
||||||
|
SCROLLBAR ID$, ScrollbarType, View$
|
||||||
|
Make View$ scrollable.
|
||||||
|
SCROLLBAR SET Scrollbar$, Borderoption$
|
||||||
|
Borderoption$ = "no-border" or "plain-border" or "fancy-border" (default)
|
||||||
|
SCROLLBAR SET Scrollbar$, "Vertical Position", Position
|
||||||
|
SCROLLBAR SET Scrollbar$, "Horizontal Position", Position
|
||||||
|
Set the scrollbar to the position Position. Default is (0,0).
|
||||||
|
SCROLLBAR SET Scrollbar$, "Vertical Range", Min, Max
|
||||||
|
SCROLLBAR SET Scrollbar$, "Horizontal Range", Min, Max
|
||||||
|
Set the scrollbars to a maximum range, default is (1000,1000).
|
||||||
|
Note: the Max value will be added to the view's actual width/height.
|
||||||
|
SCROLLBAR SET Scrollbar$, "Vertical Steps", SmallSteps, BigSteps
|
||||||
|
SCROLLBAR SET Scrollbar$, "Horizontal Steps", SmallSteps, BigSteps
|
||||||
|
Set the scrollbar steps.
|
||||||
|
SmallSteps are the scrolling steps when the user clicks on the arrow buttons (default is 1.0).
|
||||||
|
BigSteps are the scrolling steps when the user clicks on the empty part of the scrollbar (default is 10.0).
|
||||||
|
Position = SCROLLBAR GET Scrollbar$, "Horizontal"
|
||||||
|
Position = SCROLLBAR GET Scrollbar$, "Vertical"
|
||||||
|
Get the current position of the scrollbars.
|
||||||
|
SHORTCUT View$, Shortcut$, MyMessage$
|
||||||
|
Set a key Shortcut$ on View$, giving back the Message$ when used.
|
||||||
|
This is comparable to the shortcuts used in menus, but NOTE:
|
||||||
|
in opposite to a menu, you can't use command -X, -C, -V, -A, -W, -Q !
|
||||||
|
SLIDER x1,y1 TO x2,y2, ID$, Label$, Min, Max, View$
|
||||||
|
Add a slider with a minimum and and a maximum value (Min, Max).
|
||||||
|
SLIDER x1,y1 TO x2,y2, ID$, Label$, Min, Max, Option$, View$
|
||||||
|
Option$ = "block/triangle, horizontal/vertical"
|
||||||
|
SLIDER LABEL Slider$, StartLabel$, EndLabel$
|
||||||
|
Set start and end limit labels
|
||||||
|
SLIDER SET Silder$, Location$, Count
|
||||||
|
Set the hashmarks.
|
||||||
|
Note: The Zeta sliders do not distinguish between top/bottom/left/right marks, just use "both"
|
||||||
|
Location$ = "none/bottom/top/both" use hashmarks for horizontal sliders
|
||||||
|
Location$ = "none/left/rigth/both" use hashmarks for vertical sliders
|
||||||
|
Count = number of hashmarks
|
||||||
|
SLIDER COLOR Silder$, Part$, r,g,b
|
||||||
|
Part$ = "barcolor"
|
||||||
|
Part$ = "fillcolor"
|
||||||
|
SLIDER SET Silder$, Value
|
||||||
|
Set the slider to Value.
|
||||||
|
Value = SLIDER GET Slider$
|
||||||
|
Get the currently selected value of the slider.
|
||||||
|
ID = SOUND PLAY SoundFile$
|
||||||
|
Play the sound file SoundFile$ (can be anything like wav, mp3, etc.).
|
||||||
|
You are given an ID to handle the playback later in your code.
|
||||||
|
Note: Currently not supported by Haiku!
|
||||||
|
SOUND STOP ID
|
||||||
|
Stop the sound with ID
|
||||||
|
SOUND WAIT ID
|
||||||
|
Waits until the sound with ID is finished playing.
|
||||||
|
SPINCONTROL x,y, ID$, Label$, Min, Max, Step, View$
|
||||||
|
Set a spin control for the range (Min,Max), counting by Step.
|
||||||
|
SPINCONTROL SET SpinControl$, Value
|
||||||
|
Set the spin control SpinControl$ to Value.
|
||||||
|
Value = SPINCONTROL GET SpinControl$
|
||||||
|
Get the current spin control value.
|
||||||
|
SPLITVIEW x1,y1 TO x2,y2, ID$, IsVerticalSplit, NormalStyle, View$
|
||||||
|
Set up the new view ID$ and split it into two new views ID$+"1" and ID$+"2".
|
||||||
|
If IsVerticalSplit = true, a vertical splitter is set,
|
||||||
|
if IsVerticalSplit = false, a horizontal splitter is set.
|
||||||
|
If NormalStyle = true, the splitter is 10 pixels thick,
|
||||||
|
If NormalStyle = false, the splitter is 4 pixels thick.
|
||||||
|
SPLITVIEW SET SplitView$ "Divider", Position
|
||||||
|
Set the position of the divider, default is the half of the total split view.
|
||||||
|
SPLITVIEW SET SplitView$ "MinimumSizes", LeftOrTop, RightOrBottom
|
||||||
|
Set the minimum sizes of the left (or top) view and the right (or bottom) view.
|
||||||
|
Position = SPLITVIEW GET SplitView$, "Divider"
|
||||||
|
Get the current position of the divider.
|
||||||
|
STACKVIEW x1,y1 TO x2,y2, ID$, NumberOfViews, View$
|
||||||
|
Set up a stack of views where only one is always visible.
|
||||||
|
STACKVIEW SET StackView$, ViewNumber
|
||||||
|
Set the view number ViewNumber as the visible view.
|
||||||
|
ViewNumber = STACKVIEW GET StackView$
|
||||||
|
Get the current number of the visible view.
|
||||||
|
STATUSBAR x1, y1 to x2, y2, ID$, Label1$, Label2$, View$
|
||||||
|
Creates a statusbar with ID$ and label(s) on View$.
|
||||||
|
Label1$ is on the left side above the actual bar and so is Label2$ on the right.
|
||||||
|
STATUSBAR SET ID$, Label1$, Label2$, State
|
||||||
|
Sets Statusbar ID$ to State and changes the Labels to specified ones.
|
||||||
|
STATUSBAR SET ID$, r, g, b
|
||||||
|
Set the color of the statusbar
|
||||||
|
STATUSBAR SET ID$, BarHeight
|
||||||
|
Set the height of the statusbar
|
||||||
|
SUBMENU MenuHead$, MenuItem$, SubMenuItem$, Modifier$, View$
|
||||||
|
This is the same as MENU, it just adds a submenu instead. Deeper leveling is not possible
|
||||||
|
in yab, as a deeper menu structure would be bad style anyway.
|
||||||
|
SUBMENU SET MenuHead$, MenuItem$, SetRadioMode, View$
|
||||||
|
Put the submenu in radio mode, so up to one item is marked.
|
||||||
|
Note: you have to set the first marked item yourself.
|
||||||
|
SUBMENU SET MenuHead$, MenuItem$, SubMenuItem$, Option$, View$
|
||||||
|
Enable/Disable or mark/remove a submenu item.
|
||||||
|
Option$ = "Disable|Enable|Mark|Plain|Remove"
|
||||||
|
|
||||||
|
|
||||||
|
-= T =-
|
||||||
|
|
||||||
|
TABVIEW x1,y1 TO x2,y2, ID$, Option$, View$
|
||||||
|
Option$ = "top, bottom" where to place the tabs.
|
||||||
|
TABVIEW ADD TabView$, TabName$
|
||||||
|
For each tab, a new view is created; you can add widgets or draw on these views as ususal.
|
||||||
|
The ids for the views ist TabView$+"1" for the first, TabView$+"2" for the second view, etc.
|
||||||
|
TABVIEW SET TabView$, TabNumber
|
||||||
|
Open the tab number TabNumber.
|
||||||
|
TabNumber = TABVIEW GET TABVIEW$
|
||||||
|
Get the current opened tab.
|
||||||
|
TEXT x,y, ID$, Text$, View$
|
||||||
|
Displays Text$ at position (x,y) on View$. This cannot be flushed like DRAW TEXT and is meant for
|
||||||
|
permanent labels.
|
||||||
|
TEXT x1,y1 TO x2,y2, ID$, Text$, View$
|
||||||
|
Displays Text$ on View$. This cannot be flushed like DRAW TEXT and is meant for permanent labels.
|
||||||
|
Furthermore you can set the alignment for this command with the TEXT SET command.
|
||||||
|
TEXT SET Text$, Alignment$
|
||||||
|
Set the alignment of Text$ to either "align-left", "align-center" or "align-right".
|
||||||
|
TEXTCONTROL x1,y1 TO x2,y2, ID$, Label$, Text$, View$
|
||||||
|
Opens a textcontrol from (x1,y1) to (x2,y2) with Label$ and preset Text$ on View$
|
||||||
|
TEXTCONTROL SET TextControl$, Text$
|
||||||
|
Set the text control's text to Text$.
|
||||||
|
TEXTCONTROL SET TextControl$, IsPassword
|
||||||
|
IsPassword = false Normal typing
|
||||||
|
IsPassword = true Hide typing
|
||||||
|
TEXTCONTROL SET TextControl$, Option$, Value$
|
||||||
|
Option$="align" Value$= "left" / "right" / "center"
|
||||||
|
*** note *** Haiku has issues aligh right. There are open tickets.
|
||||||
|
Option$="exclude", Value$=characters to disallow.
|
||||||
|
Option$="include", Value$=characters to allow.
|
||||||
|
Option$="length", Value$=str$(number) of characters allowed.
|
||||||
|
Sets the font used to the system fixed font.
|
||||||
|
Option$="type"
|
||||||
|
Value$="number" Only allow to characters 0-9 and ".", full stop.
|
||||||
|
Value$=""alphanumeric" allow all characters.
|
||||||
|
Option$="focus" Value$ = "true" / "false" Set the focus of TextControl$.
|
||||||
|
Option$="Curser", Value$=str$(number) positions the curser, sets the focus to true.
|
||||||
|
TEXTCONTROL CLEAR TextControl$
|
||||||
|
Delete the text of the text control.
|
||||||
|
Text$ = TEXTCONTROL GET$ TextControl$
|
||||||
|
Get the entry of the text control TextControl$. Even works, when Return was not pressed.
|
||||||
|
TEXTEDIT x1,y1 TO x2,y2, ID$, ScrollbarType, View$
|
||||||
|
Opens an editor at (x1,y1) to (x2,y2) with ID$ (not displayed) on View$. For the
|
||||||
|
scrollbartypes look at the listbox entry.
|
||||||
|
TEXTEDIT also follows all sides in standard layout.
|
||||||
|
TEXTEDIT ADD TextEdit$, Text$
|
||||||
|
Insert Text$ in the textedit TextEdit$ on View$.
|
||||||
|
TEXTEDIT CLEAR TextEdit$
|
||||||
|
Clears the text from the textedit TextEdit$ on View$.
|
||||||
|
EnteredText$ = TEXTEDIT GET$ TextEdit$
|
||||||
|
EnteredText$ holds the text of the textedit ID$ on View$
|
||||||
|
SelectedText$ = TEXTEDIT GET$ TextEdit$, Option$
|
||||||
|
Returns the current selected text, can be empty of course.
|
||||||
|
Option$ = "Selection"
|
||||||
|
TextLine$ = TEXTEDIT GET$ TextEdit$, LineNumber
|
||||||
|
Width = TEXTEDIT GET TextEdit$, "Line-Width", LineNumber
|
||||||
|
Height = TEXTEDIT GET TextEdit$, "Line-Height", LineNumber
|
||||||
|
LineNumber = TEXTEDIT GET TextEdit$, Option$, Search$
|
||||||
|
LineNumber = Option$ = "Find", Search$
|
||||||
|
LineNumber = Option$ = "Case-Sensitive-Find", Search$
|
||||||
|
LineNumber = TEXTEDIT GET TextEdit$, Option$
|
||||||
|
IsChanged = Option$ = "hasChanged"
|
||||||
|
LineNumber = Option$ = "countlines"
|
||||||
|
LineNumber = Option$ = "currentline"
|
||||||
|
YOffset = Option$ = "vertical-scrollbar"
|
||||||
|
XOffset = Option$ = "horizontal-scrollbar"
|
||||||
|
Position = Option$ = "cursor-position"
|
||||||
|
TextLength = Option$ = "textlength"
|
||||||
|
TEXTEDIT SET TextEdit$, Option$
|
||||||
|
Applys an option to the textedit TextEdit$ on View$.
|
||||||
|
Option$ = "cut, copy, paste, clear, select-all, undo"
|
||||||
|
TEXTEDIT SET TextEdit$, Option$, Value
|
||||||
|
Option$ = "autoindent", true/false
|
||||||
|
Option$ = "wordwrap", true/false
|
||||||
|
Option$ = "editable", true/false
|
||||||
|
Option$ = "color-case-sensitive", true/false
|
||||||
|
Option$ = "changed", true/false
|
||||||
|
Option$ = "gotoline", LineNumber
|
||||||
|
Option$ = "select", LineNumber
|
||||||
|
Option$ = "tabwidth", TabWidth
|
||||||
|
Option$ = "textwidth", TextWidth
|
||||||
|
Option$ = "autocomplete-start"
|
||||||
|
Option$ = "has-autocompletion"
|
||||||
|
Option$= "align", left/center/right
|
||||||
|
Default options are:
|
||||||
|
autoindent = false
|
||||||
|
wordwrap = true
|
||||||
|
editable = true
|
||||||
|
color-case-sensitive = false
|
||||||
|
changed = false
|
||||||
|
has-autocompletion = true
|
||||||
|
autocomplete-start = 4
|
||||||
|
align = left
|
||||||
|
TEXTEDIT SET TextEdit$, Option$, Value$
|
||||||
|
Option$ = "autocomplete"
|
||||||
|
Add a word Value$ to the auto-completion list.
|
||||||
|
Option$ = "font"
|
||||||
|
Set the font to Value$ (similar to DRAW SET); default is "system-plain"
|
||||||
|
TEXTEDIT COLOR TextEdit$, Option$, Command$
|
||||||
|
Option$ = "color1, color2, color3, color4, char-color", Command$
|
||||||
|
Add the command Command$ to the list of words that are checked for syntax highlighting
|
||||||
|
The char-color behaves differently and highlights only the first character of Command$
|
||||||
|
(this happens after the highlighting of the other colors).
|
||||||
|
TEXTEDIT COLOR TextEdit$, Option$, r,g,b
|
||||||
|
Option$ = "bgcolor, textcolor, color1, color2, color3, color4, char-color", r,g,b
|
||||||
|
Default colors are:
|
||||||
|
bgcolor = 255,255,255 (white)
|
||||||
|
textcolor = 0,0,0 (black)
|
||||||
|
color1 = 0,0,255 (blue)
|
||||||
|
color2 = 255,0,0 (red)
|
||||||
|
color3 = 0,250,0 (green)
|
||||||
|
color4 = 185,185,185 (gray)
|
||||||
|
char-color = 200,0,255 (magenta)
|
||||||
|
TEXTURL x,y, ID$, Label$, Address$, View$
|
||||||
|
Set the web/email/ftp address at (x,y) with the label Label$ and the url Address$.
|
||||||
|
This widget is quite nice, it launches the appropriate application when clicked, it supports
|
||||||
|
a right-click popup-menu and you can drag the url to create either a person file or a bookmark.
|
||||||
|
Email can be either of the style: "mailto:foo@bar.com" or just "foo@bar.com"
|
||||||
|
A web url starts either with "http://" or with "file://"
|
||||||
|
And a ftp address starts with "ftp://"
|
||||||
|
TEXTURL COLOR TextURL$, Option$, r,g,b
|
||||||
|
Set the colors for the URL. Valid options are:
|
||||||
|
"Label" for the color of the label,
|
||||||
|
"Click" for the color of the label, when clicked and
|
||||||
|
"Mouse-over" for the color of the label, when the mouse is moved over the label.
|
||||||
|
Id = THREAD GET Option$, Program$
|
||||||
|
Option$ = "TeamID" returns the team ID for the program named Program$
|
||||||
|
Specify the whole path with parameters (only the first 64 characters are important)
|
||||||
|
for the team, the first team with this path and parameters will be returned.
|
||||||
|
Option$ = "ThreadID" returns the thread ID for the program named Program$
|
||||||
|
Specify the program name, the first thread with this name will be returned.
|
||||||
|
Returns -1 when the program was not found.
|
||||||
|
Success = THREAD REMOVE Option$, ID
|
||||||
|
Option$ = "TeamID" kills the team with number ID
|
||||||
|
Option$ = "ThreadID" kills the thread with number ID
|
||||||
|
Returns True when successful and False otherwise.
|
||||||
|
Note: You can crash your system with this command! If you don't know what this command is meant for,
|
||||||
|
then don't use it!
|
||||||
|
TOOLTIP View$, Text$
|
||||||
|
Set Text$ as the tooltip information for any Widget or View View$.
|
||||||
|
Set Test$ = "" to remove the tooltip again.
|
||||||
|
TOOLTIP COLOR "bgcolor/textcolor", r,g,b
|
||||||
|
Set the background/text color of all tooltips to r,g,b. Note: This is currently not supported.
|
||||||
|
Translation$ = TRANSLATE$(Source$)
|
||||||
|
Translation$ holds the translation of Source$
|
||||||
|
TREEBOX x1,y1 to x2,y2, ID$, ScrollbarType, View$
|
||||||
|
Adds a tree box. This behaves just like a LISTBOX but is able to show nested trees.
|
||||||
|
Note: ITEM ADD does not work here. Use TREEBOX ADD instead. ITEM ADD will be depricated in
|
||||||
|
one of the next releases.
|
||||||
|
TREEBOX ADD TreeBox$, RootItem$
|
||||||
|
Add the item RootItem$ to the top level of the tree.
|
||||||
|
TREEBOX ADD TreeBox$, HeadItem$, ListItem$, IsExpanded
|
||||||
|
Add the item ListItem$ under the level of HeadItem$ of the tree.
|
||||||
|
TREEBOX CLEAR TreeBox$
|
||||||
|
Clear the tree.
|
||||||
|
TREEBOX REMOVE TreeBox$, ListItem$
|
||||||
|
Removes the first list item ListItem$ from the tree. Note: this also removes all subitems!
|
||||||
|
n = TREEBOX COUNT TreeBox$
|
||||||
|
Returns the number of entries in TreeBox$
|
||||||
|
Item$ = TREEBOX GET TreeBox$, Position
|
||||||
|
Returns the Item$ at position Position in TreeBox$.
|
||||||
|
TREEBOX EXPAND TreeBox$, Head$
|
||||||
|
Expands Head$ in TreeBox$.
|
||||||
|
TREEBOX COLLAPSE TreeBox$, Head$
|
||||||
|
Collapses Head$ in TreeBox$.
|
||||||
|
TREEBOX REMOVE TreeBox$, Position
|
||||||
|
Removes the entry at position Position in TreeBox$.
|
||||||
|
TREEBOX REMOVE TreeBox$, Head$, ListItem$
|
||||||
|
Removes ListItem$ under Head$ in TreeBox$.
|
||||||
|
TREEBOX SELECT TreeBox$, Position
|
||||||
|
Selects theitem at position Position in TreeBox$.
|
||||||
|
TREEBOX SORT TreeBox$
|
||||||
|
Sorts the entries of TreeBox$ alphabetically.
|
||||||
|
|
||||||
|
|
||||||
|
-= V =-
|
||||||
|
|
||||||
|
VIEW x1,y1 TO x2,y2, ID$, View$
|
||||||
|
Adds a view
|
||||||
|
VIEW DROPZONE View$
|
||||||
|
Define View$ as a drop zone that accepts dropped files.
|
||||||
|
DROPZONE now accepts multiple files (and sends them in inversed order as message)
|
||||||
|
VIEW REMOVE View$
|
||||||
|
Remove View$. The window view cannot be removed. Should be much more stable now.
|
||||||
|
Warning: Currently clears all internal information about menues and drop boxes. It is only safe to
|
||||||
|
use it, when you don't have any menues or drop boxes on views that will not be removed.
|
||||||
|
Warning: Never remove menus with shortcuts, otherwise yab will crash when the shortcut key is pressed!
|
||||||
|
Result = VIEW GET View$, Option$
|
||||||
|
Option$ = "Position-X/Position-Y/Width/Height/Exists/Focused"
|
||||||
|
Returns the requested property or if used with Exists/Focused returns 1 if so and 0 if not.
|
||||||
|
|
||||||
|
|
||||||
|
-= W =-
|
||||||
|
|
||||||
|
WINDOW OPEN x1,y1 TO x2,y2, ID$, Title$
|
||||||
|
Open window at position x1,y1 to x2,y2 in screen coordinates with title Title$.
|
||||||
|
Automatically generates a window-sized view called ID$.
|
||||||
|
WINDOW CLOSE WindowView$
|
||||||
|
Closes window containing the view View$. Warning: this might destabilize your program if you try
|
||||||
|
to reconstruct your old window or further use old views! The yab-taskforce is set on the tracks of
|
||||||
|
this bug ;)
|
||||||
|
n = WINDOW COUNT
|
||||||
|
Returns the number of open windows
|
||||||
|
Result = WINDOW GET View$, Option$
|
||||||
|
Option$ = "Position-X/Position-Y/Width/Height/Minimum-Width/Minimum-Height/Maximum-Width/Maximum-Height/Exists"
|
||||||
|
Returns the requested property or if used with Exists returns 1 if found and 0 if not.
|
||||||
|
WINDOW SET Window$, Option$, Value$
|
||||||
|
"Look", "Document/Titled(default)/Floating/Modal/Bordered/No-Border"
|
||||||
|
"Feel", "Normal(default)/Modal-App/Modal-All/Floating-App/Floating-All"
|
||||||
|
See "BeBook->Interface Kit->BWindow->Constants and Defined Types" for details.
|
||||||
|
"Title", Title$
|
||||||
|
"Flags", "Not-Closable, Not-Zoomable, Not-Minimizable, Not-H-Resizable, Not-V-Resizable,
|
||||||
|
Not-Resizable, No-Workspace-Activation, Accept-First-Click"
|
||||||
|
See "BeBook->Interface Kit->BWindow->Constants and Defined Types" for details.
|
||||||
|
"Flags", "Reset"
|
||||||
|
Resets the flags back to none.
|
||||||
|
"Workspace", "All"
|
||||||
|
Causes the window to appear on all workspaces.
|
||||||
|
"Workspace", "Current"
|
||||||
|
Causes the window to appear on only the current workspace.
|
||||||
|
"Workspace", "n" (where n is a number >= 1)
|
||||||
|
Causes the window to appear on workspace number n
|
||||||
|
WINDOW SET Window$, Option$, r,g,b
|
||||||
|
"BGColor", r,g,b (216,216,216 default)
|
||||||
|
"HighColor", r,g,b (0,0,0 default)
|
||||||
|
"LowColor", r,g,b (216,216,216 default)
|
||||||
|
WINDOW SET Window$, Option$, x,y
|
||||||
|
"ResizeTo", x,y
|
||||||
|
"MoveTo", x,y
|
||||||
|
"MinimumTo", x,y
|
||||||
|
"MaximumTo", x,y
|
||||||
|
WINDOW SET WindowView$, Option$
|
||||||
|
Option$ = "Activate"
|
||||||
|
Activate the window, so it is in the foreground.
|
||||||
|
Option$ = "Deactivate"
|
||||||
|
Deactivate the window, so it is in the background.
|
||||||
|
Option$ = "Minimize"
|
||||||
|
Minimize the window, or restore the window if it is already minimized.
|
||||||
|
Option$ = "Maximize"
|
||||||
|
Maximize (zoom) the window.
|
||||||
|
Option$ = "Enable-Updates"
|
||||||
|
Updates the window again after a "Disable-Updates".
|
||||||
|
Option$ = "Disable-Updates"
|
||||||
|
Disables the automatic window updates.
|
||||||
2664
Documentation/yabasic.html
Normal file
2664
Documentation/yabasic.html
Normal file
File diff suppressed because one or more lines are too long
66
Localizer/Language/de.catalog
Normal file
66
Localizer/Language/de.catalog
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
1 de x-vnd.Localizer 1483942934
|
||||||
|
File Datei
|
||||||
|
Help Hilfe
|
||||||
|
New... Neu...
|
||||||
|
Import ZETA... Importiere aus ZETA...
|
||||||
|
Mime Type Mime-Typ
|
||||||
|
English Source Englischer Quelltext
|
||||||
|
Target Language Code Zielsprachencode
|
||||||
|
Add Phrase Zeile hinzufügen
|
||||||
|
Cancel Abbrechen
|
||||||
|
Commit Ändern
|
||||||
|
Open... Öffnen...
|
||||||
|
Save... Speichern...
|
||||||
|
Save and Install... Speichern und Installieren...
|
||||||
|
Quit Beenden
|
||||||
|
Help... Hilfe...
|
||||||
|
About... Über...
|
||||||
|
Localizer for Haiku\n\n2011 by Jan Bungeroth Localizer für Haiku\n\n2011 von Jan Bungeroth
|
||||||
|
Ok Ok
|
||||||
|
Saving catalog completed.\n\nSaved to Katalog erfolgreich gespeichert.\n\nGespeichert in
|
||||||
|
All existing data will be lost!\n\nAre you sure? Alle Daten werden gelöscht!\n\nSind Sie sicher?
|
||||||
|
Yes Ja
|
||||||
|
No Nein
|
||||||
|
Error reading file\n Fehler beim Einlesen\n
|
||||||
|
Duplicate source lines were skipped. Doppelte Zeilen wurden ignoriert.
|
||||||
|
Mime type invalid.\n\nA valid mime type has the form:\nx-vnd.ApplicationName Mime-Typ ungültig.\n\nEin gültiger Mime-Typ hat die Form:\nx-vnd.ApplicationName
|
||||||
|
Error writing file\n Fehler beim Schreiben\n
|
||||||
|
Error reading or writing file\n Fehler beim Lesen oder Schreiben\n
|
||||||
|
No target language specified.\nOnly the English catalog was generated. Keine Zielsprache angegeben.\nNur der englische Katalog wurde erstellt.
|
||||||
|
Catalogs saved and installed. Kataloge gespeichert und installiert.
|
||||||
|
Open Catalog Öffne Katalog
|
||||||
|
Import ZETA Locale Importiere ZETA Lokalisierung
|
||||||
|
Select Save Directory Wähle Zielverzeichnis
|
||||||
|
Delete Löschen
|
||||||
|
Close Schließen
|
||||||
|
Localizer helps you to bring localization to your Haiku applications.\n\n Localizer hilft bei der Lokalisierung deiner Haiku Programme.\n\n
|
||||||
|
Localization is done using special catalog files. These catalog files are then compiled into BMessages and stored in a specific directory. The directory and the catalog files are signed by an application mimetype.\n\n Die Lokalisierung wird mit speziellen Katalogdateien umgesetzt. Diese Dateien werden zu BMessages umgewandelt und in einem speziellen Verzeichnis abgelegt. Das Verzeichnis und die Kataloge werden über den Mime-Typ signiert.\n\n
|
||||||
|
How to use Localizer:\n\n So funktioniert Localizer:\n\n
|
||||||
|
1. Add the English strings of your program to the left list and their translations into the right list.\n\n 1. Füge die englischen Strings aus deinem Programm in die linke Liste ein, die übersetzten Strings in die rechte Liste.\n\n
|
||||||
|
2. Enter the translation short code for the target language and the mimetype of your program.\n\n 2. Trage das Sprachkürzel und den Mime-Typ deines Programmes ein.\n\n
|
||||||
|
3. 'Save and Install' will save your translations locally and install their compiled version to /boot/common/data/locale/catalogs\n\n 3. 'Speichern und Installieren' speichert deine Übersetzungen und installiert die kompilierten Kataloge nach /boot/common/data/locale/catalogs\n\n
|
||||||
|
Make sure, both lists are also in sync!\n\n Achte darauf, daß beide Listen synchron sind!\n\n
|
||||||
|
The language code consists of a two letter country code (e.g. de for Germany or nl for Netherlands) or a combined code if the language code differs from the country code (e.g. nl_be for Dutch in Belgium).\n\n Das Sprachkürzel besteht aus einem Code für das Land (z.B. de für Deutschland) und einem Sprachcode, wenn dieser vom Ländercode abweicht (z.B. nl_be für Niederländisch in Belgien).\n\n
|
||||||
|
The mimetype identifies the application. An application mimetype usually has the format: x-vnd.ApplicationName Der Mime-Typ identifiziert die Applikation. Ein Applikations-Mime-Typ hat das Format: x-vnd.ApplikationsName
|
||||||
|
Importing ZETA locale files:\n\n Import von ZETA-Lokalisierungen:\n\n
|
||||||
|
Localizer allows you to import old ZETA locale files.\n\n Localizer erlaubt den Import von alten ZETA-Lokalisierungsdateien.\n\n
|
||||||
|
Currently Localizer does feature context support, so all source strings are allowed only once. If there are several equal English strings in the ZETA file, only the first one is imported. The others are ignored.\n\n Zur Zeit unterstützt Localizer noch keinen Context, deshalb dürfen Quelltexte nur einmal vorkommen. Sollte ein englischer String mehrfach in einer ZETA-Datei vorkommen, wird nur der erste verwendet.\n\n
|
||||||
|
Localizer supports ZETA files using the format:\n Localizer unterstützt das folgende ZETA-Format:\n
|
||||||
|
\"English string\" <tab> \"Target string\"\n\n \"Englischer String\" <tab> \"Übersetzung\"\n\n
|
||||||
|
And also this format:\n Und außerdem noch folgendes Format:\n
|
||||||
|
\"_key\" = \"English string\"\n \"_key\" = \"Englischer String\"\n
|
||||||
|
\"_value\" = \"Target string\"\n \"_value\" = \"Übersetzung\"\n
|
||||||
|
(Note: _key and _value need to be on separate lines.) (Achtung: _key und _value müssen jeweils in einer eigenen Zeile stehen.)
|
||||||
|
How to use localization in yab programs:\n\n Lokalisierung in yab-Programmen:\n\n
|
||||||
|
First you have to load the locale catalog with the mimetype name:\n localize \"x-vnd.MyApplication\"\n\n Zuerst wird der Lokalisierungskatalog mit einem Mime-Typ geladen:\n localize \"x-vnd.MeineApplikation\"\n\n
|
||||||
|
All widgets will now automatically translate all their strings.\n\n Alle Strings in Widgets werden jetzt automatisch übersetzt.\n\n
|
||||||
|
To translate a specific string use:\n translate$(myString$)\n\n Um gezielt einen String zu übersetzen, verwende:\n translate$(meinString$)\n\n
|
||||||
|
A new feature allows you to turn the automatic translation of widget strings off and on again.\n Eine neue Erweiterung läßt dich die Lokalisierung aus- und einschalten.\n
|
||||||
|
To turn the automatic translation off, use:\n localize stop\n\n Um die Übersetzung auszuschalten, verwende:\n localize stop\n\n
|
||||||
|
To turn it on again, use:\n localize Um sie wieder einzuschalten, verwende:\n localize
|
||||||
|
How to use localization in C++ programs:\n\n Lokalisierung in C++-Programmen:\n\n
|
||||||
|
First, include Catalog.h and Locale.h:\n #include <Catalog.h>\n #include <Locale.h>\n\n Zunächst müssen Catalog.h und Locale.h eingebunden werden:\n #include <Catalog.h>\n #include <Locale.h>\n\n
|
||||||
|
Within your code, now you can simply translate a string with:\n B_TRANSLATE(myString);\n\n Im Code kann man dann einfach einen String folgendermaßen übersetzen:\n B_TRANSLATE(meinString);\n\n
|
||||||
|
The locale kit will search for the catalog files associated with your application's signature mimetype.\n\n Das Locale Kit wird die passenden Katalogdateien zum Mime-Typ deiner Applikationssignatur suchen.\n\n
|
||||||
|
To link your program, add the locale and localestub libraries:\n -l locale -l localestub Um dein Programm zu linken, verwenden die Libraries locale und localestub:\n -l locale -l localestub
|
||||||
|
To translate a string separated with colons : use:\n menu translate$(myString$)\nThis is useful for translating menu entries because menu messages are separated with :\n\n Um Strings zu übersetzen, die mit einem Doppelpunkt : getrennt sind, verwende:\n menu translate$(meinString$)\nDas ist besonders bei den Menü-Messages sinnvoll, weil diese mit einem : getrennt werden.\n\n
|
||||||
66
Localizer/Language/en.catalog
Normal file
66
Localizer/Language/en.catalog
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
1 english x-vnd.Localizer 1483942934
|
||||||
|
File File
|
||||||
|
Help Help
|
||||||
|
New... New...
|
||||||
|
Import ZETA... Import ZETA...
|
||||||
|
Mime Type Mime Type
|
||||||
|
English Source English Source
|
||||||
|
Target Language Code Target Language Code
|
||||||
|
Add Phrase Add Phrase
|
||||||
|
Cancel Cancel
|
||||||
|
Commit Commit
|
||||||
|
Open... Open...
|
||||||
|
Save... Save...
|
||||||
|
Save and Install... Save and Install...
|
||||||
|
Quit Quit
|
||||||
|
Help... Help...
|
||||||
|
About... About...
|
||||||
|
Localizer for Haiku\n\n2011 by Jan Bungeroth Localizer for Haiku\n\n2011 by Jan Bungeroth
|
||||||
|
Ok Ok
|
||||||
|
Saving catalog completed.\n\nSaved to Saving catalog completed.\n\nSaved to
|
||||||
|
All existing data will be lost!\n\nAre you sure? All existing data will be lost!\n\nAre you sure?
|
||||||
|
Yes Yes
|
||||||
|
No No
|
||||||
|
Error reading file\n Error reading file\n
|
||||||
|
Duplicate source lines were skipped. Duplicate source lines were skipped.
|
||||||
|
Mime type invalid.\n\nA valid mime type has the form:\nx-vnd.ApplicationName Mime type invalid.\n\nA valid mime type has the form:\nx-vnd.ApplicationName
|
||||||
|
Error writing file\n Error writing file\n
|
||||||
|
Error reading or writing file\n Error reading or writing file\n
|
||||||
|
No target language specified.\nOnly the English catalog was generated. No target language specified.\nOnly the English catalog was generated.
|
||||||
|
Catalogs saved and installed. Catalogs saved and installed.
|
||||||
|
Open Catalog Open Catalog
|
||||||
|
Import ZETA Locale Import ZETA Locale
|
||||||
|
Select Save Directory Select Save Directory
|
||||||
|
Delete Delete
|
||||||
|
Close Close
|
||||||
|
Localizer helps you to bring localization to your Haiku applications.\n\n Localizer helps you to bring localization to your Haiku applications.\n\n
|
||||||
|
Localization is done using special catalog files. These catalog files are then compiled into BMessages and stored in a specific directory. The directory and the catalog files are signed by an application mimetype.\n\n Localization is done using special catalog files. These catalog files are then compiled into BMessages and stored in a specific directory. The directory and the catalog files are signed by an application mimetype.\n\n
|
||||||
|
How to use Localizer:\n\n How to use Localizer:\n\n
|
||||||
|
1. Add the English strings of your program to the left list and their translations into the right list.\n\n 1. Add the English strings of your program to the left list and their translations into the right list.\n\n
|
||||||
|
2. Enter the translation short code for the target language and the mimetype of your program.\n\n 2. Enter the translation short code for the target language and the mimetype of your program.\n\n
|
||||||
|
3. 'Save and Install' will save your translations locally and install their compiled version to /boot/common/data/locale/catalogs\n\n 3. 'Save and Install' will save your translations locally and install their compiled version to /boot/common/data/locale/catalogs\n\n
|
||||||
|
Make sure, both lists are also in sync!\n\n Make sure, both lists are also in sync!\n\n
|
||||||
|
The language code consists of a two letter country code (e.g. de for Germany or nl for Netherlands) or a combined code if the language code differs from the country code (e.g. nl_be for Dutch in Belgium).\n\n The language code consists of a two letter country code (e.g. de for Germany or nl for Netherlands) or a combined code if the language code differs from the country code (e.g. nl_be for Dutch in Belgium).\n\n
|
||||||
|
The mimetype identifies the application. An application mimetype usually has the format: x-vnd.ApplicationName The mimetype identifies the application. An application mimetype usually has the format: x-vnd.ApplicationName
|
||||||
|
Importing ZETA locale files:\n\n Importing ZETA locale files:\n\n
|
||||||
|
Localizer allows you to import old ZETA locale files.\n\n Localizer allows you to import old ZETA locale files.\n\n
|
||||||
|
Currently Localizer does feature context support, so all source strings are allowed only once. If there are several equal English strings in the ZETA file, only the first one is imported. The others are ignored.\n\n Currently Localizer does feature context support, so all source strings are allowed only once. If there are several equal English strings in the ZETA file, only the first one is imported. The others are ignored.\n\n
|
||||||
|
Localizer supports ZETA files using the format:\n Localizer supports ZETA files using the format:\n
|
||||||
|
\"English string\" <tab> \"Target string\"\n\n \"English string\" <tab> \"Target string\"\n\n
|
||||||
|
And also this format:\n And also this format:\n
|
||||||
|
\"_key\" = \"English string\"\n \"_key\" = \"English string\"\n
|
||||||
|
\"_value\" = \"Target string\"\n \"_value\" = \"Target string\"\n
|
||||||
|
(Note: _key and _value need to be on separate lines.) (Note: _key and _value need to be on separate lines.)
|
||||||
|
How to use localization in yab programs:\n\n How to use localization in yab programs:\n\n
|
||||||
|
First you have to load the locale catalog with the mimetype name:\n localize \"x-vnd.MyApplication\"\n\n First you have to load the locale catalog with the mimetype name:\n localize \"x-vnd.MyApplication\"\n\n
|
||||||
|
All widgets will now automatically translate all their strings.\n\n All widgets will now automatically translate all their strings.\n\n
|
||||||
|
To translate a specific string use:\n translate$(myString$)\n\n To translate a specific string use:\n translate$(myString$)\n\n
|
||||||
|
A new feature allows you to turn the automatic translation of widget strings off and on again.\n A new feature allows you to turn the automatic translation of widget strings off and on again.\n
|
||||||
|
To turn the automatic translation off, use:\n localize stop\n\n To turn the automatic translation off, use:\n localize stop\n\n
|
||||||
|
To turn it on again, use:\n localize To turn it on again, use:\n localize
|
||||||
|
How to use localization in C++ programs:\n\n How to use localization in C++ programs:\n\n
|
||||||
|
First, include Catalog.h and Locale.h:\n #include <Catalog.h>\n #include <Locale.h>\n\n First, include Catalog.h and Locale.h:\n #include <Catalog.h>\n #include <Locale.h>\n\n
|
||||||
|
Within your code, now you can simply translate a string with:\n B_TRANSLATE(myString);\n\n Within your code, now you can simply translate a string with:\n B_TRANSLATE(myString);\n\n
|
||||||
|
The locale kit will search for the catalog files associated with your application's signature mimetype.\n\n The locale kit will search for the catalog files associated with your application's signature mimetype.\n\n
|
||||||
|
To link your program, add the locale and localestub libraries:\n -l locale -l localestub To link your program, add the locale and localestub libraries:\n -l locale -l localestub
|
||||||
|
To translate a string separated with colons : use:\n menu translate$(myString$)\nThis is useful for translating menu entries because menu messages are separated with :\n\n To translate a string separated with colons : use:\n menu translate$(myString$)\nThis is useful for translating menu entries because menu messages are separated with :\n\n
|
||||||
645
Localizer/Localizer.yab
Executable file
645
Localizer/Localizer.yab
Executable file
@@ -0,0 +1,645 @@
|
|||||||
|
#!yab
|
||||||
|
|
||||||
|
doc Author: Jan Bungeroth
|
||||||
|
doc (c) 2011 in terms of the Artistic License
|
||||||
|
doc
|
||||||
|
doc The Localizer helps you to localize your yab applications
|
||||||
|
doc and import old Zeta localizations.
|
||||||
|
|
||||||
|
localize "x-vnd.Localizer"
|
||||||
|
|
||||||
|
INSTALLPATH$ = "/boot/common/data/locale/catalogs"
|
||||||
|
mime$ = "x-vnd."
|
||||||
|
lastdir$ = "/boot/home"
|
||||||
|
targetLang$ = ""
|
||||||
|
|
||||||
|
OpenMainWindow()
|
||||||
|
MainMessageLoop()
|
||||||
|
CloseWindows()
|
||||||
|
|
||||||
|
sub MainMessageLoop()
|
||||||
|
local finished, i, j, n, selected, tmp
|
||||||
|
local tmp$, t$
|
||||||
|
|
||||||
|
dim msg$(1)
|
||||||
|
while(not finished)
|
||||||
|
n = split(message$, msg$(), "|")
|
||||||
|
|
||||||
|
for i = 1 to n
|
||||||
|
// if(msg$(i) <> "") print msg$(i)
|
||||||
|
|
||||||
|
// menu
|
||||||
|
switch(msg$(i))
|
||||||
|
case menu translate$("MainWindow:File:New...")
|
||||||
|
NewLocale()
|
||||||
|
break
|
||||||
|
case menu translate$("MainWindow:File:Open...")
|
||||||
|
OpenLocale()
|
||||||
|
break
|
||||||
|
case menu translate$("MainWindow:File:Import ZETA...")
|
||||||
|
ImportZETA()
|
||||||
|
break
|
||||||
|
case menu translate$("MainWindow:File:Save...")
|
||||||
|
if(SaveLocale()) then
|
||||||
|
alert translate$("Saving catalog completed.\n\nSaved to ") + lastdir$, "Ok", "info"
|
||||||
|
endif
|
||||||
|
break
|
||||||
|
case menu translate$("MainWindow:File:Save and Install...")
|
||||||
|
if(SaveLocale()) then
|
||||||
|
InstallLocale()
|
||||||
|
endif
|
||||||
|
break
|
||||||
|
case menu translate$("MainWindow:File:Quit")
|
||||||
|
case "MainWindow:_QuitRequested"
|
||||||
|
case "_QuitRequested"
|
||||||
|
finished = true
|
||||||
|
break
|
||||||
|
case menu translate$("MainWindow:Help:Help...")
|
||||||
|
Help()
|
||||||
|
break
|
||||||
|
case menu translate$("MainWindow:Help:About...")
|
||||||
|
About()
|
||||||
|
break
|
||||||
|
end switch
|
||||||
|
|
||||||
|
// textcontrols
|
||||||
|
if(left$(msg$(i), 6) = "AddSrc") then
|
||||||
|
tmp$ = right$(msg$(i), len(msg$(i)) - 7)
|
||||||
|
selected = 0
|
||||||
|
for j = 1 to listbox count "SrcList"
|
||||||
|
t$ = listbox get$ "SrcList", j
|
||||||
|
if(t$ = tmp$) then
|
||||||
|
selected = j
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
next j
|
||||||
|
if(selected = 0) then
|
||||||
|
localize stop
|
||||||
|
listbox add "SrcList", tmp$
|
||||||
|
localize
|
||||||
|
selected = listbox count "SrcList"
|
||||||
|
endif
|
||||||
|
listbox select "SrcList", selected
|
||||||
|
if(listbox count "TgtList" >= selected) then
|
||||||
|
listbox select "TgtList", selected
|
||||||
|
else
|
||||||
|
listbox select "TgtList", 0
|
||||||
|
endif
|
||||||
|
end if
|
||||||
|
if(left$(msg$(i), 6) = "AddTgt") then
|
||||||
|
listbox add "TgtList", right$(msg$(i), len(msg$(i)) - 7)
|
||||||
|
selected = listbox count "TgtList"
|
||||||
|
listbox select "TgtList", selected
|
||||||
|
if(listbox count "SrcList" >= selected) then
|
||||||
|
listbox select "SrcList", selected
|
||||||
|
else
|
||||||
|
listbox select "SrcList", 0
|
||||||
|
endif
|
||||||
|
end if
|
||||||
|
if(left$(msg$(i), 4) = "Mime") then
|
||||||
|
mime$ = right$(msg$(i), len(msg$(i)) - 5)
|
||||||
|
end if
|
||||||
|
|
||||||
|
// listboxes
|
||||||
|
if(left$(msg$(i), 7) = "SrcList") then
|
||||||
|
selected = val(right$(msg$(i), len(msg$(i)) - 16))
|
||||||
|
if(listbox count "TgtList" >= selected) then
|
||||||
|
listbox select "TgtList", selected
|
||||||
|
else
|
||||||
|
listbox select "TgtList", 0
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
if(left$(msg$(i), 7) = "TgtList") then
|
||||||
|
selected = val(right$(msg$(i), len(msg$(i)) - 16))
|
||||||
|
if(listbox count "SrcList" >= selected) then
|
||||||
|
listbox select "SrcList", selected
|
||||||
|
else
|
||||||
|
listbox select "SrcList", 0
|
||||||
|
end if
|
||||||
|
end if
|
||||||
|
if(mid$(msg$(i), 9, 7) = "_Invoke") then
|
||||||
|
OpenEditor(msg$(i))
|
||||||
|
end if
|
||||||
|
next i
|
||||||
|
wend
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub OpenMainWindow()
|
||||||
|
local h, w
|
||||||
|
|
||||||
|
h = peek("desktopheight") - 200
|
||||||
|
w = peek("desktopwidth") - 400
|
||||||
|
window open 200, 100 to w + 200, h + 100, "MainWindow", "Localizer"
|
||||||
|
window set "MainWindow", "minimumto", 100,100
|
||||||
|
|
||||||
|
menu "File", "New...", "N", "MainWindow"
|
||||||
|
menu "File", "Open...", "O", "MainWindow"
|
||||||
|
menu "File", "Import ZETA...", "Z", "MainWindow"
|
||||||
|
menu "File", "--", "", "MainWindow"
|
||||||
|
menu "File", "Save...", "S", "MainWindow"
|
||||||
|
menu "File", "Save and Install...", "I", "MainWindow"
|
||||||
|
menu "File", "--", "", "MainWindow"
|
||||||
|
menu "File", "Quit", "Q", "MainWindow"
|
||||||
|
|
||||||
|
menu "Help", "Help...", "H", "MainWindow"
|
||||||
|
menu "Help", "--", "", "MainWindow"
|
||||||
|
menu "Help", "About...", "", "MainWindow"
|
||||||
|
|
||||||
|
layout "top, left, right", "MainWindow"
|
||||||
|
textcontrol 10,30 to w-20,55, "Mime", "Mime Type", mime$, "MainWindow"
|
||||||
|
|
||||||
|
layout "top, bottom, left, right", "MainWindow"
|
||||||
|
splitview 0,65 to w,h, "Split", true, true, "MainWindow"
|
||||||
|
layout "top, left", "Split1"
|
||||||
|
text 10,10, "EngText", "English Source", "Split1"
|
||||||
|
layout "top, bottom, left, right", "Split1"
|
||||||
|
listbox 10,30 to w/2 - 10,h-125, "SrcList", 3, "Split1"
|
||||||
|
layout "bottom, left", "Split1"
|
||||||
|
text 10,h-115, "AddEngText", "Add Phrase", "Split1"
|
||||||
|
|
||||||
|
layout "top, left, right", "Split2"
|
||||||
|
textcontrol 10, 4 to w/2-20, 25, "TgtLang", "Target Language Code", targetLang$, "Split2"
|
||||||
|
layout "top, bottom, left, right", "Split2"
|
||||||
|
listbox 10,30 to w/2 - 20,h-125, "TgtList", 3, "Split2"
|
||||||
|
layout "bottom, left", "MainWindow"
|
||||||
|
text 10,h-115, "AddTgtText", "Add Phrase", "Split2"
|
||||||
|
|
||||||
|
layout "bottom, left, right", "Split1"
|
||||||
|
textcontrol 10,h-100 to w/2 - 20, h-80, "AddSrc", "", "", "Split1"
|
||||||
|
layout "bottom, left, right", "MainWindow"
|
||||||
|
textcontrol 10,h-100 to w/2-20, h-80, "AddTgt", "", "", "Split2"
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub CloseWindows()
|
||||||
|
window close "MainWindow"
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub OpenEditor(msg$)
|
||||||
|
local h, w, pos
|
||||||
|
local entry$, list$, t$
|
||||||
|
local editorFinished, i, n
|
||||||
|
|
||||||
|
h = peek("desktopheight") / 2
|
||||||
|
w = peek("desktopwidth") / 2
|
||||||
|
window open w-300,h - 40 to w+300,h+40, "EditorWindow", ""
|
||||||
|
window set "EditorWindow", "look", "bordered"
|
||||||
|
window set "EditorWindow", "feel", "modal-app"
|
||||||
|
|
||||||
|
pos = val(right$(msg$, len(msg$)-16))
|
||||||
|
list$ = left$(msg$, 7)
|
||||||
|
entry$ = listbox get$ list$, pos
|
||||||
|
|
||||||
|
localize stop
|
||||||
|
textcontrol 10,10 to 580,35, "Editor", "", entry$, "EditorWindow"
|
||||||
|
localize
|
||||||
|
button 300,40 to 390,70, "Cancel", "Cancel", "EditorWindow"
|
||||||
|
button 400,40 to 490,70, "Delete", "Delete", "EditorWindow"
|
||||||
|
button 500,40 to 590,70, "Commit", "Commit", "EditorWindow"
|
||||||
|
option set "Editor", "Focus", true
|
||||||
|
|
||||||
|
dim editorMsg$(1)
|
||||||
|
editorFinished = false
|
||||||
|
while(not editorFinished)
|
||||||
|
n = split(message$, editorMsg$(), "|")
|
||||||
|
for i = 1 to n
|
||||||
|
if(editorMsg$(i) = "_QuitRequested") exit(1)
|
||||||
|
if(editorMsg$(i) = "Cancel") editorFinished = true
|
||||||
|
if(editorMsg$(i) = "Commit") then
|
||||||
|
listbox remove list$, pos
|
||||||
|
t$ = textcontrol get$ "Editor"
|
||||||
|
localize stop
|
||||||
|
listbox add list$, pos, t$
|
||||||
|
localize
|
||||||
|
listbox select list$, pos
|
||||||
|
editorFinished = true
|
||||||
|
endif
|
||||||
|
if(editorMsg$(i) = "Delete") then
|
||||||
|
listbox remove list$, pos
|
||||||
|
listbox select list$, 0
|
||||||
|
editorFinished = true
|
||||||
|
endif
|
||||||
|
next i
|
||||||
|
wend
|
||||||
|
|
||||||
|
window close "EditorWindow"
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub NewLocale()
|
||||||
|
local selected
|
||||||
|
selected = alert "All existing data will be lost!\n\nAre you sure?", "Yes", "No", "", "warning"
|
||||||
|
if(selected = 1) then
|
||||||
|
ClearAll()
|
||||||
|
endif
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub OpenLocale()
|
||||||
|
local readno, n
|
||||||
|
local line$
|
||||||
|
|
||||||
|
file$ = filepanel "load-file", "Open Catalog", lastdir$
|
||||||
|
if(file$ = "") return
|
||||||
|
|
||||||
|
ClearAll()
|
||||||
|
lastdir$ = left$(file$, rinstr(file$, "/"))
|
||||||
|
|
||||||
|
readno = open(file$, "r")
|
||||||
|
if(readno = 0) then
|
||||||
|
alert translate$("Error reading file\n") + peek$("error"), "Ok", "stop"
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
line input #readno line$
|
||||||
|
dim tabs$(1)
|
||||||
|
n = split(line$, tabs$(), "\t")
|
||||||
|
if(n <> 4) then
|
||||||
|
alert "Error reading file\n", "Ok", "stop"
|
||||||
|
close(readno)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
if(tabs$(2) <> "english") then
|
||||||
|
targetLang$ = tabs$(2)
|
||||||
|
else
|
||||||
|
targetLang$ = ""
|
||||||
|
endif
|
||||||
|
mime$ = tabs$(3)
|
||||||
|
|
||||||
|
textcontrol set "TgtLang", targetLang$
|
||||||
|
textcontrol set "Mime", mime$
|
||||||
|
|
||||||
|
while(not eof(readno))
|
||||||
|
line input #readno line$
|
||||||
|
n = split(line$, tabs$(), "\t")
|
||||||
|
if(n <> 4) then
|
||||||
|
alert "Error reading file\n", "Ok", "stop"
|
||||||
|
close(readno)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
localize stop
|
||||||
|
listbox add "SrcList", tabs$(1)
|
||||||
|
localize
|
||||||
|
if(targetLang$ <> "") then
|
||||||
|
listbox add "TgtList", tabs$(4)
|
||||||
|
endif
|
||||||
|
wend
|
||||||
|
close(readno)
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub ClearAll()
|
||||||
|
listbox clear "SrcList"
|
||||||
|
listbox clear "TgtList"
|
||||||
|
textcontrol clear "AddSrc"
|
||||||
|
textcontrol clear "AddTgt"
|
||||||
|
mime$ = "x-vnd."
|
||||||
|
textcontrol set "Mime", mime$
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub ImportZETA()
|
||||||
|
local file$, line$
|
||||||
|
file$ = filepanel "load-file", "Import ZETA Locale", lastdir$
|
||||||
|
if(file$ <> "") then
|
||||||
|
ClearAll()
|
||||||
|
lastdir$ = left$(file$, rinstr(file$, "/"))
|
||||||
|
open file$ for reading as #1
|
||||||
|
while(not eof(#1))
|
||||||
|
line input #1 line$
|
||||||
|
ParseZETA(line$)
|
||||||
|
wend
|
||||||
|
close #1
|
||||||
|
file$ = right$(file$, len(file$) - rinstr(file$, "/"))
|
||||||
|
if(lower$(right$(file$,2)) = mid$(file$,len(file$)-3,2)) then
|
||||||
|
targetLang$ = lower$(right$(file$,2))
|
||||||
|
else
|
||||||
|
targetLang$ = mid$(file$,len(file$)-3,2) + "_" + lower$(right$(file$,2))
|
||||||
|
endif
|
||||||
|
textcontrol set "TgtLang", targetLang$
|
||||||
|
mime$ = "x-vnd." + left$(file$, instr(file$, ".") - 1)
|
||||||
|
textcontrol set "Mime", mime$
|
||||||
|
if(warnDuplicates) then
|
||||||
|
warnDulicates = false
|
||||||
|
alert "Duplicate source lines were skipped.", "Ok", "warning"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub ParseZETA(line$)
|
||||||
|
local i, counter
|
||||||
|
local a$, b$, m$
|
||||||
|
|
||||||
|
line$ = trim$(line$)
|
||||||
|
if(left$(line$,1) <> "#") then
|
||||||
|
counter = 0
|
||||||
|
for i = 1 to len(line$)
|
||||||
|
m$ = mid$(line$, i, 1)
|
||||||
|
if(m$ = chr$(34) and (mid$(line$, i-1, 1) <> chr$(92))) then
|
||||||
|
counter = counter + 1
|
||||||
|
endif
|
||||||
|
if(counter = 1) a$ = a$ + m$
|
||||||
|
if(counter = 3) b$ = b$ + m$
|
||||||
|
next i
|
||||||
|
if(trim$(a$) <> "") then
|
||||||
|
a$ = right$(a$, len(a$) - 1)
|
||||||
|
b$ = right$(b$, len(b$) - 1)
|
||||||
|
if(a$ = "_key") then
|
||||||
|
if(IsUnique(b$)) then
|
||||||
|
localize stop
|
||||||
|
listbox add "SrcList", b$
|
||||||
|
localize
|
||||||
|
else
|
||||||
|
warnDuplicates = true
|
||||||
|
endif
|
||||||
|
elsif(a$ = "_value") then
|
||||||
|
listbox add "TgtList", b$
|
||||||
|
else
|
||||||
|
if(IsUnique(a$)) then
|
||||||
|
localize stop
|
||||||
|
listbox add "SrcList", a$
|
||||||
|
localize
|
||||||
|
listbox add "TgtList", b$
|
||||||
|
else
|
||||||
|
warnDuplicates = true
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub IsUnique(entry$)
|
||||||
|
local i
|
||||||
|
local t$
|
||||||
|
|
||||||
|
for i = 1 to listbox count "SrcList"
|
||||||
|
t$ = listbox get$ "SrcList", i
|
||||||
|
if(t$ = entry$) return false
|
||||||
|
next i
|
||||||
|
return true
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub SaveLocale()
|
||||||
|
local fileno, i, writerno, n
|
||||||
|
local entry$, file$, saveFile$
|
||||||
|
|
||||||
|
targetLang$ = textcontrol get$ "TgtLang"
|
||||||
|
|
||||||
|
if(targetLang$ <> "") then
|
||||||
|
saveFile$ = targetLang$ + ".catalog"
|
||||||
|
else
|
||||||
|
saveFile$ = "en.catalog"
|
||||||
|
endif
|
||||||
|
dir$ = filepanel "Save-File", "Save Catalog", lastdir$, saveFile$
|
||||||
|
if(dir$ = "") return false
|
||||||
|
|
||||||
|
lastdir$ = left$(dir$, rinstr(dir$, "/") - 1)
|
||||||
|
|
||||||
|
mime$ = textcontrol get$ "Mime"
|
||||||
|
|
||||||
|
if(mime$ = "" or mime$ = "x-vnd.") then
|
||||||
|
alert "Mime type invalid.\n\nA valid mime type has the form:\nx-vnd.ApplicationName", "Ok", "warning"
|
||||||
|
return false
|
||||||
|
endif
|
||||||
|
file$ = right$(mime$, len(mime$) - instr(mime$, "."))
|
||||||
|
|
||||||
|
fileno = open(file$ + ".tmp", "w")
|
||||||
|
if(fileno = 0) then
|
||||||
|
alert translate$("Error writing file\n") + peek$("error"), "Ok", "stop"
|
||||||
|
return false
|
||||||
|
endif
|
||||||
|
|
||||||
|
for i = 1 to listbox count "SrcList"
|
||||||
|
entry$ = listbox get$ "SrcList", i
|
||||||
|
entry$ = "B_CATKEY\"" + entry$ + "\""
|
||||||
|
print #fileno entry$
|
||||||
|
next i
|
||||||
|
close fileno
|
||||||
|
|
||||||
|
system("collectcatkeys -l english -s " + mime$ + " " + file$ + ".tmp")
|
||||||
|
|
||||||
|
fileno = open(file$ + ".catkeys", "r")
|
||||||
|
if(targetLang$ <> "") then
|
||||||
|
writerno = open(lastdir$ + "/en.catalog", "w")
|
||||||
|
else
|
||||||
|
writerno = open(dir$, "w")
|
||||||
|
endif
|
||||||
|
if(fileno = 0 or writerno = 0) then
|
||||||
|
alert translate$("Error reading or writing file\n") + peek$("error"), "Ok", "stop"
|
||||||
|
return false
|
||||||
|
endif
|
||||||
|
|
||||||
|
line input #fileno entry$
|
||||||
|
dim tabs$(1)
|
||||||
|
n = split(entry$, tabs$(), "\t")
|
||||||
|
if(n <> 4) then
|
||||||
|
alert "Error reading file\n", "Ok", "stop"
|
||||||
|
close(writerno)
|
||||||
|
close(fileno)
|
||||||
|
return false
|
||||||
|
endif
|
||||||
|
print #writerno tabs$(1) + "\tenglish\t" + tabs$(3) + "\t" + tabs$(4)
|
||||||
|
for i = 1 to listbox count "SrcList"
|
||||||
|
entry$ = listbox get$ "SrcList", i
|
||||||
|
print #writerno entry$ + "\t\t\t" + entry$
|
||||||
|
next i
|
||||||
|
close(writerno)
|
||||||
|
close(fileno)
|
||||||
|
|
||||||
|
system("rm " + file$ + ".catkeys")
|
||||||
|
if(targetLang$ <> "") then
|
||||||
|
fileno = open(lastdir$ + "/en.catalog", "r")
|
||||||
|
writerno = open(dir$, "w")
|
||||||
|
if(fileno = 0 or writerno = 0) then
|
||||||
|
alert translate$("Error reading or writing file\n") + peek$("error"), "Ok", "stop"
|
||||||
|
return false
|
||||||
|
endif
|
||||||
|
|
||||||
|
line input #fileno entry$
|
||||||
|
dim tabs$(1)
|
||||||
|
n = split(entry$, tabs$(), "\t")
|
||||||
|
if(n <> 4) then
|
||||||
|
alert "Error reading file\n", "Ok", "stop"
|
||||||
|
close(writerno)
|
||||||
|
close(fileno)
|
||||||
|
return false
|
||||||
|
endif
|
||||||
|
print #writerno tabs$(1) + "\t" + targetLang$ + "\t" + tabs$(3) + "\t" + tabs$(4)
|
||||||
|
i = 1
|
||||||
|
while(not eof(fileno))
|
||||||
|
line input #fileno entry$
|
||||||
|
n = split(entry$, tabs$(), "\t")
|
||||||
|
if(n <> 4) then
|
||||||
|
alert "Error reading file\n", "Ok", "stop"
|
||||||
|
close(writerno)
|
||||||
|
close(fileno)
|
||||||
|
return false
|
||||||
|
endif
|
||||||
|
print #writerno tabs$(1) + "\t\t\t" + GetTarget$(tabs$(1))
|
||||||
|
i = i + 1
|
||||||
|
wend
|
||||||
|
|
||||||
|
close(writerno)
|
||||||
|
close(fileno)
|
||||||
|
else
|
||||||
|
alert "No target language specified.\nOnly the English catalog was generated.", "Ok", "warning"
|
||||||
|
endif
|
||||||
|
system("rm " + file$ + ".tmp")
|
||||||
|
return true
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub InstallLocale()
|
||||||
|
local inst$
|
||||||
|
|
||||||
|
inst$ = INSTALLPATH$ + "/" + mime$
|
||||||
|
system("mkdir -p " + inst$)
|
||||||
|
if(targetLang$ <> "") then
|
||||||
|
system("linkcatkeys -l english -s "+mime$+" -o "+inst$+"/en.catalog "+lastdir$+"/en.catalog")
|
||||||
|
system("linkcatkeys -l "+targetLang$+" -s "+mime$+" -o "+inst$+"/"+targetLang$+".catalog "+dir$)
|
||||||
|
else
|
||||||
|
system("linkcatkeys -l english -s "+mime$+" -o "+inst$+"/en.catalog "+dir$)
|
||||||
|
endif
|
||||||
|
alert "Catalogs saved and installed.", "Ok", "info"
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub GetTarget$(source$)
|
||||||
|
local t$
|
||||||
|
local i
|
||||||
|
|
||||||
|
for i = 1 to listbox count "SrcList"
|
||||||
|
t$ = listbox get$ "SrcList", i
|
||||||
|
if(t$ = source$) then
|
||||||
|
if(i <= listbox count "TgtList") then
|
||||||
|
return listbox get$ "TgtList", i
|
||||||
|
else
|
||||||
|
return ""
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
next i
|
||||||
|
return ""
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub About()
|
||||||
|
alert "Localizer for Haiku\n\n2011 by Jan Bungeroth", "Ok", "idea"
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub Help()
|
||||||
|
local w,h, helpFinished, i, n, currentPage, maxPages
|
||||||
|
|
||||||
|
h = peek("desktopheight")
|
||||||
|
w = peek("desktopwidth")
|
||||||
|
|
||||||
|
window open w/2-200,150 to w/2+200,h-150, "HelpWindow", "Help"
|
||||||
|
window set "HelpWindow", "Flags", "not-zoomable, not-resizable"
|
||||||
|
view 0,0 to 400,h-350, "HelpText", "HelpWindow"
|
||||||
|
draw set "bgcolor", 255,255,255, "HelpText"
|
||||||
|
draw set "highcolor", "Panel-Background-Color, Lighten-1-Tint", "HelpWindow"
|
||||||
|
draw line 0,h-347 to 400,h-347, "HelpWindow"
|
||||||
|
draw set "highcolor", "Panel-Background-Color, Darken-1-Tint", "HelpWindow"
|
||||||
|
draw line 0,h-348 to 400,h-348, "HelpWindow"
|
||||||
|
|
||||||
|
button 10,h-340 to 40,h-310, "HelpBack", "\xe2\x86\xa9", "HelpWindow"
|
||||||
|
option set "HelpBack", "enabled", false
|
||||||
|
button 360,h-340 to 390,h-310, "HelpForward", "\xe2\x86\xaa", "HelpWindow"
|
||||||
|
button 120,h-340 to 280,h-310, "HelpClose", "Close", "HelpWindow"
|
||||||
|
|
||||||
|
textedit 0,0 to 400,h-350, "Help", 1, "HelpText"
|
||||||
|
textedit set "Help", "editable", false
|
||||||
|
|
||||||
|
restore Pages
|
||||||
|
read maxPages
|
||||||
|
|
||||||
|
currentPage = 1
|
||||||
|
ShowHelpPage(currentPage)
|
||||||
|
|
||||||
|
dim helpMsg$(1)
|
||||||
|
helpFinished = false
|
||||||
|
while(not helpFinished)
|
||||||
|
n = split(message$, helpMsg$(), "|")
|
||||||
|
for i = 1 to n
|
||||||
|
switch(helpMsg$(i))
|
||||||
|
case "_QuitRequested"
|
||||||
|
exit(0)
|
||||||
|
break
|
||||||
|
case "HelpWindow:_QuitRequested"
|
||||||
|
case "HelpClose"
|
||||||
|
helpFinished = true
|
||||||
|
break
|
||||||
|
case "HelpForward"
|
||||||
|
if(currentPage < maxPages) then
|
||||||
|
currentPage = currentPage + 1
|
||||||
|
ShowHelpPage(currentPage)
|
||||||
|
if(currentPage = maxPages) option set "HelpForward", "enabled", false
|
||||||
|
if(currentPage = 2) option set "HelpBack", "enabled", true
|
||||||
|
endif
|
||||||
|
break
|
||||||
|
case "HelpBack"
|
||||||
|
if(currentPage > 1) then
|
||||||
|
currentPage = currentPage - 1
|
||||||
|
ShowHelpPage(currentPage)
|
||||||
|
if(currentPage = 1) option set "HelpBack", "enabled", false
|
||||||
|
if(currentPage = maxPages - 1) option set "HelpForward", "enabled", true
|
||||||
|
endif
|
||||||
|
break
|
||||||
|
end switch
|
||||||
|
next i
|
||||||
|
wend
|
||||||
|
|
||||||
|
window close "HelpWindow"
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub ShowHelpPage(num)
|
||||||
|
local lines, i
|
||||||
|
local line$
|
||||||
|
|
||||||
|
textedit clear "Help"
|
||||||
|
restore "Page" + str$(num)
|
||||||
|
read lines
|
||||||
|
for i = 1 to lines
|
||||||
|
read line$
|
||||||
|
textedit add "Help", translate$(line$)
|
||||||
|
next i
|
||||||
|
end sub
|
||||||
|
|
||||||
|
// Help pages
|
||||||
|
label Pages
|
||||||
|
data 4
|
||||||
|
|
||||||
|
label Page1
|
||||||
|
data 9 // data lines for this page
|
||||||
|
data "Localizer helps you to bring localization to your Haiku applications.\n\n"
|
||||||
|
data "Localization is done using special catalog files. These catalog files are then compiled into BMessages and stored in a specific directory. The directory and the catalog files are signed by an application mimetype.\n\n"
|
||||||
|
data "How to use Localizer:\n\n"
|
||||||
|
data "1. Add the English strings of your program to the left list and their translations into the right list.\n\n"
|
||||||
|
data "2. Enter the translation short code for the target language and the mimetype of your program.\n\n"
|
||||||
|
data "3. 'Save and Install' will save your translations locally and install their compiled version to /boot/common/data/locale/catalogs\n\n"
|
||||||
|
data "Make sure, both lists are also in sync!\n\n"
|
||||||
|
data "The language code consists of a two letter country code (e.g. de for Germany or nl for Netherlands) or a combined code if the language code differs from the country code (e.g. nl_be for Dutch in Belgium).\n\n"
|
||||||
|
data "The mimetype identifies the application. An application mimetype usually has the format: x-vnd.ApplicationName"
|
||||||
|
|
||||||
|
label Page2
|
||||||
|
data 9
|
||||||
|
data "Importing ZETA locale files:\n\n"
|
||||||
|
data "Localizer allows you to import old ZETA locale files.\n\n"
|
||||||
|
data "Currently Localizer does feature context support, so all source strings are allowed only once. If there are several equal English strings in the ZETA file, only the first one is imported. The others are ignored.\n\n"
|
||||||
|
data "Localizer supports ZETA files using the format:\n"
|
||||||
|
data " \"English string\" <tab> \"Target string\"\n\n"
|
||||||
|
data "And also this format:\n"
|
||||||
|
data " \"_key\" = \"English string\"\n"
|
||||||
|
data " \"_value\" = \"Target string\"\n"
|
||||||
|
data "(Note: _key and _value need to be on separate lines.)"
|
||||||
|
|
||||||
|
label Page3
|
||||||
|
data 7
|
||||||
|
data "How to use localization in yab programs:\n\n"
|
||||||
|
data "First you have to load the locale catalog with the mimetype name:\n localize \"x-vnd.MyApplication\"\n\n"
|
||||||
|
data "All widgets will now automatically translate all their strings.\n\n"
|
||||||
|
data "To translate a specific string use:\n translate$(myString$)\n\n"
|
||||||
|
data "To translate a string separated with colons : use:\n menu translate$(myString$)\nThis is useful for translating menu entries because menu messages are separated with :\n\n"
|
||||||
|
data "A new feature allows you to turn the automatic translation of widget strings off and on again.\n"
|
||||||
|
data "To turn the automatic translation off, use:\n localize stop\n\n"
|
||||||
|
data "To turn it on again, use:\n localize"
|
||||||
|
|
||||||
|
label Page4
|
||||||
|
data 5
|
||||||
|
data "How to use localization in C++ programs:\n\n"
|
||||||
|
data "First, include Catalog.h and Locale.h:\n #include <Catalog.h>\n #include <Locale.h>\n\n"
|
||||||
|
data "Within your code, now you can simply translate a string with:\n B_TRANSLATE(myString);\n\n"
|
||||||
|
data "The locale kit will search for the catalog files associated with your application's signature mimetype.\n\n"
|
||||||
|
data "To link your program, add the locale and localestub libraries:\n -l locale -l localestub"
|
||||||
19
README.md
19
README.md
@@ -1,2 +1,19 @@
|
|||||||
# YAB1
|
# YAB
|
||||||
yab | yet another Basic for HAIKU
|
yab | yet another Basic for HAIKU
|
||||||
|
===
|
||||||
|
Yab is a complete BASIC programming language for Haiku.
|
||||||
|
|
||||||
|
|
||||||
|
Yab allows fast prototyping with simple and clean code. yab contains a large number of BeAPI specific commands for GUI creation and much, much more. This package includes only the yab binary and documentation.
|
||||||
|
|
||||||
|
|
||||||
|
Compiling
|
||||||
|
---------------------
|
||||||
|
run `make` in `src`.
|
||||||
|
|
||||||
|
run `fixattributes.sh` in `src`.
|
||||||
|
|
||||||
|
type `gcc -o yab-compress yab-compress.c -lz` in `/yab-IDE/BuildFactory`.
|
||||||
|
|
||||||
|
LICENSE: Artistic License -- Create your own stand-alone binaries with yab under any license you want.
|
||||||
|
AUTHOR: jan__64
|
||||||
|
|||||||
252
src/CalendarControl.cpp
Normal file
252
src/CalendarControl.cpp
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
// Calendar Control version 2.5
|
||||||
|
// by Al.V. Sarikov.
|
||||||
|
// Kherson, Ukraine, 2006.
|
||||||
|
// E-mail: avix@ukrpost.net.
|
||||||
|
// Home page: http://avix.pp.ru.
|
||||||
|
|
||||||
|
// Updated for Haiku and removed all stuff that is not needed and refactored by jan__64 2009
|
||||||
|
|
||||||
|
// Control which allows to work with dates:
|
||||||
|
// enter date to text field and choose it from calendar.
|
||||||
|
|
||||||
|
// Distributed under BSD license (see LICENSE file).
|
||||||
|
|
||||||
|
#define __LANG_ENGLISH // to compile english version
|
||||||
|
|
||||||
|
#include "CalendarControl.h"
|
||||||
|
|
||||||
|
#define myButtonMessage 'DCBP'
|
||||||
|
|
||||||
|
#include "DateTextView.cpp"
|
||||||
|
#include "MonthWindow.cpp"
|
||||||
|
|
||||||
|
#include <AppFileInfo.h>
|
||||||
|
#include <FindDirectory.h>
|
||||||
|
#include <File.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <Point.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
|
|
||||||
|
|
||||||
|
CalendarControl::CalendarControl(BPoint p, const char* name, int day, int month, int year, uint32 flags, uint32 look)
|
||||||
|
:BControl(BRect(100,100,200,200),name, NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW)
|
||||||
|
{
|
||||||
|
|
||||||
|
uint32 divider=look & CC_ALL_DIVIDERS;
|
||||||
|
|
||||||
|
myDateTextView = new DateTextView(day,month,year,flags,divider);
|
||||||
|
myButton = new CalendarButton(BRect(70,0,85,15), "CalendarButton", "", new BMessage(myButtonMessage), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
|
||||||
|
myOrigin = p;
|
||||||
|
|
||||||
|
AddChild(myDateTextView);
|
||||||
|
myDateTextView->MoveTo(3,3);
|
||||||
|
ResizeTo(myDateTextView->Bounds().Width()+6,myDateTextView->Bounds().Height()+7);
|
||||||
|
|
||||||
|
AddChild(myButton);
|
||||||
|
|
||||||
|
myButton->ResizeTo(Bounds().Height()*0.7,Bounds().Height()-1);
|
||||||
|
myButton->MoveTo(Bounds().right+1, Bounds().top);
|
||||||
|
ResizeBy(myButton->Bounds().Width()+1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CalendarControl::~CalendarControl()
|
||||||
|
{
|
||||||
|
RemoveChild(myDateTextView);
|
||||||
|
delete myDateTextView;
|
||||||
|
RemoveChild(myButton);
|
||||||
|
delete myButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::AttachedToWindow(void)
|
||||||
|
{
|
||||||
|
BControl::AttachedToWindow();
|
||||||
|
|
||||||
|
myButton->SetTarget(this);
|
||||||
|
|
||||||
|
if(Parent()!=NULL)
|
||||||
|
view_color=Parent()->ViewColor();
|
||||||
|
else
|
||||||
|
view_color.red=view_color.green=view_color.blue=view_color.alpha=255;
|
||||||
|
|
||||||
|
SetViewColor(view_color); // function of CalendarControl class
|
||||||
|
|
||||||
|
// MakeButton(); // for BeOS interface is called only from here,
|
||||||
|
MoveTo(myOrigin);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::Draw(BRect r)
|
||||||
|
{
|
||||||
|
BRect bounds(Bounds());
|
||||||
|
bounds.bottom--;
|
||||||
|
bounds.right = myButton->Frame().left - 1;
|
||||||
|
|
||||||
|
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
|
||||||
|
bool active = myDateTextView->IsFocus() && Window()->IsActive();
|
||||||
|
uint32 flags = 0;
|
||||||
|
if (!IsEnabled())
|
||||||
|
flags |= BControlLook::B_DISABLED;
|
||||||
|
if (active)
|
||||||
|
flags |= BControlLook::B_FOCUSED;
|
||||||
|
be_control_look->DrawTextControlBorder((BView*)this, bounds, r, base, flags, 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::KeyDown(const char *bytes, int32 numBytes)
|
||||||
|
{
|
||||||
|
BControl::KeyDown(bytes, numBytes);
|
||||||
|
if(bytes[0]==B_TAB) Draw(Bounds());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::MakeFocus(bool focused)
|
||||||
|
{
|
||||||
|
myDateTextView->MakeFocus(focused);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::MessageReceived(BMessage *msg)
|
||||||
|
{
|
||||||
|
switch(msg->what)
|
||||||
|
{
|
||||||
|
case myButtonMessage:
|
||||||
|
{
|
||||||
|
if(IsEnabled())
|
||||||
|
{
|
||||||
|
MakeFocus(true);
|
||||||
|
int day, month, year;
|
||||||
|
int first_year, last_year;
|
||||||
|
GetDate(&day, &month, &year);
|
||||||
|
GetYearRange(&first_year, &last_year);
|
||||||
|
new MonthWindow(ConvertToScreen(BPoint(Bounds().left+1,Bounds().bottom+1)),
|
||||||
|
new BMessenger(this), day, month, year, first_year, last_year);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'MVME': // message has come from window with calendar
|
||||||
|
{
|
||||||
|
int32 day, month, year;
|
||||||
|
msg->FindInt32("day",&day);
|
||||||
|
msg->FindInt32("month",&month);
|
||||||
|
msg->FindInt32("year",&year);
|
||||||
|
SetDate((int)day, (int)month, (int)year);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
BControl::MessageReceived(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::SetEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
if(enabled==IsEnabled()) return;
|
||||||
|
BControl::SetEnabled(enabled);
|
||||||
|
myButton->SetEnabled(enabled);
|
||||||
|
myDateTextView->SetEnabled(enabled);
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::SetViewColor(rgb_color color)
|
||||||
|
{
|
||||||
|
view_color=color;
|
||||||
|
BControl::SetViewColor(view_color);
|
||||||
|
Draw(Bounds());
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::SetViewColor(uchar red, uchar green,
|
||||||
|
uchar blue, uchar alpha)
|
||||||
|
{
|
||||||
|
rgb_color color={red, green, blue, alpha};
|
||||||
|
SetViewColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::WindowActivated(bool active)
|
||||||
|
{
|
||||||
|
myWindowActive = active; // true if window where control is placed is active
|
||||||
|
Draw(Bounds());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* CalendarControl::Text() const
|
||||||
|
{
|
||||||
|
return myDateTextView->Text();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::GetDate(int *day, int *month, int *year)
|
||||||
|
{
|
||||||
|
myDateTextView->GetDate(day,month,year);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::SetDate(int day, int month, int year)
|
||||||
|
{
|
||||||
|
myDateTextView->SetDate(day,month,year);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::SetDate(const char *tdate)
|
||||||
|
{
|
||||||
|
myDateTextView->SetDate(tdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::GetYearRange(int *first_year, int *last_year)
|
||||||
|
{
|
||||||
|
myDateTextView->GetYearRange(first_year, last_year);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32 CalendarControl::GetLook()
|
||||||
|
{
|
||||||
|
return (myDateTextView->GetDivider());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::SetLook(uint32 look)
|
||||||
|
{
|
||||||
|
myDateTextView->SetDivider(look & CC_ALL_DIVIDERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32 CalendarControl::GetFlags()
|
||||||
|
{
|
||||||
|
return myDateTextView->GetDateFlags();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarControl::SetFlags(uint32 flags)
|
||||||
|
{
|
||||||
|
myDateTextView->SetDateFlags(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BTextView *CalendarControl::TextView(void) const
|
||||||
|
{
|
||||||
|
return (BTextView *)myDateTextView;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CalendarButton::Draw(BRect update)
|
||||||
|
{
|
||||||
|
BButton::Draw(update);
|
||||||
|
BRect rect = Bounds();
|
||||||
|
rect.InsetBy(2.0,4.0);
|
||||||
|
uint32 flags = 0;
|
||||||
|
rgb_color base = ui_color(B_PANEL_TEXT_COLOR);
|
||||||
|
float tint = B_NO_TINT;
|
||||||
|
if(!IsEnabled())
|
||||||
|
{
|
||||||
|
tint = B_LIGHTEN_MAX_TINT;
|
||||||
|
flags |= BControlLook::B_DISABLED;
|
||||||
|
}
|
||||||
|
be_control_look->DrawArrowShape(this, rect, update, base, 3, flags, tint);
|
||||||
|
}
|
||||||
97
src/CalendarControl.h
Normal file
97
src/CalendarControl.h
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
// Calendar Control version 2.5
|
||||||
|
// by Al.V. Sarikov.
|
||||||
|
// Kherson, Ukraine, 2006.
|
||||||
|
// E-mail: avix@ukrpost.net.
|
||||||
|
// Home page: http://avix.pp.ru.
|
||||||
|
|
||||||
|
// Control which allows to work with dates:
|
||||||
|
// enter date to text field and choose it from calendar.
|
||||||
|
|
||||||
|
// Distributed under BSD license (see LICENSE file).
|
||||||
|
|
||||||
|
#include <Control.h>
|
||||||
|
#include <PictureButton.h>
|
||||||
|
#include <Button.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
|
||||||
|
class DateTextView;
|
||||||
|
|
||||||
|
class CalendarButton : public BButton
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CalendarButton(BRect frame, const char* name, const char* label,
|
||||||
|
BMessage* message, uint32 resizingMode, uint32 flags)
|
||||||
|
: BButton(frame, name, label, message, resizingMode, flags)
|
||||||
|
{};
|
||||||
|
~CalendarButton() {};
|
||||||
|
void Draw(BRect update);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Formats of date
|
||||||
|
|
||||||
|
enum date_format {
|
||||||
|
CC_DD_MM_YYYY_FORMAT = 0,
|
||||||
|
CC_MM_DD_YYYY_FORMAT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum full_short_year {
|
||||||
|
CC_FULL_YEAR = 0, // DD.MM.YYYY
|
||||||
|
CC_SHORT_YEAR = 8 // DD.MM.YY
|
||||||
|
};
|
||||||
|
|
||||||
|
enum century_begin {
|
||||||
|
CC_FULL_CENTURY = 0, // first year is first year of century (01-00)
|
||||||
|
CC_HALF_CENTURY = 16 // first year is 51th year of century (51-50)
|
||||||
|
};
|
||||||
|
|
||||||
|
enum divider_format {
|
||||||
|
CC_DOT_DIVIDER = 0, // .
|
||||||
|
CC_SLASH_DIVIDER, // /
|
||||||
|
CC_MINUS_DIVIDER, // -
|
||||||
|
CC_ALL_DIVIDERS // 2 bits, and some one bit is reserved
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CalendarControl: public BControl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CalendarControl(BPoint p,
|
||||||
|
const char* name,
|
||||||
|
int day=0,
|
||||||
|
int month=0,
|
||||||
|
int year=0,
|
||||||
|
uint32 flags=CC_DD_MM_YYYY_FORMAT | CC_FULL_YEAR,
|
||||||
|
uint32 look=CC_DOT_DIVIDER);
|
||||||
|
~CalendarControl();
|
||||||
|
virtual void AttachedToWindow(void);
|
||||||
|
virtual void Draw(BRect r);
|
||||||
|
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||||
|
virtual void MakeFocus(bool focused=true);
|
||||||
|
virtual void MessageReceived(BMessage *msg);
|
||||||
|
virtual void SetEnabled(bool enabled);
|
||||||
|
virtual void SetViewColor(rgb_color color);
|
||||||
|
void SetViewColor(uchar red, uchar green, uchar blue, uchar alpha=255);
|
||||||
|
virtual void WindowActivated(bool active);
|
||||||
|
|
||||||
|
void GetDate(int *day, int *month, int *year);
|
||||||
|
void SetDate(int day=0, int month=0, int year=0);
|
||||||
|
void SetDate(const char *tdate);
|
||||||
|
void GetYearRange(int *first_year, int *last_year);
|
||||||
|
uint32 GetLook();
|
||||||
|
void SetLook(uint32 look);
|
||||||
|
uint32 GetFlags();
|
||||||
|
void SetFlags(uint32 flags);
|
||||||
|
const char* Text() const;
|
||||||
|
BTextView *TextView(void) const;
|
||||||
|
const char* Version();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void MakeButton();
|
||||||
|
|
||||||
|
DateTextView *myDateTextView;
|
||||||
|
CalendarButton *myButton;
|
||||||
|
bool myWindowActive;
|
||||||
|
BPoint myOrigin;
|
||||||
|
rgb_color view_color;
|
||||||
|
};
|
||||||
|
|
||||||
2293
src/ControlLook.cpp
Normal file
2293
src/ControlLook.cpp
Normal file
File diff suppressed because it is too large
Load Diff
620
src/DateTextView.cpp
Normal file
620
src/DateTextView.cpp
Normal file
@@ -0,0 +1,620 @@
|
|||||||
|
// Calendar Control version 2.5
|
||||||
|
// by Al.V. Sarikov.
|
||||||
|
// Kherson, Ukraine, 2006.
|
||||||
|
// E-mail: avix@ukrpost.net.
|
||||||
|
// Home page: http://avix.pp.ru.
|
||||||
|
|
||||||
|
// Control which allows to work with dates:
|
||||||
|
// enter date to text field and choose it from calendar.
|
||||||
|
|
||||||
|
// Distributed under BSD license (see LICENSE file).
|
||||||
|
|
||||||
|
#include <Clipboard.h>
|
||||||
|
#include <InterfaceDefs.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define LAST_FORMAT 1 // quantity of formats - 1
|
||||||
|
#define LAST_DIVIDER 2 // quantity of dividers - 1
|
||||||
|
|
||||||
|
|
||||||
|
class DateTextView: public BTextView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DateTextView(int day, int month, int year, uint32 flags, uint32 look);
|
||||||
|
virtual void Cut(BClipboard *clip);
|
||||||
|
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||||
|
virtual void MakeFocus(bool focused);
|
||||||
|
virtual void Paste(BClipboard *clip);
|
||||||
|
virtual void SetEnabled(bool enabled);
|
||||||
|
|
||||||
|
void GetDate(int *day, int *month, int *year);
|
||||||
|
void SetDate(int day, int month, int year);
|
||||||
|
void SetDate(const char *tdate);
|
||||||
|
void GetYearRange(int *first_year, int *last_year);
|
||||||
|
uint32 GetDivider();
|
||||||
|
void SetDivider(uint32 dvder);
|
||||||
|
uint32 GetDateFlags();
|
||||||
|
void SetDateFlags(uint32 flags);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DeleteText(int32 start, int32 finish);
|
||||||
|
private:
|
||||||
|
virtual bool AcceptsDrop(const BMessage *message);
|
||||||
|
virtual bool AcceptsPaste(BClipboard *clip);
|
||||||
|
|
||||||
|
void DrawDate(int day, int month, int year);
|
||||||
|
bool VerifyDate(int *day, int *month, int *year);
|
||||||
|
|
||||||
|
bool is_ins; // is it necessar to insert symbol
|
||||||
|
uint32 flags;
|
||||||
|
char *div[LAST_DIVIDER+1]; // сstrings of dividers
|
||||||
|
uint32 divider;
|
||||||
|
|
||||||
|
bool enabled;
|
||||||
|
|
||||||
|
int first_year;
|
||||||
|
int last_year; // first and last year which control accepts
|
||||||
|
|
||||||
|
int textlen; // length of text string (10 or 8 symbols)
|
||||||
|
|
||||||
|
uint32 interface; // the same as control variable
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
DateTextView::DateTextView(int day, int month, int year,
|
||||||
|
uint32 flags, uint32 look)
|
||||||
|
:BTextView(BRect(0,0,110,15),"DateTextViewAViX",
|
||||||
|
BRect(0,0,110,15),B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
|
B_WILL_DRAW | B_NAVIGABLE)
|
||||||
|
{
|
||||||
|
enabled=true;
|
||||||
|
|
||||||
|
is_ins=false;
|
||||||
|
|
||||||
|
interface=look;
|
||||||
|
|
||||||
|
div[0]=(char*)".";
|
||||||
|
div[1]=(char*)"/";
|
||||||
|
div[2]=(char*)"-";
|
||||||
|
|
||||||
|
divider=look & CC_ALL_DIVIDERS;
|
||||||
|
if(divider>LAST_DIVIDER || divider<0) divider=0; // index of divider
|
||||||
|
|
||||||
|
this->flags=(flags & (LAST_FORMAT | CC_SHORT_YEAR | CC_HALF_CENTURY));
|
||||||
|
if((this->flags & (CC_SHORT_YEAR | CC_HALF_CENTURY))==CC_HALF_CENTURY)
|
||||||
|
this->flags=this->flags^CC_HALF_CENTURY; // XOR; CC_FULL_YEAR and CC_HALF_CENTURY
|
||||||
|
// at the same time may not be used
|
||||||
|
|
||||||
|
first_year=1;
|
||||||
|
last_year=9999;
|
||||||
|
|
||||||
|
if((this->flags & CC_SHORT_YEAR)==CC_SHORT_YEAR)
|
||||||
|
{
|
||||||
|
textlen=8;
|
||||||
|
|
||||||
|
// Changing first and last acceptable years
|
||||||
|
// Working in range of century defined by year variable
|
||||||
|
|
||||||
|
if(year<first_year || year>last_year)
|
||||||
|
{
|
||||||
|
// Range is set relative to today's year
|
||||||
|
struct tm *dat;
|
||||||
|
time_t tmp;
|
||||||
|
time(&tmp);
|
||||||
|
dat=localtime(&tmp);
|
||||||
|
|
||||||
|
year=dat->tm_year+1900; // today's year
|
||||||
|
}
|
||||||
|
|
||||||
|
first_year=(year/100)*100+1; // dividing with loosing rest
|
||||||
|
last_year=first_year+99;
|
||||||
|
if(last_year==10000) last_year--; // full century
|
||||||
|
|
||||||
|
if((this->flags & CC_HALF_CENTURY)==CC_HALF_CENTURY)
|
||||||
|
{
|
||||||
|
if(year<51 || year>9950)
|
||||||
|
this->flags=this->flags^CC_HALF_CENTURY; // HALF_CENTURY may nor be set
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if((year%100)>50)
|
||||||
|
{
|
||||||
|
first_year+=50;
|
||||||
|
last_year+=50;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
first_year-=50;
|
||||||
|
last_year-=50;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else textlen=10; // length of text string
|
||||||
|
|
||||||
|
SetDate(day,month,year);
|
||||||
|
|
||||||
|
float width=0;
|
||||||
|
BString s("");
|
||||||
|
for(char i='0'; i<='9'; i++)
|
||||||
|
{
|
||||||
|
s<<i;
|
||||||
|
if(StringWidth(s.String())>width) width=StringWidth(s.String());
|
||||||
|
s.SetTo("");
|
||||||
|
}
|
||||||
|
|
||||||
|
ResizeTo(width*(textlen-2)+StringWidth("/")*2.5, LineHeight()-1);
|
||||||
|
|
||||||
|
SetWordWrap(false);
|
||||||
|
SetMaxBytes(textlen);
|
||||||
|
SetTextRect(Bounds());
|
||||||
|
SetDoesUndo(false);
|
||||||
|
for(int32 i=0;i<256;i++) DisallowChar(i);
|
||||||
|
for(int32 i='0';i<='9';i++) AllowChar(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////
|
||||||
|
bool DateTextView::AcceptsDrop(const BMessage *message)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
bool DateTextView::AcceptsPaste(BClipboard *clip)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
void DateTextView::Cut(BClipboard *clip)
|
||||||
|
{
|
||||||
|
Copy(clip);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////
|
||||||
|
void DateTextView::DeleteText(int32 start, int32 finish)
|
||||||
|
{
|
||||||
|
BTextView::DeleteText(start,finish);
|
||||||
|
if(is_ins)
|
||||||
|
{
|
||||||
|
if(start==2 || start==5) InsertText(div[divider],1,start,NULL);
|
||||||
|
else InsertText("0",1,start,NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
void DateTextView::KeyDown(const char *bytes, int32 numBytes)
|
||||||
|
{
|
||||||
|
if(!enabled) if(bytes[0]!=B_TAB) return;
|
||||||
|
|
||||||
|
int32 i1,i2;
|
||||||
|
GetSelection(&i1,&i2);
|
||||||
|
|
||||||
|
if(bytes[0]>='0' && bytes[0]<='9')
|
||||||
|
{
|
||||||
|
if(i1>(textlen-1)) return; // not to insert after end of string
|
||||||
|
Select(i1,i1);
|
||||||
|
if(i1==2 || i1==5)
|
||||||
|
{
|
||||||
|
i1++;
|
||||||
|
Select(i1,i1);
|
||||||
|
}
|
||||||
|
DeleteText(i1,i1+1);
|
||||||
|
BTextView::KeyDown(bytes, numBytes);
|
||||||
|
}
|
||||||
|
else if(bytes[0]==B_DELETE)
|
||||||
|
{
|
||||||
|
if(i1>(textlen-1)) return; // not to insert after end of string
|
||||||
|
Select(i1,i1);
|
||||||
|
is_ins=true; // symbol "0" or divider will be inserted
|
||||||
|
BTextView::KeyDown(bytes, numBytes);
|
||||||
|
is_ins=false;
|
||||||
|
}
|
||||||
|
else if(bytes[0]==B_BACKSPACE)
|
||||||
|
{
|
||||||
|
Select(i1,i1);
|
||||||
|
is_ins=true;
|
||||||
|
BTextView::KeyDown(bytes, numBytes);
|
||||||
|
is_ins=false;
|
||||||
|
}
|
||||||
|
else if(bytes[0]==B_TAB)
|
||||||
|
{
|
||||||
|
Parent()->KeyDown(bytes, numBytes);
|
||||||
|
}
|
||||||
|
else if(bytes[0]==B_DOWN_ARROW)
|
||||||
|
{
|
||||||
|
// Is Ctrl+DownArrow pressed?
|
||||||
|
if(modifiers() & B_CONTROL_KEY)
|
||||||
|
{
|
||||||
|
// yes
|
||||||
|
BMessage msg(myButtonMessage);
|
||||||
|
Parent()->MessageReceived(&msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
BTextView::KeyDown(bytes, numBytes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
BTextView::KeyDown(bytes, numBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////
|
||||||
|
void DateTextView::MakeFocus(bool focused=true)
|
||||||
|
{
|
||||||
|
BTextView::MakeFocus(focused);
|
||||||
|
|
||||||
|
int day, month, year;
|
||||||
|
GetDate(&day, &month, &year);
|
||||||
|
Parent()->Draw(Parent()->Bounds());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////
|
||||||
|
void DateTextView::Paste(BClipboard *clip)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////
|
||||||
|
void DateTextView::SetEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
this->enabled=enabled;
|
||||||
|
SetFlags(Flags()^B_NAVIGABLE);
|
||||||
|
MakeEditable(enabled);
|
||||||
|
|
||||||
|
BFont font;
|
||||||
|
rgb_color color;
|
||||||
|
GetFontAndColor((int32) 0, &font, &color);
|
||||||
|
color.alpha=0;
|
||||||
|
if(enabled)
|
||||||
|
{
|
||||||
|
SetViewColor(255,255,255,255);
|
||||||
|
color.red=color.green=color.blue=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetViewColor(239,239,239,255);
|
||||||
|
color.red=color.green=color.blue=128;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetFontAndColor(&font,B_FONT_ALL,&color);
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////
|
||||||
|
void DateTextView::DrawDate(int day, int month, int year)
|
||||||
|
{
|
||||||
|
// It is assumed that date is correct
|
||||||
|
BString s;
|
||||||
|
s.SetTo("");
|
||||||
|
|
||||||
|
if(!((flags & CC_MM_DD_YYYY_FORMAT)==CC_MM_DD_YYYY_FORMAT))
|
||||||
|
{
|
||||||
|
if(day<10) s.Append("0");
|
||||||
|
s<<day;
|
||||||
|
|
||||||
|
s.Append(div[divider]);
|
||||||
|
|
||||||
|
if(month<10) s.Append("0");
|
||||||
|
s<<month;
|
||||||
|
}
|
||||||
|
else // CC_MM_DD_YYYY_FORMAT
|
||||||
|
{
|
||||||
|
if(month<10) s.Append("0");
|
||||||
|
s<<month;
|
||||||
|
|
||||||
|
s.Append(div[divider]);
|
||||||
|
|
||||||
|
if(day<10) s.Append("0");
|
||||||
|
s<<day;
|
||||||
|
}
|
||||||
|
s.Append(div[divider]);
|
||||||
|
|
||||||
|
if((flags & CC_SHORT_YEAR)==CC_SHORT_YEAR)
|
||||||
|
{
|
||||||
|
int year1=year%100;
|
||||||
|
if(year1<10) s.Append("0");
|
||||||
|
s<<year1;
|
||||||
|
}
|
||||||
|
else // FULL_YEAR
|
||||||
|
{
|
||||||
|
if(year<10) s.Append("000");
|
||||||
|
else if(year<100) s.Append("00");
|
||||||
|
else if(year<1000) s.Append("0");
|
||||||
|
s<<year;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetText(s.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
void DateTextView::GetDate(int *day, int *month, int *year)
|
||||||
|
{
|
||||||
|
int mday=*day;
|
||||||
|
int mmonth=*month;
|
||||||
|
int myear=*year;
|
||||||
|
|
||||||
|
BString s(Text());
|
||||||
|
char n1[11];
|
||||||
|
char n2[11];
|
||||||
|
char n3[11];
|
||||||
|
|
||||||
|
s.CopyInto(n1,0,2);
|
||||||
|
n1[2]='\0';
|
||||||
|
s.CopyInto(n2,3,2);
|
||||||
|
n2[2]='\0';
|
||||||
|
|
||||||
|
if((flags & CC_SHORT_YEAR)==CC_SHORT_YEAR)
|
||||||
|
{
|
||||||
|
s.CopyInto(n3,6,2);
|
||||||
|
n3[2]='\0';
|
||||||
|
}
|
||||||
|
else // FULL_YEAR
|
||||||
|
{
|
||||||
|
s.CopyInto(n3,6,4);
|
||||||
|
n3[4]='\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!((flags & CC_MM_DD_YYYY_FORMAT)==CC_MM_DD_YYYY_FORMAT))
|
||||||
|
{
|
||||||
|
mday=atoi(n1);
|
||||||
|
mmonth=atoi(n2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mday=atoi(n2);
|
||||||
|
mmonth=atoi(n1);
|
||||||
|
}
|
||||||
|
|
||||||
|
myear=atoi(n3);
|
||||||
|
if((flags & CC_SHORT_YEAR)==CC_SHORT_YEAR)
|
||||||
|
{
|
||||||
|
if((flags & CC_HALF_CENTURY)==CC_HALF_CENTURY)
|
||||||
|
{
|
||||||
|
if(myear<51) myear+=50; else myear-=50;
|
||||||
|
}
|
||||||
|
else if(myear==0) myear=100;
|
||||||
|
|
||||||
|
myear+=(first_year-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!VerifyDate(&mday,&mmonth,&myear)) SetDate(mday,mmonth,myear);
|
||||||
|
|
||||||
|
*day=mday;
|
||||||
|
*month=mmonth;
|
||||||
|
*year=myear;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////
|
||||||
|
void DateTextView::SetDate(int day, int month, int year)
|
||||||
|
{
|
||||||
|
int mday=day;
|
||||||
|
int mmonth=month;
|
||||||
|
int myear=year;
|
||||||
|
VerifyDate(&mday, &mmonth, &myear);
|
||||||
|
DrawDate(mday, mmonth, myear);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
void DateTextView::SetDate(const char *tdate)
|
||||||
|
{
|
||||||
|
// Almost the same as GetDate. May be to combine them.
|
||||||
|
|
||||||
|
// Changes text using current settings of control.
|
||||||
|
int day;
|
||||||
|
int month;
|
||||||
|
int year;
|
||||||
|
|
||||||
|
int k;
|
||||||
|
|
||||||
|
bool short_year=false;
|
||||||
|
if((flags & CC_SHORT_YEAR)==CC_SHORT_YEAR) short_year=true;
|
||||||
|
|
||||||
|
char n1[3]="00";
|
||||||
|
char n2[3]="00";
|
||||||
|
char n3[5]="0000";
|
||||||
|
if(short_year) n3[2]='\0';
|
||||||
|
|
||||||
|
bool zero=false; // was the end of tdate string?
|
||||||
|
|
||||||
|
int c=0;
|
||||||
|
while (!(c==2 || zero))
|
||||||
|
{
|
||||||
|
if(tdate[c]=='\0') zero=true;
|
||||||
|
else n1[c]=tdate[c];
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(zero) goto L1;
|
||||||
|
if(tdate[2]=='\0') goto L1;
|
||||||
|
|
||||||
|
c=0;
|
||||||
|
while (!(c==2 || zero))
|
||||||
|
{
|
||||||
|
if(tdate[c+3]=='\0') zero=true;
|
||||||
|
else n2[c]=tdate[c+3];
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(zero) goto L1;
|
||||||
|
if(tdate[5]=='\0') goto L1;
|
||||||
|
|
||||||
|
k=short_year ? 2 : 4;
|
||||||
|
|
||||||
|
c=0;
|
||||||
|
while (!(c==k || zero))
|
||||||
|
{
|
||||||
|
if(tdate[c+6]=='\0') zero=true;
|
||||||
|
else n3[c]=tdate[c+6];
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
|
||||||
|
L1:
|
||||||
|
if(!((flags & CC_MM_DD_YYYY_FORMAT)==CC_MM_DD_YYYY_FORMAT))
|
||||||
|
{
|
||||||
|
day=atoi(n1);
|
||||||
|
month=atoi(n2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
day=atoi(n2);
|
||||||
|
month=atoi(n1);
|
||||||
|
}
|
||||||
|
|
||||||
|
year=atoi(n3);
|
||||||
|
if(short_year)
|
||||||
|
{
|
||||||
|
if((flags & CC_HALF_CENTURY)==CC_HALF_CENTURY)
|
||||||
|
{
|
||||||
|
if(year<51) year+=50; else year-=50;
|
||||||
|
}
|
||||||
|
else if(year==0) year=100;
|
||||||
|
|
||||||
|
year+=(first_year-1);
|
||||||
|
}
|
||||||
|
SetDate(day,month,year);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
bool DateTextView::VerifyDate(int *day, int *month, int *year)
|
||||||
|
{
|
||||||
|
// Function verifies date to be correct and changes it if it's needed
|
||||||
|
// Returns true if date was correct (and wasn't changed)
|
||||||
|
|
||||||
|
struct tm *dat;
|
||||||
|
time_t tmp;
|
||||||
|
time(&tmp);
|
||||||
|
dat=localtime(&tmp);
|
||||||
|
|
||||||
|
bool flag=true; // date is correct
|
||||||
|
|
||||||
|
if((flags & CC_SHORT_YEAR)==CC_SHORT_YEAR)
|
||||||
|
{
|
||||||
|
if(*year<first_year || *year>last_year)
|
||||||
|
{
|
||||||
|
int year1=*year%100;
|
||||||
|
if((flags & CC_HALF_CENTURY)==CC_HALF_CENTURY)
|
||||||
|
{
|
||||||
|
if(year1<51) year1+=50; else year1-=50;
|
||||||
|
}
|
||||||
|
else if(year1==0) year1=100;
|
||||||
|
|
||||||
|
*year=year1+first_year-1;
|
||||||
|
flag=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // FULL_YEAR
|
||||||
|
{
|
||||||
|
if(*year<1 || *year>9999)
|
||||||
|
{
|
||||||
|
*year=dat->tm_year+1900;
|
||||||
|
flag=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*month<1 || *month>12)
|
||||||
|
{
|
||||||
|
*month=dat->tm_mon+1;
|
||||||
|
flag=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*day<1 || *day>31)
|
||||||
|
{
|
||||||
|
*day=dat->tm_mday;
|
||||||
|
flag=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((*month==4 || *month==6 || *month==9 || *month==11) && *day>30)
|
||||||
|
{
|
||||||
|
if((*day=dat->tm_mday)>30) *day=30;
|
||||||
|
flag=false;
|
||||||
|
}
|
||||||
|
else if (*month==2)
|
||||||
|
{
|
||||||
|
int tmpday;
|
||||||
|
|
||||||
|
if((*year)%4==0) // leap year?
|
||||||
|
{
|
||||||
|
if((*year)%100==0 && (*year)%400!=0) tmpday=28; // no
|
||||||
|
else tmpday=29; // yes
|
||||||
|
}
|
||||||
|
else tmpday=28;
|
||||||
|
|
||||||
|
if(*day>tmpday)
|
||||||
|
{
|
||||||
|
if((*day=dat->tm_mday)>tmpday) *day=tmpday;
|
||||||
|
flag=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
void DateTextView::GetYearRange(int *first_year, int *last_year)
|
||||||
|
{
|
||||||
|
*first_year=this->first_year;
|
||||||
|
*last_year=this->last_year;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
uint32 DateTextView::GetDivider()
|
||||||
|
{
|
||||||
|
return divider;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////
|
||||||
|
void DateTextView::SetDivider(uint32 dvder)
|
||||||
|
{
|
||||||
|
if(dvder<0 || dvder>LAST_DIVIDER) dvder=0;
|
||||||
|
|
||||||
|
BString s(Text());
|
||||||
|
SetText((s.ReplaceAll(div[divider],div[dvder])).String());
|
||||||
|
this->divider=dvder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////
|
||||||
|
uint32 DateTextView::GetDateFlags()
|
||||||
|
{
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////
|
||||||
|
void DateTextView::SetDateFlags(uint32 fmt)
|
||||||
|
{
|
||||||
|
int mday, mmonth, myear;
|
||||||
|
GetDate(&mday, &mmonth, &myear);
|
||||||
|
|
||||||
|
// Blocking changing of parameters of year
|
||||||
|
// (full/short year, full/half century)
|
||||||
|
fmt=fmt & 0xFFE7;
|
||||||
|
|
||||||
|
if(fmt<0 || fmt>LAST_FORMAT) fmt=0;
|
||||||
|
|
||||||
|
flags=fmt | (flags & 0xFFFE); // LAST_FORMAT==1, 1 bit
|
||||||
|
|
||||||
|
SetDate(mday, mmonth, myear);
|
||||||
|
}
|
||||||
129
src/Makefile
Normal file
129
src/Makefile
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
##
|
||||||
|
## yab Haiku Makefile
|
||||||
|
##
|
||||||
|
## (c) Jan Bungeroth 2009 - 2012
|
||||||
|
## Artistic License.
|
||||||
|
##
|
||||||
|
## Use
|
||||||
|
## make
|
||||||
|
## to compile yab for Haiku.
|
||||||
|
##
|
||||||
|
## Needs a valid installation of at least: gcc, flex, bison, perl, ncurses
|
||||||
|
##
|
||||||
|
|
||||||
|
##
|
||||||
|
## Haiku stuff
|
||||||
|
##
|
||||||
|
HAIKUTAB = YabTabView.o
|
||||||
|
HAIKUOPT = -DHAIKU -DLIBRARY_PATH=\"`finddir B_USER_SETTINGS_DIRECTORY`/yab\"
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
## Use our own column list view
|
||||||
|
##
|
||||||
|
COLUMN = column/ColumnListView.o
|
||||||
|
|
||||||
|
##
|
||||||
|
## enable debug
|
||||||
|
##
|
||||||
|
# DBG = -g
|
||||||
|
#
|
||||||
|
|
||||||
|
##
|
||||||
|
## enable optimization
|
||||||
|
##
|
||||||
|
OPT = -O
|
||||||
|
#
|
||||||
|
|
||||||
|
##
|
||||||
|
## GCC Options
|
||||||
|
##
|
||||||
|
GCC = gcc
|
||||||
|
GCC_OPT = $(DBG) $(OPT) -I. -I/boot/home/config/include/ -I/boot/home/config/include/ncurses/ -DHAVE_CONFIG -DUNIX $(HAIKUOPT)
|
||||||
|
GPP = g++
|
||||||
|
GPP_OPT = $(DBG) $(OPT) -I. -DHAVE_CONFIG -DUNIX $(HAIKUOPT)
|
||||||
|
|
||||||
|
##
|
||||||
|
## Libraries
|
||||||
|
##
|
||||||
|
##LIBPATH = -L/boot/home/config/lib
|
||||||
|
LIBPATHS = $(shell findpaths B_FIND_PATH_LIB_DIRECTORY)
|
||||||
|
LIBPATH=$(addprefix -L,$(LIBPATHS))
|
||||||
|
##LIBPATH = -L`finddir B_SYSTEM_LIB_DIRECTORY` ##/boot/system/lib
|
||||||
|
LIB = -lbe -lroot -ltranslation -ltracker -lmedia
|
||||||
|
|
||||||
|
## flags for flex (-d for debugging)
|
||||||
|
FLEXFLAGS = -i -I -L -s
|
||||||
|
|
||||||
|
## flags for bison (-t -v for debugging)
|
||||||
|
BISONFLAGS = -d -l -t -v
|
||||||
|
|
||||||
|
##
|
||||||
|
## Compile and link
|
||||||
|
##
|
||||||
|
yab: YabMain.o YabInterface.o YabWindow.o YabView.o YabBitmapView.o YabFilePanel.o YabFilePanelLooper.o YabList.o \
|
||||||
|
YabText.o flex.o bison.o symbol.o function.o graphic.o io.o main.o $(COLUMN) column/YabColumnType.o column/ColorTools.o YabStackView.o SplitPane.o URLView.o YabControlLook.o \
|
||||||
|
$(HAIKUTAB) Spinner.o column/ColumnListView.o CalendarControl.o
|
||||||
|
$(GPP) $(GPP_OPT) -o yab YabMain.o YabInterface.o YabWindow.o YabView.o YabBitmapView.o YabText.o YabFilePanel.o \
|
||||||
|
YabFilePanelLooper.o YabList.o main.o function.o io.o graphic.o symbol.o bison.o flex.o $(COLUMN) column/YabColumnType.o column/ColorTools.o \
|
||||||
|
YabStackView.o SplitPane.o URLView.o YabControlLook.o $(HAIKUTAB) Spinner.o $(TABLIB) CalendarControl.o \
|
||||||
|
$(LIBPATH) $(LIB)
|
||||||
|
YabMain.o: YabMain.cpp
|
||||||
|
$(GPP) $(GPP_OPT) -c YabMain.cpp -o YabMain.o
|
||||||
|
YabInterface.o: YabInterface.cpp YabInterface.h YabMenu.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabInterface.cpp -o YabInterface.o
|
||||||
|
YabWindow.o: YabWindow.cpp YabWindow.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabWindow.cpp -o YabWindow.o
|
||||||
|
YabView.o: YabView.cpp YabView.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabView.cpp -o YabView.o
|
||||||
|
YabBitmapView.o: YabBitmapView.cpp YabBitmapView.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabBitmapView.cpp -o YabBitmapView.o
|
||||||
|
YabFilePanel.o: YabFilePanel.cpp YabFilePanel.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabFilePanel.cpp -o YabFilePanel.o
|
||||||
|
YabFilePanelLooper.o: YabFilePanelLooper.cpp YabFilePanelLooper.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabFilePanelLooper.cpp -o YabFilePanelLooper.o
|
||||||
|
YabList.o: YabList.cpp YabList.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabList.cpp -o YabList.o
|
||||||
|
YabText.o: YabText.cpp YabText.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabText.cpp -o YabText.o
|
||||||
|
bison.o: bison.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c bison.c -o bison.o
|
||||||
|
flex.o: flex.c bison.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c flex.c -o flex.o
|
||||||
|
function.o: function.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c function.c -o function.o
|
||||||
|
io.o: io.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c io.c -o io.o
|
||||||
|
graphic.o: graphic.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c graphic.c -o graphic.o
|
||||||
|
symbol.o: symbol.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c symbol.c -o symbol.o
|
||||||
|
main.o: main.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c main.c -o main.o
|
||||||
|
flex.c: yabasic.flex
|
||||||
|
flex $(FLEXFLAGS) -t yabasic.flex >flex.c
|
||||||
|
bison.c: yabasic.bison
|
||||||
|
bison $(BISONFLAGS) --output-file bison.c yabasic.bison
|
||||||
|
YabStackView.o: YabStackView.cpp YabStackView.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabStackView.cpp -o YabStackView.o
|
||||||
|
SplitPane.o: SplitPane.cpp SplitPane.h
|
||||||
|
$(GPP) $(GPP_OPT) -c SplitPane.cpp -o SplitPane.o
|
||||||
|
URLView.o: URLView.cpp URLView.h
|
||||||
|
$(GPP) $(GPP_OPT) -c URLView.cpp -o URLView.o
|
||||||
|
Spinner.o: Spinner.cpp Spinner.h
|
||||||
|
$(GPP) $(GPP_OPT) -c Spinner.cpp -o Spinner.o
|
||||||
|
column/ColumnListView.o: column/ColumnListView.cpp column/ColumnListView.h column/ObjectList.h
|
||||||
|
$(GPP) $(GPP_OPT) -c column/ColumnListView.cpp -o column/ColumnListView.o
|
||||||
|
column/ColorTools.o: column/ColorTools.cpp column/ColorTools.h
|
||||||
|
$(GPP) $(GPP_OPT) -c column/ColorTools.cpp -o column/ColorTools.o
|
||||||
|
column/YabColumnType.o: column/YabColumnType.cpp column/YabColumnType.h
|
||||||
|
$(GPP) $(GPP_OPT) -c column/YabColumnType.cpp -o column/YabColumnType.o
|
||||||
|
$(HAIKUTAB): YabTabView.cpp YabTabView.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabTabView.cpp -o YabTabView.o
|
||||||
|
CalendarControl.o: CalendarControl.cpp CalendarControl.h DateTextView.cpp MonthWindow.cpp MonthView.cpp MouseSenseStringView.cpp
|
||||||
|
$(GPP) $(GPP_OPT) -c CalendarControl.cpp -o CalendarControl.o
|
||||||
|
YabControlLook.o: YabControlLook.h YabControlLook.cpp
|
||||||
|
$(GPP) $(GPP_OPT) -c YabControlLook.cpp -o YabControlLook.o
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f core *.o column/*.o flex.* bison.* yab yabasic.output
|
||||||
960
src/MonthView.cpp
Normal file
960
src/MonthView.cpp
Normal file
@@ -0,0 +1,960 @@
|
|||||||
|
// Calendar Control version 2.5
|
||||||
|
// by Al.V. Sarikov.
|
||||||
|
// Kherson, Ukraine, 2006.
|
||||||
|
// E-mail: avix@ukrpost.net.
|
||||||
|
// Home page: http://avix.pp.ru.
|
||||||
|
|
||||||
|
// Control which allows to work with dates:
|
||||||
|
// enter date to text field and choose it from calendar.
|
||||||
|
|
||||||
|
// Distributed under BSD license (see LICENSE file).
|
||||||
|
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
|
#include "MouseSenseStringView.cpp"
|
||||||
|
|
||||||
|
|
||||||
|
class MonthView : public BView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MonthView(int day, int month, int year, int first_year, int last_year);
|
||||||
|
~MonthView();
|
||||||
|
virtual void AttachedToWindow(void);
|
||||||
|
virtual void Draw(BRect r);
|
||||||
|
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||||
|
virtual void MessageReceived(BMessage *msg);
|
||||||
|
virtual void MouseDown(BPoint p);
|
||||||
|
virtual void MouseUp(BPoint p);
|
||||||
|
void MouseMoved(BPoint pt, uint32 transit, const BMessage *msg);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void DrawMonth();
|
||||||
|
|
||||||
|
BMessenger *msng;
|
||||||
|
MouseSenseStringView *yearMStringView[2];
|
||||||
|
MouseSenseStringView *monthMStringView[2];
|
||||||
|
|
||||||
|
MouseSenseStringView *todayStringView;
|
||||||
|
BStringView *monthStringView;
|
||||||
|
BStringView *yearStringView;
|
||||||
|
char *weekdayNames[7];
|
||||||
|
char *monthNames[12];
|
||||||
|
int monthDays[12];
|
||||||
|
|
||||||
|
BBitmap *Bmp;
|
||||||
|
BView *BmpView;
|
||||||
|
|
||||||
|
int cday, cmonth, cyear; // current date in window
|
||||||
|
int cwday1; // day of week of 1st of month in window
|
||||||
|
int cwday; // day of week of current day of month in window
|
||||||
|
|
||||||
|
int first_year, last_year;
|
||||||
|
|
||||||
|
int tday, tmonth, tyear; // today
|
||||||
|
int twday; // is needed to calculate days of week
|
||||||
|
|
||||||
|
float h_cell, w_cell; // height and width of cell for one number of day of nonth
|
||||||
|
|
||||||
|
BRect cursor; // rectangle arounding chosen date
|
||||||
|
|
||||||
|
BRect cursorPressed; // rectangle arounding date where mouse was pressed
|
||||||
|
bool MousePressed; // is mouse pressed on date
|
||||||
|
int dayPressed; // date where mouse is pressed
|
||||||
|
|
||||||
|
bool NewMonth; // if true field must be cleared
|
||||||
|
|
||||||
|
int which_focused; // 0 - if month, 1 - if year,
|
||||||
|
// 2 - if days of month, 3 - if today
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
MonthView::MonthView(int day, int month, int year, int first_year, int last_year)
|
||||||
|
:BView(BRect(0,0,100,100), "MonthViewAViX", B_FOLLOW_LEFT, B_WILL_DRAW)
|
||||||
|
{
|
||||||
|
this->cday=day;
|
||||||
|
this->cmonth=month;
|
||||||
|
this->cyear=year;
|
||||||
|
|
||||||
|
this->first_year=first_year;
|
||||||
|
this->last_year=last_year;
|
||||||
|
|
||||||
|
struct tm *dat;
|
||||||
|
time_t tmp;
|
||||||
|
time(&tmp);
|
||||||
|
dat=localtime(&tmp);
|
||||||
|
|
||||||
|
tday=dat->tm_mday;
|
||||||
|
tmonth=dat->tm_mon+1;
|
||||||
|
tyear=dat->tm_year+1900; // new day coming when window is opened is not handled
|
||||||
|
// because it is very rear case
|
||||||
|
twday=dat->tm_wday;
|
||||||
|
|
||||||
|
weekdayNames[0]=(char*)"Mo";
|
||||||
|
weekdayNames[1]=(char*)"Tu";
|
||||||
|
weekdayNames[2]=(char*)"We";
|
||||||
|
weekdayNames[3]=(char*)"Th";
|
||||||
|
weekdayNames[4]=(char*)"Fr";
|
||||||
|
weekdayNames[5]=(char*)"Sa";
|
||||||
|
weekdayNames[6]=(char*)"Su";
|
||||||
|
|
||||||
|
monthNames[0]=(char*)"January";
|
||||||
|
monthNames[1]=(char*)"February";
|
||||||
|
monthNames[2]=(char*)"March";
|
||||||
|
monthNames[3]=(char*)"April";
|
||||||
|
monthNames[4]=(char*)"May";
|
||||||
|
monthNames[5]=(char*)"June";
|
||||||
|
monthNames[6]=(char*)"July";
|
||||||
|
monthNames[7]=(char*)"August";
|
||||||
|
monthNames[8]=(char*)"September";
|
||||||
|
monthNames[9]=(char*)"October";
|
||||||
|
monthNames[10]=(char*)"November";
|
||||||
|
monthNames[11]=(char*)"December";
|
||||||
|
|
||||||
|
monthDays[0]=31;
|
||||||
|
monthDays[1]=28;
|
||||||
|
monthDays[2]=31;
|
||||||
|
monthDays[3]=30;
|
||||||
|
monthDays[4]=31;
|
||||||
|
monthDays[5]=30;
|
||||||
|
monthDays[6]=31;
|
||||||
|
monthDays[7]=31;
|
||||||
|
monthDays[8]=30;
|
||||||
|
monthDays[9]=31;
|
||||||
|
monthDays[10]=30;
|
||||||
|
monthDays[11]=31;
|
||||||
|
|
||||||
|
NewMonth=false; // first field is cleared and clearing is not needed
|
||||||
|
|
||||||
|
MousePressed=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MonthView::~MonthView()
|
||||||
|
{
|
||||||
|
delete todayStringView;
|
||||||
|
delete monthStringView;
|
||||||
|
delete monthMStringView[0];
|
||||||
|
delete monthMStringView[1];
|
||||||
|
delete yearStringView;
|
||||||
|
delete yearMStringView[0];
|
||||||
|
delete yearMStringView[1];
|
||||||
|
delete msng;
|
||||||
|
Bmp->RemoveChild(BmpView);
|
||||||
|
delete BmpView;
|
||||||
|
delete Bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MonthView::AttachedToWindow(void)
|
||||||
|
{
|
||||||
|
SetFont(be_plain_font);
|
||||||
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
|
// Calculate size of cell needed for number of day of month
|
||||||
|
font_height h;
|
||||||
|
be_plain_font->GetHeight(&h);
|
||||||
|
h_cell = (int)(h.ascent+h.descent+h.leading+6);
|
||||||
|
w_cell = StringWidth("4")*4;
|
||||||
|
|
||||||
|
// add today's date
|
||||||
|
BString s("");
|
||||||
|
s << tday << " " << monthNames[tmonth-1] << " " << tyear;
|
||||||
|
|
||||||
|
msng=new BMessenger(this);
|
||||||
|
todayStringView=new MouseSenseStringView(new BMessage('TODA'), msng,
|
||||||
|
BRect(10,10,100,100),"todayMStringViewAViX", s.String());
|
||||||
|
todayStringView->ResizeToPreferred();
|
||||||
|
todayStringView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
AddChild(todayStringView);
|
||||||
|
|
||||||
|
// add month selection
|
||||||
|
monthStringView=new BStringView(BRect(10,10,100,100),"monthStringViewAViX", monthNames[8]);
|
||||||
|
monthStringView->SetAlignment(B_ALIGN_CENTER);
|
||||||
|
monthStringView->ResizeToPreferred();
|
||||||
|
monthStringView->SetText(monthNames[cmonth-1]);
|
||||||
|
monthStringView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
AddChild(monthStringView);
|
||||||
|
|
||||||
|
// add year selection
|
||||||
|
s.SetTo("");
|
||||||
|
if(cyear<10) s.Append("000");
|
||||||
|
else if(cyear<100) s.Append("00");
|
||||||
|
else if(cyear<1000) s.Append("0");
|
||||||
|
s << cyear;
|
||||||
|
yearStringView=new BStringView(BRect(10,10,100,100),"yearStringViewAViX",
|
||||||
|
"0000");
|
||||||
|
yearStringView->ResizeToPreferred();
|
||||||
|
yearStringView->SetText(s.String());
|
||||||
|
yearStringView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
AddChild(yearStringView);
|
||||||
|
|
||||||
|
ResizeTo(w_cell*7+1,h_cell*7+3+16+yearStringView->Bounds().bottom+todayStringView->Bounds().bottom);
|
||||||
|
Window()->ResizeTo(Bounds().right, Bounds().bottom);
|
||||||
|
|
||||||
|
// year to the left button
|
||||||
|
yearMStringView[0]=new MouseSenseStringView(new BMessage('YEA0'),msng,
|
||||||
|
BRect(10,10,100,100),
|
||||||
|
"yearMStringViewAViX0",
|
||||||
|
"<<");
|
||||||
|
AddChild(yearMStringView[0]);
|
||||||
|
yearMStringView[0]->ResizeToPreferred();
|
||||||
|
yearMStringView[0]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
|
// year to the right button
|
||||||
|
yearMStringView[1]=new MouseSenseStringView(new BMessage('YEA1'),msng,
|
||||||
|
BRect(10,10,100,100),
|
||||||
|
"yearMStringViewAViX1",
|
||||||
|
">>");
|
||||||
|
AddChild(yearMStringView[1]);
|
||||||
|
yearMStringView[1]->ResizeToPreferred();
|
||||||
|
yearMStringView[1]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
|
// month to the left button
|
||||||
|
monthMStringView[0]=new MouseSenseStringView(new BMessage('MON0'),msng,
|
||||||
|
BRect(10,10,100,100),
|
||||||
|
"monthMStringViewAViX0",
|
||||||
|
"<<");
|
||||||
|
AddChild(monthMStringView[0]);
|
||||||
|
monthMStringView[0]->ResizeToPreferred();
|
||||||
|
monthMStringView[0]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
|
// month to the right button
|
||||||
|
monthMStringView[1]=new MouseSenseStringView(new BMessage('MON1'),msng,
|
||||||
|
BRect(10,10,100,100),
|
||||||
|
"monthMStringViewAViX1",
|
||||||
|
">>");
|
||||||
|
AddChild(monthMStringView[1]);
|
||||||
|
monthMStringView[1]->ResizeToPreferred();
|
||||||
|
monthMStringView[1]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
|
// move all in correct position
|
||||||
|
todayStringView->MoveTo((Bounds().right-todayStringView->Bounds().right)/2,
|
||||||
|
Bounds().bottom-todayStringView->Bounds().bottom-2);
|
||||||
|
|
||||||
|
if(tyear<first_year || tyear>last_year) todayStringView->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT));
|
||||||
|
|
||||||
|
yearMStringView[1]->MoveTo(Bounds().right-yearMStringView[1]->Bounds().right,5);
|
||||||
|
yearStringView->MoveTo(yearMStringView[1]->Frame().left-yearStringView->Bounds().right,5);
|
||||||
|
yearMStringView[0]->MoveTo(yearStringView->Frame().left-yearMStringView[0]->Bounds().right,5);
|
||||||
|
|
||||||
|
monthStringView->MoveTo((yearMStringView[0]->Frame().left-monthStringView->Bounds().right)/2,5);
|
||||||
|
monthMStringView[0]->MoveTo(monthStringView->Frame().left-monthMStringView[0]->Bounds().right,5);
|
||||||
|
monthMStringView[1]->MoveTo(monthStringView->Frame().right,5);
|
||||||
|
|
||||||
|
which_focused=2; // days of month
|
||||||
|
|
||||||
|
// Bitmap for the dates
|
||||||
|
Bmp=new BBitmap(Bounds(),B_RGB32,true);
|
||||||
|
BmpView=new BView(Bmp->Bounds(),"BV",0,B_WILL_DRAW);
|
||||||
|
Bmp->AddChild(BmpView);
|
||||||
|
|
||||||
|
Bmp->Lock();
|
||||||
|
BmpView->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
BmpView->FillRect(BmpView->Frame());
|
||||||
|
BmpView->SetHighColor(255,255,255);
|
||||||
|
BRect bmpRect(Bounds());
|
||||||
|
bmpRect.top = yearStringView->Frame().bottom + 2;
|
||||||
|
bmpRect.bottom = todayStringView->Frame().top - 5;
|
||||||
|
BmpView->FillRect(bmpRect);
|
||||||
|
|
||||||
|
BmpView->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
|
||||||
|
BmpView->StrokeLine(BPoint(0,bmpRect.top), BPoint(BmpView->Bounds().right,bmpRect.top));
|
||||||
|
BmpView->StrokeLine(BPoint(0,bmpRect.bottom), BPoint(BmpView->Bounds().right,bmpRect.bottom));
|
||||||
|
BmpView->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
|
|
||||||
|
float y=yearStringView->Frame().bottom+h_cell;
|
||||||
|
float x=0;
|
||||||
|
for(int i=0;i<7;i++)
|
||||||
|
{
|
||||||
|
BmpView->DrawString(weekdayNames[i],BPoint(x+(w_cell-StringWidth(weekdayNames[i]))/2,y));
|
||||||
|
x+=w_cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
BmpView->Sync();
|
||||||
|
Bmp->Unlock();
|
||||||
|
|
||||||
|
DrawMonth();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MonthView::Draw(BRect r)
|
||||||
|
{
|
||||||
|
Window()->Lock();
|
||||||
|
DrawBitmap(Bmp, BPoint(0,0));
|
||||||
|
Window()->Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MonthView::DrawMonth()
|
||||||
|
{
|
||||||
|
Bmp->Lock();
|
||||||
|
|
||||||
|
float y=yearStringView->Frame().bottom+h_cell;
|
||||||
|
float x=0;
|
||||||
|
|
||||||
|
if(NewMonth)
|
||||||
|
{
|
||||||
|
BmpView->SetHighColor(255,255,255);
|
||||||
|
BmpView->FillRect(BRect(0,y+1, BmpView->Bounds().right,todayStringView->Frame().top - 6));
|
||||||
|
BmpView->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
|
BmpView->SetLowColor(255,255,255);
|
||||||
|
NewMonth=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int byear=cyear; // base year
|
||||||
|
if(tyear<byear) byear=tyear;
|
||||||
|
|
||||||
|
int day1=0, m=0, k=byear;
|
||||||
|
|
||||||
|
while(k<cyear)
|
||||||
|
{
|
||||||
|
day1++;
|
||||||
|
|
||||||
|
if(k%4==0) // leap year?
|
||||||
|
if((k%100!=0) || (k%400==0)) day1++; // yes
|
||||||
|
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
while(++m<cmonth)
|
||||||
|
{
|
||||||
|
day1+=(monthDays[m-1]-28);
|
||||||
|
if(m==2) if((cyear%4)==0) if((cyear%100!=0) || (cyear%400==0)) day1++;
|
||||||
|
}
|
||||||
|
day1++; // day1 is number of 1st day of chosen month in chosen year
|
||||||
|
day1=day1%7;
|
||||||
|
|
||||||
|
int day2=0;
|
||||||
|
m=0;
|
||||||
|
k=byear;
|
||||||
|
while(k<tyear)
|
||||||
|
{
|
||||||
|
day2++;
|
||||||
|
if((k%4)==0) if((k%100!=0) || (k%400==0)) day2++;
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
while(++m<tmonth)
|
||||||
|
{
|
||||||
|
day2+=(monthDays[m-1]-28);
|
||||||
|
if(m==2) if((tyear%4)==0) if((tyear%100!=0) || (tyear%400==0)) day2++;
|
||||||
|
}
|
||||||
|
day2+=tday; // day2 - number of today's day in today's year
|
||||||
|
day2=day2%7;
|
||||||
|
|
||||||
|
k=(twday==0) ? 6 : twday-1;
|
||||||
|
|
||||||
|
k=k-day2+day1;
|
||||||
|
while(k<0) k+=7;
|
||||||
|
k=k%7;
|
||||||
|
cwday1=k;
|
||||||
|
|
||||||
|
x=w_cell*k+1;
|
||||||
|
y+=h_cell;
|
||||||
|
|
||||||
|
int qu_days=monthDays[cmonth-1]; // quantity of days in month
|
||||||
|
|
||||||
|
if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
|
||||||
|
|
||||||
|
BString s;
|
||||||
|
int t=0;
|
||||||
|
while(t<qu_days)
|
||||||
|
{
|
||||||
|
t++;
|
||||||
|
|
||||||
|
s<<t;
|
||||||
|
|
||||||
|
if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(236,0,0,0);
|
||||||
|
BmpView->DrawString(s.String(),BPoint(x+(w_cell-StringWidth(s.String()))/2,y));
|
||||||
|
if(cyear==tyear) if(cmonth==tmonth) if(t==tday) BmpView->SetHighColor(0,0,0,0);
|
||||||
|
|
||||||
|
if(t==cday)
|
||||||
|
{
|
||||||
|
cwday=k;
|
||||||
|
if(which_focused==2) BmpView->SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
|
||||||
|
else
|
||||||
|
// BmpView->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT));
|
||||||
|
BmpView->SetHighColor(255,255,255);
|
||||||
|
cursor.Set(x,y-h_cell+5,x+w_cell-1,y+4);
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
BmpView->SetHighColor(0,0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
x+=w_cell;
|
||||||
|
k++;
|
||||||
|
s.SetTo("");
|
||||||
|
|
||||||
|
if(k==7)
|
||||||
|
{
|
||||||
|
k=0;
|
||||||
|
y+=h_cell;
|
||||||
|
x=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BmpView->Sync();
|
||||||
|
Bmp->Unlock();
|
||||||
|
Draw(Bounds());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
void MonthView::KeyDown(const char *bytes, int32 numBytes)
|
||||||
|
{
|
||||||
|
switch(bytes[0])
|
||||||
|
{
|
||||||
|
case B_TAB:
|
||||||
|
{
|
||||||
|
Bmp->Lock();
|
||||||
|
switch(which_focused)
|
||||||
|
{
|
||||||
|
case 0: // months
|
||||||
|
{
|
||||||
|
BmpView->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
BmpView->StrokeLine(BPoint(monthMStringView[0]->Frame().left,
|
||||||
|
monthMStringView[0]->Frame().bottom+1),
|
||||||
|
BPoint(monthMStringView[1]->Frame().right,
|
||||||
|
monthMStringView[1]->Frame().bottom+1));
|
||||||
|
BmpView->SetHighColor(0,0,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: // years
|
||||||
|
{
|
||||||
|
BmpView->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
BmpView->StrokeLine(BPoint(yearMStringView[0]->Frame().left,
|
||||||
|
yearMStringView[0]->Frame().bottom+1),
|
||||||
|
BPoint(yearMStringView[1]->Frame().right,
|
||||||
|
yearMStringView[1]->Frame().bottom+1));
|
||||||
|
BmpView->SetHighColor(0,0,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: // days of month
|
||||||
|
{
|
||||||
|
BmpView->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT));
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
BmpView->SetHighColor(0,0,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: // today
|
||||||
|
{
|
||||||
|
BmpView->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
BmpView->StrokeLine(BPoint(todayStringView->Frame().left,
|
||||||
|
todayStringView->Frame().bottom+1),
|
||||||
|
BPoint(todayStringView->Frame().right,
|
||||||
|
todayStringView->Frame().bottom+1));
|
||||||
|
BmpView->SetHighColor(0,0,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// changing which_focused
|
||||||
|
if(modifiers() & B_SHIFT_KEY)
|
||||||
|
{
|
||||||
|
if(which_focused==0)
|
||||||
|
which_focused=3;
|
||||||
|
else which_focused--;
|
||||||
|
}
|
||||||
|
else // simply Tab
|
||||||
|
{
|
||||||
|
if(which_focused==3)
|
||||||
|
which_focused=0;
|
||||||
|
else which_focused++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// drawing with new which_focused
|
||||||
|
switch(which_focused)
|
||||||
|
{
|
||||||
|
case 0: // months
|
||||||
|
{
|
||||||
|
BmpView->SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
|
||||||
|
BmpView->StrokeLine(BPoint(monthMStringView[0]->Frame().left,
|
||||||
|
monthMStringView[0]->Frame().bottom+1),
|
||||||
|
BPoint(monthMStringView[1]->Frame().right,
|
||||||
|
monthMStringView[1]->Frame().bottom+1));
|
||||||
|
BmpView->SetHighColor(0,0,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1: // years
|
||||||
|
{
|
||||||
|
BmpView->SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
|
||||||
|
BmpView->StrokeLine(BPoint(yearMStringView[0]->Frame().left,
|
||||||
|
yearMStringView[0]->Frame().bottom+1),
|
||||||
|
BPoint(yearMStringView[1]->Frame().right,
|
||||||
|
yearMStringView[1]->Frame().bottom+1));
|
||||||
|
BmpView->SetHighColor(0,0,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: // days of month
|
||||||
|
{
|
||||||
|
BmpView->SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
BmpView->SetHighColor(0,0,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: // today
|
||||||
|
{
|
||||||
|
BmpView->SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
|
||||||
|
BmpView->StrokeLine(BPoint(todayStringView->Frame().left,
|
||||||
|
todayStringView->Frame().bottom+1),
|
||||||
|
BPoint(todayStringView->Frame().right,
|
||||||
|
todayStringView->Frame().bottom+1));
|
||||||
|
BmpView->SetHighColor(0,0,0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BmpView->Sync();
|
||||||
|
Bmp->Unlock();
|
||||||
|
Draw(Bounds());
|
||||||
|
break;
|
||||||
|
} // B_TAB
|
||||||
|
|
||||||
|
case B_DOWN_ARROW:
|
||||||
|
{
|
||||||
|
if(which_focused==0) // month
|
||||||
|
{
|
||||||
|
BMessage msg('MON0');
|
||||||
|
MessageReceived(&msg);
|
||||||
|
}
|
||||||
|
else if(which_focused==1) // year
|
||||||
|
{
|
||||||
|
BMessage msg('YEA0');
|
||||||
|
MessageReceived(&msg);
|
||||||
|
}
|
||||||
|
else if(which_focused==2) // days of month
|
||||||
|
{
|
||||||
|
int qu_days=monthDays[cmonth-1];
|
||||||
|
if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
|
||||||
|
if((cday+7)<=qu_days)
|
||||||
|
{
|
||||||
|
Bmp->Lock();
|
||||||
|
BmpView->SetHighColor(255,255,255);
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
cursor.OffsetBySelf(0, h_cell);
|
||||||
|
cday+=7;
|
||||||
|
BmpView->SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
BmpView->SetHighColor(0,0,0);
|
||||||
|
BmpView->Sync();
|
||||||
|
Bmp->Unlock();
|
||||||
|
Draw(Bounds());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case B_UP_ARROW:
|
||||||
|
{
|
||||||
|
// Test whether Ctrl+UpArrow is pressed
|
||||||
|
if(modifiers() & B_CONTROL_KEY)
|
||||||
|
Window()->PostMessage(B_QUIT_REQUESTED);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(which_focused==0) // month
|
||||||
|
{
|
||||||
|
BMessage msg('MON1');
|
||||||
|
MessageReceived(&msg);
|
||||||
|
}
|
||||||
|
else if(which_focused==1) // year
|
||||||
|
{
|
||||||
|
BMessage msg('YEA1');
|
||||||
|
MessageReceived(&msg);
|
||||||
|
}
|
||||||
|
else if(which_focused==2) // days of month
|
||||||
|
{
|
||||||
|
if((cday-7)>=1)
|
||||||
|
{
|
||||||
|
Bmp->Lock();
|
||||||
|
BmpView->SetHighColor(255,255,255);
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
cursor.OffsetBySelf(0, -h_cell);
|
||||||
|
cday-=7;
|
||||||
|
BmpView->SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
BmpView->SetHighColor(0,0,0);
|
||||||
|
BmpView->Sync();
|
||||||
|
Bmp->Unlock();
|
||||||
|
Draw(Bounds());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case B_LEFT_ARROW:
|
||||||
|
{
|
||||||
|
if(which_focused==0) // month
|
||||||
|
{
|
||||||
|
BMessage msg('MON0');
|
||||||
|
MessageReceived(&msg);
|
||||||
|
}
|
||||||
|
else if(which_focused==1) // year
|
||||||
|
{
|
||||||
|
BMessage msg('YEA0');
|
||||||
|
MessageReceived(&msg);
|
||||||
|
}
|
||||||
|
else if(which_focused==2) // days of month
|
||||||
|
{
|
||||||
|
if(cday>1)
|
||||||
|
{
|
||||||
|
Bmp->Lock();
|
||||||
|
BmpView->SetHighColor(255,255,255);
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
if(cwday>0) // by dates no matter of day of week
|
||||||
|
{
|
||||||
|
cursor.OffsetBySelf(-w_cell,0);
|
||||||
|
cwday--;
|
||||||
|
}
|
||||||
|
else // cwday==0
|
||||||
|
{
|
||||||
|
cursor.OffsetBySelf(w_cell*6,-h_cell);
|
||||||
|
cwday=6;
|
||||||
|
}
|
||||||
|
cday--;
|
||||||
|
BmpView->SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
BmpView->SetHighColor(0,0,0);
|
||||||
|
BmpView->Sync();
|
||||||
|
Bmp->Unlock();
|
||||||
|
Draw(Bounds());
|
||||||
|
}
|
||||||
|
else // 1st of month, go month before
|
||||||
|
{
|
||||||
|
if(cyear>first_year || cmonth>1) // one can go
|
||||||
|
{
|
||||||
|
int cm=(cmonth==1) ? 12 : cmonth-1;
|
||||||
|
int qu_days=monthDays[cm-1];
|
||||||
|
if(cm==2) if(cyear%4==0)
|
||||||
|
if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
|
||||||
|
// it is correct not to pay attention to year changing
|
||||||
|
// because if we moved to february then year was not changed
|
||||||
|
// but if month is other then february
|
||||||
|
// then it has the same number of days every year.
|
||||||
|
cday=qu_days;
|
||||||
|
|
||||||
|
BMessage msg('MON0');
|
||||||
|
MessageReceived(&msg); // here month, cwday and year (if needed) will be changed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case B_RIGHT_ARROW:
|
||||||
|
{
|
||||||
|
if(which_focused==0) // month
|
||||||
|
{
|
||||||
|
BMessage msg('MON1');
|
||||||
|
MessageReceived(&msg);
|
||||||
|
}
|
||||||
|
else if(which_focused==1) // year
|
||||||
|
{
|
||||||
|
BMessage msg('YEA1');
|
||||||
|
MessageReceived(&msg);
|
||||||
|
}
|
||||||
|
else if(which_focused==2) // days of month
|
||||||
|
{
|
||||||
|
int qu_days=monthDays[cmonth-1];
|
||||||
|
if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
|
||||||
|
if(cday<qu_days)
|
||||||
|
{
|
||||||
|
Bmp->Lock();
|
||||||
|
BmpView->SetHighColor(255,255,255);
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
if(cwday<6) // by dates no matter of day of week
|
||||||
|
{
|
||||||
|
cursor.OffsetBySelf(w_cell,0);
|
||||||
|
cwday++;
|
||||||
|
}
|
||||||
|
else // cwday==6
|
||||||
|
{
|
||||||
|
cursor.OffsetBySelf(-w_cell*6,h_cell);
|
||||||
|
cwday=0;
|
||||||
|
}
|
||||||
|
cday++;
|
||||||
|
BmpView->SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
BmpView->SetHighColor(0,0,0);
|
||||||
|
BmpView->Sync();
|
||||||
|
Bmp->Unlock();
|
||||||
|
Draw(Bounds());
|
||||||
|
}
|
||||||
|
else // last of month, go next month
|
||||||
|
{
|
||||||
|
if(cyear<last_year || cmonth<12) // one can go
|
||||||
|
{
|
||||||
|
cday=1;
|
||||||
|
BMessage msg('MON1');
|
||||||
|
MessageReceived(&msg); // here month, cwday and year (if needed) will be changed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case B_ESCAPE:
|
||||||
|
{
|
||||||
|
Window()->PostMessage(B_QUIT_REQUESTED);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case B_ENTER:
|
||||||
|
case B_SPACE:
|
||||||
|
{
|
||||||
|
if(which_focused==2)
|
||||||
|
{
|
||||||
|
// here it is needed to send dayPressed (==cwday), cyear, cmonth
|
||||||
|
// to window and leave
|
||||||
|
BMessage *msg=new BMessage('MVME');
|
||||||
|
msg->AddInt32("day",cday);
|
||||||
|
msg->AddInt32("month",cmonth);
|
||||||
|
msg->AddInt32("year",cyear);
|
||||||
|
Window()->PostMessage(msg);
|
||||||
|
}
|
||||||
|
else if(which_focused==3)
|
||||||
|
{
|
||||||
|
BMessage msg('TODA');
|
||||||
|
MessageReceived(&msg);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
BView::KeyDown(bytes, numBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////
|
||||||
|
void MonthView::MessageReceived(BMessage *msg)
|
||||||
|
{
|
||||||
|
switch(msg->what)
|
||||||
|
{
|
||||||
|
case 'YEA0': // year before
|
||||||
|
{
|
||||||
|
if(cyear<=first_year) break;
|
||||||
|
cyear--;
|
||||||
|
NewMonth=true;
|
||||||
|
BString s("");
|
||||||
|
if(cyear<10) s.Append("000");
|
||||||
|
else if(cyear<100) s.Append("00");
|
||||||
|
else if(cyear<1000) s.Append("0");
|
||||||
|
s<<cyear;
|
||||||
|
yearStringView->SetText(s.String());
|
||||||
|
|
||||||
|
if(cmonth==2) if(cday==29) // one can do simplier: if cday==29, then make
|
||||||
|
// cday=28, because two leap years one after other can't be
|
||||||
|
{
|
||||||
|
if(cyear%4!=0) cday=28;
|
||||||
|
else if(cyear%100==0 && cyear%400!=0) cday=28;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawMonth();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'YEA1': // year after
|
||||||
|
{
|
||||||
|
if(cyear>=last_year) break;
|
||||||
|
cyear++;
|
||||||
|
NewMonth=true;
|
||||||
|
BString s("");
|
||||||
|
if(cyear<10) s.Append("000");
|
||||||
|
else if(cyear<100) s.Append("00");
|
||||||
|
else if(cyear<1000) s.Append("0");
|
||||||
|
s<<cyear;
|
||||||
|
yearStringView->SetText(s.String());
|
||||||
|
|
||||||
|
if(cmonth==2) if(cday==29)
|
||||||
|
{
|
||||||
|
if(cyear%4!=0) cday=28;
|
||||||
|
else if(cyear%100==0 && cyear%400!=0) cday=28;
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawMonth();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'MON0': // month before
|
||||||
|
{
|
||||||
|
if(cmonth>1) cmonth--;
|
||||||
|
else if(cyear>first_year)
|
||||||
|
{
|
||||||
|
cmonth=12;
|
||||||
|
cyear--;
|
||||||
|
|
||||||
|
BString s("");
|
||||||
|
if(cyear<10) s.Append("000");
|
||||||
|
else if(cyear<100) s.Append("00");
|
||||||
|
else if(cyear<1000) s.Append("0");
|
||||||
|
s<<cyear;
|
||||||
|
yearStringView->SetText(s.String());
|
||||||
|
}
|
||||||
|
else break; // nothing is changed
|
||||||
|
|
||||||
|
NewMonth=true;
|
||||||
|
monthStringView->SetText(monthNames[cmonth-1]);
|
||||||
|
|
||||||
|
if(cmonth==2)
|
||||||
|
{
|
||||||
|
int tmpday=28;
|
||||||
|
if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) tmpday=29;
|
||||||
|
if(cday>tmpday) cday=tmpday;
|
||||||
|
}
|
||||||
|
else if(cday>monthDays[cmonth-1]) cday=monthDays[cmonth-1];
|
||||||
|
|
||||||
|
DrawMonth();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'MON1': // month after
|
||||||
|
{
|
||||||
|
if(cmonth<12) cmonth++;
|
||||||
|
else if(cyear<last_year)
|
||||||
|
{
|
||||||
|
cmonth=1;
|
||||||
|
cyear++;
|
||||||
|
|
||||||
|
BString s("");
|
||||||
|
if(cyear<10) s.Append("000");
|
||||||
|
else if(cyear<100) s.Append("00");
|
||||||
|
else if(cyear<1000) s.Append("0");
|
||||||
|
s<<cyear;
|
||||||
|
yearStringView->SetText(s.String());
|
||||||
|
}
|
||||||
|
else break; // nothing is changed
|
||||||
|
|
||||||
|
NewMonth=true;
|
||||||
|
monthStringView->SetText(monthNames[cmonth-1]);
|
||||||
|
|
||||||
|
if(cmonth==2)
|
||||||
|
{
|
||||||
|
int tmpday=28;
|
||||||
|
if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) tmpday=29;
|
||||||
|
if(cday>tmpday) cday=tmpday;
|
||||||
|
}
|
||||||
|
else if(cday>monthDays[cmonth-1]) cday=monthDays[cmonth-1];
|
||||||
|
|
||||||
|
DrawMonth();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'TODA': // to place to today's date
|
||||||
|
{
|
||||||
|
if(tyear<first_year || tyear>last_year) break;
|
||||||
|
|
||||||
|
NewMonth=true;
|
||||||
|
|
||||||
|
cyear=tyear;
|
||||||
|
cmonth=tmonth;
|
||||||
|
cday=tday;
|
||||||
|
|
||||||
|
BString s("");
|
||||||
|
if(cyear<10) s.Append("000");
|
||||||
|
else if(cyear<100) s.Append("00");
|
||||||
|
else if(cyear<1000) s.Append("0");
|
||||||
|
s<<cyear;
|
||||||
|
yearStringView->SetText(s.String());
|
||||||
|
monthStringView->SetText(monthNames[cmonth-1]);
|
||||||
|
|
||||||
|
DrawMonth();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
BView::MessageReceived(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////
|
||||||
|
void MonthView::MouseDown(BPoint p)
|
||||||
|
{
|
||||||
|
// It's necessary to define whether mouse cursor is on one of dates
|
||||||
|
BRect r;
|
||||||
|
|
||||||
|
int k=cwday1;
|
||||||
|
float x=w_cell*k+1;
|
||||||
|
float y=yearStringView->Frame().bottom+h_cell+h_cell;
|
||||||
|
|
||||||
|
int qu_days=monthDays[cmonth-1]; // quantity of days in month
|
||||||
|
|
||||||
|
if(cmonth==2) if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) qu_days=29;
|
||||||
|
|
||||||
|
bool flag=false; // whether mouse is pressed just on date
|
||||||
|
int t=0;
|
||||||
|
while(t<qu_days)
|
||||||
|
{
|
||||||
|
t++;
|
||||||
|
r.Set(x,y-h_cell+5,x+w_cell-1,y+4);
|
||||||
|
|
||||||
|
if(r.Contains(p))
|
||||||
|
{
|
||||||
|
flag=true;
|
||||||
|
dayPressed=t;
|
||||||
|
cursorPressed.Set(r.left,r.top,r.right,r.bottom);
|
||||||
|
MousePressed=true;
|
||||||
|
Bmp->Lock();
|
||||||
|
BmpView->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
BmpView->SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
|
||||||
|
BmpView->StrokeRect(cursorPressed);
|
||||||
|
Bmp->Unlock();
|
||||||
|
Invalidate();
|
||||||
|
break; // exit while
|
||||||
|
}
|
||||||
|
|
||||||
|
x+=w_cell;
|
||||||
|
k++;
|
||||||
|
|
||||||
|
if(k==7)
|
||||||
|
{
|
||||||
|
k=0;
|
||||||
|
y+=h_cell;
|
||||||
|
x=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MonthView::MouseUp(BPoint p)
|
||||||
|
{
|
||||||
|
if(!MousePressed) return;
|
||||||
|
|
||||||
|
if(cursorPressed.Contains(p))
|
||||||
|
{
|
||||||
|
// here it is needed to send dayPressed, cyear, cmonth
|
||||||
|
// to window and leave
|
||||||
|
BMessage *msg=new BMessage('MVME');
|
||||||
|
msg->AddInt32("day",dayPressed);
|
||||||
|
msg->AddInt32("month",cmonth);
|
||||||
|
msg->AddInt32("year",cyear);
|
||||||
|
Window()->PostMessage(msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Bmp->Lock();
|
||||||
|
BmpView->SetHighColor(255,255,255);
|
||||||
|
BmpView->StrokeRect(cursorPressed);
|
||||||
|
BmpView->SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
|
||||||
|
BmpView->StrokeRect(cursor);
|
||||||
|
Bmp->Unlock();
|
||||||
|
Invalidate();
|
||||||
|
MousePressed=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MonthView::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg)
|
||||||
|
{
|
||||||
|
BPoint point;
|
||||||
|
uint32 buttons;
|
||||||
|
GetMouse(&point,&buttons);
|
||||||
|
|
||||||
|
if(transit==B_ENTERED_VIEW)
|
||||||
|
{
|
||||||
|
if( (buttons & B_PRIMARY_MOUSE_BUTTON)==0 &&
|
||||||
|
(buttons & B_SECONDARY_MOUSE_BUTTON)==0 &&
|
||||||
|
(buttons & B_PRIMARY_MOUSE_BUTTON)==0 )
|
||||||
|
MousePressed = false;
|
||||||
|
else
|
||||||
|
MousePressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(transit==B_EXITED_VIEW || transit==B_OUTSIDE_VIEW)
|
||||||
|
MouseUp(Bounds().LeftTop());
|
||||||
|
}
|
||||||
112
src/MonthWindow.cpp
Normal file
112
src/MonthWindow.cpp
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
// Calendar Control version 2.5
|
||||||
|
// by Al.V. Sarikov.
|
||||||
|
// Kherson, Ukraine, 2006.
|
||||||
|
// E-mail: avix@ukrpost.net.
|
||||||
|
// Home page: http://avix.pp.ru.
|
||||||
|
|
||||||
|
// Control which allows to work with dates:
|
||||||
|
// enter date to text field and choose it from calendar.
|
||||||
|
|
||||||
|
// Distributed under BSD license (see LICENSE file).
|
||||||
|
|
||||||
|
#include <Point.h>
|
||||||
|
#include <Screen.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <StringView.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
#include "MonthView.cpp"
|
||||||
|
|
||||||
|
class MonthWindow: public BWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MonthWindow(BPoint LT, BMessenger *msng, int day, int month, int year,
|
||||||
|
int first_year, int last_year);
|
||||||
|
virtual void MessageReceived(BMessage *msg);
|
||||||
|
virtual bool QuitRequested(void);
|
||||||
|
virtual void WindowActivated(bool active);
|
||||||
|
private:
|
||||||
|
MonthView *myMonthView;
|
||||||
|
BMessenger *messenger;
|
||||||
|
|
||||||
|
int first_year;
|
||||||
|
int last_year;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
MonthWindow::MonthWindow(BPoint LT, BMessenger *msng, int day, int month, int year, int first_year, int last_year)
|
||||||
|
:BWindow(BRect(LT,BPoint(LT.x+200,LT.y+200)),"MonthWindowAViX",
|
||||||
|
B_BORDERED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NOT_MOVABLE|B_AVOID_FOCUS)
|
||||||
|
{
|
||||||
|
this->first_year=first_year;
|
||||||
|
this->last_year=last_year;
|
||||||
|
|
||||||
|
myMonthView = new MonthView(day, month, year, first_year, last_year);
|
||||||
|
|
||||||
|
AddChild(myMonthView);
|
||||||
|
myMonthView->MakeFocus(true);
|
||||||
|
|
||||||
|
messenger = msng;
|
||||||
|
|
||||||
|
BRect screenFrame = BScreen(this).Frame();
|
||||||
|
if(LT.x < 0)
|
||||||
|
LT.x = 0;
|
||||||
|
if(LT.x > screenFrame.right - Bounds().Width())
|
||||||
|
LT.x = screenFrame.right - Bounds().Width();
|
||||||
|
if(LT.y > screenFrame.bottom - Bounds().Height())
|
||||||
|
LT.y = screenFrame.bottom - Bounds().Height();
|
||||||
|
MoveTo(LT);
|
||||||
|
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MonthWindow::MessageReceived(BMessage *msg)
|
||||||
|
{
|
||||||
|
if(msg->what=='MVME')
|
||||||
|
{
|
||||||
|
// Is date correct?
|
||||||
|
int32 day, month, year;
|
||||||
|
if(msg->FindInt32("day",&day)!=B_OK) return;
|
||||||
|
if(msg->FindInt32("month",&month)!=B_OK) return;
|
||||||
|
if(msg->FindInt32("year",&year)!=B_OK) return;
|
||||||
|
|
||||||
|
if(year<first_year || year>last_year) return;
|
||||||
|
if(month<1 || month>12) return;
|
||||||
|
int32 tmp;
|
||||||
|
|
||||||
|
tmp=31;
|
||||||
|
if(month==4 || month==6 || month==9 || month==11)
|
||||||
|
tmp=30;
|
||||||
|
else if(month==2)
|
||||||
|
{
|
||||||
|
if(year%4==0)
|
||||||
|
{
|
||||||
|
if(year%100==0 && year%400!=0)
|
||||||
|
tmp=28;
|
||||||
|
else
|
||||||
|
tmp=29;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tmp=28;
|
||||||
|
}
|
||||||
|
if(day<1 || day>tmp) return;
|
||||||
|
messenger->SendMessage(msg);
|
||||||
|
Quit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
BWindow::MessageReceived(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool MonthWindow::QuitRequested(void)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MonthWindow::WindowActivated(bool active)
|
||||||
|
{
|
||||||
|
// exit if unfocused
|
||||||
|
if(!active) Quit();
|
||||||
|
}
|
||||||
95
src/MouseSenseStringView.cpp
Normal file
95
src/MouseSenseStringView.cpp
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
// Calendar Control version 2.5
|
||||||
|
// by Al.V. Sarikov.
|
||||||
|
// Kherson, Ukraine, 2006.
|
||||||
|
// E-mail: avix@ukrpost.net.
|
||||||
|
// Home page: http://avix.pp.ru.
|
||||||
|
|
||||||
|
// Control which allows to work with dates:
|
||||||
|
// enter date to text field and choose it from calendar.
|
||||||
|
|
||||||
|
// Distributed under BSD license (see LICENSE file).
|
||||||
|
|
||||||
|
#include <ControlLook.h>
|
||||||
|
#include <Message.h>
|
||||||
|
#include <Messenger.h>
|
||||||
|
#include <Point.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
#include <StringView.h>
|
||||||
|
|
||||||
|
class MouseSenseStringView:public BStringView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MouseSenseStringView(BMessage *msg,
|
||||||
|
BMessenger *msng,
|
||||||
|
BRect frame,
|
||||||
|
const char *name,
|
||||||
|
const char *text,
|
||||||
|
uint32 resizingMode=B_FOLLOW_LEFT|B_FOLLOW_TOP,
|
||||||
|
uint32 flags=B_WILL_DRAW);
|
||||||
|
virtual void MouseDown(BPoint p);
|
||||||
|
virtual void MouseUp(BPoint p);
|
||||||
|
void Draw(BRect(update));
|
||||||
|
|
||||||
|
private:
|
||||||
|
BMessage *msg;
|
||||||
|
BMessenger *msng;
|
||||||
|
bool isMouseDown;
|
||||||
|
};
|
||||||
|
|
||||||
|
MouseSenseStringView::MouseSenseStringView(BMessage *msg,
|
||||||
|
BMessenger *msng,
|
||||||
|
BRect frame,
|
||||||
|
const char *name,
|
||||||
|
const char *text,
|
||||||
|
uint32 resizingMode,
|
||||||
|
uint32 flags)
|
||||||
|
:BStringView(frame,name,text,resizingMode,flags)
|
||||||
|
{
|
||||||
|
this->msg=msg;
|
||||||
|
this->msng=msng;
|
||||||
|
isMouseDown = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MouseSenseStringView::MouseDown(BPoint p)
|
||||||
|
{
|
||||||
|
isMouseDown = true;
|
||||||
|
// if(msg!=NULL) if(msng!=NULL)
|
||||||
|
// msng->SendMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MouseSenseStringView::MouseUp(BPoint p)
|
||||||
|
{
|
||||||
|
BPoint mouse;
|
||||||
|
uint32 buttons;
|
||||||
|
GetMouse(&mouse, &buttons);
|
||||||
|
if(Bounds().Contains(mouse))
|
||||||
|
if(msg!=NULL) if(msng!=NULL)
|
||||||
|
msng->SendMessage(msg);
|
||||||
|
isMouseDown = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MouseSenseStringView::Draw(BRect update)
|
||||||
|
{
|
||||||
|
BString t(Text());
|
||||||
|
BRect r1(Bounds());
|
||||||
|
r1.right = r1.right/2;
|
||||||
|
BRect r2(Bounds());
|
||||||
|
r2.left= r2.right/4;
|
||||||
|
r2.right= r2.right*3/4;
|
||||||
|
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
uint32 flags = 0;
|
||||||
|
|
||||||
|
if(t == "<<")
|
||||||
|
{
|
||||||
|
be_control_look->DrawArrowShape(this, r1, update, base, 0);
|
||||||
|
be_control_look->DrawArrowShape(this, r2, update, base, 0);
|
||||||
|
}
|
||||||
|
else if(t == ">>")
|
||||||
|
{
|
||||||
|
be_control_look->DrawArrowShape(this, r1, update, base, 1);
|
||||||
|
be_control_look->DrawArrowShape(this, r2, update, base, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
BStringView::Draw(update);
|
||||||
|
}
|
||||||
34
src/RdefApply
Executable file
34
src/RdefApply
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!yab
|
||||||
|
|
||||||
|
doc RdefApply
|
||||||
|
doc adds icon, application signature and version info attributes from an rdef file.
|
||||||
|
doc
|
||||||
|
doc Copyright © 2015 Jim Saxton, Fat Elk Software
|
||||||
|
|
||||||
|
if (peek("argument") >= 2) then
|
||||||
|
filename$=peek$("argument")
|
||||||
|
Outfilename$=peek$("argument")
|
||||||
|
make$=peek$("argument")
|
||||||
|
make=0
|
||||||
|
if (make$="M") make=1
|
||||||
|
readicon()
|
||||||
|
else
|
||||||
|
print"RdefApply"
|
||||||
|
print "Adds icon, application signature and version info attributes from an rdef file.
|
||||||
|
"
|
||||||
|
print "usage:"
|
||||||
|
print "RdefApply <RdefFilename> <OutputFilename> <M>"
|
||||||
|
print "if M is used, OutoutFilename is created if it does not exist
|
||||||
|
or the creation date is set if it does exist."
|
||||||
|
endif
|
||||||
|
|
||||||
|
sub readicon()
|
||||||
|
|
||||||
|
if (not open(1,filename$)) print "Could not open file'"+filename$+"' for reading":exit
|
||||||
|
|
||||||
|
if (make=1) system("touch "+Outfilename$)
|
||||||
|
close #1
|
||||||
|
system("rc -o "+filename$+".rsrc "+filename$)
|
||||||
|
system("resattr -O -o "+Outfilename$+" "+filename$+".rsrc")
|
||||||
|
end sub
|
||||||
|
|
||||||
624
src/Spinner.cpp
Normal file
624
src/Spinner.cpp
Normal file
@@ -0,0 +1,624 @@
|
|||||||
|
/*
|
||||||
|
Spinner.cpp: A number spinner control.
|
||||||
|
Written by DarkWyrm <bpmagic@columbus.rr.com>, Copyright 2004
|
||||||
|
Released under the MIT license.
|
||||||
|
|
||||||
|
Original BScrollBarButton class courtesy Haiku project
|
||||||
|
*/
|
||||||
|
#include "Spinner.h"
|
||||||
|
#include <String.h>
|
||||||
|
#include <ScrollBar.h>
|
||||||
|
#include <Window.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <Font.h>
|
||||||
|
#include <Box.h>
|
||||||
|
#include <MessageFilter.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
|
#include "global.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
M_UP='mmup',
|
||||||
|
M_DOWN,
|
||||||
|
M_TEXT_CHANGED='mtch'
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
ARROW_LEFT=0,
|
||||||
|
ARROW_RIGHT,
|
||||||
|
ARROW_UP,
|
||||||
|
ARROW_DOWN,
|
||||||
|
ARROW_NONE
|
||||||
|
} arrow_direction;
|
||||||
|
|
||||||
|
class SpinnerMsgFilter : public BMessageFilter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SpinnerMsgFilter(void);
|
||||||
|
~SpinnerMsgFilter(void);
|
||||||
|
virtual filter_result Filter(BMessage *msg, BHandler **target);
|
||||||
|
};
|
||||||
|
|
||||||
|
class SpinnerArrowButton : public BView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SpinnerArrowButton(BPoint location, const char *name,
|
||||||
|
arrow_direction dir);
|
||||||
|
~SpinnerArrowButton(void);
|
||||||
|
void AttachedToWindow(void);
|
||||||
|
void DetachedToWindow(void);
|
||||||
|
void MouseDown(BPoint pt);
|
||||||
|
void MouseUp(BPoint pt);
|
||||||
|
void MouseMoved(BPoint pt, uint32 code, const BMessage *msg);
|
||||||
|
void Draw(BRect update);
|
||||||
|
void SetEnabled(bool value);
|
||||||
|
bool IsEnabled(void) const { return enabled; }
|
||||||
|
void SetViewColor(rgb_color color);
|
||||||
|
|
||||||
|
private:
|
||||||
|
arrow_direction fDirection;
|
||||||
|
BPoint tri1,tri2,tri3;
|
||||||
|
Spinner *parent;
|
||||||
|
bool mousedown;
|
||||||
|
bool enabled;
|
||||||
|
rgb_color myColor;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SpinnerPrivateData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SpinnerPrivateData(void)
|
||||||
|
{
|
||||||
|
thumbframe.Set(0,0,0,0);
|
||||||
|
enabled=true;
|
||||||
|
tracking=false;
|
||||||
|
mousept.Set(0,0);
|
||||||
|
thumbinc=1.0;
|
||||||
|
repeaterid=-1;
|
||||||
|
exit_repeater=false;
|
||||||
|
arrowdown=ARROW_NONE;
|
||||||
|
|
||||||
|
#ifdef TEST_MODE
|
||||||
|
sbinfo.proportional=true;
|
||||||
|
sbinfo.double_arrows=false;
|
||||||
|
sbinfo.knob=0;
|
||||||
|
sbinfo.min_knob_size=14;
|
||||||
|
#else
|
||||||
|
get_scroll_bar_info(&sbinfo);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
~SpinnerPrivateData(void)
|
||||||
|
{
|
||||||
|
if(repeaterid!=-1)
|
||||||
|
{
|
||||||
|
exit_repeater=false;
|
||||||
|
kill_thread(repeaterid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
thread_id repeaterid;
|
||||||
|
scroll_bar_info sbinfo;
|
||||||
|
BRect thumbframe;
|
||||||
|
bool enabled;
|
||||||
|
bool tracking;
|
||||||
|
BPoint mousept;
|
||||||
|
float thumbinc;
|
||||||
|
bool exit_repeater;
|
||||||
|
arrow_direction arrowdown;
|
||||||
|
};
|
||||||
|
|
||||||
|
Spinner::Spinner(BRect frame, const char *name, const char *label, int32 min, int32 max, int32 step, BMessage *msg,
|
||||||
|
uint32 resize,uint32 flags)
|
||||||
|
: BControl(frame, name,NULL,msg,resize,flags)
|
||||||
|
{
|
||||||
|
|
||||||
|
BRect r(Bounds());
|
||||||
|
if(r.Height()<14*2)
|
||||||
|
r.bottom=r.top+14*2;
|
||||||
|
ResizeTo(r.Width(),r.Height());
|
||||||
|
|
||||||
|
r.right-=14;
|
||||||
|
|
||||||
|
font_height fh;
|
||||||
|
BFont font;
|
||||||
|
font.GetHeight(&fh);
|
||||||
|
float textheight=fh.ascent+fh.descent+fh.leading;
|
||||||
|
|
||||||
|
BString t("");
|
||||||
|
t << max;
|
||||||
|
BFont f(be_plain_font);
|
||||||
|
float width1 = f.StringWidth(t.String())+2;
|
||||||
|
float width2 = f.StringWidth(label);
|
||||||
|
ResizeTo(width1+width2+18+14, 14*2-2);
|
||||||
|
r = Bounds();
|
||||||
|
r.right-=14+3;
|
||||||
|
|
||||||
|
r.bottom=r.top+textheight+8;
|
||||||
|
r.OffsetTo(0, ( (Bounds().Height()-r.Height())/2) );
|
||||||
|
|
||||||
|
fTextControl=new BTextControl(r,"textcontrol",label,"0",new BMessage(M_TEXT_CHANGED),
|
||||||
|
B_FOLLOW_ALL,B_WILL_DRAW|B_NAVIGABLE);
|
||||||
|
AddChild(fTextControl);
|
||||||
|
BTextView *tview=fTextControl->TextView();
|
||||||
|
tview->SetAlignment(B_ALIGN_LEFT);
|
||||||
|
tview->SetWordWrap(false);
|
||||||
|
|
||||||
|
fTextControl->SetDivider(width2+5);
|
||||||
|
|
||||||
|
BString string("QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,/qwertyuiop{}| "
|
||||||
|
"asdfghjkl:\"zxcvbnm<>?!@#$%^&*()-_=+`~\r");
|
||||||
|
|
||||||
|
for(int32 i=0; i<string.CountChars(); i++)
|
||||||
|
{
|
||||||
|
char c=string.ByteAt(i);
|
||||||
|
tview->DisallowChar(c);
|
||||||
|
}
|
||||||
|
r=Bounds();
|
||||||
|
r.left=r.right-15;
|
||||||
|
r.bottom/=2;
|
||||||
|
|
||||||
|
fUpButton=new SpinnerArrowButton(BPoint(r.left, r.top),"up",ARROW_UP);
|
||||||
|
AddChild(fUpButton);
|
||||||
|
|
||||||
|
r=Bounds();
|
||||||
|
r.left=r.right-15;
|
||||||
|
r.top=r.bottom/2+1;
|
||||||
|
|
||||||
|
fDownButton=new SpinnerArrowButton(BPoint(r.left, r.top-1),"down",ARROW_DOWN);
|
||||||
|
AddChild(fDownButton);
|
||||||
|
|
||||||
|
fStep=step;
|
||||||
|
fMin=min;
|
||||||
|
fMax=max;
|
||||||
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
|
privatedata=new SpinnerPrivateData;
|
||||||
|
fFilter=new SpinnerMsgFilter;
|
||||||
|
|
||||||
|
SetValue(min);
|
||||||
|
}
|
||||||
|
|
||||||
|
Spinner::~Spinner(void)
|
||||||
|
{
|
||||||
|
delete privatedata;
|
||||||
|
delete fFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::AttachedToWindow(void)
|
||||||
|
{
|
||||||
|
Window()->AddCommonFilter(fFilter);
|
||||||
|
fTextControl->SetTarget(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::DetachedFromWindow(void)
|
||||||
|
{
|
||||||
|
Window()->RemoveCommonFilter(fFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::SetValue(int32 value)
|
||||||
|
{
|
||||||
|
if(value>GetMax() || value<GetMin())
|
||||||
|
return;
|
||||||
|
|
||||||
|
BControl::SetValue(value);
|
||||||
|
|
||||||
|
char string[50];
|
||||||
|
sprintf(string,"%ld",value);
|
||||||
|
fTextControl->SetText(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::SetViewColor(rgb_color color)
|
||||||
|
{
|
||||||
|
BControl::SetViewColor(color);
|
||||||
|
fTextControl->SetViewColor(color);
|
||||||
|
fTextControl->SetLowColor(color);
|
||||||
|
fUpButton->SetViewColor(color);
|
||||||
|
fDownButton->SetViewColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::SetLabel(const char *text)
|
||||||
|
{
|
||||||
|
fTextControl->SetLabel(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::ValueChanged(int32 value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::MessageReceived(BMessage *msg)
|
||||||
|
{
|
||||||
|
if(msg->what==M_TEXT_CHANGED)
|
||||||
|
{
|
||||||
|
BString string(fTextControl->Text());
|
||||||
|
int32 newvalue=0;
|
||||||
|
|
||||||
|
sscanf(string.String(),"%ld",&newvalue);
|
||||||
|
if(newvalue>=GetMin() && newvalue<=GetMax())
|
||||||
|
{
|
||||||
|
// new value is in range, so set it and go
|
||||||
|
SetValue(newvalue);
|
||||||
|
Invoke();
|
||||||
|
Draw(Bounds());
|
||||||
|
ValueChanged(Value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// new value is out of bounds. Clip to range if current value is not
|
||||||
|
// at the end of its range
|
||||||
|
if(newvalue<GetMin() && Value()!=GetMin())
|
||||||
|
{
|
||||||
|
SetValue(GetMin());
|
||||||
|
Invoke();
|
||||||
|
Draw(Bounds());
|
||||||
|
ValueChanged(Value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(newvalue>GetMax() && Value()!=GetMax())
|
||||||
|
{
|
||||||
|
SetValue(GetMax());
|
||||||
|
Invoke();
|
||||||
|
Draw(Bounds());
|
||||||
|
ValueChanged(Value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char string[100];
|
||||||
|
sprintf(string,"%ld",Value());
|
||||||
|
fTextControl->SetText(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
BControl::MessageReceived(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::SetSteps(int32 stepsize)
|
||||||
|
{
|
||||||
|
fStep=stepsize;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::SetRange(int32 min, int32 max)
|
||||||
|
{
|
||||||
|
SetMin(min);
|
||||||
|
SetMax(max);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::GetRange(int32 *min, int32 *max)
|
||||||
|
{
|
||||||
|
*min=fMin;
|
||||||
|
*max=fMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::SetMax(int32 max)
|
||||||
|
{
|
||||||
|
fMax=max;
|
||||||
|
if(Value()>fMax)
|
||||||
|
SetValue(fMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::SetMin(int32 min)
|
||||||
|
{
|
||||||
|
fMin=min;
|
||||||
|
if(Value()<fMin)
|
||||||
|
SetValue(fMin);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::SetEnabled(bool value)
|
||||||
|
{
|
||||||
|
if(IsEnabled()==value)
|
||||||
|
return;
|
||||||
|
|
||||||
|
BControl::SetEnabled(value);
|
||||||
|
fTextControl->SetEnabled(value);
|
||||||
|
fTextControl->TextView()->MakeSelectable(value);
|
||||||
|
fUpButton->SetEnabled(value);
|
||||||
|
fDownButton->SetEnabled(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Spinner::MakeFocus(bool value)
|
||||||
|
{
|
||||||
|
fTextControl->MakeFocus(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SpinnerArrowButton::SpinnerArrowButton(BPoint location,
|
||||||
|
const char *name, arrow_direction dir)
|
||||||
|
:BView(BRect(0,0,16,12).OffsetToCopy(location),
|
||||||
|
name, B_FOLLOW_ALL, B_WILL_DRAW)
|
||||||
|
{
|
||||||
|
fDirection=dir;
|
||||||
|
enabled=true;
|
||||||
|
myColor = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
mousedown=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinnerArrowButton::~SpinnerArrowButton(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinnerArrowButton::MouseDown(BPoint pt)
|
||||||
|
{
|
||||||
|
if(enabled==false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!IsEnabled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
mousedown=true;
|
||||||
|
int redcost = 1000;
|
||||||
|
Draw(Bounds());
|
||||||
|
|
||||||
|
BRect bounds = Bounds();
|
||||||
|
uint32 buttons;
|
||||||
|
BPoint point;
|
||||||
|
|
||||||
|
int32 step=parent->GetSteps();
|
||||||
|
int32 newvalue=parent->Value();
|
||||||
|
int32 waitvalue=150000;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if(fDirection==ARROW_UP)
|
||||||
|
{
|
||||||
|
parent->privatedata->arrowdown=ARROW_UP;
|
||||||
|
newvalue+=step;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parent->privatedata->arrowdown=ARROW_DOWN;
|
||||||
|
newvalue-=step;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( newvalue>=parent->GetMin() && newvalue<=parent->GetMax())
|
||||||
|
{
|
||||||
|
// new value is in range, so set it and go
|
||||||
|
parent->SetValue(newvalue);
|
||||||
|
parent->Invoke();
|
||||||
|
// parent->Draw(parent->Bounds());
|
||||||
|
parent->ValueChanged(parent->Value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// new value is out of bounds. Clip to range if current value is not
|
||||||
|
// at the end of its range
|
||||||
|
if(newvalue<parent->GetMin() && parent->Value()!=parent->GetMin())
|
||||||
|
{
|
||||||
|
parent->SetValue(parent->GetMin());
|
||||||
|
parent->Invoke();
|
||||||
|
// parent->Draw(parent->Bounds());
|
||||||
|
parent->ValueChanged(parent->Value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if(newvalue>parent->GetMax() && parent->Value()!=parent->GetMax())
|
||||||
|
{
|
||||||
|
parent->SetValue(parent->GetMax());
|
||||||
|
parent->Invoke();
|
||||||
|
// parent->Draw(parent->Bounds());
|
||||||
|
parent->ValueChanged(parent->Value());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// cases which go here are if new value is <minimum and value already at
|
||||||
|
// minimum or if > maximum and value already at maximum
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Window()->UpdateIfNeeded();
|
||||||
|
|
||||||
|
snooze(waitvalue);
|
||||||
|
|
||||||
|
GetMouse(&point, &buttons, false);
|
||||||
|
|
||||||
|
bool inside = bounds.Contains(point);
|
||||||
|
|
||||||
|
// if ((parent->Value() == B_CONTROL_ON) != inside)
|
||||||
|
// parent->SetValue(inside ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||||
|
|
||||||
|
if(waitvalue<=50000)
|
||||||
|
waitvalue=50000;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
waitvalue -= redcost;
|
||||||
|
redcost = redcost*10;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (buttons != 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinnerArrowButton::MouseUp(BPoint pt)
|
||||||
|
{
|
||||||
|
if(enabled)
|
||||||
|
{
|
||||||
|
mousedown=false;
|
||||||
|
|
||||||
|
if(parent)
|
||||||
|
{
|
||||||
|
parent->privatedata->arrowdown=ARROW_NONE;
|
||||||
|
parent->privatedata->exit_repeater=true;
|
||||||
|
}
|
||||||
|
Draw(Bounds());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinnerArrowButton::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg)
|
||||||
|
{
|
||||||
|
if(enabled==false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(transit==B_ENTERED_VIEW)
|
||||||
|
{
|
||||||
|
BPoint point;
|
||||||
|
uint32 buttons;
|
||||||
|
GetMouse(&point,&buttons);
|
||||||
|
if( (buttons & B_PRIMARY_MOUSE_BUTTON)==0 &&
|
||||||
|
(buttons & B_SECONDARY_MOUSE_BUTTON)==0 &&
|
||||||
|
(buttons & B_PRIMARY_MOUSE_BUTTON)==0 )
|
||||||
|
mousedown=false;
|
||||||
|
else
|
||||||
|
mousedown=true;
|
||||||
|
Draw(Bounds());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(transit==B_EXITED_VIEW || transit==B_OUTSIDE_VIEW)
|
||||||
|
MouseUp(Bounds().LeftTop());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinnerArrowButton::Draw(BRect update)
|
||||||
|
{
|
||||||
|
BRect rect(Bounds());
|
||||||
|
rgb_color background = B_TRANSPARENT_COLOR;
|
||||||
|
if (Parent())
|
||||||
|
background = Parent()->ViewColor();
|
||||||
|
if (background == B_TRANSPARENT_COLOR)
|
||||||
|
background = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
|
||||||
|
uint32 flags = 0;
|
||||||
|
if(!parent->IsEnabled())
|
||||||
|
flags |= BControlLook::B_DISABLED;
|
||||||
|
if(mousedown)
|
||||||
|
flags = 1 << 2;
|
||||||
|
BRect r(Bounds());
|
||||||
|
if(fDirection == ARROW_UP)
|
||||||
|
r.bottom = r.bottom*2;
|
||||||
|
else
|
||||||
|
r.top = - r.bottom;
|
||||||
|
be_control_look->DrawButtonFrame(this, r, update, base, background, flags);
|
||||||
|
be_control_look->DrawButtonBackground(this, r, update, base, flags);
|
||||||
|
|
||||||
|
rect.InsetBy(2.0,2.0);
|
||||||
|
base = ui_color(B_PANEL_TEXT_COLOR);
|
||||||
|
float tint = B_NO_TINT;
|
||||||
|
if(!parent->IsEnabled())
|
||||||
|
tint = B_LIGHTEN_MAX_TINT;
|
||||||
|
be_control_look->DrawArrowShape(this, rect, update, base, fDirection, flags, tint);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinnerArrowButton::AttachedToWindow(void)
|
||||||
|
{
|
||||||
|
parent=(Spinner*)Parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinnerArrowButton::DetachedToWindow(void)
|
||||||
|
{
|
||||||
|
parent=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinnerArrowButton::SetEnabled(bool value)
|
||||||
|
{
|
||||||
|
enabled=value;
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinnerArrowButton::SetViewColor(rgb_color color)
|
||||||
|
{
|
||||||
|
myColor = color;
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinnerMsgFilter::SpinnerMsgFilter(void)
|
||||||
|
: BMessageFilter(B_PROGRAMMED_DELIVERY, B_ANY_SOURCE,B_KEY_DOWN)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinnerMsgFilter::~SpinnerMsgFilter(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
filter_result SpinnerMsgFilter::Filter(BMessage *msg, BHandler **target)
|
||||||
|
{
|
||||||
|
int32 c;
|
||||||
|
msg->FindInt32("raw_char",&c);
|
||||||
|
switch(c)
|
||||||
|
{
|
||||||
|
case B_ENTER:
|
||||||
|
{
|
||||||
|
BTextView *text=dynamic_cast<BTextView*>(*target);
|
||||||
|
if(text && text->IsFocus())
|
||||||
|
{
|
||||||
|
BView *view=text->Parent();
|
||||||
|
while(view)
|
||||||
|
{
|
||||||
|
Spinner *spin=dynamic_cast<Spinner*>(view);
|
||||||
|
if(spin)
|
||||||
|
{
|
||||||
|
BString string(text->Text());
|
||||||
|
int32 newvalue=0;
|
||||||
|
|
||||||
|
sscanf(string.String(),"%ld",&newvalue);
|
||||||
|
if(newvalue!=spin->Value())
|
||||||
|
{
|
||||||
|
spin->SetValue(newvalue);
|
||||||
|
spin->Invoke();
|
||||||
|
}
|
||||||
|
return B_SKIP_MESSAGE;
|
||||||
|
}
|
||||||
|
view=view->Parent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return B_DISPATCH_MESSAGE;
|
||||||
|
}/*
|
||||||
|
case B_TAB:
|
||||||
|
{
|
||||||
|
// Cause Tab characters to perform keybaord navigation
|
||||||
|
BHandler *h=*target;
|
||||||
|
BView *v=NULL;
|
||||||
|
|
||||||
|
h=h->NextHandler();
|
||||||
|
while(h)
|
||||||
|
{
|
||||||
|
v=dynamic_cast<BView*>(h);
|
||||||
|
if(v)
|
||||||
|
{
|
||||||
|
*target=v->Window();
|
||||||
|
return B_DISPATCH_MESSAGE;
|
||||||
|
}
|
||||||
|
h=h->NextHandler();
|
||||||
|
}
|
||||||
|
return B_SKIP_MESSAGE;
|
||||||
|
// return B_DISPATCH_MESSAGE;
|
||||||
|
}*/
|
||||||
|
case B_UP_ARROW:
|
||||||
|
case B_DOWN_ARROW:
|
||||||
|
{
|
||||||
|
BTextView *text=dynamic_cast<BTextView*>(*target);
|
||||||
|
if(text && text->IsFocus())
|
||||||
|
{
|
||||||
|
// We have a text view. See if it currently has the focus and belongs
|
||||||
|
// to a Spinner control. If so, change the value of the spinner
|
||||||
|
|
||||||
|
// TextViews are complicated beasts which are actually multiple views.
|
||||||
|
// Travel up the hierarchy to see if any of the target's ancestors are
|
||||||
|
// a Spinner.
|
||||||
|
|
||||||
|
BView *view=text->Parent();
|
||||||
|
while(view)
|
||||||
|
{
|
||||||
|
Spinner *spin=dynamic_cast<Spinner*>(view);
|
||||||
|
if(spin)
|
||||||
|
{
|
||||||
|
int32 step=spin->GetSteps();
|
||||||
|
if(c==B_DOWN_ARROW)
|
||||||
|
step=0-step;
|
||||||
|
|
||||||
|
spin->SetValue(spin->Value()+step);
|
||||||
|
spin->Invoke();
|
||||||
|
return B_SKIP_MESSAGE;
|
||||||
|
}
|
||||||
|
view=view->Parent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_DISPATCH_MESSAGE;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return B_DISPATCH_MESSAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// shut the stupid compiler up
|
||||||
|
return B_SKIP_MESSAGE;
|
||||||
|
}
|
||||||
59
src/Spinner.h
Normal file
59
src/Spinner.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
#ifndef SPINNER_H_
|
||||||
|
#define SPINNER_H_
|
||||||
|
|
||||||
|
#include <Control.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
#include <Button.h>
|
||||||
|
#include <StringView.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
|
||||||
|
class SpinnerPrivateData;
|
||||||
|
class SpinnerArrowButton;
|
||||||
|
class SpinnerMsgFilter;
|
||||||
|
|
||||||
|
class Spinner : public BControl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Spinner(BRect frame, const char *name, const char *label, int32 min, int32 max, int32 step, BMessage *msg,
|
||||||
|
uint32 resize=B_FOLLOW_LEFT|B_FOLLOW_TOP,uint32 flags=B_WILL_DRAW|B_NAVIGABLE);
|
||||||
|
virtual ~Spinner(void);
|
||||||
|
virtual void AttachedToWindow(void);
|
||||||
|
virtual void DetachedFromWindow(void);
|
||||||
|
virtual void ValueChanged(int32 value);
|
||||||
|
virtual void MessageReceived(BMessage *msg);
|
||||||
|
virtual void SetViewColor(rgb_color color);
|
||||||
|
|
||||||
|
virtual void SetSteps(int32 stepsize);
|
||||||
|
int32 GetSteps(void) const { return fStep; }
|
||||||
|
|
||||||
|
virtual void SetRange(int32 min, int32 max);
|
||||||
|
void GetRange(int32 *min, int32 *max);
|
||||||
|
|
||||||
|
virtual void SetMax(int32 max);
|
||||||
|
int32 GetMax(void) const { return fMax; }
|
||||||
|
virtual void SetMin(int32 min);
|
||||||
|
int32 GetMin(void) const { return fMin; }
|
||||||
|
|
||||||
|
virtual void MakeFocus(bool value=true);
|
||||||
|
|
||||||
|
virtual void SetValue(int32 value);
|
||||||
|
// int32 Value();
|
||||||
|
virtual void SetLabel(const char *text);
|
||||||
|
BTextControl *TextControl(void) const { return fTextControl; }
|
||||||
|
|
||||||
|
virtual void SetEnabled(bool value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class SpinnerArrowButton;
|
||||||
|
friend class SpinnerPrivateData;
|
||||||
|
|
||||||
|
BTextControl *fTextControl;
|
||||||
|
SpinnerArrowButton *fUpButton, *fDownButton;
|
||||||
|
SpinnerPrivateData *privatedata;
|
||||||
|
|
||||||
|
int32 fStep;
|
||||||
|
int32 fMin, fMax;
|
||||||
|
SpinnerMsgFilter *fFilter;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
726
src/SplitPane.cpp
Normal file
726
src/SplitPane.cpp
Normal file
@@ -0,0 +1,726 @@
|
|||||||
|
/*******************************************************
|
||||||
|
* SplitPane©
|
||||||
|
*
|
||||||
|
* SplitPane is a usefull UI component. It alows the
|
||||||
|
* use to ajust two view Horizontaly or Vertacly so
|
||||||
|
* that they are a desired size. This type of Pane
|
||||||
|
* shows up most comonly in Mail/News Readers.
|
||||||
|
*
|
||||||
|
* @author YNOP (ynop@acm.org)
|
||||||
|
* @version beta
|
||||||
|
* @date Dec. 10 1999
|
||||||
|
*******************************************************/
|
||||||
|
#include <AppKit.h>
|
||||||
|
#include <InterfaceKit.h>
|
||||||
|
#include <StorageKit.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <TranslationKit.h>
|
||||||
|
#include <TranslationUtils.h>
|
||||||
|
|
||||||
|
//#include <stdio.h>
|
||||||
|
|
||||||
|
#include "SplitPane.h"
|
||||||
|
//#include "SplitPaneConfig.h"
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Setup the main view. Add in all the niffty components
|
||||||
|
* we have made and get things rolling
|
||||||
|
*******************************************************/
|
||||||
|
SplitPane::SplitPane(BRect frame, const char* name, BView *one, BView *two,uint32 Mode):BView(frame, name, Mode,B_WILL_DRAW|B_FRAME_EVENTS){
|
||||||
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // This is default get from parent if exist
|
||||||
|
//SetViewColor(B_TRANSPARENT_32_BIT); // go tran so we have control over drawing
|
||||||
|
BRect b;
|
||||||
|
b = Bounds();
|
||||||
|
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
PaneOne = one;
|
||||||
|
PaneTwo = two;
|
||||||
|
|
||||||
|
align = B_VERTICAL; // Most people use it this way
|
||||||
|
pos = (int)b.Width()/2; // Center is a good start place
|
||||||
|
thickness = 10;
|
||||||
|
jump = 1; // 1 makes a smother slide
|
||||||
|
VOneDetachable = false;
|
||||||
|
VTwoDetachable = false;
|
||||||
|
pad = 1;
|
||||||
|
MinSizeOne = 0; // full left
|
||||||
|
MinSizeTwo = 0; // full right
|
||||||
|
poslocked = false; // free movement
|
||||||
|
alignlocked = false; // free alignment
|
||||||
|
Draggin = false;
|
||||||
|
attached = false;
|
||||||
|
|
||||||
|
WinOne = NULL;
|
||||||
|
WinTwo = NULL;
|
||||||
|
ConfigWindow = NULL;
|
||||||
|
|
||||||
|
AddChild(one);
|
||||||
|
AddChild(two);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* When ready grap the parents color and refreash.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::AttachedToWindow(){
|
||||||
|
//SetViewColor(Parent()->ViewColor());
|
||||||
|
attached = true;
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* If we are being resized. Fix the stuff we need to fix
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::FrameResized(float,float){
|
||||||
|
// if bar is on the left side follow left
|
||||||
|
// else if it is on the right side follow the right
|
||||||
|
// Need to implements smart follow still
|
||||||
|
Update();
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* The main draw stuff here. basicly just the slider
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::Draw(BRect f){
|
||||||
|
SetHighColor(160,160,160);
|
||||||
|
|
||||||
|
if(align == B_VERTICAL){
|
||||||
|
SetHighColor(185,185,185);
|
||||||
|
// SetHighColor(145,145,145);
|
||||||
|
//FillRect(BRect(pos,Bounds().top+pad+1,pos,Bounds().bottom-pad-1)); // 145
|
||||||
|
FillRect(BRect(pos,Bounds().top+pad+1,pos,Bounds().bottom-pad-1)); // 145
|
||||||
|
|
||||||
|
SetHighColor(255,255,255);
|
||||||
|
FillRect(BRect(pos+1,Bounds().top+pad+1,pos+2,Bounds().bottom-pad-1)); // 255
|
||||||
|
|
||||||
|
//SetHighColor(216,216,216);
|
||||||
|
SetHighColor(Parent()->ViewColor());
|
||||||
|
FillRect(BRect(pos+2,Bounds().top+pad+1,pos+thickness-2,Bounds().bottom-pad-1));// 216
|
||||||
|
|
||||||
|
if(thickness>9)
|
||||||
|
{
|
||||||
|
float y = (Bounds().bottom - Bounds().top)/2;
|
||||||
|
float x = pos + (thickness/2);
|
||||||
|
SetPenSize(2);
|
||||||
|
SetHighColor(255,255,255);
|
||||||
|
StrokeLine(BPoint(x-3,y-11),BPoint(x+3,y-5));
|
||||||
|
StrokeLine(BPoint(x-3,y-7),BPoint(x+3,y-1));
|
||||||
|
StrokeLine(BPoint(x-3,y-3),BPoint(x+3,y+3));
|
||||||
|
StrokeLine(BPoint(x-3,y+1),BPoint(x+3,y+7));
|
||||||
|
StrokeLine(BPoint(x-3,y+5),BPoint(x+3,y+11));
|
||||||
|
SetPenSize(1);
|
||||||
|
SetHighColor(145,145,145);
|
||||||
|
StrokeLine(BPoint(x-3,y-10),BPoint(x+3,y-4));
|
||||||
|
StrokeLine(BPoint(x-3,y-6),BPoint(x+3,y+0));
|
||||||
|
StrokeLine(BPoint(x-3,y-2),BPoint(x+3,y+4));
|
||||||
|
StrokeLine(BPoint(x-3,y+2),BPoint(x+3,y+8));
|
||||||
|
StrokeLine(BPoint(x-3,y+6),BPoint(x+3,y+12));
|
||||||
|
}
|
||||||
|
|
||||||
|
SetHighColor(185,185,185);
|
||||||
|
// SetHighColor(145,145,145);
|
||||||
|
FillRect(BRect(pos+thickness-2,Bounds().top+pad+1,pos+thickness-2,Bounds().bottom-pad-1)) ;// 145
|
||||||
|
|
||||||
|
SetHighColor(145,145,145);
|
||||||
|
FillRect(BRect(pos+thickness-1,Bounds().top+pad+1,pos+thickness-1,Bounds().bottom-pad-1)); // 96
|
||||||
|
//FillRect(BRect(pos+thickness,Bounds().top+pad+1,pos+thickness,Bounds().bottom-pad-1));
|
||||||
|
}else{
|
||||||
|
SetHighColor(185,185,185);
|
||||||
|
// SetHighColor(145,145,145);
|
||||||
|
//FillRect(BRect(Bounds().left+pad+1,pos,Bounds().right-pad-1,pos)); // 145
|
||||||
|
FillRect(BRect(Bounds().left+pad+1,pos,Bounds().right-pad-1,pos)); // 145
|
||||||
|
|
||||||
|
SetHighColor(255,255,255);
|
||||||
|
FillRect(BRect(Bounds().left+pad+1,pos+1,Bounds().right-pad-1,pos+2)); // 255
|
||||||
|
|
||||||
|
//SetHighColor(216,216,216);
|
||||||
|
SetHighColor(Parent()->ViewColor());
|
||||||
|
FillRect(BRect(Bounds().left+pad+1,pos+2,Bounds().right-pad-1,pos+thickness-2));// 216
|
||||||
|
|
||||||
|
if(thickness>9)
|
||||||
|
{
|
||||||
|
SetHighColor(255,255,255);
|
||||||
|
float x = (Bounds().right - Bounds().left)/2;
|
||||||
|
float y = pos + (thickness/2);
|
||||||
|
SetPenSize(2);
|
||||||
|
StrokeLine(BPoint(x-11,y-3),BPoint(x-5,y+3));
|
||||||
|
StrokeLine(BPoint(x-7,y-3),BPoint(x-1,y+3));
|
||||||
|
StrokeLine(BPoint(x-3,y-3),BPoint(x+3,y+3));
|
||||||
|
StrokeLine(BPoint(x+1,y-3),BPoint(x+7,y+3));
|
||||||
|
StrokeLine(BPoint(x+5,y-3),BPoint(x+11,y+3));
|
||||||
|
SetPenSize(1);
|
||||||
|
SetHighColor(145,145,145);
|
||||||
|
StrokeLine(BPoint(x-10,y-3),BPoint(x-4,y+3));
|
||||||
|
StrokeLine(BPoint(x-6,y-3),BPoint(x+0,y+3));
|
||||||
|
StrokeLine(BPoint(x-2,y-3),BPoint(x+4,y+3));
|
||||||
|
StrokeLine(BPoint(x+2,y-3),BPoint(x+8,y+3));
|
||||||
|
StrokeLine(BPoint(x+6,y-3),BPoint(x+12,y+3));
|
||||||
|
}
|
||||||
|
|
||||||
|
SetHighColor(185,185,185);
|
||||||
|
// SetHighColor(145,145,145);
|
||||||
|
FillRect(BRect(Bounds().left+pad+1,pos+thickness-2,Bounds().right-pad-1,pos+thickness-2)) ;// 145
|
||||||
|
|
||||||
|
SetHighColor(145,145,145);
|
||||||
|
// SetHighColor(96,96,96);
|
||||||
|
FillRect(BRect(Bounds().left+pad+1,pos+thickness-1,Bounds().right-pad-1,pos+thickness-1)); // 96
|
||||||
|
//FillRect(BRect(Bounds().left+pad+1,pos+thickness,Bounds().right-pad-1,pos+thickness));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Keeps Modes for both panles uptodate and acctually
|
||||||
|
* is the func that sets the location of the slider
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::Update(){
|
||||||
|
Window()->Lock();
|
||||||
|
if(align == B_VERTICAL){
|
||||||
|
PaneOne->SetResizingMode(B_FOLLOW_LEFT|B_FOLLOW_TOP_BOTTOM);
|
||||||
|
PaneTwo->SetResizingMode(B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP_BOTTOM);
|
||||||
|
if(pos > (Bounds().Width()-thickness-MinSizeTwo)){
|
||||||
|
if(!poslocked){
|
||||||
|
pos = (int)Bounds().Width()-thickness-MinSizeTwo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(pos < MinSizeOne){
|
||||||
|
if(!poslocked){
|
||||||
|
pos = MinSizeOne;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
PaneOne->SetResizingMode(B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP);
|
||||||
|
PaneTwo->SetResizingMode(B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP_BOTTOM);
|
||||||
|
if(pos > (Bounds().Height()-thickness-MinSizeTwo)){
|
||||||
|
if(!poslocked){
|
||||||
|
pos = (int)Bounds().Height()-thickness-MinSizeTwo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(pos < MinSizeOne){
|
||||||
|
if(!poslocked){
|
||||||
|
pos = MinSizeOne;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// this block should go in FrameResized .. think about it
|
||||||
|
if(align == B_VERTICAL){
|
||||||
|
if(pos >= (Bounds().IntegerWidth()/2)){
|
||||||
|
//pos should follow the right side
|
||||||
|
// staying the same distans from it that
|
||||||
|
// it is right now
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(pos >= (Bounds().IntegerHeight()/2)){
|
||||||
|
//should follow bottom and stay the
|
||||||
|
// same distance that we are way from
|
||||||
|
// it now
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(PaneOne){
|
||||||
|
if(!WinOne){
|
||||||
|
if(align == B_VERTICAL){
|
||||||
|
PaneOne->MoveTo(pad,Bounds().top+pad);
|
||||||
|
PaneOne->ResizeTo(pos-pad, Bounds().Height()-pad-pad); // widht x height
|
||||||
|
}else{
|
||||||
|
PaneOne->MoveTo(pad,Bounds().top+pad);
|
||||||
|
PaneOne->ResizeTo(Bounds().Width()-pad-pad, pos-pad-pad); // widht x height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(PaneTwo){
|
||||||
|
if(!WinTwo){
|
||||||
|
if(align == B_VERTICAL){
|
||||||
|
PaneTwo->MoveTo(pos+thickness,Bounds().top+pad);
|
||||||
|
PaneTwo->ResizeTo(Bounds().Width()-(pos+thickness)-pad, Bounds().Height()-pad-pad);
|
||||||
|
}else{
|
||||||
|
PaneTwo->MoveTo(Bounds().left+pad,pos+thickness);
|
||||||
|
PaneTwo->ResizeTo(Bounds().Width()-pad-pad, Bounds().Height()-pos-pad-thickness);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Window()->Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Hook for when we click. This takes care of all the
|
||||||
|
* little stuff - Like where is the mouse and what is
|
||||||
|
* going on.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::MouseDown(BPoint where){
|
||||||
|
Window()->Lock();
|
||||||
|
BMessage *currentMsg = Window()->CurrentMessage();
|
||||||
|
if (currentMsg->what == B_MOUSE_DOWN) {
|
||||||
|
uint32 buttons = 0;
|
||||||
|
currentMsg->FindInt32("buttons", (int32 *)&buttons);
|
||||||
|
uint32 modifiers = 0;
|
||||||
|
currentMsg->FindInt32("modifiers", (int32 *)&modifiers);
|
||||||
|
uint32 clicks = 0;
|
||||||
|
currentMsg->FindInt32("clicks",(int32*)&clicks);
|
||||||
|
|
||||||
|
if (buttons & B_SECONDARY_MOUSE_BUTTON){
|
||||||
|
if(!alignlocked){
|
||||||
|
switch(align){
|
||||||
|
case B_VERTICAL:
|
||||||
|
align = B_HORIZONTAL;
|
||||||
|
break;
|
||||||
|
case B_HORIZONTAL:
|
||||||
|
align = B_VERTICAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Update();
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if(VOneDetachable){
|
||||||
|
WinOne = new BWindow(ConvertToScreen(PaneOne->Bounds()),"PanelOne",B_TITLED_WINDOW,B_ASYNCHRONOUS_CONTROLS);
|
||||||
|
RemoveChild(PaneOne);
|
||||||
|
WinOne->AddChild(PaneOne);
|
||||||
|
PaneOne->SetResizingMode(B_FOLLOW_ALL_SIDES);
|
||||||
|
// PaneOne->SetTarget(this);
|
||||||
|
WinOne->Show();
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
// if((buttons & B_PRIMARY_MOUSE_BUTTON) && (clicks >= 2)){
|
||||||
|
//Config window for split pane
|
||||||
|
// (new BAlert(NULL,"This is - or will be - a configuration panel for SplitPane.","Ok"))->Go();
|
||||||
|
//ConfigWindow = new SplitPaneConfig(this);
|
||||||
|
//ConfigWindow->Show();
|
||||||
|
//}else
|
||||||
|
if((buttons & B_PRIMARY_MOUSE_BUTTON) && !Draggin){
|
||||||
|
if(!poslocked){
|
||||||
|
Draggin= true; // this is so we can drag
|
||||||
|
here = where;
|
||||||
|
}
|
||||||
|
SetMouseEventMask(B_POINTER_EVENTS,B_LOCK_WINDOW_FOCUS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Window()->Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* If we unclick then stop dragging or whatever it is
|
||||||
|
* we are doing
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::MouseUp(BPoint where){
|
||||||
|
Draggin = false; // stop following mouse
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* If the mouse moves while we dragg. Then follow it
|
||||||
|
* Also Invalidate so we update the views
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::MouseMoved(BPoint where,uint32 info,const BMessage *m){
|
||||||
|
if(Draggin){
|
||||||
|
switch(align){
|
||||||
|
case B_HORIZONTAL:
|
||||||
|
pos = (int)(where.y)-(thickness/2);//- here.x
|
||||||
|
break;
|
||||||
|
case B_VERTICAL:
|
||||||
|
pos = (int)(where.x)-(thickness/2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// This code figures out which jump we are closest
|
||||||
|
// to and if needed we "snap" to that.
|
||||||
|
int c = Bounds().IntegerWidth() / pos
|
||||||
|
Jump * c ... hmmm this is not right at all
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(pos < MinSizeOne){
|
||||||
|
pos = MinSizeOne;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(align == B_VERTICAL){
|
||||||
|
if(pos > (Bounds().Width() - thickness - MinSizeTwo)){
|
||||||
|
pos = (int)(Bounds().Width() - thickness - MinSizeTwo + 1);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(pos > (Bounds().Height() - thickness - MinSizeTwo)){
|
||||||
|
pos = (int)(Bounds().Height() - thickness - MinSizeTwo + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Update();
|
||||||
|
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* If you already have a view One, but want to change
|
||||||
|
* if for some odd reason. This should work.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::AddChildOne(BView *v){
|
||||||
|
RemoveChild(PaneOne);
|
||||||
|
PaneOne = v;
|
||||||
|
AddChild(PaneOne);
|
||||||
|
}
|
||||||
|
/*void SplitPane::MakePaneTwoFocus()
|
||||||
|
{
|
||||||
|
if(PaneTwo)
|
||||||
|
PaneTwo->MakeFocus();
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*******************************************************
|
||||||
|
* If you already have a view Two, and want to put
|
||||||
|
* another view there, this is what to use.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::AddChildTwo(BView* v,bool IsAdded,bool ShowAfterHide)
|
||||||
|
{
|
||||||
|
if(!v->IsHidden())
|
||||||
|
v->Hide();
|
||||||
|
|
||||||
|
PaneTwo = v;
|
||||||
|
//WinTwo = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
PaneTwo = v;
|
||||||
|
if(IsAdded)
|
||||||
|
{
|
||||||
|
Update();
|
||||||
|
if(ShowAfterHide)
|
||||||
|
{
|
||||||
|
if(v->IsHidden())
|
||||||
|
v->Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if(!IsAdded)
|
||||||
|
{
|
||||||
|
AddChild(PaneTwo);
|
||||||
|
}
|
||||||
|
PaneTwo = v;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Sets is we are horizontal or Vertical. We use the
|
||||||
|
* standard B_HORIZONTAL and B_VERTICAL flags for this
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetAlignment(uint a){
|
||||||
|
align = a;
|
||||||
|
if(attached){
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Returns wheather the slider is horizontal or vertical
|
||||||
|
*******************************************************/
|
||||||
|
uint SplitPane::GetAlignment(){
|
||||||
|
return align;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Sets the location of the bar. (we do no bounds
|
||||||
|
* checking for you so if its off the window thats
|
||||||
|
* your problem)
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetBarPosition(int i){
|
||||||
|
pos = i;
|
||||||
|
if(attached){
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Returns about where the bar is ...
|
||||||
|
*******************************************************/
|
||||||
|
int SplitPane::GetBarPosition(){
|
||||||
|
return pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Sets how thick the bar should be.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetBarThickness(int i){
|
||||||
|
thickness = i;
|
||||||
|
if(attached){
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Retuns to us the thickness of the slider bar
|
||||||
|
*******************************************************/
|
||||||
|
int SplitPane::GetBarThickness(){
|
||||||
|
return thickness;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Sets the amount of jump the bar has when it is
|
||||||
|
* moved. This can also be though of as snap. The bar
|
||||||
|
* will start at 0 and jump(snap) to everry J pixels.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetJump(int i){
|
||||||
|
jump = i;
|
||||||
|
if(attached){
|
||||||
|
Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Lets you know what the jump is .. see SetJump
|
||||||
|
*******************************************************/
|
||||||
|
int SplitPane::GetJump(){
|
||||||
|
return jump;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Do we have a View One or is it NULL
|
||||||
|
*******************************************************/
|
||||||
|
bool SplitPane::HasViewOne(){
|
||||||
|
if(PaneOne) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Do we have a View Two .. or is it NULL too
|
||||||
|
*******************************************************/
|
||||||
|
bool SplitPane::HasViewTwo(){
|
||||||
|
if(PaneTwo) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Sets wheather View one is detachable from the
|
||||||
|
* slider view and from the app. This will creat a
|
||||||
|
* window that is detached (floating) from the app.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetViewOneDetachable(bool b){
|
||||||
|
VOneDetachable = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Sets view tow detachable or not
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetViewTwoDetachable(bool b){
|
||||||
|
VTwoDetachable = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Returns whether the view is detachable
|
||||||
|
*******************************************************/
|
||||||
|
bool SplitPane::IsViewOneDetachable(){
|
||||||
|
return VOneDetachable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Returns if this view is detachable
|
||||||
|
*******************************************************/
|
||||||
|
bool SplitPane::IsViewTwoDetachable(){
|
||||||
|
return VTwoDetachable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Tells the view if the user is alowed to open the
|
||||||
|
* configuration window for the slider.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetEditable(bool b){
|
||||||
|
//ADD CODE HERE YNOP
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Tells use if the split pane is user editable
|
||||||
|
*******************************************************/
|
||||||
|
bool SplitPane::IsEditable(){
|
||||||
|
return true; //ADD SOME MORE CODE HERE
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Sets the inset that the view has.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetViewInsetBy(int i){
|
||||||
|
pad = i;
|
||||||
|
if(attached){
|
||||||
|
Update();
|
||||||
|
} Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Returns to use the padding around the views
|
||||||
|
*******************************************************/
|
||||||
|
int SplitPane::GetViewInsetBy(){
|
||||||
|
return pad;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* This sets the minimum size that View one can be.
|
||||||
|
* if the user trys to go past this .. we just stop
|
||||||
|
* By default the minimum size is set to 0 (zero) so
|
||||||
|
* the user can put the slider anywhere.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetMinSizeOne(int i){
|
||||||
|
MinSizeOne = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Gives us the minimum size that one can be.
|
||||||
|
*******************************************************/
|
||||||
|
int SplitPane::GetMinSizeOne(){
|
||||||
|
return MinSizeOne;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* This sets the Minimum size that the second view
|
||||||
|
* can be.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetMinSizeTwo(int i){
|
||||||
|
MinSizeTwo = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Lets us know what that minimum size is.
|
||||||
|
*******************************************************/
|
||||||
|
int SplitPane::GetMinSizeTwo(){
|
||||||
|
return MinSizeTwo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Locks the bar from being moved by the User. The
|
||||||
|
* system can still move the bar (via SetBarPosition)
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetBarLocked(bool b){
|
||||||
|
poslocked = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Returns to use if the bar is in a locked state or
|
||||||
|
* not.
|
||||||
|
*******************************************************/
|
||||||
|
bool SplitPane::IsBarLocked(){
|
||||||
|
return poslocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Locks the alignment of the bar. The user can no
|
||||||
|
* longer toggle between Horizontal and Vertical
|
||||||
|
* Slider bar. Again you can still progomaticly set
|
||||||
|
* the position how ever you want.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetBarAlignmentLocked(bool b){
|
||||||
|
alignlocked = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Lets us know about the lock state of the bar
|
||||||
|
*******************************************************/
|
||||||
|
bool SplitPane::IsBarAlignmentLocked(){
|
||||||
|
return alignlocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Gets the Total state of the bar, alignment, size,
|
||||||
|
* position and many other things that are required
|
||||||
|
* to fully capture the state of the SplitPane.
|
||||||
|
* We pack all of this into a cute little BMessage
|
||||||
|
* so that it is esally expandable and can be saved
|
||||||
|
* off easyaly too. The SplitPane System does not
|
||||||
|
* however save the state for you. Your program must
|
||||||
|
* grab the state and save it in its config file.
|
||||||
|
*******************************************************/
|
||||||
|
BMessage* SplitPane::GetState(){
|
||||||
|
BMessage *state;
|
||||||
|
|
||||||
|
state = new BMessage(SPLITPANE_STATE);
|
||||||
|
|
||||||
|
state->AddBool("onedetachable",VOneDetachable);
|
||||||
|
state->AddBool("twodetachable",VTwoDetachable);
|
||||||
|
state->AddInt32("align",align);
|
||||||
|
state->AddInt32("pos",pos);
|
||||||
|
state->AddInt32("thick",thickness);
|
||||||
|
state->AddInt32("jump",jump);
|
||||||
|
state->AddInt32("pad",pad);
|
||||||
|
state->AddInt32("minsizeone",MinSizeOne);
|
||||||
|
state->AddInt32("minsizetwo",MinSizeTwo);
|
||||||
|
state->AddBool("poslock",poslocked);
|
||||||
|
state->AddBool("alignlock",alignlocked);
|
||||||
|
return state;
|
||||||
|
// delete state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Sets the state of the SplitPane from a BMessage
|
||||||
|
* like the one recived from GetState().
|
||||||
|
* This is one of three ways the user can rebuild the
|
||||||
|
* state of the SplitPane. The second is to simply
|
||||||
|
* send the SplitPane the state message, it is the
|
||||||
|
* same as calling SetState but it ashyncronouse.
|
||||||
|
* The third way is to use all the Get/Set methouds
|
||||||
|
* for each element of the SplitPane, this way is
|
||||||
|
* long and boarding. I suggest you just send the
|
||||||
|
* View a message :)
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::SetState(BMessage *state){
|
||||||
|
int32 Npos,Nthickness,Njump,Npad,NMSO,NMST;
|
||||||
|
int32 Nalign;//uint
|
||||||
|
|
||||||
|
if(state->FindBool("onedetachable",&VOneDetachable) != B_OK){
|
||||||
|
VOneDetachable = false;
|
||||||
|
}
|
||||||
|
if(state->FindBool("towdetachable",&VTwoDetachable) != B_OK){
|
||||||
|
VTwoDetachable = false;
|
||||||
|
}
|
||||||
|
if(state->FindInt32("align",&Nalign) == B_OK){
|
||||||
|
align = Nalign;
|
||||||
|
}
|
||||||
|
if(state->FindInt32("pos",&Npos) == B_OK){
|
||||||
|
pos = Npos;
|
||||||
|
}
|
||||||
|
if(state->FindInt32("thick",&Nthickness) == B_OK){
|
||||||
|
thickness = Nthickness;
|
||||||
|
}
|
||||||
|
if(state->FindInt32("jump",&Njump) == B_OK){
|
||||||
|
jump = Njump;
|
||||||
|
}
|
||||||
|
if(state->FindInt32("pad",&Npad) == B_OK){
|
||||||
|
pad = Npad;
|
||||||
|
}
|
||||||
|
if(state->FindInt32("minsizeonw",&NMSO) == B_OK){
|
||||||
|
MinSizeOne = NMSO;
|
||||||
|
}
|
||||||
|
if(state->FindInt32("minsizetwo",&NMST) == B_OK){
|
||||||
|
MinSizeTwo = NMST;
|
||||||
|
}
|
||||||
|
if(state->FindBool("poslock",&poslocked) != B_OK){
|
||||||
|
poslocked = false;
|
||||||
|
}
|
||||||
|
if(state->FindBool("alignlock",&alignlocked) != B_OK){
|
||||||
|
alignlocked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Update();
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*******************************************************
|
||||||
|
* Ok, hmm what does this do. NOT MUCH. if we get a
|
||||||
|
* STATE message then lets set the state. This is here
|
||||||
|
* to provide a asyncronuse way of seting the state and
|
||||||
|
* also to make life easyer.
|
||||||
|
*******************************************************/
|
||||||
|
void SplitPane::MessageReceived(BMessage *msg){
|
||||||
|
switch(msg->what){
|
||||||
|
case SPLITPANE_STATE:
|
||||||
|
SetState(msg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BView::MessageReceived(msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
93
src/SplitPane.h
Normal file
93
src/SplitPane.h
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/*******************************************************
|
||||||
|
* SplitPane©
|
||||||
|
*
|
||||||
|
* SplitPane is a usefull UI component. It alows the
|
||||||
|
* use to ajust two view Horizontaly or Vertacly so
|
||||||
|
* that they are a desired size. This type of Pane
|
||||||
|
* shows up most comonly in Mail/News Readers.
|
||||||
|
*
|
||||||
|
* @author YNOP (ynop@acm.org)
|
||||||
|
* @version beta
|
||||||
|
* @date Dec. 10 1999
|
||||||
|
*******************************************************/
|
||||||
|
#ifndef _SPLIT_PANE_VIEW_H
|
||||||
|
#define _SPLIT_PANE_VIEW_H
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
|
#include <AppKit.h>
|
||||||
|
// #include <InterfaceKit.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <ScrollView.h>
|
||||||
|
#define SPLITPANE_STATE 'spst'
|
||||||
|
|
||||||
|
class SplitPane : public BView {
|
||||||
|
public:
|
||||||
|
SplitPane(BRect,const char*,BView*,BView*,uint32);
|
||||||
|
void AddChildOne(BView*);
|
||||||
|
void AddChildTwo(BView* v,bool IsAdded,bool ShowAfterHide);
|
||||||
|
void SetAlignment(uint);
|
||||||
|
uint GetAlignment();
|
||||||
|
void SetBarPosition(int);
|
||||||
|
int GetBarPosition();
|
||||||
|
void SetBarThickness(int);
|
||||||
|
int GetBarThickness();
|
||||||
|
void SetJump(int);
|
||||||
|
int GetJump();
|
||||||
|
bool HasViewOne();
|
||||||
|
bool HasViewTwo();
|
||||||
|
void SetViewOneDetachable(bool);
|
||||||
|
void SetViewTwoDetachable(bool);
|
||||||
|
bool IsViewOneDetachable();
|
||||||
|
bool IsViewTwoDetachable();
|
||||||
|
void SetEditable(bool);
|
||||||
|
bool IsEditable();
|
||||||
|
void SetViewInsetBy(int);
|
||||||
|
int GetViewInsetBy();
|
||||||
|
void SetMinSizeOne(int);
|
||||||
|
int GetMinSizeOne();
|
||||||
|
void SetMinSizeTwo(int);
|
||||||
|
int GetMinSizeTwo();
|
||||||
|
BMessage* GetState();
|
||||||
|
void SetBarLocked(bool);
|
||||||
|
bool IsBarLocked();
|
||||||
|
void SetBarAlignmentLocked(bool);
|
||||||
|
bool IsBarAlignmentLocked();
|
||||||
|
void SetState(BMessage*);
|
||||||
|
virtual void Draw(BRect);
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void FrameResized(float,float);
|
||||||
|
virtual void MouseDown(BPoint);
|
||||||
|
virtual void MouseUp(BPoint);
|
||||||
|
virtual void MouseMoved(BPoint,uint32,const BMessage*);
|
||||||
|
virtual void MessageReceived(BMessage*);
|
||||||
|
//void MakePaneTwoFocus();
|
||||||
|
private:
|
||||||
|
void Update();
|
||||||
|
BView *PaneOne;
|
||||||
|
BView *PaneTwo;
|
||||||
|
|
||||||
|
//State info
|
||||||
|
bool VOneDetachable;
|
||||||
|
bool VTwoDetachable;
|
||||||
|
uint align;
|
||||||
|
int pos;
|
||||||
|
int thickness;
|
||||||
|
int jump;
|
||||||
|
int pad;
|
||||||
|
int MinSizeOne;
|
||||||
|
int MinSizeTwo;
|
||||||
|
bool poslocked;
|
||||||
|
bool alignlocked;
|
||||||
|
//end State info
|
||||||
|
|
||||||
|
bool Draggin;
|
||||||
|
BPoint here;
|
||||||
|
bool attached;
|
||||||
|
|
||||||
|
BWindow *WinOne;
|
||||||
|
BWindow *WinTwo;
|
||||||
|
|
||||||
|
BWindow *ConfigWindow;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
1126
src/URLView.cpp
Normal file
1126
src/URLView.cpp
Normal file
File diff suppressed because it is too large
Load Diff
141
src/URLView.h
Normal file
141
src/URLView.h
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
/* URLView 2.11
|
||||||
|
written by William Kakes of Tall Hill Software.
|
||||||
|
|
||||||
|
This class provides an underlined and clickable BStringView
|
||||||
|
that will launch the web browser, e-mail program, or FTP client
|
||||||
|
when clicked on. Other features include hover-highlighting,
|
||||||
|
right-click menus, and drag-and-drop support.
|
||||||
|
|
||||||
|
You are free to use URLView in your own programs (both open-source
|
||||||
|
and closed-source) free of charge, but a mention in your read me
|
||||||
|
file or your program's about box would be appreciated. See
|
||||||
|
http://www.tallhill.com for current contact information.
|
||||||
|
|
||||||
|
URLView is provided as-is, with no warranties of any kind. If
|
||||||
|
you use it, you are on your own.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef TH_URL_VIEW_H
|
||||||
|
#define TH_URL_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <Cursor.h>
|
||||||
|
#include <List.h>
|
||||||
|
#include <Mime.h>
|
||||||
|
#include <PopUpMenu.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <StringView.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// This is the link's mouse cursor (a replica of NetPositive's link cursor).
|
||||||
|
const uint8 url_cursor[] = { 16, 1, 1, 2,
|
||||||
|
// This is the cursor data.
|
||||||
|
0x00, 0x00, 0x38, 0x00, 0x24, 0x00, 0x24, 0x00,
|
||||||
|
0x13, 0xe0, 0x12, 0x5c, 0x09, 0x2a, 0x08, 0x01,
|
||||||
|
0x3c, 0x21, 0x4c, 0x71, 0x42, 0x71, 0x30, 0xf9,
|
||||||
|
0x0c, 0xf9, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
|
|
||||||
|
// This is the cursor mask.
|
||||||
|
0x00, 0x00, 0x38, 0x00, 0x3c, 0x00, 0x3c, 0x00,
|
||||||
|
0x1f, 0xe0, 0x1f, 0xfc, 0x0f, 0xfe, 0x0f, 0xff,
|
||||||
|
0x3f, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x3f, 0xff,
|
||||||
|
0x0f, 0xff, 0x03, 0xfe, 0x01, 0xf8, 0x00, 0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// The default link color, blue.
|
||||||
|
const rgb_color blue = { 0, 0, 255 };
|
||||||
|
// The default clicked-link color, red.
|
||||||
|
const rgb_color red = { 255, 0, 0 };
|
||||||
|
// The default link hover color, dark blue.
|
||||||
|
const rgb_color dark_blue = { 0, 0, 120 };
|
||||||
|
// The default disabled color, gray.
|
||||||
|
const rgb_color gray = { 100, 100, 100 };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class URLView : public BStringView {
|
||||||
|
public:
|
||||||
|
URLView( BRect frame, const char *name, const char *label, const char *url,
|
||||||
|
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
|
uint32 flags = B_WILL_DRAW );
|
||||||
|
~URLView();
|
||||||
|
|
||||||
|
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void Draw( BRect updateRect );
|
||||||
|
virtual void MessageReceived( BMessage *message );
|
||||||
|
virtual void MouseDown( BPoint point );
|
||||||
|
virtual void MouseMoved( BPoint point, uint32 transit, const BMessage *message );
|
||||||
|
virtual void MouseUp( BPoint point );
|
||||||
|
virtual void WindowActivated( bool active );
|
||||||
|
|
||||||
|
virtual void AddAttribute( const char *name, const char *value );
|
||||||
|
virtual bool IsEnabled();
|
||||||
|
virtual void SetColor( rgb_color color );
|
||||||
|
virtual void SetColor( uchar red, uchar green, uchar blue, uchar alpha = 255 );
|
||||||
|
virtual void SetClickColor( rgb_color color );
|
||||||
|
virtual void SetClickColor( uchar red, uchar green, uchar blue, uchar alpha = 255 );
|
||||||
|
virtual void SetDisabledColor( rgb_color color );
|
||||||
|
virtual void SetDisabledColor( uchar red, uchar green, uchar blue, uchar alpha = 255 );
|
||||||
|
virtual void SetDraggable( bool draggable );
|
||||||
|
virtual void SetEnabled( bool enabled );
|
||||||
|
virtual void SetHoverColor( rgb_color color );
|
||||||
|
virtual void SetHoverColor( uchar red, uchar green, uchar blue, uchar alpha = 255 );
|
||||||
|
virtual void SetHoverEnabled( bool hover );
|
||||||
|
virtual void SetIconSize( icon_size iconSize );
|
||||||
|
virtual void SetUnderlineThickness( int thickness );
|
||||||
|
virtual void SetURL( const char *url );
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void CopyToClipboard();
|
||||||
|
void CreateBookmark( const BString *fullName, const BString *title );
|
||||||
|
void CreatePerson( const BString *fullName, const BString *title );
|
||||||
|
BPopUpMenu *CreatePopupMenu();
|
||||||
|
void DoBookmarkDrag();
|
||||||
|
void DoPersonDrag();
|
||||||
|
BString GetImportantURL();
|
||||||
|
BRect GetTextRect();
|
||||||
|
BRect GetURLRect();
|
||||||
|
bool IsEmailLink();
|
||||||
|
bool IsFTPLink();
|
||||||
|
bool IsHTMLLink();
|
||||||
|
void LaunchURL();
|
||||||
|
void Redraw();
|
||||||
|
void WriteAttributes( int fd );
|
||||||
|
|
||||||
|
BString *url;
|
||||||
|
rgb_color color;
|
||||||
|
rgb_color clickColor;
|
||||||
|
rgb_color hoverColor;
|
||||||
|
rgb_color disabledColor;
|
||||||
|
bool enabled;
|
||||||
|
bool hoverEnabled;
|
||||||
|
bool draggable;
|
||||||
|
int underlineThickness;
|
||||||
|
int iconSize;
|
||||||
|
|
||||||
|
bool selected;
|
||||||
|
bool hovering;
|
||||||
|
bool draggedOut;
|
||||||
|
bool inPopup;
|
||||||
|
const BCursor *linkCursor;
|
||||||
|
BPoint dragOffset;
|
||||||
|
BList *attributes;
|
||||||
|
|
||||||
|
typedef struct kp {
|
||||||
|
BString *key;
|
||||||
|
BString *value;
|
||||||
|
} KeyPair;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // TH_URL_VIEW
|
||||||
38
src/YAB.rdef
Normal file
38
src/YAB.rdef
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
resource vector_icon {
|
||||||
|
$"6E6369660E0500020006023C43C6B9E5E23A85A83CEE414268F44A445900C6D7"
|
||||||
|
$"F5FF6B94DD03EC66660200060238C5F1BB105D3DFDC23B9CD045487847B50700"
|
||||||
|
$"FFFFFFFFC1CCFF020006023B3049396B0ABA90833C646E4A101543299500FFFF"
|
||||||
|
$"FFFFEBEFFF020006023C71E33A0C78BA15E43C7D2149055549455700E3EDFFFF"
|
||||||
|
$"9EC2FF03FFACAC0200060239D53438FFCBBBC1973C666F4ADC3246DC6C00C1CC"
|
||||||
|
$"FFFFFFFFFF03003CB0020006023C0AE63B3927BC611E3D03FF4C25624A1A9600"
|
||||||
|
$"A3043CFFFF90AF03C93B3B030D296402000602BD498B3E1159BF219BBE7D2F4C"
|
||||||
|
$"1B8F4A331300BD0F0FFFE98484040174100A08325E385E40564E5E545E605058"
|
||||||
|
$"4C3E510A062E2C2E3E3E454A3C4A2A3A250A042E2C2E3E3E453E320A042E2C3E"
|
||||||
|
$"324A2A3A250A043E323E454A3C4A2A0A0338423C4D3C440A0622422254325C3E"
|
||||||
|
$"513E402E3A0A0422422254325C32490A04224232493E402E3A0A043249325C3E"
|
||||||
|
$"513E400A063E423E544E5C5A505A3F4A390A04C222C20F4E495A3F523C0A043E"
|
||||||
|
$"42C222C20F523C4A390A054151C08BC8834E5C4E49C22AC2130A053E423E54C0"
|
||||||
|
$"8BC8834151C22AC2130A044E494E5C5A505A3F110A0D0100000A0001061815FF"
|
||||||
|
$"01178400040A00010618001501178600040A010107000A080109000A0B010520"
|
||||||
|
$"20210A050108000A00010A1001178400040A02010D000A0A010E000A0902040F"
|
||||||
|
$"000A06010B000A0C010C000A0001011001178400040A030102000A040103000A"
|
||||||
|
$"07010400"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
resource app_signature "application/x-vnd.yab-app";
|
||||||
|
|
||||||
|
resource app_version {
|
||||||
|
major = 1,
|
||||||
|
middle = 7,
|
||||||
|
minor = 4,
|
||||||
|
|
||||||
|
variety = B_APPV_FINAL,
|
||||||
|
internal = 1,
|
||||||
|
|
||||||
|
short_info = "Yab BASIC programming language",
|
||||||
|
long_info = "Yab allows fast prototyping with simple and clean code. yab contains a large number of BeAPI specific commands for GUI creation and much, much more."
|
||||||
|
};
|
||||||
|
|
||||||
|
resource app_flags 1;
|
||||||
BIN
src/YAB.rdef.rsrc
Normal file
BIN
src/YAB.rdef.rsrc
Normal file
Binary file not shown.
117
src/YabBitmapView.cpp
Normal file
117
src/YabBitmapView.cpp
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
#include <Bitmap.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <Picture.h>
|
||||||
|
#include <Region.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include "YabWindow.h"
|
||||||
|
#include "YabBitmapView.h"
|
||||||
|
|
||||||
|
YabBitmapView::YabBitmapView(BRect frame, const char *name, uint32 resizingMode, uint32 flags)
|
||||||
|
: BView(frame, name, resizingMode, flags)
|
||||||
|
{
|
||||||
|
bmp = new BBitmap(BRect(0,0, frame.Width(), frame.Height()), B_RGBA32, true);
|
||||||
|
BView *myView = new BView(BRect(0,0, frame.Width(), frame.Height()), "canvas", B_FOLLOW_NONE, 0);
|
||||||
|
bmp->AddChild(myView);
|
||||||
|
SetDrawingMode(B_OP_COPY);
|
||||||
|
SetViewColor(0,0,0,255);
|
||||||
|
mouseMovedInfo = 1;
|
||||||
|
mouseStateInfo = -1;
|
||||||
|
prevMouseStateInfo = 0;
|
||||||
|
mouseX = 0;
|
||||||
|
mouseY = 0;
|
||||||
|
mouseLButton = 0;
|
||||||
|
mouseMButton = 0;
|
||||||
|
mouseRButton = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
YabBitmapView::~YabBitmapView()
|
||||||
|
{
|
||||||
|
delete bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
BBitmap* YabBitmapView::GetBitmap()
|
||||||
|
{
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
BView* YabBitmapView::GetBitmapView()
|
||||||
|
{
|
||||||
|
return bmp->FindView("canvas");
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabBitmapView::Draw(BRect updateRect)
|
||||||
|
{
|
||||||
|
DrawBitmap(bmp, updateRect, updateRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabBitmapView::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
|
||||||
|
{
|
||||||
|
BPoint ptCursor;
|
||||||
|
uint32 uButtons = 0;
|
||||||
|
GetMouse(&ptCursor, &uButtons, true);
|
||||||
|
|
||||||
|
mouseX = (int)ptCursor.x;
|
||||||
|
mouseY = (int)ptCursor.y;
|
||||||
|
if(uButtons & B_PRIMARY_MOUSE_BUTTON) mouseLButton = 1; else mouseLButton = 0;
|
||||||
|
if(uButtons & B_SECONDARY_MOUSE_BUTTON) mouseRButton = 1; else mouseRButton = 0;
|
||||||
|
if(uButtons & B_TERTIARY_MOUSE_BUTTON) mouseMButton = 1; else mouseMButton = 0;
|
||||||
|
|
||||||
|
switch(transit)
|
||||||
|
{
|
||||||
|
case B_INSIDE_VIEW:
|
||||||
|
if(prevMouseStateInfo==1)
|
||||||
|
mouseStateInfo = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mouseStateInfo = 1;
|
||||||
|
prevMouseStateInfo = 1;
|
||||||
|
}
|
||||||
|
mouseMovedInfo = 0;
|
||||||
|
break;
|
||||||
|
case B_ENTERED_VIEW:
|
||||||
|
mouseStateInfo = 1;
|
||||||
|
mouseMovedInfo = 0;
|
||||||
|
break;
|
||||||
|
case B_OUTSIDE_VIEW:
|
||||||
|
mouseStateInfo = 2;
|
||||||
|
mouseMovedInfo = 1;
|
||||||
|
break;
|
||||||
|
case B_EXITED_VIEW:
|
||||||
|
mouseStateInfo = 3;
|
||||||
|
mouseMovedInfo = 1;
|
||||||
|
prevMouseStateInfo = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
BView::MouseMoved(point, transit, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabBitmapView::MouseDown(BPoint point)
|
||||||
|
{
|
||||||
|
BPoint ptCursor;
|
||||||
|
uint32 uButtons = 0;
|
||||||
|
GetMouse(&ptCursor, &uButtons, false);
|
||||||
|
|
||||||
|
mouseX = (int)ptCursor.x;
|
||||||
|
mouseY = (int)ptCursor.y;
|
||||||
|
if(uButtons & B_PRIMARY_MOUSE_BUTTON) mouseLButton = 1; else mouseLButton = 0;
|
||||||
|
if(uButtons & B_SECONDARY_MOUSE_BUTTON) mouseRButton = 1; else mouseRButton = 0;
|
||||||
|
if(uButtons & B_TERTIARY_MOUSE_BUTTON) mouseMButton = 1; else mouseMButton = 0;
|
||||||
|
mouseStateInfo = 4;
|
||||||
|
BView::MouseDown(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabBitmapView::MouseUp(BPoint point)
|
||||||
|
{
|
||||||
|
BPoint ptCursor;
|
||||||
|
uint32 uButtons = 0;
|
||||||
|
GetMouse(&ptCursor, &uButtons, false);
|
||||||
|
|
||||||
|
mouseX = (int)ptCursor.x;
|
||||||
|
mouseY = (int)ptCursor.y;
|
||||||
|
if(uButtons & B_PRIMARY_MOUSE_BUTTON) mouseLButton = 1; else mouseLButton = 0;
|
||||||
|
if(uButtons & B_SECONDARY_MOUSE_BUTTON) mouseRButton = 1; else mouseRButton = 0;
|
||||||
|
if(uButtons & B_TERTIARY_MOUSE_BUTTON) mouseMButton = 1; else mouseMButton = 0;
|
||||||
|
mouseStateInfo = 5;
|
||||||
|
BView::MouseUp(point);
|
||||||
|
}
|
||||||
|
|
||||||
31
src/YabBitmapView.h
Normal file
31
src/YabBitmapView.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#ifndef YABBITMAPVIEW_H
|
||||||
|
#define YABBITMAPVIEW_H
|
||||||
|
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
class YabBitmapView : public BView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YabBitmapView(BRect frame, const char *name, uint32 resizingMode, uint32 flags);
|
||||||
|
~YabBitmapView();
|
||||||
|
virtual void Draw(BRect updateRect);
|
||||||
|
BBitmap* GetBitmap();
|
||||||
|
BView* GetBitmapView();
|
||||||
|
BBitmap *bmp;
|
||||||
|
|
||||||
|
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
|
||||||
|
virtual void MouseUp(BPoint point);
|
||||||
|
virtual void MouseDown(BPoint point);
|
||||||
|
int mouseStateInfo;
|
||||||
|
int mouseMovedInfo;
|
||||||
|
int mouseX;
|
||||||
|
int mouseY;
|
||||||
|
uint mouseLButton;
|
||||||
|
uint mouseMButton;
|
||||||
|
uint mouseRButton;
|
||||||
|
private:
|
||||||
|
int prevMouseStateInfo;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
257
src/YabControlLook.cpp
Normal file
257
src/YabControlLook.cpp
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
#include <GradientLinear.h>
|
||||||
|
#include <Region.h>
|
||||||
|
#include "YabControlLook.h"
|
||||||
|
|
||||||
|
YabControlLook::YabControlLook()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
YabControlLook::~YabControlLook()
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void YabControlLook::DrawActiveTabBottom(BView* view, BRect& rect, const BRect& updateRect, const rgb_color& base, uint32 flags, uint32 borders)
|
||||||
|
{
|
||||||
|
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
||||||
|
return;
|
||||||
|
|
||||||
|
rgb_color edgeShadowColor;
|
||||||
|
rgb_color edgeLightColor;
|
||||||
|
rgb_color frameShadowColor;
|
||||||
|
rgb_color frameLightColor;
|
||||||
|
rgb_color bevelShadowColor;
|
||||||
|
rgb_color bevelLightColor;
|
||||||
|
BGradientLinear fillGradient;
|
||||||
|
fillGradient.SetStart(rect.LeftBottom() + BPoint(3, -3));
|
||||||
|
fillGradient.SetEnd(rect.LeftTop() + BPoint(3, 3));
|
||||||
|
|
||||||
|
if (flags & B_DISABLED) {
|
||||||
|
edgeShadowColor = base;
|
||||||
|
edgeLightColor = base;
|
||||||
|
frameShadowColor = tint_color(base, 1.30);
|
||||||
|
frameLightColor = tint_color(base, 1.25);
|
||||||
|
bevelShadowColor = tint_color(base, 1.07);
|
||||||
|
bevelLightColor = tint_color(base, 0.8);
|
||||||
|
fillGradient.AddColor(tint_color(base, 0.85), 0);
|
||||||
|
fillGradient.AddColor(base, 255);
|
||||||
|
} else {
|
||||||
|
edgeShadowColor = tint_color(base, 1.03);
|
||||||
|
edgeLightColor = tint_color(base, 0.80);
|
||||||
|
frameShadowColor = tint_color(base, 1.30);
|
||||||
|
frameLightColor = tint_color(base, 1.30);
|
||||||
|
bevelShadowColor = tint_color(base, 1.07);
|
||||||
|
bevelLightColor = tint_color(base, 0.6);
|
||||||
|
fillGradient.AddColor(tint_color(base, 0.75), 0);
|
||||||
|
fillGradient.AddColor(tint_color(base, 1.03), 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const float kRoundCornerRadius = 4;
|
||||||
|
|
||||||
|
// left/top corner
|
||||||
|
BRect cornerRect(rect);
|
||||||
|
cornerRect.right = cornerRect.left + kRoundCornerRadius;
|
||||||
|
cornerRect.top = cornerRect.bottom - kRoundCornerRadius;
|
||||||
|
|
||||||
|
BRegion clipping(rect);
|
||||||
|
clipping.Exclude(cornerRect);
|
||||||
|
|
||||||
|
_DrawRoundCornerLeftBottom(view, cornerRect, updateRect, base, edgeShadowColor,
|
||||||
|
frameLightColor, bevelLightColor, fillGradient);
|
||||||
|
|
||||||
|
// left/top corner
|
||||||
|
cornerRect.right = rect.right;
|
||||||
|
cornerRect.left = cornerRect.right - kRoundCornerRadius;
|
||||||
|
|
||||||
|
clipping.Exclude(cornerRect);
|
||||||
|
|
||||||
|
_DrawRoundCornerRightBottom(view, cornerRect, updateRect, base, edgeShadowColor,
|
||||||
|
edgeLightColor, frameLightColor, frameShadowColor, bevelLightColor,
|
||||||
|
bevelShadowColor, fillGradient);
|
||||||
|
|
||||||
|
// rest of frame and fill
|
||||||
|
view->ConstrainClippingRegion(&clipping);
|
||||||
|
|
||||||
|
_DrawFrame(view, rect, edgeShadowColor, edgeLightColor, edgeLightColor,
|
||||||
|
edgeShadowColor,
|
||||||
|
borders & (B_LEFT_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER));
|
||||||
|
if ((borders & B_LEFT_BORDER) == 0)
|
||||||
|
rect.left++;
|
||||||
|
if ((borders & B_RIGHT_BORDER) == 0)
|
||||||
|
rect.right--;
|
||||||
|
|
||||||
|
_DrawFrame(view, rect, frameLightColor, frameShadowColor, frameShadowColor,
|
||||||
|
frameLightColor, B_LEFT_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER);
|
||||||
|
|
||||||
|
_DrawFrame(view, rect, bevelLightColor, bevelShadowColor, bevelShadowColor,
|
||||||
|
bevelLightColor);
|
||||||
|
|
||||||
|
view->FillRect(rect, fillGradient);
|
||||||
|
|
||||||
|
view->SetHighColor(216,216,216);
|
||||||
|
view->StrokeLine(BPoint(rect.left, rect.top), BPoint(rect.right, rect.top));
|
||||||
|
|
||||||
|
view->ConstrainClippingRegion(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabControlLook::DrawInactiveTabBottom(BView* view, BRect& rect,const BRect& updateRect, const rgb_color& base, uint32 flags, uint32 borders)
|
||||||
|
{
|
||||||
|
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
||||||
|
return;
|
||||||
|
|
||||||
|
rgb_color edgeShadowColor;
|
||||||
|
rgb_color edgeLightColor;
|
||||||
|
rgb_color frameShadowColor;
|
||||||
|
rgb_color frameLightColor;
|
||||||
|
rgb_color bevelShadowColor;
|
||||||
|
rgb_color bevelLightColor;
|
||||||
|
BGradientLinear fillGradient;
|
||||||
|
fillGradient.SetStart(rect.LeftBottom() + BPoint(3, -3));
|
||||||
|
fillGradient.SetEnd(rect.LeftTop() + BPoint(3, 3));
|
||||||
|
|
||||||
|
if (flags & B_DISABLED) {
|
||||||
|
edgeShadowColor = base;
|
||||||
|
edgeLightColor = base;
|
||||||
|
frameShadowColor = tint_color(base, 1.30);
|
||||||
|
frameLightColor = tint_color(base, 1.25);
|
||||||
|
bevelShadowColor = tint_color(base, 1.07);
|
||||||
|
bevelLightColor = tint_color(base, 0.8);
|
||||||
|
fillGradient.AddColor(tint_color(base, 0.85), 0);
|
||||||
|
fillGradient.AddColor(base, 255);
|
||||||
|
} else {
|
||||||
|
edgeShadowColor = tint_color(base, 1.03);
|
||||||
|
edgeLightColor = tint_color(base, 0.80);
|
||||||
|
frameShadowColor = tint_color(base, 1.30);
|
||||||
|
frameLightColor = tint_color(base, 1.30);
|
||||||
|
bevelShadowColor = tint_color(base, 1.17);
|
||||||
|
bevelLightColor = tint_color(base, 1.10);
|
||||||
|
fillGradient.AddColor(tint_color(base, 1.12), 0);
|
||||||
|
fillGradient.AddColor(tint_color(base, 1.08), 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
// active tabs stand out at the top, but this is an inactive tab
|
||||||
|
view->SetHighColor(base);
|
||||||
|
view->FillRect(BRect(rect.left, rect.bottom - 4, rect.right, rect.bottom));
|
||||||
|
rect.bottom -= 4;
|
||||||
|
|
||||||
|
// frame and fill
|
||||||
|
_DrawFrame(view, rect, edgeShadowColor, edgeShadowColor, edgeLightColor,
|
||||||
|
edgeLightColor,
|
||||||
|
borders & (B_LEFT_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER));
|
||||||
|
|
||||||
|
_DrawFrame(view, rect, frameLightColor, frameLightColor, frameShadowColor,
|
||||||
|
frameShadowColor,
|
||||||
|
borders & (B_LEFT_BORDER | B_BOTTOM_BORDER | B_RIGHT_BORDER));
|
||||||
|
|
||||||
|
if (rect.IsValid()) {
|
||||||
|
_DrawFrame(view, rect, bevelShadowColor, bevelShadowColor,
|
||||||
|
bevelLightColor, bevelLightColor, B_LEFT_BORDER & ~borders);
|
||||||
|
} else {
|
||||||
|
if ((B_LEFT_BORDER & ~borders) != 0)
|
||||||
|
rect.left++;
|
||||||
|
}
|
||||||
|
|
||||||
|
view->FillRect(rect, fillGradient);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
YabControlLook::_DrawRoundCornerLeftBottom(BView* view, BRect& rect,
|
||||||
|
const BRect& updateRect, const rgb_color& base, const rgb_color& edgeColor,
|
||||||
|
const rgb_color& frameColor, const rgb_color& bevelColor,
|
||||||
|
const BGradientLinear& fillGradient)
|
||||||
|
{
|
||||||
|
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BRegion clipping(rect);
|
||||||
|
view->ConstrainClippingRegion(&clipping);
|
||||||
|
|
||||||
|
// background
|
||||||
|
view->SetHighColor(base);
|
||||||
|
view->FillRect(rect);
|
||||||
|
|
||||||
|
// outer edge
|
||||||
|
BRect ellipseRect(rect);
|
||||||
|
ellipseRect.right = ellipseRect.left + ellipseRect.Width() * 2;
|
||||||
|
ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
|
||||||
|
|
||||||
|
view->SetHighColor(edgeColor);
|
||||||
|
view->FillEllipse(ellipseRect);
|
||||||
|
|
||||||
|
// frame
|
||||||
|
ellipseRect.InsetBy(1, 1);
|
||||||
|
view->SetHighColor(frameColor);
|
||||||
|
view->FillEllipse(ellipseRect);
|
||||||
|
|
||||||
|
// bevel
|
||||||
|
ellipseRect.InsetBy(1, 1);
|
||||||
|
view->SetHighColor(bevelColor);
|
||||||
|
view->FillEllipse(ellipseRect);
|
||||||
|
|
||||||
|
// fill
|
||||||
|
ellipseRect.InsetBy(1, 1);
|
||||||
|
view->FillEllipse(ellipseRect, fillGradient);
|
||||||
|
|
||||||
|
view->ConstrainClippingRegion(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
YabControlLook::_DrawRoundCornerRightBottom(BView* view, BRect& rect,
|
||||||
|
const BRect& updateRect, const rgb_color& base,
|
||||||
|
const rgb_color& edgeTopColor, const rgb_color& edgeRightColor,
|
||||||
|
const rgb_color& frameTopColor, const rgb_color& frameRightColor,
|
||||||
|
const rgb_color& bevelTopColor, const rgb_color& bevelRightColor,
|
||||||
|
const BGradientLinear& fillGradient)
|
||||||
|
{
|
||||||
|
if (!rect.IsValid() || !rect.Intersects(updateRect))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BRegion clipping(rect);
|
||||||
|
view->ConstrainClippingRegion(&clipping);
|
||||||
|
|
||||||
|
// background
|
||||||
|
view->SetHighColor(base);
|
||||||
|
view->FillRect(rect);
|
||||||
|
|
||||||
|
// outer edge
|
||||||
|
BRect ellipseRect(rect);
|
||||||
|
ellipseRect.left = ellipseRect.right - ellipseRect.Width() * 2;
|
||||||
|
ellipseRect.top = ellipseRect.bottom - ellipseRect.Height() * 2;
|
||||||
|
|
||||||
|
BGradientLinear gradient;
|
||||||
|
gradient.AddColor(edgeTopColor, 0);
|
||||||
|
gradient.AddColor(edgeRightColor, 255);
|
||||||
|
gradient.SetStart(rect.LeftTop());
|
||||||
|
gradient.SetEnd(rect.RightBottom());
|
||||||
|
view->FillEllipse(ellipseRect, gradient);
|
||||||
|
|
||||||
|
// frame
|
||||||
|
ellipseRect.InsetBy(1, 1);
|
||||||
|
rect.right--;
|
||||||
|
rect.top++;
|
||||||
|
if (frameTopColor == frameRightColor) {
|
||||||
|
view->SetHighColor(frameTopColor);
|
||||||
|
view->FillEllipse(ellipseRect);
|
||||||
|
} else {
|
||||||
|
gradient.SetColor(0, frameTopColor);
|
||||||
|
gradient.SetColor(1, frameRightColor);
|
||||||
|
gradient.SetStart(rect.LeftTop());
|
||||||
|
gradient.SetEnd(rect.RightBottom());
|
||||||
|
view->FillEllipse(ellipseRect, gradient);
|
||||||
|
}
|
||||||
|
|
||||||
|
// bevel
|
||||||
|
ellipseRect.InsetBy(1, 1);
|
||||||
|
rect.right--;
|
||||||
|
rect.top++;
|
||||||
|
gradient.SetColor(0, bevelTopColor);
|
||||||
|
gradient.SetColor(1, bevelRightColor);
|
||||||
|
gradient.SetStart(rect.LeftTop());
|
||||||
|
gradient.SetEnd(rect.RightBottom());
|
||||||
|
view->FillEllipse(ellipseRect, gradient);
|
||||||
|
|
||||||
|
// fill
|
||||||
|
ellipseRect.InsetBy(1, 1);
|
||||||
|
view->FillEllipse(ellipseRect, fillGradient);
|
||||||
|
|
||||||
|
view->ConstrainClippingRegion(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
33
src/YabControlLook.h
Normal file
33
src/YabControlLook.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef YABCONTROLLOOK
|
||||||
|
#define YABCONTROLLOOK
|
||||||
|
|
||||||
|
#include <ControlLook.h>
|
||||||
|
|
||||||
|
class YabControlLook : public BControlLook
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YabControlLook();
|
||||||
|
~YabControlLook();
|
||||||
|
|
||||||
|
virtual void DrawActiveTabBottom(BView* view, BRect& rect, const BRect& updateRect, const rgb_color& base, uint32 flags = 0, uint32 borders = BControlLook::B_ALL_BORDERS);
|
||||||
|
virtual void DrawInactiveTabBottom(BView* view, BRect& rect, const BRect& updateRect, const rgb_color& base, uint32 flags = 0, uint32 borders = BControlLook::B_ALL_BORDERS);
|
||||||
|
void _DrawRoundCornerLeftBottom(BView* view,
|
||||||
|
BRect& rect, const BRect& updateRect,
|
||||||
|
const rgb_color& base,
|
||||||
|
const rgb_color& edgeColor,
|
||||||
|
const rgb_color& frameColor,
|
||||||
|
const rgb_color& bevelColor,
|
||||||
|
const BGradientLinear& fillGradient);
|
||||||
|
void _DrawRoundCornerRightBottom(BView* view,
|
||||||
|
BRect& rect, const BRect& updateRect,
|
||||||
|
const rgb_color& base,
|
||||||
|
const rgb_color& edgeTopColor,
|
||||||
|
const rgb_color& edgeRightColor,
|
||||||
|
const rgb_color& frameTopColor,
|
||||||
|
const rgb_color& frameRightColor,
|
||||||
|
const rgb_color& bevelTopColor,
|
||||||
|
const rgb_color& bevelRightColor,
|
||||||
|
const BGradientLinear& fillGradient);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
79
src/YabFilePanel.cpp
Normal file
79
src/YabFilePanel.cpp
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
#include <Directory.h>
|
||||||
|
#include <Entry.h>
|
||||||
|
#include <FilePanel.h>
|
||||||
|
#include <Messenger.h>
|
||||||
|
#include <Window.h>
|
||||||
|
#include "YabFilePanel.h"
|
||||||
|
#include "YabFilePanelLooper.h"
|
||||||
|
|
||||||
|
BEntry *YabFilePanel::MyFilePanel(const char *name, const char *directory, const char* filename, int mode)
|
||||||
|
{
|
||||||
|
BEntry *myEntry = NULL;
|
||||||
|
entry_ref ref;
|
||||||
|
|
||||||
|
sem_id semaphore = create_sem(0, "yabfilepanel");
|
||||||
|
YabFilePanelLooper *myLooper = new YabFilePanelLooper(semaphore);
|
||||||
|
myLooper->Run();
|
||||||
|
|
||||||
|
if(directory)
|
||||||
|
{
|
||||||
|
myEntry=new BEntry(directory);
|
||||||
|
if(myEntry->GetRef(&ref)!=B_OK)
|
||||||
|
{
|
||||||
|
myEntry->Unset();
|
||||||
|
myEntry->SetTo("/boot/home/");
|
||||||
|
myEntry->GetRef(&ref);
|
||||||
|
}
|
||||||
|
myEntry->Unset();
|
||||||
|
delete myEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
BFilePanel *myFilePanel = NULL;
|
||||||
|
switch(mode)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
myFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(myLooper, myLooper), &ref, B_FILE_NODE, false, NULL, NULL, true, true);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
myFilePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(myLooper, myLooper), &ref, B_FILE_NODE, false, NULL, NULL, true, true);
|
||||||
|
if (filename) myFilePanel->SetSaveText(filename);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
myFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(myLooper, myLooper), &ref, B_DIRECTORY_NODE, false, NULL, NULL, true, true);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
myFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(myLooper, myLooper), &ref, B_FILE_NODE|B_DIRECTORY_NODE, false, NULL, NULL, true, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(name) myFilePanel->Window()->SetTitle(name);
|
||||||
|
myFilePanel->Show();
|
||||||
|
|
||||||
|
bool inloop = true;
|
||||||
|
while(inloop)
|
||||||
|
{
|
||||||
|
while(acquire_sem_etc(semaphore, 1, B_RELATIVE_TIMEOUT, 10000)==B_TIMED_OUT) ;
|
||||||
|
|
||||||
|
myEntry = myLooper->GetChosenFile();
|
||||||
|
inloop = false;
|
||||||
|
/*
|
||||||
|
if(mode!=2)
|
||||||
|
inloop = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(myEntry->IsDirectory())
|
||||||
|
inloop = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
myFilePanel->Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
myLooper->Lock();
|
||||||
|
myLooper->Quit();
|
||||||
|
|
||||||
|
delete_sem(semaphore);
|
||||||
|
delete myFilePanel;
|
||||||
|
return myEntry;
|
||||||
|
}
|
||||||
10
src/YabFilePanel.h
Normal file
10
src/YabFilePanel.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef YABFILEPANEL_H
|
||||||
|
#define YABFILEPANEL_H
|
||||||
|
|
||||||
|
class YabFilePanel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BEntry *MyFilePanel(const char *name, const char *directory, const char* filename, int panelType);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
57
src/YabFilePanelLooper.cpp
Normal file
57
src/YabFilePanelLooper.cpp
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#include <Entry.h>
|
||||||
|
#include <Directory.h>
|
||||||
|
#include "YabFilePanelLooper.h"
|
||||||
|
|
||||||
|
YabFilePanelLooper::YabFilePanelLooper(sem_id semaphore) : BLooper("YabFilePanelLooper")
|
||||||
|
{
|
||||||
|
myEntry=new BEntry();
|
||||||
|
mySemaphore = semaphore;
|
||||||
|
}
|
||||||
|
|
||||||
|
BEntry *YabFilePanelLooper::GetChosenFile()
|
||||||
|
{
|
||||||
|
return myEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabFilePanelLooper::MessageReceived(BMessage *msg)
|
||||||
|
{
|
||||||
|
switch(msg->what)
|
||||||
|
{
|
||||||
|
case B_REFS_RECEIVED:
|
||||||
|
{
|
||||||
|
entry_ref ref;
|
||||||
|
if (msg->FindRef("refs", 0, &ref)==B_OK)
|
||||||
|
myEntry->SetTo(&ref);
|
||||||
|
else
|
||||||
|
myEntry->Unset();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_SAVE_REQUESTED:
|
||||||
|
{
|
||||||
|
const char *selected;
|
||||||
|
entry_ref ref;
|
||||||
|
|
||||||
|
if (msg->FindString("name", &selected)!=B_OK)
|
||||||
|
myEntry->Unset();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (msg->FindRef("directory", 0, &ref)==B_OK)
|
||||||
|
{
|
||||||
|
BDirectory *myDirectory = new BDirectory(&ref);
|
||||||
|
myEntry->SetTo(myDirectory, selected);
|
||||||
|
myDirectory->Unset();
|
||||||
|
delete myDirectory;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
myEntry->Unset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_CANCEL:
|
||||||
|
release_sem(mySemaphore);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
19
src/YabFilePanelLooper.h
Normal file
19
src/YabFilePanelLooper.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef YABFPLOOPER_H
|
||||||
|
#define YABFPLOOPER_H
|
||||||
|
|
||||||
|
#include <Looper.h>
|
||||||
|
#include <Message.h>
|
||||||
|
#include <Entry.h>
|
||||||
|
|
||||||
|
class YabFilePanelLooper : public BLooper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YabFilePanelLooper(sem_id semaphore);
|
||||||
|
void MessageReceived(BMessage *msg);
|
||||||
|
BEntry *GetChosenFile();
|
||||||
|
private:
|
||||||
|
BEntry *myEntry;
|
||||||
|
sem_id mySemaphore;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
10698
src/YabInterface.cpp
Normal file
10698
src/YabInterface.cpp
Normal file
File diff suppressed because it is too large
Load Diff
523
src/YabInterface.h
Normal file
523
src/YabInterface.h
Normal file
@@ -0,0 +1,523 @@
|
|||||||
|
#ifndef YABINTERFACE_H
|
||||||
|
#define YABINTERFACE_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#include <Application.h>
|
||||||
|
#include <FilePanel.h>
|
||||||
|
#include <GraphicsDefs.h>
|
||||||
|
#include <ListItem.h>
|
||||||
|
#include <Menu.h>
|
||||||
|
#include <PropertyInfo.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <TranslatorRoster.h>
|
||||||
|
#include "YabList.h"
|
||||||
|
#include "global.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
class YabInterface : public BApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YabInterface(int argc, char** argv, const char* signature);
|
||||||
|
~YabInterface();
|
||||||
|
|
||||||
|
status_t GetSupportedSuites(BMessage *msg);
|
||||||
|
BHandler *ResolveSpecifier(BMessage *msg, int32 index, BMessage *spec, int32 form, const char *prop);
|
||||||
|
const char* GetApplicationDirectory();
|
||||||
|
void OpenWindow(const BRect frame, const char* id, const char* title);
|
||||||
|
int CloseWindow(const char* view);
|
||||||
|
void MessageReceived(BMessage *message);
|
||||||
|
bool QuitRequested();
|
||||||
|
bool ExitRequested();
|
||||||
|
void CreateButton(BRect frame, const char* id, const char* title, const char* window);
|
||||||
|
int CreateImage(BPoint coordinates, const char* imagefile, const char* window);
|
||||||
|
int CreateImage(BRect frame, const char* imagefile, const char* window);
|
||||||
|
int CreateSVG(BRect frame, const char* imagefile, const char* window);
|
||||||
|
void DrawText(BPoint coordinates, const char* text, const char* window);
|
||||||
|
void DrawRect(BRect frame, const char* window);
|
||||||
|
void DrawClear(const char* window, bool isExit);
|
||||||
|
void CreateAlert(const char* text, const char* button1, const char* option);
|
||||||
|
void CreateMenu(const char* menuhead, const char* menuitem, const char *shortcut, const char* window);
|
||||||
|
void CreateTextControl(BRect frame, const char *id, const char* label, const char* text, const char* window);
|
||||||
|
void CreateCheckBox(double x, double y, const char *id, const char* label, int isActivated, const char* window);
|
||||||
|
void CreateRadioButton(double x, double y, const char* groupID, const char* label, int isActivated, const char* window);
|
||||||
|
void CreateListBox(BRect frame, const char* title, int scrollbar, const char* window);
|
||||||
|
void CreateDropBox(BRect frame, const char* title, const char* label, const char* window);
|
||||||
|
void CreateItem(const char* id, const char* item);
|
||||||
|
void RemoveItem(const char* title, const char* item);
|
||||||
|
void ClearItems(const char* title);
|
||||||
|
void CreateText(double x, double y, const char *id, const char* text, const char* window);
|
||||||
|
void Text2(BRect frame, const char *id, const char* text, const char* window);
|
||||||
|
void TextAlign(const char* txt, const char *option);
|
||||||
|
const char* LoadFilePanel(const char* mode, const char* title, const char* directory);
|
||||||
|
const char* SaveFilePanel(const char* mode, const char* title, const char* directory, const char*filename);
|
||||||
|
void SetLayout(const char* layout, const char* window);
|
||||||
|
void WindowSet(const char* option, const char* value, const char* window);
|
||||||
|
void WindowSet(const char* option, int r, int g, int b, const char* window);
|
||||||
|
void WindowSet(const char* option, double x, double y, const char* window);
|
||||||
|
void WindowSet(const char* option, const char* window);
|
||||||
|
void WindowClear(const char* window);
|
||||||
|
void TextEdit(BRect frame, const char* title, int scrollbar, const char* window);
|
||||||
|
void TextAdd(const char* title, const char* text);
|
||||||
|
void TextSet(const char* title, const char* option);
|
||||||
|
void TextSet(const char* title, const char* option, int value);
|
||||||
|
void TextSet(const char* title, const char* option, const char* value);
|
||||||
|
void TextColor(const char* title, const char* option, const char* command);
|
||||||
|
void TextColor(const char* title, const char* option, int r, int g, int b);
|
||||||
|
void TextClear(const char* title);
|
||||||
|
const char* TextGet(const char* title);
|
||||||
|
const char* TextGet(const char* title, int linenum);
|
||||||
|
const char* TextGet6(const char* title, const char* option);
|
||||||
|
int TextGet(const char* title, const char* option);
|
||||||
|
double TextGet(const char* title, const char* option, int line);
|
||||||
|
int TextGet(const char* title, const char* option, const char* option2);
|
||||||
|
void DrawSet1(const char* option, const char* window);
|
||||||
|
void DrawSet2(int fillorstroke, const char* mypattern);
|
||||||
|
void View(BRect frame, const char* id, const char* view);
|
||||||
|
void BoxView(BRect frame, const char* id, const char* text, int lineType, const char* view);
|
||||||
|
void BoxViewSet(const char* id, const char* option, const char* value);
|
||||||
|
void Tab(BRect frame, const char* id, const char* names, const char* view);
|
||||||
|
void TabSet(const char* id, int num);
|
||||||
|
void TabAdd(const char* id, const char* name);
|
||||||
|
void TabDel(const char* id, int num);
|
||||||
|
int TabViewGet(const char* id);
|
||||||
|
void DrawDot(double x, double y, const char* window);
|
||||||
|
void DrawLine(double x1, double y1, double x2, double y2, const char* window);
|
||||||
|
void DrawCircle(double x, double y, double r, const char* window);
|
||||||
|
void DrawEllipse(double x, double y, double r1, double r2, const char* window);
|
||||||
|
void DrawCurve(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, const char* window);
|
||||||
|
void Slider(BRect frame, const char* id, const char* title, int min, int max, const char* view);
|
||||||
|
void Slider(BRect frame, const char* id, const char* title, int min, int max, const char* option, const char* view);
|
||||||
|
void SetSlider(const char* id, const char* label1, const char* label2);
|
||||||
|
void SetSlider(const char* id, const char* bottomtop, int count);
|
||||||
|
void SetSlider(const char* id, const char* part, int r, int g, int b);
|
||||||
|
void SetSlider(const char* id, int value);
|
||||||
|
void SetOption(const char* id, const char* option, const char* value);
|
||||||
|
void SetOption(const char* id, const char* option, int r, int g, int b);
|
||||||
|
void SetOption(const char* id, const char* option, double x, double y);
|
||||||
|
void SetOption(const char* id, const char* option);
|
||||||
|
void SetOption(const char* id, const char* option, int value);
|
||||||
|
void DropZone(const char* view);
|
||||||
|
void ColorControl(double x, double y, const char* id, const char* view);
|
||||||
|
void ColorControl(const char* id, int r, int g, int b);
|
||||||
|
void TextControl(const char* id, const char* text);
|
||||||
|
void TextControl(const char* id, int mode);
|
||||||
|
void TextControl(const char* id, const char* option, const char* value);
|
||||||
|
void TextControl(const char* id);
|
||||||
|
void TreeBox1(BRect frame, const char* id, int scrollbarType, const char* view);
|
||||||
|
void TreeBox2(const char* id, const char* item);
|
||||||
|
void TreeBox3(const char* id, const char* head, const char* item, int isExpanded);
|
||||||
|
void TreeBox4(const char* id);
|
||||||
|
void TreeBox5(const char* id, const char* item);
|
||||||
|
void TreeBox7(const char* id, int pos);
|
||||||
|
void TreeBox8(const char* id, int pos);
|
||||||
|
void TreeBox9(const char* id, const char* head, const char* item);
|
||||||
|
void TreeBox10(const char* id, const char* head);
|
||||||
|
void TreeBox11(const char* id, const char* head);
|
||||||
|
void TreeBox12(const char* id, const char* item, int pos);
|
||||||
|
void Launch(const char* strg);
|
||||||
|
const char* TreeboxGet(const char* treebox, int pos);
|
||||||
|
int TreeboxCount(const char* treebox);
|
||||||
|
void ButtonImage(double x, double y,const char* id,const char* enabledon, const char* enabledoff, const char* disabled, const char* view);
|
||||||
|
void CheckboxImage(double x, double y,const char* id,const char* enabledon, const char* enabledoff, const char *disabledon, const char *disabledoff, int isActivated, const char* view);
|
||||||
|
void CheckboxSet(const char* id, int isActivated);
|
||||||
|
void RadioSet(const char* id, int isActivated);
|
||||||
|
void ToolTips(const char* view, const char* text);
|
||||||
|
void ToolTipsColor(const char* color, int r, int g, int b);
|
||||||
|
void TreeSort(const char* view);
|
||||||
|
void ListSort(const char* view);
|
||||||
|
void FileBox(BRect frame, const char* id, bool scrollbartype, const char* option, const char* view);
|
||||||
|
void FileBoxAdd(const char* id, const char* name, int32 pos, double maxWidth, double minWidth, double width, const char* option);
|
||||||
|
void FileBoxClear(const char* view);
|
||||||
|
void ColumnBoxAdd(const char* id, int column, int position, int height, const char* item);
|
||||||
|
void ColumnBoxSelect(const char *columnbox, int position);
|
||||||
|
void ColumnBoxRemove(const char *columnbox, int position);
|
||||||
|
void ColumnBoxColor(const char *columnbox, const char* option, int r, int g, int b);
|
||||||
|
int Printer(const char* docname, const char *view, const char* config);
|
||||||
|
void PrinterConfig(const char* config);
|
||||||
|
void Calendar(double x, double y, const char* id, const char* format, const char* date, const char* view);
|
||||||
|
const char* Calendar(const char* id);
|
||||||
|
void Calendar(const char* id, const char* date);
|
||||||
|
void MouseSet(const char* opt);
|
||||||
|
void Scrollbar(const char* id, int format, const char* view);
|
||||||
|
void ScrollbarSet(const char* scrollview, const char* option, double position);
|
||||||
|
void ScrollbarSet(const char* scrollview, const char* option, double opt1, double opt2);
|
||||||
|
void ScrollbarSet(const char* scrollview, const char* option);
|
||||||
|
double ScrollbarGet(const char* scrollview, const char* option);
|
||||||
|
const char* ListboxGet(const char* listbox, int pos);
|
||||||
|
int ListboxCount(const char* listbox);
|
||||||
|
void ListboxAdd(const char* listbox, const char* item);
|
||||||
|
void ListboxAdd(const char* listbox, int pos, const char* item);
|
||||||
|
void ListboxSelect(const char* listbox, int pos);
|
||||||
|
void ListboxRemove(const char* listbox, int pos);
|
||||||
|
void SplitView(BRect frame, const char* id, int isVertical, int style, const char* view);
|
||||||
|
void SplitView(const char* splitView, const char* option, double position);
|
||||||
|
void SplitView(const char* splitView, const char* option, double left, double right);
|
||||||
|
double SplitViewGet(const char* splitView, const char* option);
|
||||||
|
void StackViews(BRect frame, const char* id, int number, const char* view);
|
||||||
|
void StackViews(const char* stackView, int num);
|
||||||
|
int StackViewGet(const char* stackView);
|
||||||
|
void DrawSet3(const char* option, int transparency);
|
||||||
|
void TextURL(double x, double y, const char* id, const char* text, const char* url, const char* view);
|
||||||
|
void TextURL(const char* id, const char* option, int r, int g, int b);
|
||||||
|
void Menu(const char* menuHead, int isRadio, const char* view);
|
||||||
|
void SubMenu(const char* menuHead, const char* menuItem, const char* subMenuItem, const char* modifiers, const char* view);
|
||||||
|
void SubMenu(const char* menuHead, const char* menuItem, int isRadio, const char* view);
|
||||||
|
void SpinControl(double x, double y, const char* id, const char* label, int min, int max, int step, const char* view);
|
||||||
|
void SpinControl(const char* spinControl, int value);
|
||||||
|
int SpinControlGet(const char *spinControl);
|
||||||
|
const char* PopUpMenu(double x, double y, const char* menuItems, const char* view);
|
||||||
|
void DropBoxSelect(const char* dropbox, int position);
|
||||||
|
void DropBoxClear(const char* dropbox);
|
||||||
|
void DropBoxRemove(const char* dropbox, int position);
|
||||||
|
int DropBoxCount(const char* dropbox);
|
||||||
|
const char* DropBoxGet(const char* dropbox, int position);
|
||||||
|
int ColorControlGet(const char* colorcontrol, const char* option);
|
||||||
|
int SliderGet(const char* slider);
|
||||||
|
void SubMenu3(const char* menuHead, const char* menuItem, const char* subMenuItem, const char* option, const char* view);
|
||||||
|
void Menu3(const char* menuHead, const char* menuItem, const char* option,const char* view);
|
||||||
|
double ScrollbarWidth();
|
||||||
|
double MenuHeight();
|
||||||
|
double TabHeight();
|
||||||
|
const char* ColumnBoxGet(const char *columnbox, int column, int position);
|
||||||
|
int ColumnBoxCount(const char *columnbox);
|
||||||
|
const char* TextControlGet(const char* id);
|
||||||
|
int WindowGet(const char* view, const char* option);
|
||||||
|
int ViewGet(const char* view, const char* option); //vasper
|
||||||
|
double DrawGet(const char* option, const char* txt, const char* view);
|
||||||
|
int DrawGet(BPoint coord, const char* option, const char* view);
|
||||||
|
const char* DrawGet(const char* option);
|
||||||
|
void ClipboardCopy(const char* text);
|
||||||
|
const char* ClipboardPaste();
|
||||||
|
int DeskbarParam(const char* option);
|
||||||
|
int DesktopParam(bool isWidth);
|
||||||
|
int NewAlert(const char* text, const char* button1, const char* button2, const char* button3, const char* option);
|
||||||
|
int ThreadKill(const char* option, int id);
|
||||||
|
int ThreadGet(const char* option, const char* appname);
|
||||||
|
const int IsMouseIn(const char* view);
|
||||||
|
const char* GetMouseIn();
|
||||||
|
const char* GetMouseMessages(const char* view);
|
||||||
|
const char* KeyboardMessages(const char* view);
|
||||||
|
const char* GetMessageString();
|
||||||
|
int MessageSend(const char* app, const char* msg);
|
||||||
|
void SetLocalize(const char* path);
|
||||||
|
void Bitmap(double w, double h, const char* id);
|
||||||
|
int BitmapColor(double x, double y, const char* id, const char* option);
|
||||||
|
void BitmapDraw(double x, double y, const char* bitmap, const char* mode, const char* view);
|
||||||
|
void BitmapDraw(BRect frame, const char* bitmap, const char* mode, const char* view);
|
||||||
|
void BitmapGet(BRect frame, const char* id, const char* bitmap);
|
||||||
|
void BitmapGet(double w, const char* id, const char* path);
|
||||||
|
int BitmapGet(const char* id, const char* option);
|
||||||
|
int BitmapLoad(const char* id, const char* option);
|
||||||
|
void BitmapGetIcon(const char* id, const char* option, const char* path);
|
||||||
|
void BitmapDrag(const char* bitmap);
|
||||||
|
void BitmapRemove(const char* bitmap);
|
||||||
|
void Screenshot(BRect frame, const char* bitmap);
|
||||||
|
int BitmapSave(const char* id, const char* filename, const char* type);
|
||||||
|
void Canvas(BRect frame, const char* id, const char* view);
|
||||||
|
int Sound(const char* filename);
|
||||||
|
void SoundStop(int32 id);
|
||||||
|
void SoundWait(int32 id);
|
||||||
|
int IsComputerOn();
|
||||||
|
void ShortCut(const char* view, const char* key, const char* msg);
|
||||||
|
void DrawSet(const char* option, const char* color,const char* view);
|
||||||
|
void Treebox13(const char* id,const char* option, int pos);
|
||||||
|
int TreeboxGetOpt(const char* id, const char* option, int pos);
|
||||||
|
int ListboxGetNum(const char* id);
|
||||||
|
int DropboxGetNum(const char* id);
|
||||||
|
int TreeboxGetNum(const char* id);
|
||||||
|
int ColumnboxGetNum(const char* id);
|
||||||
|
void Attribute1(const char* type, const char* name, const char* value, const char* filename);
|
||||||
|
void AttributeClear(const char* name, const char* filename);
|
||||||
|
const char* AttributeGet1(const char* name, const char* filename);
|
||||||
|
double AttributeGet2(const char* name, const char* filename);
|
||||||
|
|
||||||
|
const int GetErrorCode();
|
||||||
|
void Error(const char* id, const char* type);
|
||||||
|
void ErrorGen(const char* msg);
|
||||||
|
void SetCurrentLineNumber(int line, const char* libname);
|
||||||
|
void SetMainFileName(const char* name);
|
||||||
|
void KillThread(int code);
|
||||||
|
void StatusBar(BRect frame, const char* id, const char* label1, const char* label2, const char* view);
|
||||||
|
void StatusBarSet(const char* id, const char* label1, const char* label2, double state);
|
||||||
|
void StatusBarSet(BRect frame, const char* id, const char* view);
|
||||||
|
void StatusBarSet(const char* id, int r, int g, int b);
|
||||||
|
void RefsReceived(BMessage *message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void RemoveView(BView* myView);
|
||||||
|
void GetMMsgInfo(BString &t, int mouseStateInfo, int mouseLButton, int mouseMButton, int mouseRButton, int x, int y, const char* name);
|
||||||
|
BBitmap* loadImage(const char* name);
|
||||||
|
static int compare(BListItem **firstArg, BListItem **secondArg);
|
||||||
|
|
||||||
|
BTranslatorRoster *Roster;
|
||||||
|
char ApplicationDirectory[1024];
|
||||||
|
char loadPanel[1280];
|
||||||
|
char columntext[4096];
|
||||||
|
char mousemessagebuffer[64];
|
||||||
|
char keyboardbuffer[27];
|
||||||
|
char messagebuffer[32567];
|
||||||
|
char attrbuffer[32567];
|
||||||
|
char mouseoverbuffer[256];
|
||||||
|
BFilePanel *fopen, *fsave;
|
||||||
|
thread_id myThread;
|
||||||
|
int errorCode;
|
||||||
|
bool drawStroking;
|
||||||
|
int yabAlpha;
|
||||||
|
pattern yabPattern;
|
||||||
|
YabList *viewList;
|
||||||
|
int currentLineNumber;
|
||||||
|
const char* mainFileName;
|
||||||
|
bool exiting;
|
||||||
|
BPropertyInfo *myProps;
|
||||||
|
BString localMessage;
|
||||||
|
BString currentLib;
|
||||||
|
BList *yabbitmaps;
|
||||||
|
BList *yabcanvas;
|
||||||
|
BString lastMouseMsg;
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
typedef
|
||||||
|
struct YabInterface
|
||||||
|
YabInterface;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern int mmain(int argc, char** argv, YabInterface* yab); /* ANSI C prototypes */
|
||||||
|
extern const char* yi_GetApplicationDirectory(YabInterface *yab);
|
||||||
|
extern void yi_OpenWindow(double x1,double y1,double x2,double y2, const char* id, const char* title, YabInterface* yab);
|
||||||
|
extern int yi_CloseWindow(const char* view, YabInterface* yab);
|
||||||
|
extern void yi_CreateButton(double x1,double y1,double x2,double y2, const char* id, const char* title, const char* window, YabInterface* yab);
|
||||||
|
extern int yi_CreateImage(double x,double y,const char* imagefile, const char* window, YabInterface* yab);
|
||||||
|
extern int yi_CreateImage2(double x1,double y1,double x2, double y2,const char* imagefile, const char* window, YabInterface* yab);
|
||||||
|
extern int yi_CreateSVG(double x1,double y1,double x2, double y2,const char* imagefile, const char* window, YabInterface* yab);
|
||||||
|
extern void yi_CreateMenu(const char* menuhead, const char* menuitem, const char *shortcut, const char* window, YabInterface* yab);
|
||||||
|
extern void yi_CreateTextControl(double x1, double y1, double x2, double y2, const char *id, const char* label, const char* text, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_CreateCheckBox(double x, double y, const char *id, const char* label, int isActivated, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_CreateRadioButton(double x, double y, const char* groupID, const char* label, int isActivated, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_CreateListBox(double x1,double y1,double x2,double y2, const char* title, int scrollbar, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_CreateDropBox(double x1, double y1,double x2,double y2, const char* title,const char* label, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_CreateItem(const char* id,const char* item, YabInterface *yab);
|
||||||
|
extern void yi_RemoveItem(const char* title,const char* item, YabInterface *yab);
|
||||||
|
extern void yi_ClearItems(const char* title, YabInterface *yab);
|
||||||
|
extern void yi_DrawText(double x, double y, const char* text, const char* window, YabInterface* yab);
|
||||||
|
extern void yi_DrawRect(double x1, double y1, double x2, double y2, const char* window, YabInterface* yab);
|
||||||
|
extern void yi_DrawClear(const char* window, YabInterface* yab);
|
||||||
|
extern void yi_CreateAlert(const char* text, const char* button1, const char* type, YabInterface* yab);
|
||||||
|
extern void yi_CreateText(double x, double y, const char *id, const char* text, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_Text2(double x1, double y1, double x2, double y2, const char *id, const char* text, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_TextAlign(const char* txt, const char *option, YabInterface *yab);
|
||||||
|
extern void yi_Translate(char* text, char result[]);
|
||||||
|
extern void yi_MenuTranslate(char* text, char result[]);
|
||||||
|
extern void yi_SetLocalize();
|
||||||
|
extern void yi_StopLocalize();
|
||||||
|
extern const char* yi_LoadFilePanel(const char* mode, const char* title, const char* directory, YabInterface* yab);
|
||||||
|
extern const char* yi_SaveFilePanel(const char* mode, const char* title, const char* directory, const char*filename, YabInterface* yab);
|
||||||
|
extern void yi_SetLayout(const char* layout, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_WindowSet1(const char* option, const char* value, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_WindowSet2(const char* option, int r, int g, int b, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_WindowSet3(const char* option, double x, double y, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_WindowSet4(const char* option, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_WindowClear(const char* window, YabInterface *yab);
|
||||||
|
extern void yi_TextEdit(double x1, double y1, double x2, double y2, const char* title, int scrollbar, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_TextAdd(const char* title, const char* text, YabInterface *yab);
|
||||||
|
extern void yi_TextSet(const char* title, const char* option, YabInterface *yab);
|
||||||
|
extern void yi_TextClear(const char* title, YabInterface *yab);
|
||||||
|
extern const char* yi_TextGet(const char* title, YabInterface *yab);
|
||||||
|
extern const char* yi_TextGet3(const char* title, int linenum, YabInterface *yab);
|
||||||
|
extern const char* yi_TextGet6(const char* title, const char* option, YabInterface *yab);
|
||||||
|
extern double yi_TextGet4(const char* title, const char* option, int line, YabInterface *yab);
|
||||||
|
extern int yi_TextGet5(const char* title, const char* option, const char* option2, YabInterface *yab);
|
||||||
|
extern void yi_TextSet2(const char* title, const char* option, int value, YabInterface *yab);
|
||||||
|
extern void yi_TextSet3(const char* title, const char* option, const char* value, YabInterface *yab);
|
||||||
|
extern void yi_TextColor1(const char* title, const char* option, const char* command, YabInterface *yab);
|
||||||
|
extern void yi_TextColor2(const char* title, const char* option, int r, int g, int b, YabInterface *yab);
|
||||||
|
extern int yi_TextGet2(const char* title, const char* option, YabInterface *yab);
|
||||||
|
extern void yi_DrawSet1(const char* option, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_DrawSet2(int fillorstroke, const char* mypattern, YabInterface *yab);
|
||||||
|
extern void yi_View(double x1, double y1, double x2, double y2, const char* id, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_BoxView(double x1, double y1, double x2, double y2, const char* id, const char* text, int lineType, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_BoxViewSet(const char* id, const char* option, const char* value, YabInterface *yab);
|
||||||
|
extern void yi_Tab(double x1, double y1, double x2, double y2, const char* id, const char* names, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_TabSet(const char* id, int num, YabInterface *yab);
|
||||||
|
extern void yi_TabAdd(const char* id, const char* name, YabInterface *yab);
|
||||||
|
extern void yi_TabDel(const char* id, int num, YabInterface *yab);
|
||||||
|
extern int yi_TabViewGet(const char* id, YabInterface *yab);
|
||||||
|
extern void yi_DrawDot(double x, double y, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_DrawLine(double x1, double y1, double x2, double y2, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_DrawCircle(double x, double y, double r, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_DrawEllipse(double x, double y, double r1, double r2, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_DrawCurve(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, const char* window, YabInterface *yab);
|
||||||
|
extern void yi_Slider1(double x1, double y1, double x2, double y2, const char* id, const char* title, int min, int max, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_Slider2(double x1, double y1, double x2, double y2, const char* id, const char* title, int min, int max, const char* option, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_SetSlider1(const char* id, const char* label1, const char* label2, YabInterface *yab);
|
||||||
|
extern void yi_SetSlider2(const char* id, const char* bottomtop, int count, YabInterface *yab);
|
||||||
|
extern void yi_SetSlider3(const char* id, const char* part, int r, int g, int b, YabInterface *yab);
|
||||||
|
extern void yi_SetSlider4(const char* id, int value, YabInterface *yab);
|
||||||
|
extern void yi_SetOption1(const char* id, const char* option, const char* value, YabInterface *yab);
|
||||||
|
extern void yi_SetOption2(const char* id, const char* option, int r, int g, int b, YabInterface *yab);
|
||||||
|
extern void yi_SetOption3(const char* id, const char* option, double x, double y, YabInterface *yab);
|
||||||
|
extern void yi_SetOption4(const char* id, const char* option, YabInterface *yab);
|
||||||
|
extern void yi_SetOption5(const char* id, const char* option, int value, YabInterface *yab);
|
||||||
|
extern void yi_DropZone(const char* view, YabInterface *yab);
|
||||||
|
extern void yi_ColorControl1(double x, double y, const char* id, const char* view, YabInterface* yab);
|
||||||
|
extern void yi_ColorControl2(const char* id, int r, int g, int b, YabInterface* yab);
|
||||||
|
extern void yi_TextControl2(const char* id, const char* text, YabInterface* yab);
|
||||||
|
extern void yi_TextControl3(const char* id, int mode, YabInterface* yab);
|
||||||
|
extern void yi_TextControl5(const char* id, YabInterface* yab);
|
||||||
|
extern void yi_TextControl4(const char* id, const char* option, const char* value, YabInterface* yab);
|
||||||
|
extern void yi_TreeBox1(double x1, double y1, double x2, double y2, const char* id, int scrollbarType, const char* view, YabInterface* yab);
|
||||||
|
extern void yi_TreeBox2(const char* id, const char* item, YabInterface* yab);
|
||||||
|
extern void yi_TreeBox3(const char* id, const char* head, const char* item, int isExpanded, YabInterface* yab);
|
||||||
|
extern void yi_TreeBox4(const char* id, YabInterface* yab);
|
||||||
|
extern void yi_TreeBox5(const char* id, const char* item, YabInterface* yab);
|
||||||
|
extern void yi_TreeBox7(const char* id, int pos, YabInterface* yab);
|
||||||
|
extern void yi_TreeBox8(const char* id, int pos, YabInterface* yab);
|
||||||
|
extern void yi_TreeBox9(const char* id, const char* head, const char* item, YabInterface* yab);
|
||||||
|
extern void yi_TreeBox10(const char* id, const char* head, YabInterface* yab);
|
||||||
|
extern void yi_TreeBox11(const char* id, const char* head, YabInterface* yab);
|
||||||
|
extern void yi_TreeBox12(const char* id, const char* item, int pos, YabInterface* yab);
|
||||||
|
extern const char* yi_TreeboxGet(const char* treebox, int pos, YabInterface* yab);
|
||||||
|
extern int yi_TreeboxCount(const char* treebox, YabInterface* yab);
|
||||||
|
extern void yi_ButtonImage(double x,double y,const char* id,const char* enabledon, const char* enabledoff, const char* disabled, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_CheckboxImage(double x,double y,const char* id,const char* enabledon, const char* enabledoff, const char *disabledon, const char *disabledoff, int isActivated, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_CheckboxSet(const char* id, int isActivated, YabInterface* yab);
|
||||||
|
extern void yi_RadioSet(const char* id, int isActivated, YabInterface* yab);
|
||||||
|
extern const char* yi_TextControlGet(const char* id, YabInterface* yab);
|
||||||
|
extern void yi_ToolTip(const char* view, const char* text, YabInterface *yab);
|
||||||
|
extern void yi_ToolTipColor(const char* color, int r, int g, int b, YabInterface *yab);
|
||||||
|
extern void yi_TreeSort(const char* view, YabInterface *yab);
|
||||||
|
extern void yi_ListSort(const char* view, YabInterface *yab);
|
||||||
|
extern void yi_FileBox(double x1, double y1, double x2, double y2, const char* id, int scrollbartype, const char* option, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_FileBoxAdd2(const char* id, const char* name, int pos, double maxWidth, double minWidth, double width, const char* option, YabInterface *yab);
|
||||||
|
extern void yi_FileBoxClear(const char* view, YabInterface *yab);
|
||||||
|
extern void yi_ColumnBoxAdd(const char* id, int column, int position, int height, const char* item, YabInterface *yab);
|
||||||
|
extern void yi_ColumnBoxSelect(const char *columnbox, int position, YabInterface *yab);
|
||||||
|
extern void yi_ColumnBoxRemove(const char *columnbox, int position, YabInterface *yab);
|
||||||
|
extern void yi_ColumnBoxColor(const char *columnbox, const char* option, int r, int g, int b, YabInterface *yab);
|
||||||
|
extern int yi_Printer(const char* docname, const char *view, const char* config, YabInterface *yab);
|
||||||
|
extern void yi_PrinterConfig(const char* config, YabInterface *yab);
|
||||||
|
extern const char* yi_ColumnBoxGet(const char *columnbox, int column, int position, YabInterface *yab);
|
||||||
|
extern int yi_ColumnBoxCount(const char *columnbox, YabInterface *yab);
|
||||||
|
extern int yi_DeskbarPosition(YabInterface *yab);
|
||||||
|
extern int yi_DeskbarExpanded(YabInterface *yab);
|
||||||
|
extern int yi_DeskbarWidth(YabInterface *yab);
|
||||||
|
extern int yi_DeskbarHeight(YabInterface *yab);
|
||||||
|
extern int yi_DeskbarX(YabInterface *yab);
|
||||||
|
extern int yi_DeskbarY(YabInterface *yab);
|
||||||
|
extern int yi_DesktopWidth(YabInterface *yab);
|
||||||
|
extern int yi_DesktopHeight(YabInterface *yab);
|
||||||
|
extern int yi_WindowGet(const char* view, const char* option, YabInterface *yab);
|
||||||
|
extern int yi_ViewGet(const char* view, const char* option, YabInterface *yab); //vasper
|
||||||
|
extern void yi_ClipboardCopy(const char* text, YabInterface *yab);
|
||||||
|
extern const char* yi_ClipboardPaste(YabInterface *yab);
|
||||||
|
extern int yi_NewAlert(const char* text, const char* button1, const char* button2, const char* button3, const char* option, YabInterface *yab);
|
||||||
|
extern void yi_Calendar1(double x, double y, const char* id, const char* format, const char* date, const char* view, YabInterface *yab);
|
||||||
|
extern const char* yi_Calendar2(const char* id, YabInterface *yab);
|
||||||
|
extern void yi_Calendar3(const char* id, const char* date, YabInterface *yab);
|
||||||
|
extern void yi_MouseSet(const char* opt, YabInterface *yab);
|
||||||
|
extern void yi_Scrollbar(const char* id, int format, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_ScrollbarSet1(const char* scrollview, const char* option, double position, YabInterface *yab);
|
||||||
|
extern void yi_ScrollbarSet2(const char* scrollview, const char* option, double opt1, double opt2, YabInterface *yab);
|
||||||
|
extern void yi_ScrollbarSet3(const char* scrollview, const char* option, YabInterface *yab);
|
||||||
|
extern double yi_ScrollbarGet(const char* scrollview, const char* option, YabInterface *yab);
|
||||||
|
extern const char* yi_ListboxGet(const char* listbox, int pos, YabInterface *yab);
|
||||||
|
extern int yi_ListboxCount(const char* listbox, YabInterface *yab);
|
||||||
|
extern void yi_ListboxAdd1(const char* listbox, const char* item, YabInterface *yab);
|
||||||
|
extern void yi_ListboxAdd2(const char* listbox, int pos, const char* item, YabInterface *yab);
|
||||||
|
extern void yi_ListboxSelect(const char* listbox, int pos, YabInterface *yab);
|
||||||
|
extern void yi_ListboxRemove(const char* listbox, int pos, YabInterface *yab);
|
||||||
|
extern void yi_SplitView1(double x1,double y1,double x2,double y2, const char* id, int isVertical, int style, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_SplitView2(const char* splitView, const char* option, double position, YabInterface *yab);
|
||||||
|
extern void yi_SplitView3(const char* splitView, const char* option, double left, double right, YabInterface *yab);
|
||||||
|
extern double yi_SplitViewGet(const char* splitView, const char* option, YabInterface *yab);
|
||||||
|
extern void yi_StackView1(double x1,double y1,double x2,double y2, const char* id, int number, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_StackView2(const char* stackView, int num, YabInterface *yab);
|
||||||
|
extern int yi_StackViewGet(const char* stackView, YabInterface *yab);
|
||||||
|
extern void yi_DrawSet3(const char* option, int transparency, YabInterface *yab);
|
||||||
|
extern void yi_TextURL1(double x, double y, const char* id, const char* text, const char* url, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_TextURL2(const char* id, const char* option, int r, int g, int b, YabInterface *yab);
|
||||||
|
extern void yi_Menu2(const char* menuHead, int isRadio, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_SubMenu1(const char* menuHead, const char* menuItem, const char* subMenuItem, const char* modifiers, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_SubMenu2(const char* menuHead, const char* menuItem, int isRadio, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_SpinControl1(double x, double y, const char* id, const char* label, int min, int max, int step, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_SpinControl2(const char* spinControl, int value, YabInterface *yab);
|
||||||
|
extern int yi_SpinControlGet(const char *spinControl, YabInterface *yab);
|
||||||
|
extern const char* yi_PopUpMenu(double x, double y, const char* menuItems, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_DropBoxSelect(const char* dropbox, int position, YabInterface *yab);
|
||||||
|
extern void yi_DropBoxClear(const char* dropbox, YabInterface *yab);
|
||||||
|
extern void yi_DropBoxRemove(const char* dropbox, int position, YabInterface *yab);
|
||||||
|
extern int yi_DropBoxCount(const char* dropbox, YabInterface *yab);
|
||||||
|
extern const char* yi_DropBoxGet(const char* dropbox, int position, YabInterface *yab);
|
||||||
|
extern int yi_ColorControlGet(const char* colorcontrol, const char* option, YabInterface *yab);
|
||||||
|
extern int yi_SliderGet(const char* slider, YabInterface *yab);
|
||||||
|
extern void yi_SubMenu3(const char* menuHead, const char* menuItem, const char* subMenuItem, const char* option, const char* view, YabInterface *yab);
|
||||||
|
extern void yi_Menu3(const char* menuHead, const char* menuItem, const char* option,const char* view, YabInterface *yab);
|
||||||
|
extern double yi_MenuHeight(YabInterface *yab);
|
||||||
|
extern double yi_TabHeight(YabInterface *yab);
|
||||||
|
extern double yi_ScrollbarWidth(YabInterface *yab);
|
||||||
|
extern double yi_DrawGet1(const char* option, const char* txt, const char* view, YabInterface* yab);
|
||||||
|
extern double yi_DrawGet2(const char* option, const char* view, YabInterface* yab);
|
||||||
|
extern const char* yi_DrawGet3(const char* option, YabInterface* yab);
|
||||||
|
extern int yi_DrawGet4(double x, double y, const char* option, const char* view, YabInterface* yab);
|
||||||
|
extern void yi_exit(int code, YabInterface *yab);
|
||||||
|
extern void yi_Launch(const char* strg, YabInterface *yab);
|
||||||
|
extern const int yi_IsMouseIn(const char* view, YabInterface* yab);
|
||||||
|
extern const char* yi_GetMouseIn(YabInterface* yab);
|
||||||
|
extern const char* yi_GetMouseMessages(const char* view, YabInterface* yab);
|
||||||
|
extern const char* yi_KeyboardMessages(const char* view, YabInterface* yab);
|
||||||
|
extern const char* yi_CheckMessages(YabInterface* yab);
|
||||||
|
extern int yi_MessageSend(const char* app, const char* msg,YabInterface* yab);
|
||||||
|
extern int yi_ThreadKill(const char* option, int id,YabInterface* yab);
|
||||||
|
extern int yi_ThreadGet(const char* option, const char* appname,YabInterface* yab);
|
||||||
|
extern void yi_Bitmap(double w, double h, const char* id,YabInterface* yab);
|
||||||
|
extern int yi_BitmapColor(double x, double y, const char* id, const char* option, YabInterface *yab);
|
||||||
|
extern void yi_BitmapDraw(double x, double y, const char* bitmap, const char* mode, const char* view,YabInterface* yab);
|
||||||
|
extern void yi_BitmapDraw2(double x1, double y1, double x2, double y2, const char* bitmap, const char* mode, const char* view,YabInterface* yab);
|
||||||
|
extern void yi_BitmapGet(double x1, double y1, double x2, double y2, const char* id, const char* bitmap,YabInterface* yab);
|
||||||
|
extern void yi_BitmapGet2(double w, const char* id, const char* path, YabInterface* yab);
|
||||||
|
extern void yi_BitmapGetIcon(const char* id, const char* option, const char* path, YabInterface* yab);
|
||||||
|
extern int yi_BitmapGetNum(const char* id, const char* option, YabInterface* yab);
|
||||||
|
extern int yi_BitmapLoad(const char* filename, const char* bitmap, YabInterface* yab);
|
||||||
|
extern void yi_BitmapDrag(const char* bitmap,YabInterface* yab);
|
||||||
|
extern void yi_BitmapRemove(const char* bitmap,YabInterface* yab);
|
||||||
|
extern void yi_Screenshot(double x1, double y1, double x2, double y2, const char* bitmap, YabInterface* yab);
|
||||||
|
extern int yi_BitmapSave(const char* id, const char* filename, const char* type, YabInterface* yab);
|
||||||
|
extern void yi_Canvas(double x1, double y1, double x2, double y2, const char* id, const char* view, YabInterface *yab);
|
||||||
|
extern int yi_Sound(const char* filename, YabInterface* yab);
|
||||||
|
extern void yi_SoundStop(int id, YabInterface* yab);
|
||||||
|
extern void yi_SoundWait(int id, YabInterface* yab);
|
||||||
|
extern int yi_IsComputerOn(YabInterface* yab);
|
||||||
|
extern void yi_ShortCut(const char* view, const char* key, const char* msg, YabInterface* yab);
|
||||||
|
extern void yi_DrawSet4(const char* option, const char* color,const char* view, YabInterface* yab);
|
||||||
|
extern void yi_Treebox13(const char* id,const char* option, int pos, YabInterface* yab);
|
||||||
|
extern int yi_TreeboxGetOpt(const char* id, const char* option, int pos, YabInterface* yab);
|
||||||
|
extern int yi_ListboxGetNum(const char* id, YabInterface* yab);
|
||||||
|
extern int yi_DropboxGetNum(const char* id, YabInterface* yab);
|
||||||
|
extern int yi_TreeboxGetNum(const char* id, YabInterface* yab);
|
||||||
|
extern int yi_ColumnboxGetNum(const char* id, YabInterface* yab);
|
||||||
|
extern void yi_SetLocalize2(const char* path, YabInterface* yab);
|
||||||
|
extern void yi_SetCurrentLineNumber(int line, const char* libname, YabInterface* yab);
|
||||||
|
extern void yi_SetMainFileName(const char* name, YabInterface* yab);
|
||||||
|
extern void yi_beep();
|
||||||
|
extern void yi_StatusBar(double x1, double y1, double x2, double y2, const char* id, const char* label1, const char* label2, const char* view, YabInterface* yab);
|
||||||
|
extern void yi_StatusBarSet(const char* id, const char* label1, const char* label2, double state, YabInterface* yab);
|
||||||
|
extern void yi_StatusBarSet2(double x1, double y1, double x2, double y2, const char* id, const char* view, YabInterface* yab);
|
||||||
|
extern void yi_StatusBarSet3(const char* id, int r, int g, int b, YabInterface* yab);
|
||||||
|
extern void yi_Attribute1(const char* type, const char* name, const char* value, const char* filename, YabInterface* yab);
|
||||||
|
extern void yi_AttributeClear(const char* name, const char* filename, YabInterface* yab);
|
||||||
|
extern const char* yi_AttributeGet1(const char* name, const char* filename, YabInterface* yab);
|
||||||
|
extern double yi_AttributeGet2(const char* name, const char* filename, YabInterface* yab);
|
||||||
|
extern char* refsRec; //refs received
|
||||||
|
|
||||||
|
#ifdef LOCALIZE
|
||||||
|
const char* _L(const char* text);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*YABINTERFACE_H*/
|
||||||
92
src/YabList.cpp
Normal file
92
src/YabList.cpp
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
#include <List.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include "YabList.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
YabList::YabList()
|
||||||
|
{
|
||||||
|
idList = new BList(1);
|
||||||
|
viewList = new BList(1);
|
||||||
|
typeList = new BList(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
YabList::~YabList()
|
||||||
|
{
|
||||||
|
DelAll();
|
||||||
|
delete idList;
|
||||||
|
delete viewList;
|
||||||
|
delete typeList;
|
||||||
|
}
|
||||||
|
|
||||||
|
int YabList::ViewNum(const char* id)
|
||||||
|
{
|
||||||
|
int tmp=-1;
|
||||||
|
if(id)
|
||||||
|
{
|
||||||
|
for(int i=0; i<idList->CountItems(); i++)
|
||||||
|
if(!strcmp(id, ((BString*)(idList->ItemAt(i)))->String() ))
|
||||||
|
{
|
||||||
|
tmp = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabList::AddView(const char* id, const BView* view, int type)
|
||||||
|
{
|
||||||
|
idList->AddItem((void*)new BString(id));
|
||||||
|
viewList->AddItem((void*)view);
|
||||||
|
typeList->AddItem((void*)type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabList::DelView(const char* id)
|
||||||
|
{
|
||||||
|
int i = ViewNum(id);
|
||||||
|
if(i!=-1)
|
||||||
|
{
|
||||||
|
idList->RemoveItem(i);
|
||||||
|
viewList->RemoveItem(i);
|
||||||
|
typeList->RemoveItem(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabList::DelAll()
|
||||||
|
{
|
||||||
|
idList->MakeEmpty();
|
||||||
|
viewList->MakeEmpty();
|
||||||
|
typeList->MakeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
const void* YabList::GetView(const char* id)
|
||||||
|
{
|
||||||
|
int t = ViewNum(id);
|
||||||
|
if(t>=0)
|
||||||
|
return viewList->ItemAt(t);
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int YabList::GetType(const char* id)
|
||||||
|
{
|
||||||
|
return (int)typeList->ItemAt(ViewNum(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
const int YabList::CountItems()
|
||||||
|
{
|
||||||
|
return typeList->CountItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
const void* YabList::ItemAt(int i)
|
||||||
|
{
|
||||||
|
return viewList->ItemAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabList::PrintOut()
|
||||||
|
{
|
||||||
|
printf("\n");
|
||||||
|
for(int i=0; i<idList->CountItems(); i++)
|
||||||
|
printf("\t%s\n", ((BString*)(idList->ItemAt(i)))->String() );
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
27
src/YabList.h
Normal file
27
src/YabList.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef YABLIST_H
|
||||||
|
#define YABLIST_H
|
||||||
|
|
||||||
|
#include <String.h>
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
class YabList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YabList();
|
||||||
|
~YabList();
|
||||||
|
void AddView(const char* id, const BView* view, int type);
|
||||||
|
void DelView(const char* id);
|
||||||
|
void DelAll();
|
||||||
|
const void* GetView(const char* id);
|
||||||
|
const int GetType(const char* id);
|
||||||
|
const int CountItems();
|
||||||
|
const void* ItemAt(int i);
|
||||||
|
void PrintOut();
|
||||||
|
private:
|
||||||
|
int ViewNum(const char* id);
|
||||||
|
BList* idList;
|
||||||
|
BList* viewList;
|
||||||
|
BList* typeList;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
54
src/YabMain.cpp
Normal file
54
src/YabMain.cpp
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#include <File.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "YabInterface.h"
|
||||||
|
|
||||||
|
char t[1024];
|
||||||
|
const char* readSignature(int argc, char** argv)
|
||||||
|
{
|
||||||
|
BString tmp("application/x-vnd.yab-app");
|
||||||
|
/* Do not make changes above this comment without changing yab-IDE
|
||||||
|
to compensate for these changes.*/
|
||||||
|
for(int i=1; i<argc; i++)
|
||||||
|
{
|
||||||
|
if(argv[i][0]!='-')
|
||||||
|
{
|
||||||
|
BFile file(argv[i], B_READ_ONLY);
|
||||||
|
if(file.InitCheck()==B_OK)
|
||||||
|
{
|
||||||
|
char readData[1024];
|
||||||
|
int pos;
|
||||||
|
file.Read(readData,1024);
|
||||||
|
BString tmpString(readData);
|
||||||
|
pos = tmpString.IFindFirst("MIMETYPE");
|
||||||
|
if(pos!=B_ERROR)
|
||||||
|
{
|
||||||
|
int quote1, quote2;
|
||||||
|
quote1 = tmpString.FindFirst("\"",pos);
|
||||||
|
if(quote1!=B_ERROR)
|
||||||
|
{
|
||||||
|
quote2 = tmpString.FindFirst("\"",quote1+1);
|
||||||
|
if(quote2!=B_ERROR)
|
||||||
|
{
|
||||||
|
tmp.SetTo("");
|
||||||
|
tmpString.CopyInto(tmp,quote1+1,quote2-quote1-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strcpy(t,tmp.String());
|
||||||
|
return (const char*)t;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
YabInterface *yabInterface = new YabInterface(argc, argv, readSignature(argc, argv));
|
||||||
|
yabInterface->Run();
|
||||||
|
ret = yabInterface->GetErrorCode();
|
||||||
|
delete yabInterface;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
17
src/YabMenu.h
Normal file
17
src/YabMenu.h
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef YABMENU_H
|
||||||
|
#define YABMENU_H
|
||||||
|
|
||||||
|
class YabMenu : public BMenu
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YabMenu(const char* name) : BMenu(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyHide()
|
||||||
|
{
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
50
src/YabStackView.cpp
Normal file
50
src/YabStackView.cpp
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
// #include <string.h>
|
||||||
|
#include "YabStackView.h"
|
||||||
|
|
||||||
|
|
||||||
|
YabStackView::YabStackView(BRect frame, const char *name, int32 number_of_views, uint32 resizingMode, uint32 flags, const BFont *labelFont) : BView(frame, name, resizingMode, flags)
|
||||||
|
{
|
||||||
|
myViews = new BView*[number_of_views];
|
||||||
|
// init
|
||||||
|
for(int i=0; i < number_of_views; i++)
|
||||||
|
{
|
||||||
|
myViews[i] = NULL;
|
||||||
|
}
|
||||||
|
myCurrent = 0;
|
||||||
|
myBounds = Bounds();
|
||||||
|
myNumOfViews = number_of_views;
|
||||||
|
}
|
||||||
|
|
||||||
|
YabStackView::~YabStackView()
|
||||||
|
{
|
||||||
|
delete[] myViews;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabStackView::AddViews(BView** stackedViews)
|
||||||
|
{
|
||||||
|
for(int32 i = 0; i < myNumOfViews; i++)
|
||||||
|
{
|
||||||
|
myViews[i] = stackedViews[i];
|
||||||
|
if(i != myCurrent) myViews[i]->Hide();
|
||||||
|
AddChild(myViews[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void YabStackView::SelectView(int32 index)
|
||||||
|
{
|
||||||
|
if(index != myCurrent && index >= 0 && index < myNumOfViews)
|
||||||
|
{
|
||||||
|
Invalidate(myBounds);
|
||||||
|
myViews[myCurrent]->Hide();
|
||||||
|
myCurrent = index;
|
||||||
|
Invalidate(myBounds);
|
||||||
|
myViews[myCurrent]->Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 YabStackView::CurrentView()
|
||||||
|
{
|
||||||
|
return myCurrent;
|
||||||
|
}
|
||||||
|
|
||||||
23
src/YabStackView.h
Normal file
23
src/YabStackView.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef YAB_STACKVIEW_H_
|
||||||
|
#define YAB_STACKVIEW_H_
|
||||||
|
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
class YabStackView : public BView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YabStackView(BRect frame, const char *name, int32 number_of_views, uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 flags = B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS, const BFont *labelFont = be_plain_font);
|
||||||
|
~YabStackView();
|
||||||
|
|
||||||
|
void AddViews(BView** stackedViews);
|
||||||
|
int32 CurrentView();
|
||||||
|
virtual void SelectView(int32 index);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BView** myViews;
|
||||||
|
int32 myCurrent;
|
||||||
|
BRect myBounds;
|
||||||
|
int32 myNumOfViews;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
543
src/YabTabView.cpp
Normal file
543
src/YabTabView.cpp
Normal file
@@ -0,0 +1,543 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2001-2005, Haiku
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
// File Name: YabTabView.cpp
|
||||||
|
// Author: Marc Flerackers (mflerackers@androme.be)
|
||||||
|
// Modified by Jan Bungeroth (jan@be-logos.org)
|
||||||
|
// Description: YabTabView provides the framework for containing and
|
||||||
|
// managing groups of BView objects. Modified for *sane*
|
||||||
|
// view handling (they stay connected to the window).
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <List.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
|
#include "YabControlLook.h"
|
||||||
|
#include "YabTabView.h"
|
||||||
|
|
||||||
|
#define X_OFFSET 0.0f
|
||||||
|
|
||||||
|
YabTabView::YabTabView(BRect frame, const char* name, button_width width, uint32 resizingMode, uint32 flags)
|
||||||
|
: BView(frame, name, resizingMode, flags)
|
||||||
|
{
|
||||||
|
fTabList = new BList;
|
||||||
|
fTabNames = new BList;
|
||||||
|
|
||||||
|
fTabWidthSetting = width;
|
||||||
|
fSelection = 0;
|
||||||
|
fFocus = -1;
|
||||||
|
fTabOffset = 0.0f;
|
||||||
|
|
||||||
|
rgb_color color = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
|
||||||
|
SetViewColor(color);
|
||||||
|
SetLowColor(color);
|
||||||
|
|
||||||
|
font_height fh;
|
||||||
|
GetFontHeight(&fh);
|
||||||
|
fTabHeight = fh.ascent + fh.descent + fh.leading + 8.0f;
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (layouted) {
|
||||||
|
BGroupLayout* layout = new(std::nothrow) BGroupLayout(B_HORIZONTAL);
|
||||||
|
if (layout) {
|
||||||
|
layout->SetInsets(3.0, 3.0 + TabHeight() - 1, 3.0, 3.0);
|
||||||
|
SetLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
fContainerView = new BView("view container", B_WILL_DRAW);
|
||||||
|
fContainerView->SetLayout(new(std::nothrow) BCardLayout());
|
||||||
|
} else {
|
||||||
|
*/
|
||||||
|
BRect bounds = Bounds();
|
||||||
|
|
||||||
|
bounds.top += TabHeight();
|
||||||
|
bounds.InsetBy(3.0f, 3.0f);
|
||||||
|
|
||||||
|
fContainerView = new BView(bounds, "view container", B_FOLLOW_ALL,
|
||||||
|
B_WILL_DRAW);
|
||||||
|
// }
|
||||||
|
|
||||||
|
fContainerView->SetViewColor(color);
|
||||||
|
fContainerView->SetLowColor(color);
|
||||||
|
|
||||||
|
AddChild(fContainerView);
|
||||||
|
FocusChanged = 1;
|
||||||
|
OldTabView = 1;
|
||||||
|
|
||||||
|
fTabOrientation = B_TAB_TOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
YabTabView::~YabTabView()
|
||||||
|
{
|
||||||
|
for(int i=0; i<CountTabs(); i++)
|
||||||
|
{
|
||||||
|
delete TabAt(i);
|
||||||
|
delete (BString*)fTabNames->RemoveItem(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete fTabList;
|
||||||
|
delete fTabNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::AddTab(BView *tabView, const char* label)
|
||||||
|
{
|
||||||
|
if(tabView)
|
||||||
|
{
|
||||||
|
tabView->Hide();
|
||||||
|
fContainerView->AddChild(tabView);
|
||||||
|
Invalidate();
|
||||||
|
if(CountTabs() == 0) tabView->Show();
|
||||||
|
|
||||||
|
|
||||||
|
fTabList->AddItem(tabView);
|
||||||
|
fTabNames->AddItem(new BString(label));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BView* YabTabView::RemoveTab(int32 index)
|
||||||
|
{
|
||||||
|
if(index < 0 || index >= CountTabs())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
BView *tab = (BView*)fTabList->RemoveItem(index);
|
||||||
|
delete (BString*)fTabNames->RemoveItem(index);
|
||||||
|
|
||||||
|
if (index <= fSelection && fSelection != 0)
|
||||||
|
fSelection--;
|
||||||
|
|
||||||
|
Select(fSelection);
|
||||||
|
|
||||||
|
if (fFocus == CountTabs() - 1)
|
||||||
|
SetFocusTab(fFocus, false);
|
||||||
|
else
|
||||||
|
SetFocusTab(fFocus, true);
|
||||||
|
|
||||||
|
return tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 YabTabView::CountTabs() const
|
||||||
|
{
|
||||||
|
return fTabList->CountItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 YabTabView::Selection() const
|
||||||
|
{
|
||||||
|
return fSelection;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::Select(int32 index)
|
||||||
|
{
|
||||||
|
if (index < 0 || index >= CountTabs())
|
||||||
|
index = Selection();
|
||||||
|
|
||||||
|
BView *tab = TabAt(Selection());
|
||||||
|
if (tab)
|
||||||
|
{
|
||||||
|
Invalidate();
|
||||||
|
tab->Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
tab = TabAt(index);
|
||||||
|
if (tab)
|
||||||
|
{
|
||||||
|
if (index != 0 && !Bounds().Contains(TabFrame(index))){
|
||||||
|
if (!Bounds().Contains(TabFrame(index).LeftTop()))
|
||||||
|
fTabOffset += TabFrame(index).left - Bounds().left - 20.0f;
|
||||||
|
else
|
||||||
|
fTabOffset += TabFrame(index).right - Bounds().right + 20.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Invalidate();
|
||||||
|
tab->Show();
|
||||||
|
fSelection = index;
|
||||||
|
FocusChanged = index+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::MakeFocus(bool focused)
|
||||||
|
{
|
||||||
|
BView::MakeFocus(focused);
|
||||||
|
|
||||||
|
SetFocusTab(Selection(), focused);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 YabTabView::FocusTab() const
|
||||||
|
{
|
||||||
|
return fFocus;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::SetFocusTab(int32 tab, bool focused)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (tab >= CountTabs())
|
||||||
|
tab = 0;
|
||||||
|
|
||||||
|
if (tab < 0)
|
||||||
|
tab = CountTabs() - 1;
|
||||||
|
|
||||||
|
if (focused) {
|
||||||
|
if (tab == fFocus)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fFocus != -1){
|
||||||
|
if (TabAt (fFocus) != NULL)
|
||||||
|
TabAt(fFocus)->MakeFocus(false);
|
||||||
|
Invalidate(TabFrame(fFocus));
|
||||||
|
}
|
||||||
|
if (TabAt(tab) != NULL){
|
||||||
|
TabAt(tab)->MakeFocus(true);
|
||||||
|
Invalidate(TabFrame(tab));
|
||||||
|
fFocus = tab;
|
||||||
|
}
|
||||||
|
} else if (fFocus != -1) {
|
||||||
|
TabAt(fFocus)->MakeFocus(false);
|
||||||
|
Invalidate(TabFrame(fFocus));
|
||||||
|
fFocus = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BView* YabTabView::TabAt(int32 index)
|
||||||
|
{
|
||||||
|
if(index < 0 || index >= CountTabs())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return (BView*)fTabList->ItemAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* YabTabView::GetTabName(int32 index) const
|
||||||
|
{
|
||||||
|
if(index < 0 || index >= CountTabs())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return ((BString*)fTabNames->ItemAt(index))->String();
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::KeyDown(const char *bytes, int32 numBytes)
|
||||||
|
{
|
||||||
|
if (IsHidden())
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (bytes[0]) {
|
||||||
|
case B_DOWN_ARROW:
|
||||||
|
case B_LEFT_ARROW: {
|
||||||
|
int32 focus = fFocus - 1;
|
||||||
|
if (focus < 0)
|
||||||
|
focus = CountTabs() - 1;
|
||||||
|
SetFocusTab(focus, true);
|
||||||
|
FocusChanged = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case B_UP_ARROW:
|
||||||
|
case B_RIGHT_ARROW: {
|
||||||
|
int32 focus = fFocus + 1;
|
||||||
|
if (focus >= CountTabs())
|
||||||
|
focus = 0;
|
||||||
|
SetFocusTab(focus, true);
|
||||||
|
FocusChanged = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case B_RETURN:
|
||||||
|
case B_SPACE:
|
||||||
|
Select(FocusTab());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
BView::KeyDown(bytes, numBytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::MouseDown(BPoint point)
|
||||||
|
{
|
||||||
|
if (fTabOrientation == B_TAB_TOP && point.y > fTabHeight)
|
||||||
|
return;
|
||||||
|
if (fTabOrientation == B_TAB_BOTTOM && point.y < Bounds().bottom-fTabHeight)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int32 i = 0; i < CountTabs(); i++) {
|
||||||
|
if (TabFrame(i).Contains(point) && i != Selection()) {
|
||||||
|
Select(i);
|
||||||
|
fFocus = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BView::MouseDown(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
BRect YabTabView::TabFrame(int32 tab_index) const
|
||||||
|
{
|
||||||
|
float width = 100.0;
|
||||||
|
float height = fTabHeight;;
|
||||||
|
BRect tabFrame(Bounds());
|
||||||
|
switch (fTabWidthSetting) {
|
||||||
|
case B_WIDTH_FROM_LABEL:
|
||||||
|
{
|
||||||
|
float x = 0.0;
|
||||||
|
for (int32 i = 0; i < tab_index; i++){
|
||||||
|
x += StringWidth(GetTabName(i)) + 20.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fTabOrientation == B_TAB_TOP)
|
||||||
|
tabFrame.Set(x, 0.0, x + StringWidth(GetTabName(tab_index)) + 20.0, height);
|
||||||
|
else
|
||||||
|
tabFrame.Set(x, tabFrame.bottom - height, x + StringWidth(GetTabName(tab_index)) + 20.0, tabFrame.bottom);
|
||||||
|
return tabFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
case B_WIDTH_FROM_WIDEST:
|
||||||
|
width = 0.0;
|
||||||
|
for (int32 i = 0; i < CountTabs(); i++) {
|
||||||
|
float tabWidth = StringWidth(GetTabName(i)) + 20.0;
|
||||||
|
if (tabWidth > width)
|
||||||
|
width = tabWidth;
|
||||||
|
}
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case B_WIDTH_AS_USUAL:
|
||||||
|
default:
|
||||||
|
if(fTabOrientation == B_TAB_TOP)
|
||||||
|
tabFrame.Set(tab_index * width, 0.0, tab_index * width + width, height);
|
||||||
|
else
|
||||||
|
tabFrame.Set(tab_index * width, tabFrame.bottom - height, tab_index * width + width, tabFrame.bottom);
|
||||||
|
return tabFrame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::SetTabWidth(button_width width)
|
||||||
|
{
|
||||||
|
fTabWidthSetting = width;
|
||||||
|
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
button_width YabTabView::TabWidth() const
|
||||||
|
{
|
||||||
|
return fTabWidthSetting;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::SetTabHeight(float height)
|
||||||
|
{
|
||||||
|
if (fTabHeight == height)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fContainerView->MoveBy(0.0f, height - fTabHeight);
|
||||||
|
fContainerView->ResizeBy(0.0f, height - fTabHeight);
|
||||||
|
|
||||||
|
fTabHeight = height;
|
||||||
|
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float YabTabView::TabHeight()
|
||||||
|
{
|
||||||
|
return fTabHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BView *YabTabView::ContainerView()
|
||||||
|
{
|
||||||
|
return fContainerView;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::Draw(BRect updateRect)
|
||||||
|
{
|
||||||
|
// DrawBox(DrawTabs());
|
||||||
|
// SetHighColor(223,223,223);
|
||||||
|
// StrokeLine(BPoint(Bounds().left, Bounds().bottom-TabHeight()-2), BPoint(Bounds().right, Bounds().bottom-TabHeight()-2));
|
||||||
|
DrawBox(TabFrame(fSelection));
|
||||||
|
DrawTabs();
|
||||||
|
|
||||||
|
if (IsFocus() && fFocus != -1)
|
||||||
|
{
|
||||||
|
DrawFocusMark(TabFrame(fFocus), fFocus);
|
||||||
|
// Invalidate(TabFrame(fFocus));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BRect YabTabView::DrawTabs()
|
||||||
|
{
|
||||||
|
float left = 0;
|
||||||
|
|
||||||
|
for (int32 i = 0; i < CountTabs(); i++) {
|
||||||
|
BRect tabFrame = TabFrame(i);
|
||||||
|
DrawTab(tabFrame, i, i == fSelection ? B_TAB_FRONT : (i == 0) ? B_TAB_FIRST : B_TAB_ANY, i + 1 != fSelection);
|
||||||
|
|
||||||
|
left = tabFrame.right;
|
||||||
|
}
|
||||||
|
|
||||||
|
BRect frame(Bounds());
|
||||||
|
if (left < frame.right) {
|
||||||
|
frame.left = left;
|
||||||
|
if(fTabOrientation == B_TAB_TOP)
|
||||||
|
frame.bottom = fTabHeight;
|
||||||
|
else
|
||||||
|
frame.top = frame.bottom - fTabHeight;
|
||||||
|
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
uint32 borders = BControlLook::B_TOP_BORDER
|
||||||
|
| BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER;
|
||||||
|
if (left == 0)
|
||||||
|
borders |= BControlLook::B_LEFT_BORDER;
|
||||||
|
if(fTabOrientation == B_TAB_TOP)
|
||||||
|
be_control_look->DrawInactiveTab(this, frame, frame, base, 0, borders);
|
||||||
|
else
|
||||||
|
fYabControlLook.DrawInactiveTabBottom(this, frame, frame, base, 0, borders);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fSelection < CountTabs())
|
||||||
|
return TabFrame(fSelection);
|
||||||
|
|
||||||
|
return BRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::DrawLabel(int32 current, BRect frame)
|
||||||
|
{
|
||||||
|
BString label = GetTabName(current);
|
||||||
|
if (label == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
float frameWidth = frame.Width();
|
||||||
|
float width = StringWidth(label.String());
|
||||||
|
font_height fh;
|
||||||
|
|
||||||
|
if (width > frameWidth) {
|
||||||
|
BFont font;
|
||||||
|
GetFont(&font);
|
||||||
|
font.TruncateString(&label, B_TRUNCATE_END, frameWidth);
|
||||||
|
width = frameWidth;
|
||||||
|
font.GetHeight(&fh);
|
||||||
|
} else {
|
||||||
|
GetFontHeight(&fh);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDrawingMode(B_OP_OVER);
|
||||||
|
SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
|
||||||
|
DrawString(label.String(),
|
||||||
|
BPoint((frame.left + frame.right - width) / 2.0,
|
||||||
|
(frame.top + frame.bottom - fh.ascent - fh.descent) / 2.0
|
||||||
|
+ fh.ascent));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void YabTabView::DrawTab(BRect frame, int32 current, tab_position position, bool full)
|
||||||
|
{
|
||||||
|
|
||||||
|
BView *owner = this;
|
||||||
|
rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
|
||||||
|
// uint32 borders = BControlLook::B_RIGHT_BORDER
|
||||||
|
// | BControlLook::B_TOP_BORDER | BControlLook::B_BOTTOM_BORDER;
|
||||||
|
// if (frame.left == owner->Bounds().left)
|
||||||
|
// borders |= BControlLook::B_LEFT_BORDER;
|
||||||
|
// be_control_look->DrawButtonFrame(owner, frame, frame,
|
||||||
|
// no_tint, 0, borders);
|
||||||
|
// if (position == B_TAB_FRONT)
|
||||||
|
// no_tint = tint_color(no_tint, B_DARKEN_2_TINT);
|
||||||
|
// be_control_look->DrawButtonBackground(owner, frame, frame, no_tint);
|
||||||
|
|
||||||
|
uint32 borders = BControlLook::B_TOP_BORDER
|
||||||
|
| BControlLook::B_BOTTOM_BORDER;
|
||||||
|
if (frame.left == owner->Bounds().left)
|
||||||
|
borders |= BControlLook::B_LEFT_BORDER;
|
||||||
|
if (frame.right == owner->Bounds().right)
|
||||||
|
borders |= BControlLook::B_RIGHT_BORDER;
|
||||||
|
|
||||||
|
if (position == B_TAB_FRONT) {
|
||||||
|
if(fTabOrientation == B_TAB_TOP)
|
||||||
|
{
|
||||||
|
frame.bottom += 1;
|
||||||
|
be_control_look->DrawActiveTab(owner, frame, frame, no_tint, 0, borders);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
frame.top -= 1;
|
||||||
|
fYabControlLook.DrawActiveTabBottom(owner, frame, frame, no_tint, 0, borders);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(fTabOrientation == B_TAB_TOP)
|
||||||
|
be_control_look->DrawInactiveTab(owner, frame, frame, no_tint, 0, borders);
|
||||||
|
else
|
||||||
|
fYabControlLook.DrawInactiveTabBottom(owner, frame, frame, no_tint, 0, borders);
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawLabel(current, frame);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::DrawFocusMark(BRect frame, int32 current)
|
||||||
|
{
|
||||||
|
float width = StringWidth(GetTabName(current));
|
||||||
|
|
||||||
|
SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
||||||
|
|
||||||
|
float offset = (fSelection == current) ? 3 : 2;
|
||||||
|
StrokeLine(BPoint((frame.left + frame.right - width) / 2.0,
|
||||||
|
frame.bottom - offset),
|
||||||
|
BPoint((frame.left + frame.right + width) / 2.0,
|
||||||
|
frame.bottom - offset));
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::DrawBox(BRect selTabRect)
|
||||||
|
{
|
||||||
|
BRect rect(Bounds());
|
||||||
|
if(fTabOrientation == B_TAB_TOP)
|
||||||
|
rect.top = selTabRect.bottom;
|
||||||
|
else
|
||||||
|
rect.bottom -= selTabRect.Height();
|
||||||
|
|
||||||
|
// BRegion clipping(Bounds());
|
||||||
|
// selTabRect.left += 2;
|
||||||
|
// selTabRect.right -= 2;
|
||||||
|
// clipping.Exclude(selTabRect);
|
||||||
|
// ConstrainClippingRegion(&clipping);
|
||||||
|
|
||||||
|
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
be_control_look->DrawGroupFrame(this, rect, rect, base);
|
||||||
|
|
||||||
|
// ConstrainClippingRegion(NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabTabView::SetOrientation(tab_orientation side)
|
||||||
|
{
|
||||||
|
if(fTabOrientation != side)
|
||||||
|
if(side == B_TAB_BOTTOM)
|
||||||
|
fContainerView->MoveTo(3.0, 3.0);
|
||||||
|
else
|
||||||
|
fContainerView->MoveTo(3.0, TabHeight());
|
||||||
|
fTabOrientation = side;
|
||||||
|
}
|
||||||
|
|
||||||
|
tab_orientation YabTabView::Orientation()
|
||||||
|
{
|
||||||
|
return fTabOrientation;
|
||||||
|
}
|
||||||
|
|
||||||
115
src/YabTabView.h
Normal file
115
src/YabTabView.h
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2001-2002, OpenBeOS
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
//
|
||||||
|
// File Name: YabTabView.h
|
||||||
|
// Author: Marc Flerackers (mflerackers@androme.be)
|
||||||
|
// Jan Bungeroth (jan@be-logos.org)
|
||||||
|
// Description: YabTabView provides the framework for containing and
|
||||||
|
// managing groups of BView objects.
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef YABTAB_VIEW_H
|
||||||
|
#define YABTAB_VIEW_H
|
||||||
|
|
||||||
|
// Standard Includes -----------------------------------------------------------
|
||||||
|
|
||||||
|
#include <View.h>
|
||||||
|
#include "YabControlLook.h"
|
||||||
|
|
||||||
|
// Local Defines ---------------------------------------------------------------
|
||||||
|
enum tab_position {
|
||||||
|
B_TAB_FIRST = 999,
|
||||||
|
B_TAB_FRONT,
|
||||||
|
B_TAB_ANY
|
||||||
|
};
|
||||||
|
|
||||||
|
enum tab_orientation {
|
||||||
|
B_TAB_TOP = 0,
|
||||||
|
B_TAB_BOTTOM
|
||||||
|
};
|
||||||
|
|
||||||
|
// YabTabView class ------------------------------------------------------------------
|
||||||
|
class YabTabView : public BView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YabTabView(BRect frame, const char *name,
|
||||||
|
button_width width = B_WIDTH_AS_USUAL,
|
||||||
|
uint32 resizingMode = B_FOLLOW_ALL,
|
||||||
|
uint32 flags = B_FULL_UPDATE_ON_RESIZE |
|
||||||
|
B_WILL_DRAW | B_NAVIGABLE_JUMP |
|
||||||
|
B_FRAME_EVENTS | B_NAVIGABLE);
|
||||||
|
~YabTabView();
|
||||||
|
|
||||||
|
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||||
|
virtual void MouseDown(BPoint point);
|
||||||
|
|
||||||
|
virtual void Select(int32 tab);
|
||||||
|
int32 Selection() const;
|
||||||
|
|
||||||
|
virtual void MakeFocus(bool focused = true);
|
||||||
|
virtual void SetFocusTab(int32 tab, bool focused);
|
||||||
|
int32 FocusTab() const;
|
||||||
|
|
||||||
|
virtual void Draw(BRect updateRect);
|
||||||
|
virtual BRect DrawTabs();
|
||||||
|
virtual void DrawBox(BRect selTabRect);
|
||||||
|
virtual BRect TabFrame(int32 tab_index) const;
|
||||||
|
virtual void DrawFocusMark(BRect frame, int32 current);
|
||||||
|
virtual void DrawLabel(int32 current, BRect frame);
|
||||||
|
virtual void DrawTab(BRect frame, int32 current, tab_position position, bool full);
|
||||||
|
virtual const char* GetTabName(int32 index) const;
|
||||||
|
|
||||||
|
virtual void AddTab(BView *target, const char* tabname);
|
||||||
|
virtual BView *RemoveTab(int32 tabIndex);
|
||||||
|
|
||||||
|
virtual BView *TabAt ( int32 tab_index );
|
||||||
|
virtual void SetTabWidth(button_width width);
|
||||||
|
button_width TabWidth() const;
|
||||||
|
|
||||||
|
void SetOrientation(tab_orientation side);
|
||||||
|
tab_orientation Orientation();
|
||||||
|
|
||||||
|
virtual void SetTabHeight(float height);
|
||||||
|
float TabHeight();
|
||||||
|
|
||||||
|
BView *ContainerView();
|
||||||
|
|
||||||
|
int32 CountTabs() const;
|
||||||
|
int32 FocusChanged;
|
||||||
|
int32 OldTabView;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BList *fTabList;
|
||||||
|
BList *fTabNames;
|
||||||
|
BView *fContainerView;
|
||||||
|
button_width fTabWidthSetting;
|
||||||
|
float fTabWidth;
|
||||||
|
float fTabHeight;
|
||||||
|
int32 fSelection;
|
||||||
|
int32 fInitialSelection;
|
||||||
|
int32 fFocus;
|
||||||
|
float fTabOffset;
|
||||||
|
tab_orientation fTabOrientation;
|
||||||
|
YabControlLook fYabControlLook;
|
||||||
|
};
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif
|
||||||
920
src/YabText.cpp
Normal file
920
src/YabText.cpp
Normal file
@@ -0,0 +1,920 @@
|
|||||||
|
#include <Input.h>
|
||||||
|
#include "YabText.h"
|
||||||
|
|
||||||
|
const uint32 YABTEXT_ANALYSE = 'YTan';
|
||||||
|
const uint32 YABTEXT_FILECHANGED = 'YTfc';
|
||||||
|
const uint32 YABTEXT_PARSE_LINE = 'YTpl';
|
||||||
|
const uint32 YABTEXT_UNDO_HIGHLIGHTING = 'YTuh';
|
||||||
|
|
||||||
|
const rgb_color Blue = {0,0,255,255};
|
||||||
|
const rgb_color Red = {255,0,0,255};
|
||||||
|
const rgb_color Grey = {185,185,185,255};
|
||||||
|
const rgb_color Green = {0,200,000,255};
|
||||||
|
const rgb_color Magenta = {200,0,255,255};
|
||||||
|
|
||||||
|
YabText::YabText(BRect frame, const char* name, BRect textRect, uint32 resizeMode, uint32 flags)
|
||||||
|
: BTextView(frame, name, textRect, resizeMode, flags)
|
||||||
|
{
|
||||||
|
isCaseSensitive = false;
|
||||||
|
hasChanged = false;
|
||||||
|
|
||||||
|
// Standard definitions
|
||||||
|
bgcolor.blue = bgcolor.red = bgcolor.green = bgcolor.alpha = 255; // background
|
||||||
|
textcolor.blue = textcolor.red = textcolor.green = 0; textcolor.alpha = 255;
|
||||||
|
|
||||||
|
generic_cmd_color = Blue;
|
||||||
|
format_cmd_color = Red;
|
||||||
|
special_cmd_color = Green;
|
||||||
|
comment_color = Grey;
|
||||||
|
punc_symbol_color = Magenta;
|
||||||
|
|
||||||
|
SetStylable(true);
|
||||||
|
// BFont myFont(be_fixed_font);
|
||||||
|
// myFontSize = 12;
|
||||||
|
// f = myFont;
|
||||||
|
// f.SetSize(myFontSize);
|
||||||
|
// SetFontAndColor(0,1,&f,B_FONT_ALL,&textcolor);
|
||||||
|
|
||||||
|
SearchOffset = 0;
|
||||||
|
SetDoesUndo(true);
|
||||||
|
|
||||||
|
hasAutoCompletion = true;
|
||||||
|
words = new BList(0);
|
||||||
|
number_of_letters = 3;
|
||||||
|
isJapanese = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
YabText::~YabText()
|
||||||
|
{
|
||||||
|
BString *anItem;
|
||||||
|
for ( int32 i = 0; (anItem = (BString*)words->ItemAt(i)); i++ )
|
||||||
|
delete anItem;
|
||||||
|
delete words;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::AddWord(BString *word)
|
||||||
|
{
|
||||||
|
words->AddItem((void*)word);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::HasAutoCompletion(bool flag)
|
||||||
|
{
|
||||||
|
hasAutoCompletion = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::SetAutoCompleteStart(int num)
|
||||||
|
{
|
||||||
|
number_of_letters = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::AddCommand(const char* command, int colorGroup)
|
||||||
|
{
|
||||||
|
switch(colorGroup)
|
||||||
|
{
|
||||||
|
case 0: generic_matches.push_back(command);
|
||||||
|
break;
|
||||||
|
case 1: green_matches.push_back(command);
|
||||||
|
break;
|
||||||
|
case 2: purple_matches.push_back(command);
|
||||||
|
break;
|
||||||
|
case 3: comment_matches.push_back(command);
|
||||||
|
break;
|
||||||
|
case 4: punctuation.push_back(command[0]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::SetColors(int id, int r, int g, int b)
|
||||||
|
{
|
||||||
|
switch(id)
|
||||||
|
{
|
||||||
|
case 0: generic_cmd_color.red = r;
|
||||||
|
generic_cmd_color.green = g;
|
||||||
|
generic_cmd_color.blue = b;
|
||||||
|
ParseAll(0,TextLength()-1,true);
|
||||||
|
break;
|
||||||
|
case 1: format_cmd_color.red = r;
|
||||||
|
format_cmd_color.green = g;
|
||||||
|
format_cmd_color.blue = b;
|
||||||
|
ParseAll(0,TextLength()-1,true);
|
||||||
|
break;
|
||||||
|
case 2: special_cmd_color.red = r;
|
||||||
|
special_cmd_color.green = g;
|
||||||
|
special_cmd_color.blue = b;
|
||||||
|
ParseAll(0,TextLength()-1,true);
|
||||||
|
break;
|
||||||
|
case 3: comment_color.red = r;
|
||||||
|
comment_color.green = g;
|
||||||
|
comment_color.blue = b;
|
||||||
|
ParseAll(0,TextLength()-1,true);
|
||||||
|
break;
|
||||||
|
case 4: punc_symbol_color.red = r;
|
||||||
|
punc_symbol_color.green = g;
|
||||||
|
punc_symbol_color.blue = b;
|
||||||
|
ParseAll(0,TextLength()-1,true);
|
||||||
|
break;
|
||||||
|
case 5: SetViewColor(r,g,b);
|
||||||
|
Invalidate();
|
||||||
|
break;
|
||||||
|
case 6: {
|
||||||
|
textcolor.red = r;
|
||||||
|
textcolor.green = g;
|
||||||
|
textcolor.blue = b;
|
||||||
|
BFont default_font;
|
||||||
|
GetFontAndColor(0, &default_font);
|
||||||
|
// BFont default_font(be_fixed_font);
|
||||||
|
// default_font.SetSize(myFontSize);
|
||||||
|
SetFontAndColor(0,TextLength()-1,&default_font,B_FONT_ALL,&textcolor);
|
||||||
|
ParseAll(0,TextLength()-1,true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::AttachedToWindow()
|
||||||
|
{
|
||||||
|
SetViewColor(bgcolor);
|
||||||
|
SetColorSpace(B_RGB32);
|
||||||
|
BTextView::AttachedToWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::Select(int32 start,int32 finish)
|
||||||
|
{
|
||||||
|
BTextView::Select(start,finish);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 YabText::CountPhysicalLines()
|
||||||
|
{
|
||||||
|
return BTextView::CountLines();
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::KeyDown(const char* bytes, int32 numBytes)
|
||||||
|
{
|
||||||
|
isAutoComplete = false;
|
||||||
|
bool shouldBeChanged = true;
|
||||||
|
bool passon = true;
|
||||||
|
switch(bytes[0])
|
||||||
|
{
|
||||||
|
case B_ENTER:
|
||||||
|
{
|
||||||
|
//update previous line on enter
|
||||||
|
BMessage msg(YABTEXT_PARSE_LINE);
|
||||||
|
int32 start,finish;
|
||||||
|
GetSelection(&start,&finish);
|
||||||
|
if(msg.AddInt32("start",start) == B_OK && msg.AddInt32("finish",finish) == B_OK)
|
||||||
|
{
|
||||||
|
BMessenger msgr(this);
|
||||||
|
msgr.SendMessage(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case B_LEFT_ARROW:
|
||||||
|
{
|
||||||
|
shouldBeChanged = false;
|
||||||
|
if(modifiers() & B_CONTROL_KEY)
|
||||||
|
{
|
||||||
|
passon = false;
|
||||||
|
int32 startoffset, endoffset;
|
||||||
|
GetSelection(&startoffset, &endoffset);
|
||||||
|
bool inloop = true;
|
||||||
|
while(inloop)
|
||||||
|
{
|
||||||
|
startoffset--;
|
||||||
|
if(startoffset < 0)
|
||||||
|
{
|
||||||
|
if(modifiers() & B_SHIFT_KEY)
|
||||||
|
Select(0,endoffset);
|
||||||
|
else
|
||||||
|
Select(0,0);
|
||||||
|
ScrollToSelection();
|
||||||
|
inloop = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char tmp = ByteAt(startoffset);
|
||||||
|
|
||||||
|
if(tmp == ' ' || tmp == ':' || tmp == '/' || tmp == '\n' || tmp == '.' || tmp == '(' || tmp == ')' || tmp == '"' || tmp == '\t' || tmp == '-' || tmp == '+' || tmp == '*' || tmp == '^' || tmp == ',' || tmp == ';' || tmp == '=' || tmp == '\r')
|
||||||
|
{
|
||||||
|
if(modifiers() & B_SHIFT_KEY)
|
||||||
|
Select(startoffset,endoffset);
|
||||||
|
else
|
||||||
|
Select(startoffset,startoffset);
|
||||||
|
ScrollToSelection();
|
||||||
|
inloop = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case B_RIGHT_ARROW:
|
||||||
|
{
|
||||||
|
shouldBeChanged = false;
|
||||||
|
int cur = CurrentLine();
|
||||||
|
if(modifiers() & B_CONTROL_KEY)
|
||||||
|
{
|
||||||
|
// passon = false;
|
||||||
|
int32 startoffset, endoffset;
|
||||||
|
GetSelection(&startoffset, &endoffset);
|
||||||
|
bool inloop = true;
|
||||||
|
while(inloop)
|
||||||
|
{
|
||||||
|
endoffset++;
|
||||||
|
if(endoffset > TextLength() )
|
||||||
|
{
|
||||||
|
if(modifiers() & B_SHIFT_KEY)
|
||||||
|
Select(startoffset,endoffset);
|
||||||
|
else
|
||||||
|
Select(endoffset, endoffset);
|
||||||
|
ScrollToSelection();
|
||||||
|
inloop = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char tmp = ByteAt(endoffset);
|
||||||
|
int a = LineAt(endoffset);
|
||||||
|
|
||||||
|
if(tmp == ' ' || tmp == ':' || tmp == '/' || tmp == '\n' || tmp == '.' || tmp == '(' || tmp == ')' || tmp == '"' || tmp == '\t' || tmp == '-' || tmp == '+' || tmp == '*' || tmp == '^' || tmp == ',' || tmp == ';' || tmp == '=' || tmp == '\r' || a!=cur)
|
||||||
|
{
|
||||||
|
if(a!=cur) endoffset --;
|
||||||
|
if(modifiers() & B_SHIFT_KEY)
|
||||||
|
Select(startoffset,endoffset);
|
||||||
|
else
|
||||||
|
Select(endoffset,endoffset);
|
||||||
|
ScrollToSelection();
|
||||||
|
inloop = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case B_UP_ARROW:
|
||||||
|
case B_DOWN_ARROW:
|
||||||
|
case B_PAGE_UP:
|
||||||
|
case B_PAGE_DOWN:
|
||||||
|
case B_HOME:
|
||||||
|
case B_END:
|
||||||
|
case B_INSERT:
|
||||||
|
case B_FUNCTION_KEY:
|
||||||
|
case B_ESCAPE:
|
||||||
|
shouldBeChanged = false;
|
||||||
|
break;
|
||||||
|
case B_BACKSPACE:
|
||||||
|
{
|
||||||
|
int32 a,b;
|
||||||
|
GetSelection(&a, &b);
|
||||||
|
if(a == b && a == 0) shouldBeChanged = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case B_DELETE:
|
||||||
|
{
|
||||||
|
int32 a,b;
|
||||||
|
GetSelection(&a, &b);
|
||||||
|
if(a == b && a == TextLength()) shouldBeChanged = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(shouldBeChanged && !hasChanged) hasChanged = true;
|
||||||
|
|
||||||
|
if(passon) BTextView::KeyDown(bytes,numBytes);
|
||||||
|
|
||||||
|
if(isAutoComplete)
|
||||||
|
{
|
||||||
|
Select(autoOffset, autoEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int YabText::FindFirstOnLine(char c,int offset,int eol)
|
||||||
|
{
|
||||||
|
for(int i=offset;i<eol;i++)
|
||||||
|
{
|
||||||
|
if(ByteAt(i) == c)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 YabText::OffsetAtIndex(int32 index) //const
|
||||||
|
{
|
||||||
|
//int text_length = TextLength();
|
||||||
|
int i;
|
||||||
|
//if(index <= 0)
|
||||||
|
// return 0;
|
||||||
|
int count = 0;
|
||||||
|
int last=0;
|
||||||
|
for(i=0;count < index;i++)
|
||||||
|
{
|
||||||
|
if(ByteAt(i) == '\n')
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
last = i+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 YabText::LineAt(int32 offset) //const
|
||||||
|
{
|
||||||
|
std::vector<int> sols;
|
||||||
|
std::vector<int> eols;
|
||||||
|
FillSolEol(sols,eols,0,TextLength()-1);
|
||||||
|
|
||||||
|
for(int i=0;i<sols.size();i++)
|
||||||
|
{
|
||||||
|
if(offset >= sols[i] && offset <= eols[i])
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::FillSolEol(std::vector<int>& s,std::vector<int>& e,int start,int finish)
|
||||||
|
{
|
||||||
|
int i=start;
|
||||||
|
int text_length = TextLength();
|
||||||
|
for(i=start;i>=0;i--)
|
||||||
|
{
|
||||||
|
if(ByteAt(i) == '\n')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
start=i+1;
|
||||||
|
|
||||||
|
i = finish;
|
||||||
|
for(i=finish;i<text_length;i++)
|
||||||
|
{
|
||||||
|
if(ByteAt(i) == '\n')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finish=i;
|
||||||
|
|
||||||
|
for(i=start;i<=finish;i++)
|
||||||
|
{
|
||||||
|
if(ByteAt(i) == '\n')
|
||||||
|
{
|
||||||
|
e.push_back(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
e.push_back(i);
|
||||||
|
|
||||||
|
s.push_back(start);
|
||||||
|
for(i=0;i<e.size()-1;i++)
|
||||||
|
{
|
||||||
|
s.push_back(e[i]+1);
|
||||||
|
}
|
||||||
|
//s.push_back(e[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void YabText::GoToLine(int32 index)
|
||||||
|
{
|
||||||
|
if(TextLength()<=0)
|
||||||
|
return;
|
||||||
|
if(index<=0) index = 0;
|
||||||
|
if(index > CountLines()) index = CountLines();
|
||||||
|
|
||||||
|
// if(index < 0 || index > CountLines() || TextLength() <= 0)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
std::vector<int> eols;
|
||||||
|
std::vector<int> sols;
|
||||||
|
|
||||||
|
FillSolEol(sols,eols,0,TextLength()-1);
|
||||||
|
Select(sols[index],eols[index]);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
int32 YabText::CountLines()
|
||||||
|
{
|
||||||
|
std::vector<int> eols;
|
||||||
|
std::vector<int> sols;
|
||||||
|
FillSolEol(sols,eols,0,TextLength()-1);
|
||||||
|
return eols.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::ParseAll(int start,int finish,bool IsInteractive)
|
||||||
|
{
|
||||||
|
// BFont font(be_fixed_font);
|
||||||
|
// font.SetSize(myFontSize);
|
||||||
|
BFont default_font;
|
||||||
|
GetFontAndColor(0, &default_font);
|
||||||
|
|
||||||
|
int text_length = TextLength();
|
||||||
|
if(text_length > 0)
|
||||||
|
{
|
||||||
|
std::vector<int> eols;
|
||||||
|
std::vector<int> sols;
|
||||||
|
FillSolEol(sols,eols,start,finish);
|
||||||
|
|
||||||
|
int i;
|
||||||
|
int size;
|
||||||
|
/*
|
||||||
|
if(!IsInteractive)
|
||||||
|
{
|
||||||
|
size = text_length;
|
||||||
|
std::vector<rgb_color> colorVec(size,textcolor);
|
||||||
|
|
||||||
|
for(i=0;i<sols.size();i++)
|
||||||
|
{
|
||||||
|
ParseLine(sols[i],eols[i],colorVec);
|
||||||
|
}
|
||||||
|
|
||||||
|
int offset_size=1;
|
||||||
|
std::vector<int> offsets;
|
||||||
|
offsets.push_back(0);
|
||||||
|
|
||||||
|
for(i=1;i<size;i++)
|
||||||
|
{
|
||||||
|
if(colorVec[i-1].blue != colorVec[i].blue ||
|
||||||
|
colorVec[i-1].green != colorVec[i].green ||
|
||||||
|
colorVec[i-1].red != colorVec[i].red)
|
||||||
|
{
|
||||||
|
offsets.push_back(i);
|
||||||
|
offset_size++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
text_run_array* tra = (text_run_array*)malloc(sizeof(text_run_array)*(size));
|
||||||
|
tra->count = offset_size;
|
||||||
|
for(i=0;i<offset_size;i++)
|
||||||
|
{
|
||||||
|
tra->runs[i].color=colorVec[offsets[i]];
|
||||||
|
tra->runs[i].font=font;
|
||||||
|
tra->runs[i].offset=offsets[i];
|
||||||
|
}
|
||||||
|
SetRunArray(0,text_length-1,tra);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{*/
|
||||||
|
for(i=0;i<sols.size();i++)
|
||||||
|
{
|
||||||
|
IParseLine(sols[i],eols[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::IParseLine(int sol,int eol)
|
||||||
|
{
|
||||||
|
int size = eol-sol+1;
|
||||||
|
std::vector<rgb_color> colorVec(size,textcolor);
|
||||||
|
|
||||||
|
for(int k=0;k<size;k++)
|
||||||
|
colorVec[k] = textcolor;
|
||||||
|
|
||||||
|
int i,j;
|
||||||
|
int pos;
|
||||||
|
int text_length = TextLength();
|
||||||
|
|
||||||
|
// punctuation first
|
||||||
|
for(i=sol;i<eol;i++)
|
||||||
|
{
|
||||||
|
for(int j=0; j<punctuation.size(); j++)
|
||||||
|
if(ByteAt(i) == punctuation[j])
|
||||||
|
colorVec[i-sol] = punc_symbol_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
// words second
|
||||||
|
ICheckWordLists(sol,eol,colorVec);
|
||||||
|
|
||||||
|
/*
|
||||||
|
for(i=sol;i<eol;i++)
|
||||||
|
{
|
||||||
|
BString word("");
|
||||||
|
for(j=i; j<eol; j++)
|
||||||
|
word << (char)ByteAt(j);
|
||||||
|
if(isIgnoring)
|
||||||
|
{
|
||||||
|
for(int k=i;k<j;k++)
|
||||||
|
colorVec[k-sol] = comment_color;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("%s\n", word.String());
|
||||||
|
if(Contains(comment_matches,word))
|
||||||
|
{
|
||||||
|
printf("\t%s\n", word.String());
|
||||||
|
isIgnoring = true;
|
||||||
|
for(int k=i;k<j;k++)
|
||||||
|
colorVec[k-sol] = comment_color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
if(FindFirstOnLine('#',sol,eol) == 0)
|
||||||
|
for(i=0;i<eol;i++)
|
||||||
|
colorVec[i-sol] = comment_color;
|
||||||
|
*/
|
||||||
|
|
||||||
|
//START COLOURING***********************************
|
||||||
|
|
||||||
|
// BFont default_font(be_fixed_font);
|
||||||
|
// default_font.SetSize(myFontSize);
|
||||||
|
|
||||||
|
BFont default_font;
|
||||||
|
GetFontAndColor(0, &default_font);
|
||||||
|
|
||||||
|
// INS HERE
|
||||||
|
|
||||||
|
int plLength=0;
|
||||||
|
int plStart=0;
|
||||||
|
for(i=sol;i<eol;i++)
|
||||||
|
{
|
||||||
|
if(i == sol)
|
||||||
|
{
|
||||||
|
plLength = 1;
|
||||||
|
plStart = i;
|
||||||
|
}
|
||||||
|
else if(colorVec[i-sol-1].blue != colorVec[i-sol].blue ||
|
||||||
|
colorVec[i-sol-1].green != colorVec[i-sol].green ||
|
||||||
|
colorVec[i-sol-1].red != colorVec[i-sol].red)
|
||||||
|
{
|
||||||
|
if(!isJapanese) SetFontAndColor(plStart,plStart+plLength,&default_font,B_FONT_ALL,&colorVec[i-sol-1]);
|
||||||
|
plLength = 1;
|
||||||
|
plStart = i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plLength++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(plLength > 0)
|
||||||
|
if(!isJapanese) SetFontAndColor(plStart,plStart+plLength,&default_font,B_FONT_ALL,&colorVec[i-sol-1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::ParseLine(int sol,int eol,std::vector<rgb_color>& colorVec)//,std::vector<rgb_color>& colorVec)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int offset = sol;
|
||||||
|
int pos;
|
||||||
|
int text_length = TextLength();
|
||||||
|
//assert(sol >=0 && eol >=0 && sol < text_length && eol < text_length);
|
||||||
|
//Setup some defaults....
|
||||||
|
/*
|
||||||
|
TwoColorPlateau('\'',sol,eol,comment_color,colorVec);//,displaced);//-displaced
|
||||||
|
TwoColorPlateau('`',sol,eol,comment_color,colorVec);//,displaced);
|
||||||
|
TwoColorPlateau('\\',sol,eol,comment_color,colorVec);//,displaced);*/
|
||||||
|
|
||||||
|
for(i=sol;i<eol;i++)
|
||||||
|
{
|
||||||
|
if(ByteAt(i) == '[' || ByteAt(i) == ']')
|
||||||
|
{
|
||||||
|
if(i-1 >= 0 && ByteAt(i-1) == '\\')
|
||||||
|
{
|
||||||
|
colorVec[i-1] = punc_symbol_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
colorVec[i] = punc_symbol_color;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(ByteAt(i) == '&' || ByteAt(i) == '{' || ByteAt(i) == '}')//
|
||||||
|
{
|
||||||
|
if(i-1 >= 0 && ByteAt(i-1) == '\\')
|
||||||
|
{
|
||||||
|
colorVec[i-1] = punc_symbol_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
colorVec[i] = punc_symbol_color;
|
||||||
|
|
||||||
|
}
|
||||||
|
else if(ByteAt(i) == '$')
|
||||||
|
{
|
||||||
|
if(i-1 >= 0 && ByteAt(i-1) == '\\')
|
||||||
|
{
|
||||||
|
colorVec[i-1] = textcolor;
|
||||||
|
colorVec[i] = textcolor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(ByteAt(i) == '\\' && i+1 < eol)
|
||||||
|
{
|
||||||
|
if(ByteAt(i+1) == '#')
|
||||||
|
{
|
||||||
|
colorVec[i] = punc_symbol_color;
|
||||||
|
colorVec[i+1] = punc_symbol_color;
|
||||||
|
}else if(ByteAt(i+1) == '\'' || ByteAt(i+1) == '`')
|
||||||
|
{
|
||||||
|
colorVec[i] = textcolor;
|
||||||
|
colorVec[i+1] = textcolor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*if(toupper((char)ByteAt(i)) == 'B')
|
||||||
|
{
|
||||||
|
if(i+3 < eol && toupper((char)ByteAt(i+1)) == 'E' &&
|
||||||
|
toupper((char)ByteAt(i+2)) == 'O' && toupper((char)ByteAt(i+3)) == 'S')
|
||||||
|
{
|
||||||
|
colorVec[i] = Blue;
|
||||||
|
colorVec[i+1] = Red;
|
||||||
|
}
|
||||||
|
else if(i+4 < eol && toupper((char)ByteAt(i+1)) == 'E' &&
|
||||||
|
toupper((char)ByteAt(i+2)) == 'T' && toupper((char)ByteAt(i+3)) == 'E'
|
||||||
|
&& toupper((char)ByteAt(i+3)) == 'X')
|
||||||
|
{
|
||||||
|
colorVec[i] = Blue;
|
||||||
|
colorVec[i+1] = Red;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
offset = sol;
|
||||||
|
while((pos = FindFirstOnLine('%',offset,eol))>= 0 && offset < eol)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(pos - 1 >= 0 && ByteAt(pos-1) == '\\')
|
||||||
|
{
|
||||||
|
colorVec[pos-1] = punc_symbol_color;
|
||||||
|
colorVec[pos] = punc_symbol_color;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(i=pos;i<eol;i++)
|
||||||
|
colorVec[i] = comment_color;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
offset= pos+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::ICheckWordLists(int sol,int eol,std::vector<rgb_color>& colorVec)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for(i=sol;i<eol;i++)
|
||||||
|
{
|
||||||
|
BString match="";
|
||||||
|
|
||||||
|
int j=i;
|
||||||
|
for(j=i;j < eol;j++)
|
||||||
|
{
|
||||||
|
if(isalpha(ByteAt(j)) || (char)ByteAt(j) == ':' || (char)ByteAt(j) == '$' || ((char)ByteAt(j)>='0' && (char)ByteAt(j)<='9'))
|
||||||
|
// if(ByteAt(j)>32)
|
||||||
|
{
|
||||||
|
match << (char)ByteAt(j);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if((match.Length() > 0) && (i==sol || !isalpha(ByteAt(i-1))))
|
||||||
|
{
|
||||||
|
if(Contains(green_matches,match))
|
||||||
|
{
|
||||||
|
for(int k=i;k<j;k++)
|
||||||
|
colorVec[k-sol] = format_cmd_color;
|
||||||
|
}
|
||||||
|
else if(Contains(purple_matches,match))
|
||||||
|
{
|
||||||
|
for(int k=i;k<j;k++)
|
||||||
|
colorVec[k-sol] = special_cmd_color;
|
||||||
|
}
|
||||||
|
else if(Contains(generic_matches,match))
|
||||||
|
{
|
||||||
|
for(int k=i;k<j;k++)
|
||||||
|
colorVec[k-sol] = generic_cmd_color;
|
||||||
|
}
|
||||||
|
else if(Contains(comment_matches,match))
|
||||||
|
{
|
||||||
|
for(int k=i;k<j;k++)
|
||||||
|
colorVec[k-sol] = comment_color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::InsertText(const char* text,int32 length,int32 offset,const text_run_array* runner)
|
||||||
|
{
|
||||||
|
hasChanged = true;
|
||||||
|
BString replace = text;
|
||||||
|
if(length == 1 && hasAutoCompletion)
|
||||||
|
{
|
||||||
|
BString itext(""); //Text();
|
||||||
|
// BString lastWord = "";
|
||||||
|
int32 myOffset = offset - 1;
|
||||||
|
while(myOffset>=0)
|
||||||
|
{
|
||||||
|
if(ByteAt(myOffset) == ' ' || ByteAt(myOffset) == '\n' || ByteAt(myOffset) == '\t')
|
||||||
|
break;
|
||||||
|
myOffset --;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(offset-myOffset>number_of_letters)
|
||||||
|
{
|
||||||
|
for(int i=myOffset+1; i<offset; i++)
|
||||||
|
itext << (char)ByteAt(i);
|
||||||
|
|
||||||
|
itext << text;
|
||||||
|
|
||||||
|
BString *anItem;
|
||||||
|
for ( int32 i = 0; (anItem = (BString*)words->ItemAt(i)); i++ )
|
||||||
|
{
|
||||||
|
if(anItem->Compare(itext, offset-myOffset+length-1) == 0)
|
||||||
|
{
|
||||||
|
autoOffset = offset + 1;
|
||||||
|
isAutoComplete = true;
|
||||||
|
BString sleepy(anItem->String());
|
||||||
|
sleepy.CopyInto(replace, offset-myOffset-1, anItem->Length());
|
||||||
|
length = replace.Length();
|
||||||
|
autoEnd = anItem->Length()+myOffset+1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BTextView::InsertText(replace.String(),length,offset,NULL);
|
||||||
|
|
||||||
|
if(text[0] != B_ENTER)
|
||||||
|
{
|
||||||
|
BMessage msg(YABTEXT_ANALYSE);
|
||||||
|
if(msg.AddInt32("offset",offset)==B_OK && msg.AddInt32("length",length)==B_OK)
|
||||||
|
//&& msg.AddString("text",text) == B_OK)
|
||||||
|
{
|
||||||
|
BMessenger msgr(this);
|
||||||
|
msgr.SendMessage(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::DeleteText(int32 start, int32 finish)
|
||||||
|
{
|
||||||
|
BMessage msg(YABTEXT_ANALYSE);
|
||||||
|
if(msg.AddInt32("start",start)==B_OK && msg.AddInt32("finish",finish)==B_OK)
|
||||||
|
{
|
||||||
|
BMessenger msgr(this);
|
||||||
|
msgr.SendMessage(&msg);
|
||||||
|
}
|
||||||
|
BTextView::DeleteText(start,finish);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::SetText(const char* text,int32 length,const text_run_array* runs )
|
||||||
|
{
|
||||||
|
hasChanged = true;
|
||||||
|
BTextView::SetText(text,length,runs);
|
||||||
|
// ParseAll(0,length-1,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::UpdateColors()
|
||||||
|
{
|
||||||
|
SetFontAndColor(0,TextLength(),&f,B_FONT_ALL,&textcolor);
|
||||||
|
ParseAll(0,TextLength()-1,true);
|
||||||
|
//const char* text = Text();
|
||||||
|
//Delete(0,TextLength()-1);
|
||||||
|
//SetText(text,strlen(text));//,TextLength()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::UpdateFontSize()
|
||||||
|
{
|
||||||
|
f.SetSize(myFontSize);
|
||||||
|
SetFontAndColor(0,TextLength(),&f,B_FONT_ALL,&textcolor);
|
||||||
|
ParseAll(0,TextLength()-1,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::SetText(BFile* file,int32 offset,int32 length,const text_run_array* runs )
|
||||||
|
{
|
||||||
|
hasChanged = true;
|
||||||
|
BTextView::SetText(file,offset,length,runs);
|
||||||
|
// ParseAll(offset,length-1,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YabText::Contains(std::vector<BString>& v,BString s)
|
||||||
|
{
|
||||||
|
for(int i=0;i<v.size();i++)
|
||||||
|
{
|
||||||
|
if(isCaseSensitive)
|
||||||
|
{
|
||||||
|
if(v[i].Compare(s) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(v[i].ICompare(s) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
bool YabText::CanEndLine(int32 offset)
|
||||||
|
{
|
||||||
|
if(ByteAt(offset) == B_ENTER || )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void YabText::MessageReceived(BMessage* msg)
|
||||||
|
{
|
||||||
|
switch(msg->what)
|
||||||
|
{
|
||||||
|
case B_INPUT_METHOD_EVENT:
|
||||||
|
{
|
||||||
|
int32 be_op;
|
||||||
|
if(msg->FindInt32("be:opcode", &be_op) == B_OK)
|
||||||
|
{
|
||||||
|
if(be_op == B_INPUT_METHOD_STARTED) isJapanese = true;
|
||||||
|
if(be_op == B_INPUT_METHOD_STOPPED) isJapanese = false;
|
||||||
|
}
|
||||||
|
BTextView::MessageReceived(msg);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABTEXT_UNDO_HIGHLIGHTING:
|
||||||
|
{
|
||||||
|
int32 start,finish;
|
||||||
|
if(msg->FindInt32("start",&start)==B_OK && msg->FindInt32("finish",&finish)==B_OK)
|
||||||
|
{
|
||||||
|
Select(start,finish);
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case YABTEXT_PARSE_LINE:
|
||||||
|
{
|
||||||
|
int32 start,finish;
|
||||||
|
if(msg->FindInt32("start",&start)==B_OK && msg->FindInt32("finish",&finish)==B_OK)
|
||||||
|
{
|
||||||
|
int32 sel_start,sel_finish;
|
||||||
|
GetSelection(&sel_start,&sel_finish);
|
||||||
|
ParseAll(min(sel_start,start),max(sel_finish,finish),true);
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case YABTEXT_ANALYSE:
|
||||||
|
{
|
||||||
|
int32 start,finish;
|
||||||
|
if(msg->FindInt32("start",&start)==B_OK && msg->FindInt32("finish",&finish)==B_OK)
|
||||||
|
{
|
||||||
|
ParseAll(start,finish,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 offset,length;
|
||||||
|
if(msg->FindInt32("offset",&offset)==B_OK
|
||||||
|
&& msg->FindInt32("length",&length)==B_OK)
|
||||||
|
{
|
||||||
|
GetSelection(&start,&finish);
|
||||||
|
ParseAll(offset,finish,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}break;
|
||||||
|
/*
|
||||||
|
case B_CUT:
|
||||||
|
case B_COPY:
|
||||||
|
case B_PASTE:
|
||||||
|
{
|
||||||
|
BMessage msg(UPDATE_CLIPBOARD_MENU_STATUS);
|
||||||
|
BMessenger msgr(Window());
|
||||||
|
msgr.SendMessage(&msg);
|
||||||
|
}*/
|
||||||
|
default:
|
||||||
|
BTextView::MessageReceived(msg);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void YabText::LoadFile (entry_ref *ref)
|
||||||
|
{
|
||||||
|
if (ref == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BFile file(ref, B_READ_ONLY);
|
||||||
|
if (file.InitCheck() != B_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
off_t length;
|
||||||
|
file.GetSize(&length);
|
||||||
|
if (length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetText (&file, 0, length);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
bool YabText::HasChanged()
|
||||||
|
{
|
||||||
|
return hasChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::SetChanged(bool changed)
|
||||||
|
{
|
||||||
|
hasChanged = changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YabText::IsCaseSensitive()
|
||||||
|
{
|
||||||
|
return isCaseSensitive;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabText::SetCaseSensitive(bool caseSensitive)
|
||||||
|
{
|
||||||
|
isCaseSensitive = caseSensitive;
|
||||||
|
}
|
||||||
90
src/YabText.h
Normal file
90
src/YabText.h
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
#ifndef YABTEXT_H
|
||||||
|
#define YABTEXT_H
|
||||||
|
|
||||||
|
#include <TextView.h>
|
||||||
|
#include <Font.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <Window.h>
|
||||||
|
#include <Message.h>
|
||||||
|
#include <Messenger.h>
|
||||||
|
|
||||||
|
class YabText : public BTextView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YabText(BRect frame, const char* name, BRect textRect, uint32 resizeMode, uint32 flags);
|
||||||
|
~YabText();
|
||||||
|
void AddCommand(const char* command, int colorGroup);
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void Select(int32 start,int32 finish);
|
||||||
|
void SetColors(int, int, int, int);
|
||||||
|
int32 CountPhysicalLines(); //?
|
||||||
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
|
int FindFirstOnLine(char c,int offset,int eol);
|
||||||
|
int32 OffsetAtIndex(int32 index);// const;
|
||||||
|
int32 LineAt(int32 offset);// const;
|
||||||
|
void FillSolEol(std::vector<int>& s,std::vector<int>& e,int start,int finish);
|
||||||
|
// void GoToLine(int32 index);
|
||||||
|
int32 CountLines();
|
||||||
|
void ParseAll(int start,int finish,bool IsInteractive);
|
||||||
|
void IParseLine(int sol,int eol); // TODO!
|
||||||
|
void ParseLine(int sol,int eol,std::vector<rgb_color>& colorVec); // TODO!
|
||||||
|
void ICheckWordLists(int sol,int eol,std::vector<rgb_color>& colorVec);
|
||||||
|
void SetText(const char* text,int32 length,const text_run_array* runs = NULL);
|
||||||
|
void UpdateColors();
|
||||||
|
void UpdateFontSize();
|
||||||
|
void SetText(BFile* file,int32 offset,int32 length,const text_run_array* runs = NULL);
|
||||||
|
bool Contains(std::vector<BString>& v,BString s);
|
||||||
|
// virtual bool CanEndLine(int32 offset);
|
||||||
|
// void LoadFile(entry_ref *ref);
|
||||||
|
virtual void MessageReceived(BMessage* msg);
|
||||||
|
|
||||||
|
bool HasChanged();
|
||||||
|
void SetChanged(bool changed);
|
||||||
|
bool IsCaseSensitive();
|
||||||
|
void SetCaseSensitive(bool caseSensitive);
|
||||||
|
|
||||||
|
void SetNormalFocus();
|
||||||
|
void SetAttachedFocus();
|
||||||
|
|
||||||
|
void AddWord(BString *word);
|
||||||
|
void SetAutoCompleteStart(int num);
|
||||||
|
void HasAutoCompletion(bool flag);
|
||||||
|
|
||||||
|
int SearchOffset;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isCaseSensitive, hasChanged, isJapanese;
|
||||||
|
int myFontSize;
|
||||||
|
rgb_color bgcolor;
|
||||||
|
rgb_color textcolor, punc_symbol_color, comment_color, ignore_color;
|
||||||
|
rgb_color format_cmd_color, special_cmd_color, generic_cmd_color;
|
||||||
|
BFont f;
|
||||||
|
|
||||||
|
std::vector <BString> green_matches;
|
||||||
|
std::vector <BString> purple_matches;
|
||||||
|
std::vector <BString> generic_matches;
|
||||||
|
std::vector <BString> comment_matches;
|
||||||
|
std::vector <char> punctuation;
|
||||||
|
|
||||||
|
BList *words;
|
||||||
|
bool hasAutoCompletion, isAutoComplete;
|
||||||
|
int32 autoOffset, autoEnd;
|
||||||
|
int number_of_letters;
|
||||||
|
|
||||||
|
bool min(int32 a, int32 b)
|
||||||
|
{
|
||||||
|
return (a<=b?a:b);
|
||||||
|
};
|
||||||
|
bool max(int32 a, int32 b)
|
||||||
|
{
|
||||||
|
return (a>=b?a:b);
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void InsertText(const char* text,int32 length,int32 offset,const text_run_array* runner);
|
||||||
|
virtual void DeleteText(int32 start, int32 finish);
|
||||||
|
};
|
||||||
|
#endif
|
||||||
138
src/YabToolTip.cpp
Normal file
138
src/YabToolTip.cpp
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// #include <MessageRunner.h>
|
||||||
|
#include <StringView.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
#include "ToolTip.h"
|
||||||
|
|
||||||
|
class MouseToolTip : public BToolTip {
|
||||||
|
public:
|
||||||
|
MouseToolTip()
|
||||||
|
{
|
||||||
|
fView = new MouseView();
|
||||||
|
SetSticky(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~MouseToolTip()
|
||||||
|
{
|
||||||
|
delete fView;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual BView* View() const
|
||||||
|
{
|
||||||
|
return fView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
BStringView* fView;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ImmediateView : public BStringView {
|
||||||
|
public:
|
||||||
|
ImmediateView(const char* name, const char* label)
|
||||||
|
:
|
||||||
|
BStringView(name, label)
|
||||||
|
{
|
||||||
|
SetToolTip("Easy but immediate!");
|
||||||
|
ToolTip()->SetSticky(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void MouseMoved(BPoint where, uint32 transit,
|
||||||
|
const BMessage* dragMessage)
|
||||||
|
{
|
||||||
|
if (transit == B_ENTERED_VIEW)
|
||||||
|
ShowToolTip(ToolTip());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Window : public BWindow {
|
||||||
|
public:
|
||||||
|
Window();
|
||||||
|
|
||||||
|
virtual bool QuitRequested();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Application : public BApplication {
|
||||||
|
public:
|
||||||
|
Application();
|
||||||
|
|
||||||
|
virtual void ReadyToRun();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
Window::Window()
|
||||||
|
:
|
||||||
|
BWindow(BRect(100, 100, 520, 430), "ToolTip-Test",
|
||||||
|
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
|
||||||
|
{
|
||||||
|
BView* simple = new BStringView("1", "Simple Tool Tip");
|
||||||
|
simple->SetToolTip("This is a really\nsimple tool tip!");
|
||||||
|
|
||||||
|
BView* custom = new BStringView("2", "Custom Tool Tip");
|
||||||
|
custom->SetToolTip(new CustomToolTip());
|
||||||
|
|
||||||
|
BView* changing = new BStringView("3", "Changing Tool Tip");
|
||||||
|
changing->SetToolTip(new ChangingToolTip());
|
||||||
|
|
||||||
|
BView* mouse = new BStringView("3", "Mouse Tool Tip (sticky)");
|
||||||
|
mouse->SetToolTip(new MouseToolTip());
|
||||||
|
|
||||||
|
BView* immediate = new ImmediateView("3", "Immediate Tool Tip (sticky)");
|
||||||
|
|
||||||
|
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||||
|
.Add(simple)
|
||||||
|
.Add(custom)
|
||||||
|
.Add(changing)
|
||||||
|
.Add(mouse)
|
||||||
|
.Add(immediate);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
Window::QuitRequested()
|
||||||
|
{
|
||||||
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
Application::Application()
|
||||||
|
: BApplication("application/x-vnd.haiku-tooltiptest")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Application::ReadyToRun()
|
||||||
|
{
|
||||||
|
BWindow *window = new Window();
|
||||||
|
window->Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
Application app;
|
||||||
|
|
||||||
|
app.Run();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
335
src/YabView.cpp
Normal file
335
src/YabView.cpp
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
#include <Bitmap.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <Picture.h>
|
||||||
|
#include <Region.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include "YabWindow.h"
|
||||||
|
#include "YabView.h"
|
||||||
|
|
||||||
|
YabView::YabView(BRect frame, const char *name, uint32 resizingMode, uint32 flags)
|
||||||
|
: BView(frame, name, resizingMode, flags)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
SetViewColor(216,216,216,255);
|
||||||
|
SetLowColor(216,216,216,255);
|
||||||
|
SetHighColor(0,0,0,255);
|
||||||
|
*/
|
||||||
|
|
||||||
|
rgb_color b1 = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
|
rgb_color b2 = {0,0,0,255};
|
||||||
|
|
||||||
|
SetViewColor(b1);
|
||||||
|
SetLowColor(b1);
|
||||||
|
SetHighColor(b2);
|
||||||
|
|
||||||
|
drawList = new BList(1);
|
||||||
|
|
||||||
|
YabDrawing *t = new YabDrawing();
|
||||||
|
t->command = 6;
|
||||||
|
t->r = 0; t->g = 0;
|
||||||
|
t->b = 0; t->alpha = 255;
|
||||||
|
drawList->AddItem(t);
|
||||||
|
|
||||||
|
YabDrawing *t2 = new YabDrawing();
|
||||||
|
t2->command = 7;
|
||||||
|
t2->r = b1.red; t2->g = b1.green;
|
||||||
|
t2->b = b1.blue; t2->alpha = 255;
|
||||||
|
drawList->AddItem(t2);
|
||||||
|
|
||||||
|
mouseMovedInfo = 1;
|
||||||
|
mouseStateInfo = -1;
|
||||||
|
prevMouseStateInfo = 0;
|
||||||
|
|
||||||
|
mouseX = 0;
|
||||||
|
mouseY = 0;
|
||||||
|
mouseLButton = 0;
|
||||||
|
mouseMButton = 0;
|
||||||
|
mouseRButton = 0;
|
||||||
|
dropZone = false;
|
||||||
|
pressedKeys.SetTo("");
|
||||||
|
SetDrawingMode(B_OP_COPY);
|
||||||
|
}
|
||||||
|
|
||||||
|
YabView::~YabView()
|
||||||
|
{
|
||||||
|
while(drawList->CountItems()>0)
|
||||||
|
{
|
||||||
|
YabDrawing *t = (YabDrawing*)drawList->LastItem();
|
||||||
|
drawList->RemoveItem(t);
|
||||||
|
if(t->command == 0) delete [] t->chardata;
|
||||||
|
delete t;
|
||||||
|
}
|
||||||
|
delete drawList;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabView::MessageReceived(BMessage *msg)
|
||||||
|
{
|
||||||
|
entry_ref ref;
|
||||||
|
switch (msg->what)
|
||||||
|
{
|
||||||
|
case B_SIMPLE_DATA:
|
||||||
|
{
|
||||||
|
if(dropZone)
|
||||||
|
{
|
||||||
|
BString tmp("");
|
||||||
|
int32 count;
|
||||||
|
uint32 type;
|
||||||
|
const char* name;
|
||||||
|
int i =0;
|
||||||
|
|
||||||
|
while(msg->FindRef("refs", i, &ref) == B_OK)
|
||||||
|
{
|
||||||
|
BEntry dropEntry(&ref);
|
||||||
|
BPath tmpDirectory;
|
||||||
|
dropEntry.GetPath(&tmpDirectory);
|
||||||
|
tmp << Name();
|
||||||
|
tmp << ":_Dropped";
|
||||||
|
tmp << ":" << tmpDirectory.Path();
|
||||||
|
tmp << "|";
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
YabWindow *yabWin = (YabWindow*)Window();
|
||||||
|
yabWin->dropMsg.SetTo(tmp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
BView::MessageReceived(msg);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BView::MessageReceived(msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabView::Draw(BRect updateRect)
|
||||||
|
{
|
||||||
|
SetFont(be_plain_font);
|
||||||
|
updateRect = Bounds();
|
||||||
|
for(int i=0; i<drawList->CountItems(); i++)
|
||||||
|
{
|
||||||
|
YabDrawing *e = (YabDrawing*)drawList->ItemAt(i);
|
||||||
|
switch(e->command)
|
||||||
|
{
|
||||||
|
case 0: DrawString(e->chardata, BPoint(e->x1, e->y1));
|
||||||
|
break;
|
||||||
|
case 1: StrokeLine(BPoint(e->x1,e->y1),BPoint(e->x2,e->y2), e->p);
|
||||||
|
break;
|
||||||
|
case 2: StrokeEllipse(BPoint(e->x1,e->y1), e->x2, e->y2, e->p);
|
||||||
|
break;
|
||||||
|
case 3: FillEllipse(BPoint(e->x1,e->y1), e->x2, e->y2, e->p);
|
||||||
|
break;
|
||||||
|
case 4: StrokeRect(BRect(e->x1,e->y1,e->x2,e->y2), e->p);
|
||||||
|
break;
|
||||||
|
case 5: FillRect(BRect(e->x1,e->y1,e->x2,e->y2), e->p);
|
||||||
|
break;
|
||||||
|
case 6: {
|
||||||
|
if(e->alpha == 255)
|
||||||
|
SetDrawingMode(B_OP_COPY);
|
||||||
|
else
|
||||||
|
SetDrawingMode(B_OP_ALPHA);
|
||||||
|
SetHighColor(e->r,e->g,e->b,e->alpha);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 7: {
|
||||||
|
if(e->alpha == 255)
|
||||||
|
SetDrawingMode(B_OP_COPY);
|
||||||
|
else
|
||||||
|
SetDrawingMode(B_OP_ALPHA);
|
||||||
|
SetLowColor(e->r,e->g,e->b,e->alpha);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 8: {
|
||||||
|
BPoint p[4];
|
||||||
|
p[0].Set(e->x1,e->y1);
|
||||||
|
p[1].Set(e->x2,e->y2);
|
||||||
|
p[2].Set(e->x3,e->y3);
|
||||||
|
p[3].Set(e->x4,e->y4);
|
||||||
|
SetPenSize(1.01);
|
||||||
|
StrokeBezier(p, e->p);
|
||||||
|
SetPenSize(1.0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 9: {
|
||||||
|
BPoint p[4];
|
||||||
|
p[0].Set(e->x1,e->y1);
|
||||||
|
p[1].Set(e->x2,e->y2);
|
||||||
|
p[2].Set(e->x3,e->y3);
|
||||||
|
p[3].Set(e->x4,e->y4);
|
||||||
|
SetPenSize(2.0);
|
||||||
|
FillBezier(p, e->p);
|
||||||
|
SetPenSize(1.0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 10: {
|
||||||
|
drawing_mode mode = DrawingMode();
|
||||||
|
if(IsPrinting())
|
||||||
|
SetDrawingMode(B_OP_COPY);
|
||||||
|
else
|
||||||
|
SetDrawingMode(B_OP_ALPHA);
|
||||||
|
DrawBitmap(e->bitmap, BPoint(e->x1, e->y1));
|
||||||
|
SetDrawingMode(mode);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 11: {
|
||||||
|
drawing_mode mode = DrawingMode();
|
||||||
|
if(IsPrinting())
|
||||||
|
SetDrawingMode(B_OP_COPY);
|
||||||
|
else
|
||||||
|
SetDrawingMode(B_OP_ALPHA);
|
||||||
|
DrawBitmap(e->bitmap, BRect(e->x1, e->y1, e->x2, e->y2));
|
||||||
|
SetDrawingMode(mode);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 12: {
|
||||||
|
// SetFont(&e->font, B_FONT_FAMILY_AND_STYLE);
|
||||||
|
// SetFont(&e->font, B_FONT_SIZE);
|
||||||
|
SetFont(&e->font, B_FONT_ALL);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabView::MouseDown(BPoint point)
|
||||||
|
{
|
||||||
|
BPoint ptCursor;
|
||||||
|
uint32 uButtons = 0;
|
||||||
|
GetMouse(&ptCursor, &uButtons, false);
|
||||||
|
|
||||||
|
mouseX = (int)ptCursor.x;
|
||||||
|
mouseY = (int)ptCursor.y;
|
||||||
|
if(uButtons & B_PRIMARY_MOUSE_BUTTON) mouseLButton = 1; else mouseLButton = 0;
|
||||||
|
if(uButtons & B_SECONDARY_MOUSE_BUTTON) mouseRButton = 1; else mouseRButton = 0;
|
||||||
|
if(uButtons & B_TERTIARY_MOUSE_BUTTON) mouseMButton = 1; else mouseMButton = 0;
|
||||||
|
mouseStateInfo = 4;
|
||||||
|
BView::MouseDown(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabView::MouseUp(BPoint point)
|
||||||
|
{
|
||||||
|
BPoint ptCursor;
|
||||||
|
uint32 uButtons = 0;
|
||||||
|
GetMouse(&ptCursor, &uButtons, false);
|
||||||
|
|
||||||
|
mouseX = (int)ptCursor.x;
|
||||||
|
mouseY = (int)ptCursor.y;
|
||||||
|
if(uButtons & B_PRIMARY_MOUSE_BUTTON) mouseLButton = 1; else mouseLButton = 0;
|
||||||
|
if(uButtons & B_SECONDARY_MOUSE_BUTTON) mouseRButton = 1; else mouseRButton = 0;
|
||||||
|
if(uButtons & B_TERTIARY_MOUSE_BUTTON) mouseMButton = 1; else mouseMButton = 0;
|
||||||
|
mouseStateInfo = 5;
|
||||||
|
BView::MouseUp(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabView::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
|
||||||
|
{
|
||||||
|
BPoint ptCursor;
|
||||||
|
uint32 uButtons = 0;
|
||||||
|
GetMouse(&ptCursor, &uButtons, true);
|
||||||
|
|
||||||
|
mouseX = (int)ptCursor.x;
|
||||||
|
mouseY = (int)ptCursor.y;
|
||||||
|
if(uButtons & B_PRIMARY_MOUSE_BUTTON) mouseLButton = 1; else mouseLButton = 0;
|
||||||
|
if(uButtons & B_SECONDARY_MOUSE_BUTTON) mouseRButton = 1; else mouseRButton = 0;
|
||||||
|
if(uButtons & B_TERTIARY_MOUSE_BUTTON) mouseMButton = 1; else mouseMButton = 0;
|
||||||
|
|
||||||
|
switch(transit)
|
||||||
|
{
|
||||||
|
case B_INSIDE_VIEW:
|
||||||
|
if(prevMouseStateInfo==1)
|
||||||
|
mouseStateInfo = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mouseStateInfo = 1;
|
||||||
|
prevMouseStateInfo = 1;
|
||||||
|
}
|
||||||
|
mouseMovedInfo = 0;
|
||||||
|
break;
|
||||||
|
case B_ENTERED_VIEW:
|
||||||
|
mouseStateInfo = 1;
|
||||||
|
mouseMovedInfo = 0;
|
||||||
|
break;
|
||||||
|
case B_OUTSIDE_VIEW:
|
||||||
|
mouseStateInfo = 2;
|
||||||
|
mouseMovedInfo = 1;
|
||||||
|
break;
|
||||||
|
case B_EXITED_VIEW:
|
||||||
|
mouseStateInfo = 3;
|
||||||
|
mouseMovedInfo = 1;
|
||||||
|
prevMouseStateInfo = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
BView::MouseMoved(point, transit, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabView::KeyDown(const char *bytes, int32 numBytes)
|
||||||
|
{
|
||||||
|
BMessage *msg = Window()->CurrentMessage();
|
||||||
|
if(msg)
|
||||||
|
{
|
||||||
|
pressedKeys.SetTo("");
|
||||||
|
int32 key, modifiers;
|
||||||
|
msg->FindInt32("key", &key);
|
||||||
|
msg->FindInt32("modifiers", &modifiers);
|
||||||
|
if(modifiers&B_CONTROL_KEY) pressedKeys << "ctrl-";
|
||||||
|
if(modifiers&B_COMMAND_KEY) pressedKeys << "command-";
|
||||||
|
if(modifiers&B_OPTION_KEY) pressedKeys << "option-";
|
||||||
|
if(modifiers&B_SHIFT_KEY) pressedKeys << "shift-";
|
||||||
|
switch(bytes[0])
|
||||||
|
{
|
||||||
|
case B_BACKSPACE: pressedKeys << "backspace"; break;
|
||||||
|
case B_ENTER: pressedKeys << "enter"; break;
|
||||||
|
case B_TAB: pressedKeys << "tab"; break;
|
||||||
|
case B_ESCAPE: pressedKeys << "esc"; break;
|
||||||
|
case B_LEFT_ARROW: pressedKeys << "left"; break;
|
||||||
|
case B_RIGHT_ARROW: pressedKeys << "right"; break;
|
||||||
|
case B_UP_ARROW: pressedKeys << "up"; break;
|
||||||
|
case B_DOWN_ARROW: pressedKeys << "down"; break;
|
||||||
|
case B_INSERT: pressedKeys << "insert"; break;
|
||||||
|
case B_DELETE: pressedKeys << "del"; break;
|
||||||
|
case B_HOME: pressedKeys << "home"; break;
|
||||||
|
case B_END: pressedKeys << "end"; break;
|
||||||
|
case B_PAGE_UP: pressedKeys << "pageup"; break;
|
||||||
|
case B_PAGE_DOWN: pressedKeys << "pagedown"; break;
|
||||||
|
case B_FUNCTION_KEY:
|
||||||
|
{
|
||||||
|
switch(key)
|
||||||
|
{
|
||||||
|
case B_F1_KEY: pressedKeys << "f1"; break;
|
||||||
|
case B_F2_KEY: pressedKeys << "f2"; break;
|
||||||
|
case B_F3_KEY: pressedKeys << "f3"; break;
|
||||||
|
case B_F4_KEY: pressedKeys << "f4"; break;
|
||||||
|
case B_F5_KEY: pressedKeys << "f5"; break;
|
||||||
|
case B_F6_KEY: pressedKeys << "f6"; break;
|
||||||
|
case B_F7_KEY: pressedKeys << "f7"; break;
|
||||||
|
case B_F8_KEY: pressedKeys << "f8"; break;
|
||||||
|
case B_F9_KEY: pressedKeys << "f9"; break;
|
||||||
|
case B_F10_KEY: pressedKeys << "f10"; break;
|
||||||
|
case B_F11_KEY: pressedKeys << "f11"; break;
|
||||||
|
case B_F12_KEY: pressedKeys << "f12"; break;
|
||||||
|
case B_PRINT_KEY: pressedKeys << "print"; break;
|
||||||
|
case B_SCROLL_KEY: pressedKeys << "scroll"; break;
|
||||||
|
case B_PAUSE_KEY: pressedKeys << "pause"; break;
|
||||||
|
default:
|
||||||
|
pressedKeys.SetTo(bytes);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pressedKeys.SetTo(bytes);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pressedKeys.SetTo(bytes);
|
||||||
|
|
||||||
|
if(bytes[0]!=B_TAB) BView::KeyDown(bytes,numBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabView::KeyUp(const char *bytes, int32 numBytes)
|
||||||
|
{
|
||||||
|
pressedKeys.SetTo("");
|
||||||
|
BView::KeyUp(bytes,numBytes);
|
||||||
|
}
|
||||||
|
|
||||||
44
src/YabView.h
Normal file
44
src/YabView.h
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
#ifndef YABVIEW_H
|
||||||
|
#define YABVIEW_H
|
||||||
|
|
||||||
|
#include <String.h>
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
struct YabDrawing
|
||||||
|
{
|
||||||
|
int command;
|
||||||
|
double x1,y1,x2,y2,x3,y3,x4,y4;
|
||||||
|
int r,g,b,alpha;
|
||||||
|
const char* chardata;
|
||||||
|
pattern p;
|
||||||
|
BBitmap *bitmap;
|
||||||
|
BFont font;
|
||||||
|
};
|
||||||
|
|
||||||
|
class YabView : public BView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YabView(BRect frame, const char *name, uint32 resizingMode, uint32 flags);
|
||||||
|
~YabView();
|
||||||
|
virtual void MessageReceived(BMessage *msg);
|
||||||
|
virtual void Draw(BRect updateRect);
|
||||||
|
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
|
||||||
|
virtual void MouseUp(BPoint point);
|
||||||
|
virtual void MouseDown(BPoint point);
|
||||||
|
virtual void KeyUp(const char *bytes, int32 numBytes);
|
||||||
|
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||||
|
BList *drawList;
|
||||||
|
int mouseMovedInfo;
|
||||||
|
int mouseStateInfo;
|
||||||
|
int mouseX;
|
||||||
|
int mouseY;
|
||||||
|
uint mouseLButton;
|
||||||
|
uint mouseMButton;
|
||||||
|
uint mouseRButton;
|
||||||
|
bool dropZone;
|
||||||
|
BString pressedKeys;
|
||||||
|
private:
|
||||||
|
int prevMouseStateInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
361
src/YabWindow.cpp
Normal file
361
src/YabWindow.cpp
Normal file
@@ -0,0 +1,361 @@
|
|||||||
|
#include "global.h"
|
||||||
|
#include <Application.h>
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include <Button.h>
|
||||||
|
#include <CheckBox.h>
|
||||||
|
#include <ColorControl.h>
|
||||||
|
#include <ListView.h>
|
||||||
|
#include <Menu.h>
|
||||||
|
#include <MenuBar.h>
|
||||||
|
#include <MenuItem.h>
|
||||||
|
#include <OutlineListView.h>
|
||||||
|
#include <RadioButton.h>
|
||||||
|
#include <Slider.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
#include <Window.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "YabWindow.h"
|
||||||
|
#include "column/ColumnListView.h"
|
||||||
|
|
||||||
|
const uint32 YABBUTTON = 'YBbu';
|
||||||
|
const uint32 YABMENU = 'YBme';
|
||||||
|
const uint32 YABSUBMENU = 'YBsu';
|
||||||
|
const uint32 YABTEXTCONTROL = 'YBtc';
|
||||||
|
const uint32 YABCHECKBOX = 'YBcb';
|
||||||
|
const uint32 YABRADIOBUTTON = 'YBrb';
|
||||||
|
const uint32 YABLISTBOXSELECT = 'YBls';
|
||||||
|
const uint32 YABLISTBOXINVOKE = 'YBli';
|
||||||
|
const uint32 YABDROPBOX = 'YBdb';
|
||||||
|
const uint32 YABSLIDER = 'YBsl';
|
||||||
|
const uint32 YABCOLORCONTROL = 'YBco';
|
||||||
|
const uint32 YABTREEBOXSELECT = 'YBts';
|
||||||
|
const uint32 YABTREEBOXINVOKE = 'YBti';
|
||||||
|
const uint32 YABFILEBOXSELECT = 'YBfs';
|
||||||
|
const uint32 YABFILEBOXINVOKE = 'YBfi';
|
||||||
|
const uint32 YABSPINCONTROL = 'YBsp';
|
||||||
|
const uint32 YABSHORTCUT = 'YBsh';
|
||||||
|
|
||||||
|
YabWindow::YabWindow(BRect frame, const char* title, const char* id, window_look winlook, window_feel winfeel, uint32 flags)
|
||||||
|
: BWindow (frame, title, winlook, winfeel, flags)
|
||||||
|
{
|
||||||
|
messageString.SetTo("");
|
||||||
|
idString.SetTo(id);
|
||||||
|
showing = 1;
|
||||||
|
dropMsg.SetTo("");
|
||||||
|
WActivated=-1;
|
||||||
|
WFrameMoved=-1;
|
||||||
|
WFrameResized=-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
YabWindow::~YabWindow()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabWindow::WindowActivated(bool state)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
WActivated=1;
|
||||||
|
else
|
||||||
|
WActivated=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabWindow::FrameMoved(BPoint new_position)
|
||||||
|
{
|
||||||
|
WFrameMoved=1;
|
||||||
|
Wpx=(int)new_position.x;
|
||||||
|
Wpy=(int)new_position.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabWindow::FrameResized(float new_width, float new_height)
|
||||||
|
{
|
||||||
|
WFrameResized=1;
|
||||||
|
Wph=(int)new_height;
|
||||||
|
Wpw=(int)new_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YabWindow::MessageReceived(BMessage *message)
|
||||||
|
{
|
||||||
|
// if(message) message->PrintToStream();
|
||||||
|
switch(message->what)
|
||||||
|
{
|
||||||
|
case YABBUTTON:
|
||||||
|
{
|
||||||
|
BString tmpMessage("");
|
||||||
|
BButton *myButtonPressed;
|
||||||
|
message->FindPointer("source",(void **) &myButtonPressed);
|
||||||
|
tmpMessage += myButtonPressed->Name();
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABMENU:
|
||||||
|
{
|
||||||
|
BString tmpMessage("");
|
||||||
|
BMenuItem *mySelectedMenu;
|
||||||
|
message->FindPointer("source",(void **) &mySelectedMenu);
|
||||||
|
BMenu *myMenu = mySelectedMenu->Menu();
|
||||||
|
tmpMessage += ((BMenuBar*)myMenu->Supermenu())->Parent()->Name();
|
||||||
|
tmpMessage += ":";
|
||||||
|
tmpMessage += myMenu->Name();
|
||||||
|
tmpMessage += ":";
|
||||||
|
tmpMessage += mySelectedMenu->Label();
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABSUBMENU:
|
||||||
|
{
|
||||||
|
BString tmpMessage("");
|
||||||
|
BMenuItem *mySelectedMenu;
|
||||||
|
message->FindPointer("source",(void **) &mySelectedMenu);
|
||||||
|
BMenu *myMenu = mySelectedMenu->Menu();
|
||||||
|
tmpMessage += ((BMenuBar*)myMenu->Supermenu()->Supermenu())->Parent()->Name();
|
||||||
|
tmpMessage += ":";
|
||||||
|
tmpMessage += myMenu->Supermenu()->Name();
|
||||||
|
tmpMessage += ":";
|
||||||
|
tmpMessage += myMenu->Name();
|
||||||
|
tmpMessage += ":";
|
||||||
|
tmpMessage += mySelectedMenu->Label();
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABTEXTCONTROL:
|
||||||
|
{
|
||||||
|
BString tmpMessage("");
|
||||||
|
BTextControl *myTextControl;
|
||||||
|
message->FindPointer("source",(void **) &myTextControl);
|
||||||
|
tmpMessage += myTextControl->Name();
|
||||||
|
tmpMessage += ":";
|
||||||
|
tmpMessage += myTextControl->Text();
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABCHECKBOX:
|
||||||
|
{
|
||||||
|
BString tmpMessage("");
|
||||||
|
BCheckBox *myCheckBox;
|
||||||
|
message->FindPointer("source",(void **) &myCheckBox);
|
||||||
|
tmpMessage += myCheckBox->Name();
|
||||||
|
tmpMessage += ":";
|
||||||
|
if(myCheckBox->Value()==B_CONTROL_ON)
|
||||||
|
tmpMessage += "ON|";
|
||||||
|
else
|
||||||
|
tmpMessage += "OFF|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABRADIOBUTTON:
|
||||||
|
{
|
||||||
|
BString tmpMessage("");
|
||||||
|
BRadioButton *myRadioButton;
|
||||||
|
message->FindPointer("source",(void **) &myRadioButton);
|
||||||
|
tmpMessage += myRadioButton->Name();
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABLISTBOXINVOKE:
|
||||||
|
{
|
||||||
|
BListView *myList;
|
||||||
|
message->FindPointer("source",(void **) &myList);
|
||||||
|
int i = myList->CurrentSelection();
|
||||||
|
if(i>=0)
|
||||||
|
{
|
||||||
|
BString tmpMessage("");
|
||||||
|
tmpMessage += myList->Name();
|
||||||
|
tmpMessage += ":_Invoke:";
|
||||||
|
// tmpMessage += ((BStringItem*)(myList->ItemAt(i)))->Text();
|
||||||
|
tmpMessage << i+1;
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABLISTBOXSELECT:
|
||||||
|
{
|
||||||
|
BListView *myList;
|
||||||
|
message->FindPointer("source",(void **) &myList);
|
||||||
|
int i = myList->CurrentSelection();
|
||||||
|
if(i>=0)
|
||||||
|
{
|
||||||
|
BString tmpMessage("");
|
||||||
|
tmpMessage += myList->Name();
|
||||||
|
tmpMessage += ":_Select:";
|
||||||
|
// tmpMessage += ((BStringItem*)(myList->ItemAt(i)))->Text();
|
||||||
|
tmpMessage << i+1;
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABDROPBOX:
|
||||||
|
{
|
||||||
|
BString tmpMessage("");
|
||||||
|
BMenuItem *myMenuItem;
|
||||||
|
message->FindPointer("source",(void **) &myMenuItem);
|
||||||
|
tmpMessage += (myMenuItem->Menu())->Supermenu()->Parent()->Name();
|
||||||
|
tmpMessage += ":";
|
||||||
|
tmpMessage += myMenuItem->Label();
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABSLIDER:
|
||||||
|
{
|
||||||
|
BString tmpMessage("");
|
||||||
|
BSlider *mySlider;
|
||||||
|
message->FindPointer("source",(void **) &mySlider);
|
||||||
|
tmpMessage += mySlider->Name();
|
||||||
|
tmpMessage += ":";
|
||||||
|
tmpMessage << mySlider->Value();
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABCOLORCONTROL:
|
||||||
|
{
|
||||||
|
rgb_color col;
|
||||||
|
BString tmpMessage("");
|
||||||
|
BColorControl *myCControl;
|
||||||
|
message->FindPointer("source",(void **) &myCControl);
|
||||||
|
tmpMessage += myCControl->Name();
|
||||||
|
tmpMessage += ":";
|
||||||
|
col = myCControl->ValueAsColor();
|
||||||
|
tmpMessage << col.red << ":" << col.green << ":" << col.blue;
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABTREEBOXINVOKE:
|
||||||
|
{
|
||||||
|
BOutlineListView *myList;
|
||||||
|
message->FindPointer("source",(void **) &myList);
|
||||||
|
int i = myList->FullListCurrentSelection();
|
||||||
|
if(i>=0)
|
||||||
|
{
|
||||||
|
BString tmpMessage("");
|
||||||
|
const char* txt = ((BStringItem*)(myList->FullListItemAt(i)))->Text();
|
||||||
|
tmpMessage += myList->Name();
|
||||||
|
tmpMessage += ":_Invoke:";
|
||||||
|
tmpMessage << i+1;
|
||||||
|
/*
|
||||||
|
int n = tmpMessage.Length();
|
||||||
|
BListItem *superitem = myList->Superitem(myList->FullListItemAt(i));
|
||||||
|
while(superitem)
|
||||||
|
{
|
||||||
|
BString t("");
|
||||||
|
t << ((BStringItem*)superitem)->Text() << ":";
|
||||||
|
tmpMessage.Insert(t,n);
|
||||||
|
superitem = myList->Superitem(superitem);
|
||||||
|
}
|
||||||
|
tmpMessage += txt;*/
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABTREEBOXSELECT:
|
||||||
|
{
|
||||||
|
BOutlineListView *myList;
|
||||||
|
message->FindPointer("source",(void **) &myList);
|
||||||
|
int i = myList->FullListCurrentSelection();
|
||||||
|
if(i>=0)
|
||||||
|
{
|
||||||
|
BString tmpMessage("");
|
||||||
|
const char* txt = ((BStringItem*)(myList->FullListItemAt(i)))->Text();
|
||||||
|
tmpMessage += myList->Name();
|
||||||
|
tmpMessage += ":_Select:";
|
||||||
|
tmpMessage << i+1;
|
||||||
|
/*
|
||||||
|
int n = tmpMessage.Length();
|
||||||
|
BListItem *superitem = myList->Superitem(myList->FullListItemAt(i));
|
||||||
|
while(superitem)
|
||||||
|
{
|
||||||
|
BString t("");
|
||||||
|
t << ((BStringItem*)superitem)->Text() << ":";
|
||||||
|
tmpMessage.Insert(t,n);
|
||||||
|
superitem = myList->Superitem(superitem);
|
||||||
|
}
|
||||||
|
tmpMessage += txt;*/
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABFILEBOXSELECT:
|
||||||
|
{
|
||||||
|
BColumnListView *myList;
|
||||||
|
message->FindPointer("source",(void **) &myList);
|
||||||
|
BRow *myRow = NULL;
|
||||||
|
if(myList) myRow = myList->CurrentSelection();
|
||||||
|
if(myRow)
|
||||||
|
{
|
||||||
|
// if(!myList->IsFocus()) myList->MakeFocus();
|
||||||
|
BString tmpMessage("");
|
||||||
|
tmpMessage += myList->Name();
|
||||||
|
tmpMessage += ":_Select:";
|
||||||
|
tmpMessage << myList->IndexOf(myRow)+1;
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABFILEBOXINVOKE:
|
||||||
|
{
|
||||||
|
BColumnListView *myList;
|
||||||
|
message->FindPointer("source",(void **) &myList);
|
||||||
|
BRow *myRow = NULL;
|
||||||
|
if(myList) myRow = myList->CurrentSelection();
|
||||||
|
if(myRow)
|
||||||
|
{
|
||||||
|
// if(!myList->IsFocus()) myList->MakeFocus();
|
||||||
|
BString tmpMessage("");
|
||||||
|
tmpMessage += myList->Name();
|
||||||
|
tmpMessage += ":_Invoke:";
|
||||||
|
tmpMessage << myList->IndexOf(myRow)+1;
|
||||||
|
tmpMessage += "|";
|
||||||
|
messageString += tmpMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case YABSHORTCUT:
|
||||||
|
{
|
||||||
|
const char* myMsg;
|
||||||
|
if(message->FindString("shortcut", &myMsg) == B_OK)
|
||||||
|
{
|
||||||
|
messageString += myMsg;
|
||||||
|
messageString += "|";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BWindow::MessageReceived(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const BString YabWindow::getMessages()
|
||||||
|
{
|
||||||
|
BString tmp(messageString);
|
||||||
|
tmp += dropMsg;
|
||||||
|
messageString.SetTo("");
|
||||||
|
dropMsg.SetTo("");
|
||||||
|
return (const BString)tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YabWindow::QuitRequested()
|
||||||
|
{
|
||||||
|
messageString += idString;
|
||||||
|
messageString += ":_QuitRequested|";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool YabWindow::IsPaper(uint8* a)
|
||||||
|
{
|
||||||
|
if(a[32] != 0) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
38
src/YabWindow.h
Normal file
38
src/YabWindow.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef YABWINDOW_H
|
||||||
|
#define YABWINDOW_H
|
||||||
|
|
||||||
|
#include <FilePanel.h>
|
||||||
|
#include <List.h>
|
||||||
|
#include <Menu.h>
|
||||||
|
#include <PopUpMenu.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
class YabWindow : public BWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
YabWindow(BRect frame, const char* title, const char* id, window_look winlook, window_feel winfeel, uint32 flags);
|
||||||
|
~YabWindow();
|
||||||
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
virtual bool QuitRequested();
|
||||||
|
const BString getMessages();
|
||||||
|
virtual void WindowActivated(bool state);
|
||||||
|
virtual void FrameMoved(BPoint new_position);
|
||||||
|
virtual void FrameResized(float new_width, float new_height);
|
||||||
|
int layout;
|
||||||
|
int showing;
|
||||||
|
int WActivated;
|
||||||
|
int WFrameResized;
|
||||||
|
int Wpx;
|
||||||
|
int Wpy;
|
||||||
|
int Wph;
|
||||||
|
int Wpw;
|
||||||
|
int WFrameMoved;
|
||||||
|
BString dropMsg;
|
||||||
|
BString idString;
|
||||||
|
private:
|
||||||
|
bool IsPaper(uint8* a);
|
||||||
|
BString messageString;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
110
src/column/ColorTools.cpp
Normal file
110
src/column/ColorTools.cpp
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/*
|
||||||
|
Open Tracker License
|
||||||
|
|
||||||
|
Terms and Conditions
|
||||||
|
|
||||||
|
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice applies to all licensees
|
||||||
|
and shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||||
|
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||||
|
this Software without prior written authorization from Be Incorporated.
|
||||||
|
|
||||||
|
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||||
|
of Be Incorporated in the United States and other countries. Other brand product
|
||||||
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
|
All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
/
|
||||||
|
/ File: ColorTools.cpp
|
||||||
|
/
|
||||||
|
/ Description: Additional experimental color manipulation functions.
|
||||||
|
/
|
||||||
|
/ Copyright 2000, Be Incorporated, All Rights Reserved
|
||||||
|
/
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "ColorTools.h"
|
||||||
|
|
||||||
|
#if B_BEOS_VERSION <= B_BEOS_VERSION_MAUI
|
||||||
|
|
||||||
|
namespace BExperimental {
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
#define DB_INLINE
|
||||||
|
#else
|
||||||
|
#define DB_INLINE inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static DB_INLINE void mix_color_func(rgb_color* target, const rgb_color other, uint8 amount)
|
||||||
|
{
|
||||||
|
target->red = (uint8)( ((int16(other.red)-int16(target->red))*amount)/255
|
||||||
|
+ target->red );
|
||||||
|
target->green = (uint8)( ((int16(other.green)-int16(target->green))*amount)/255
|
||||||
|
+ target->green );
|
||||||
|
target->blue = (uint8)( ((int16(other.blue)-int16(target->blue))*amount)/255
|
||||||
|
+ target->blue );
|
||||||
|
target->alpha = (uint8)( ((int16(other.alpha)-int16(target->alpha))*amount)/255
|
||||||
|
+ target->alpha );
|
||||||
|
}
|
||||||
|
|
||||||
|
static DB_INLINE void blend_color_func(rgb_color* target, const rgb_color other, uint8 amount)
|
||||||
|
{
|
||||||
|
const uint8 alphaMix = (uint8)( ((int16(other.alpha)-int16(255-target->alpha))*amount)/255
|
||||||
|
+ (255-target->alpha) );
|
||||||
|
target->red = (uint8)( ((int16(other.red)-int16(target->red))*alphaMix)/255
|
||||||
|
+ target->red );
|
||||||
|
target->green = (uint8)( ((int16(other.green)-int16(target->green))*alphaMix)/255
|
||||||
|
+ target->green );
|
||||||
|
target->blue = (uint8)( ((int16(other.blue)-int16(target->blue))*alphaMix)/255
|
||||||
|
+ target->blue );
|
||||||
|
target->alpha = (uint8)( ((int16(other.alpha)-int16(target->alpha))*amount)/255
|
||||||
|
+ target->alpha );
|
||||||
|
}
|
||||||
|
|
||||||
|
static DB_INLINE void disable_color_func(rgb_color* target, const rgb_color background)
|
||||||
|
{
|
||||||
|
blend_color_func(target, background, 255-70);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
rgb_color mix_color(rgb_color color1, rgb_color color2, uint8 amount)
|
||||||
|
{
|
||||||
|
mix_color_func(&color1, color2, amount);
|
||||||
|
return color1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_color blend_color(rgb_color color1, rgb_color color2, uint8 amount)
|
||||||
|
{
|
||||||
|
blend_color_func(&color1, color2, amount);
|
||||||
|
return color1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_color disable_color(rgb_color color, rgb_color background)
|
||||||
|
{
|
||||||
|
disable_color_func(&color, background);
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
107
src/column/ColorTools.h
Normal file
107
src/column/ColorTools.h
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
Open Tracker License
|
||||||
|
|
||||||
|
Terms and Conditions
|
||||||
|
|
||||||
|
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice applies to all licensees
|
||||||
|
and shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||||
|
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||||
|
this Software without prior written authorization from Be Incorporated.
|
||||||
|
|
||||||
|
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||||
|
of Be Incorporated in the United States and other countries. Other brand product
|
||||||
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
|
All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
/
|
||||||
|
/ File: ColorTools.h
|
||||||
|
/
|
||||||
|
/ Description: Additional experimental color manipulation functions.
|
||||||
|
/
|
||||||
|
/ Copyright 2000, Be Incorporated, All Rights Reserved
|
||||||
|
/
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _COLOR_TOOLS_H
|
||||||
|
#define _COLOR_TOOLS_H
|
||||||
|
|
||||||
|
#include <GraphicsDefs.h>
|
||||||
|
|
||||||
|
#if B_BEOS_VERSION <= B_BEOS_VERSION_MAUI
|
||||||
|
|
||||||
|
namespace BExperimental {
|
||||||
|
|
||||||
|
// Comparison operators.
|
||||||
|
|
||||||
|
inline bool operator==(const rgb_color c1, const rgb_color c2)
|
||||||
|
{
|
||||||
|
return (*((uint32*)&c1)) == (*((uint32*)&c2));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator!=(const rgb_color c1, const rgb_color c2)
|
||||||
|
{
|
||||||
|
return (*((uint32*)&c1)) != (*((uint32*)&c2));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Color creation.
|
||||||
|
|
||||||
|
#ifndef HAIKU
|
||||||
|
|
||||||
|
inline rgb_color make_color(uint8 red, uint8 green, uint8 blue, uint8 alpha=255)
|
||||||
|
{
|
||||||
|
rgb_color c;
|
||||||
|
c.red = red;
|
||||||
|
c.green = green;
|
||||||
|
c.blue = blue;
|
||||||
|
c.alpha = alpha;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Mix two colors together, ignoring their relative alpha channels.
|
||||||
|
// If amount is 0, the result is color1; if 255, the result is color2;
|
||||||
|
// if another value, it is somewhere in-between. The resulting alpha
|
||||||
|
// channel is mixed exactly like the other color channels.
|
||||||
|
rgb_color mix_color(rgb_color color1, rgb_color color2, uint8 amount);
|
||||||
|
|
||||||
|
// Blend two colors together, weighting by their relative alpha channels.
|
||||||
|
// The resulting color is the same as mix_color(), except that the amount
|
||||||
|
// used from color1 and color2's color channels is dependent on that color's
|
||||||
|
// alpha channel. For example, if color1.alpha is 0 and color2.alpha is
|
||||||
|
// 255, the resulting red, green, and blue values will be the same as those
|
||||||
|
// in color2, regardless of 'amount'.
|
||||||
|
rgb_color blend_color(rgb_color color1, rgb_color color2, uint8 amount);
|
||||||
|
|
||||||
|
// Return a color that is the disabled representation of 'color' when drawn
|
||||||
|
// on a solid color 'background'.
|
||||||
|
rgb_color disable_color(rgb_color color, rgb_color background);
|
||||||
|
|
||||||
|
} // namespace BExperimental
|
||||||
|
|
||||||
|
using namespace BExperimental;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
4887
src/column/ColumnListView.cpp
Normal file
4887
src/column/ColumnListView.cpp
Normal file
File diff suppressed because it is too large
Load Diff
409
src/column/ColumnListView.h
Normal file
409
src/column/ColumnListView.h
Normal file
@@ -0,0 +1,409 @@
|
|||||||
|
/*
|
||||||
|
Open Tracker License
|
||||||
|
|
||||||
|
Terms and Conditions
|
||||||
|
|
||||||
|
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice applies to all licensees
|
||||||
|
and shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||||
|
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||||
|
this Software without prior written authorization from Be Incorporated.
|
||||||
|
|
||||||
|
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||||
|
of Be Incorporated in the United States and other countries. Other brand product
|
||||||
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
|
All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
/
|
||||||
|
/ File: ColumnListView.h
|
||||||
|
/
|
||||||
|
/ Description: Experimental multi-column list view.
|
||||||
|
/
|
||||||
|
/ Copyright 2000+, Be Incorporated, All Rights Reserved
|
||||||
|
/
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _COLUMN_LIST_VIEW_H
|
||||||
|
#define _COLUMN_LIST_VIEW_H
|
||||||
|
|
||||||
|
#include <BeBuild.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include <List.h>
|
||||||
|
#include <Invoker.h>
|
||||||
|
#include <ListView.h>
|
||||||
|
|
||||||
|
class BScrollBar;
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
class OutlineView;
|
||||||
|
class TitleView;
|
||||||
|
class BRowContainer;
|
||||||
|
class RecursiveOutlineIterator;
|
||||||
|
|
||||||
|
} // ns BPrivate
|
||||||
|
|
||||||
|
class BField;
|
||||||
|
class BRow;
|
||||||
|
class BColumn;
|
||||||
|
class BColumnListView;
|
||||||
|
|
||||||
|
enum LatchType {
|
||||||
|
B_NO_LATCH = 0,
|
||||||
|
B_OPEN_LATCH = 1,
|
||||||
|
B_PRESSED_LATCH = 2,
|
||||||
|
B_CLOSED_LATCH = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
B_ALLOW_COLUMN_NONE = 0,
|
||||||
|
B_ALLOW_COLUMN_MOVE = 1,
|
||||||
|
B_ALLOW_COLUMN_RESIZE = 2,
|
||||||
|
B_ALLOW_COLUMN_POPUP = 4,
|
||||||
|
B_ALLOW_COLUMN_REMOVE = 8
|
||||||
|
} column_flags;
|
||||||
|
|
||||||
|
enum ColumnListViewColor {
|
||||||
|
B_COLOR_BACKGROUND = 0,
|
||||||
|
B_COLOR_TEXT = 1,
|
||||||
|
B_COLOR_ROW_DIVIDER = 2,
|
||||||
|
B_COLOR_SELECTION = 3,
|
||||||
|
B_COLOR_SELECTION_TEXT = 4,
|
||||||
|
B_COLOR_NON_FOCUS_SELECTION = 5,
|
||||||
|
B_COLOR_EDIT_BACKGROUND = 6,
|
||||||
|
B_COLOR_EDIT_TEXT = 7,
|
||||||
|
B_COLOR_HEADER_BACKGROUND = 8,
|
||||||
|
B_COLOR_HEADER_TEXT = 9,
|
||||||
|
B_COLOR_SEPARATOR_LINE = 10,
|
||||||
|
B_COLOR_SEPARATOR_BORDER = 11,
|
||||||
|
|
||||||
|
B_COLOR_TOTAL = 12
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ColumnListViewFont {
|
||||||
|
B_FONT_ROW = 0,
|
||||||
|
B_FONT_HEADER = 1,
|
||||||
|
|
||||||
|
B_FONT_TOTAL = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// A single row/column intersection in the list.
|
||||||
|
class BField {
|
||||||
|
public:
|
||||||
|
BField();
|
||||||
|
virtual ~BField();
|
||||||
|
};
|
||||||
|
|
||||||
|
// A single line in the list. Each line contains a BField object
|
||||||
|
// for each column in the list, associated by their "logical field"
|
||||||
|
// index. Hierarchies are formed by adding other BRow objects as
|
||||||
|
// a parent of a row, using the AddRow() function in BColumnListView().
|
||||||
|
class BRow {
|
||||||
|
public:
|
||||||
|
BRow(float height = 16.0);
|
||||||
|
virtual ~BRow();
|
||||||
|
virtual bool HasLatch() const;
|
||||||
|
|
||||||
|
int32 CountFields() const;
|
||||||
|
BField* GetField(int32 logicalFieldIndex);
|
||||||
|
const BField* GetField(int32 logicalFieldIndex) const;
|
||||||
|
void SetField(BField* field,
|
||||||
|
int32 logicalFieldIndex);
|
||||||
|
|
||||||
|
float Height() const;
|
||||||
|
bool IsExpanded() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Blows up into the debugger if the validation fails.
|
||||||
|
void ValidateFields() const;
|
||||||
|
void ValidateField(const BField* field,
|
||||||
|
int32 logicalFieldIndex) const;
|
||||||
|
private:
|
||||||
|
BList fFields;
|
||||||
|
BPrivate::
|
||||||
|
BRowContainer* fChildList;
|
||||||
|
bool fIsExpanded;
|
||||||
|
float fHeight;
|
||||||
|
BRow* fNextSelected;
|
||||||
|
BRow* fPrevSelected;
|
||||||
|
BRow* fParent;
|
||||||
|
BColumnListView* fList;
|
||||||
|
|
||||||
|
|
||||||
|
friend class BColumnListView;
|
||||||
|
friend class BPrivate::RecursiveOutlineIterator;
|
||||||
|
friend class BPrivate::OutlineView;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Information about a single column in the list. A column knows
|
||||||
|
// how to display the BField objects that occur at its location in
|
||||||
|
// each of the list's rows. See ColumnTypes.h for particular
|
||||||
|
// subclasses of BField and BColumn that handle common data types.
|
||||||
|
class BColumn {
|
||||||
|
public:
|
||||||
|
BColumn(float width, float minWidth,
|
||||||
|
float maxWidth,
|
||||||
|
alignment align = B_ALIGN_LEFT);
|
||||||
|
virtual ~BColumn();
|
||||||
|
|
||||||
|
float Width() const;
|
||||||
|
void SetWidth(float width);
|
||||||
|
float MinWidth() const;
|
||||||
|
float MaxWidth() const;
|
||||||
|
|
||||||
|
virtual void DrawTitle(BRect rect, BView* targetView);
|
||||||
|
virtual void DrawField(BField* field, BRect rect,
|
||||||
|
BView* targetView);
|
||||||
|
virtual int CompareFields(BField* field1, BField* field2);
|
||||||
|
|
||||||
|
virtual void MouseMoved(BColumnListView* parent, BRow* row,
|
||||||
|
BField* field, BRect fieldRect,
|
||||||
|
BPoint point, uint32 buttons, int32 code);
|
||||||
|
virtual void MouseDown(BColumnListView* parent, BRow* row,
|
||||||
|
BField* field, BRect fieldRect,
|
||||||
|
BPoint point, uint32 buttons);
|
||||||
|
virtual void MouseUp(BColumnListView* parent, BRow* row,
|
||||||
|
BField* field);
|
||||||
|
|
||||||
|
virtual void GetColumnName(BString* into) const;
|
||||||
|
virtual float GetPreferredWidth(BField* field,
|
||||||
|
BView* parent) const;
|
||||||
|
|
||||||
|
bool IsVisible() const;
|
||||||
|
void SetVisible(bool);
|
||||||
|
|
||||||
|
bool WantsEvents() const;
|
||||||
|
void SetWantsEvents(bool);
|
||||||
|
|
||||||
|
bool ShowHeading() const;
|
||||||
|
void SetShowHeading(bool);
|
||||||
|
|
||||||
|
alignment Alignment() const;
|
||||||
|
void SetAlignment(alignment);
|
||||||
|
|
||||||
|
int32 LogicalFieldNum() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\param field The BField derivative to validate.
|
||||||
|
|
||||||
|
Implement this function on your BColumn derivatives to validate
|
||||||
|
BField derivatives that your BColumn will be drawing/manipulating.
|
||||||
|
|
||||||
|
This function will be called when BFields are added to the Column,
|
||||||
|
use dynamic_cast<> to determine if it is of a kind that your
|
||||||
|
BColumn know how ot handle. return false if it is not.
|
||||||
|
|
||||||
|
\note The debugger will be called if you return false from here
|
||||||
|
with information about what type of BField and BColumn and the
|
||||||
|
logical field index where it occured.
|
||||||
|
|
||||||
|
\note Do not call the inherited version of this, it just returns
|
||||||
|
true;
|
||||||
|
*/
|
||||||
|
virtual bool AcceptsField(const BField* field) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
float fWidth;
|
||||||
|
float fMinWidth;
|
||||||
|
float fMaxWidth;
|
||||||
|
bool fVisible;
|
||||||
|
int32 fFieldID;
|
||||||
|
BColumnListView* fList;
|
||||||
|
bool fSortAscending;
|
||||||
|
bool fWantsEvents;
|
||||||
|
bool fShowHeading;
|
||||||
|
alignment fAlignment;
|
||||||
|
|
||||||
|
friend class BPrivate::OutlineView;
|
||||||
|
friend class BColumnListView;
|
||||||
|
friend class BPrivate::TitleView;
|
||||||
|
};
|
||||||
|
|
||||||
|
// The column list view class.
|
||||||
|
class BColumnListView : public BView, public BInvoker {
|
||||||
|
public:
|
||||||
|
BColumnListView(BRect rect,
|
||||||
|
const char* name, uint32 resizingMode,
|
||||||
|
uint32 flags, border_style = B_NO_BORDER,
|
||||||
|
bool showHorizontalScrollbar = true);
|
||||||
|
BColumnListView(const char* name,
|
||||||
|
uint32 flags, border_style = B_NO_BORDER,
|
||||||
|
bool showHorizontalScrollbar = true);
|
||||||
|
virtual ~BColumnListView();
|
||||||
|
|
||||||
|
// Interaction
|
||||||
|
virtual bool InitiateDrag(BPoint, bool wasSelected);
|
||||||
|
virtual void MessageDropped(BMessage*, BPoint point);
|
||||||
|
virtual void ExpandOrCollapse(BRow* row, bool expand);
|
||||||
|
virtual status_t Invoke(BMessage* message = NULL);
|
||||||
|
virtual void ItemInvoked();
|
||||||
|
virtual void SetInvocationMessage(BMessage* message);
|
||||||
|
BMessage* InvocationMessage() const;
|
||||||
|
uint32 InvocationCommand() const;
|
||||||
|
BRow* FocusRow() const;
|
||||||
|
void SetFocusRow(int32 index, bool select = false);
|
||||||
|
void SetFocusRow(BRow* row, bool select = false);
|
||||||
|
void SetMouseTrackingEnabled(bool);
|
||||||
|
|
||||||
|
// Selection
|
||||||
|
list_view_type SelectionMode() const;
|
||||||
|
void Deselect(BRow* row);
|
||||||
|
void AddToSelection(BRow* row);
|
||||||
|
void DeselectAll();
|
||||||
|
BRow* CurrentSelection(BRow* lastSelected = 0) const;
|
||||||
|
virtual void SelectionChanged();
|
||||||
|
virtual void SetSelectionMessage(BMessage* message);
|
||||||
|
BMessage* SelectionMessage();
|
||||||
|
uint32 SelectionCommand() const;
|
||||||
|
void SetSelectionMode(list_view_type type);
|
||||||
|
// list_view_type is defined in ListView.h.
|
||||||
|
|
||||||
|
// Sorting
|
||||||
|
void SetSortingEnabled(bool);
|
||||||
|
bool SortingEnabled() const;
|
||||||
|
void SetSortColumn(BColumn* column, bool add,
|
||||||
|
bool ascending);
|
||||||
|
void ClearSortColumns();
|
||||||
|
|
||||||
|
// The status view is a little area in the lower left hand corner.
|
||||||
|
void AddStatusView(BView* view);
|
||||||
|
BView* RemoveStatusView();
|
||||||
|
|
||||||
|
// Column Manipulation
|
||||||
|
void AddColumn(BColumn* column,
|
||||||
|
int32 logicalFieldIndex);
|
||||||
|
void MoveColumn(BColumn* column, int32 index);
|
||||||
|
void RemoveColumn(BColumn* column);
|
||||||
|
int32 CountColumns() const;
|
||||||
|
BColumn* ColumnAt(int32 index) const;
|
||||||
|
BColumn* ColumnAt(BPoint point) const;
|
||||||
|
void SetColumnVisible(BColumn* column,
|
||||||
|
bool isVisible);
|
||||||
|
void SetColumnVisible(int32, bool);
|
||||||
|
bool IsColumnVisible(int32) const;
|
||||||
|
void SetColumnFlags(column_flags flags);
|
||||||
|
void ResizeColumnToPreferred(int32 index);
|
||||||
|
void ResizeAllColumnsToPreferred();
|
||||||
|
|
||||||
|
// Row manipulation
|
||||||
|
const BRow* RowAt(int32 index, BRow *parent = 0) const;
|
||||||
|
BRow* RowAt(int32 index, BRow *parent = 0);
|
||||||
|
const BRow* RowAt(BPoint) const;
|
||||||
|
BRow* RowAt(BPoint);
|
||||||
|
bool GetRowRect(const BRow* row, BRect* _rect) const;
|
||||||
|
bool FindParent(BRow* row, BRow** _parent,
|
||||||
|
bool *_isVisible) const;
|
||||||
|
int32 IndexOf(BRow* row);
|
||||||
|
int32 CountRows(BRow* parent = 0) const;
|
||||||
|
void AddRow(BRow* row, BRow* parent = NULL);
|
||||||
|
void AddRow(BRow* row, int32 index,
|
||||||
|
BRow* parent = NULL);
|
||||||
|
|
||||||
|
void ScrollTo(const BRow* Row);
|
||||||
|
void ScrollTo(BPoint point);
|
||||||
|
|
||||||
|
// Does not delete row or children at this time.
|
||||||
|
// todo: Make delete row and children
|
||||||
|
void RemoveRow(BRow* row);
|
||||||
|
|
||||||
|
void UpdateRow(BRow* row);
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
// Appearance (DEPRECATED)
|
||||||
|
void GetFont(BFont* font) const
|
||||||
|
{ BView::GetFont(font); }
|
||||||
|
virtual void SetFont(const BFont* font,
|
||||||
|
uint32 mask = B_FONT_ALL);
|
||||||
|
virtual void SetHighColor(rgb_color);
|
||||||
|
void SetSelectionColor(rgb_color);
|
||||||
|
void SetBackgroundColor(rgb_color);
|
||||||
|
void SetEditColor(rgb_color);
|
||||||
|
const rgb_color SelectionColor() const;
|
||||||
|
const rgb_color BackgroundColor() const;
|
||||||
|
const rgb_color EditColor() const;
|
||||||
|
|
||||||
|
// Appearance (NEW STYLE)
|
||||||
|
void SetColor(ColumnListViewColor colorIndex,
|
||||||
|
rgb_color color);
|
||||||
|
void SetFont(ColumnListViewFont fontIndex,
|
||||||
|
const BFont* font,
|
||||||
|
uint32 mask = B_FONT_ALL);
|
||||||
|
rgb_color Color(ColumnListViewColor colorIndex) const;
|
||||||
|
void GetFont(ColumnListViewFont fontIndex,
|
||||||
|
BFont* font) const;
|
||||||
|
|
||||||
|
BPoint SuggestTextPosition(const BRow* row,
|
||||||
|
const BColumn* column = NULL) const;
|
||||||
|
|
||||||
|
void SetLatchWidth(float width);
|
||||||
|
float LatchWidth() const;
|
||||||
|
virtual void DrawLatch(BView* view, BRect frame,
|
||||||
|
LatchType type, BRow* row);
|
||||||
|
virtual void MakeFocus(bool isfocus = true);
|
||||||
|
void SaveState(BMessage* archive);
|
||||||
|
void LoadState(BMessage* archive);
|
||||||
|
|
||||||
|
BView* ScrollView() const
|
||||||
|
{ return (BView*)fOutlineView; }
|
||||||
|
void SetEditMode(bool state);
|
||||||
|
void Refresh();
|
||||||
|
|
||||||
|
virtual BSize MinSize();
|
||||||
|
virtual BSize PreferredSize();
|
||||||
|
virtual BSize MaxSize();
|
||||||
|
|
||||||
|
virtual void InvalidateLayout(bool descendants = false);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
virtual void KeyDown(const char* bytes, int32 numBytes);
|
||||||
|
virtual void AttachedToWindow();
|
||||||
|
virtual void WindowActivated(bool active);
|
||||||
|
virtual void Draw(BRect updateRect);
|
||||||
|
|
||||||
|
virtual void DoLayout();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void _Init(bool showHorizontalScrollbar);
|
||||||
|
void _GetChildViewRects(const BRect& bounds,
|
||||||
|
bool showHorizontalScrollBar,
|
||||||
|
BRect& titleRect, BRect& outlineRect,
|
||||||
|
BRect& vScrollBarRect,
|
||||||
|
BRect& hScrollBarRect);
|
||||||
|
|
||||||
|
rgb_color fColorList[B_COLOR_TOTAL];
|
||||||
|
BPrivate::TitleView* fTitleView;
|
||||||
|
BPrivate::OutlineView* fOutlineView;
|
||||||
|
BList fColumns;
|
||||||
|
BScrollBar* fHorizontalScrollBar;
|
||||||
|
BScrollBar* fVerticalScrollBar;
|
||||||
|
BList fSortColumns;
|
||||||
|
BView* fStatusView;
|
||||||
|
BMessage* fSelectionMessage;
|
||||||
|
bool fSortingEnabled;
|
||||||
|
float fLatchWidth;
|
||||||
|
border_style fBorderStyle;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _COLUMN_LIST_VIEW_H
|
||||||
704
src/column/ColumnTypes.cpp
Normal file
704
src/column/ColumnTypes.cpp
Normal file
@@ -0,0 +1,704 @@
|
|||||||
|
/*
|
||||||
|
Open Tracker License
|
||||||
|
|
||||||
|
Terms and Conditions
|
||||||
|
|
||||||
|
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice applies to all licensees
|
||||||
|
and shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||||
|
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||||
|
this Software without prior written authorization from Be Incorporated.
|
||||||
|
|
||||||
|
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||||
|
of Be Incorporated in the United States and other countries. Other brand product
|
||||||
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
|
All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
/
|
||||||
|
/ File: ColumnTypes.h
|
||||||
|
/
|
||||||
|
/ Description: Experimental classes that implement particular column/field
|
||||||
|
/ data types for use in BColumnListView.
|
||||||
|
/
|
||||||
|
/ Copyright 2000+, Be Incorporated, All Rights Reserved
|
||||||
|
/
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "ColumnTypes.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include <parsedate.h>
|
||||||
|
|
||||||
|
#define kTEXT_MARGIN 8
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BTitledColumn::BTitledColumn(const char* title, float width, float minWidth,
|
||||||
|
float maxWidth, alignment align)
|
||||||
|
:BColumn(width, minWidth, maxWidth, align),
|
||||||
|
fTitle(title)
|
||||||
|
{
|
||||||
|
font_height fh;
|
||||||
|
|
||||||
|
be_plain_font->GetHeight(&fh);
|
||||||
|
fFontHeight = fh.descent + fh.leading;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BTitledColumn::DrawTitle(BRect rect, BView* parent)
|
||||||
|
{
|
||||||
|
float width = rect.Width() - (2 * kTEXT_MARGIN);
|
||||||
|
BString out_string(fTitle);
|
||||||
|
|
||||||
|
parent->TruncateString(&out_string, B_TRUNCATE_END, width + 2);
|
||||||
|
DrawString(out_string.String(), parent, rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BTitledColumn::GetColumnName(BString* into) const
|
||||||
|
{
|
||||||
|
*into = fTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BTitledColumn::DrawString(const char* string, BView* parent, BRect rect)
|
||||||
|
{
|
||||||
|
float width = rect.Width() - (2 * kTEXT_MARGIN);
|
||||||
|
float y;
|
||||||
|
BFont font;
|
||||||
|
font_height finfo;
|
||||||
|
|
||||||
|
parent->GetFont(&font);
|
||||||
|
font.GetHeight(&finfo);
|
||||||
|
y = rect.top + ((rect.Height() - (finfo.ascent + finfo.descent + finfo.leading)) / 2) +
|
||||||
|
(finfo.ascent + finfo.descent) - 2;
|
||||||
|
|
||||||
|
switch (Alignment())
|
||||||
|
{
|
||||||
|
case B_ALIGN_LEFT:
|
||||||
|
parent->MovePenTo(rect.left + kTEXT_MARGIN, y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_ALIGN_CENTER:
|
||||||
|
parent->MovePenTo(rect.left + kTEXT_MARGIN + ((width - font.StringWidth(string)) / 2), y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_ALIGN_RIGHT:
|
||||||
|
parent->MovePenTo(rect.right - kTEXT_MARGIN - font.StringWidth(string), y);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
parent->DrawString(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BTitledColumn::SetTitle(const char* title)
|
||||||
|
{
|
||||||
|
fTitle.SetTo(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BTitledColumn::Title(BString* forTitle) const
|
||||||
|
{
|
||||||
|
if (forTitle)
|
||||||
|
forTitle->SetTo(fTitle.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
float BTitledColumn::FontHeight() const
|
||||||
|
{
|
||||||
|
return fFontHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BStringField::BStringField(const char* string)
|
||||||
|
:fWidth(0),
|
||||||
|
fString(string),
|
||||||
|
fClippedString(string)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BStringField::SetString(const char* val)
|
||||||
|
{
|
||||||
|
fString = val;
|
||||||
|
fClippedString = "";
|
||||||
|
fWidth = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
const char* BStringField::String() const
|
||||||
|
{
|
||||||
|
return fString.String();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BStringField::SetWidth(float width)
|
||||||
|
{
|
||||||
|
fWidth = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
float BStringField::Width()
|
||||||
|
{
|
||||||
|
return fWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BStringField::SetClippedString(const char* val)
|
||||||
|
{
|
||||||
|
fClippedString = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
const char* BStringField::ClippedString()
|
||||||
|
{
|
||||||
|
return fClippedString.String();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BStringColumn::BStringColumn(const char* title, float width, float minWidth,
|
||||||
|
float maxWidth, uint32 truncate, alignment align)
|
||||||
|
:BTitledColumn(title, width, minWidth, maxWidth, align),
|
||||||
|
fTruncate(truncate)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BStringColumn::DrawField(BField* _field, BRect rect, BView* parent)
|
||||||
|
{
|
||||||
|
float width = rect.Width() - (2 * kTEXT_MARGIN);
|
||||||
|
BStringField* field = static_cast<BStringField*>(_field);
|
||||||
|
|
||||||
|
if (width != field->Width())
|
||||||
|
{
|
||||||
|
BString out_string(field->String());
|
||||||
|
|
||||||
|
parent->TruncateString(&out_string, fTruncate, width + 2);
|
||||||
|
field->SetClippedString(out_string.String());
|
||||||
|
field->SetWidth(width);
|
||||||
|
}
|
||||||
|
DrawString(field->ClippedString(), parent, rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
int BStringColumn::CompareFields(BField* field1, BField* field2)
|
||||||
|
{
|
||||||
|
return(ICompare(((BStringField*)field1)->String(),
|
||||||
|
(((BStringField*)field2)->String())));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool BStringColumn::AcceptsField(const BField *field) const
|
||||||
|
{
|
||||||
|
return static_cast<bool>(dynamic_cast<const BStringField*>(field));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BDateField::BDateField(time_t *t)
|
||||||
|
:fTime(*localtime(t)),
|
||||||
|
fUnixTime(*t),
|
||||||
|
fSeconds(0),
|
||||||
|
fClippedString(""),
|
||||||
|
fWidth(0)
|
||||||
|
{
|
||||||
|
fSeconds = mktime(&fTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BDateField::SetWidth(float width)
|
||||||
|
{
|
||||||
|
fWidth = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
float BDateField::Width()
|
||||||
|
{
|
||||||
|
return fWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BDateField::SetClippedString(const char* val)
|
||||||
|
{
|
||||||
|
fClippedString = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
const char* BDateField::ClippedString()
|
||||||
|
{
|
||||||
|
return fClippedString.String();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
time_t BDateField::Seconds()
|
||||||
|
{
|
||||||
|
return fSeconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
time_t BDateField::UnixTime()
|
||||||
|
{
|
||||||
|
return fUnixTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BDateColumn::BDateColumn(const char* title, float width, float minWidth,
|
||||||
|
float maxWidth, alignment align)
|
||||||
|
:BTitledColumn(title, width, minWidth, maxWidth, align),
|
||||||
|
fTitle(title)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
const char *kTIME_FORMATS[] = {
|
||||||
|
"%A, %B %d %Y, %I:%M:%S %p", // Monday, July 09 1997, 05:08:15 PM
|
||||||
|
"%a, %b %d %Y, %I:%M:%S %p", // Mon, Jul 09 1997, 05:08:15 PM
|
||||||
|
"%a, %b %d %Y, %I:%M %p", // Mon, Jul 09 1997, 05:08 PM
|
||||||
|
"%b %d %Y, %I:%M %p", // Jul 09 1997, 05:08 PM
|
||||||
|
"%m/%d/%y, %I:%M %p", // 07/09/97, 05:08 PM
|
||||||
|
"%m/%d/%y", // 07/09/97
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
void BDateColumn::DrawField(BField* _field, BRect rect, BView* parent)
|
||||||
|
{
|
||||||
|
float width = rect.Width() - (2 * kTEXT_MARGIN);
|
||||||
|
BDateField* field = (BDateField*)_field;
|
||||||
|
|
||||||
|
if (field->Width() != rect.Width())
|
||||||
|
{
|
||||||
|
char dateString[256];
|
||||||
|
time_t curtime = field->UnixTime();
|
||||||
|
tm time_data;
|
||||||
|
BFont font;
|
||||||
|
|
||||||
|
parent->GetFont(&font);
|
||||||
|
localtime_r(&curtime, &time_data);
|
||||||
|
for (int32 index = 0; ; index++)
|
||||||
|
{
|
||||||
|
if (!kTIME_FORMATS[index])
|
||||||
|
break;
|
||||||
|
strftime(dateString, 256, kTIME_FORMATS[index], &time_data);
|
||||||
|
if (font.StringWidth(dateString) <= width)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (font.StringWidth(dateString) > width)
|
||||||
|
{
|
||||||
|
BString out_string(dateString);
|
||||||
|
|
||||||
|
parent->TruncateString(&out_string, B_TRUNCATE_MIDDLE, width + 2);
|
||||||
|
strcpy(dateString, out_string.String());
|
||||||
|
}
|
||||||
|
field->SetClippedString(dateString);
|
||||||
|
field->SetWidth(width);
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawString(field->ClippedString(), parent, rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
int BDateColumn::CompareFields(BField* field1, BField* field2)
|
||||||
|
{
|
||||||
|
return((BDateField*)field1)->Seconds() - ((BDateField*)field2)->Seconds();
|
||||||
|
}
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BSizeField::BSizeField(off_t size)
|
||||||
|
:fSize(size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BSizeField::SetSize(off_t size)
|
||||||
|
{
|
||||||
|
fSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
off_t BSizeField::Size()
|
||||||
|
{
|
||||||
|
return fSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BSizeColumn::BSizeColumn(const char* title, float width, float minWidth,
|
||||||
|
float maxWidth, alignment align)
|
||||||
|
:BTitledColumn(title, width, minWidth, maxWidth, align)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
const int64 kKB_SIZE = 1024;
|
||||||
|
const int64 kMB_SIZE = 1048576;
|
||||||
|
const int64 kGB_SIZE = 1073741824;
|
||||||
|
const int64 kTB_SIZE = kGB_SIZE * kKB_SIZE;
|
||||||
|
|
||||||
|
const char *kSIZE_FORMATS[] = {
|
||||||
|
"%.2f %s",
|
||||||
|
"%.1f %s",
|
||||||
|
"%.f %s",
|
||||||
|
"%.f%s",
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
void BSizeColumn::DrawField(BField* _field, BRect rect, BView* parent)
|
||||||
|
{
|
||||||
|
char str[256];
|
||||||
|
float width = rect.Width() - (2 * kTEXT_MARGIN);
|
||||||
|
BFont font;
|
||||||
|
BString string;
|
||||||
|
off_t size = ((BSizeField*)_field)->Size();
|
||||||
|
|
||||||
|
parent->GetFont(&font);
|
||||||
|
if (size < kKB_SIZE)
|
||||||
|
{
|
||||||
|
sprintf(str, "%Ld bytes", size);
|
||||||
|
if (font.StringWidth(str) > width)
|
||||||
|
sprintf(str, "%Ld B", size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const char* suffix;
|
||||||
|
float float_value;
|
||||||
|
if (size >= kTB_SIZE)
|
||||||
|
{
|
||||||
|
suffix = "TB";
|
||||||
|
float_value = (float)size / kTB_SIZE;
|
||||||
|
}
|
||||||
|
else if (size >= kGB_SIZE)
|
||||||
|
{
|
||||||
|
suffix = "GB";
|
||||||
|
float_value = (float)size / kGB_SIZE;
|
||||||
|
}
|
||||||
|
else if (size >= kMB_SIZE)
|
||||||
|
{
|
||||||
|
suffix = "MB";
|
||||||
|
float_value = (float)size / kMB_SIZE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
suffix = "KB";
|
||||||
|
float_value = (float)size / kKB_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int32 index = 0; ; index++)
|
||||||
|
{
|
||||||
|
if (!kSIZE_FORMATS[index])
|
||||||
|
break;
|
||||||
|
|
||||||
|
sprintf(str, kSIZE_FORMATS[index], float_value, suffix);
|
||||||
|
// strip off an insignificant zero so we don't get readings
|
||||||
|
// such as 1.00
|
||||||
|
char *period = 0;
|
||||||
|
char *tmp (NULL);
|
||||||
|
for (tmp = str; *tmp; tmp++)
|
||||||
|
{
|
||||||
|
if (*tmp == '.')
|
||||||
|
period = tmp;
|
||||||
|
}
|
||||||
|
if (period && period[1] && period[2] == '0')
|
||||||
|
// move the rest of the string over the insignificant zero
|
||||||
|
for (tmp = &period[2]; *tmp; tmp++)
|
||||||
|
*tmp = tmp[1];
|
||||||
|
if (font.StringWidth(str) <= width)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string = str;
|
||||||
|
parent->TruncateString(&string, B_TRUNCATE_MIDDLE, width + 2);
|
||||||
|
DrawString(string.String(), parent, rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
int BSizeColumn::CompareFields(BField* field1, BField* field2)
|
||||||
|
{
|
||||||
|
return ((BSizeField*)field1)->Size() - ((BSizeField*)field2)->Size();
|
||||||
|
}
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BIntegerField::BIntegerField(int32 number)
|
||||||
|
:fInteger(number)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BIntegerField::SetValue(int32 value)
|
||||||
|
{
|
||||||
|
fInteger = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
int32 BIntegerField::Value()
|
||||||
|
{
|
||||||
|
return fInteger;
|
||||||
|
}
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BIntegerColumn::BIntegerColumn(const char* title, float width, float minWidth,
|
||||||
|
float maxWidth, alignment align)
|
||||||
|
:BTitledColumn(title, width, minWidth, maxWidth, align)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BIntegerColumn::DrawField(BField *field, BRect rect, BView* parent)
|
||||||
|
{
|
||||||
|
char formatted[256];
|
||||||
|
float width = rect.Width() - (2 * kTEXT_MARGIN);
|
||||||
|
BString string;
|
||||||
|
|
||||||
|
sprintf(formatted, "%d", (int)((BIntegerField*)field)->Value());
|
||||||
|
|
||||||
|
string = formatted;
|
||||||
|
parent->TruncateString(&string, B_TRUNCATE_MIDDLE, width + 2);
|
||||||
|
DrawString(string.String(), parent, rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
int BIntegerColumn::CompareFields(BField *field1, BField *field2)
|
||||||
|
{
|
||||||
|
return (((BIntegerField*)field1)->Value() - ((BIntegerField*)field2)->Value());
|
||||||
|
}
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
GraphColumn::GraphColumn(const char* name, float width, float minWidth,
|
||||||
|
float maxWidth, alignment align)
|
||||||
|
:BIntegerColumn(name, width, minWidth, maxWidth, align)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void GraphColumn::DrawField(BField* field, BRect rect, BView* parent)
|
||||||
|
{
|
||||||
|
int number = ((BIntegerField*)field)->Value();
|
||||||
|
|
||||||
|
if (number > 100)
|
||||||
|
number = 100;
|
||||||
|
else if (number < 0)
|
||||||
|
number = 0;
|
||||||
|
|
||||||
|
BRect graphRect(rect);
|
||||||
|
graphRect.InsetBy(5, 3);
|
||||||
|
parent->StrokeRect(graphRect);
|
||||||
|
if (number > 0) {
|
||||||
|
graphRect.InsetBy(1, 1);
|
||||||
|
float val = graphRect.Width() * (float) number / 100;
|
||||||
|
graphRect.right = graphRect.left + val;
|
||||||
|
parent->SetHighColor(0, 0, 190);
|
||||||
|
parent->FillRect(graphRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent->SetDrawingMode(B_OP_INVERT);
|
||||||
|
parent->SetHighColor(128, 128, 128);
|
||||||
|
char numstr[256];
|
||||||
|
sprintf(numstr, "%d%%", number);
|
||||||
|
|
||||||
|
float width = be_plain_font->StringWidth(numstr);
|
||||||
|
parent->MovePenTo(rect.left + rect.Width() / 2 - width / 2, rect.bottom - FontHeight());
|
||||||
|
parent->DrawString(numstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BBitmapField::BBitmapField(BBitmap *bitmap)
|
||||||
|
:fBitmap(bitmap)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
const BBitmap* BBitmapField::Bitmap()
|
||||||
|
{
|
||||||
|
return fBitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BBitmapField::SetBitmap(BBitmap* bitmap)
|
||||||
|
{
|
||||||
|
fBitmap = bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BBitmapColumn::BBitmapColumn(const char* title, float width, float minWidth,
|
||||||
|
float maxWidth, alignment align)
|
||||||
|
:BTitledColumn(title, width, minWidth, maxWidth, align)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BBitmapColumn::DrawField(BField* field, BRect rect, BView* parent)
|
||||||
|
{
|
||||||
|
BBitmapField *bitmapField = static_cast<BBitmapField *>(field);
|
||||||
|
const BBitmap *bitmap = bitmapField->Bitmap();
|
||||||
|
|
||||||
|
if (bitmap != NULL)
|
||||||
|
{
|
||||||
|
float x = 0.0;
|
||||||
|
float y;
|
||||||
|
BRect r = bitmap->Bounds();
|
||||||
|
|
||||||
|
y = rect.top + ((rect.Height() - r.Height()) / 2);
|
||||||
|
|
||||||
|
switch (Alignment())
|
||||||
|
{
|
||||||
|
case B_ALIGN_LEFT:
|
||||||
|
x = rect.left + kTEXT_MARGIN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_ALIGN_CENTER:
|
||||||
|
x = rect.left + ((rect.Width() - r.Width()) / 2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_ALIGN_RIGHT:
|
||||||
|
x = rect.right - kTEXT_MARGIN - r.Width();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
parent->SetDrawingMode(B_OP_ALPHA);
|
||||||
|
parent->DrawBitmap(bitmap, BPoint(x, y));
|
||||||
|
parent->SetDrawingMode(B_OP_OVER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
int BBitmapColumn::CompareFields(BField* /*field1*/, BField* /*field2*/)
|
||||||
|
{
|
||||||
|
// Comparing bitmaps doesn't really make sense...
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool
|
||||||
|
BBitmapColumn::AcceptsField(const BField *field) const
|
||||||
|
{
|
||||||
|
return static_cast<bool>(dynamic_cast<const BBitmapField*>(field));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
289
src/column/ColumnTypes.h
Normal file
289
src/column/ColumnTypes.h
Normal file
@@ -0,0 +1,289 @@
|
|||||||
|
/*
|
||||||
|
Open Tracker License
|
||||||
|
|
||||||
|
Terms and Conditions
|
||||||
|
|
||||||
|
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice applies to all licensees
|
||||||
|
and shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||||
|
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||||
|
this Software without prior written authorization from Be Incorporated.
|
||||||
|
|
||||||
|
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||||
|
of Be Incorporated in the United States and other countries. Other brand product
|
||||||
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
|
All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
/
|
||||||
|
/ File: ColumnTypes.h
|
||||||
|
/
|
||||||
|
/ Description: Experimental classes that implement particular column/field
|
||||||
|
/ data types for use in BColumnListView.
|
||||||
|
/
|
||||||
|
/ Copyright 2000+, Be Incorporated, All Rights Reserved
|
||||||
|
/
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _COLUMN_TYPES_H
|
||||||
|
#define _COLUMN_TYPES_H
|
||||||
|
|
||||||
|
#include "ColumnListView.h"
|
||||||
|
#include <String.h>
|
||||||
|
#include <Font.h>
|
||||||
|
#include <Bitmap.h>
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
// Common base-class: a column that draws a standard title at its top.
|
||||||
|
|
||||||
|
class BTitledColumn : public BColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BTitledColumn (const char *title,
|
||||||
|
float width,
|
||||||
|
float minWidth,
|
||||||
|
float maxWidth,
|
||||||
|
alignment align = B_ALIGN_LEFT);
|
||||||
|
virtual void DrawTitle (BRect rect,
|
||||||
|
BView* parent);
|
||||||
|
virtual void GetColumnName (BString* into) const;
|
||||||
|
|
||||||
|
void DrawString (const char*,
|
||||||
|
BView*,
|
||||||
|
BRect);
|
||||||
|
void SetTitle (const char* title);
|
||||||
|
void Title (BString* forTitle) const; // sets the BString arg to be the title
|
||||||
|
float FontHeight () const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
float fFontHeight;
|
||||||
|
BString fTitle;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
// Field and column classes for strings.
|
||||||
|
|
||||||
|
class BStringField : public BField
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BStringField (const char* string);
|
||||||
|
|
||||||
|
void SetString (const char* string);
|
||||||
|
const char* String () const;
|
||||||
|
void SetClippedString (const char* string);
|
||||||
|
const char* ClippedString ();
|
||||||
|
void SetWidth (float);
|
||||||
|
float Width ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
float fWidth;
|
||||||
|
BString fString;
|
||||||
|
BString fClippedString;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
class BStringColumn : public BTitledColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BStringColumn (const char *title,
|
||||||
|
float width,
|
||||||
|
float maxWidth,
|
||||||
|
float minWidth,
|
||||||
|
uint32 truncate,
|
||||||
|
alignment align = B_ALIGN_LEFT);
|
||||||
|
virtual void DrawField (BField* field,
|
||||||
|
BRect rect,
|
||||||
|
BView* parent);
|
||||||
|
virtual int CompareFields (BField* field1,
|
||||||
|
BField* field2);
|
||||||
|
virtual bool AcceptsField (const BField* field) const;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32 fTruncate;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
// Field and column classes for dates.
|
||||||
|
|
||||||
|
class BDateField : public BField
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BDateField (time_t* t);
|
||||||
|
void SetWidth (float);
|
||||||
|
float Width ();
|
||||||
|
void SetClippedString (const char*);
|
||||||
|
const char* ClippedString ();
|
||||||
|
time_t Seconds ();
|
||||||
|
time_t UnixTime ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct tm fTime;
|
||||||
|
time_t fUnixTime;
|
||||||
|
time_t fSeconds;
|
||||||
|
BString fClippedString;
|
||||||
|
float fWidth;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
class BDateColumn : public BTitledColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BDateColumn (const char* title,
|
||||||
|
float width,
|
||||||
|
float minWidth,
|
||||||
|
float maxWidth,
|
||||||
|
alignment align = B_ALIGN_LEFT);
|
||||||
|
virtual void DrawField (BField* field,
|
||||||
|
BRect rect,
|
||||||
|
BView* parent);
|
||||||
|
virtual int CompareFields (BField* field1,
|
||||||
|
BField* field2);
|
||||||
|
private:
|
||||||
|
BString fTitle;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
// Field and column classes for numeric sizes.
|
||||||
|
|
||||||
|
class BSizeField : public BField
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BSizeField (off_t size);
|
||||||
|
void SetSize (off_t);
|
||||||
|
off_t Size ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
off_t fSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
class BSizeColumn : public BTitledColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BSizeColumn (const char* title,
|
||||||
|
float width,
|
||||||
|
float minWidth,
|
||||||
|
float maxWidth,
|
||||||
|
alignment align = B_ALIGN_LEFT);
|
||||||
|
virtual void DrawField (BField* field,
|
||||||
|
BRect rect,
|
||||||
|
BView* parent);
|
||||||
|
virtual int CompareFields (BField* field1,
|
||||||
|
BField* field2);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
// Field and column classes for integers.
|
||||||
|
|
||||||
|
class BIntegerField : public BField
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BIntegerField (int32 number);
|
||||||
|
void SetValue (int32);
|
||||||
|
int32 Value ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32 fInteger;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
class BIntegerColumn : public BTitledColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BIntegerColumn (const char* title,
|
||||||
|
float width,
|
||||||
|
float minWidth,
|
||||||
|
float maxWidth,
|
||||||
|
alignment align = B_ALIGN_LEFT);
|
||||||
|
virtual void DrawField (BField* field,
|
||||||
|
BRect rect,
|
||||||
|
BView* parent);
|
||||||
|
virtual int CompareFields (BField* field1,
|
||||||
|
BField* field2);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
// Field and column classes for bitmaps
|
||||||
|
|
||||||
|
class BBitmapField : public BField
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BBitmapField (BBitmap* bitmap);
|
||||||
|
const BBitmap* Bitmap ();
|
||||||
|
void SetBitmap (BBitmap* bitmap);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BBitmap* fBitmap;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
class BBitmapColumn : public BTitledColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BBitmapColumn (const char* title,
|
||||||
|
float width,
|
||||||
|
float minWidth,
|
||||||
|
float maxWidth,
|
||||||
|
alignment align = B_ALIGN_LEFT);
|
||||||
|
virtual void DrawField (BField*field,
|
||||||
|
BRect rect,
|
||||||
|
BView* parent);
|
||||||
|
virtual int CompareFields (BField* field1, BField* field2);
|
||||||
|
virtual bool AcceptsField (const BField* field) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
// Column to display BIntegerField objects as a graph.
|
||||||
|
|
||||||
|
class GraphColumn : public BIntegerColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GraphColumn (const char* name,
|
||||||
|
float width,
|
||||||
|
float minWidth,
|
||||||
|
float maxWidth,
|
||||||
|
alignment align = B_ALIGN_LEFT);
|
||||||
|
virtual void DrawField (BField*field,
|
||||||
|
BRect rect,
|
||||||
|
BView* parent);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
800
src/column/ObjectList.h
Normal file
800
src/column/ObjectList.h
Normal file
@@ -0,0 +1,800 @@
|
|||||||
|
/*
|
||||||
|
Open Tracker License
|
||||||
|
|
||||||
|
Terms and Conditions
|
||||||
|
|
||||||
|
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice applies to all licensees
|
||||||
|
and shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||||
|
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||||
|
this Software without prior written authorization from Be Incorporated.
|
||||||
|
|
||||||
|
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||||
|
of Be Incorporated in the United States and other countries. Other brand product
|
||||||
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
|
All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING **
|
||||||
|
** **
|
||||||
|
** DANGER, WILL ROBINSON! **
|
||||||
|
** **
|
||||||
|
** The interfaces contained here are part of BeOS's **
|
||||||
|
** **
|
||||||
|
** >> PRIVATE NOT FOR PUBLIC USE << **
|
||||||
|
** **
|
||||||
|
** implementation. **
|
||||||
|
** **
|
||||||
|
** These interfaces WILL CHANGE in future releases. **
|
||||||
|
** If you use them, your app WILL BREAK at some future time. **
|
||||||
|
** **
|
||||||
|
** (And yes, this does mean that binaries built from OpenTracker will not **
|
||||||
|
** be compatible with some future releases of the OS. When that happens, **
|
||||||
|
** we will provide an updated version of this file to keep compatibility.) **
|
||||||
|
** **
|
||||||
|
** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING **
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
//
|
||||||
|
// ObjectList is a wrapper around BList that adds type safety,
|
||||||
|
// optional object ownership, search, insert operations, etc.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef __OBJECT_LIST__
|
||||||
|
#define __OBJECT_LIST__
|
||||||
|
|
||||||
|
#ifndef _BE_H
|
||||||
|
#include <List.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Debug.h>
|
||||||
|
|
||||||
|
template<class T> class BObjectList;
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
struct UnaryPredicate {
|
||||||
|
|
||||||
|
virtual int operator()(const T *) const
|
||||||
|
// virtual could be avoided here if FindBinaryInsertionIndex,
|
||||||
|
// etc. were member template functions
|
||||||
|
{ return 0; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
static int _unary_predicate_glue(const void *item, void *context);
|
||||||
|
|
||||||
|
friend class BObjectList<T>;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
int
|
||||||
|
UnaryPredicate<T>::_unary_predicate_glue(const void *item, void *context)
|
||||||
|
{
|
||||||
|
return ((UnaryPredicate<T> *)context)->operator()((const T *)item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class _PointerList_ : public BList {
|
||||||
|
public:
|
||||||
|
_PointerList_(const _PointerList_ &list);
|
||||||
|
_PointerList_(int32 itemsPerBlock = 20, bool owning = false);
|
||||||
|
~_PointerList_();
|
||||||
|
|
||||||
|
typedef void *(* GenericEachFunction)(void *, void *);
|
||||||
|
typedef int (* GenericCompareFunction)(const void *, const void *);
|
||||||
|
typedef int (* GenericCompareFunctionWithState)(const void *, const void *,
|
||||||
|
void *);
|
||||||
|
typedef int (* UnaryPredicateGlue)(const void *, void *);
|
||||||
|
|
||||||
|
void *EachElement(GenericEachFunction, void *);
|
||||||
|
void SortItems(GenericCompareFunction);
|
||||||
|
void SortItems(GenericCompareFunctionWithState, void *state);
|
||||||
|
void HSortItems(GenericCompareFunction);
|
||||||
|
void HSortItems(GenericCompareFunctionWithState, void *state);
|
||||||
|
|
||||||
|
void *BinarySearch(const void *, GenericCompareFunction) const;
|
||||||
|
void *BinarySearch(const void *, GenericCompareFunctionWithState, void *state) const;
|
||||||
|
|
||||||
|
int32 BinarySearchIndex(const void *, GenericCompareFunction) const;
|
||||||
|
int32 BinarySearchIndex(const void *, GenericCompareFunctionWithState, void *state) const;
|
||||||
|
int32 BinarySearchIndexByPredicate(const void *, UnaryPredicateGlue) const;
|
||||||
|
|
||||||
|
bool Owning() const;
|
||||||
|
bool ReplaceItem(int32, void *);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool owning;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
class BObjectList : private _PointerList_ {
|
||||||
|
public:
|
||||||
|
|
||||||
|
// iteration and sorting
|
||||||
|
typedef T *(* EachFunction)(T *, void *);
|
||||||
|
typedef const T *(* ConstEachFunction)(const T *, void *);
|
||||||
|
typedef int (* CompareFunction)(const T *, const T *);
|
||||||
|
typedef int (* CompareFunctionWithState)(const T *, const T *, void *state);
|
||||||
|
|
||||||
|
BObjectList(int32 itemsPerBlock = 20, bool owning = false);
|
||||||
|
BObjectList(const BObjectList &list);
|
||||||
|
// clones list; if list is owning, makes copies of all
|
||||||
|
// the items
|
||||||
|
|
||||||
|
virtual ~BObjectList();
|
||||||
|
|
||||||
|
BObjectList &operator=(const BObjectList &list);
|
||||||
|
// clones list; if list is owning, makes copies of all
|
||||||
|
// the items
|
||||||
|
|
||||||
|
// adding and removing
|
||||||
|
// ToDo:
|
||||||
|
// change Add calls to return const item
|
||||||
|
bool AddItem(T *);
|
||||||
|
bool AddItem(T *, int32);
|
||||||
|
bool AddList(BObjectList *);
|
||||||
|
bool AddList(BObjectList *, int32);
|
||||||
|
|
||||||
|
bool RemoveItem(T *, bool deleteIfOwning = true);
|
||||||
|
// if owning, deletes the removed item
|
||||||
|
T *RemoveItemAt(int32);
|
||||||
|
// returns the removed item
|
||||||
|
|
||||||
|
void MakeEmpty();
|
||||||
|
|
||||||
|
// item access
|
||||||
|
T *ItemAt(int32) const;
|
||||||
|
|
||||||
|
bool ReplaceItem(int32 index, T *);
|
||||||
|
// if list is owning, deletes the item at <index> first
|
||||||
|
T *SwapWithItem(int32 index, T *newItem);
|
||||||
|
// same as ReplaceItem, except does not delete old item at <index>,
|
||||||
|
// returns it instead
|
||||||
|
|
||||||
|
T *FirstItem() const;
|
||||||
|
T *LastItem() const;
|
||||||
|
|
||||||
|
// misc. getters
|
||||||
|
int32 IndexOf(const T *) const;
|
||||||
|
bool HasItem(const T *) const;
|
||||||
|
bool IsEmpty() const;
|
||||||
|
int32 CountItems() const;
|
||||||
|
|
||||||
|
T *EachElement(EachFunction, void *);
|
||||||
|
const T *EachElement(ConstEachFunction, void *) const;
|
||||||
|
|
||||||
|
void SortItems(CompareFunction);
|
||||||
|
void SortItems(CompareFunctionWithState, void *state);
|
||||||
|
void HSortItems(CompareFunction);
|
||||||
|
void HSortItems(CompareFunctionWithState, void *state);
|
||||||
|
|
||||||
|
// linear search, returns first item that matches predicate
|
||||||
|
const T *FindIf(const UnaryPredicate<T> &) const;
|
||||||
|
T *FindIf(const UnaryPredicate<T> &);
|
||||||
|
|
||||||
|
// list must be sorted with CompareFunction for these to work
|
||||||
|
const T *BinarySearch(const T &, CompareFunction) const;
|
||||||
|
const T *BinarySearch(const T &, CompareFunctionWithState, void *state) const;
|
||||||
|
|
||||||
|
// Binary insertion - list must be sorted with CompareFunction for
|
||||||
|
// these to work
|
||||||
|
|
||||||
|
// simple insert
|
||||||
|
void BinaryInsert(T *, CompareFunction);
|
||||||
|
void BinaryInsert(T *, CompareFunctionWithState, void *state);
|
||||||
|
void BinaryInsert(T *, const UnaryPredicate<T> &);
|
||||||
|
|
||||||
|
// unique insert, returns false if item already in list
|
||||||
|
bool BinaryInsertUnique(T *, CompareFunction);
|
||||||
|
bool BinaryInsertUnique(T *, CompareFunctionWithState, void *state);
|
||||||
|
bool BinaryInsertUnique(T *, const UnaryPredicate<T> &);
|
||||||
|
|
||||||
|
// insert a copy of the item, returns new inserted item
|
||||||
|
T *BinaryInsertCopy(const T ©This, CompareFunction);
|
||||||
|
T *BinaryInsertCopy(const T ©This, CompareFunctionWithState, void *state);
|
||||||
|
|
||||||
|
// insert a copy of the item if not in list already
|
||||||
|
// returns new inserted item or existing item in case of a conflict
|
||||||
|
T *BinaryInsertCopyUnique(const T ©This, CompareFunction);
|
||||||
|
T *BinaryInsertCopyUnique(const T ©This, CompareFunctionWithState, void *state);
|
||||||
|
|
||||||
|
|
||||||
|
int32 FindBinaryInsertionIndex(const UnaryPredicate<T> &, bool *alreadyInList = 0) const;
|
||||||
|
// returns either the index into which a new item should be inserted
|
||||||
|
// or index of an existing item that matches the predicate
|
||||||
|
|
||||||
|
// deprecated API, will go away
|
||||||
|
BList *AsBList()
|
||||||
|
{ return this; }
|
||||||
|
const BList *AsBList() const
|
||||||
|
{ return this; }
|
||||||
|
private:
|
||||||
|
void SetItem(int32, T *);
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class Item, class Result, class Param1>
|
||||||
|
Result
|
||||||
|
WhileEachListItem(BObjectList<Item> *list, Result (Item::*func)(Param1), Param1 p1)
|
||||||
|
{
|
||||||
|
Result result = 0;
|
||||||
|
int32 count = list->CountItems();
|
||||||
|
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
if ((result = (list->ItemAt(index)->*func)(p1)) != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Item, class Result, class Param1>
|
||||||
|
Result
|
||||||
|
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1), Param1 p1)
|
||||||
|
{
|
||||||
|
Result result = 0;
|
||||||
|
int32 count = list->CountItems();
|
||||||
|
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
if ((result = (*func)(list->ItemAt(index), p1)) != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Item, class Result, class Param1, class Param2>
|
||||||
|
Result
|
||||||
|
WhileEachListItem(BObjectList<Item> *list, Result (Item::*func)(Param1, Param2),
|
||||||
|
Param1 p1, Param2 p2)
|
||||||
|
{
|
||||||
|
Result result = 0;
|
||||||
|
int32 count = list->CountItems();
|
||||||
|
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
if ((result = (list->ItemAt(index)->*func)(p1, p2)) != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Item, class Result, class Param1, class Param2>
|
||||||
|
Result
|
||||||
|
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1, Param2),
|
||||||
|
Param1 p1, Param2 p2)
|
||||||
|
{
|
||||||
|
Result result = 0;
|
||||||
|
int32 count = list->CountItems();
|
||||||
|
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
if ((result = (*func)(list->ItemAt(index), p1, p2)) != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Item, class Result, class Param1, class Param2, class Param3, class Param4>
|
||||||
|
Result
|
||||||
|
WhileEachListItem(BObjectList<Item> *list, Result (*func)(Item *, Param1, Param2,
|
||||||
|
Param3, Param4), Param1 p1, Param2 p2, Param3 p3, Param4 p4)
|
||||||
|
{
|
||||||
|
Result result = 0;
|
||||||
|
int32 count = list->CountItems();
|
||||||
|
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
if ((result = (*func)(list->ItemAt(index), p1, p2, p3, p4)) != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Item, class Result>
|
||||||
|
void
|
||||||
|
EachListItemIgnoreResult(BObjectList<Item> *list, Result (Item::*func)())
|
||||||
|
{
|
||||||
|
int32 count = list->CountItems();
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
(list->ItemAt(index)->*func)();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Item, class Param1>
|
||||||
|
void
|
||||||
|
EachListItem(BObjectList<Item> *list, void (*func)(Item *, Param1), Param1 p1)
|
||||||
|
{
|
||||||
|
int32 count = list->CountItems();
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
(func)(list->ItemAt(index), p1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Item, class Param1, class Param2>
|
||||||
|
void
|
||||||
|
EachListItem(BObjectList<Item> *list, void (Item::*func)(Param1, Param2),
|
||||||
|
Param1 p1, Param2 p2)
|
||||||
|
{
|
||||||
|
int32 count = list->CountItems();
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
(list->ItemAt(index)->*func)(p1, p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Item, class Param1, class Param2>
|
||||||
|
void
|
||||||
|
EachListItem(BObjectList<Item> *list, void (*func)(Item *,Param1, Param2),
|
||||||
|
Param1 p1, Param2 p2)
|
||||||
|
{
|
||||||
|
int32 count = list->CountItems();
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
(func)(list->ItemAt(index), p1, p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Item, class Param1, class Param2, class Param3>
|
||||||
|
void
|
||||||
|
EachListItem(BObjectList<Item> *list, void (*func)(Item *,Param1, Param2,
|
||||||
|
Param3), Param1 p1, Param2 p2, Param3 p3)
|
||||||
|
{
|
||||||
|
int32 count = list->CountItems();
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
(func)(list->ItemAt(index), p1, p2, p3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Item, class Param1, class Param2, class Param3, class Param4>
|
||||||
|
void
|
||||||
|
EachListItem(BObjectList<Item> *list, void (*func)(Item *,Param1, Param2,
|
||||||
|
Param3, Param4), Param1 p1, Param2 p2, Param3 p3, Param4 p4)
|
||||||
|
{
|
||||||
|
int32 count = list->CountItems();
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
(func)(list->ItemAt(index), p1, p2, p3, p4);
|
||||||
|
}
|
||||||
|
|
||||||
|
// inline code
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
_PointerList_::Owning() const
|
||||||
|
{
|
||||||
|
return owning;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
BObjectList<T>::BObjectList(int32 itemsPerBlock, bool isOwning)
|
||||||
|
: _PointerList_(itemsPerBlock, isOwning)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
BObjectList<T>::BObjectList(const BObjectList<T> &list)
|
||||||
|
: _PointerList_(list)
|
||||||
|
{
|
||||||
|
owning = list.owning;
|
||||||
|
if (owning) {
|
||||||
|
// make our own copies in an owning list
|
||||||
|
int32 count = list.CountItems();
|
||||||
|
for (int32 index = 0; index < count; index++) {
|
||||||
|
T *item = list.ItemAt(index);
|
||||||
|
if (item)
|
||||||
|
item = new T(*item);
|
||||||
|
SetItem(index, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
BObjectList<T>::~BObjectList()
|
||||||
|
{
|
||||||
|
if (Owning())
|
||||||
|
// have to nuke elements first
|
||||||
|
MakeEmpty();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
BObjectList<T> &
|
||||||
|
BObjectList<T>::operator=(const BObjectList<T> &list)
|
||||||
|
{
|
||||||
|
owning = list.owning;
|
||||||
|
BObjectList<T> &result = (BObjectList<T> &)_PointerList_::operator=(list);
|
||||||
|
if (owning) {
|
||||||
|
// make our own copies in an owning list
|
||||||
|
int32 count = list.CountItems();
|
||||||
|
for (int32 index = 0; index < count; index++) {
|
||||||
|
T *item = list.ItemAt(index);
|
||||||
|
if (item)
|
||||||
|
item = new T(*item);
|
||||||
|
SetItem(index, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool
|
||||||
|
BObjectList<T>::AddItem(T *item)
|
||||||
|
{
|
||||||
|
// need to cast to void * to make T work for const pointers
|
||||||
|
return _PointerList_::AddItem((void *)item);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool
|
||||||
|
BObjectList<T>::AddItem(T *item, int32 atIndex)
|
||||||
|
{
|
||||||
|
return _PointerList_::AddItem((void *)item, atIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool
|
||||||
|
BObjectList<T>::AddList(BObjectList<T> *newItems)
|
||||||
|
{
|
||||||
|
return _PointerList_::AddList(newItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool
|
||||||
|
BObjectList<T>::AddList(BObjectList<T> *newItems, int32 atIndex)
|
||||||
|
{
|
||||||
|
return _PointerList_::AddList(newItems, atIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool
|
||||||
|
BObjectList<T>::RemoveItem(T *item, bool deleteIfOwning)
|
||||||
|
{
|
||||||
|
bool result = _PointerList_::RemoveItem((void *)item);
|
||||||
|
|
||||||
|
if (result && Owning() && deleteIfOwning)
|
||||||
|
delete item;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T *
|
||||||
|
BObjectList<T>::RemoveItemAt(int32 index)
|
||||||
|
{
|
||||||
|
return (T *)_PointerList_::RemoveItem(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline T *
|
||||||
|
BObjectList<T>::ItemAt(int32 index) const
|
||||||
|
{
|
||||||
|
return (T *)_PointerList_::ItemAt(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool
|
||||||
|
BObjectList<T>::ReplaceItem(int32 index, T *item)
|
||||||
|
{
|
||||||
|
if (owning)
|
||||||
|
delete ItemAt(index);
|
||||||
|
return _PointerList_::ReplaceItem(index, (void *)item);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T *
|
||||||
|
BObjectList<T>::SwapWithItem(int32 index, T *newItem)
|
||||||
|
{
|
||||||
|
T *result = ItemAt(index);
|
||||||
|
_PointerList_::ReplaceItem(index, (void *)newItem);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void
|
||||||
|
BObjectList<T>::SetItem(int32 index, T *newItem)
|
||||||
|
{
|
||||||
|
_PointerList_::ReplaceItem(index, (void *)newItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
int32
|
||||||
|
BObjectList<T>::IndexOf(const T *item) const
|
||||||
|
{
|
||||||
|
return _PointerList_::IndexOf((void *)const_cast<T *>(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T *
|
||||||
|
BObjectList<T>::FirstItem() const
|
||||||
|
{
|
||||||
|
return (T *)_PointerList_::FirstItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T *
|
||||||
|
BObjectList<T>::LastItem() const
|
||||||
|
{
|
||||||
|
return (T *)_PointerList_::LastItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool
|
||||||
|
BObjectList<T>::HasItem(const T *item) const
|
||||||
|
{
|
||||||
|
return _PointerList_::HasItem((void *)item);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool
|
||||||
|
BObjectList<T>::IsEmpty() const
|
||||||
|
{
|
||||||
|
return _PointerList_::IsEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
int32
|
||||||
|
BObjectList<T>::CountItems() const
|
||||||
|
{
|
||||||
|
return _PointerList_::CountItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void
|
||||||
|
BObjectList<T>::MakeEmpty()
|
||||||
|
{
|
||||||
|
if (owning) {
|
||||||
|
int32 count = CountItems();
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
delete ItemAt(index);
|
||||||
|
}
|
||||||
|
_PointerList_::MakeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T *
|
||||||
|
BObjectList<T>::EachElement(EachFunction func, void *params)
|
||||||
|
{
|
||||||
|
return (T *)_PointerList_::EachElement((GenericEachFunction)func, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
const T *
|
||||||
|
BObjectList<T>::EachElement(ConstEachFunction func, void *params) const
|
||||||
|
{
|
||||||
|
return (const T *)
|
||||||
|
const_cast<BObjectList<T> *>(this)->_PointerList_::EachElement(
|
||||||
|
(GenericEachFunction)func, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
const T *
|
||||||
|
BObjectList<T>::FindIf(const UnaryPredicate<T> &predicate) const
|
||||||
|
{
|
||||||
|
int32 count = CountItems();
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
if (predicate.operator()(ItemAt(index)) == 0)
|
||||||
|
return ItemAt(index);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T *
|
||||||
|
BObjectList<T>::FindIf(const UnaryPredicate<T> &predicate)
|
||||||
|
{
|
||||||
|
int32 count = CountItems();
|
||||||
|
for (int32 index = 0; index < count; index++)
|
||||||
|
if (predicate.operator()(ItemAt(index)) == 0)
|
||||||
|
return ItemAt(index);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void
|
||||||
|
BObjectList<T>::SortItems(CompareFunction function)
|
||||||
|
{
|
||||||
|
_PointerList_::SortItems((GenericCompareFunction)function);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void
|
||||||
|
BObjectList<T>::SortItems(CompareFunctionWithState function, void *state)
|
||||||
|
{
|
||||||
|
_PointerList_::SortItems((GenericCompareFunctionWithState)function, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void
|
||||||
|
BObjectList<T>::HSortItems(CompareFunction function)
|
||||||
|
{
|
||||||
|
_PointerList_::HSortItems((GenericCompareFunction)function);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void
|
||||||
|
BObjectList<T>::HSortItems(CompareFunctionWithState function, void *state)
|
||||||
|
{
|
||||||
|
_PointerList_::HSortItems((GenericCompareFunctionWithState)function, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
const T *
|
||||||
|
BObjectList<T>::BinarySearch(const T &key, CompareFunction func) const
|
||||||
|
{
|
||||||
|
return (const T *)_PointerList_::BinarySearch(&key,
|
||||||
|
(GenericCompareFunction)func);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
const T *
|
||||||
|
BObjectList<T>::BinarySearch(const T &key, CompareFunctionWithState func, void *state) const
|
||||||
|
{
|
||||||
|
return (const T *)_PointerList_::BinarySearch(&key,
|
||||||
|
(GenericCompareFunctionWithState)func, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void
|
||||||
|
BObjectList<T>::BinaryInsert(T *item, CompareFunction func)
|
||||||
|
{
|
||||||
|
int32 index = _PointerList_::BinarySearchIndex(item,
|
||||||
|
(GenericCompareFunction)func);
|
||||||
|
if (index >= 0)
|
||||||
|
// already in list, add after existing
|
||||||
|
AddItem(item, index + 1);
|
||||||
|
else
|
||||||
|
AddItem(item, -index - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void
|
||||||
|
BObjectList<T>::BinaryInsert(T *item, CompareFunctionWithState func, void *state)
|
||||||
|
{
|
||||||
|
int32 index = _PointerList_::BinarySearchIndex(item,
|
||||||
|
(GenericCompareFunctionWithState)func, state);
|
||||||
|
if (index >= 0)
|
||||||
|
// already in list, add after existing
|
||||||
|
AddItem(item, index + 1);
|
||||||
|
else
|
||||||
|
AddItem(item, -index - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool
|
||||||
|
BObjectList<T>::BinaryInsertUnique(T *item, CompareFunction func)
|
||||||
|
{
|
||||||
|
int32 index = _PointerList_::BinarySearchIndex(item,
|
||||||
|
(GenericCompareFunction)func);
|
||||||
|
if (index >= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AddItem(item, -index - 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool
|
||||||
|
BObjectList<T>::BinaryInsertUnique(T *item, CompareFunctionWithState func, void *state)
|
||||||
|
{
|
||||||
|
int32 index = _PointerList_::BinarySearchIndex(item,
|
||||||
|
(GenericCompareFunctionWithState)func, state);
|
||||||
|
if (index >= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AddItem(item, -index - 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T *
|
||||||
|
BObjectList<T>::BinaryInsertCopy(const T ©This, CompareFunction func)
|
||||||
|
{
|
||||||
|
int32 index = _PointerList_::BinarySearchIndex(©This,
|
||||||
|
(GenericCompareFunction)func);
|
||||||
|
|
||||||
|
if (index >= 0)
|
||||||
|
index++;
|
||||||
|
else
|
||||||
|
index = -index - 1;
|
||||||
|
|
||||||
|
T *newItem = new T(copyThis);
|
||||||
|
AddItem(newItem, index);
|
||||||
|
return newItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T *
|
||||||
|
BObjectList<T>::BinaryInsertCopy(const T ©This, CompareFunctionWithState func, void *state)
|
||||||
|
{
|
||||||
|
int32 index = _PointerList_::BinarySearchIndex(©This,
|
||||||
|
(GenericCompareFunctionWithState)func, state);
|
||||||
|
|
||||||
|
if (index >= 0)
|
||||||
|
index++;
|
||||||
|
else
|
||||||
|
index = -index - 1;
|
||||||
|
|
||||||
|
T *newItem = new T(copyThis);
|
||||||
|
AddItem(newItem, index);
|
||||||
|
return newItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T *
|
||||||
|
BObjectList<T>::BinaryInsertCopyUnique(const T ©This, CompareFunction func)
|
||||||
|
{
|
||||||
|
int32 index = _PointerList_::BinarySearchIndex(©This,
|
||||||
|
(GenericCompareFunction)func);
|
||||||
|
if (index >= 0)
|
||||||
|
return ItemAt(index);
|
||||||
|
|
||||||
|
index = -index - 1;
|
||||||
|
T *newItem = new T(copyThis);
|
||||||
|
AddItem(newItem, index);
|
||||||
|
return newItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
T *
|
||||||
|
BObjectList<T>::BinaryInsertCopyUnique(const T ©This, CompareFunctionWithState func,
|
||||||
|
void *state)
|
||||||
|
{
|
||||||
|
int32 index = _PointerList_::BinarySearchIndex(©This,
|
||||||
|
(GenericCompareFunctionWithState)func, state);
|
||||||
|
if (index >= 0)
|
||||||
|
return ItemAt(index);
|
||||||
|
|
||||||
|
index = -index - 1;
|
||||||
|
T *newItem = new T(copyThis);
|
||||||
|
AddItem(newItem, index);
|
||||||
|
return newItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
int32
|
||||||
|
BObjectList<T>::FindBinaryInsertionIndex(const UnaryPredicate<T> &pred, bool *alreadyInList)
|
||||||
|
const
|
||||||
|
{
|
||||||
|
int32 index = _PointerList_::BinarySearchIndexByPredicate(&pred,
|
||||||
|
(UnaryPredicateGlue)&UnaryPredicate<T>::_unary_predicate_glue);
|
||||||
|
|
||||||
|
if (alreadyInList)
|
||||||
|
*alreadyInList = index >= 0;
|
||||||
|
|
||||||
|
if (index < 0)
|
||||||
|
index = -index - 1;
|
||||||
|
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void
|
||||||
|
BObjectList<T>::BinaryInsert(T *item, const UnaryPredicate<T> &pred)
|
||||||
|
{
|
||||||
|
int32 index = FindBinaryInsertionIndex(pred);
|
||||||
|
AddItem(item, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
bool
|
||||||
|
BObjectList<T>::BinaryInsertUnique(T *item, const UnaryPredicate<T> &pred)
|
||||||
|
{
|
||||||
|
bool alreadyInList;
|
||||||
|
int32 index = FindBinaryInsertionIndex(pred, &alreadyInList);
|
||||||
|
if (alreadyInList)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
AddItem(item, index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
413
src/column/YabColumnType.cpp
Normal file
413
src/column/YabColumnType.cpp
Normal file
@@ -0,0 +1,413 @@
|
|||||||
|
/*
|
||||||
|
Open Tracker License
|
||||||
|
|
||||||
|
Terms and Conditions
|
||||||
|
|
||||||
|
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice applies to all licensees
|
||||||
|
and shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||||
|
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||||
|
this Software without prior written authorization from Be Incorporated.
|
||||||
|
|
||||||
|
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||||
|
of Be Incorporated in the United States and other countries. Other brand product
|
||||||
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
|
All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "YabColumnType.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <Application.h>
|
||||||
|
#include <BitmapStream.h>
|
||||||
|
#include <File.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
#include <TranslatorRoster.h>
|
||||||
|
#include <Translator.h>
|
||||||
|
#include <View.h>
|
||||||
|
#include <NodeInfo.h>
|
||||||
|
#ifdef ZETA
|
||||||
|
#include <sys_apps/Tracker/Icons.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define kTEXT_MARGIN 8
|
||||||
|
#define kIMG_MARGIN 2
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BTitledColumn::BTitledColumn(const char* title, float width, float minWidth,
|
||||||
|
float maxWidth, alignment align)
|
||||||
|
:BColumn(width, minWidth, maxWidth, align),
|
||||||
|
fTitle(title)
|
||||||
|
{
|
||||||
|
font_height fh;
|
||||||
|
|
||||||
|
be_plain_font->GetHeight(&fh);
|
||||||
|
fFontHeight = fh.descent + fh.leading;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BTitledColumn::DrawTitle(BRect rect, BView* parent)
|
||||||
|
{
|
||||||
|
float width = rect.Width() - (2 * kTEXT_MARGIN);
|
||||||
|
BString out_string(fTitle);
|
||||||
|
|
||||||
|
parent->TruncateString(&out_string, B_TRUNCATE_END, width + 2);
|
||||||
|
DrawString(out_string.String(), parent, rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BTitledColumn::GetColumnName(BString* into) const
|
||||||
|
{
|
||||||
|
*into = fTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BTitledColumn::DrawString(const char* string, BView* parent, BRect rect)
|
||||||
|
{
|
||||||
|
float width = rect.Width() - (2 * kTEXT_MARGIN);
|
||||||
|
float y;
|
||||||
|
BFont font;
|
||||||
|
font_height finfo;
|
||||||
|
|
||||||
|
parent->GetFont(&font);
|
||||||
|
font.GetHeight(&finfo);
|
||||||
|
y = rect.top + ((rect.Height() - (finfo.ascent + finfo.descent + finfo.leading)) / 2) +
|
||||||
|
(finfo.ascent + finfo.descent) - 2;
|
||||||
|
|
||||||
|
switch (Alignment())
|
||||||
|
{
|
||||||
|
case B_ALIGN_LEFT:
|
||||||
|
parent->MovePenTo(rect.left + kTEXT_MARGIN, y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_ALIGN_CENTER:
|
||||||
|
parent->MovePenTo(rect.left + kTEXT_MARGIN + ((width - font.StringWidth(string)) / 2), y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_ALIGN_RIGHT:
|
||||||
|
parent->MovePenTo(rect.right - kTEXT_MARGIN - font.StringWidth(string), y);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
parent->DrawString(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BTitledColumn::SetTitle(const char* title)
|
||||||
|
{
|
||||||
|
fTitle.SetTo(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
void BTitledColumn::Title(BString* forTitle) const
|
||||||
|
{
|
||||||
|
if (forTitle)
|
||||||
|
forTitle->SetTo(fTitle.String());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
float BTitledColumn::FontHeight() const
|
||||||
|
{
|
||||||
|
return fFontHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BYabField::BYabField(const char* string)
|
||||||
|
:fWidth(0), fString(string), fClippedString(string)
|
||||||
|
{
|
||||||
|
int n = fString.FindFirst("__Icon__=");
|
||||||
|
fBitmap = NULL;
|
||||||
|
if(n==0)
|
||||||
|
{
|
||||||
|
BString myPath;
|
||||||
|
fString.CopyInto(myPath, 9, fString.Length()-9);
|
||||||
|
BPath AppDirectory;
|
||||||
|
|
||||||
|
// app directory
|
||||||
|
BString ApplicationDirectory("");
|
||||||
|
app_info appinfo;
|
||||||
|
|
||||||
|
if(be_roster->GetRunningAppInfo(be_app->Team(), &appinfo) == B_OK)
|
||||||
|
{
|
||||||
|
BEntry ApplicationEntry( &appinfo.ref);
|
||||||
|
BEntry ApplicationDirectoryEntry;
|
||||||
|
|
||||||
|
if( ApplicationEntry.GetParent( &ApplicationDirectoryEntry) == B_OK)
|
||||||
|
{
|
||||||
|
if( AppDirectory.SetTo( &ApplicationDirectoryEntry) == B_OK)
|
||||||
|
{
|
||||||
|
// strcpy(ApplicationDirectory, AppDirectory.Path());
|
||||||
|
ApplicationDirectory.SetTo(AppDirectory.Path());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BFile ImageFile;
|
||||||
|
BPath ImagePath;
|
||||||
|
|
||||||
|
if(myPath[0] == '/')
|
||||||
|
ImageFile.SetTo( myPath.String(), B_READ_ONLY);
|
||||||
|
else
|
||||||
|
// App directory.
|
||||||
|
if(ApplicationDirectory != "")
|
||||||
|
{
|
||||||
|
if( ImagePath.SetTo(ApplicationDirectory.String(), myPath.String()) == B_OK)
|
||||||
|
ImageFile.SetTo( ImagePath.Path(), B_READ_ONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ImageFile.InitCheck() != B_OK)
|
||||||
|
ImageFile.SetTo( myPath.String(), B_READ_ONLY);
|
||||||
|
|
||||||
|
if( ImageFile.InitCheck() == B_OK)
|
||||||
|
{
|
||||||
|
BTranslatorRoster *Roster = BTranslatorRoster::Default();
|
||||||
|
if( Roster)
|
||||||
|
{
|
||||||
|
BBitmapStream Stream;
|
||||||
|
if( Roster->Translate( &ImageFile, NULL, NULL, &Stream, B_TRANSLATOR_BITMAP) == B_OK)
|
||||||
|
Stream.DetachBitmap( &fBitmap);
|
||||||
|
delete Roster;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BYabField::SetString(const char* val, int height)
|
||||||
|
{
|
||||||
|
fString = val;
|
||||||
|
fClippedString = "";
|
||||||
|
fWidth = 0;
|
||||||
|
|
||||||
|
fBitmap = NULL;
|
||||||
|
if( ! fString.FindFirst("__Icon__=") )
|
||||||
|
{
|
||||||
|
BString myPath;
|
||||||
|
fString.CopyInto(myPath, 9, fString.Length()-9);
|
||||||
|
BPath AppDirectory;
|
||||||
|
|
||||||
|
// app directory
|
||||||
|
BString ApplicationDirectory("");
|
||||||
|
app_info appinfo;
|
||||||
|
|
||||||
|
if(be_roster->GetRunningAppInfo(be_app->Team(), &appinfo) == B_OK)
|
||||||
|
{
|
||||||
|
BEntry ApplicationEntry( &appinfo.ref);
|
||||||
|
BEntry ApplicationDirectoryEntry;
|
||||||
|
|
||||||
|
if( ApplicationEntry.GetParent( &ApplicationDirectoryEntry) == B_OK)
|
||||||
|
{
|
||||||
|
if( AppDirectory.SetTo( &ApplicationDirectoryEntry) == B_OK)
|
||||||
|
{
|
||||||
|
// strcpy(ApplicationDirectory, AppDirectory.Path());
|
||||||
|
ApplicationDirectory.SetTo(AppDirectory.Path());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BFile ImageFile;
|
||||||
|
BPath ImagePath;
|
||||||
|
|
||||||
|
if(myPath[0] == '/')
|
||||||
|
ImageFile.SetTo( myPath.String(), B_READ_ONLY);
|
||||||
|
else
|
||||||
|
// App directory.
|
||||||
|
if(ApplicationDirectory != "")
|
||||||
|
{
|
||||||
|
if( ImagePath.SetTo(ApplicationDirectory.String(), myPath.String()) == B_OK)
|
||||||
|
ImageFile.SetTo( ImagePath.Path(), B_READ_ONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ImageFile.InitCheck() != B_OK)
|
||||||
|
ImageFile.SetTo( myPath.String(), B_READ_ONLY);
|
||||||
|
|
||||||
|
if( ImageFile.InitCheck() == B_OK)
|
||||||
|
{
|
||||||
|
BTranslatorRoster *Roster = BTranslatorRoster::Default();
|
||||||
|
if( Roster)
|
||||||
|
{
|
||||||
|
BBitmapStream Stream;
|
||||||
|
if( Roster->Translate( &ImageFile, NULL, NULL, &Stream, B_TRANSLATOR_BITMAP) == B_OK)
|
||||||
|
Stream.DetachBitmap( &fBitmap);
|
||||||
|
delete Roster;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( ! fString.FindFirst("__Mime__=") )
|
||||||
|
{
|
||||||
|
BString myPath;
|
||||||
|
fString.CopyInto(myPath, 9, fString.Length()-9);
|
||||||
|
fBitmap = new BBitmap(BRect(0, 0, 15,15), B_CMAP8);
|
||||||
|
BMimeType mime(myPath.String());
|
||||||
|
mime.GetIcon(fBitmap, B_MINI_ICON);
|
||||||
|
}
|
||||||
|
else if( ! fString.FindFirst("__Path__=") )
|
||||||
|
{
|
||||||
|
BString myPath;
|
||||||
|
fString.CopyInto(myPath, 9, fString.Length()-9);
|
||||||
|
#ifdef ZETA
|
||||||
|
fBitmap = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32);
|
||||||
|
BEntry fEntry = BEntry( myPath.String() );
|
||||||
|
BBitmap icon = &GetTrackerIcon(fEntry, 16);
|
||||||
|
*fBitmap = icon;
|
||||||
|
#else
|
||||||
|
fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_RGBA32);
|
||||||
|
BNode *fNode = new BNode(myPath.String());
|
||||||
|
BNodeInfo fInfo(fNode);
|
||||||
|
fInfo.GetTrackerIcon(fBitmap, B_LARGE_ICON);
|
||||||
|
delete fNode;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* BYabField::String() const
|
||||||
|
{
|
||||||
|
return fString.String();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BYabField::SetWidth(float width)
|
||||||
|
{
|
||||||
|
fWidth = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
float BYabField::Width()
|
||||||
|
{
|
||||||
|
return fWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BYabField::SetClippedString(const char* val)
|
||||||
|
{
|
||||||
|
fClippedString = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* BYabField::ClippedString()
|
||||||
|
{
|
||||||
|
return fClippedString.String();
|
||||||
|
}
|
||||||
|
|
||||||
|
const BBitmap* BYabField::Bitmap()
|
||||||
|
{
|
||||||
|
return fBitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BYabField::SetBitmap(BBitmap* bitmap)
|
||||||
|
{
|
||||||
|
fBitmap = bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BYabField::HasBitmap()
|
||||||
|
{
|
||||||
|
if(fBitmap) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
|
||||||
|
BYabColumn::BYabColumn(const char* title, float width, float minWidth,
|
||||||
|
float maxWidth, uint32 truncate, alignment align)
|
||||||
|
:BTitledColumn(title, width, minWidth, maxWidth, align),
|
||||||
|
fTruncate(truncate)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BYabColumn::DrawField(BField* _field, BRect rect, BView* parent)
|
||||||
|
{
|
||||||
|
if(!((BYabField*)_field)->HasBitmap())
|
||||||
|
{
|
||||||
|
float width = rect.Width() - (2 * kTEXT_MARGIN);
|
||||||
|
BYabField* field = static_cast<BYabField*>(_field);
|
||||||
|
|
||||||
|
if (width != field->Width())
|
||||||
|
{
|
||||||
|
BString out_string(field->String());
|
||||||
|
|
||||||
|
parent->TruncateString(&out_string, fTruncate, width + 2);
|
||||||
|
field->SetClippedString(out_string.String());
|
||||||
|
field->SetWidth(width);
|
||||||
|
}
|
||||||
|
DrawString(field->ClippedString(), parent, rect);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BYabField *bitmapField = static_cast<BYabField *>(_field);
|
||||||
|
const BBitmap *bitmap = bitmapField->Bitmap();
|
||||||
|
|
||||||
|
if (bitmap != NULL)
|
||||||
|
{
|
||||||
|
float x = 0.0;
|
||||||
|
float y;
|
||||||
|
BRect r = bitmap->Bounds();
|
||||||
|
|
||||||
|
y = rect.top + ((rect.Height() - r.Height()) / 2);
|
||||||
|
|
||||||
|
switch (Alignment())
|
||||||
|
{
|
||||||
|
case B_ALIGN_LEFT:
|
||||||
|
x = rect.left + kIMG_MARGIN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_ALIGN_CENTER:
|
||||||
|
x = rect.left + ((rect.Width() - r.Width()) / 2);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case B_ALIGN_RIGHT:
|
||||||
|
x = rect.right - kIMG_MARGIN - r.Width();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
parent->SetDrawingMode(B_OP_ALPHA);
|
||||||
|
parent->DrawBitmap(bitmap, BPoint(x, y));
|
||||||
|
parent->SetDrawingMode(B_OP_OVER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int BYabColumn::CompareFields(BField* field1, BField* field2)
|
||||||
|
{
|
||||||
|
return(ICompare(((BYabField*)field1)->String(),
|
||||||
|
(((BYabField*)field2)->String())));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
BYabColumn::AcceptsField(const BField *field) const
|
||||||
|
{
|
||||||
|
return static_cast<bool>(dynamic_cast<const BYabField*>(field));
|
||||||
|
}
|
||||||
|
|
||||||
107
src/column/YabColumnType.h
Normal file
107
src/column/YabColumnType.h
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/*
|
||||||
|
Open Tracker License
|
||||||
|
|
||||||
|
Terms and Conditions
|
||||||
|
|
||||||
|
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice applies to all licensees
|
||||||
|
and shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
Except as contained in this notice, the name of Be Incorporated shall not be
|
||||||
|
used in advertising or otherwise to promote the sale, use or other dealings in
|
||||||
|
this Software without prior written authorization from Be Incorporated.
|
||||||
|
|
||||||
|
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
|
||||||
|
of Be Incorporated in the United States and other countries. Other brand product
|
||||||
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
|
All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef YAB_COLUMN_TYPES_H
|
||||||
|
#define YAB_COLUMN_TYPES_H
|
||||||
|
|
||||||
|
#include "../global.h"
|
||||||
|
#include <String.h>
|
||||||
|
#include <Font.h>
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include "ColumnListView.h"
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
// Common base-class: a column that draws a standard title at its top.
|
||||||
|
|
||||||
|
class BTitledColumn : public BColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BTitledColumn (const char *title, float width, float minWidth, float maxWidth, alignment align = B_ALIGN_LEFT);
|
||||||
|
|
||||||
|
virtual void DrawTitle(BRect rect, BView* parent);
|
||||||
|
virtual void GetColumnName(BString* into) const;
|
||||||
|
void DrawString(const char*, BView*, BRect);
|
||||||
|
void SetTitle(const char* title);
|
||||||
|
void Title(BString* forTitle) const; // sets the BString arg to be the title
|
||||||
|
float FontHeight() const;
|
||||||
|
private:
|
||||||
|
float fFontHeight;
|
||||||
|
BString fTitle;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//=====================================================================
|
||||||
|
// Field and column classes for strings.
|
||||||
|
|
||||||
|
class BYabField : public BField
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BYabField (const char* string);
|
||||||
|
BYabField (BBitmap* bitmap);
|
||||||
|
|
||||||
|
void SetString(const char* string, int height);
|
||||||
|
const char* String() const;
|
||||||
|
void SetClippedString(const char* string);
|
||||||
|
const char*ClippedString();
|
||||||
|
void SetWidth(float);
|
||||||
|
float Width();
|
||||||
|
|
||||||
|
const BBitmap* Bitmap();
|
||||||
|
void SetBitmap(BBitmap* bitmap);
|
||||||
|
bool HasBitmap();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BBitmap* fBitmap;
|
||||||
|
float fWidth;
|
||||||
|
BString fString;
|
||||||
|
BString fClippedString;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
class BYabColumn: public BTitledColumn
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BYabColumn(const char *title, float width, float maxWidth, float minWidth, uint32 truncate, alignment align = B_ALIGN_LEFT);
|
||||||
|
|
||||||
|
virtual void DrawField(BField* field, BRect rect, BView* parent);
|
||||||
|
virtual int CompareFields(BField* field1, BField* field2);
|
||||||
|
virtual bool AcceptsField(const BField* field) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32 fTruncate;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
216
src/config.h
Normal file
216
src/config.h
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
#ifndef CONFIG_H
|
||||||
|
#define CONFIG_H
|
||||||
|
|
||||||
|
#define BEOS
|
||||||
|
// #define LIBBSVG
|
||||||
|
#define BUILD_TIME __DATE__
|
||||||
|
/* Version number of package */
|
||||||
|
#define VERSION "1.7.4.3"
|
||||||
|
/* architecture of build machine */
|
||||||
|
#define UNIX_ARCHITECTURE "BePC-Haiku"
|
||||||
|
|
||||||
|
/* config.h. Generated by configure. */
|
||||||
|
/* config.h.in. Generated from configure.in by autoheader. */
|
||||||
|
|
||||||
|
|
||||||
|
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||||
|
#define HAVE_ALLOCA 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||||
|
*/
|
||||||
|
#define HAVE_ALLOCA_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <ctype.h> header file. */
|
||||||
|
#define HAVE_CTYPE_H 1
|
||||||
|
|
||||||
|
/* defined, if ncurses.h is present */
|
||||||
|
#define HAVE_CURSES_HEADER 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `difftime' function. */
|
||||||
|
#define HAVE_DIFFTIME 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||||
|
#define HAVE_FCNTL_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <float.h> header file. */
|
||||||
|
#define HAVE_FLOAT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `floor' function. */
|
||||||
|
#define HAVE_FLOOR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `fork' function. */
|
||||||
|
#define HAVE_FORK 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#define HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `ncurses' library (-lncurses). */
|
||||||
|
#define HAVE_LIBNCURSES 0
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <limits.h> header file. */
|
||||||
|
#define HAVE_LIMITS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <math.h> header file. */
|
||||||
|
#define HAVE_MATH_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#define HAVE_MEMORY_H 1
|
||||||
|
|
||||||
|
/* defined, if ncurses.h is present */
|
||||||
|
#define HAVE_NCURSES_HEADER 0
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `pow' function. */
|
||||||
|
#define HAVE_POW 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `select' function. */
|
||||||
|
#define HAVE_SELECT 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <signal.h> header file. */
|
||||||
|
#define HAVE_SIGNAL_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `sqrt' function. */
|
||||||
|
#define HAVE_SQRT 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stddef.h> header file. */
|
||||||
|
#define HAVE_STDDEF_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
/* #undef HAVE_STDINT_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdio.h> header file. */
|
||||||
|
#define HAVE_STDIO_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#define HAVE_STDLIB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strchr' function. */
|
||||||
|
#define HAVE_STRCHR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strerror' function. */
|
||||||
|
#define HAVE_STRERROR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strftime' function. */
|
||||||
|
#define HAVE_STRFTIME 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
#define HAVE_STRINGS_H 1
|
||||||
|
|
||||||
|
/* defined, if strings.h is present */
|
||||||
|
#define HAVE_STRINGS_HEADER 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#define HAVE_STRING_H 1
|
||||||
|
|
||||||
|
/* defined, if string.h is present */
|
||||||
|
#define HAVE_STRING_HEADER 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strpbrk' function. */
|
||||||
|
#define HAVE_STRPBRK 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strrchr' function. */
|
||||||
|
#define HAVE_STRRCHR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `strstr' function. */
|
||||||
|
#define HAVE_STRSTR 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||||
|
#define HAVE_SYS_SELECT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||||
|
#define HAVE_SYS_SOCKET_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#define HAVE_SYS_STAT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||||
|
#define HAVE_SYS_TIME_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#define HAVE_SYS_TYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||||
|
#define HAVE_SYS_WAIT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <time.h> header file. */
|
||||||
|
#define HAVE_TIME_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `tmpnam' function. */
|
||||||
|
#define HAVE_TMPNAM 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#define HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `vfork' function. */
|
||||||
|
/* #undef HAVE_VFORK */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <vfork.h> header file. */
|
||||||
|
/* #undef HAVE_VFORK_H */
|
||||||
|
|
||||||
|
/* Define to 1 if `fork' works. */
|
||||||
|
#define HAVE_WORKING_FORK 1
|
||||||
|
|
||||||
|
/* Define to 1 if `vfork' works. */
|
||||||
|
/* #undef HAVE_WORKING_VFORK */
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#define PACKAGE "yabasic"
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#define PACKAGE_BUGREPORT ""
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#define PACKAGE_NAME ""
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#define PACKAGE_STRING ""
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#define PACKAGE_TARNAME ""
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#define PACKAGE_VERSION ""
|
||||||
|
|
||||||
|
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||||
|
#define RETSIGTYPE void
|
||||||
|
|
||||||
|
/* Define to the type of arg 1 for `select'. */
|
||||||
|
#define SELECT_TYPE_ARG1 int
|
||||||
|
|
||||||
|
/* Define to the type of args 2, 3 and 4 for `select'. */
|
||||||
|
#define SELECT_TYPE_ARG234 (fd_set *)
|
||||||
|
|
||||||
|
/* Define to the type of arg 5 for `select'. */
|
||||||
|
#define SELECT_TYPE_ARG5 (struct timeval *)
|
||||||
|
|
||||||
|
/* If using the C implementation of alloca, define if you know the
|
||||||
|
direction of stack growth for your system; otherwise it will be
|
||||||
|
automatically deduced at run-time.
|
||||||
|
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||||
|
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||||
|
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||||
|
/* #undef STACK_DIRECTION */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
#define STDC_HEADERS 1
|
||||||
|
|
||||||
|
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||||
|
#define TIME_WITH_SYS_TIME 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Define to 1 if the X Window System is missing or not being used. */
|
||||||
|
#define X_DISPLAY_MISSING 1
|
||||||
|
|
||||||
|
/* Define to empty if `const' does not conform to ANSI C. */
|
||||||
|
/* #undef const */
|
||||||
|
|
||||||
|
/* Define to `int' if <sys/types.h> does not define. */
|
||||||
|
/* #undef pid_t */
|
||||||
|
|
||||||
|
/* Define to `unsigned' if <sys/types.h> does not define. */
|
||||||
|
/* #undef size_t */
|
||||||
|
|
||||||
|
/* Define as `fork' if `vfork' does not work. */
|
||||||
|
#define vfork fork
|
||||||
|
|
||||||
|
#endif
|
||||||
3
src/fixattributes.sh
Executable file
3
src/fixattributes.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!sh
|
||||||
|
yab RdefApply YAB.rdef yab
|
||||||
|
addattr -t mime BEOS:TYPE application/x-vnd.be-elfexecutable yab
|
||||||
2053
src/function.c
Normal file
2053
src/function.c
Normal file
File diff suppressed because it is too large
Load Diff
3
src/global.h
Normal file
3
src/global.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
//define BUILD_NCURSES
|
||||||
|
#define BUILD_YABTEXT
|
||||||
|
#define BUILD_GAMESOUND
|
||||||
2560
src/graphic.c
Normal file
2560
src/graphic.c
Normal file
File diff suppressed because it is too large
Load Diff
2250
src/main.c
Normal file
2250
src/main.c
Normal file
File diff suppressed because it is too large
Load Diff
BIN
src/resattr
Executable file
BIN
src/resattr
Executable file
Binary file not shown.
1775
src/symbol.c
Normal file
1775
src/symbol.c
Normal file
File diff suppressed because it is too large
Load Diff
3918
src/yab-IDE.yab
Executable file
3918
src/yab-IDE.yab
Executable file
File diff suppressed because it is too large
Load Diff
940
src/yabasic.bison
Normal file
940
src/yabasic.bison
Normal file
@@ -0,0 +1,940 @@
|
|||||||
|
%{
|
||||||
|
/*
|
||||||
|
|
||||||
|
YABASIC --- a simple Basic Interpreter
|
||||||
|
written by Marc-Oliver Ihm 1995-2004
|
||||||
|
homepage: www.yabasic.de
|
||||||
|
|
||||||
|
BISON part
|
||||||
|
|
||||||
|
This file is part of yabasic and may be copied only
|
||||||
|
under the terms of either the Artistic License or
|
||||||
|
the GNU General Public License (GPL), both of which
|
||||||
|
can be found at www.yabasic.de
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef YABASIC_INCLUDED
|
||||||
|
#include "yabasic.h" /* definitions of yabasic */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#if HAVE_ALLOCA_H
|
||||||
|
#ifndef WINDOWS
|
||||||
|
#include <alloca.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void __yy_bcopy(char *,char *,int); /* prototype missing */
|
||||||
|
|
||||||
|
int tileol; /* true, read should go to eon of line */
|
||||||
|
int mylineno=1; /* line number; counts fresh in every new file */
|
||||||
|
int main_lineno=1; /* line number of main */
|
||||||
|
int function_type=ftNONE; /* contains function type while parsing function */
|
||||||
|
char *current_function=NULL; /* name of currently parsed function */
|
||||||
|
int exported=FALSE; /* true, if function is exported */
|
||||||
|
int yylex(void);
|
||||||
|
extern struct libfile_name *current_libfile; /* defined in main.c: name of currently parsed file */
|
||||||
|
int missing_endif=0;
|
||||||
|
int missing_endif_line=0;
|
||||||
|
int missing_endsub=0;
|
||||||
|
int missing_endsub_line=0;
|
||||||
|
int missing_next=0;
|
||||||
|
int missing_next_line=0;
|
||||||
|
int missing_wend=0;
|
||||||
|
int missing_wend_line=0;
|
||||||
|
int missing_until=0;
|
||||||
|
int missing_until_line=0;
|
||||||
|
int missing_loop=0;
|
||||||
|
int missing_loop_line=0;
|
||||||
|
int in_loop=0;
|
||||||
|
|
||||||
|
void report_missing(int severity,char *text) {
|
||||||
|
if (missing_loop || missing_endif || missing_next || missing_until || missing_wend) {
|
||||||
|
error(severity,text);
|
||||||
|
string[0]='\0';
|
||||||
|
if (missing_endif)
|
||||||
|
sprintf(string,"if statement starting at line %d has seen no 'endif' yet",missing_endif_line);
|
||||||
|
else if (missing_next)
|
||||||
|
sprintf(string,"for-loop starting at line %d has seen no 'next' yet",missing_next_line);
|
||||||
|
else if (missing_wend)
|
||||||
|
sprintf(string,"while-loop starting at line %d has seen no 'wend' yet",missing_wend_line);
|
||||||
|
else if (missing_until)
|
||||||
|
sprintf(string,"repeat-loop starting at line %d has seen no 'until' yet",missing_until_line);
|
||||||
|
else if (missing_loop)
|
||||||
|
sprintf(string,"do-loop starting at line %d has seen no 'loop' yet",missing_wend_line);
|
||||||
|
if (string[0]) error(severity,string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%}
|
||||||
|
|
||||||
|
%union {
|
||||||
|
double fnum; /* double number */
|
||||||
|
int inum; /* integer number */
|
||||||
|
int token; /* token of command */
|
||||||
|
int sep; /* number of newlines */
|
||||||
|
char *string; /* quoted string */
|
||||||
|
char *symbol; /* general symbol */
|
||||||
|
char *digits; /* string of digits */
|
||||||
|
char *docu; /* embedded documentation */
|
||||||
|
}
|
||||||
|
|
||||||
|
%type <fnum> const
|
||||||
|
%type <fnum> number
|
||||||
|
%type <symbol> symbol_or_lineno
|
||||||
|
%type <symbol> function_name
|
||||||
|
%type <symbol> function_or_array
|
||||||
|
%type <symbol> stringfunction_or_array
|
||||||
|
%type <sep> tSEP sep_list
|
||||||
|
|
||||||
|
%token <fnum> tFNUM
|
||||||
|
%token <symbol> tSYMBOL
|
||||||
|
%token <symbol> tSTRSYM
|
||||||
|
%token <symbol> tDOCU
|
||||||
|
%token <digits> tDIGITS
|
||||||
|
%token <string> tSTRING
|
||||||
|
|
||||||
|
%token tFOR tTO tSTEP tNEXT tWHILE tWEND tREPEAT tUNTIL tIMPORT
|
||||||
|
%token tGOTO tGOSUB tLABEL tON tSUB tENDSUB tLOCAL tSTATIC tEXPORT tERROR
|
||||||
|
%token tEXECUTE tEXECUTE2 tCOMPILE tRUNTIME_CREATED_SUB
|
||||||
|
%token tINTERRUPT tBREAK tCONTINUE tSWITCH tSEND tCASE tDEFAULT tLOOP tDO tSEP tEOPROG
|
||||||
|
%token tIF tTHEN tELSE tELSIF tENDIF tUSING
|
||||||
|
%token tPRINT tINPUT tLINE tRETURN tDIM tEND tEXIT tAT tSCREEN tSCREENSHOT
|
||||||
|
%token tREVERSE tCOLOUR
|
||||||
|
%token tAND tOR tNOT tEOR
|
||||||
|
%token tNEQ tLEQ tGEQ tLTN tGTN tEQU tPOW
|
||||||
|
%token tREAD tDATA tRESTORE
|
||||||
|
%token tOPEN tCLOSE tSEEK tTELL tAS tREADING tWRITING
|
||||||
|
%token tWAIT tBELL tLET tARDIM tARSIZE tBIND
|
||||||
|
%token tWINDOW tDOT tCIRCLE tCLEAR tFILL tPRINTER tSETUP
|
||||||
|
%token tBUTTON tALERT tMENU tCHECKBOX tRADIOBUTTON tTEXTCONTROL
|
||||||
|
%token tLISTBOX tDROPBOX tADD tREMOVE tLOCALIZE tFILEPANEL tSLIDER tSTATUSBAR
|
||||||
|
%token tLAYOUT tSET tTEXTEDIT tCOUNT tVIEW tBOXVIEW tTABVIEW tTEXTURL tBITMAP tCANVAS
|
||||||
|
%token tOPTION tDROPZONE tCOLORCONTROL tTREEBOX tCOLUMNBOX tCOLUMN tSORT tTOOLTIP tCALENDAR
|
||||||
|
%token tCLIPBOARD tCOPY tSUBMENU tSELECT tSCROLLBAR tEXPAND tCOLLAPSE tSPLITVIEW tSTACKVIEW
|
||||||
|
%token tPOPUPMENU tSPINCONTROL tMSEND tNUMMESSAGE tTHREAD tSOUND tPLAY tSTOP tSHORTCUT tISCOMPUTERON
|
||||||
|
%token tDRAW tTEXT tFLUSH tELLIPSE tSAVE
|
||||||
|
%token tRECT tGETCHAR tPUTCHAR tNEW tCURVE tLAUNCH tATTRIBUTE
|
||||||
|
|
||||||
|
%token tSIN tASIN tCOS tACOS tTAN tATAN tEXP tLOG
|
||||||
|
%token tSQRT tSQR tMYEOF tABS tSIG
|
||||||
|
%token tINT tFRAC tMOD tRAN tLEN tVAL tLEFT tRIGHT tMID tMIN tMAX
|
||||||
|
%token tSTR tINKEY tCHR tASC tHEX tDEC tBIN tUPPER tLOWER
|
||||||
|
%token tTRIM tLTRIM tRTRIM tINSTR tRINSTR
|
||||||
|
%token tSYSTEM tSYSTEM2 tPEEK tPEEK2 tPOKE
|
||||||
|
%token tDATE tTIME tTOKEN tTOKENALT tSPLIT tSPLITALT tGLOB
|
||||||
|
%token tMESSAGE tIMAGE tSVG tTRANSLATE tGET tMOUSE tISMOUSEIN
|
||||||
|
%token tKEYBOARD tPASTE tGETNUM
|
||||||
|
|
||||||
|
%left tOR
|
||||||
|
%left tAND
|
||||||
|
%left tNOT
|
||||||
|
%left tNEQ
|
||||||
|
%left tGEQ
|
||||||
|
%left tLEQ
|
||||||
|
%left tLTN
|
||||||
|
%left tGTN
|
||||||
|
%left tEQU
|
||||||
|
%left '-' '+'
|
||||||
|
%left '*' '/'
|
||||||
|
%left tPOW
|
||||||
|
%nonassoc UMINUS
|
||||||
|
|
||||||
|
%%
|
||||||
|
|
||||||
|
program: statement_list tEOPROG {YYACCEPT;}
|
||||||
|
;
|
||||||
|
|
||||||
|
statement_list: statement
|
||||||
|
| statement_list {if (errorlevel<=ERROR) {YYABORT;}}
|
||||||
|
tSEP {if ($3>=0) mylineno+=$3; else switchlib();} statement
|
||||||
|
;
|
||||||
|
|
||||||
|
statement: /* empty */
|
||||||
|
| string_assignment
|
||||||
|
| tLET string_assignment
|
||||||
|
| assignment
|
||||||
|
| tLET assignment
|
||||||
|
| tIMPORT {report_missing(ERROR,"do not import a library in a loop or an if-statement");switchlib();}
|
||||||
|
| tERROR string_expression {add_command(cERROR,NULL);}
|
||||||
|
| for_loop
|
||||||
|
| switch_number_or_string
|
||||||
|
| repeat_loop
|
||||||
|
| while_loop
|
||||||
|
| do_loop
|
||||||
|
| tBREAK {add_command(cBREAK,NULL);if (!in_loop) error(ERROR,"break outside loop");}
|
||||||
|
| tCONTINUE {add_command(cCONTINUE,NULL);if (!in_loop) error(ERROR,"continue outside loop");}
|
||||||
|
| function_definition
|
||||||
|
| function_or_array {create_call($1);add_command(cPOP,NULL);}
|
||||||
|
| stringfunction_or_array {create_call($1);add_command(cPOP,NULL);}
|
||||||
|
| tLOCAL {if (function_type==ftNONE) error(ERROR,"no use for 'local' outside functions");} local_list
|
||||||
|
| tSTATIC {if (function_type==ftNONE) error(ERROR,"no use for 'static' outside functions");} static_list
|
||||||
|
| if_clause
|
||||||
|
| short_if
|
||||||
|
| tGOTO symbol_or_lineno {create_goto((function_type!=ftNONE)?dotify($2,TRUE):$2);}
|
||||||
|
| tGOSUB symbol_or_lineno {create_gosub((function_type!=ftNONE)?dotify($2,TRUE):$2);}
|
||||||
|
| tON tINTERRUPT tBREAK {create_exception(TRUE);}
|
||||||
|
| tON tINTERRUPT tCONTINUE {create_exception(FALSE);}
|
||||||
|
| tON expression tGOTO {add_command(cSKIPPER,NULL);}
|
||||||
|
goto_list {add_command(cNOP,NULL);}
|
||||||
|
| tON expression tGOSUB {add_command(cSKIPPER,NULL);}
|
||||||
|
gosub_list {add_command(cNOP,NULL);}
|
||||||
|
| tLABEL symbol_or_lineno {create_label((function_type!=ftNONE)?dotify($2,TRUE):$2,cLABEL);}
|
||||||
|
| open_clause {add_command(cCHECKOPEN,NULL);}
|
||||||
|
| tCLOSE hashed_number {add_command(cCLOSE,NULL);}
|
||||||
|
| seek_clause {add_command(cCHECKSEEK,NULL);}
|
||||||
|
| tCOMPILE string_expression {add_command(cCOMPILE,NULL);}
|
||||||
|
| tEXECUTE '(' call_list ')' {create_execute(0);add_command(cPOP,NULL);add_command(cPOP,NULL);}
|
||||||
|
| tEXECUTE2 '(' call_list ')' {create_execute(1);add_command(cPOP,NULL);add_command(cPOP,NULL);}
|
||||||
|
| tPRINT printintro printlist {create_colour(0);create_print('n');create_pps(cPOPSTREAM,0);}
|
||||||
|
| tPRINT printintro printlist ';' {create_colour(0);create_pps(cPOPSTREAM,0);}
|
||||||
|
| tPRINT printintro printlist ',' {create_colour(0);create_print('t');create_pps(cPOPSTREAM,0);}
|
||||||
|
| tINPUT {tileol=FALSE;} inputbody
|
||||||
|
| tLINE tINPUT {tileol=TRUE;} inputbody
|
||||||
|
| tREAD readlist
|
||||||
|
| tDATA datalist
|
||||||
|
| tRESTORE {create_restore("");}
|
||||||
|
| tRESTORE symbol_or_lineno {create_restore((function_type!=ftNONE)?dotify($2,TRUE):$2);}
|
||||||
|
| tRESTORE string_expression {add_command(cRESTORE2, NULL);}
|
||||||
|
| tRETURN {if (get_switch_id()) create_clean_switch_mark(0,TRUE);
|
||||||
|
if (function_type!=ftNONE) {
|
||||||
|
add_command(cCLEARREFS,NULL);lastcmd->nextref=firstref;
|
||||||
|
add_command(cPOPSYMLIST,NULL);
|
||||||
|
create_retval(ftNONE,function_type);
|
||||||
|
add_command(cRET_FROM_FUN,NULL);
|
||||||
|
} else {
|
||||||
|
add_command(cRETURN,NULL);
|
||||||
|
}}
|
||||||
|
| tRETURN expression {if (get_switch_id()) create_clean_switch_mark(1,TRUE); if (function_type==ftNONE) {error(ERROR,"can not return value"); YYABORT;} add_command(cCLEARREFS,NULL);lastcmd->nextref=firstref;add_command(cPOPSYMLIST,NULL);create_retval(ftNUMBER,function_type);add_command(cRET_FROM_FUN,NULL);}
|
||||||
|
| tRETURN string_expression {if (get_switch_id()) create_clean_switch_mark(1,TRUE); if (function_type==ftNONE) {error(ERROR,"can not return value"); YYABORT;} add_command(cCLEARREFS,NULL);lastcmd->nextref=firstref;add_command(cPOPSYMLIST,NULL);create_retval(ftSTRING,function_type);add_command(cRET_FROM_FUN,NULL);}
|
||||||
|
| tDIM dimlist
|
||||||
|
/* | tOPEN tWINDOW expression ',' expression {create_openwin(FALSE);} */
|
||||||
|
| tWINDOW tOPEN coordinates to coordinates ',' string_expression ',' string_expression {create_openwin(TRUE);}
|
||||||
|
| tBUTTON coordinates to coordinates ',' string_expression ',' string_expression ',' string_expression {add_command(cBUTTON,NULL);}
|
||||||
|
| tMENU string_expression ',' string_expression ',' string_expression ',' string_expression {add_command(cMENU,NULL);}
|
||||||
|
| tCHECKBOX coordinates ',' string_expression ',' string_expression ',' expression ',' string_expression {add_command(cCHECKBOX,NULL);}
|
||||||
|
| tRADIOBUTTON coordinates ',' string_expression ',' string_expression ',' expression ',' string_expression {add_command(cRADIOBUTTON,NULL);}
|
||||||
|
| tTEXTCONTROL coordinates to coordinates ',' string_expression ',' string_expression ',' string_expression ',' string_expression{add_command(cTEXTCONTROL,NULL);}
|
||||||
|
| tLISTBOX coordinates to coordinates ',' string_expression ',' expression ',' string_expression {add_command(cLISTBOX,NULL);}
|
||||||
|
| tLISTBOX tCLEAR string_expression {add_command(cITEMCLEAR, NULL);}
|
||||||
|
| tLISTBOX tADD string_expression ',' string_expression {add_command(cLISTBOXADD1, NULL);}
|
||||||
|
| tLISTBOX tADD string_expression ',' expression ',' string_expression {add_command(cLISTBOXADD2, NULL);}
|
||||||
|
| tDROPBOX coordinates to coordinates ',' string_expression ',' string_expression ',' string_expression {add_command(cDROPBOX,NULL);}
|
||||||
|
| tDROPBOX tADD string_expression ',' string_expression {add_command(cITEMADD,NULL);}
|
||||||
|
| tDROPBOX tCLEAR string_expression {add_command(cDROPBOXCLEAR,NULL);}
|
||||||
|
| tDROPBOX tREMOVE string_expression ',' expression {add_command(cDROPBOXREMOVE,NULL);}
|
||||||
|
| tLISTBOX tREMOVE string_expression ',' string_expression {add_command(cITEMDEL,NULL);}
|
||||||
|
| tLISTBOX tREMOVE string_expression ',' expression {add_command(cLISTBOXDEL2,NULL);}
|
||||||
|
| tLISTBOX tSELECT string_expression ',' expression {add_command(cLISTBOXSELECT,NULL);}
|
||||||
|
| tALERT string_expression ',' string_expression ',' string_expression {add_command(cALERT,NULL);}
|
||||||
|
| tTEXT coordinates ',' string_expression ',' string_expression ',' string_expression {add_command(cTEXT,NULL);}
|
||||||
|
| tTEXT coordinates to coordinates ',' string_expression ',' string_expression ',' string_expression {add_command(cTEXT2, NULL);}
|
||||||
|
| tTEXT tSET string_expression ',' string_expression {add_command(cTEXTALIGN,NULL);}
|
||||||
|
| tLOCALIZE {add_command(cLOCALIZE,NULL);}
|
||||||
|
| tLOCALIZE string_expression {add_command(cLOCALIZE2,NULL);}
|
||||||
|
| tLOCALIZE tSTOP {add_command(cLOCALIZESTOP, NULL);}
|
||||||
|
| tDRAW tTEXT coordinates ',' string_expression ',' string_expression {add_command(cDRAWTEXT,NULL);}
|
||||||
|
| tDRAW tRECT coordinates to coordinates ',' string_expression {add_command(cDRAWRECT,NULL);}
|
||||||
|
| tDRAW tFLUSH string_expression {add_command(cDRAWCLEAR,NULL);}
|
||||||
|
| tWINDOW tCLOSE string_expression {add_command(cCLOSEWIN,NULL);}
|
||||||
|
| tLAYOUT string_expression ',' string_expression {add_command(cLAYOUT,NULL);}
|
||||||
|
| tWINDOW tSET string_expression ',' string_expression {add_command(cWINSET4,NULL);}
|
||||||
|
| tWINDOW tSET string_expression ',' string_expression ',' string_expression {add_command(cWINSET1,NULL);}
|
||||||
|
| tWINDOW tSET string_expression ',' string_expression ',' expression ',' expression {add_command(cWINSET3,NULL);}
|
||||||
|
/*
|
||||||
|
| tWINDOW tSET string_expression ',' string_expression ',' expression ',' expression ',' expression {add_command(cWINSET2,NULL);}
|
||||||
|
this tWINDOW tSET was replaced by tDRAW tSET ... cWINSET2
|
||||||
|
tWINDOW tCLEAR string_expression {add_command(cWINCLEAR,NULL);}*/
|
||||||
|
| tSHORTCUT string_expression ',' string_expression ',' string_expression {add_command(cSHORTCUT,NULL);}
|
||||||
|
| tTEXTEDIT coordinates to coordinates ',' string_expression ',' expression ',' string_expression {add_command(cTEXTEDIT,NULL);}
|
||||||
|
| tTEXTEDIT tADD string_expression ',' string_expression {add_command(cTEXTADD,NULL);}
|
||||||
|
| tTEXTEDIT tSET string_expression ',' string_expression {add_command(cTEXTSET,NULL);}
|
||||||
|
| tTEXTEDIT tSET string_expression ',' string_expression ',' expression {add_command(cTEXTSET2,NULL);}
|
||||||
|
| tTEXTEDIT tSET string_expression ',' string_expression ',' string_expression {add_command(cTEXTSET3,NULL);}
|
||||||
|
| tTEXTEDIT tCOLOUR string_expression ',' string_expression ',' string_expression {add_command(cTEXTCOLOR1,NULL);}
|
||||||
|
| tTEXTEDIT tCOLOUR string_expression ',' string_expression ',' expression ',' expression ',' expression {add_command(cTEXTCOLOR2,NULL);}
|
||||||
|
| tTEXTEDIT tCLEAR string_expression {add_command(cTEXTCLEAR,NULL);}
|
||||||
|
| tDRAW tSET string_expression ',' string_expression {add_command(cDRAWSET1,NULL);}
|
||||||
|
| tDRAW tSET expression ',' string_expression {add_command(cDRAWSET2,NULL);}
|
||||||
|
| tDRAW tSET string_expression ',' expression ',' expression ',' expression ',' string_expression {add_command(cWINSET2,NULL);}
|
||||||
|
| tDRAW tSET string_expression ',' expression {add_command(cDRAWSET3,NULL);}
|
||||||
|
| tDRAW tSET string_expression ',' string_expression ',' string_expression {add_command(cDRAWSET4,NULL);}
|
||||||
|
| tVIEW coordinates to coordinates ',' string_expression ',' string_expression {add_command(cVIEW,NULL);}
|
||||||
|
| tVIEW tREMOVE string_expression {add_command(cWINCLEAR,NULL);}
|
||||||
|
| tBOXVIEW coordinates to coordinates ',' string_expression ',' string_expression ',' expression ',' string_expression {add_command(cBOXVIEW,NULL);}
|
||||||
|
| tBOXVIEW tSET string_expression ',' string_expression ',' string_expression {add_command(cBOXVIEWSET,NULL);}
|
||||||
|
| tTABVIEW coordinates to coordinates ',' string_expression ',' string_expression ',' string_expression {add_command(cTAB,NULL);}
|
||||||
|
| tTABVIEW tSET string_expression ',' expression {add_command(cTABSET,NULL);}
|
||||||
|
| tTABVIEW tADD string_expression ',' string_expression {add_command(cTABADD, NULL);}
|
||||||
|
| tTABVIEW tREMOVE string_expression ',' expression {add_command(cTABDEL, NULL);}
|
||||||
|
| tDRAW tDOT coordinates ',' string_expression {add_command(cDOT,NULL);}
|
||||||
|
| tDRAW tLINE coordinates to coordinates ',' string_expression {add_command(cLINE,NULL);}
|
||||||
|
| tDRAW tCIRCLE coordinates ',' expression ',' string_expression {add_command(cCIRCLE,NULL);}
|
||||||
|
| tDRAW tELLIPSE coordinates ',' expression ',' expression ',' string_expression {add_command(cELLIPSE,NULL);}
|
||||||
|
| tDRAW tCURVE coordinates ',' coordinates ',' coordinates ',' coordinates ',' string_expression {add_command(cCURVE,NULL);}
|
||||||
|
| tSLIDER coordinates to coordinates ',' string_expression ',' string_expression ',' expression ',' expression ',' string_expression {add_command(cSLIDER1,NULL);}
|
||||||
|
| tSLIDER coordinates to coordinates ',' string_expression ',' string_expression ',' expression ',' expression ',' string_expression ',' string_expression {add_command(cSLIDER2,NULL);}
|
||||||
|
| tSLIDER tLABEL string_expression ',' string_expression ',' string_expression {add_command(cSLIDER3,NULL);}
|
||||||
|
| tSLIDER tSET string_expression ',' string_expression ',' expression {add_command(cSLIDER4,NULL);}
|
||||||
|
| tSLIDER tCOLOUR string_expression ',' string_expression ',' expression ',' expression ',' expression {add_command(cSLIDER5,NULL);}
|
||||||
|
| tSLIDER tSET string_expression ',' expression {add_command(cSLIDER6,NULL);}
|
||||||
|
| tLAUNCH string_expression {add_command(cLAUNCH,NULL);}
|
||||||
|
| tOPTION tSET string_expression ',' string_expression ',' string_expression {add_command(cOPTION1,NULL);}
|
||||||
|
| tOPTION tCOLOUR string_expression ',' string_expression ',' expression ',' expression ',' expression {add_command(cOPTION2,NULL);}
|
||||||
|
/*
|
||||||
|
| tOPTION tRESIZE string_expression ',' coordinates to coordinates {add_command(cOPTION3,NULL);}
|
||||||
|
*/
|
||||||
|
| tOPTION tSET string_expression ',' string_expression {add_command(cOPTION4,NULL);}
|
||||||
|
| tOPTION tSET string_expression ',' string_expression ',' expression {add_command(cOPTION5,NULL);}
|
||||||
|
| tOPTION tSET string_expression ',' string_expression ',' expression ',' expression {add_command(cOPTION3,NULL);}
|
||||||
|
| tBITMAP coordinates ',' string_expression {add_command(cBITMAP,NULL);}
|
||||||
|
| tBITMAP tGETNUM coordinates to coordinates ',' string_expression ',' string_expression {add_command(cBITMAPGET, NULL);}
|
||||||
|
| tBITMAP tGETNUM expression ',' string_expression ',' string_expression {add_command(cBITMAPGET2, NULL);}
|
||||||
|
| tBITMAP tGETNUM string_expression ',' string_expression ',' string_expression {add_command(cBITMAPGETICON, NULL);}
|
||||||
|
| tDRAW tBITMAP coordinates ',' string_expression ',' string_expression ',' string_expression {add_command(cBITMAPDRAW,NULL);}
|
||||||
|
| tDRAW tBITMAP coordinates to coordinates ',' string_expression ',' string_expression ',' string_expression {add_command(cBITMAPDRAW2,NULL);}
|
||||||
|
/*
|
||||||
|
| tCANVAS tDRAG string_expression {add_command(cBITMAPDRAG,NULL);}
|
||||||
|
*/
|
||||||
|
| tBITMAP tREMOVE string_expression {add_command(cBITMAPREMOVE,NULL);}
|
||||||
|
| tSCREENSHOT coordinates to coordinates ',' string_expression {add_command(cSCREENSHOT,NULL);}
|
||||||
|
| tCANVAS coordinates to coordinates ',' string_expression ',' string_expression {add_command(cCANVAS,NULL);}
|
||||||
|
| tVIEW tDROPZONE string_expression {add_command(cDROPZONE,NULL);}
|
||||||
|
| tCOLORCONTROL coordinates ',' string_expression ',' string_expression {add_command(cCOLORCONTROL1,NULL);}
|
||||||
|
| tCOLORCONTROL tSET string_expression ',' expression ',' expression ',' expression {add_command(cCOLORCONTROL2,NULL);}
|
||||||
|
| tTEXTCONTROL tSET string_expression ',' string_expression {add_command(cTEXTCONTROL2,NULL);}
|
||||||
|
| tTEXTCONTROL tSET string_expression ',' expression {add_command(cTEXTCONTROL3,NULL);}
|
||||||
|
| tTEXTCONTROL tSET string_expression ',' string_expression ',' string_expression {add_command(cTEXTCONTROL4,NULL);}
|
||||||
|
| tTEXTCONTROL tCLEAR string_expression {add_command(cTEXTCONTROL5,NULL);}
|
||||||
|
| tTREEBOX coordinates to coordinates ',' string_expression ',' expression ',' string_expression {add_command(cTREEBOX1,NULL);}
|
||||||
|
| tTREEBOX tADD string_expression ',' string_expression {add_command(cTREEBOX2,NULL);}
|
||||||
|
| tTREEBOX tADD string_expression ',' string_expression ',' string_expression ',' expression {add_command(cTREEBOX3,NULL);}
|
||||||
|
| tTREEBOX tADD string_expression ',' string_expression ',' expression ',' expression ',' expression {add_command(cTREEBOX13,NULL);}
|
||||||
|
| tTREEBOX tADD string_expression ',' string_expression ',' expression {add_command(cTREEBOX12,NULL);}
|
||||||
|
| tTREEBOX tCLEAR string_expression {add_command(cTREEBOX4,NULL);}
|
||||||
|
| tTREEBOX tREMOVE string_expression ',' string_expression {add_command(cTREEBOX5,NULL);}
|
||||||
|
| tTREEBOX tSELECT string_expression ',' expression {add_command(cTREEBOX7,NULL);}
|
||||||
|
| tTREEBOX tREMOVE string_expression ',' expression {add_command(cTREEBOX8,NULL);}
|
||||||
|
| tTREEBOX tREMOVE string_expression ',' string_expression ',' string_expression {add_command(cTREEBOX9,NULL);}
|
||||||
|
| tTREEBOX tEXPAND string_expression ',' string_expression {add_command(cTREEBOX10,NULL);}
|
||||||
|
| tTREEBOX tCOLLAPSE string_expression ',' string_expression {add_command(cTREEBOX11,NULL);}
|
||||||
|
| tBUTTON tIMAGE coordinates ',' string_expression ',' string_expression ',' string_expression ',' string_expression ',' string_expression {add_command(cBUTTONIMAGE,NULL);}
|
||||||
|
| tCHECKBOX tIMAGE coordinates ',' string_expression ',' string_expression ',' string_expression ',' string_expression ',' string_expression ',' expression ',' string_expression {add_command(cCHECKBOXIMAGE,NULL);}
|
||||||
|
| tCHECKBOX tSET string_expression ',' expression {add_command(cCHECKBOXSET,NULL);}
|
||||||
|
| tRADIOBUTTON tSET string_expression ',' expression {add_command(cRADIOSET,NULL);}
|
||||||
|
| tTOOLTIP string_expression ',' string_expression {add_command(cTOOLTIP,NULL);}
|
||||||
|
| tTOOLTIP tCOLOUR string_expression ',' expression ',' expression ',' expression {add_command(cTOOLTIPCOLOR,NULL);}
|
||||||
|
| tLISTBOX tSORT string_expression {add_command(cLISTSORT,NULL);}
|
||||||
|
| tTREEBOX tSORT string_expression {add_command(cTREESORT,NULL);}
|
||||||
|
| tCOLUMNBOX coordinates to coordinates ',' string_expression ',' expression ',' string_expression ',' string_expression {add_command(cFILEBOX,NULL);}
|
||||||
|
| tCOLUMNBOX tADD string_expression ',' expression ',' expression ',' expression ',' string_expression {add_command(cCOLUMNBOXADD,NULL);}
|
||||||
|
| tCOLUMNBOX tCOLUMN string_expression ',' string_expression ',' expression ',' expression ',' expression ',' expression ',' string_expression {add_command(cFILEBOXADD2,NULL);}
|
||||||
|
| tCOLUMNBOX tCLEAR string_expression {add_command(cFILEBOXCLEAR,NULL);}
|
||||||
|
| tCOLUMNBOX tREMOVE string_expression ',' expression {add_command(cCOLUMNBOXREMOVE,NULL);}
|
||||||
|
| tCOLUMNBOX tSELECT string_expression ',' expression {add_command(cCOLUMNBOXSELECT,NULL);}
|
||||||
|
| tCOLUMNBOX tCOLOUR string_expression ',' string_expression ',' expression ',' expression ',' expression {add_command(cCOLUMNBOXCOLOR,NULL);}
|
||||||
|
| tCALENDAR coordinates ',' string_expression ',' string_expression ',' string_expression ',' string_expression {add_command(cCALENDAR,NULL);}
|
||||||
|
| tCALENDAR tSET string_expression ',' string_expression {add_command(cCALENDARSET,NULL);}
|
||||||
|
| tSCROLLBAR string_expression ',' expression ',' string_expression {add_command(cSCROLLBAR,NULL);}
|
||||||
|
| tSCROLLBAR tSET string_expression ',' string_expression ',' expression {add_command(cSCROLLBARSET1,NULL);}
|
||||||
|
| tSCROLLBAR tSET string_expression ',' string_expression ',' expression ',' expression {add_command(cSCROLLBARSET2,NULL);}
|
||||||
|
| tSCROLLBAR tSET string_expression ',' string_expression {add_command(cSCROLLBARSET3,NULL);}
|
||||||
|
| tDROPBOX tSELECT string_expression ',' expression {add_command(cDROPBOXSELECT,NULL);}
|
||||||
|
| tMENU tSET string_expression ',' expression ',' string_expression {add_command(cMENU2,NULL);}
|
||||||
|
| tMENU tSET string_expression ',' string_expression ',' string_expression ',' string_expression {add_command(cMENU3,NULL);}
|
||||||
|
| tSUBMENU string_expression ',' string_expression ',' string_expression ',' string_expression ',' string_expression {add_command(cSUBMENU1,NULL);}
|
||||||
|
| tSUBMENU tSET string_expression ',' string_expression ',' expression ',' string_expression {add_command(cSUBMENU2,NULL);}
|
||||||
|
| tSUBMENU tSET string_expression ',' string_expression ',' string_expression ',' string_expression ',' string_expression {add_command(cSUBMENU3,NULL);}
|
||||||
|
| tSTATUSBAR coordinates to coordinates ',' string_expression ',' string_expression ',' string_expression ',' string_expression {add_command(cSTATUSBAR,NULL);}
|
||||||
|
| tSTATUSBAR tSET string_expression ',' string_expression ',' string_expression ',' expression {add_command(cSTATUSBARSET,NULL);}
|
||||||
|
| tSTATUSBAR tSET string_expression ',' expression ',' expression ',' expression {add_command(cSTATUSBARSET3,NULL);}
|
||||||
|
| tSPINCONTROL coordinates ',' string_expression ',' string_expression ',' expression ',' expression ',' expression ',' string_expression {add_command(cSPINCONTROL1,NULL);}
|
||||||
|
| tSPINCONTROL tSET string_expression ',' expression {add_command(cSPINCONTROL2,NULL);}
|
||||||
|
| tCLIPBOARD tCOPY string_expression {add_command(cCLIPBOARDCOPY,NULL);}
|
||||||
|
| tPRINTER tSETUP string_expression {add_command(cPRINTERCONFIG,NULL);}
|
||||||
|
| tMOUSE tSET string_expression {add_command(cMOUSESET,NULL);}
|
||||||
|
| tSOUND tSTOP expression {add_command(cSOUNDSTOP,NULL);}
|
||||||
|
| tSOUND tSTOP '(' expression ')' {add_command(cSOUNDSTOP,NULL);}
|
||||||
|
| tSOUND tWAIT expression {add_command(cSOUNDWAIT,NULL);}
|
||||||
|
| tSOUND tWAIT '(' expression ')' {add_command(cSOUNDWAIT,NULL);}
|
||||||
|
| tSPLITVIEW coordinates to coordinates ',' string_expression ',' expression ',' expression ',' string_expression {add_command(cSPLITVIEW1,NULL);}
|
||||||
|
| tSPLITVIEW tSET string_expression ',' string_expression ',' expression {add_command(cSPLITVIEW2,NULL);}
|
||||||
|
| tSPLITVIEW tSET string_expression ',' string_expression ',' expression ',' expression {add_command(cSPLITVIEW3,NULL);}
|
||||||
|
| tSTACKVIEW coordinates to coordinates ',' string_expression ',' expression ',' string_expression {add_command(cSTACKVIEW1,NULL);}
|
||||||
|
| tSTACKVIEW tSET string_expression ',' expression {add_command(cSTACKVIEW2,NULL);}
|
||||||
|
| tTEXTURL coordinates ',' string_expression ',' string_expression ',' string_expression ',' string_expression {add_command(cTEXTURL1, NULL);}
|
||||||
|
| tTEXTURL tCOLOUR string_expression ',' string_expression ',' expression ',' expression ',' expression {add_command(cTEXTURL2, NULL);}
|
||||||
|
| tATTRIBUTE tSET string_expression ',' string_expression ',' string_expression ',' string_expression {add_command(cATTRIBUTE1, NULL);}
|
||||||
|
| tATTRIBUTE tCLEAR string_expression ',' string_expression {add_command(cATTRIBUTECLEAR, NULL);}
|
||||||
|
| tPUTCHAR string_expression to expression ',' expression {add_command(cPUTCHAR,NULL);}
|
||||||
|
| tCLEAR tSCREEN {add_command(cCLEARSCR,NULL);}
|
||||||
|
| tWAIT expression {add_command(cWAIT,NULL);}
|
||||||
|
| tBELL {add_command(cBELL,NULL);}
|
||||||
|
| tINKEY {create_pushdbl(-1);create_function(fINKEY);add_command(cPOP,NULL);}
|
||||||
|
| tINKEY '(' ')' {create_pushdbl(-1);create_function(fINKEY);add_command(cPOP,NULL);}
|
||||||
|
| tINKEY '(' expression ')' {create_function(fINKEY);add_command(cPOP,NULL);}
|
||||||
|
| tSYSTEM2 '(' string_expression ')' {create_function(fSYSTEM2);
|
||||||
|
add_command(cPOP,NULL);}
|
||||||
|
| tPOKE string_expression ',' string_expression {create_poke('s');}
|
||||||
|
| tPOKE string_expression ',' expression {create_poke('d');}
|
||||||
|
| tPOKE hashed_number ',' string_expression {create_poke('S');}
|
||||||
|
| tPOKE hashed_number ',' expression {create_poke('D');}
|
||||||
|
| tEND {add_command(cEND,NULL);}
|
||||||
|
| tEXIT {create_pushdbl(0);add_command(cEXIT,NULL);}
|
||||||
|
| tEXIT expression {add_command(cEXIT,NULL);}
|
||||||
|
| tDOCU {create_docu($1);}
|
||||||
|
| tBIND string_expression {add_command(cBIND,NULL);}
|
||||||
|
;
|
||||||
|
|
||||||
|
/*
|
||||||
|
clear_fill_clause: * empty * {drawmode=0;}
|
||||||
|
| tCLEAR {drawmode=dmCLEAR;}
|
||||||
|
| tFILL {drawmode=dmFILL;}
|
||||||
|
| tCLEAR tFILL {drawmode=dmFILL+dmCLEAR;}
|
||||||
|
| tFILL tCLEAR {drawmode=dmFILL+dmCLEAR;}
|
||||||
|
;*/
|
||||||
|
|
||||||
|
|
||||||
|
string_assignment: tSTRSYM tEQU string_expression {add_command(cPOPSTRSYM,dotify($1,FALSE));}
|
||||||
|
| tMID '(' string_scalar_or_array ',' expression ',' expression ')' tEQU string_expression {create_changestring(fMID);}
|
||||||
|
| tMID '(' string_scalar_or_array ',' expression ')' tEQU string_expression {create_changestring(fMID2);}
|
||||||
|
| tLEFT '(' string_scalar_or_array ',' expression ')' tEQU string_expression {create_changestring(fLEFT);}
|
||||||
|
| tRIGHT '(' string_scalar_or_array ',' expression ')' tEQU string_expression {create_changestring(fRIGHT);}
|
||||||
|
| stringfunction_or_array tEQU string_expression {create_doarray(dotify($1,FALSE),ASSIGNSTRINGARRAY);}
|
||||||
|
;
|
||||||
|
|
||||||
|
to: ','
|
||||||
|
| tTO
|
||||||
|
;
|
||||||
|
|
||||||
|
open_clause: tOPEN hashed_number ',' string_expression ',' string_expression {create_myopen(OPEN_HAS_STREAM+OPEN_HAS_MODE);}
|
||||||
|
| tOPEN hashed_number ',' string_expression {create_myopen(OPEN_HAS_STREAM);}
|
||||||
|
/* | tOPEN hashed_number ',' tPRINTER {create_myopen(OPEN_HAS_STREAM+OPEN_PRINTER);} */
|
||||||
|
| tOPEN string_expression tFOR tREADING tAS hashed_number {add_command(cSWAP,NULL);create_pushstr("r");create_myopen(OPEN_HAS_STREAM+OPEN_HAS_MODE);}
|
||||||
|
| tOPEN string_expression tFOR tWRITING tAS hashed_number {add_command(cSWAP,NULL);create_pushstr("w");create_myopen(OPEN_HAS_STREAM+OPEN_HAS_MODE);}
|
||||||
|
;
|
||||||
|
|
||||||
|
seek_clause: tSEEK hashed_number ',' expression {add_command(cSEEK,NULL);}
|
||||||
|
| tSEEK hashed_number ',' expression ',' string_expression {add_command(cSEEK2,NULL);}
|
||||||
|
;
|
||||||
|
|
||||||
|
string_scalar_or_array: tSTRSYM {add_command(cPUSHSTRPTR,dotify($1,FALSE));}
|
||||||
|
| tSTRSYM '(' call_list ')' {create_doarray(dotify($1,FALSE),GETSTRINGPOINTER);}
|
||||||
|
;
|
||||||
|
|
||||||
|
string_expression: tSTRSYM {add_command(cPUSHSTRSYM,dotify($1,FALSE));}
|
||||||
|
| string_function
|
||||||
|
| stringfunction_or_array {add_command(cSTRINGFUNCTION_OR_ARRAY,$1);}
|
||||||
|
| tSTRING {if ($1==NULL) {error(ERROR,"String not terminated");create_pushstr("");} else {create_pushstr($1);}}
|
||||||
|
| string_expression '+' string_expression {add_command(cCONCAT,NULL);}
|
||||||
|
| '(' string_expression ')'
|
||||||
|
;
|
||||||
|
|
||||||
|
string_function: tLEFT '(' string_expression ',' expression ')' {create_function(fLEFT);}
|
||||||
|
| tRIGHT '(' string_expression ',' expression ')' {create_function(fRIGHT);}
|
||||||
|
| tMID '(' string_expression ',' expression ',' expression ')' {create_function(fMID);}
|
||||||
|
| tMID '(' string_expression ',' expression ')' {create_function(fMID2);}
|
||||||
|
| tSTR '(' expression ')' {create_function(fSTR);}
|
||||||
|
| tSTR '(' expression ',' string_expression ')' {create_function(fSTR2);}
|
||||||
|
| tSTR '(' expression ',' string_expression ',' string_expression ')' {create_function(fSTR3);}
|
||||||
|
| tINKEY {create_pushdbl(-1);create_function(fINKEY);}
|
||||||
|
| tINKEY '(' ')' {create_pushdbl(-1);create_function(fINKEY);}
|
||||||
|
| tINKEY '(' expression ')' {create_function(fINKEY);}
|
||||||
|
| tCHR '(' expression ')' {create_function(fCHR);}
|
||||||
|
| tUPPER '(' string_expression ')' {create_function(fUPPER);}
|
||||||
|
| tLOWER '(' string_expression ')' {create_function(fLOWER);}
|
||||||
|
| tLTRIM '(' string_expression ')' {create_function(fLTRIM);}
|
||||||
|
| tRTRIM '(' string_expression ')' {create_function(fRTRIM);}
|
||||||
|
| tTRIM '(' string_expression ')' {create_function(fTRIM);}
|
||||||
|
| tSYSTEM '(' string_expression ')' {create_function(fSYSTEM);}
|
||||||
|
| tDATE {create_function(fDATE);}
|
||||||
|
| tDATE '(' ')' {create_function(fDATE);}
|
||||||
|
| tTIME {create_function(fTIME);}
|
||||||
|
| tTIME '(' ')' {create_function(fTIME);}
|
||||||
|
| tPEEK2 '(' string_expression ')' {create_function(fPEEK2);}
|
||||||
|
| tPEEK2 '(' string_expression ',' string_expression ')' {create_function(fPEEK3);}
|
||||||
|
| tTOKENALT '(' string_scalar_or_array ',' string_expression ')' {add_command(cTOKENALT2,NULL);}
|
||||||
|
| tTOKENALT '(' string_scalar_or_array ')' {add_command(cTOKENALT,NULL);}
|
||||||
|
| tSPLITALT '(' string_scalar_or_array ',' string_expression ')' {add_command(cSPLITALT2,NULL);}
|
||||||
|
| tSPLITALT '(' string_scalar_or_array ')' {add_command(cSPLITALT,NULL);}
|
||||||
|
| tGETCHAR '(' expression ',' expression to expression ',' expression ')' {create_function(fGETCHAR);}
|
||||||
|
| tHEX '(' expression ')' {create_function(fHEX);}
|
||||||
|
| tBIN '(' expression ')' {create_function(fBIN);}
|
||||||
|
| tEXECUTE2 '(' call_list ')' {create_execute(1);add_command(cSWAP,NULL);add_command(cPOP,NULL);}
|
||||||
|
| tMESSAGE {create_function(fMESSAGE);}
|
||||||
|
| tMESSAGE '(' ')' {create_function(fMESSAGE);}
|
||||||
|
| tMOUSE tMESSAGE {create_function(fMOUSEMOVE);}
|
||||||
|
| tMOUSE tMESSAGE '(' ')' {create_function(fMOUSEMOVE);}
|
||||||
|
| tTRANSLATE '(' string_expression ')' {create_function(fTRANSLATE);}
|
||||||
|
| tMENU tTRANSLATE '(' string_expression ')' {create_function(fMENUTRANSLATE);}
|
||||||
|
| tTEXTEDIT tGET string_expression {create_function(fTEXTGET);}
|
||||||
|
| tTEXTEDIT tGET string_expression ',' expression {create_function(fTEXTGET3);}
|
||||||
|
| tTEXTEDIT tGET string_expression ',' string_expression {create_function(fTEXTGET6);}
|
||||||
|
| tTEXTCONTROL tGET string_expression {create_function(fTEXTCONTROLGET);}
|
||||||
|
| tFILEPANEL string_expression ',' string_expression ',' string_expression {create_function(fLOAD);}
|
||||||
|
| tFILEPANEL string_expression ',' string_expression ',' string_expression ',' string_expression {create_function(fSAVE);}
|
||||||
|
| tMOUSE tMESSAGE string_expression {create_function(fMOUSE);}
|
||||||
|
//| tMOUSE tMESSAGE '(' string_expression ')' {create_function(fMOUSE);}
|
||||||
|
| tKEYBOARD tMESSAGE string_expression {create_function(fKEYBOARD);}
|
||||||
|
//| tKEYBOARD tMESSAGE '(' string_expression ')' {create_function(fKEYBOARD);}
|
||||||
|
| tCLIPBOARD tPASTE {create_function(fCLIPBOARDPASTE);}
|
||||||
|
| tCOLUMNBOX tGET string_expression ',' expression ',' expression {create_function(fCOLUMNBOXGET);}
|
||||||
|
| tCALENDAR tGET string_expression {create_function(fCALENDAR);}
|
||||||
|
| tLISTBOX tGET string_expression ',' expression {create_function(fLISTBOXGET);}
|
||||||
|
| tTREEBOX tGET string_expression ',' expression {create_function(fTREEBOXGET);}
|
||||||
|
| tPOPUPMENU coordinates ',' string_expression ',' string_expression {create_function(fPOPUPMENU);}
|
||||||
|
| tDROPBOX tGET string_expression ',' expression {create_function(fDROPBOXGET);}
|
||||||
|
| tDRAW tGET string_expression {create_function(fDRAWGET3);}
|
||||||
|
| tATTRIBUTE tGET string_expression ',' string_expression {create_function(fATTRIBUTEGET1);}
|
||||||
|
;
|
||||||
|
|
||||||
|
assignment: tSYMBOL tEQU expression {add_command(cPOPDBLSYM,dotify($1,FALSE));}
|
||||||
|
| function_or_array tEQU expression {create_doarray($1,ASSIGNARRAY);}
|
||||||
|
;
|
||||||
|
|
||||||
|
expression: expression tOR {add_command(cORSHORT,NULL);pushlabel();} expression {poplabel();create_boole('|');}
|
||||||
|
| expression tAND {add_command(cANDSHORT,NULL);pushlabel();} expression {poplabel();create_boole('&');}
|
||||||
|
| tNOT expression {create_boole('!');}
|
||||||
|
| expression tEQU expression {create_dblrelop('=');}
|
||||||
|
| expression tNEQ expression {create_dblrelop('!');}
|
||||||
|
| expression tLTN expression {create_dblrelop('<');}
|
||||||
|
| expression tLEQ expression {create_dblrelop('{');}
|
||||||
|
| expression tGTN expression {create_dblrelop('>');}
|
||||||
|
| expression tGEQ expression {create_dblrelop('}');}
|
||||||
|
| tMYEOF '(' hashed_number ')' {add_command(cTESTEOF,NULL);}
|
||||||
|
| tGLOB '(' string_expression ',' string_expression ')' {add_command(cGLOB,NULL);}
|
||||||
|
| number {create_pushdbl($1);}
|
||||||
|
| tARDIM '(' arrayref ')' {add_command(cARDIM,"");}
|
||||||
|
| tARDIM '(' string_arrayref ')' {add_command(cARDIM,"");}
|
||||||
|
| tARSIZE '(' arrayref ',' expression ')' {add_command(cARSIZE,"");}
|
||||||
|
| tARSIZE '(' string_arrayref ',' expression ')' {add_command(cARSIZE,"");}
|
||||||
|
| function_or_array {add_command(cFUNCTION_OR_ARRAY,$1);}
|
||||||
|
| tSYMBOL {add_command(cPUSHDBLSYM,dotify($1,FALSE));}
|
||||||
|
| expression '+' expression {create_dblbin('+');}
|
||||||
|
| expression '-' expression {create_dblbin('-');}
|
||||||
|
| expression '*' expression {create_dblbin('*');}
|
||||||
|
| expression '/' expression {create_dblbin('/');}
|
||||||
|
| expression tPOW expression {create_dblbin('^');}
|
||||||
|
| '-' expression %prec UMINUS {add_command(cNEGATE,NULL);}
|
||||||
|
| string_expression tEQU string_expression {create_strrelop('=');}
|
||||||
|
| string_expression tNEQ string_expression {create_strrelop('!');}
|
||||||
|
| string_expression tLTN string_expression {create_strrelop('<');}
|
||||||
|
| string_expression tLEQ string_expression {create_strrelop('{');}
|
||||||
|
| string_expression tGTN string_expression {create_strrelop('>');}
|
||||||
|
| string_expression tGEQ string_expression {create_strrelop('}');}
|
||||||
|
| function
|
||||||
|
| '(' expression ')'
|
||||||
|
;
|
||||||
|
|
||||||
|
arrayref: tSYMBOL '(' ')' {create_pusharrayref(dotify($1,FALSE),stNUMBERARRAYREF);}
|
||||||
|
;
|
||||||
|
|
||||||
|
string_arrayref: tSTRSYM '(' ')' {create_pusharrayref(dotify($1,FALSE),stSTRINGARRAYREF);}
|
||||||
|
;
|
||||||
|
|
||||||
|
coordinates: expression ',' expression
|
||||||
|
;
|
||||||
|
|
||||||
|
function: tSIN '(' expression ')' {create_function(fSIN);}
|
||||||
|
| tASIN '(' expression ')' {create_function(fASIN);}
|
||||||
|
| tCOS '(' expression ')' {create_function(fCOS);}
|
||||||
|
| tACOS '(' expression ')' {create_function(fACOS);}
|
||||||
|
| tTAN '(' expression ')' {create_function(fTAN);}
|
||||||
|
| tATAN '(' expression ')' {create_function(fATAN);}
|
||||||
|
| tATAN '(' expression ',' expression ')' {create_function(fATAN2);}
|
||||||
|
| tEXP '(' expression ')' {create_function(fEXP);}
|
||||||
|
| tLOG '(' expression ')' {create_function(fLOG);}
|
||||||
|
| tLOG '(' expression ',' expression ')' {create_function(fLOG2);}
|
||||||
|
| tSQRT '(' expression ')' {create_function(fSQRT);}
|
||||||
|
| tSQR '(' expression ')' {create_function(fSQR);}
|
||||||
|
| tINT '(' expression ')' {create_function(fINT);}
|
||||||
|
| tFRAC '(' expression ')' {create_function(fFRAC);}
|
||||||
|
| tABS '(' expression ')' {create_function(fABS);}
|
||||||
|
| tSIG '(' expression ')' {create_function(fSIG);}
|
||||||
|
| tMOD '(' expression ',' expression ')' {create_function(fMOD);}
|
||||||
|
| tRAN '(' expression ')' {create_function(fRAN);}
|
||||||
|
| tRAN '(' ')' {create_function(fRAN2);}
|
||||||
|
| tMIN '(' expression ',' expression ')' {create_function(fMIN);}
|
||||||
|
| tMAX '(' expression ',' expression ')' {create_function(fMAX);}
|
||||||
|
| tLEN '(' string_expression ')' {create_function(fLEN);}
|
||||||
|
| tVAL '(' string_expression ')' {create_function(fVAL);}
|
||||||
|
| tASC '(' string_expression ')' {create_function(fASC);}
|
||||||
|
| tDEC '(' string_expression ')' {create_function(fDEC);}
|
||||||
|
| tDEC '(' string_expression ',' expression ')' {create_function(fDEC2);}
|
||||||
|
| tINSTR '(' string_expression ',' string_expression ')' {if (check_compat) error(WARNING,"instr() has changed in version 2.712"); create_function(fINSTR);}
|
||||||
|
| tINSTR '(' string_expression ',' string_expression ',' expression ')' {create_function(fINSTR2);}
|
||||||
|
| tRINSTR '(' string_expression ',' string_expression ')' {create_function(fRINSTR);}
|
||||||
|
| tRINSTR '(' string_expression ',' string_expression ',' expression ')' {create_function(fRINSTR2);}
|
||||||
|
| tSYSTEM2 '(' string_expression ')' {create_function(fSYSTEM2);}
|
||||||
|
| tPEEK '(' hashed_number ')' {create_function(fPEEK4);}
|
||||||
|
| tPEEK '(' string_expression ')' {create_function(fPEEK);}
|
||||||
|
/*
|
||||||
|
| tMOUSEX '(' string_expression ')' {create_function(fMOUSEX);}
|
||||||
|
| tMOUSEX {create_pushstr("");create_function(fMOUSEX);}
|
||||||
|
| tMOUSEX '(' ')' {create_pushstr("");create_function(fMOUSEX);}
|
||||||
|
| tMOUSEY '(' string_expression ')' {create_function(fMOUSEY);}
|
||||||
|
| tMOUSEY {create_pushstr("");create_function(fMOUSEY);}
|
||||||
|
| tMOUSEY '(' ')' {create_pushstr("");create_function(fMOUSEY);}
|
||||||
|
| tMOUSEB '(' string_expression ')' {create_function(fMOUSEB);}
|
||||||
|
| tMOUSEB {create_pushstr("");create_function(fMOUSEB);}
|
||||||
|
| tMOUSEB '(' ')' {create_pushstr("");create_function(fMOUSEB);}
|
||||||
|
| tMOUSEMOD '(' string_expression ')' {create_function(fMOUSEMOD);}
|
||||||
|
| tMOUSEMOD {create_pushstr("");create_function(fMOUSEMOD);}
|
||||||
|
| tMOUSEMOD '(' ')' {create_pushstr("");create_function(fMOUSEMOD);}*/
|
||||||
|
| tAND '(' expression ',' expression ')' {create_function(fAND);}
|
||||||
|
| tOR '(' expression ',' expression ')' {create_function(fOR);}
|
||||||
|
| tEOR '(' expression ',' expression ')' {create_function(fEOR);}
|
||||||
|
| tTELL '(' hashed_number ')' {create_function(fTELL);}
|
||||||
|
| tTOKEN '(' string_expression ',' string_arrayref ',' string_expression ')' {add_command(cTOKEN2,NULL);}
|
||||||
|
| tTOKEN '(' string_expression ',' string_arrayref ')' {add_command(cTOKEN,NULL);}
|
||||||
|
| tSPLIT '(' string_expression ',' string_arrayref ',' string_expression ')' {add_command(cSPLIT2,NULL);}
|
||||||
|
| tSPLIT '(' string_expression ',' string_arrayref ')' {add_command(cSPLIT,NULL);}
|
||||||
|
| tEXECUTE '(' call_list ')' {create_execute(0);add_command(cSWAP,NULL);add_command(cPOP,NULL);}
|
||||||
|
| tOPEN '(' string_expression ')' {create_myopen(0);}
|
||||||
|
| tOPEN '(' string_expression ',' string_expression ')' {create_myopen(OPEN_HAS_MODE);}
|
||||||
|
| tOPEN '(' hashed_number ',' string_expression ')' {create_myopen(OPEN_HAS_STREAM);}
|
||||||
|
| tOPEN '(' hashed_number ',' string_expression ',' string_expression ')' {create_myopen(OPEN_HAS_STREAM+OPEN_HAS_MODE);}
|
||||||
|
| tDRAW tIMAGE expression ',' expression ',' string_expression ',' string_expression {create_function(fDRAWIMAGE);}
|
||||||
|
| tDRAW tIMAGE coordinates to coordinates ',' string_expression ',' string_expression {create_function(fDRAWIMAGE2);}
|
||||||
|
| tSVG coordinates to coordinates ',' string_expression ',' string_expression {create_function(fDRAWSVG);}
|
||||||
|
| tWINDOW tCOUNT {create_function(fNUMWINDOWS);}
|
||||||
|
// | tISMOUSEIN '(' string_expression ')' {create_function(fISMOUSEIN);}
|
||||||
|
| tISMOUSEIN string_expression {create_function(fISMOUSEIN);}
|
||||||
|
| tCOLUMNBOX tCOUNT string_expression {create_function(fCOLUMNBOXCOUNT);}
|
||||||
|
| tWINDOW tGETNUM string_expression ',' string_expression {create_function(fWINDOWGET);}
|
||||||
|
| tVIEW tGETNUM string_expression ',' string_expression {create_function(fVIEWGET);}
|
||||||
|
| tALERT string_expression ',' string_expression ',' string_expression ',' string_expression ',' string_expression {create_function(fALERT);}
|
||||||
|
| tLISTBOX tCOUNT string_expression {create_function(fLISTBOXCOUNT);}
|
||||||
|
| tTREEBOX tCOUNT string_expression {create_function(fTREEBOXCOUNT);}
|
||||||
|
| tSCROLLBAR tGETNUM string_expression ',' string_expression {create_function(fSCROLLBARGET);}
|
||||||
|
| tSPLITVIEW tGETNUM string_expression ',' string_expression {create_function(fSPLITVIEWGET);}
|
||||||
|
| tSTACKVIEW tGETNUM string_expression {create_function(fSTACKVIEWGET);}
|
||||||
|
| tTABVIEW tGETNUM string_expression {create_function(fTABVIEWGET);}
|
||||||
|
| tSPINCONTROL tGETNUM string_expression {create_function(fSPINCONTROLGET);}
|
||||||
|
| tDROPBOX tCOUNT string_expression {create_function(fDROPBOXCOUNT);}
|
||||||
|
| tSLIDER tGETNUM string_expression {create_function(fSLIDERGET);}
|
||||||
|
| tCOLORCONTROL tGETNUM string_expression ',' string_expression {create_function(fCOLORCONTROLGET);}
|
||||||
|
| tTEXTEDIT tGETNUM string_expression ',' string_expression {create_function(fTEXTGET2);}
|
||||||
|
| tTEXTEDIT tGETNUM string_expression ',' string_expression ',' expression {create_function(fTEXTGET4);}
|
||||||
|
| tTEXTEDIT tGETNUM string_expression ',' string_expression ',' string_expression {create_function(fTEXTGET5);}
|
||||||
|
| tDRAW tGETNUM string_expression ',' string_expression ',' string_expression {create_function(fDRAWGET1);}
|
||||||
|
| tDRAW tGETNUM string_expression ',' string_expression {create_function(fDRAWGET2);}
|
||||||
|
| tDRAW tGETNUM coordinates ',' string_expression ',' string_expression {create_function(fDRAWGET4);}
|
||||||
|
| tNUMMESSAGE tMSEND string_expression ',' string_expression {create_function(fMESSAGESEND);}
|
||||||
|
| tTHREAD tREMOVE string_expression ',' expression {create_function(fTHREADKILL);}
|
||||||
|
| tTHREAD tGETNUM string_expression ',' string_expression {create_function(fTHREADGET);}
|
||||||
|
| tPRINTER string_expression ',' string_expression ',' string_expression {create_function(fPRINTER);}
|
||||||
|
| tSOUND tPLAY string_expression {create_function(fSOUND);}
|
||||||
|
| tISCOMPUTERON {create_function(fISCOMPUTERON);}
|
||||||
|
| tLISTBOX tGETNUM string_expression {create_function(fLISTBOXGETNUM);}
|
||||||
|
| tDROPBOX tGETNUM string_expression {create_function(fDROPBOXGETNUM);}
|
||||||
|
| tTREEBOX tGETNUM string_expression {create_function(fTREEBOXGETNUM);}
|
||||||
|
| tCOLUMNBOX tGETNUM string_expression {create_function(fCOLUMNBOXGETNUM);}
|
||||||
|
| tTREEBOX tGETNUM string_expression ',' string_expression ',' expression {create_function(fTREEBOXGETOPT);}
|
||||||
|
| tBITMAP tSAVE string_expression ',' string_expression ',' string_expression {create_function(fBITMAPSAVE);}
|
||||||
|
| tBITMAP tIMAGE string_expression ',' string_expression {create_function(fBITMAPLOAD);}
|
||||||
|
| tBITMAP tGETNUM string_expression ',' string_expression {create_function(fBITMAPGET);}
|
||||||
|
| tBITMAP tCOLOUR expression ',' expression ',' string_expression ',' string_expression {create_function(fBITMAPCOLOR);}
|
||||||
|
| tATTRIBUTE tGETNUM string_expression ',' string_expression {create_function(fATTRIBUTEGET2);}
|
||||||
|
;
|
||||||
|
|
||||||
|
const: number {$$=$1;}
|
||||||
|
| '+' number {$$=$2;}
|
||||||
|
| '-' number {$$=-$2;}
|
||||||
|
;
|
||||||
|
|
||||||
|
number: tFNUM {$$=$1;}
|
||||||
|
| tDIGITS {$$=strtod($1,NULL);}
|
||||||
|
;
|
||||||
|
|
||||||
|
symbol_or_lineno: tDIGITS {$$=my_strdup(dotify($1,FALSE));}
|
||||||
|
| tSYMBOL {$$=my_strdup(dotify($1,FALSE));}
|
||||||
|
;
|
||||||
|
|
||||||
|
dimlist: tSYMBOL '(' call_list ')' {create_dim(dotify($1,FALSE),'D');}
|
||||||
|
| dimlist ',' tSYMBOL '(' call_list ')' {create_dim(dotify($3,FALSE),'D');}
|
||||||
|
| tSTRSYM '(' call_list ')' {create_dim(dotify($1,FALSE),'S');}
|
||||||
|
| dimlist ',' tSTRSYM '(' call_list ')' {create_dim(dotify($3,FALSE),'S');}
|
||||||
|
;
|
||||||
|
|
||||||
|
function_or_array: tSYMBOL '(' call_list ')' {$$=my_strdup(dotify($1,FALSE));}
|
||||||
|
;
|
||||||
|
|
||||||
|
stringfunction_or_array: tSTRSYM '(' call_list ')' {$$=my_strdup(dotify($1,FALSE));}
|
||||||
|
;
|
||||||
|
|
||||||
|
call_list: {add_command(cPUSHFREE,NULL);} calls
|
||||||
|
;
|
||||||
|
|
||||||
|
calls: /* empty */
|
||||||
|
| call_item
|
||||||
|
| calls ',' call_item
|
||||||
|
;
|
||||||
|
|
||||||
|
call_item: string_expression
|
||||||
|
| expression
|
||||||
|
;
|
||||||
|
|
||||||
|
function_definition: export tSUB {missing_endsub++;missing_endsub_line=mylineno;pushlabel();report_missing(WARNING,"do not define a function in a loop or an if-statement");if (function_type!=ftNONE) {error(ERROR,"nested functions not allowed");YYABORT;}}
|
||||||
|
function_name {if (exported) create_sublink($4); create_label($4,cUSER_FUNCTION);
|
||||||
|
add_command(cPUSHSYMLIST,NULL);add_command(cCLEARREFS,NULL);firstref=lastref=lastcmd;
|
||||||
|
create_numparam();}
|
||||||
|
'(' paramlist ')' {create_require(stFREE);add_command(cPOP,NULL);}
|
||||||
|
statement_list
|
||||||
|
endsub {add_command(cCLEARREFS,NULL);lastcmd->nextref=firstref;add_command(cPOPSYMLIST,NULL);create_retval(ftNONE,function_type);function_type=ftNONE;add_command(cRET_FROM_FUN,NULL);lastref=NULL;create_endfunction();poplabel();}
|
||||||
|
;
|
||||||
|
|
||||||
|
endsub: tEOPROG {if (missing_endsub) {sprintf(string,"%d end-sub(s) are missing (last at line %d)",missing_endsub,missing_endsub_line);error(ERROR,string);} YYABORT;}
|
||||||
|
| tENDSUB {missing_endsub--;}
|
||||||
|
;
|
||||||
|
|
||||||
|
function_name: tSYMBOL {function_type=ftNUMBER;current_function=my_strdup(dotify($1,FALSE));$$=my_strdup(dotify($1,FALSE));}
|
||||||
|
| tSTRSYM {function_type=ftSTRING;current_function=my_strdup(dotify($1,FALSE));$$=my_strdup(dotify($1,FALSE));}
|
||||||
|
;
|
||||||
|
|
||||||
|
export: /* empty */ {exported=FALSE;}
|
||||||
|
| tEXPORT {exported=TRUE;}
|
||||||
|
| tRUNTIME_CREATED_SUB {exported=FALSE;}
|
||||||
|
| tRUNTIME_CREATED_SUB tEXPORT {exported=TRUE;}
|
||||||
|
;
|
||||||
|
|
||||||
|
local_list: local_item
|
||||||
|
| local_list ',' local_item
|
||||||
|
;
|
||||||
|
|
||||||
|
local_item: tSYMBOL {create_makelocal(dotify($1,FALSE),syNUMBER);}
|
||||||
|
| tSTRSYM {create_makelocal(dotify($1,FALSE),sySTRING);}
|
||||||
|
| tSYMBOL '(' call_list ')' {create_makelocal(dotify($1,FALSE),syARRAY);create_dim(dotify($1,FALSE),'d');}
|
||||||
|
| tSTRSYM '(' call_list ')' {create_makelocal(dotify($1,FALSE),syARRAY);create_dim(dotify($1,FALSE),'s');}
|
||||||
|
;
|
||||||
|
|
||||||
|
static_list: static_item
|
||||||
|
| static_list ',' static_item
|
||||||
|
;
|
||||||
|
|
||||||
|
static_item: tSYMBOL {create_makestatic(dotify($1,TRUE),syNUMBER);}
|
||||||
|
| tSTRSYM {create_makestatic(dotify($1,TRUE),sySTRING);}
|
||||||
|
| tSYMBOL '(' call_list ')' {create_makestatic(dotify($1,TRUE),syARRAY);create_dim(dotify($1,TRUE),'D');}
|
||||||
|
| tSTRSYM '(' call_list ')' {create_makestatic(dotify($1,TRUE),syARRAY);create_dim(dotify($1,TRUE),'S');}
|
||||||
|
;
|
||||||
|
|
||||||
|
paramlist: /* empty */
|
||||||
|
| paramitem
|
||||||
|
| paramlist ',' paramitem
|
||||||
|
;
|
||||||
|
|
||||||
|
paramitem: tSYMBOL {create_require(stNUMBER);create_makelocal(dotify($1,FALSE),syNUMBER);add_command(cPOPDBLSYM,dotify($1,FALSE));}
|
||||||
|
| tSTRSYM {create_require(stSTRING);create_makelocal(dotify($1,FALSE),sySTRING);add_command(cPOPSTRSYM,dotify($1,FALSE));}
|
||||||
|
| tSYMBOL '(' ')' {create_require(stNUMBERARRAYREF);create_arraylink(dotify($1,FALSE),stNUMBERARRAYREF);}
|
||||||
|
| tSTRSYM '(' ')' {create_require(stSTRINGARRAYREF);create_arraylink(dotify($1,FALSE),stSTRINGARRAYREF);}
|
||||||
|
;
|
||||||
|
|
||||||
|
for_loop: tFOR {missing_next++;missing_next_line=mylineno;} tSYMBOL tEQU
|
||||||
|
{pushname(dotify($3,FALSE)); /* will be used by next_symbol to check equality */
|
||||||
|
add_command(cRESETSKIPONCE,NULL);
|
||||||
|
pushgoto();add_command(cCONTINUE_HERE,NULL);create_break_mark(0,1);}
|
||||||
|
expression tTO expression
|
||||||
|
step_part { /* pushes another expression */
|
||||||
|
add_command(cSKIPONCE,NULL);
|
||||||
|
pushlabel();
|
||||||
|
add_command(cSTARTFOR,NULL);
|
||||||
|
add_command(cPOPDBLSYM,dotify($3,FALSE));
|
||||||
|
poplabel();
|
||||||
|
add_command(cPUSHDBLSYM,dotify($3,FALSE));
|
||||||
|
add_command(cFORINCREMENT,NULL);
|
||||||
|
add_command(cPOPDBLSYM,dotify($3,FALSE));
|
||||||
|
add_command(cPUSHDBLSYM,dotify($3,FALSE));
|
||||||
|
add_command(cFORCHECK,NULL);
|
||||||
|
add_command(cDECIDE,NULL);
|
||||||
|
pushlabel();}
|
||||||
|
statement_list {
|
||||||
|
swap();popgoto();poplabel();}
|
||||||
|
next next_symbol {create_break_mark(0,-1);add_command(cBREAK_HERE,NULL);}
|
||||||
|
;
|
||||||
|
|
||||||
|
next: tEOPROG {if (missing_next) {sprintf(string,"%d next(s) are missing (last at line %d)",missing_next,missing_next_line);error(ERROR,string);} YYABORT;}
|
||||||
|
| tNEXT {missing_next--;}
|
||||||
|
;
|
||||||
|
|
||||||
|
step_part: {create_pushdbl(1);} /* can be omitted */
|
||||||
|
| tSTEP expression
|
||||||
|
;
|
||||||
|
|
||||||
|
next_symbol: {pop(stSTRING);}/* can be omitted */
|
||||||
|
| tSYMBOL {if (strcmp(pop(stSTRING)->pointer,dotify($1,FALSE)))
|
||||||
|
{error(ERROR,"'for' and 'next' do not match"); YYABORT;}
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
switch_number_or_string: tSWITCH {push_switch_id();add_command(cPUSH_SWITCH_MARK,NULL);create_break_mark(0,1);
|
||||||
|
add_command(cCONTINUE_CORRECTION,NULL);}
|
||||||
|
number_or_string sep_list case_list default tSEND {create_break_mark(-1,0);add_command(cBREAK_HERE,NULL);create_break_mark(0,-1);add_command(cBREAK_HERE,NULL);create_clean_switch_mark(0,FALSE);pop_switch_id();}
|
||||||
|
;
|
||||||
|
|
||||||
|
sep_list: tSEP {if ($1>=0) mylineno+=$1;}
|
||||||
|
| sep_list tSEP {if ($2>=0) mylineno+=$2;}
|
||||||
|
;
|
||||||
|
|
||||||
|
number_or_string: expression
|
||||||
|
| string_expression
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
case_list: /* empty */
|
||||||
|
| case_list tCASE {create_break_mark(-1,0);add_command(cBREAK_HERE,NULL);} number_or_string
|
||||||
|
{add_command(cSWITCH_COMPARE,NULL);add_command(cDECIDE,NULL);add_command(cMINOR_BREAK,NULL);create_break_mark(1,0);} statement_list {add_command(cNEXT_CASE,NULL);}
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
default: /* empty */
|
||||||
|
| tDEFAULT tSEP {if ($2>=0) mylineno+=$2; create_break_mark(-1,0);add_command(cBREAK_HERE,NULL);} statement_list
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
do_loop: tDO {add_command(cCONTINUE_HERE,NULL);create_break_mark(0,1);missing_loop++;missing_loop_line=mylineno;pushgoto();}
|
||||||
|
statement_list
|
||||||
|
loop
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
loop: tEOPROG {if (missing_loop) {sprintf(string,"%d loop(s) are missing (last at line %d)",missing_loop,missing_loop_line);error(ERROR,string);} YYABORT;}
|
||||||
|
| tLOOP {missing_loop--;popgoto();create_break_mark(0,-1);add_command(cBREAK_HERE,NULL);}
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
while_loop: tWHILE {add_command(cCONTINUE_HERE,NULL);create_break_mark(0,1);missing_wend++;missing_wend_line=mylineno;pushgoto()} '(' expression ')'
|
||||||
|
{add_command(cDECIDE,NULL);
|
||||||
|
pushlabel();}
|
||||||
|
statement_list
|
||||||
|
wend
|
||||||
|
;
|
||||||
|
|
||||||
|
wend: tEOPROG {if (missing_wend) {sprintf(string,"%d wend(s) are missing (last at line %d)",missing_wend,missing_wend_line);error(ERROR,string);} YYABORT;}
|
||||||
|
| tWEND {missing_wend--;swap();popgoto();poplabel();create_break_mark(0,-1);add_command(cBREAK_HERE,NULL);}
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
repeat_loop: tREPEAT {add_command(cCONTINUE_HERE,NULL);create_break_mark(0,1);missing_until++;missing_until_line=mylineno;pushgoto();}
|
||||||
|
statement_list
|
||||||
|
until
|
||||||
|
;
|
||||||
|
|
||||||
|
until: tEOPROG {if (missing_until) {sprintf(string,"%d until(s) are missing (last at line %d)",missing_until,missing_until_line);error(ERROR,string);} YYABORT;}
|
||||||
|
| tUNTIL '(' expression ')'
|
||||||
|
{missing_until--;add_command(cDECIDE,NULL);popgoto();create_break_mark(0,-1);add_command(cBREAK_HERE,NULL);}
|
||||||
|
;
|
||||||
|
|
||||||
|
if_clause: tIF expression {add_command(cDECIDE,NULL);storelabel();pushlabel();}
|
||||||
|
tTHEN {missing_endif++;missing_endif_line=mylineno;} statement_list {swap();matchgoto();swap();poplabel();}
|
||||||
|
elsif_part
|
||||||
|
else_part {poplabel();}
|
||||||
|
endif
|
||||||
|
;
|
||||||
|
|
||||||
|
endif: tEOPROG {if (missing_endif) {sprintf(string,"%d endif(s) are missing (last at line %d)",missing_endif,missing_endif_line);error(ERROR,string);} YYABORT;}
|
||||||
|
| tENDIF {missing_endif--;}
|
||||||
|
;
|
||||||
|
|
||||||
|
short_if: tIF expression {fi_pending++;add_command(cDECIDE,NULL);pushlabel();}
|
||||||
|
statement_list tENDIF {poplabel();}
|
||||||
|
;
|
||||||
|
|
||||||
|
else_part: /* can be omitted */
|
||||||
|
| tELSE statement_list
|
||||||
|
;
|
||||||
|
|
||||||
|
elsif_part: /* can be omitted */
|
||||||
|
| tELSIF expression maybe_then
|
||||||
|
{add_command(cDECIDE,NULL);pushlabel();}
|
||||||
|
statement_list
|
||||||
|
{swap();matchgoto();swap();poplabel();}
|
||||||
|
elsif_part
|
||||||
|
;
|
||||||
|
|
||||||
|
maybe_then: /* can be omitted */
|
||||||
|
| tTHEN
|
||||||
|
;
|
||||||
|
|
||||||
|
inputlist: input
|
||||||
|
| input ',' {add_command(cCHKPROMPT,NULL);} inputlist
|
||||||
|
;
|
||||||
|
|
||||||
|
input: tSYMBOL {create_myread('d',tileol);add_command(cPOPDBLSYM,dotify($1,FALSE));}
|
||||||
|
| tSYMBOL '(' call_list ')'
|
||||||
|
{create_myread('d',tileol);create_doarray(dotify($1,FALSE),ASSIGNARRAY);}
|
||||||
|
| tSTRSYM {create_myread('s',tileol);add_command(cPOPSTRSYM,dotify($1,FALSE));}
|
||||||
|
| tSTRSYM '(' call_list ')'
|
||||||
|
{create_myread('s',tileol);create_doarray(dotify($1,FALSE),ASSIGNSTRINGARRAY);}
|
||||||
|
;
|
||||||
|
|
||||||
|
readlist: readitem
|
||||||
|
| readlist ',' readitem
|
||||||
|
;
|
||||||
|
|
||||||
|
readitem: tSYMBOL {create_readdata('d');add_command(cPOPDBLSYM,dotify($1,FALSE));}
|
||||||
|
| tSYMBOL '(' call_list ')'
|
||||||
|
{create_readdata('d');create_doarray(dotify($1,FALSE),ASSIGNARRAY);}
|
||||||
|
| tSTRSYM {create_readdata('s');add_command(cPOPSTRSYM,dotify($1,FALSE));}
|
||||||
|
| tSTRSYM '(' call_list ')'
|
||||||
|
{create_readdata('s');create_doarray(dotify($1,FALSE),ASSIGNSTRINGARRAY);}
|
||||||
|
;
|
||||||
|
|
||||||
|
datalist: tSTRING {create_strdata($1);}
|
||||||
|
| const {create_dbldata($1);}
|
||||||
|
| datalist ',' tSTRING {create_strdata($3);}
|
||||||
|
| datalist ',' const {create_dbldata($3);}
|
||||||
|
;
|
||||||
|
|
||||||
|
printlist: /* possible empty */
|
||||||
|
| expression using
|
||||||
|
| printlist ',' expression using
|
||||||
|
| string_expression {create_print('s');}
|
||||||
|
| printlist ',' string_expression {create_print('s');}
|
||||||
|
;
|
||||||
|
|
||||||
|
using: {create_print('d');} /* possible empty */
|
||||||
|
| tUSING string_expression {create_print('u');}
|
||||||
|
| tUSING '(' string_expression ',' string_expression ')' {create_print('U');}
|
||||||
|
;
|
||||||
|
|
||||||
|
inputbody: '#' tSYMBOL {add_command(cPUSHDBLSYM,dotify($2,FALSE));create_pps(cPUSHSTREAM,1);} inputlist {create_pps(cPOPSTREAM,0);}
|
||||||
|
| '#' tDIGITS {create_pushdbl(atoi($2));create_pps(cPUSHSTREAM,1);} inputlist {create_pps(cPOPSTREAM,0);}
|
||||||
|
| '#' '(' expression ')' {create_pps(cPUSHSTREAM,1);} inputlist {create_pps(cPOPSTREAM,0);}
|
||||||
|
| tAT '(' expression ',' expression ')' {add_command(cMOVE,NULL);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,1);} prompt inputlist {create_pps(cPOPSTREAM,0);}
|
||||||
|
| {create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,1);} prompt inputlist {create_pps(cPOPSTREAM,0);}
|
||||||
|
;
|
||||||
|
|
||||||
|
prompt: /* empty */ {create_pushstr("?");create_print('s');}
|
||||||
|
| tSTRING {create_pushstr($1);create_print('s');}
|
||||||
|
;
|
||||||
|
|
||||||
|
printintro: /* may be empty */ {create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}
|
||||||
|
| '#' tSYMBOL {add_command(cPUSHDBLSYM,dotify($2,FALSE));create_pps(cPUSHSTREAM,0);}
|
||||||
|
| '#' tDIGITS {create_pushdbl(atoi($2));create_pps(cPUSHSTREAM,0);}
|
||||||
|
| '#' '(' expression ')' {create_pps(cPUSHSTREAM,0);}
|
||||||
|
| tREVERSE {create_colour(1);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}
|
||||||
|
| tCOLOUR '(' string_expression ')' {create_colour(2);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}
|
||||||
|
| tCOLOUR '(' string_expression ',' string_expression ')' {create_colour(3);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}
|
||||||
|
| tAT '(' expression ',' expression ')' {add_command(cMOVE,NULL);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}
|
||||||
|
| tREVERSE tAT '(' expression ',' expression ')' {add_command(cMOVE,NULL);create_colour(1);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}
|
||||||
|
| tCOLOUR '(' string_expression ')' tAT '(' expression ',' expression ')' {add_command(cMOVE,NULL);create_colour(2);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}
|
||||||
|
| tCOLOUR '(' string_expression ',' string_expression ')' tAT '(' expression ',' expression ')' {add_command(cMOVE,NULL);create_colour(3);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);}
|
||||||
|
| tAT '(' expression ',' expression ')' tREVERSE {create_colour(1);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);add_command(cMOVE,NULL);}
|
||||||
|
| tAT '(' expression ',' expression ')' tCOLOUR '(' string_expression ')' {create_colour(2);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);add_command(cMOVE,NULL);}
|
||||||
|
| tAT '(' expression ',' expression ')' tCOLOUR '(' string_expression ',' string_expression ')' {create_colour(3);create_pushdbl(STDIO_STREAM);create_pps(cPUSHSTREAM,0);add_command(cMOVE,NULL);}
|
||||||
|
;
|
||||||
|
|
||||||
|
hashed_number: '#' expression
|
||||||
|
| expression;
|
||||||
|
|
||||||
|
goto_list: symbol_or_lineno {create_goto((function_type!=ftNONE)?dotify($1,TRUE):$1);add_command(cFINDNOP,NULL);}
|
||||||
|
| goto_list ',' symbol_or_lineno {create_goto((function_type!=ftNONE)?dotify($3,TRUE):$3);add_command(cFINDNOP,NULL);}
|
||||||
|
;
|
||||||
|
|
||||||
|
gosub_list: symbol_or_lineno {create_gosub((function_type!=ftNONE)?dotify($1,TRUE):$1);add_command(cFINDNOP,NULL);}
|
||||||
|
| gosub_list ',' symbol_or_lineno {create_gosub((function_type!=ftNONE)?dotify($3,TRUE):$3);add_command(cFINDNOP,NULL);}
|
||||||
|
;
|
||||||
|
|
||||||
560
src/yabasic.flex
Normal file
560
src/yabasic.flex
Normal file
@@ -0,0 +1,560 @@
|
|||||||
|
%{
|
||||||
|
/*
|
||||||
|
|
||||||
|
YABASIC --- a simple Basic Interpreter
|
||||||
|
written by Marc-Oliver Ihm 1995-2004
|
||||||
|
homepage: www.yabasic.de
|
||||||
|
|
||||||
|
FLEX part
|
||||||
|
|
||||||
|
This file is part of yabasic and may be copied only
|
||||||
|
under the terms of either the Artistic License or
|
||||||
|
the GNU General Public License (GPL), both of which
|
||||||
|
can be found at www.yabasic.de
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#undef WINDOWS
|
||||||
|
|
||||||
|
#include "bison.h" /* get tokens from BISON */
|
||||||
|
#ifndef YABASIC_INCLUDED
|
||||||
|
#include "yabasic.h" /* definitions of yabasic */
|
||||||
|
#endif
|
||||||
|
extern int main_lineno; /* defined in yabasic.bison: line number of main file */
|
||||||
|
extern int mylineno; /* defined in yabasic.bison: line number of main file */
|
||||||
|
int import_lib(char *); /* import library */
|
||||||
|
|
||||||
|
#define MAX_INCLUDE_DEPTH 5
|
||||||
|
#define MAX_INCLUDE_NUMBER 100
|
||||||
|
static YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; /* stack for included libraries */
|
||||||
|
int include_stack_ptr; /* current position in libfile_stack */
|
||||||
|
struct libfile_name *libfile_stack[MAX_INCLUDE_DEPTH]; /* stack for library file names */
|
||||||
|
int libfile_chain_length=0; /* length of libfile_chain */
|
||||||
|
struct libfile_name *libfile_chain[MAX_INCLUDE_NUMBER]; /* list of all library file names */
|
||||||
|
struct libfile_name *currlib; /* current libfile as relevant to bison */
|
||||||
|
int inlib; /* true, while in library */
|
||||||
|
int fi_pending=0; /* true, if within a short if */
|
||||||
|
int flex_line=0; /* line number counted in flex */
|
||||||
|
%}
|
||||||
|
|
||||||
|
WS [ \t\f\r\v]
|
||||||
|
NAME ([A-Za-z_][A-za-z0-9_]*\.[A-Za-z_][A-za-z0-9_]*)|([A-Za-z_][A-za-z0-9_]*)
|
||||||
|
|
||||||
|
%option noyywrap
|
||||||
|
%x PRELNO
|
||||||
|
%x PASTLNO
|
||||||
|
%x IMPORT
|
||||||
|
%x IMPORT_DONE
|
||||||
|
|
||||||
|
%%
|
||||||
|
<<EOF>> {
|
||||||
|
if (--include_stack_ptr<0) {
|
||||||
|
return tEOPROG;
|
||||||
|
} else {
|
||||||
|
if (!is_bound) {
|
||||||
|
yy_delete_buffer(YY_CURRENT_BUFFER);
|
||||||
|
yy_switch_to_buffer(include_stack[include_stack_ptr]);
|
||||||
|
}
|
||||||
|
flex_line+=yylval.sep=-1;
|
||||||
|
return tSEP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{WS}+ {BEGIN(INITIAL);} /* ignore whitespace */
|
||||||
|
|
||||||
|
^{WS}*/[0-9]+ {BEGIN(PRELNO);return tLABEL;}
|
||||||
|
<PRELNO>[0-9]+ {
|
||||||
|
BEGIN(PASTLNO);
|
||||||
|
yylval.symbol=(char *)my_strdup(yytext);
|
||||||
|
return tSYMBOL;
|
||||||
|
}
|
||||||
|
<PASTLNO>.* {BEGIN(INITIAL);flex_line+=yylval.sep=0;yyless(0);return tSEP;}
|
||||||
|
<PASTLNO>\n {if (fi_pending) {fi_pending--;yyless(0);return tENDIF;}BEGIN(INITIAL);flex_line+=yylval.sep=1;return tSEP;}
|
||||||
|
|
||||||
|
\n\n {if (fi_pending) {fi_pending--;yyless(0);return tENDIF;}if (interactive && !inlib) {return tEOPROG;} else {flex_line+=yylval.sep=2;return tSEP;}}
|
||||||
|
\n {if (fi_pending) {fi_pending--;yyless(0);return tENDIF;}flex_line+=yylval.sep=1;return tSEP;}
|
||||||
|
: {if (fi_pending && check_compat) error_with_line(WARNING,"short-if has changed in version 2.71",flex_line);flex_line+=yylval.sep=0;return tSEP;}
|
||||||
|
|
||||||
|
REM{WS}+.* {flex_line+=yylval.sep=0;return tSEP;} /* comments span 'til end of line */
|
||||||
|
\/\/.* {flex_line+=yylval.sep=0;return tSEP;} /* comments span 'til end of line */
|
||||||
|
REM\n {if (fi_pending) {fi_pending--;yyless(0);return tENDIF;}flex_line+=yylval.sep=1;return tSEP;}
|
||||||
|
REM {yymore();}
|
||||||
|
|
||||||
|
IMPORT {BEGIN(IMPORT);}
|
||||||
|
<IMPORT>{WS}+{NAME} {if (!import_lib(yytext)) return 0;BEGIN(IMPORT_DONE);return tIMPORT;}
|
||||||
|
<IMPORT_DONE>(.|\n) {if (yytext[0]=='\n' && fi_pending) {fi_pending--;yyless(0);return tENDIF;}BEGIN(INITIAL);yyless(0);flex_line+=yylval.sep=0;return tSEP;}
|
||||||
|
|
||||||
|
((DOCU|DOC|DOCUMENTATION)({WS}+.*)?) {
|
||||||
|
char *where=strpbrk(yytext," \t\r\f\v");
|
||||||
|
yylval.docu=(char *)my_strdup(where ? where+1 : NULL);
|
||||||
|
return tDOCU;
|
||||||
|
}
|
||||||
|
|
||||||
|
^#.*\n {flex_line+=yylval.sep=1;return tSEP;} /* '#' as first character may introduce comments too */
|
||||||
|
^'.*\n {flex_line+=yylval.sep=1;return tSEP;} /* ' as first character may introduce comments too */
|
||||||
|
|
||||||
|
EXECUTE return tEXECUTE;
|
||||||
|
"EXECUTE$" return tEXECUTE2;
|
||||||
|
COMPILE return tCOMPILE;
|
||||||
|
RUNTIME_CREATED_SUB return tRUNTIME_CREATED_SUB;
|
||||||
|
END{WS}+SUB return tENDSUB;
|
||||||
|
END{WS}+IF return tENDIF;
|
||||||
|
END-IF return tENDIF;
|
||||||
|
END{WS}+WHILE return tWEND;
|
||||||
|
END-WHILE return tWEND;
|
||||||
|
END{WS}+SWITCH return tSEND;
|
||||||
|
END-SWITCH return tSEND;
|
||||||
|
END{WS}+"SWITCH$" return tSEND;
|
||||||
|
END-"SWITCH$" return tSEND;
|
||||||
|
EXPORT return tEXPORT;
|
||||||
|
ERROR return tERROR;
|
||||||
|
FOR return tFOR;
|
||||||
|
BREAK return tBREAK;
|
||||||
|
SWITCH return tSWITCH;
|
||||||
|
CASE return tCASE;
|
||||||
|
DEFAULT return tDEFAULT;
|
||||||
|
LOOP return tLOOP;
|
||||||
|
DO return tDO;
|
||||||
|
TO return tTO;
|
||||||
|
AS return tAS;
|
||||||
|
READING return tREADING;
|
||||||
|
WRITING return tWRITING;
|
||||||
|
STEP return tSTEP;
|
||||||
|
NEXT return tNEXT;
|
||||||
|
WHILE return tWHILE;
|
||||||
|
WEND return tWEND;
|
||||||
|
REPEAT return tREPEAT;
|
||||||
|
UNTIL return tUNTIL;
|
||||||
|
GOTO return tGOTO;
|
||||||
|
GOSUB return tGOSUB;
|
||||||
|
SUB return tSUB;
|
||||||
|
SUBROUTINE return tSUB;
|
||||||
|
LOCAL return tLOCAL;
|
||||||
|
STATIC return tSTATIC;
|
||||||
|
ON return tON;
|
||||||
|
INTERRUPT return tINTERRUPT;
|
||||||
|
CONTINUE return tCONTINUE;
|
||||||
|
LABEL return tLABEL;
|
||||||
|
IF return tIF;
|
||||||
|
THEN return tTHEN;
|
||||||
|
ELSE return tELSE;
|
||||||
|
ELSIF return tELSIF;
|
||||||
|
ELSEIF return tELSIF;
|
||||||
|
ENDIF return tENDIF;
|
||||||
|
FI return tENDIF;
|
||||||
|
OPEN return tOPEN;
|
||||||
|
CLOSE return tCLOSE;
|
||||||
|
SEEK return tSEEK;
|
||||||
|
TELL return tTELL;
|
||||||
|
PRINT return tPRINT;
|
||||||
|
USING return tUSING;
|
||||||
|
REVERSE return tREVERSE;
|
||||||
|
COLOR return tCOLOUR;
|
||||||
|
COLOUR return tCOLOUR;
|
||||||
|
\? return tPRINT;
|
||||||
|
INPUT return tINPUT;
|
||||||
|
RETURN return tRETURN;
|
||||||
|
DIM return tDIM;
|
||||||
|
REDIM return tDIM;
|
||||||
|
END return tEND;
|
||||||
|
EXIT return tEXIT;
|
||||||
|
READ return tREAD;
|
||||||
|
DATA return tDATA;
|
||||||
|
RESTORE return tRESTORE;
|
||||||
|
AND return tAND;
|
||||||
|
OR return tOR;
|
||||||
|
NOT return tNOT;
|
||||||
|
EOR return tEOR;
|
||||||
|
XOR return tEOR;
|
||||||
|
WINDOW return tWINDOW;
|
||||||
|
PRINTER return tPRINTER;
|
||||||
|
SETUP return tSETUP;
|
||||||
|
PUTSCREEN return tPUTCHAR;
|
||||||
|
"GETSCREEN$" return tGETCHAR;
|
||||||
|
NEW return tNEW;
|
||||||
|
WAIT return tWAIT;
|
||||||
|
PAUSE return tWAIT;
|
||||||
|
SLEEP return tWAIT;
|
||||||
|
BELL return tBELL;
|
||||||
|
BEEP return tBELL;
|
||||||
|
LET return tLET;
|
||||||
|
ARRAYDIM return tARDIM;
|
||||||
|
ARRAYDIMENSION return tARDIM;
|
||||||
|
ARRAYSIZE return tARSIZE;
|
||||||
|
NUMPARAM(S)?({WS}*\({WS}*\))? {yylval.symbol=(char *)my_strdup("numparams"); return tSYMBOL;}
|
||||||
|
BIND return tBIND;
|
||||||
|
SET return tSET;
|
||||||
|
|
||||||
|
LOCALIZE return tLOCALIZE;
|
||||||
|
BUTTON return tBUTTON;
|
||||||
|
ALERT return tALERT;
|
||||||
|
MENU return tMENU;
|
||||||
|
CHECKBOX return tCHECKBOX;
|
||||||
|
RADIOBUTTON return tRADIOBUTTON;
|
||||||
|
TEXTCONTROL return tTEXTCONTROL;
|
||||||
|
LISTBOX return tLISTBOX;
|
||||||
|
DROPBOX return tDROPBOX;
|
||||||
|
ADD return tADD;
|
||||||
|
REMOVE return tREMOVE;
|
||||||
|
TEXT return tTEXT;
|
||||||
|
RECT return tRECT;
|
||||||
|
DRAW return tDRAW;
|
||||||
|
FLUSH return tFLUSH;
|
||||||
|
FILEPANEL return tFILEPANEL;
|
||||||
|
LAYOUT return tLAYOUT;
|
||||||
|
TEXTEDIT return tTEXTEDIT;
|
||||||
|
COUNT return tCOUNT;
|
||||||
|
VIEW return tVIEW;
|
||||||
|
BOXVIEW return tBOXVIEW;
|
||||||
|
TABVIEW return tTABVIEW;
|
||||||
|
ELLIPSE return tELLIPSE;
|
||||||
|
DOT return tDOT;
|
||||||
|
LINE return tLINE;
|
||||||
|
CURVE return tCURVE;
|
||||||
|
CIRCLE return tCIRCLE;
|
||||||
|
CLEAR return tCLEAR;
|
||||||
|
TEXT return tTEXT;
|
||||||
|
RECT return tRECT;
|
||||||
|
SLIDER return tSLIDER;
|
||||||
|
OPTION return tOPTION;
|
||||||
|
DROPZONE return tDROPZONE;
|
||||||
|
COLORCONTROL return tCOLORCONTROL;
|
||||||
|
TREEBOX return tTREEBOX;
|
||||||
|
SORT return tSORT;
|
||||||
|
TOOLTIP return tTOOLTIP;
|
||||||
|
COLUMNBOX return tCOLUMNBOX;
|
||||||
|
COLUMN return tCOLUMN;
|
||||||
|
CLIPBOARD return tCLIPBOARD;
|
||||||
|
COPY return tCOPY;
|
||||||
|
SUBMENU return tSUBMENU;
|
||||||
|
KEYBOARD return tKEYBOARD;
|
||||||
|
SELECT return tSELECT;
|
||||||
|
CALENDAR return tCALENDAR;
|
||||||
|
SCROLLBAR return tSCROLLBAR;
|
||||||
|
COLLAPSE return tCOLLAPSE;
|
||||||
|
EXPAND return tEXPAND;
|
||||||
|
SOUND return tSOUND;
|
||||||
|
PLAY return tPLAY;
|
||||||
|
STOP return tSTOP;
|
||||||
|
SPLITVIEW return tSPLITVIEW;
|
||||||
|
STACKVIEW return tSTACKVIEW;
|
||||||
|
TEXTURL return tTEXTURL;
|
||||||
|
SPINCONTROL return tSPINCONTROL;
|
||||||
|
POPUPMENU return tPOPUPMENU;
|
||||||
|
SEND return tMSEND;
|
||||||
|
MESSAGE return tNUMMESSAGE;
|
||||||
|
THREAD return tTHREAD;
|
||||||
|
BITMAP return tBITMAP;
|
||||||
|
CANVAS return tCANVAS;
|
||||||
|
SHORTCUT return tSHORTCUT;
|
||||||
|
SAVE return tSAVE;
|
||||||
|
ISCOMPUTERON return tISCOMPUTERON;
|
||||||
|
SCREENSHOT return tSCREENSHOT;
|
||||||
|
STATUSBAR return tSTATUSBAR;
|
||||||
|
LAUNCH return tLAUNCH;
|
||||||
|
ATTRIBUTE return tATTRIBUTE;
|
||||||
|
|
||||||
|
"PASTE$" return tPASTE;
|
||||||
|
IMAGE return tIMAGE;
|
||||||
|
SVG return tSVG;
|
||||||
|
"MESSAGE$" return tMESSAGE;
|
||||||
|
"TRANSLATE$" return tTRANSLATE;
|
||||||
|
"GET$" return tGET;
|
||||||
|
MOUSE return tMOUSE;
|
||||||
|
ISMOUSEIN return tISMOUSEIN;
|
||||||
|
GET return tGETNUM;
|
||||||
|
|
||||||
|
SIN return tSIN;
|
||||||
|
ASIN return tASIN;
|
||||||
|
COS return tCOS;
|
||||||
|
ACOS return tACOS;
|
||||||
|
TAN return tTAN;
|
||||||
|
ATAN return tATAN;
|
||||||
|
EXP return tEXP;
|
||||||
|
LOG return tLOG;
|
||||||
|
SQRT return tSQRT;
|
||||||
|
SQR return tSQR;
|
||||||
|
INT return tINT;
|
||||||
|
FRAC return tFRAC;
|
||||||
|
ABS return tABS;
|
||||||
|
SIG return tSIG;
|
||||||
|
MOD return tMOD;
|
||||||
|
RAN return tRAN;
|
||||||
|
MIN return tMIN;
|
||||||
|
MAX return tMAX;
|
||||||
|
"LEFT$" return tLEFT;
|
||||||
|
"RIGHT$" return tRIGHT;
|
||||||
|
"MID$" return tMID;
|
||||||
|
"LOWER$" return tLOWER;
|
||||||
|
"UPPER$" return tUPPER;
|
||||||
|
"LTRIM$" return tLTRIM;
|
||||||
|
"RTRIM$" return tRTRIM;
|
||||||
|
"TRIM$" return tTRIM;
|
||||||
|
INSTR return tINSTR;
|
||||||
|
RINSTR return tRINSTR;
|
||||||
|
LEN return tLEN;
|
||||||
|
VAL return tVAL;
|
||||||
|
EOF return tMYEOF;
|
||||||
|
"STR$" return tSTR;
|
||||||
|
"INKEY$" return tINKEY;
|
||||||
|
"CHR$" return tCHR;
|
||||||
|
ASC return tASC;
|
||||||
|
"HEX$" return tHEX;
|
||||||
|
"BIN$" return tBIN;
|
||||||
|
DEC return tDEC;
|
||||||
|
AT return tAT;
|
||||||
|
@ return tAT;
|
||||||
|
SCREEN return tSCREEN;
|
||||||
|
"SYSTEM$" return tSYSTEM;
|
||||||
|
SYSTEM return tSYSTEM2;
|
||||||
|
"DATE$" return tDATE;
|
||||||
|
"TIME$" return tTIME;
|
||||||
|
PEEK return tPEEK;
|
||||||
|
"PEEK$" return tPEEK2;
|
||||||
|
POKE return tPOKE;
|
||||||
|
TOKEN return tTOKEN;
|
||||||
|
"TOKEN$" return tTOKENALT;
|
||||||
|
SPLIT return tSPLIT;
|
||||||
|
"SPLIT$" return tSPLITALT;
|
||||||
|
GLOB return tGLOB;
|
||||||
|
"^" return tPOW;
|
||||||
|
"**" return tPOW;
|
||||||
|
|
||||||
|
"<>" return tNEQ;
|
||||||
|
"<=" return tLEQ;
|
||||||
|
">=" return tGEQ;
|
||||||
|
"=" return tEQU;
|
||||||
|
"<" return tLTN;
|
||||||
|
">" return tGTN;
|
||||||
|
"!" return tNOT;
|
||||||
|
|
||||||
|
[-+*/:(),.;] {return yytext[0];}
|
||||||
|
|
||||||
|
[0-9]+ {
|
||||||
|
yylval.digits=(char *)my_strdup(yytext);
|
||||||
|
return tDIGITS;
|
||||||
|
}
|
||||||
|
|
||||||
|
(([0-9]+|([0-9]*\.[0-9]*))([eE][-+]?[0-9]+)?) {
|
||||||
|
{ double d;
|
||||||
|
sscanf(yytext,"%lg",&d);
|
||||||
|
yylval.fnum=d;
|
||||||
|
return tFNUM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pi {yylval.fnum=3.1415926535897932;return tFNUM;}
|
||||||
|
euler {yylval.fnum=2.7182818284590452;return tFNUM;}
|
||||||
|
TRUE {yylval.fnum=1; return tFNUM;}
|
||||||
|
FALSE {yylval.fnum=0; return tFNUM;}
|
||||||
|
|
||||||
|
{NAME} {
|
||||||
|
yylval.symbol=(char *)my_strdup(yytext);
|
||||||
|
return tSYMBOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Symbols with a trailing $-sign are treated special */
|
||||||
|
{NAME}\$ {
|
||||||
|
yylval.symbol=(char *)my_strdup(yytext);
|
||||||
|
return tSTRSYM;
|
||||||
|
}
|
||||||
|
|
||||||
|
\"[^"]*(\"|\n) {
|
||||||
|
int cnt;
|
||||||
|
if (yytext[yyleng-1]=='\n' && fi_pending) {fi_pending--;yyless(0);return tENDIF;}
|
||||||
|
if (yytext[yyleng-1]=='\n') {
|
||||||
|
yylval.string=NULL;
|
||||||
|
return tSTRING;
|
||||||
|
}
|
||||||
|
for(cnt=0;yytext[yyleng-cnt-2]=='\\';cnt++) ;
|
||||||
|
if (cnt%2) {
|
||||||
|
yyless(yyleng-1);
|
||||||
|
yymore();
|
||||||
|
} else {
|
||||||
|
yylval.string=(char *)my_strdup(yytext+1);
|
||||||
|
*(yylval.string+yyleng-2)='\0';
|
||||||
|
replace(yylval.string);
|
||||||
|
return tSTRING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
. {if (isprint(yytext[0])) return yytext[0]; else return ' ';}
|
||||||
|
|
||||||
|
%%
|
||||||
|
void yyerror(char *msg)
|
||||||
|
{
|
||||||
|
int i,j;
|
||||||
|
|
||||||
|
sprintf(string,"%s at %n",msg,&j);
|
||||||
|
if (*yytext=='\n' || *yytext=='\0') {
|
||||||
|
sprintf(string+j,"end of line");
|
||||||
|
} else {
|
||||||
|
i=0;
|
||||||
|
string[j++]='\"';
|
||||||
|
while(yytext[i]) {
|
||||||
|
if (isprint(yytext[i])) string[j++]=yytext[i++];
|
||||||
|
else {
|
||||||
|
sprintf(string+j,"0x%02x",yytext[i]);
|
||||||
|
j+=4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string[j++]='\"';
|
||||||
|
string[j]='\0';
|
||||||
|
}
|
||||||
|
error(ERROR,string);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void open_main(FILE *file,char *explicit,char *main_file_name) /* open main file */
|
||||||
|
{
|
||||||
|
include_stack_ptr=0;
|
||||||
|
|
||||||
|
if (explicit)
|
||||||
|
include_stack[include_stack_ptr]=yy_scan_string(explicit);
|
||||||
|
else
|
||||||
|
include_stack[include_stack_ptr]=yy_create_buffer(file,YY_BUF_SIZE);
|
||||||
|
libfile_stack[include_stack_ptr]=new_file(main_file_name,"main");
|
||||||
|
libfile_chain[libfile_chain_length++]=libfile_stack[include_stack_ptr];
|
||||||
|
if (!explicit) yy_switch_to_buffer(include_stack[include_stack_ptr]);
|
||||||
|
currlib=libfile_stack[0];
|
||||||
|
inlib=FALSE;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void open_string(char *cmd) /* open string with commands */
|
||||||
|
{
|
||||||
|
yy_switch_to_buffer(yy_scan_string(cmd));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int import_lib(char *name) /* import library */
|
||||||
|
{
|
||||||
|
char *full;
|
||||||
|
static int end_of_import=FALSE;
|
||||||
|
|
||||||
|
if (!*name) name=pop(stSTRING)->pointer;
|
||||||
|
while(isspace(*name)) name++;
|
||||||
|
|
||||||
|
if (!strcmp(name,"__END_OF_IMPORT")) end_of_import=TRUE;
|
||||||
|
if (end_of_import) return TRUE;
|
||||||
|
|
||||||
|
/* start line numbers anew */
|
||||||
|
libfile_stack[include_stack_ptr]->lineno=mylineno;
|
||||||
|
|
||||||
|
include_stack_ptr++;
|
||||||
|
if (include_stack_ptr>=MAX_INCLUDE_DEPTH) {
|
||||||
|
sprintf(string,"Could not import '%s': nested too deep",name);
|
||||||
|
error(ERROR,string);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_bound) {
|
||||||
|
full=name;
|
||||||
|
} else {
|
||||||
|
yyin=open_library(name,&full,FALSE);
|
||||||
|
if (!yyin) return FALSE;
|
||||||
|
yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
|
||||||
|
include_stack[include_stack_ptr]=YY_CURRENT_BUFFER;
|
||||||
|
}
|
||||||
|
libfile_stack[include_stack_ptr]=new_file(full,NULL);
|
||||||
|
libfile_chain[libfile_chain_length++]=libfile_stack[include_stack_ptr];
|
||||||
|
if (libfile_chain_length>=MAX_INCLUDE_NUMBER) {
|
||||||
|
sprintf(string,"Cannot import more than %d libraries",MAX_INCLUDE_NUMBER);
|
||||||
|
error(ERROR,string);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (!libfile_stack[include_stack_ptr]) {
|
||||||
|
sprintf(string,"library '%s' has already been imported",full);
|
||||||
|
error(ERROR,string);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (infolevel>=NOTE && !is_bound) {
|
||||||
|
sprintf(string,"importing from file '%s'",full);
|
||||||
|
error(NOTE,string);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FILE *open_library(char *name,char **fullreturn,int without) /* search and open a library */
|
||||||
|
{
|
||||||
|
static char full[200];
|
||||||
|
char unquoted[200];
|
||||||
|
char *p;
|
||||||
|
FILE *lib;
|
||||||
|
int i;
|
||||||
|
char *trail;
|
||||||
|
|
||||||
|
if (fullreturn) *fullreturn=full;
|
||||||
|
|
||||||
|
for(p=name;strchr(" \"'`",*p);p++) if (!*p) break;
|
||||||
|
strncpy(unquoted,p,200);
|
||||||
|
for(;!strchr(" \"'`",*p);p++) if (!*p) break;
|
||||||
|
if (*p) unquoted[p-name-2]='\0';
|
||||||
|
name=unquoted;
|
||||||
|
if (strchr(name,'.')) {
|
||||||
|
sprintf(string,"library name '%s' contains '.'",name);
|
||||||
|
error(ERROR,string);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (!strcmp(name,"main")) {
|
||||||
|
if (is_bound) return NULL;
|
||||||
|
error(ERROR,"invalid library name 'main'");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* search local */
|
||||||
|
trail=".yab";
|
||||||
|
for(i=0;i<2;i++) {
|
||||||
|
strcpy(full,name);
|
||||||
|
if (!strchr(full,'.')) strcat(full,trail);
|
||||||
|
lib=fopen(full,"r");
|
||||||
|
if (lib) return lib;
|
||||||
|
trail="";
|
||||||
|
if (!without) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* search in global location */
|
||||||
|
trail=".yab";
|
||||||
|
for(i=0;i<2;i++) {
|
||||||
|
strcpy(full,library_path);
|
||||||
|
if (full[0] && !strchr("\\/",full[strlen(full)-1])) {
|
||||||
|
#ifdef UNIX
|
||||||
|
strcat(full,"/");
|
||||||
|
#else
|
||||||
|
strcat(full,"\\");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
strcat(full,name);
|
||||||
|
if (!strchr(full,'.')) strcat(full,trail);
|
||||||
|
lib=fopen(full,"r");
|
||||||
|
if (lib) return lib;
|
||||||
|
trail="";
|
||||||
|
if (!without) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(string,"couldn't open library '%s'",full);
|
||||||
|
error(ERROR,string);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void switchlib(void) /* switch library, called by bison */
|
||||||
|
{
|
||||||
|
if (include_stack_ptr<0) return;
|
||||||
|
if (infolevel>=DEBUG) {
|
||||||
|
sprintf(string,"switching from '%s' to '%s'",currlib->s,libfile_stack[include_stack_ptr]->s);
|
||||||
|
error(DEBUG,string);
|
||||||
|
}
|
||||||
|
currlib=libfile_stack[include_stack_ptr];
|
||||||
|
mylineno=currlib->lineno;
|
||||||
|
inlib=(include_stack_ptr>0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
885
src/yabasic.h
Normal file
885
src/yabasic.h
Normal file
@@ -0,0 +1,885 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
YABASIC --- a simple Basic Interpreter
|
||||||
|
written by Marc-Oliver Ihm 1995-2004
|
||||||
|
homepage: www.yabasic.de
|
||||||
|
|
||||||
|
yabasic.h --- function prototypes and global variables
|
||||||
|
|
||||||
|
This file is part of yabasic and may be copied only
|
||||||
|
under the terms of either the Artistic License or
|
||||||
|
the GNU General Public License (GPL), both of which
|
||||||
|
can be found at www.yabasic.de
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define YABLICENSE \
|
||||||
|
"\n"\
|
||||||
|
" Yab may only be copied under the terms of the Artistic \n"\
|
||||||
|
" License which can be found at yab-interpreter.sourceforge.net. \n"\
|
||||||
|
"\n"\
|
||||||
|
" The Artistic License gives you the right to use and distribute \n"\
|
||||||
|
" yab in a more-or-less customary fashion, plus the right to make \n"\
|
||||||
|
" reasonable modifications and distribute (or even sell) such a \n"\
|
||||||
|
" modified version under a different name. \n"\
|
||||||
|
" However, the original author and copyright holder still reserves \n"\
|
||||||
|
" himself some sort of artistic control over the development \n"\
|
||||||
|
" of yab itself. \n"\
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define YABASIC_INCLUDED
|
||||||
|
|
||||||
|
/* ------------- defines ---------------- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
Define one and only one of the following symbols, depending on your
|
||||||
|
System:
|
||||||
|
- UNIX: uses some UNIX-features and X11
|
||||||
|
- WINDOWS: uses WIN32-features
|
||||||
|
Define UNIX and BEOS for a BeOS build
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(UNIX) && defined(WINDOWS)
|
||||||
|
UNIX and WINDOWS are defined at once; check your compiler settings
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------- includes ---------------- */
|
||||||
|
|
||||||
|
#include "global.h"
|
||||||
|
#include <config.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <float.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#include <string.h>
|
||||||
|
#include <windows.h>
|
||||||
|
#include <io.h>
|
||||||
|
#define ARCHITECTURE "windows"
|
||||||
|
#ifdef __LCC__ /* fix for lccwin32 */
|
||||||
|
#include <winspool.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "YabInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef UNIX
|
||||||
|
#define ARCHITECTURE UNIX_ARCHITECTURE
|
||||||
|
#ifdef HAS_STRING_HEADER
|
||||||
|
#include <string.h>
|
||||||
|
#elif HAS_STRINGS_HEADER
|
||||||
|
#include <strings.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#ifndef BEOS
|
||||||
|
#include <sys/ipc.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#include <X11/Intrinsic.h>
|
||||||
|
#define XK_LATIN1
|
||||||
|
#define XK_MISCELLANY
|
||||||
|
#include <X11/keysymdef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#ifdef BUILD_NCURSES
|
||||||
|
#include <ncurses.h>
|
||||||
|
// #else
|
||||||
|
// #ifdef HAVE_CURSES_HEADER
|
||||||
|
// #include <curses.h>
|
||||||
|
// #endif
|
||||||
|
#endif
|
||||||
|
#ifndef KEY_MAX
|
||||||
|
#define KEY_MAX 0777
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FOPEN_MAX
|
||||||
|
#define FOPEN_MAX 24
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#ifdef UNIX
|
||||||
|
#ifndef LIBRARY_PATH
|
||||||
|
#define LIBRARY_PATH "/boot/home/config/settings/yab"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define OPEN_HAS_STREAM 1
|
||||||
|
#define OPEN_HAS_MODE 2
|
||||||
|
#define OPEN_PRINTER 8
|
||||||
|
#define STDIO_STREAM 1234
|
||||||
|
|
||||||
|
/* -------- variables needed in all files and defined in ... -------- */
|
||||||
|
|
||||||
|
/* main.c */
|
||||||
|
extern struct command *current; /* currently executed command */
|
||||||
|
extern struct command *cmdroot; /* first command */
|
||||||
|
extern struct command *cmdhead; /* next command */
|
||||||
|
extern struct command *lastcmd; /* last command */
|
||||||
|
extern int infolevel; /* controls issuing of error messages */
|
||||||
|
extern int errorlevel; /* highest level of error message seen til now */
|
||||||
|
extern int interactive; /* true, if commands come from stdin */
|
||||||
|
extern char *progname; /* name of yabasic-program */
|
||||||
|
extern char *explanation[]; /* explanations of commands */
|
||||||
|
extern char **yabargv; /* arguments for yabasic */
|
||||||
|
extern int yabargc; /* number of arguments in yabargv */
|
||||||
|
extern time_t compilation_start,compilation_end,execution_end;
|
||||||
|
extern char *string; /* for trash-strings */
|
||||||
|
extern char *errorstring; /* for error-strings */
|
||||||
|
extern int errorcode; /* error-codes */
|
||||||
|
extern char library_path[]; /* full path to search libraries */
|
||||||
|
extern int program_state; /* state of program */
|
||||||
|
extern int check_compat; /* true, if compatibility should be checked */
|
||||||
|
extern int is_bound; /* true, if this executable is bound */
|
||||||
|
extern char* appdirectory; /* appdir */
|
||||||
|
|
||||||
|
|
||||||
|
/* io.c */
|
||||||
|
extern FILE *streams[]; /* file streams */
|
||||||
|
extern int read_controls; /* TRUE, if input should read control characters */
|
||||||
|
extern int stream_modes[]; /* modes for streams */
|
||||||
|
extern int curinized; /* true, if curses has been initialized */
|
||||||
|
extern int badstream(int,int); /* test for valid stream id */
|
||||||
|
void myseek(struct command *); /* reposition file pointer */
|
||||||
|
#ifdef WINDOWS
|
||||||
|
extern HANDLE wantkey; /* mutex to signal key desire */
|
||||||
|
extern HANDLE gotkey; /* mutex to signal key reception */
|
||||||
|
extern HANDLE wthandle; /* handle of win thread */
|
||||||
|
extern HANDLE kthandle; /* handle of inkey thread */
|
||||||
|
extern DWORD ktid; /* id of inkey thread */
|
||||||
|
extern int LINES; /* number of lines on screen */
|
||||||
|
extern int COLS; /* number of columns on screen */
|
||||||
|
extern HANDLE ConsoleInput; /* handle for console input */
|
||||||
|
extern HANDLE ConsoleOutput; /* handle for console output */
|
||||||
|
#else
|
||||||
|
extern int winpid; /* pid of process waiting for window keys */
|
||||||
|
extern int termpid; /* pid of process waiting for terminal keys */
|
||||||
|
#ifndef BUILD_NCURSES
|
||||||
|
extern int LINES; /* number of lines on screen */
|
||||||
|
extern int COLS; /* number of columns on screen */
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* graphic.c */
|
||||||
|
/* printing and plotting */
|
||||||
|
extern int print_to_file; /* print to file ? */
|
||||||
|
#ifdef WINDOWS
|
||||||
|
extern HFONT printerfont; /* handle of printer-font */
|
||||||
|
extern HDC printer; /* handle of printer */
|
||||||
|
#endif
|
||||||
|
extern FILE *printerfile; /* file to print on */
|
||||||
|
extern double xoff; /* offset for x-mapping */
|
||||||
|
extern double xinc; /* inclination of x-mapping */
|
||||||
|
extern double yoff; /* offset for y-mapping */
|
||||||
|
extern double yinc; /* inclination for y-mapping */
|
||||||
|
/* window coordinates */
|
||||||
|
extern int winopened; /* flag if window is open already */
|
||||||
|
extern char *winorigin; /* e.g. "lt","rc"; defines origin of grafic window */
|
||||||
|
extern int winwidth,winheight; /* size of window */
|
||||||
|
/* mouse, console and keyboard */
|
||||||
|
/* extern int mousex,mousey,mouseb,mousemod; */ /* last know mouse coordinates */
|
||||||
|
extern char *ykey[]; /* keys returned by inkey */
|
||||||
|
/* text and font */
|
||||||
|
extern char *getreg(char *); /* get defaults from Registry */
|
||||||
|
extern char *text_align; /* specifies alignement of text */
|
||||||
|
extern int fontheight; /* height of font in pixel */
|
||||||
|
#ifdef WINDOWS
|
||||||
|
extern HFONT myfont; /* handle of font for screen */
|
||||||
|
#endif
|
||||||
|
/* general window stuff */
|
||||||
|
extern char *foreground;
|
||||||
|
extern char *background;
|
||||||
|
extern char *geometry;
|
||||||
|
extern char *displayname;
|
||||||
|
extern char *font;
|
||||||
|
extern int drawmode;
|
||||||
|
#ifdef WINDOWS
|
||||||
|
extern HWND window; /* handle of my window */
|
||||||
|
extern HANDLE mainthread; /* handle to main thread */
|
||||||
|
extern HANDLE this_instance;
|
||||||
|
extern WNDCLASS myclass; /* window class for my program */
|
||||||
|
extern char *my_class;
|
||||||
|
extern BOOL Commandline; /* true if launched from command line */
|
||||||
|
#else
|
||||||
|
extern int backpid; /* pid of process waiting for redraw events */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* function.c */
|
||||||
|
extern struct command *datapointer; /* current location for read-command */
|
||||||
|
|
||||||
|
/* symbol.c */
|
||||||
|
extern struct stackentry *stackroot; /* first element of stack */
|
||||||
|
extern struct stackentry *stackhead; /* last element of stack */
|
||||||
|
extern void query_array(struct command *cmd); /* query array */
|
||||||
|
extern struct command *lastref; /* last command in UDS referencing a symbol */
|
||||||
|
extern struct command *firstref; /* first command in UDS referencing a symbol */
|
||||||
|
extern int labelcount; /* count self-generated labels */
|
||||||
|
|
||||||
|
|
||||||
|
/* flex.c */
|
||||||
|
extern int include_stack_ptr; /* Lex buffer for any imported file */
|
||||||
|
extern struct libfile_name *libfile_stack[]; /* stack for library file names */
|
||||||
|
extern struct libfile_name *currlib; /* current libfile as relevant to bison */
|
||||||
|
extern int inlib; /* true, while in library */
|
||||||
|
extern int fi_pending; /* true, if within a short if */
|
||||||
|
extern int libfile_chain_length; /* length of libfile_chain */
|
||||||
|
extern struct libfile_name *libfile_chain[]; /* list of all library file names */
|
||||||
|
|
||||||
|
|
||||||
|
/* bison.c */
|
||||||
|
extern char *current_function; /* name of currently parsed function */
|
||||||
|
extern int yydebug;
|
||||||
|
extern int missing_endif;
|
||||||
|
extern int missing_endif_line;
|
||||||
|
extern int in_loop;
|
||||||
|
|
||||||
|
/*-------------------------- defs and undefs ------------------------*/
|
||||||
|
|
||||||
|
/* undef symbols */
|
||||||
|
#undef FATAL
|
||||||
|
#undef ERROR
|
||||||
|
#undef WARNING
|
||||||
|
#undef NOTE
|
||||||
|
#undef DEBUG
|
||||||
|
#undef DUMP
|
||||||
|
|
||||||
|
#if !defined(TRUE)
|
||||||
|
#define TRUE (1==1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FALSE
|
||||||
|
#define FALSE (1!=1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* I've been told, that some symbols are missing under SunOs ... */
|
||||||
|
#ifndef RAND_MAX
|
||||||
|
#define RAND_MAX 32767
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* length of buffers for system() and input */
|
||||||
|
#define SYSBUFFLEN 100
|
||||||
|
#define INBUFFLEN 10000
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------- enum types ------------------------------- */
|
||||||
|
|
||||||
|
enum error { /* error levels */
|
||||||
|
FATAL,ERROR,INFO,DUMP,WARNING,NOTE,DEBUG
|
||||||
|
};
|
||||||
|
|
||||||
|
enum endreasons { /* ways to end the program */
|
||||||
|
erNONE,erERROR,erREQUEST,erEOF
|
||||||
|
};
|
||||||
|
|
||||||
|
enum streammodes { /* ways to access a stream */
|
||||||
|
smCLOSED=0,smREAD=1,smWRITE=2,smPRINT=4
|
||||||
|
};
|
||||||
|
|
||||||
|
enum functions { /* functions in yabasic (sorted by number of arguments) */
|
||||||
|
fRAN2,fDATE,fTIME,fMESSAGE,fNUMWINDOWS,fCLIPBOARDPASTE,fISCOMPUTERON,fMOUSEMOVE,
|
||||||
|
fZEROARGS,
|
||||||
|
fINKEY,/* fMOUSEX,fMOUSEY,fMOUSEB,fMOUSEMOD,*/
|
||||||
|
fSIN,fASIN,fCOS,fACOS,fTAN,
|
||||||
|
fATAN,fSYSTEM,fSYSTEM2,fPEEK,fPEEK2,fPEEK4,fTELL,fEXP,fLOG,fLEN,fSTR,
|
||||||
|
fSQRT,fSQR,fFRAC,fABS,fSIG,fRAN,fINT,fVAL,fASC,fHEX,fBIN,fDEC,fUPPER,fLOWER,
|
||||||
|
fLTRIM,fRTRIM,fTRIM,fCHR,fTRANSLATE,fMENUTRANSLATE,fMOUSE, fISMOUSEIN,fTEXTCONTROLGET,
|
||||||
|
fKEYBOARD,fCOLUMNBOXCOUNT, fCALENDAR, fLISTBOXCOUNT, fTREEBOXCOUNT, fSTACKVIEWGET,
|
||||||
|
fSPINCONTROLGET, fDROPBOXCOUNT, fSLIDERGET, fTEXTGET, fDRAWGET3, fTABVIEWGET,
|
||||||
|
fLISTBOXGETNUM, fDROPBOXGETNUM, fCOLUMNBOXGETNUM, fTREEBOXGETNUM, fSOUND,
|
||||||
|
fONEARGS,
|
||||||
|
fDEC2,fATAN2,fLEFT,fAND,fOR,fEOR,fLOG2,
|
||||||
|
fRIGHT,fINSTR,fRINSTR,fSTR2,fMOD,fMIN,fMAX,fPEEK3,fMID2,fWINDOWGET, fVIEWGET /* vasper */,
|
||||||
|
fLISTBOXGET, fTREEBOXGET, fSCROLLBARGET, fSPLITVIEWGET, fDROPBOXGET, fCOLORCONTROLGET,
|
||||||
|
fTEXTGET2,fTEXTGET6,fDRAWGET2, fTEXTGET3, fMESSAGESEND, fTHREADKILL, fTHREADGET, fBITMAPGET,
|
||||||
|
fBITMAPLOAD, fATTRIBUTEGET1, fATTRIBUTEGET2,
|
||||||
|
fTWOARGS,
|
||||||
|
fMID,fINSTR2,fRINSTR2,fSTR3,fCOLUMNBOXGET,fDRAWGET1,fTEXTGET4,fTEXTGET5,fPRINTER,
|
||||||
|
fLOAD, fTREEBOXGETOPT,fBITMAPSAVE,
|
||||||
|
fTHREEARGS,
|
||||||
|
fGETCHAR,fDRAWIMAGE,fPOPUPMENU,fSAVE,fDRAWGET4,fBITMAPCOLOR,
|
||||||
|
fFOURARGS,
|
||||||
|
fALERT,
|
||||||
|
fFIVEARGS,
|
||||||
|
fDRAWSVG,fDRAWIMAGE2,
|
||||||
|
fSIXARGS
|
||||||
|
};
|
||||||
|
|
||||||
|
enum arraymode { /* type of array access */
|
||||||
|
CALLARRAY,ASSIGNARRAY,CALLSTRINGARRAY,ASSIGNSTRINGARRAY,GETSTRINGPOINTER
|
||||||
|
};
|
||||||
|
|
||||||
|
enum drawing_modes { /* various ways to draw */
|
||||||
|
dmNORMAL=0,dmCLEAR=1,dmFILL=2
|
||||||
|
};
|
||||||
|
|
||||||
|
enum cmd_type { /* type of command */
|
||||||
|
cFIRST_COMMAND, /* no command, just marks start of list */
|
||||||
|
|
||||||
|
cLABEL,cSUBLINK,cGOTO,cQGOTO,cGOSUB,cQGOSUB,cRETURN, /* flow control */
|
||||||
|
cEND,cEXIT,cBIND,cDECIDE,cSKIPPER,cNOP,cFINDNOP,cEXCEPTION,cANDSHORT,
|
||||||
|
cORSHORT,cSKIPONCE,cRESETSKIPONCE,cCOMPILE,cEXECUTE,cEXECUTE2,
|
||||||
|
|
||||||
|
cDIM,cFUNCTION,cDOARRAY,cARRAYLINK,cPUSHARRAYREF,cCLEARREFS, /* everything with "()" */
|
||||||
|
cARDIM,cARSIZE,cTOKEN,cTOKEN2,cTOKENALT,cTOKENALT2,
|
||||||
|
cSPLIT,cSPLIT2,cSPLITALT,cSPLITALT2,
|
||||||
|
cSTARTFOR,cFORCHECK,cFORINCREMENT, /* for for-loops */
|
||||||
|
|
||||||
|
cSWITCH_COMPARE,cNEXT_CASE,cBREAK,cMINOR_BREAK, /* break-continue-switch */
|
||||||
|
cCONTINUE,cBREAK_HERE,cCONTINUE_HERE,cCONTINUE_CORRECTION,
|
||||||
|
cBREAK_MARK,cPUSH_SWITCH_MARK,cCLEAN_SWITCH_MARK,
|
||||||
|
|
||||||
|
cDBLADD,cDBLMIN,cDBLMUL,cDBLDIV,cDBLPOW, /* double operations */
|
||||||
|
cNEGATE,cPUSHDBLSYM,cPOP,cPOPDBLSYM,cPUSHDBL,
|
||||||
|
|
||||||
|
cREQUIRE,cPUSHFREE,cMAKELOCAL,cMAKESTATIC,cNUMPARAM, /* functions and procedures */
|
||||||
|
cCALL,cQCALL,cPUSHSYMLIST,cPOPSYMLIST,cRET_FROM_FUN,
|
||||||
|
cUSER_FUNCTION,cRETVAL,cEND_FUNCTION,
|
||||||
|
cFUNCTION_OR_ARRAY,cSTRINGFUNCTION_OR_ARRAY,
|
||||||
|
|
||||||
|
cPOKE,cPOKEFILE,cSWAP,cDUPLICATE,cDOCU, /* internals */
|
||||||
|
|
||||||
|
cAND,cOR,cNOT,cLT,cGT,cLE,cGE,cEQ,cNE, /* comparisons */
|
||||||
|
cSTREQ,cSTRNE,cSTRLT,cSTRLE,cSTRGT,cSTRGE,
|
||||||
|
|
||||||
|
cPUSHSTRSYM,cPOPSTRSYM,cPUSHSTR,cCONCAT, /* string operations */
|
||||||
|
cPUSHSTRPTR,cCHANGESTRING,cGLOB,
|
||||||
|
|
||||||
|
cPRINT,cREAD,cRESTORE,cQRESTORE,cONESTRING, /* i/o operations */
|
||||||
|
cREADDATA,cDATA,cOPEN,cCHECKOPEN,cCHECKSEEK,cCLOSE,cPUSHSTREAM,cPOPSTREAM,
|
||||||
|
cSEEK,cSEEK2,cTESTEOF,cWAIT,cBELL,cMOVE,
|
||||||
|
cCLEARSCR,cCOLOUR,cCHKPROMPT,cERROR,
|
||||||
|
|
||||||
|
/*
|
||||||
|
cDOT,cLINE,cCIRCLE,cCLEARWIN,
|
||||||
|
cOPENPRN,cCLOSEPRN,cMOVEORIGIN,cRECT,
|
||||||
|
cPUTBIT, */
|
||||||
|
|
||||||
|
cPUTCHAR,
|
||||||
|
|
||||||
|
cOPENWIN, cCLOSEWIN, cLAYOUT, cWINSET1, cWINSET2, cWINSET3, cWINSET4, /* Be Graphics */
|
||||||
|
cBUTTON, cALERT, cMENU, cTEXTCONTROL, cCHECKBOX, cRADIOBUTTON, cWINCLEAR,
|
||||||
|
cLISTBOX, cDROPBOX, cITEMADD, cITEMDEL, cITEMCLEAR, cLOCALIZE, cLOCALIZE2, cLOCALIZESTOP, cTEXT, cTEXT2, cTEXTALIGN,
|
||||||
|
cTEXTEDIT, cTEXTADD, cTEXTSET, cTEXTSET2, cTEXTCOLOR1, cTEXTCOLOR2, cTEXTSET3, cTEXTCLEAR,
|
||||||
|
cVIEW, cBOXVIEW, cBOXVIEWSET, cTAB, cSLIDER1, cSLIDER2, cSLIDER3, cSLIDER4, cSLIDER5, cSLIDER6,
|
||||||
|
cOPTION1, cOPTION2, cOPTION3, cDROPZONE, cTEXTCONTROL2, cTEXTCONTROL3, cTEXTCONTROL4, cTEXTCONTROL5,
|
||||||
|
cCOLORCONTROL1, cCOLORCONTROL2, cTREEBOX1, cTREEBOX2, cTREEBOX3, cTREEBOX4, cTREEBOX5,
|
||||||
|
cBUTTONIMAGE, cCHECKBOXIMAGE, cCHECKBOXSET, cRADIOSET, cTOOLTIP, cTOOLTIPCOLOR, cTREESORT,
|
||||||
|
cLISTSORT, cFILEBOX, cFILEBOXADD2, cFILEBOXCLEAR, cCOLUMNBOXREMOVE,
|
||||||
|
cCOLUMNBOXSELECT, cCOLUMNBOXADD, cDROPBOXSELECT, cMENU2, cSUBMENU1, cSUBMENU2, cCLIPBOARDCOPY,
|
||||||
|
cCOLUMNBOXCOLOR, cPRINTERCONFIG, cCALENDAR, cLISTBOXSELECT, cLISTBOXADD1, cLISTBOXADD2,
|
||||||
|
cLISTBOXDEL2, cSCROLLBAR, cSCROLLBARSET1, cSCROLLBARSET2, cSCROLLBARSET3, cTREEBOX7, cTREEBOX8,
|
||||||
|
cTREEBOX9, cTREEBOX10, cTREEBOX11, cSPLITVIEW1, cSPLITVIEW2, cSPLITVIEW3,
|
||||||
|
cSTACKVIEW1, cSTACKVIEW2, cTEXTURL1, cTEXTURL2, cDRAWSET3, cSPINCONTROL1, cTABSET, cTABDEL, cTABADD,
|
||||||
|
cSPINCONTROL2, cDROPBOXREMOVE, cDROPBOXCLEAR, cSUBMENU3, cMENU3, cCALENDARSET,
|
||||||
|
cDOT, cLINE, cCIRCLE, cDRAWTEXT, cDRAWRECT, cTREEBOX12, cOPTION4, cOPTION5,
|
||||||
|
cDRAWCLEAR, cDRAWSET1, cDRAWSET2, cELLIPSE, cCURVE, /* Drawing */
|
||||||
|
cBITMAP, cBITMAPDRAW, cBITMAPDRAW2, cBITMAPGET, cBITMAPGET2, cBITMAPGETICON, cBITMAPDRAG, cBITMAPREMOVE, cCANVAS, /* Bitmaps */
|
||||||
|
cSOUNDSTOP, cSOUNDWAIT, /* Sound */
|
||||||
|
cTREEBOX13, cDRAWSET4, cSHORTCUT, cMOUSESET,
|
||||||
|
cSCREENSHOT, cSTATUSBAR, cSTATUSBARSET, cSTATUSBARSET2, cSTATUSBARSET3, cLAUNCH, cRESTORE2, cRESTORE3,
|
||||||
|
cATTRIBUTE1, cATTRIBUTE2, cATTRIBUTECLEAR,
|
||||||
|
cLAST_COMMAND /* no command, just marks end of list */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum stackentries { /* different types of stackentries */
|
||||||
|
stGOTO,stSTRING,stSTRINGARRAYREF,stNUMBER,stNUMBERARRAYREF,stLABEL,stRETADD,stRETADDCALL,stFREE,stROOT,
|
||||||
|
stANY,stSTRING_OR_NUMBER,stSTRING_OR_NUMBER_ARRAYREF, /* these will never appear on stack but are used to check with pop */
|
||||||
|
stSWITCH_MARK, /* used to clean up stack after switch-statement */
|
||||||
|
stSWITCH_STRING,stSWITCH_NUMBER /* only used in switch statement, compares true to every string or number */
|
||||||
|
};
|
||||||
|
|
||||||
|
enum symbols { /* different types of symbols */
|
||||||
|
sySTRING,syNUMBER,syFREE,syARRAY
|
||||||
|
};
|
||||||
|
|
||||||
|
enum function_type { /* different types of functions */
|
||||||
|
ftNONE,ftNUMBER,ftSTRING
|
||||||
|
};
|
||||||
|
|
||||||
|
enum addmodes { /* different modes for adding symbols */
|
||||||
|
amSEARCH,amSEARCH_PRE,amADD_LOCAL,amADD_GLOBAL,amSEARCH_VERY_LOCAL
|
||||||
|
};
|
||||||
|
|
||||||
|
enum states { /* current state of program */
|
||||||
|
HATCHED,INITIALIZED,COMPILING,RUNNING,FINISHED
|
||||||
|
};
|
||||||
|
|
||||||
|
enum yabkeys { /* recognized special keys */
|
||||||
|
kERR,kUP,kDOWN,kLEFT,kRIGHT,kDEL,kINS,kCLEAR,kHOME,kEND,
|
||||||
|
kF0,kF1,kF2,kF3,kF4,kF5,kF6,kF7,kF8,kF9,kF10,kF11,kF12,
|
||||||
|
kF13,kF14,kF15,kF16,kF17,kF18,kF19,kF20,kF21,kF22,kF23,kF24,
|
||||||
|
kBACKSPACE,kSCRNDOWN,kSCRNUP,kENTER,kESC,kTAB,kLASTKEY
|
||||||
|
};
|
||||||
|
|
||||||
|
enum searchmodes { /* modes for searching labels */
|
||||||
|
smSUB=1,smLINK=2,smLABEL=4,smGLOBAL=8
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------- global types ---------------- */
|
||||||
|
|
||||||
|
struct stackentry { /* one element on stack */
|
||||||
|
int type; /* contents of entry */
|
||||||
|
struct stackentry *next;
|
||||||
|
struct stackentry *prev;
|
||||||
|
void *pointer; /* multiuse ptr */
|
||||||
|
double value; /* double value, only one of pointer or value is used */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
symbols are organized as a stack of lists: for every procedure call
|
||||||
|
a new list is pushed onto the stack; all local variables of this
|
||||||
|
function are chained into this list. After return from this procedure,
|
||||||
|
the whole list is discarded and one element is popped from
|
||||||
|
the stack.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct symstack { /* stack of symbol lists */
|
||||||
|
struct symbol *next_in_list;
|
||||||
|
struct symstack *next_in_stack;
|
||||||
|
struct symstack *prev_in_stack;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct symbol { /* general symbol; either variable, string */
|
||||||
|
int type;
|
||||||
|
struct symbol *link; /* points to linked symbol, if any */
|
||||||
|
struct symbol *next_in_list; /* next symbol in symbollist */
|
||||||
|
char *name; /* name of symbol */
|
||||||
|
void *pointer; /* pointer to string contents (if any) */
|
||||||
|
char *args; /* used to store number of arguments for functions/array */
|
||||||
|
double value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct command { /* one interpreter command */
|
||||||
|
int type; /* type of command */
|
||||||
|
int cnt; /* count of this command */
|
||||||
|
struct command *prev; /* link to previous command */
|
||||||
|
struct command *next; /* link to next command */
|
||||||
|
void *pointer; /* pointer to data */
|
||||||
|
void *symbol; /* pointer to symbol (or data within symbol) associated with command */
|
||||||
|
struct command *jump; /* pointer to jump destination */
|
||||||
|
char *name; /* name of symbol associated with command */
|
||||||
|
struct command *nextref; /* next cmd within function referencing a symbol */
|
||||||
|
struct command *nextassoc; /* next cmd within within chain of associated commands */
|
||||||
|
int args; /* number of arguments for function/array call */
|
||||||
|
/* or stream number for open/close */
|
||||||
|
int tag; /* char/int to pass some information */
|
||||||
|
int line; /* line this command has been created for */
|
||||||
|
struct libfile_name *lib; /* associated library */
|
||||||
|
int switch_id; /* TRUE, if in switch, FALSE else; used to check gotos */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct array { /* data structure for arrays */
|
||||||
|
int bounds[10]; /* index boundaries */
|
||||||
|
int dimension; /* dimension of array */
|
||||||
|
void *pointer; /* contents of array */
|
||||||
|
char type; /* decide between string- ('s') and double-Arrays ('d') */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct buff_chain { /* buffer chain for system-input */
|
||||||
|
char buff[SYSBUFFLEN+1]; /* content of buffer */
|
||||||
|
int len; /* used length of buff */
|
||||||
|
struct buff_chain *next; /* next buffer in chain */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct libfile_name { /* used to store library names */
|
||||||
|
char *l; /* long version, including path */
|
||||||
|
int llen; /* length of l */
|
||||||
|
char *s; /* short version */
|
||||||
|
int slen; /* length of s */
|
||||||
|
int lineno; /* linenumber within file */
|
||||||
|
struct command *datapointer; /* data pointer of this library */
|
||||||
|
struct command *firstdata; /* first data-command in library */
|
||||||
|
struct libfile_name *next; /* next in chain */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ------------- function prototypes defined in ... ---------------- */
|
||||||
|
|
||||||
|
/* main.c */
|
||||||
|
void error(int,char *); /* reports an error and possibly exits */
|
||||||
|
void error_with_line(int,char *,int); /* reports an error and possibly exits */
|
||||||
|
void *my_malloc(unsigned); /* my own version of malloc */
|
||||||
|
void my_free(void *); /* free memory */
|
||||||
|
char *my_strerror(int); /* return description of error messages */
|
||||||
|
struct command *add_command(int,char *); /* get room for new command */
|
||||||
|
void signal_handler(int); /* handle various signals */
|
||||||
|
char *my_strdup(char *); /* my own version of strdup */
|
||||||
|
char *my_strndup(char *,int); /* own version of strndup */
|
||||||
|
struct libfile_name *new_file(char *,char *); /* create a new structure for library names */
|
||||||
|
char *dotify(char *,int); /* add library name, if not already present */
|
||||||
|
char *strip(char *); /* strip off to minimal name */
|
||||||
|
void do_error(struct command *); /* issue user defined error */
|
||||||
|
void create_docu(char *); /* create command 'docu' */
|
||||||
|
extern void add_variables(char *); /* add pi and e to symbol table */
|
||||||
|
void compile(void); /* create a subroutine at runtime */
|
||||||
|
void create_execute(int); /* create command 'cEXECUTE' */
|
||||||
|
void execute(struct command *); /* execute a subroutine */
|
||||||
|
int isbound(void); /* check if this interpreter is bound to a program */
|
||||||
|
|
||||||
|
|
||||||
|
/* io.c */
|
||||||
|
void checkopen(void); /* check, if open has been sucessfull */
|
||||||
|
void create_colour(int); /* create command 'reverse' */
|
||||||
|
void colour(struct command *cmd); /* switch reverse-printing */
|
||||||
|
void create_print(char); /* create command 'print' */
|
||||||
|
void print(struct command *); /* print on screen */
|
||||||
|
void create_myread(char,int); /* create command 'read' */
|
||||||
|
void myread(struct command *); /* read from file or stdin */
|
||||||
|
void create_onestring(char *); /* write string to file */
|
||||||
|
void onestring(char *); /* write string to file */
|
||||||
|
void chkprompt(void); /* print an intermediate prompt if necessary */
|
||||||
|
void create_myopen(int); /* create command 'myopen' */
|
||||||
|
void myopen(struct command *); /* open specified file for given name */
|
||||||
|
void testeof(struct command *); /* close the specified stream */
|
||||||
|
void myclose(); /* close the specified stream */
|
||||||
|
void create_pps(int,int); /* create command pushswitch or popswitch */
|
||||||
|
void push_switch(struct command *); /* push current stream on stack and switch to new one */
|
||||||
|
void pop_switch(void); /* pop current stream from stack and switch to it */
|
||||||
|
void mymove(); /* move to specific position on screen */
|
||||||
|
void clearscreen(); /* clear entire screen */
|
||||||
|
char *inkey(double); /* gets char from keyboard, blocks and doesn´t print */
|
||||||
|
char *replace(char *); /* replace \n,\a, etc. */
|
||||||
|
|
||||||
|
/* graphic.c */
|
||||||
|
void create_openwin(int); /* create Command 'openwin' */
|
||||||
|
void openwin(struct command *, YabInterface* yab); /* open a Window */
|
||||||
|
void closewin(struct command *, YabInterface* yab); /* close the window */
|
||||||
|
int numwindows(); /* number of windows opened */
|
||||||
|
void createbutton(struct command *, YabInterface* yab); /* create a Button */
|
||||||
|
int createimage(double x, double y, const char* imagefile, const char* window, YabInterface* yab, int line, const char* libname); /* insert an image*/
|
||||||
|
int createimage2(double x1, double y1, double x2, double y2, const char* imagefile, const char* window, YabInterface* yab, int line, const char* libname); /* insert an image*/
|
||||||
|
int createsvg(double x1, double y1, double x2, double y2, const char* imagefile, const char* window, YabInterface* yab, int line, const char* libname); /* insert a svg image*/
|
||||||
|
int ismousein(const char* view, YabInterface *yab, int line, const char* libname); /* check if mouse is in view */
|
||||||
|
char* getmousein(YabInterface *yab, int line, const char* libname); /* check which view the mouse is in */ //vasper
|
||||||
|
void drawtext(struct command *, YabInterface* yab); /* draw text */
|
||||||
|
void drawrect(struct command *, YabInterface* yab); /* draw rectangle */
|
||||||
|
void drawclear(struct command *, YabInterface* yab); /* clears canvas */
|
||||||
|
void createmenu(struct command *, YabInterface* yab); /* add a menu */
|
||||||
|
void createalert(struct command *, YabInterface* yab); /* alert */
|
||||||
|
void createtext(struct command *, YabInterface* yab); /* text */
|
||||||
|
void text2(struct command *, YabInterface* yab); /* text */
|
||||||
|
void textalign(struct command *, YabInterface* yab); /* align text */
|
||||||
|
void createtextcontrol(struct command *, YabInterface* yab); /* textcontrol */
|
||||||
|
void createcheckbox(struct command *, YabInterface* yab); /* checkbox*/
|
||||||
|
void createradiobutton(struct command *, YabInterface* yab); /* radio button */
|
||||||
|
void createlistbox(struct command *, YabInterface* yab); /* list box */
|
||||||
|
void createdropbox(struct command *, YabInterface* yab); /* drop box */
|
||||||
|
void createitem(struct command *, YabInterface* yab); /* item add*/
|
||||||
|
void removeitem(struct command *, YabInterface* yab); /* item del*/
|
||||||
|
void clearitems(struct command *, YabInterface* yab); /* clears itemlist */
|
||||||
|
void localize();
|
||||||
|
void localizestop();
|
||||||
|
void localize2(struct command *, YabInterface* yab);
|
||||||
|
void setlayout(struct command *, YabInterface* yab); /* set layout */
|
||||||
|
void winset1(struct command *, YabInterface* yab);
|
||||||
|
void winset2(struct command *, YabInterface* yab);
|
||||||
|
void winset3(struct command *, YabInterface* yab);
|
||||||
|
void winset4(struct command *, YabInterface* yab);
|
||||||
|
void winclear(struct command *, YabInterface* yab);
|
||||||
|
void textedit(struct command *, YabInterface* yab);
|
||||||
|
void textadd(struct command *, YabInterface* yab);
|
||||||
|
void textset(struct command *, YabInterface* yab);
|
||||||
|
void textset2(struct command *, YabInterface* yab);
|
||||||
|
void textset3(struct command *, YabInterface* yab);
|
||||||
|
void textcolor1(struct command *, YabInterface* yab);
|
||||||
|
void textcolor2(struct command *, YabInterface* yab);
|
||||||
|
void textclear(struct command *, YabInterface* yab);
|
||||||
|
char* textget(const char*, YabInterface* yab, int line, const char* libname);
|
||||||
|
int textget2(const char*, const char*, YabInterface* yab, int line, const char* libname);
|
||||||
|
char* textget3(const char*, int, YabInterface* yab, int line, const char* libname);
|
||||||
|
double textget4(const char*, const char*, int, YabInterface* yab, int line, const char* libname);
|
||||||
|
int textget5(const char*, const char*, const char*, YabInterface* yab, int line, const char* libname);
|
||||||
|
char* textget6(const char*, const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
char* textcontrolget(const char*, YabInterface* yab, int line, const char* libname);
|
||||||
|
void drawset1(struct command *, YabInterface* yab);
|
||||||
|
void drawset2(struct command *, YabInterface* yab);
|
||||||
|
char* getmessages(YabInterface* yab, int line, const char* libname); /* get message string */
|
||||||
|
char* getmousemessages(const char* view, YabInterface* yab, int line, const char* libname); /* get mouse message string */
|
||||||
|
char* gettranslation(const char*,YabInterface* yab, int line, const char* libname); /* get translation string */
|
||||||
|
char* getmenutranslation(const char*,YabInterface* yab, int line, const char* libname); /* get translation string */
|
||||||
|
char* getloadfilepanel(const char*, const char*, const char*, YabInterface *yab, int line, const char* libname); /* open a load filepanel */
|
||||||
|
char* getsavefilepanel(const char*, const char*, const char*, const char*, YabInterface *yab, int line, const char* libname); /* open a save filepanel */
|
||||||
|
void view(struct command *, YabInterface *yab); /* add a view */
|
||||||
|
void boxview(struct command *, YabInterface *yab); /* add a boxview */
|
||||||
|
void boxviewset(struct command *, YabInterface *yab);/*boxview options*/
|
||||||
|
void tab(struct command *, YabInterface *yab); /* add a tab */
|
||||||
|
void tabset(struct command *, YabInterface *yab); /* set a tab */
|
||||||
|
void tabadd(struct command *, YabInterface *yab);
|
||||||
|
void tabdel(struct command *, YabInterface *yab);
|
||||||
|
int tabviewget(const char* tab, YabInterface *yab, int line, const char* libname); /* get a tab */
|
||||||
|
void drawdot(struct command *, YabInterface *yab); /* draw a dot */
|
||||||
|
void drawline(struct command *, YabInterface *yab); /* draw a line */
|
||||||
|
void drawcircle(struct command *, YabInterface *yab); /* draw a circle */
|
||||||
|
void drawellipse(struct command *, YabInterface *yab); /* draw a ellipse */
|
||||||
|
void drawcurve(struct command *, YabInterface *yab); /* draw a curve */
|
||||||
|
void slider1(struct command *, YabInterface *yab);
|
||||||
|
void slider2(struct command *, YabInterface *yab);
|
||||||
|
void slider3(struct command *, YabInterface *yab);
|
||||||
|
void slider4(struct command *, YabInterface *yab);
|
||||||
|
void slider5(struct command *, YabInterface *yab);
|
||||||
|
void slider6(struct command *, YabInterface *yab);
|
||||||
|
void option1(struct command *, YabInterface *yab);
|
||||||
|
void option2(struct command *, YabInterface *yab);
|
||||||
|
void option3(struct command *, YabInterface *yab);
|
||||||
|
void dropzone(struct command *, YabInterface *yab);
|
||||||
|
void colorcontrol1(struct command *, YabInterface *yab);
|
||||||
|
void colorcontrol2(struct command *, YabInterface *yab);
|
||||||
|
void textcontrol2(struct command *, YabInterface *yab);
|
||||||
|
void textcontrol3(struct command *, YabInterface *yab);
|
||||||
|
void textcontrol4(struct command *, YabInterface *yab);
|
||||||
|
void textcontrol5(struct command *, YabInterface *yab);
|
||||||
|
void treebox1(struct command *, YabInterface *yab);
|
||||||
|
void treebox2(struct command *, YabInterface *yab);
|
||||||
|
void treebox3(struct command *, YabInterface *yab);
|
||||||
|
void treebox4(struct command *, YabInterface *yab);
|
||||||
|
void treebox5(struct command *, YabInterface *yab);
|
||||||
|
void treebox7(struct command *, YabInterface *yab);
|
||||||
|
void treebox8(struct command *, YabInterface *yab);
|
||||||
|
void treebox9(struct command *, YabInterface *yab);
|
||||||
|
void treebox10(struct command *, YabInterface *yab);
|
||||||
|
void treebox11(struct command *, YabInterface *yab);
|
||||||
|
void buttonimage(struct command *, YabInterface *yab);
|
||||||
|
void checkboximage(struct command *, YabInterface *yab);
|
||||||
|
void checkboxset(struct command *, YabInterface *yab);
|
||||||
|
void radioset(struct command *, YabInterface *yab);
|
||||||
|
void tooltip(struct command *, YabInterface *yab);
|
||||||
|
void tooltipcolor(struct command *, YabInterface *yab);
|
||||||
|
void listsort(struct command *, YabInterface *yab);
|
||||||
|
void treesort(struct command *, YabInterface *yab);
|
||||||
|
void filebox(struct command *, YabInterface *yab);
|
||||||
|
void fileboxadd2(struct command *, YabInterface *yab);
|
||||||
|
void fileboxclear(struct command *, YabInterface *yab);
|
||||||
|
void columnboxadd(struct command *, YabInterface *yab);
|
||||||
|
void columnboxremove(struct command *, YabInterface *yab);
|
||||||
|
void columnboxselect(struct command *, YabInterface *yab);
|
||||||
|
void columnboxcolor(struct command *, YabInterface *yab);
|
||||||
|
void dropboxselect(struct command *, YabInterface *yab);
|
||||||
|
void menu2(struct command *, YabInterface *yab);
|
||||||
|
void submenu1(struct command *, YabInterface *yab);
|
||||||
|
void submenu2(struct command *, YabInterface *yab);
|
||||||
|
void clipboardcopy(struct command *, YabInterface *yab);
|
||||||
|
void launch(struct command *, YabInterface *yab);
|
||||||
|
int printer(const char* docname, const char *view, const char* config, YabInterface *yab, int line, const char* libname);
|
||||||
|
void printerconfig(struct command *, YabInterface *yab);
|
||||||
|
char* keyboardmessages(const char* view, YabInterface* yab, int line, const char* libname);
|
||||||
|
char* clipboardpaste(YabInterface* yab, int line, const char* libname);
|
||||||
|
char* columnboxget(const char* columnbox, int column, int position, YabInterface* yab, int line, const char* libname);
|
||||||
|
int columnboxcount(const char* columnbox, YabInterface* yab, int line, const char* libname);
|
||||||
|
int windowgetnum(const char* view, const char *option, YabInterface* yab, int line, const char* libname);
|
||||||
|
int viewgetnum(const char* view, const char *option, YabInterface* yab, int line, const char* libname); //vasper
|
||||||
|
int newalert(const char* text, const char* button1, const char* button2, const char* button3, const char* option, YabInterface* yab, int line, const char* libname);
|
||||||
|
void calendar1(struct command *, YabInterface *yab);
|
||||||
|
char* calendar2(const char* calendar, YabInterface *yab, int line, const char* libname);
|
||||||
|
void calendar3(struct command *, YabInterface *yab);
|
||||||
|
void listboxadd1(struct command *, YabInterface *yab);
|
||||||
|
void listboxadd2(struct command *, YabInterface *yab);
|
||||||
|
void listboxselect(struct command *, YabInterface *yab);
|
||||||
|
void listboxremove(struct command *, YabInterface *yab);
|
||||||
|
int listboxcount(const char* listbox, YabInterface *yab, int line, const char* libname);
|
||||||
|
char* treeboxget(const char* treebox, int position, YabInterface *yab, int line, const char* libname);
|
||||||
|
int treeboxcount(const char* treebox, YabInterface *yab, int line, const char* libname);
|
||||||
|
char* listboxget(const char* listbox, int position, YabInterface *yab, int line, const char* libname);
|
||||||
|
void scrollbar(struct command *, YabInterface *yab);
|
||||||
|
void scrollbarset1(struct command *, YabInterface *yab);
|
||||||
|
void scrollbarset2(struct command *, YabInterface *yab);
|
||||||
|
void scrollbarset3(struct command *, YabInterface *yab);
|
||||||
|
double scrollbarget(const char* scrollbar, const char* option, YabInterface *yab, int line, const char* libname);
|
||||||
|
void splitview1(struct command *, YabInterface *yab);
|
||||||
|
void splitview2(struct command *, YabInterface *yab);
|
||||||
|
void splitview3(struct command *, YabInterface *yab);
|
||||||
|
double splitviewget(const char* splitview, const char* option, YabInterface *yab, int line, const char* libname);
|
||||||
|
void stackview1(struct command *, YabInterface *yab);
|
||||||
|
void stackview2(struct command *, YabInterface *yab);
|
||||||
|
int stackviewget(const char* stackview, YabInterface *yab, int line, const char* libname);
|
||||||
|
void texturl1(struct command *, YabInterface *yab);
|
||||||
|
void texturl2(struct command *, YabInterface *yab);
|
||||||
|
void drawset3(struct command *, YabInterface *yab);
|
||||||
|
void spincontrol1(struct command *, YabInterface *yab);
|
||||||
|
void spincontrol2(struct command *, YabInterface *yab);
|
||||||
|
int spincontrol(const char* spincontrol, YabInterface *yab, int line, const char* libname);
|
||||||
|
char* popupmenu(double x, double y, const char* messages, const char* id, YabInterface *yab, int line, const char* libname);
|
||||||
|
void dropboxremove(struct command *, YabInterface *yab);
|
||||||
|
void dropboxclear(struct command *, YabInterface *yab);
|
||||||
|
int dropboxcount(const char* id, YabInterface *yab, int line, const char* libname);
|
||||||
|
char* dropboxget(const char* id, int position, YabInterface *yab, int line, const char* libname);
|
||||||
|
int sliderget(const char *slider, YabInterface *yab, int line, const char* libname);
|
||||||
|
int colorcontrolget(const char* colorcontrol, const char* option, YabInterface *yab, int line, const char* libname);
|
||||||
|
void submenu3(struct command *, YabInterface *yab);
|
||||||
|
void menu3(struct command *, YabInterface *yab);
|
||||||
|
double drawget1(const char*, const char*, const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
double drawget2(const char*, const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
char* drawget3(const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
int drawget4(double, double, const char*, const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
void option4(struct command *, YabInterface *yab);
|
||||||
|
void option5(struct command *, YabInterface *yab);
|
||||||
|
void treebox12(struct command *, YabInterface *yab);
|
||||||
|
int messagesend(const char*, const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
int threadkill(const char*, int, YabInterface *yab, int line, const char* libname);
|
||||||
|
int threadget(const char*, const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
void bitmap(struct command *, YabInterface *yab);
|
||||||
|
void bitmapdraw(struct command *, YabInterface *yab);
|
||||||
|
void bitmapdraw2(struct command *, YabInterface *yab);
|
||||||
|
void bitmapget(struct command *, YabInterface *yab);
|
||||||
|
void bitmapget2(struct command *, YabInterface *yab);
|
||||||
|
void bitmapgeticon(struct command *, YabInterface *yab);
|
||||||
|
void bitmapdrag(struct command *, YabInterface *yab);
|
||||||
|
void bitmapremove(struct command *, YabInterface *yab);
|
||||||
|
void screenshot(struct command *, YabInterface *yab);
|
||||||
|
void statusbar(struct command *, YabInterface *yab);
|
||||||
|
void statusbarset(struct command *, YabInterface *yab);
|
||||||
|
void statusbarset2(struct command *, YabInterface *yab);
|
||||||
|
void statusbarset3(struct command *, YabInterface *yab);
|
||||||
|
void canvas(struct command *, YabInterface *yab);
|
||||||
|
int bitmapsave(const char*, const char*, const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
int bitmapload(const char*, const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
int bitmapgetnum(const char*, const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
int bitmapcolor(double x, double y, const char* id, const char* option, YabInterface *yab, int line, const char* libname);
|
||||||
|
int listboxgetnum(const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
int dropboxgetnum(const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
int columnboxgetnum(const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
int treeboxgetnum(const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
int treeboxgetopt(const char*, const char*, int, YabInterface *yab, int line, const char* libname);
|
||||||
|
void treebox13(struct command *, YabInterface *yab);
|
||||||
|
void drawset4(struct command *, YabInterface *yab);
|
||||||
|
int sound(const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
void soundstop(struct command *, YabInterface *yab);
|
||||||
|
void soundwait(struct command *, YabInterface *yab);
|
||||||
|
void shortcut(struct command *, YabInterface *yab);
|
||||||
|
int iscomputeron(YabInterface *yab, int line, const char* libname);
|
||||||
|
void mouseset(struct command *, YabInterface *yab);
|
||||||
|
void gettermkey(char *); /* read a key from terminal */
|
||||||
|
void attribute1(struct command *, YabInterface *yab);
|
||||||
|
void attributeclear(struct command *, YabInterface *yab);
|
||||||
|
char* attributeget1(const char*, const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
double attributeget2(const char*, const char*, YabInterface *yab, int line, const char* libname);
|
||||||
|
|
||||||
|
/* function.c */
|
||||||
|
void create_exception(int); /* create command 'exception' */
|
||||||
|
void exception(struct command *); /* change handling of exceptions */
|
||||||
|
void create_poke(char); /* create Command 'POKE' */
|
||||||
|
void poke(); /* poke in internals */
|
||||||
|
void pokefile(struct command *); /* poke into file */
|
||||||
|
void create_dblrelop(char); /* create command dblrelop */
|
||||||
|
void dblrelop(struct command *); /* compare topmost double-values */
|
||||||
|
void concat(void); /* concetenates two strings from stack */
|
||||||
|
void create_strrelop(char); /* create command strrelop */
|
||||||
|
void strrelop(struct command *); /* compare topmost string-values */
|
||||||
|
void create_changestring(int); /* create command 'changestring' */
|
||||||
|
void changestring(struct command *); /* changes a string */
|
||||||
|
void glob(void); /* check, if pattern globs string */
|
||||||
|
void create_boole(char); /* create command boole */
|
||||||
|
void boole(struct command *); /* perform and/or/not */
|
||||||
|
void create_function(int); /* create command 'function' */
|
||||||
|
void function(struct command *, YabInterface* yab); /* performs a function */
|
||||||
|
int myformat(char *,double,char *,char *); /* format number */
|
||||||
|
void create_restore(char *); /* create command 'restore' */
|
||||||
|
void restore(struct command *); /* reset data pointer to given label */
|
||||||
|
void create_dbldata(double); /* create command dbldata */
|
||||||
|
void create_strdata(char *); /* create command strdata */
|
||||||
|
void create_readdata(char); /* create command readdata */
|
||||||
|
void readdata(struct command *); /* read data items */
|
||||||
|
void mywait(); /* wait given number of seconds */
|
||||||
|
void mybell(); /* ring ascii bell */
|
||||||
|
void getmousexybm(char *,int *,int *,int *,int *); /* get mouse coordinates */
|
||||||
|
void token(struct command *); /* extract token from variable */
|
||||||
|
void tokenalt(struct command *); /* extract token from variable with alternate semantics */
|
||||||
|
|
||||||
|
|
||||||
|
/* symbol.c */
|
||||||
|
struct array *create_array(int,int); /* create an array */
|
||||||
|
void clearrefs(struct command *); /* clear references for commands within function */
|
||||||
|
void duplicate(void); /* duplicate topmost element of stack */
|
||||||
|
void negate(void); /* negates top of stack */
|
||||||
|
void create_require(int); /* create command 'cREQUIRE' */
|
||||||
|
void require(struct command *); /* check item on stack has right type */
|
||||||
|
void create_makelocal(char *,int); /* create command 'cMAKELOCAL' */
|
||||||
|
void create_makestatic(char *,int); /* create command 'cMAKESTATIC' */
|
||||||
|
void create_arraylink(char *,int); /* create command 'cARRAYLINK' */
|
||||||
|
void create_pusharrayref(char *,int); /* create command 'cPUSHARRAYREF' */
|
||||||
|
void pusharrayref(struct command *); /* push an array reference onto stack */
|
||||||
|
void arraylink(struct command *); /* link a local symbol to a global array */
|
||||||
|
void makestatic(struct command *); /* makes symbol static */
|
||||||
|
void makelocal(struct command *); /* makes symbol local */
|
||||||
|
void create_numparam(void); /* create command 'cNUMPARAM' */
|
||||||
|
void numparam(struct command *); /* count number of function parameters */
|
||||||
|
void pushdblsym(struct command *); /* push double symbol onto stack */
|
||||||
|
void popdblsym(struct command *); /* pop double from stack */
|
||||||
|
void create_pushdbl(double); /* create command 'pushdbl' */
|
||||||
|
void pushdbl(struct command *); /* push double onto stack */
|
||||||
|
void create_dblbin(char); /* create binary expression calculation */
|
||||||
|
void dblbin(struct command *); /* compute with two numbers from stack */
|
||||||
|
void pushstrsym(struct command *); /* push string symbol onto stack */
|
||||||
|
void popstrsym(struct command *); /* pop string from stack */
|
||||||
|
void create_pushstr(char *); /* creates command pushstr */
|
||||||
|
void pushstr(struct command *); /* push string onto stack */
|
||||||
|
void pushname(char *); /* push a name on stack */
|
||||||
|
void pushstrptr(struct command *); /* push string-pointer onto stack */
|
||||||
|
void forcheck(void); /* check, if for-loop is done */
|
||||||
|
void forincrement(void); /* increment value on stack */
|
||||||
|
void startfor(void); /* compute initial value of for-variable */
|
||||||
|
void create_goto(char *); /* creates command goto */
|
||||||
|
void create_gosub(char *); /* creates command gosub */
|
||||||
|
void create_call(char *); /* creates command function call */
|
||||||
|
void create_label(char *,int); /* creates command label */
|
||||||
|
void create_sublink(char *); /* create link to subroutine */
|
||||||
|
void pushgoto(void); /* generate label and push goto on stack */
|
||||||
|
void popgoto(void); /* pops a goto and generates the matching command */
|
||||||
|
void jump(struct command *); /* jump to specific Label */
|
||||||
|
void myreturn(struct command *); /* return from gosub */
|
||||||
|
void findnop(); /* used for on_gosub, find trailing nop command */
|
||||||
|
void skipper(void); /* used for on_goto/gosub, skip commands */
|
||||||
|
void skiponce(struct command *); /* skip next command once */
|
||||||
|
void resetskiponce(struct command *); /* find and reset next skip */
|
||||||
|
void decide(void); /* skips next command, if not 0 on stack */
|
||||||
|
void logical_shortcut(struct command *type); /* shortcut and/or if possible */
|
||||||
|
void create_doarray(char *,int); /* creates array-commands */
|
||||||
|
void doarray(struct command *); /* call an array */
|
||||||
|
void create_dim(char *,char); /* create command 'dim' */
|
||||||
|
void dim(struct command *); /* get room for array */
|
||||||
|
void pushlabel(void); /* generate goto and push label on stack */
|
||||||
|
void poplabel(void); /* pops a label and generates the matching command */
|
||||||
|
void storelabel(); /* push label on stack */
|
||||||
|
void matchgoto(); /* generate goto matching label on stack */
|
||||||
|
void swap(void); /*swap topmost elements on stack */
|
||||||
|
struct stackentry *push(void); /* push element on stack and enlarge it*/
|
||||||
|
struct stackentry *pop(int); /* pops element to memory */
|
||||||
|
struct symbol *get_sym(char *,int,int); /* find and/or add a symbol */
|
||||||
|
void link_symbols(struct symbol *,struct symbol *); /* link one symbol to the other */
|
||||||
|
void pushsymlist(void); /* push a new list on symbol stack */
|
||||||
|
void popsymlist(void); /* pop list of symbols and free symbol contents */
|
||||||
|
void dump_sym(); /* dump the stack of lists of symbols */
|
||||||
|
void dump_sub(int); /* dump the stack of subroutine calls */
|
||||||
|
void create_retval(int,int); /* create command 'cRETVAL' */
|
||||||
|
void retval(struct command *); /* check return value of function */
|
||||||
|
void create_endfunction(void); /* create command cEND_FUNCTION */
|
||||||
|
void function_or_array(struct command *); /* decide whether to do perform function or array */
|
||||||
|
struct command *search_label(char *,int); /* search label */
|
||||||
|
void reshufflestack(struct stackentry *); /* reorganize stack for function call */
|
||||||
|
void push_switch_mark(void); /* push a switch mark */
|
||||||
|
void create_clean_switch_mark(int,int); /* add command clean_switch_mark */
|
||||||
|
void clean_switch_mark(struct command *); /* pop everything up to (and including) first switch_mark from stack */
|
||||||
|
void push_switch_id(void); /* generate a new switch id */
|
||||||
|
void pop_switch_id(void); /* get previous switch id */
|
||||||
|
int get_switch_depth(void); /* get current depth of switch id stack */
|
||||||
|
|
||||||
|
|
||||||
|
/* flex.c */
|
||||||
|
void yyerror(char *); /* yyerror message */
|
||||||
|
void open_main(FILE *,char *,char *); /* switch to file */
|
||||||
|
void open_string(char *); /* open string with commands */
|
||||||
|
FILE *open_library(char *,char **,int); /* search and open a library */
|
||||||
|
void switchlib(void); /* switch library, called by bison */
|
||||||
77
yab-IDE/BuildFactory/AutoFooter.mak
Normal file
77
yab-IDE/BuildFactory/AutoFooter.mak
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
##
|
||||||
|
## GCC Options
|
||||||
|
##
|
||||||
|
|
||||||
|
SH=$(shell finddir B_SYSTEM_HEADERS_DIRECTORY)
|
||||||
|
UH= $(shell finddir B_USER_HEADERS_DIRECTORY)
|
||||||
|
GCC = gcc
|
||||||
|
GCC_OPT = $(DBG) $(OPT) -I. $(addprefix -I,$(SH)) $(addprefix -I,$(UH)) -DHAVE_CONFIG -DUNIX $(HAIKUOPT)
|
||||||
|
GPP = g++
|
||||||
|
GPP_OPT = $(DBG) $(OPT) -I. -DHAVE_CONFIG -DUNIX $(HAIKUOPT)
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
## Compile and link
|
||||||
|
##
|
||||||
|
yab: YabMain.o YabInterface.o YabWindow.o YabView.o YabBitmapView.o YabFilePanel.o YabFilePanelLooper.o YabList.o \
|
||||||
|
YabText.o flex.o bison.o symbol.o function.o graphic.o io.o main.o $(COLUMN) column/YabColumnType.o column/ColorTools.o YabStackView.o SplitPane.o URLView.o YabControlLook.o \
|
||||||
|
$(HAIKUTAB) Spinner.o column/ColumnListView.o CalendarControl.o
|
||||||
|
$(GPP) $(GPP_OPT) -o $(TARGET) YabMain.o YabInterface.o YabWindow.o YabView.o YabBitmapView.o YabText.o YabFilePanel.o \
|
||||||
|
YabFilePanelLooper.o YabList.o main.o function.o io.o graphic.o symbol.o bison.o flex.o $(COLUMN) column/YabColumnType.o column/ColorTools.o \
|
||||||
|
YabStackView.o SplitPane.o URLView.o YabControlLook.o $(HAIKUTAB) Spinner.o $(TABLIB) CalendarControl.o \
|
||||||
|
$(LIBPATH) $(LIB)
|
||||||
|
YabMain.o: YabMain.cpp
|
||||||
|
$(GPP) $(GPP_OPT) -c YabMain.cpp -o YabMain.o
|
||||||
|
YabInterface.o: YabInterface.cpp YabInterface.h global.h YabMenu.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabInterface.cpp -o YabInterface.o
|
||||||
|
YabWindow.o: YabWindow.cpp YabWindow.h global.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabWindow.cpp -o YabWindow.o
|
||||||
|
YabView.o: YabView.cpp YabView.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabView.cpp -o YabView.o
|
||||||
|
YabBitmapView.o: YabBitmapView.cpp YabBitmapView.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabBitmapView.cpp -o YabBitmapView.o
|
||||||
|
YabFilePanel.o: YabFilePanel.cpp YabFilePanel.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabFilePanel.cpp -o YabFilePanel.o
|
||||||
|
YabFilePanelLooper.o: YabFilePanelLooper.cpp YabFilePanelLooper.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabFilePanelLooper.cpp -o YabFilePanelLooper.o
|
||||||
|
YabList.o: YabList.cpp YabList.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabList.cpp -o YabList.o
|
||||||
|
YabText.o: YabText.cpp YabText.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabText.cpp -o YabText.o
|
||||||
|
bison.o: bison.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c bison.c -o bison.o
|
||||||
|
flex.o: flex.c bison.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c flex.c -o flex.o
|
||||||
|
function.o: function.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c function.c -o function.o
|
||||||
|
io.o: io.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c io.c -o io.o
|
||||||
|
graphic.o: graphic.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c graphic.c -o graphic.o
|
||||||
|
symbol.o: symbol.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c symbol.c -o symbol.o
|
||||||
|
main.o: main.c yabasic.h config.h
|
||||||
|
$(GCC) $(GCC_OPT) -c main.c -o main.o
|
||||||
|
YabStackView.o: YabStackView.cpp YabStackView.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabStackView.cpp -o YabStackView.o
|
||||||
|
SplitPane.o: SplitPane.cpp SplitPane.h
|
||||||
|
$(GPP) $(GPP_OPT) -c SplitPane.cpp -o SplitPane.o
|
||||||
|
URLView.o: URLView.cpp URLView.h
|
||||||
|
$(GPP) $(GPP_OPT) -c URLView.cpp -o URLView.o
|
||||||
|
Spinner.o: Spinner.cpp Spinner.h
|
||||||
|
$(GPP) $(GPP_OPT) -c Spinner.cpp -o Spinner.o
|
||||||
|
column/ColumnListView.o: column/ColumnListView.cpp column/ColumnListView.h column/ObjectList.h
|
||||||
|
$(GPP) $(GPP_OPT) -c column/ColumnListView.cpp -o column/ColumnListView.o
|
||||||
|
column/ColorTools.o: column/ColorTools.cpp column/ColorTools.h
|
||||||
|
$(GPP) $(GPP_OPT) -c column/ColorTools.cpp -o column/ColorTools.o
|
||||||
|
column/YabColumnType.o: column/YabColumnType.cpp column/YabColumnType.h
|
||||||
|
$(GPP) $(GPP_OPT) -c column/YabColumnType.cpp -o column/YabColumnType.o
|
||||||
|
$(HAIKUTAB): YabTabView.cpp YabTabView.h
|
||||||
|
$(GPP) $(GPP_OPT) -c YabTabView.cpp -o YabTabView.o
|
||||||
|
CalendarControl.o: CalendarControl.cpp CalendarControl.h DateTextView.cpp MonthWindow.cpp MonthView.cpp MouseSenseStringView.cpp
|
||||||
|
$(GPP) $(GPP_OPT) -c CalendarControl.cpp -o CalendarControl.o
|
||||||
|
YabControlLook.o: YabControlLook.h YabControlLook.cpp
|
||||||
|
$(GPP) $(GPP_OPT) -c YabControlLook.cpp -o YabControlLook.o
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f core *.o column/*.o yabasic.output
|
||||||
40
yab-IDE/BuildFactory/AutoHeader.mak
Normal file
40
yab-IDE/BuildFactory/AutoHeader.mak
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
##
|
||||||
|
## yab Haiku BuildFactory Makefile
|
||||||
|
##
|
||||||
|
## (c) Jan Bungeroth 2009 - 2011
|
||||||
|
## Artistic License.
|
||||||
|
##
|
||||||
|
|
||||||
|
##
|
||||||
|
## Haiku stuff
|
||||||
|
##
|
||||||
|
HAIKUTAB = YabTabView.o
|
||||||
|
HAIKUOPT = -DHAIKU
|
||||||
|
|
||||||
|
##
|
||||||
|
## Use our own column list view
|
||||||
|
##
|
||||||
|
COLUMN = column/ColumnListView.o
|
||||||
|
|
||||||
|
##
|
||||||
|
## enable debug
|
||||||
|
##
|
||||||
|
# DBG = -g
|
||||||
|
#
|
||||||
|
|
||||||
|
##
|
||||||
|
## enable optimization
|
||||||
|
##
|
||||||
|
OPT = -O
|
||||||
|
#
|
||||||
|
|
||||||
|
##
|
||||||
|
## Libraries
|
||||||
|
##
|
||||||
|
##LIBPATH = -L/boot/home/config/lib
|
||||||
|
##LIBPATH = -L/boot/system/lib
|
||||||
|
LIBPATHS = $(shell findpaths B_FIND_PATH_DEVELOP_LIB_DIRECTORY)
|
||||||
|
LIBPATH=$(addprefix -L,$(LIBPATHS))
|
||||||
|
|
||||||
|
LIB = -lbe -lroot -ltranslation -ltracker -lmedia -lz
|
||||||
|
|
||||||
488
yab-IDE/BuildFactory/BuildFactory.yab
Executable file
488
yab-IDE/BuildFactory/BuildFactory.yab
Executable file
@@ -0,0 +1,488 @@
|
|||||||
|
#!yab
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// BuildFactory v 2.4
|
||||||
|
//////////////////////////////////////
|
||||||
|
|
||||||
|
// find out in which directory we are
|
||||||
|
if (peek("isbound")) then
|
||||||
|
This_dir$ = peek$("directory")+"/"
|
||||||
|
else
|
||||||
|
This_dir$ = trim$(system$("pwd"))+"/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (system("test -e \""+This_dir$+"yab\"")) then
|
||||||
|
YAB$ = "yab"
|
||||||
|
else
|
||||||
|
YAB$ = This_dir$+"yab"
|
||||||
|
fi
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// if yab gives us its version, we know that it exists.
|
||||||
|
// Otherwise we tell the user to make sure that there is one
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
if (system(YAB$+" -version")) then
|
||||||
|
print "Please make sure you have a yab binary in"
|
||||||
|
print "\t"+left$(This_dir$, len(This_dir$)-1)
|
||||||
|
print "or"
|
||||||
|
print "\t/home/config/bin"
|
||||||
|
print "or"
|
||||||
|
print "\t/system/bin\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
// set some global variables here
|
||||||
|
AppName$ = "BuildFactory"
|
||||||
|
VERSION$ = " 2.4.1"
|
||||||
|
TMP_folder$ = "/boot/var/tmp/BUILD_FACTORY_TMP/"
|
||||||
|
Lib_path$ = "/boot/home/config/settings/yab/"
|
||||||
|
|
||||||
|
dim Library$(1)
|
||||||
|
dim Is_in_lib_path(1)
|
||||||
|
dim Found_sub$(1)
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// Program starts here
|
||||||
|
//
|
||||||
|
|
||||||
|
if (not open(1,"flex.c")) then
|
||||||
|
system("yab flex-bison.yab") // make flex.c and modify it for BuildFactory
|
||||||
|
else
|
||||||
|
close #1
|
||||||
|
endif
|
||||||
|
|
||||||
|
if (peek("argument") < 2) then
|
||||||
|
UsageAdvise(1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
// in- and outputfiles
|
||||||
|
Output_file$ = peek$("argument")
|
||||||
|
Input_file$ = peek$("argument")
|
||||||
|
appsig$ = peek$("argument")
|
||||||
|
run_from_ide$ = peek$("argument")
|
||||||
|
if appsig$="" appsig$="application/x-vnd.yab-app"
|
||||||
|
SetAppSig(appsig$)
|
||||||
|
|
||||||
|
Input_dir$ = left$(Input_file$, rinstr(Input_file$, "/"))
|
||||||
|
Library$(0) = right$(Input_file$, len(Input_file$)-rinstr(Input_file$, "/"))
|
||||||
|
|
||||||
|
if (trim$(Input_dir$) = "") Input_dir$ = This_dir$
|
||||||
|
|
||||||
|
// create the temp folder
|
||||||
|
if (system("test -d \""+TMP_folder$+"\"")) then
|
||||||
|
if (system("mkdir -p \""+TMP_folder$+"\"")) then
|
||||||
|
print "-- Error while creating temp folder!"
|
||||||
|
UsageAdvise(1)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
// We clean up all the files including the libs, if existing
|
||||||
|
for NL = 0 to num_lib
|
||||||
|
if (Is_in_lib_path(NL)) then
|
||||||
|
lib$ = Lib_path$+Library$(NL)
|
||||||
|
else
|
||||||
|
lib$ = Input_dir$+Library$(NL)
|
||||||
|
fi
|
||||||
|
num_lib = CleanUpCode(lib$)
|
||||||
|
next NL
|
||||||
|
|
||||||
|
// writing all the libs into the mainfile
|
||||||
|
// because the BuildFactory can not handle libs
|
||||||
|
err = JoinFiles(Output_file$+"_bf.yab")
|
||||||
|
|
||||||
|
// here it comes - the BuildFactory
|
||||||
|
BuildFactory(Output_file$+"_bf.yab")
|
||||||
|
|
||||||
|
// cleaning up
|
||||||
|
RmErr = RemoveTemp()
|
||||||
|
system ("RdefApply parts/YAB.bf.rdef "+Output_file$)
|
||||||
|
system ("addattr -t mime BEOS:APP_SIG "+appsig$+" "+Output_file$)
|
||||||
|
system ("addattr -t mime BEOS:TYPE application/x-vnd.be-elfexecutable "+Output_file$)
|
||||||
|
|
||||||
|
|
||||||
|
// check if the BuildFactory was envoked by the yab-ide.
|
||||||
|
// if so, copy the output file to the inmputfile's directory and open the directory.
|
||||||
|
// the IDE will delete the output file from the BuildFactory directory.
|
||||||
|
|
||||||
|
|
||||||
|
if run_from_ide$ = "yab-ide" then
|
||||||
|
system ("cp "+Output_file$+" "+Input_dir$)
|
||||||
|
system ("open "+Input_dir$)
|
||||||
|
endif
|
||||||
|
|
||||||
|
print "--------"
|
||||||
|
print "-- Info:"
|
||||||
|
print "\tNumber of libs:\t\t", num_lib
|
||||||
|
print "\tNumber of subs:\t\t", num_sub
|
||||||
|
print "\tNumber of lines:\t", num_line
|
||||||
|
|
||||||
|
exit
|
||||||
|
|
||||||
|
//
|
||||||
|
// programm ends here
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// joining all files to one
|
||||||
|
///////////////////////////////////////////
|
||||||
|
sub JoinFiles(the_file$)
|
||||||
|
local in_file, out_file
|
||||||
|
|
||||||
|
out_file = OpenWriteFile(the_file$)
|
||||||
|
for NL = 0 to num_lib
|
||||||
|
// contents of each file is written to our joined temp file
|
||||||
|
in_file = OpenReadFile(TMP_folder$+Library$(NL))
|
||||||
|
while (not eof(in_file))
|
||||||
|
print #out_file LineInput$(in_file)
|
||||||
|
num_line = num_line + 1
|
||||||
|
wend
|
||||||
|
close in_file
|
||||||
|
next NL
|
||||||
|
close out_file
|
||||||
|
|
||||||
|
return
|
||||||
|
end sub
|
||||||
|
|
||||||
|
///////////////////////////////////////////
|
||||||
|
// here we are cleaning up the files
|
||||||
|
///////////////////////////////////////////
|
||||||
|
sub CleanUpCode(the_file$)
|
||||||
|
local the_filename$, out_file$
|
||||||
|
local in_file, out_file
|
||||||
|
local Current_line$
|
||||||
|
|
||||||
|
the_filename$ = right$(the_file$, len(the_file$)-rinstr(the_file$, "/"))
|
||||||
|
out_file$ = TMP_folder$+the_filename$
|
||||||
|
|
||||||
|
out_file = OpenWriteFile(out_file$)
|
||||||
|
in_file = OpenReadFile(the_file$)
|
||||||
|
|
||||||
|
if (min(out_file, in_file) = 0) return -1
|
||||||
|
|
||||||
|
print "\t-- removing not needed stuff ..."
|
||||||
|
while (not eof(in_file))
|
||||||
|
Current_line$ = LineInput$(in_file)
|
||||||
|
|
||||||
|
if (double_sub) then
|
||||||
|
if (upper$(left$(Current_line$, 7)) = "END SUB") double_sub = false
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
// remove empty lines and commented lines and stuff
|
||||||
|
if (Current_line$ = "") continue
|
||||||
|
if (left$(Current_line$, 2) = "//") continue
|
||||||
|
if (left$(Current_line$, 1) = "#") continue
|
||||||
|
if (upper$(left$(Current_line$, 11)) = "EXPORT SUB ") then
|
||||||
|
Current_line$ = trim$(right$(Current_line$, len(Current_line$)-6))
|
||||||
|
fi
|
||||||
|
Current_line$ = CheckOnLineComments$(Current_line$)
|
||||||
|
if (upper$(left$(Current_line$, 4)) = "SUB ") then
|
||||||
|
curr_sub$ = right$(Current_line$, len(Current_line$)-4)
|
||||||
|
curr_sub$ = left$(curr_sub$, instr(curr_sub$, "("))
|
||||||
|
for NS = 0 to num_sub
|
||||||
|
if (Found_sub$(NS) = curr_sub$) then
|
||||||
|
double_sub = true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
next NS
|
||||||
|
|
||||||
|
if (double_sub) then
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
num_sub = num_sub + 1
|
||||||
|
dim Found_sub$(num_sub+1)
|
||||||
|
Found_sub$(num_sub) = curr_sub$
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if (upper$(left$(Current_line$, 6)) = "IMPORT") then
|
||||||
|
found_lib = FindLibraries(Current_line$)
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if (upper$(Current_line$) = "ENDIF") Current_line$ = "fi"
|
||||||
|
|
||||||
|
print #out_file Current_line$
|
||||||
|
wend
|
||||||
|
|
||||||
|
close in_file
|
||||||
|
close out_file
|
||||||
|
|
||||||
|
return found_lib
|
||||||
|
end sub
|
||||||
|
|
||||||
|
////////////////////////////////////////////
|
||||||
|
// search for comments behind a needed line
|
||||||
|
// if found, remove it. Exept there is a "
|
||||||
|
////////////////////////////////////////////
|
||||||
|
sub CheckOnLineComments$(the_line$)
|
||||||
|
D = instr(the_line$, "//")
|
||||||
|
|
||||||
|
if (D) then
|
||||||
|
local is_comment
|
||||||
|
local A : local B
|
||||||
|
local C : local E
|
||||||
|
|
||||||
|
for B = 1 to len(the_line$)
|
||||||
|
A = asc(mid$(the_line$, B, 1))
|
||||||
|
if (B > D) then
|
||||||
|
if (A = 34 and is_comment) then
|
||||||
|
C = true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
E = asc(mid$(the_line$, B+1, 1))
|
||||||
|
if (E = 34 and not A = 92) then
|
||||||
|
if (is_comment) then
|
||||||
|
is_comment = false
|
||||||
|
else
|
||||||
|
is_comment = true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
next B
|
||||||
|
|
||||||
|
if (not C) the_line$ = left$(the_line$, D-1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
return trim$(the_line$)
|
||||||
|
end sub
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
// search for libraries, to prepare them as well
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
sub FindLibraries(the_line$)
|
||||||
|
local Library$
|
||||||
|
|
||||||
|
Library$ = right$(the_line$, len(the_line$)-7)
|
||||||
|
|
||||||
|
if (upper$(right$(Library$, 4)) <> ".YAB") then
|
||||||
|
Library$ = Library$+".yab"
|
||||||
|
fi
|
||||||
|
|
||||||
|
num_lib = num_lib + 1
|
||||||
|
dim Library$(num_lib+1)
|
||||||
|
dim Is_in_lib_path(num_lib+1)
|
||||||
|
|
||||||
|
if (system("test -e \""+Input_dir$+Library$+"\"")) then
|
||||||
|
if (system("test -e \""+Lib_path$+Library$+"\"")) then
|
||||||
|
print "-- Could not find lib\n\t"+Library$
|
||||||
|
num_lib = num_lib - 1
|
||||||
|
return num_lib
|
||||||
|
else
|
||||||
|
Is_in_lib_path(num_lib) = true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
Library$(num_lib) = Library$
|
||||||
|
|
||||||
|
print "-- Found lib: "+Library$
|
||||||
|
return num_lib
|
||||||
|
end sub
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// open the inputfile for reading
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
sub OpenReadFile(the_file$)
|
||||||
|
local READ_FILE
|
||||||
|
READ_FILE = 22
|
||||||
|
|
||||||
|
if (not open(#READ_FILE,the_file$,"r")) then
|
||||||
|
print "-- Could not open "+the_file$
|
||||||
|
print "-- for reading!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
return READ_FILE
|
||||||
|
end sub
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// open the outputfile for writing
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
sub OpenWriteFile(the_file$)
|
||||||
|
local WRITE_FILE
|
||||||
|
WRITE_FILE = 23
|
||||||
|
|
||||||
|
if (not open(#WRITE_FILE,the_file$,"w")) then
|
||||||
|
print "-- Could not open "+the_file$
|
||||||
|
print "-- for writing!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
return WRITE_FILE
|
||||||
|
end sub
|
||||||
|
|
||||||
|
/////////////////////////////////////////
|
||||||
|
// read in one line from the given file
|
||||||
|
/////////////////////////////////////////
|
||||||
|
sub LineInput$(n)
|
||||||
|
local tmp : local tmp$
|
||||||
|
while (tmp <> 10)
|
||||||
|
tmp = peek(n)
|
||||||
|
if (tmp < 0) continue
|
||||||
|
tmp$ = tmp$ + chr$(tmp)
|
||||||
|
wend
|
||||||
|
|
||||||
|
return trim$(tmp$)
|
||||||
|
end sub
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// Remove our tempfolder
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
sub RemoveTemp()
|
||||||
|
if (not system("test -d \""+TMP_folder$+"\"")) then
|
||||||
|
RmErr = system("rm -rf \""+TMP_folder$+"\"")
|
||||||
|
fi
|
||||||
|
|
||||||
|
return RmErr
|
||||||
|
end sub
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// tell the user how to use this app
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
sub UsageAdvise(n)
|
||||||
|
print "\n"+AppName$+VERSION$
|
||||||
|
print "Usage:"
|
||||||
|
print "\t"+AppName$+" outputfile inputfile < applicationsignature >\n"
|
||||||
|
print "\tFilenames may have no spaces!\n"
|
||||||
|
print "\tapplicationsignature default is: application/x-vnd.yab-app\n"
|
||||||
|
RemoveTemp()
|
||||||
|
|
||||||
|
exit n
|
||||||
|
end sub
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
// set the application signature in YabMain.cpp
|
||||||
|
/////////////////////////////////////////////////////////////
|
||||||
|
sub SetAppSig(sig$)
|
||||||
|
app_sig$="\n\tBString tmp(\""+sig$+"\");\n"
|
||||||
|
open #1, This_dir$+"parts/YabMain.cpp.appsig","w"
|
||||||
|
print #1 app_sig$
|
||||||
|
close #1
|
||||||
|
cmd$="cat "+This_dir$+"parts/YabMain.cpp.start "+This_dir$+"parts/YabMain.cpp.appsig "+This_dir$+"parts/YabMain.cpp.end > "+This_dir$+"YabMain.cpp"
|
||||||
|
system(cmd$)
|
||||||
|
|
||||||
|
end sub
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
////////////////////////////////////////
|
||||||
|
// the BuildFactory starts here
|
||||||
|
////////////////////////////////////////
|
||||||
|
////////////////////////////////////////
|
||||||
|
sub BuildFactory(f$)
|
||||||
|
handle = open(f$, "r")
|
||||||
|
if(not handle) then
|
||||||
|
print "Error: Could not open file "+f$
|
||||||
|
exit(1)
|
||||||
|
endif
|
||||||
|
|
||||||
|
print "Reading file "+f$+"..."
|
||||||
|
print
|
||||||
|
|
||||||
|
while(not eof(handle))
|
||||||
|
numRead = numRead + 1
|
||||||
|
dim line$(numRead)
|
||||||
|
line$(numRead) = GetLine$(handle)
|
||||||
|
wend
|
||||||
|
close(handle)
|
||||||
|
|
||||||
|
print "Dumping file..."
|
||||||
|
print
|
||||||
|
DumpProg(f$)
|
||||||
|
|
||||||
|
// times have changed :)
|
||||||
|
hasZeta = false
|
||||||
|
|
||||||
|
print "This yab version was compiled on "+peek$("os")+"."
|
||||||
|
realOS$ = upper$(system$("uname -o"))
|
||||||
|
realOS$ = left$(realOS$, len(realOS$)-1)
|
||||||
|
print "This system is running "+realOS$
|
||||||
|
|
||||||
|
print "Writing Automakefile and global.h..."
|
||||||
|
print
|
||||||
|
|
||||||
|
system("cp AutoHeader.mak Automakefile")
|
||||||
|
|
||||||
|
handle = open("Automakefile", "a")
|
||||||
|
if(not handle) then
|
||||||
|
print "Error: Could not write file Automakefile"
|
||||||
|
exit(1)
|
||||||
|
endif
|
||||||
|
|
||||||
|
print #handle "TARGET = "+left$(f$, len(f$)-7)
|
||||||
|
|
||||||
|
close(handle)
|
||||||
|
|
||||||
|
system("cat AutoFooter.mak >> Automakefile")
|
||||||
|
|
||||||
|
print "Starting make (ignore warnings)..."
|
||||||
|
print
|
||||||
|
system("make -f Automakefile clean")
|
||||||
|
system("make -f Automakefile")
|
||||||
|
system("make -f Automakefile clean")
|
||||||
|
system("rm -f program.h Automakefile "+f$)
|
||||||
|
print
|
||||||
|
print "Finished"
|
||||||
|
print
|
||||||
|
|
||||||
|
return
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub GetFirstCommand$(line$)
|
||||||
|
local t$: local ret$
|
||||||
|
local i
|
||||||
|
|
||||||
|
t$ = ltrim$(line$)
|
||||||
|
for i=1 to len(t$)
|
||||||
|
if(mid$(t$,i,1) = " " or mid$(t$,i,1) = "\t" or mid$(t$,i,1) = "\n" or mid$(t$,i,1) = "(") break
|
||||||
|
ret$ = ret$ + mid$(t$,i,1)
|
||||||
|
next i
|
||||||
|
return ret$
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub DumpProg(fileName$)
|
||||||
|
local handle
|
||||||
|
local t$
|
||||||
|
local i
|
||||||
|
|
||||||
|
if(val(system$("wc -c "+fileName$)) < 100) then
|
||||||
|
print "WARNING: File too small, filling up program with comments"
|
||||||
|
handle = open(fileName$, "a")
|
||||||
|
if(handle) then
|
||||||
|
print #handle "rem ~~ This comment was added by the ~~"
|
||||||
|
print #handle "rem ~~ BuildFactory because your program ~~"
|
||||||
|
print #handle "rem ~~ was too small. ~~"
|
||||||
|
close(handle)
|
||||||
|
else
|
||||||
|
print "ERROR: Could not add comments, is "+fileName$+" write-protected?"
|
||||||
|
exit(1)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
system("yab-compress "+fileName$)
|
||||||
|
handle = open("program.h", "a")
|
||||||
|
if(handle) then
|
||||||
|
print #handle "#define PROGLEN ";
|
||||||
|
t$ = system$("wc -c "+fileName$)
|
||||||
|
i = 1
|
||||||
|
while(mid$(t$,i,1) = " ")
|
||||||
|
i = i + 1
|
||||||
|
wend
|
||||||
|
if(i>1) t$ = right$(t$,len(t$)-i+1)
|
||||||
|
t$ = left$(t$, instr(t$, " ")-1)
|
||||||
|
print #handle t$
|
||||||
|
close(handle)
|
||||||
|
endif
|
||||||
|
return
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub GetLine$(handle)
|
||||||
|
local tmp$
|
||||||
|
local retString$
|
||||||
|
|
||||||
|
while(tmp$<>chr$(10) and tmp$<>chr$(13) and not eof(handle))
|
||||||
|
tmp$ = chr$(peek(handle))
|
||||||
|
retString$ = retString$ + tmp$
|
||||||
|
wend
|
||||||
|
|
||||||
|
return retString$
|
||||||
|
end sub
|
||||||
|
|
||||||
64
yab-IDE/BuildFactory/README
Normal file
64
yab-IDE/BuildFactory/README
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
-- English -- Englisch -- -- German below -- Deutsch unten --
|
||||||
|
|
||||||
|
Some rules you have to know:
|
||||||
|
|
||||||
|
Names of sub functions are only to be used once. This is for all affected files.
|
||||||
|
If there are subs with the same name, only the first one will be taken over while
|
||||||
|
the second will simply be ignored!
|
||||||
|
|
||||||
|
|
||||||
|
In libraries only subs and export subs are to be entered. Additional code not within
|
||||||
|
a sub or export sub are senseless later on, because libraries are simply added at the
|
||||||
|
end of the main file, so that one big file is generated.
|
||||||
|
So such additional lines are between the subs and are never read.
|
||||||
|
|
||||||
|
All libraries that are imported with import are recognized. Also libraries that were
|
||||||
|
imported from within libraries.
|
||||||
|
|
||||||
|
Libraries have to be placed either in the folder of the main file or in the yab lib
|
||||||
|
folder "/boot/home/config/settings/yab"!
|
||||||
|
|
||||||
|
The BuildFactory is to be used as follows:
|
||||||
|
|
||||||
|
yab BuildFactory Outputfile Inputfile.yab < applicationsig >
|
||||||
|
|
||||||
|
from within the folder of the BuildFactory. The Outputfile is also placed there at the end.
|
||||||
|
The Inputfile has to have its relative or complete path included of course.
|
||||||
|
|
||||||
|
The file which contains the total of the code is also stored in the folder of the BuildFactory,
|
||||||
|
for the case the created binary gives out error messages with line number. Those are of course
|
||||||
|
regarded to this certain file.
|
||||||
|
|
||||||
|
|
||||||
|
-- German -- Deutsch --
|
||||||
|
|
||||||
|
Ein paar Regeln, die man befolgen muss:
|
||||||
|
|
||||||
|
Namen für sub-Funktionen dürfen nur einmal vergeben werden. Das gilt für
|
||||||
|
den Umfang aller Dateien. Sollten zwei subs mit gleichem Namen vorkommen,
|
||||||
|
wird nur das erste eingebaut, während das zweite einfach ignoriert wird!
|
||||||
|
|
||||||
|
In libraries dürfen nur subs und export subs vorkommen. Zusätzliche
|
||||||
|
Funktionen, die nicht in einer Sub-Funktion stehen machen später keinen
|
||||||
|
Sinn, dadurch dass die libs einfach hinten an die Hauptdatei angefügt
|
||||||
|
werden, so dass eine einzige Datei entsteht.
|
||||||
|
Also sind zusätzliche Funktionen zwischen den subs und werden nie gelesen.
|
||||||
|
|
||||||
|
Alle libraries, die mit import importiert werden, werden beachtet. Auch
|
||||||
|
Libraries, die aus Libraries heraus importiert werden.
|
||||||
|
|
||||||
|
Libraries haben entweder in dem Verzeichnis der Hauptdatei oder in dem
|
||||||
|
yab-lib-Ordner "/boot/home/config/settings/yab/" zu liegen!
|
||||||
|
|
||||||
|
Aufgerufen muss die BuildFactory wie folgt:
|
||||||
|
|
||||||
|
yab BuildFactory.yab OutputFile InputFile.yab < applicationsig >
|
||||||
|
|
||||||
|
aus dem Verzeichnis der BuildFactory heraus. Dort landet auch das
|
||||||
|
OutputFile. Zu dem InputFile.yab muss natürlich ein relativer oder
|
||||||
|
vollständiger Pfad angegeben werden.
|
||||||
|
|
||||||
|
Die Datei, in dem der gesamte Source zusammengefasst ist, wird ebenfalls in
|
||||||
|
dem Verzeichnis der BuildFactory abgelegt, für den Fall, dass das erzeugte
|
||||||
|
Binary Fehler mit Zeilenangabe ausgibt. Diese beziehen sich dann natürlich
|
||||||
|
auf jene Datei.
|
||||||
138
yab-IDE/BuildFactory/flex-bison.yab
Normal file
138
yab-IDE/BuildFactory/flex-bison.yab
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
#!yab
|
||||||
|
|
||||||
|
doc This program modifies flex.c and main.c for the Buildfactory
|
||||||
|
doc It accomplishes the seteps documented in HowToMakeABuildFactory.txt.
|
||||||
|
doc The BuildFactory calls this program if flex.c is missing.
|
||||||
|
doc
|
||||||
|
doc by Jim Saxton, 2015, Artistic license
|
||||||
|
|
||||||
|
system("flex -i -I -L -s -t yabasic.flex >flex.c")
|
||||||
|
system("perl -i -n -e 'if (!/^\#include\s+<unistd.h>\s+$$/) {print if $$i;$$i++}' flex.c")
|
||||||
|
system("bison -d -l -t -v --output-file bison.c yabasic.bison ")
|
||||||
|
system ("mv flex.c tmpflex.c")
|
||||||
|
|
||||||
|
open #1, "tmpflex.c", "r"
|
||||||
|
open #2, "outflex.c", "w"
|
||||||
|
|
||||||
|
while (a$<>"#include <stdlib.h>")
|
||||||
|
line input #1 a$
|
||||||
|
print #2 a$
|
||||||
|
wend
|
||||||
|
|
||||||
|
print #2 "#include <zlib.h>"
|
||||||
|
print #2 "#include "+chr$(34)+"program.h"+chr$(34)
|
||||||
|
print #2 "static int isparsed = 0;"
|
||||||
|
|
||||||
|
while (a$<>"#define YY_BUF_SIZE 16384")
|
||||||
|
line input #1 a$
|
||||||
|
if (a$<>"#define YY_BUF_SIZE 16384") print #2 a$
|
||||||
|
wend
|
||||||
|
|
||||||
|
print #2 "#define YY_BUF_SIZE PROGLEN"
|
||||||
|
|
||||||
|
found=0
|
||||||
|
|
||||||
|
while (found=0)
|
||||||
|
line input #1 a$
|
||||||
|
if (!instr(a$,"while ( (result = fread"))then
|
||||||
|
print #2 a$
|
||||||
|
else
|
||||||
|
found=1
|
||||||
|
endif
|
||||||
|
wend
|
||||||
|
|
||||||
|
print #2 " while ( (result = zread(buf, 1, max_size, yyin))==0 && ferror(yyin)) "+chr$(92)
|
||||||
|
found=0
|
||||||
|
|
||||||
|
while (found=0)
|
||||||
|
line input #1 a$
|
||||||
|
if (!instr(a$,"int ret_val;")) then
|
||||||
|
print #2 a$
|
||||||
|
else
|
||||||
|
found=1
|
||||||
|
endif
|
||||||
|
wend
|
||||||
|
|
||||||
|
print #2 a$
|
||||||
|
print #2 " if(isparsed) return EOB_ACT_END_OF_FILE;"
|
||||||
|
|
||||||
|
while (! eof(#1))
|
||||||
|
line input #1 a$
|
||||||
|
print #2 a$
|
||||||
|
wend
|
||||||
|
|
||||||
|
print #2 "int zread(char* dest, size_t memb_size, size_t num_memb, FILE *file)"
|
||||||
|
print #2 "{"
|
||||||
|
print #2 " long destlen = PROGLEN;"
|
||||||
|
print #2 " if(isparsed==1)"
|
||||||
|
print #2 " return 0;"
|
||||||
|
print #2 " isparsed = 1;"
|
||||||
|
print #2 " uncompress(dest,&destlen,myProg,sizeof(myProg));"
|
||||||
|
print #2 " return destlen;"
|
||||||
|
print #2 "}"
|
||||||
|
|
||||||
|
system("mv outflex.c flex.c")
|
||||||
|
system("rm tmpflex.c")
|
||||||
|
|
||||||
|
close #1
|
||||||
|
close #2
|
||||||
|
|
||||||
|
// fix main.c
|
||||||
|
|
||||||
|
system ("mv main.c tmpmain.c")
|
||||||
|
|
||||||
|
open #1, "tmpmain.c", "r"
|
||||||
|
open #2, "outmain.c", "w"
|
||||||
|
|
||||||
|
found=0
|
||||||
|
|
||||||
|
while (found = 0)
|
||||||
|
line input #1 a$
|
||||||
|
if (not instr(a$, "int isbound(void)")) then
|
||||||
|
print #2 a$
|
||||||
|
else
|
||||||
|
found=1
|
||||||
|
print #2 a$
|
||||||
|
end if
|
||||||
|
wend
|
||||||
|
|
||||||
|
print #2 "{"
|
||||||
|
print #2 " FILE *interpreter;"
|
||||||
|
print #2 " if (!interpreter_path || !interpreter_path[0]) {"
|
||||||
|
print #2 " error(FATAL,"+chr$(34)+"interpreter_path is not set !"+chr$(34)+");"
|
||||||
|
print #2 " return 0;"
|
||||||
|
print #2 " }"
|
||||||
|
print #2 " if (!(interpreter=fopen(interpreter_path,"+chr$(34)+"r"+chr$(34)+"))) {"
|
||||||
|
print #2 " sprintf(string,"+chr$(34)+"Couldn't open '%s' to check, if it is bound: %s"+chr$(34)+",interpreter_path,my_strerror(errno));"
|
||||||
|
print #2 " error(WARNING,string);"
|
||||||
|
print #2 " return 0;"
|
||||||
|
print #2 " }"
|
||||||
|
print #2 " return 1;"
|
||||||
|
print #2 "}"
|
||||||
|
print #2 ""
|
||||||
|
print #2 ""
|
||||||
|
|
||||||
|
found = 0
|
||||||
|
|
||||||
|
while (found = 0)
|
||||||
|
line input #1 a$
|
||||||
|
if (not instr(a$, "static int mybind(char *bound)")) then
|
||||||
|
found = 0
|
||||||
|
else
|
||||||
|
found = 1
|
||||||
|
print #2 a$
|
||||||
|
end if
|
||||||
|
wend
|
||||||
|
|
||||||
|
while (not eof(1))
|
||||||
|
line input #1 a$
|
||||||
|
print #2 a$
|
||||||
|
wend
|
||||||
|
|
||||||
|
close #1
|
||||||
|
close #2
|
||||||
|
system("mv outmain.c main.c")
|
||||||
|
system("rm tmpmain.c")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
38
yab-IDE/BuildFactory/parts/YAB-IDE.bf.rdef
Normal file
38
yab-IDE/BuildFactory/parts/YAB-IDE.bf.rdef
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
resource vector_icon {
|
||||||
|
$"6E6369660E0500020006023C43C6B9E5E23A85A83CEE414268F44A445900C6D7"
|
||||||
|
$"F5FF6B94DD03EC66660200060238C5F1BB105D3DFDC23B9CD045487847B50700"
|
||||||
|
$"FFFFFFFFC1CCFF020006023B3049396B0ABA90833C646E4A101543299500FFFF"
|
||||||
|
$"FFFFEBEFFF020006023C71E33A0C78BA15E43C7D2149055549455700E3EDFFFF"
|
||||||
|
$"9EC2FF03FFACAC0200060239D53438FFCBBBC1973C666F4ADC3246DC6C00C1CC"
|
||||||
|
$"FFFFFFFFFF03003CB0020006023C0AE63B3927BC611E3D03FF4C25624A1A9600"
|
||||||
|
$"A3043CFFFF90AF03C93B3B030D296402000602BD498B3E1159BF219BBE7D2F4C"
|
||||||
|
$"1B8F4A331300BD0F0FFFE98484040174100A08325E385E40564E5E545E605058"
|
||||||
|
$"4C3E510A062E2C2E3E3E454A3C4A2A3A250A042E2C2E3E3E453E320A042E2C3E"
|
||||||
|
$"324A2A3A250A043E323E454A3C4A2A0A0338423C4D3C440A0622422254325C3E"
|
||||||
|
$"513E402E3A0A0422422254325C32490A04224232493E402E3A0A043249325C3E"
|
||||||
|
$"513E400A063E423E544E5C5A505A3F4A390A04C222C20F4E495A3F523C0A043E"
|
||||||
|
$"42C222C20F523C4A390A054151C08BC8834E5C4E49C22AC2130A053E423E54C0"
|
||||||
|
$"8BC8834151C22AC2130A044E494E5C5A505A3F110A0D0100000A0001061815FF"
|
||||||
|
$"01178400040A00010618001501178600040A010107000A080109000A0B010520"
|
||||||
|
$"20210A050108000A00010A1001178400040A02010D000A0A010E000A0902040F"
|
||||||
|
$"000A06010B000A0C010C000A0001011001178400040A030102000A040103000A"
|
||||||
|
$"07010400"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
resource app_signature "application/x-vnd.yab-IDE";
|
||||||
|
|
||||||
|
resource app_version {
|
||||||
|
major = 2,
|
||||||
|
middle = 2,
|
||||||
|
minor = 4,
|
||||||
|
|
||||||
|
variety = B_APPV_FINAL,
|
||||||
|
internal = 1,
|
||||||
|
|
||||||
|
short_info = "yab IDE",
|
||||||
|
long_info = "An integrated development environment for yab."
|
||||||
|
};
|
||||||
|
|
||||||
|
resource app_flags 1;
|
||||||
38
yab-IDE/BuildFactory/parts/YAB.bf.rdef
Normal file
38
yab-IDE/BuildFactory/parts/YAB.bf.rdef
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
resource vector_icon {
|
||||||
|
$"6E6369660E0500020006023C43C6B9E5E23A85A83CEE414268F44A445900C6D7"
|
||||||
|
$"F5FF6B94DD03EC66660200060238C5F1BB105D3DFDC23B9CD045487847B50700"
|
||||||
|
$"FFFFFFFFC1CCFF020006023B3049396B0ABA90833C646E4A101543299500FFFF"
|
||||||
|
$"FFFFEBEFFF020006023C71E33A0C78BA15E43C7D2149055549455700E3EDFFFF"
|
||||||
|
$"9EC2FF03FFACAC0200060239D53438FFCBBBC1973C666F4ADC3246DC6C00C1CC"
|
||||||
|
$"FFFFFFFFFF03003CB0020006023C0AE63B3927BC611E3D03FF4C25624A1A9600"
|
||||||
|
$"A3043CFFFF90AF03C93B3B030D296402000602BD498B3E1159BF219BBE7D2F4C"
|
||||||
|
$"1B8F4A331300BD0F0FFFE98484040174100A08325E385E40564E5E545E605058"
|
||||||
|
$"4C3E510A062E2C2E3E3E454A3C4A2A3A250A042E2C2E3E3E453E320A042E2C3E"
|
||||||
|
$"324A2A3A250A043E323E454A3C4A2A0A0338423C4D3C440A0622422254325C3E"
|
||||||
|
$"513E402E3A0A0422422254325C32490A04224232493E402E3A0A043249325C3E"
|
||||||
|
$"513E400A063E423E544E5C5A505A3F4A390A04C222C20F4E495A3F523C0A043E"
|
||||||
|
$"42C222C20F523C4A390A054151C08BC8834E5C4E49C22AC2130A053E423E54C0"
|
||||||
|
$"8BC8834151C22AC2130A044E494E5C5A505A3F110A0D0100000A0001061815FF"
|
||||||
|
$"01178400040A00010618001501178600040A010107000A080109000A0B010520"
|
||||||
|
$"20210A050108000A00010A1001178400040A02010D000A0A010E000A0902040F"
|
||||||
|
$"000A06010B000A0C010C000A0001011001178400040A030102000A040103000A"
|
||||||
|
$"07010400"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
resource app_signature "application/x-vnd.yab-app";
|
||||||
|
|
||||||
|
resource app_version {
|
||||||
|
major = 1,
|
||||||
|
middle = 7,
|
||||||
|
minor = 4,
|
||||||
|
|
||||||
|
variety = B_APPV_FINAL,
|
||||||
|
internal = 1,
|
||||||
|
|
||||||
|
short_info = "Yab BASIC programming language",
|
||||||
|
long_info = "Yab allows fast prototyping with simple and clean code. yab contains a large number of BeAPI specific commands for GUI creation and much, much more."
|
||||||
|
};
|
||||||
|
|
||||||
|
resource app_flags 1;
|
||||||
3
yab-IDE/BuildFactory/parts/YabMain.cpp.appsig
Normal file
3
yab-IDE/BuildFactory/parts/YabMain.cpp.appsig
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
BString tmp("application/x-vnd.yab-app");
|
||||||
|
|
||||||
43
yab-IDE/BuildFactory/parts/YabMain.cpp.end
Normal file
43
yab-IDE/BuildFactory/parts/YabMain.cpp.end
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
for(int i=1; i<argc; i++)
|
||||||
|
{
|
||||||
|
if(argv[i][0]!='-')
|
||||||
|
{
|
||||||
|
BFile file(argv[i], B_READ_ONLY);
|
||||||
|
if(file.InitCheck()==B_OK)
|
||||||
|
{
|
||||||
|
char readData[1024];
|
||||||
|
int pos;
|
||||||
|
file.Read(readData,1024);
|
||||||
|
BString tmpString(readData);
|
||||||
|
pos = tmpString.IFindFirst("MIMETYPE");
|
||||||
|
if(pos!=B_ERROR)
|
||||||
|
{
|
||||||
|
int quote1, quote2;
|
||||||
|
quote1 = tmpString.FindFirst("\"",pos);
|
||||||
|
if(quote1!=B_ERROR)
|
||||||
|
{
|
||||||
|
quote2 = tmpString.FindFirst("\"",quote1+1);
|
||||||
|
if(quote2!=B_ERROR)
|
||||||
|
{
|
||||||
|
tmp.SetTo("");
|
||||||
|
tmpString.CopyInto(tmp,quote1+1,quote2-quote1-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strcpy(t,tmp.String());
|
||||||
|
return (const char*)t;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
YabInterface *yabInterface = new YabInterface(argc, argv, readSignature(argc, argv));
|
||||||
|
yabInterface->Run();
|
||||||
|
ret = yabInterface->GetErrorCode();
|
||||||
|
delete yabInterface;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
8
yab-IDE/BuildFactory/parts/YabMain.cpp.start
Normal file
8
yab-IDE/BuildFactory/parts/YabMain.cpp.start
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#include <File.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "YabInterface.h"
|
||||||
|
|
||||||
|
char t[1024];
|
||||||
|
const char* readSignature(int argc, char** argv)
|
||||||
|
{
|
||||||
50
yab-IDE/BuildFactory/srcfiles
Normal file
50
yab-IDE/BuildFactory/srcfiles
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
CalendarControl.cpp
|
||||||
|
CalendarControl.h
|
||||||
|
config.h
|
||||||
|
ControlLook.cpp
|
||||||
|
DateTextView.cpp
|
||||||
|
function.c
|
||||||
|
global.h
|
||||||
|
graphic.c
|
||||||
|
io.c
|
||||||
|
main.c
|
||||||
|
MonthView.cpp
|
||||||
|
MonthWindow.cpp
|
||||||
|
MouseSenseStringView.cpp
|
||||||
|
README.Compile
|
||||||
|
RdefApply
|
||||||
|
Spinner.cpp
|
||||||
|
Spinner.h
|
||||||
|
SplitPane.cpp
|
||||||
|
SplitPane.h
|
||||||
|
symbol.c
|
||||||
|
URLView.cpp
|
||||||
|
URLView.h
|
||||||
|
yabasic.bison
|
||||||
|
yabasic.flex
|
||||||
|
yabasic.h
|
||||||
|
YabBitmapView.cpp
|
||||||
|
YabBitmapView.h
|
||||||
|
YabControlLook.cpp
|
||||||
|
YabControlLook.h
|
||||||
|
YabFilePanel.cpp
|
||||||
|
YabFilePanel.h
|
||||||
|
YabFilePanelLooper.cpp
|
||||||
|
YabFilePanelLooper.h
|
||||||
|
YabInterface.cpp
|
||||||
|
YabInterface.h
|
||||||
|
YabList.cpp
|
||||||
|
YabList.h
|
||||||
|
YabMain.cpp
|
||||||
|
YabMenu.h
|
||||||
|
YabStackView.cpp
|
||||||
|
YabStackView.h
|
||||||
|
YabTabView.cpp
|
||||||
|
YabTabView.h
|
||||||
|
YabText.cpp
|
||||||
|
YabText.h
|
||||||
|
YabToolTip.cpp
|
||||||
|
YabView.cpp
|
||||||
|
YabView.h
|
||||||
|
YabWindow.cpp
|
||||||
|
YabWindow.h
|
||||||
50
yab-IDE/BuildFactory/yab-compress.c
Normal file
50
yab-IDE/BuildFactory/yab-compress.c
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
|
unsigned long file_size(char *filename)
|
||||||
|
{
|
||||||
|
unsigned long size;
|
||||||
|
FILE *pFile = fopen(filename, "rb");
|
||||||
|
fseek (pFile, 0, SEEK_END);
|
||||||
|
size = ftell(pFile);
|
||||||
|
fclose (pFile);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
unsigned long filesize;
|
||||||
|
char *buffer;
|
||||||
|
FILE *fi, *fo;
|
||||||
|
char *dest;
|
||||||
|
unsigned long destlen;
|
||||||
|
unsigned long i;
|
||||||
|
|
||||||
|
if(argc != 2) {
|
||||||
|
printf("Usage: yab-compress <file.yab>\n\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
filesize = file_size(argv[1]);
|
||||||
|
buffer = (char*)malloc(filesize);
|
||||||
|
dest = (char*)malloc(filesize);
|
||||||
|
|
||||||
|
// read source file into buffer
|
||||||
|
fi = fopen(argv[1], "r");
|
||||||
|
fread(buffer, sizeof(char), filesize, fi);
|
||||||
|
fclose(fi);
|
||||||
|
|
||||||
|
// compress buffer
|
||||||
|
compress(dest, &destlen, buffer, filesize);
|
||||||
|
|
||||||
|
// write compressed buffer to output
|
||||||
|
fo = fopen("program.h", "w");
|
||||||
|
fprintf(fo, "const char myProg[] = {");
|
||||||
|
for(i=0; i < destlen; i++)
|
||||||
|
fprintf(fo, "%i,", dest[i]);
|
||||||
|
fprintf(fo, "' ' };\n");
|
||||||
|
fclose(fo);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
215
yab-IDE/Language/de.catalog
Normal file
215
yab-IDE/Language/de.catalog
Normal file
@@ -0,0 +1,215 @@
|
|||||||
|
1 de x-vnd.yab-IDE 2612525067
|
||||||
|
File Datei
|
||||||
|
New... Neu...
|
||||||
|
Open... Öffnen...
|
||||||
|
Close Schließen
|
||||||
|
Save Speichern
|
||||||
|
Save As... Speichern als...
|
||||||
|
Save As Template... Als Vorlage speichern...
|
||||||
|
Page Setup... Seiteneinrichtung...
|
||||||
|
Print... Drucken...
|
||||||
|
Quit Beenden
|
||||||
|
Edit Bearbeiten
|
||||||
|
Undo Rückgängig
|
||||||
|
Cut Ausschneiden
|
||||||
|
Copy Kopieren
|
||||||
|
Paste Einfügen
|
||||||
|
Select All Alles auswählen
|
||||||
|
Find Suchen
|
||||||
|
Find Again Weitersuchen
|
||||||
|
Find and Replace Suchen und ersetzen
|
||||||
|
Program Programm
|
||||||
|
Run Ausführen
|
||||||
|
Run in Terminal Im Terminal ausführen
|
||||||
|
Set Run Parameters... Parameter setzen...
|
||||||
|
Build Factory... Build-Factory...
|
||||||
|
Tools Werkzeuge
|
||||||
|
Pattern Editor... Muster erstellen...
|
||||||
|
Color Selection... Farbe auswählen...
|
||||||
|
ASCII Table... ASCII Tabelle...
|
||||||
|
View Ansicht
|
||||||
|
Next File Nächste Datei
|
||||||
|
Previous File Vorherige Datei
|
||||||
|
Full Screen Vollbild
|
||||||
|
Maximize Editor Editor maximieren
|
||||||
|
Auto Indent Automatisch einrücken
|
||||||
|
Auto Completion Automatisch ergänzen
|
||||||
|
Refresh Colors Farben wiederherstellen
|
||||||
|
Reformat Sourcecode Quelltext formatieren
|
||||||
|
Undo Reformat Formatierung zurücksetzen
|
||||||
|
Options... Einstellungen...
|
||||||
|
Introduction to the IDE... Einführung zur IDE...
|
||||||
|
yab Help... yab Hilfe...
|
||||||
|
Yabasic Manual... Yabasic Handbuch...
|
||||||
|
Online Resources Webseiten online
|
||||||
|
yab Homepage... yab Homepage...
|
||||||
|
yab Forums... yab Foren...
|
||||||
|
Yabasic Homepage... Yabasic Homepage...
|
||||||
|
Team Maui... Team Maui...
|
||||||
|
About... Über yab-IDE...
|
||||||
|
New Neu
|
||||||
|
Open Öffnen
|
||||||
|
Build Factory Build Factory
|
||||||
|
Pattern Editor Muster erstellen
|
||||||
|
Options Einstellungen
|
||||||
|
yab Help yab Hilfe
|
||||||
|
Go to Line: Gehe zu Zeile:
|
||||||
|
Files Dateien
|
||||||
|
Help Hilfe
|
||||||
|
Filename Dateiname
|
||||||
|
Command Befehl
|
||||||
|
yab Output yab Ausgabe
|
||||||
|
Immediate Sofort ausführen
|
||||||
|
Execute Ausführen
|
||||||
|
Find: Suche:
|
||||||
|
Replace: Ersetze:
|
||||||
|
Case Sensitive Groß-/Kleinschreibung beachten
|
||||||
|
Replace All Alles ersetzen
|
||||||
|
Suspecting user input, therefore starting in a terminal. Eine Benutzereingabe wird erwartet, Programm startet deshalb im Terminal.
|
||||||
|
Ok Ok
|
||||||
|
File: Datei:
|
||||||
|
(not saved) (nicht gespeichert)
|
||||||
|
Line Zeile
|
||||||
|
Please wait... Bitte warten...
|
||||||
|
Loading Program Lade Programm
|
||||||
|
Running Ausführung
|
||||||
|
Running Program Ausführung
|
||||||
|
Error! Program could not be killed. Fehler! Programm konnte nicht beendet werden.
|
||||||
|
Oops Oops
|
||||||
|
Close terminal to break program Terminal schließen um Programm zu beenden
|
||||||
|
yab-IDE Set Run Parameters yab-IDE Parameter setzen
|
||||||
|
Set Run Parameters Parameter setzen
|
||||||
|
yab Parameters: yab Parameter:
|
||||||
|
Program Parameters: Programm Parameter:
|
||||||
|
yab-IDE New Program yab-IDE Neues Programm
|
||||||
|
New yab Program Neues yab Programm
|
||||||
|
Please select one of the available templates for your program: Bitte eine der verfügbaren Vorlagen auswählen:
|
||||||
|
Name: Name:
|
||||||
|
Browse... Wählen...
|
||||||
|
Advanced Options Weitere Optionen
|
||||||
|
Remove Template Vorlage löschen
|
||||||
|
Project Directory Projektverzeichnis
|
||||||
|
Could not open template: Vorlage konnte nicht geladen werden:
|
||||||
|
Opening an empty file instead. Öffne eine leere Datei stattdessen.
|
||||||
|
Really delete template Vorlage wirklich löschen
|
||||||
|
Yes Ja
|
||||||
|
Cancel Abbrechen
|
||||||
|
This standard template can not be deleted! Diese Standardvorlage kann nicht gelöscht werden!
|
||||||
|
Template successfully removed. Vorlage erfolgreich gelöscht.
|
||||||
|
Error while deleting template! Fehler beim Löschen der Vorlage!
|
||||||
|
Empty Leere Datei
|
||||||
|
Basic Template Einfache Vorlage
|
||||||
|
Editor Template Vorlage für einen Editor
|
||||||
|
Command Line Template Kommandozeilenvorlage
|
||||||
|
|
||||||
|
Create an empty file. Erstelle eine leere Datei.
|
||||||
|
Create a new program with a bare Erstelle ein neues Programm
|
||||||
|
window. mit einem leeren Fenster.
|
||||||
|
Create a new program with menus Erstelle ein neues Programm mit
|
||||||
|
and an editor. Menüs und einem Editor.
|
||||||
|
Erstelle ein neues
|
||||||
|
Create a new command line program. Kommandozeilenprogramm.
|
||||||
|
yab-IDE Save As Template yab-IDE Als Vorlage speichern
|
||||||
|
Save As Template Als Vorlage speichern
|
||||||
|
Save your code as a template for other programs: Quellcode als Vorlage speichern
|
||||||
|
Template Name Vorlagenname
|
||||||
|
Description (not more than 30 characters per line) Beschreibung (nicht mehr als 30 Zeichen pro Zeile)
|
||||||
|
Drop image here Bilddatei hierher ziehen
|
||||||
|
Could not load image! Bilddatei konnte nicht geladen werden
|
||||||
|
Error while saving template! Fehler beim Speichern der Vorlage!
|
||||||
|
File could not be saved! Datei konnte nicht gespeichert werden!
|
||||||
|
Sorry, you can not open more than Achtung, es können nicht mehr als
|
||||||
|
files at once!\n\nPlease close one or more other files first. Dateien auf einmal geöffnet werden!\n\nBitte zunächst eine oder mehrere andere Dateien schließen.
|
||||||
|
File is already open. Datei ist bereits geöffnet.
|
||||||
|
Error while loading file:\n\n Fehler beim Laden der Datei:\n\n
|
||||||
|
File \" Datei \"
|
||||||
|
\" not saved!\n\nSave the file now? \" ist nicht gespeichert\n\nDatei jetzt speichern?
|
||||||
|
Error while printing! Fehler beim Drucken!
|
||||||
|
Some files are not saved!\n\nDo you really want to quit? Es gibt nicht gesicherte Dateien!\n\nSoll yab-IDE dennoch beendet werden?
|
||||||
|
Program is not saved.\n\nSave it now? Programm ist nicht gesichert.\n\nJetzt speichern?
|
||||||
|
Save Always Immer speichern
|
||||||
|
Save Now Jetzt speichern
|
||||||
|
Reformating did not close all open loops and conditions.\nReformating currently does not support loops and conditions opened and closed by a colon (:).\nE.g. while(loop):wend\n\nYou can undo the reformating before doing any further changes. Das Formatieren hat nicht alle Schleifen und Konditionen schließen können.\nDas Formatieren unterstützt momentan keine Verschachtelungen mit Doppelpunkten (:).\nZ.B.. while(loop):wend\n\nDas Formatieren kann rückgängig gemacht werden, solange der Text nicht geändert wird.
|
||||||
|
Do not show this warning again Diese Warnung nicht mehr zeigen
|
||||||
|
Changes made since reformating will be lost! Änderungen seit dem letzten Formatieren gehen verloren!
|
||||||
|
The operation \"Replace All\" can not be reverted!\n\nDo you want to continue? \"Alles ersetzen\" kann nicht rückgängig gemacht werden\n\nDennoch fortfahren?
|
||||||
|
yab-IDE Build Factory yab-IDE Build-Factory
|
||||||
|
Target file name: Zieldatei:
|
||||||
|
Use the Haiku tab view instead of the ZETA native tab view Verwende Haiku-Tabviews anstatt ZETA-eigenen Tabviews
|
||||||
|
Create Binary Kompiliere Zieldatei
|
||||||
|
The compiler GCC was not found!\n\nPlease install the development tools from your ZETA CD. Der GCC-Compiler wurde nicht gefunden!\n\nBitte die Entwicklungsprogramme von der ZETA CD nachinstallieren.
|
||||||
|
The compiler GCC was not found!\n\nPlease install the development tools. Der GCC-Compiler wurde nicht gefunden!\n\nBitte die Entwicklungsprogramme nachinstallieren.
|
||||||
|
Visit Download Site GCC jetzt herunterladen
|
||||||
|
Warning: Although you are using the BeOS yab, the resulting binary will be ZETA only! Achtung: Obwohl gerade BeOS yab verwendet wird, wird die Zieldatei nur auf ZETA laufen!
|
||||||
|
Build Factory Output\n\n Build-Factory Ausgabe\n\n
|
||||||
|
Please wait, processing... (this may take a while)\n\n Bitte warten... (die Bearbeitung kann einige Zeit dauern)\n\n
|
||||||
|
Build was successful Die Erstellung war erfolgreich
|
||||||
|
Build failed! Die Erstellung ist fehlgeschlagen!
|
||||||
|
yab-IDE Pattern Editor yab-IDE Muster erstellen
|
||||||
|
Insert Pattern Muster einfügen
|
||||||
|
yab-IDE Color Selection yab-IDE Farbauswahl
|
||||||
|
Color Selection Farbauswahl
|
||||||
|
Default Colors: Standardfarben:
|
||||||
|
Black Schwarz
|
||||||
|
Darken 4 Dunkler 4
|
||||||
|
Darken 3 Dunkler 3
|
||||||
|
Darken 2 Dunkler 2
|
||||||
|
Darken 1 Dunkler 1
|
||||||
|
Default Background Standardhintergrund
|
||||||
|
Lighten 1 Heller 1
|
||||||
|
Lighten 2 Heller 2
|
||||||
|
White Weiß
|
||||||
|
Red Rot
|
||||||
|
Brown Braun
|
||||||
|
Yellow Gelb
|
||||||
|
Green Grün
|
||||||
|
Cyan Türkis
|
||||||
|
Light Blue Hellblau
|
||||||
|
Blue Blau
|
||||||
|
Magenta Violett
|
||||||
|
Light Magenta Hellviolett
|
||||||
|
Insert Color Farbe einfügen
|
||||||
|
yab-IDE ASCII Table yab-IDE ASCII Tabelle
|
||||||
|
ASCII Table ASCII Tabelle
|
||||||
|
yab-IDE Options yab-IDE Einstellungen
|
||||||
|
Editor Editor
|
||||||
|
General Allgemein
|
||||||
|
Environment Arbeitsumgebung
|
||||||
|
Directories Verzeichnisse
|
||||||
|
Language Sprachen
|
||||||
|
Number of spaces per tab: Anzahl Leerzeichen pro Tab:
|
||||||
|
Ask about saving before running a program Frage nach Speicherung vor der Programmausführung
|
||||||
|
Show warning when reformating sourcecode did not close all loops and conditions Zeige Warnung wenn die Formatierung nicht alle Schleifen und Konditionen schließen konnte
|
||||||
|
Show warning before undo reformating Zeige Warnung vor dem Zurücksetzem der Formatierung
|
||||||
|
Show warning before applying Replace All Zeige Warnung vor der Anwendung von Alles ersetzen
|
||||||
|
Select font for editor: Schriftart für den Editor wählen:
|
||||||
|
Font Family Schriftart
|
||||||
|
Font Style Schriftstil
|
||||||
|
Font Size Schriftgröße
|
||||||
|
My hovercraft is full of eels. Mein Luftkissenfahrzeug ist voller Aale.
|
||||||
|
Factory Settings Standardeinstellungen
|
||||||
|
Enable auto completion Automatisches Ergänzen
|
||||||
|
Number of characters for starting completion: Anzahl Startzeichen für die Ergänzung:
|
||||||
|
New Entry: Neuer Eintrag:
|
||||||
|
Add New Entry Neuen Eintrag hinzufügen
|
||||||
|
Remove Entry Eintrag löschen
|
||||||
|
Note: You have to restart the IDE to update the Achtung: Die IDE muß neugestartet werden
|
||||||
|
autocompletion when removing entries. damit gelöschte Einträge nicht mehr erscheinen.
|
||||||
|
Note: Only change the directories, when you know what you are doing! Achtung: Verzeichnisse nur ändern, wenn man weiß was man tut!
|
||||||
|
Default yab Binary Standard yab-Interpreter
|
||||||
|
Default yab Directory Standard yab-Verzeichnis
|
||||||
|
Use the automatic localization Die automatische Lokalisierung verwenden
|
||||||
|
Supported Languages Unterstützte Sprachen
|
||||||
|
Entry already exists. Eintrag existiert bereits
|
||||||
|
Restart yab-IDE to change localization yab-IDE neustarten um die Lokalisierung zu ändern
|
||||||
|
Could not find yab 1.0 directory!\n\nPlease do a proper installation. Das Verzeichnis von yab 1.0 konnte nicht gefunden werden!\n\nBitte yab sauber installieren.
|
||||||
|
Could not find yab binary!\n\nPlease do a proper installation. Der Interpreter von yab 1.0 konnte nicht gefunden werden!\n\nBitte yab sauber installieren.
|
||||||
|
New yab directory set to:\n\n Neues yab-Verzeichnis gesetzt zu:\n\n
|
||||||
|
\n\nRestart the IDE using the new directory. \n\nyab-IDE neustarten um die Lokalisierung zu ändern.
|
||||||
|
Invalid directory:\n\n Ungültiges Verzeichnis:\n\n
|
||||||
|
yab binary set to:\n\n yab-Interpreter gesetzt zu:\n\n
|
||||||
|
Invalid file:\n\n Ungültige Datei:\n\n
|
||||||
|
Export As HTML... Exportieren als HTML...
|
||||||
|
Open Project Folder... Öffne Projektordner...
|
||||||
|
Help Hilfe
|
||||||
|
Short Command Help... Kurzanleitung...
|
||||||
214
yab-IDE/Language/en.catalog
Normal file
214
yab-IDE/Language/en.catalog
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
1 english x-vnd.yab-IDE 1378724574
|
||||||
|
File File
|
||||||
|
New... New...
|
||||||
|
Open... Open...
|
||||||
|
Close Close
|
||||||
|
Save Save
|
||||||
|
Save As... Save As...
|
||||||
|
Save As Template... Save As Template...
|
||||||
|
Page Setup... Page Setup...
|
||||||
|
Print... Print...
|
||||||
|
Quit Quit
|
||||||
|
Edit Edit
|
||||||
|
Undo Undo
|
||||||
|
Cut Cut
|
||||||
|
Copy Copy
|
||||||
|
Paste Paste
|
||||||
|
Select All Select All
|
||||||
|
Find Find
|
||||||
|
Find Again Find Again
|
||||||
|
Find and Replace Find and Replace
|
||||||
|
Program Program
|
||||||
|
Run Run
|
||||||
|
Run in Terminal Run in Terminal
|
||||||
|
Set Run Parameters... Set Run Parameters...
|
||||||
|
Build Factory... Build Factory...
|
||||||
|
Tools Tools
|
||||||
|
Pattern Editor... Pattern Editor...
|
||||||
|
Color Selection... Color Selection...
|
||||||
|
ASCII Table... ASCII Table...
|
||||||
|
View View
|
||||||
|
Next File Next File
|
||||||
|
Previous File Previous File
|
||||||
|
Full Screen Full Screen
|
||||||
|
Maximize Editor Maximize Editor
|
||||||
|
Auto Indent Auto Indent
|
||||||
|
Auto Completion Auto Completion
|
||||||
|
Refresh Colors Refresh Colors
|
||||||
|
Reformat Sourcecode Reformat Sourcecode
|
||||||
|
Undo Reformat Undo Reformat
|
||||||
|
Options... Options...
|
||||||
|
Introduction to the IDE... Introduction to the IDE...
|
||||||
|
yab Help... yab Help...
|
||||||
|
Yabasic Manual... Yabasic Manual...
|
||||||
|
Online Resources Online Resources
|
||||||
|
yab Homepage... yab Homepage...
|
||||||
|
yab Forums... yab Forums...
|
||||||
|
Yabasic Homepage... Yabasic Homepage...
|
||||||
|
Team Maui... Team Maui...
|
||||||
|
About... About...
|
||||||
|
New New
|
||||||
|
Open Open
|
||||||
|
Build Factory Build Factory
|
||||||
|
Pattern Editor Pattern Editor
|
||||||
|
Options Options
|
||||||
|
yab Help yab Help
|
||||||
|
Go to Line: Go to Line:
|
||||||
|
Go to Line Go to Line
|
||||||
|
Files Files
|
||||||
|
Help Help
|
||||||
|
Filename Filename
|
||||||
|
Command Command
|
||||||
|
yab Output yab Output
|
||||||
|
Immediate Immediate
|
||||||
|
Execute Execute
|
||||||
|
Find: Find:
|
||||||
|
Replace: Replace:
|
||||||
|
Case Sensitive Case Sensitive
|
||||||
|
Replace All Replace All
|
||||||
|
Suspecting user input, therefore starting in a terminal. Suspecting user input, therefore starting in a terminal.
|
||||||
|
Ok Ok
|
||||||
|
File: File:
|
||||||
|
(not saved) (not saved)
|
||||||
|
Line Line
|
||||||
|
Please wait... Please wait...
|
||||||
|
Loading Program Loading Program
|
||||||
|
Running Running
|
||||||
|
Running Program Running Program
|
||||||
|
Error! Program could not be killed. Error! Program could not be killed.
|
||||||
|
Oops Oops
|
||||||
|
Close terminal to break program Close terminal to break program
|
||||||
|
yab-IDE Set Run Parameters yab-IDE Set Run Parameters
|
||||||
|
Set Run Parameters Set Run Parameters
|
||||||
|
yab Parameters: yab Parameters:
|
||||||
|
Program Parameters: Program Parameters:
|
||||||
|
yab-IDE New Program yab-IDE New Program
|
||||||
|
New yab Program New yab Program
|
||||||
|
Please select one of the available templates for your program: Please select one of the available templates for your program:
|
||||||
|
Name: Name:
|
||||||
|
Browse... Browse...
|
||||||
|
Advanced Options Advanced Options
|
||||||
|
Remove Template Remove Template
|
||||||
|
Project Directory Project Directory
|
||||||
|
Could not open template: Could not open template:
|
||||||
|
Opening an empty file instead. Opening an empty file instead.
|
||||||
|
Really delete template Really delete template
|
||||||
|
Yes Yes
|
||||||
|
Cancel Cancel
|
||||||
|
This standard template can not be deleted! This standard template can not be deleted!
|
||||||
|
Template successfully removed. Template successfully removed.
|
||||||
|
Error while deleting template! Error while deleting template!
|
||||||
|
Empty Empty
|
||||||
|
Basic Template Basic Template
|
||||||
|
Editor Template Editor Template
|
||||||
|
Command Line Template Command Line Template
|
||||||
|
|
||||||
|
Create an empty file. Create an empty file.
|
||||||
|
Create a new program with a bare Create a new program with a bare
|
||||||
|
window. window.
|
||||||
|
Create a new program with menus Create a new program with menus
|
||||||
|
and an editor. and an editor.
|
||||||
|
|
||||||
|
Create a new command line program. Create a new command line program.
|
||||||
|
yab-IDE Save As Template yab-IDE Save As Template
|
||||||
|
Save As Template Save As Template
|
||||||
|
Save your code as a template for other programs: Save your code as a template for other programs:
|
||||||
|
Template Name Template Name
|
||||||
|
Description (not more than 30 characters per line) Description (not more than 30 characters per line)
|
||||||
|
Drop image here Drop image here
|
||||||
|
Could not load image! Could not load image!
|
||||||
|
Error while saving template! Error while saving template!
|
||||||
|
File could not be saved! File could not be saved!
|
||||||
|
Sorry, you can not open more than Sorry, you can not open more than
|
||||||
|
files at once!\n\nPlease close one or more other files first. files at once!\n\nPlease close one or more other files first.
|
||||||
|
File is already open. File is already open.
|
||||||
|
Error while loading file:\n\n Error while loading file:\n\n
|
||||||
|
File \" File \"
|
||||||
|
\" not saved!\n\nSave the file now? \" not saved!\n\nSave the file now?
|
||||||
|
Error while printing! Error while printing!
|
||||||
|
Some files are not saved!\n\nDo you really want to quit? Some files are not saved!\n\nDo you really want to quit?
|
||||||
|
Program is not saved.\n\nSave it now? Program is not saved.\n\nSave it now?
|
||||||
|
Save Always Save Always
|
||||||
|
Save Now Save Now
|
||||||
|
Reformating did not close all open loops and conditions.\nReformating currently does not support loops and conditions opened and closed by a colon (:).\nE.g. while(loop):wend\n\nYou can undo the reformating before doing any further changes. Reformating did not close all open loops and conditions.\nReformating currently does not support loops and conditions opened and closed by a colon (:).\nE.g. while(loop):wend\n\nYou can undo the reformating before doing any further changes.
|
||||||
|
Do not show this warning again Do not show this warning again
|
||||||
|
Changes made since reformating will be lost! Changes made since reformating will be lost!
|
||||||
|
The operation \"Replace All\" can not be reverted!\n\nDo you want to continue? The operation \"Replace All\" can not be reverted!\n\nDo you want to continue?
|
||||||
|
yab-IDE Build Factory yab-IDE Build Factory
|
||||||
|
Target file name: Target file name:
|
||||||
|
Use the Haiku tab view instead of the ZETA native tab view Use the Haiku tab view instead of the ZETA native tab view
|
||||||
|
Create Binary Create Binary
|
||||||
|
The compiler GCC was not found!\n\nPlease install the development tools from your ZETA CD. The compiler GCC was not found!\n\nPlease install the development tools from your ZETA CD.
|
||||||
|
The compiler GCC was not found!\n\nPlease install the development tools. The compiler GCC was not found!\n\nPlease install the development tools.
|
||||||
|
Visit Download Site Visit Download Site
|
||||||
|
Warning: Although you are using the BeOS yab, the resulting binary will be ZETA only! Warning: Although you are using the BeOS yab, the resulting binary will be ZETA only!
|
||||||
|
Build Factory Output\n\n Build Factory Output\n\n
|
||||||
|
Please wait, processing... (this may take a while)\n\n Please wait, processing... (this may take a while)\n\n
|
||||||
|
Build was successful Build was successful
|
||||||
|
Build failed! Build failed!
|
||||||
|
yab-IDE Pattern Editor yab-IDE Pattern Editor
|
||||||
|
Insert Pattern Insert Pattern
|
||||||
|
yab-IDE Color Selection yab-IDE Color Selection
|
||||||
|
Color Selection Color Selection
|
||||||
|
Default Colors: Default Colors:
|
||||||
|
Black Black
|
||||||
|
Darken 4 Darken 4
|
||||||
|
Darken 3 Darken 3
|
||||||
|
Darken 2 Darken 2
|
||||||
|
Darken 1 Darken 1
|
||||||
|
Default Background Default Background
|
||||||
|
Lighten 1 Lighten 1
|
||||||
|
Lighten 2 Lighten 2
|
||||||
|
White White
|
||||||
|
Red Red
|
||||||
|
Brown Brown
|
||||||
|
Yellow Yellow
|
||||||
|
Green Green
|
||||||
|
Cyan Cyan
|
||||||
|
Light Blue Light Blue
|
||||||
|
Blue Blue
|
||||||
|
Magenta Magenta
|
||||||
|
Light Magenta Light Magenta
|
||||||
|
Insert Color Insert Color
|
||||||
|
yab-IDE ASCII Table yab-IDE ASCII Table
|
||||||
|
ASCII Table ASCII Table
|
||||||
|
yab-IDE Options yab-IDE Options
|
||||||
|
Editor Editor
|
||||||
|
General General
|
||||||
|
Environment Environment
|
||||||
|
Directories Directories
|
||||||
|
Language Language
|
||||||
|
Number of spaces per tab: Number of spaces per tab:
|
||||||
|
Ask about saving before running a program Ask about saving before running a program
|
||||||
|
Show warning when reformating sourcecode did not close all loops and conditions Show warning when reformating sourcecode did not close all loops and conditions
|
||||||
|
Show warning before undo reformating Show warning before undo reformating
|
||||||
|
Show warning before applying Replace All Show warning before applying Replace All
|
||||||
|
Select font for editor: Select font for editor:
|
||||||
|
Font Family Font Family
|
||||||
|
Font Style Font Style
|
||||||
|
Font Size Font Size
|
||||||
|
My hovercraft is full of eels. My hovercraft is full of eels.
|
||||||
|
Factory Settings Factory Settings
|
||||||
|
Enable auto completion Enable auto completion
|
||||||
|
Number of characters for starting completion: Number of characters for starting completion:
|
||||||
|
New Entry: New Entry:
|
||||||
|
Add New Entry Add New Entry
|
||||||
|
Remove Entry Remove Entry
|
||||||
|
Note: You have to restart the IDE to update the Note: You have to restart the IDE to update the
|
||||||
|
autocompletion when removing entries. autocompletion when removing entries.
|
||||||
|
Note: Only change the directories, when you know what you are doing! Note: Only change the directories, when you know what you are doing!
|
||||||
|
Default yab Binary Default yab Binary
|
||||||
|
Default yab Directory Default yab Directory
|
||||||
|
Use the automatic localization Use the automatic localization
|
||||||
|
Supported Languages Supported Languages
|
||||||
|
Entry already exists. Entry already exists.
|
||||||
|
Restart yab-IDE to change localization Restart yab-IDE to change localization
|
||||||
|
Could not find yab 1.0 directory!\n\nPlease do a proper installation. Could not find yab 1.0 directory!\n\nPlease do a proper installation.
|
||||||
|
Could not find yab binary!\n\nPlease do a proper installation. Could not find yab binary!\n\nPlease do a proper installation.
|
||||||
|
New yab directory set to:\n\n New yab directory set to:\n\n
|
||||||
|
\n\nRestart the IDE using the new directory. \n\nRestart the IDE using the new directory.
|
||||||
|
Invalid directory:\n\n Invalid directory:\n\n
|
||||||
|
yab binary set to:\n\n yab binary set to:\n\n
|
||||||
|
Invalid file:\n\n Invalid file:\n\n
|
||||||
|
Export As HTML... Export As HTML...
|
||||||
|
Open Project Folder... Open Project Folder...
|
||||||
214
yab-IDE/Language/nl.catalog
Normal file
214
yab-IDE/Language/nl.catalog
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
1 nl x-vnd.yab-IDE 1378724574
|
||||||
|
File Bestand
|
||||||
|
New... Nieuw...
|
||||||
|
Open... Openen...
|
||||||
|
Close Sluiten
|
||||||
|
Save Opslaan
|
||||||
|
Save As... Opslaan als...
|
||||||
|
Save As Template... Als sjabloon opslaan...
|
||||||
|
Page Setup... Pagina instellingen...
|
||||||
|
Print... Afdrukken...
|
||||||
|
Quit Afsluiten
|
||||||
|
Edit Bewerken
|
||||||
|
Undo Ongedaan maken
|
||||||
|
Cut Knippen
|
||||||
|
Copy Kopiëren
|
||||||
|
Paste Plakken
|
||||||
|
Select All Alles selecteren
|
||||||
|
Find Zoek
|
||||||
|
Find Again Verder zoeken
|
||||||
|
Find and Replace Zoeken en vervangen
|
||||||
|
Program Toepassing
|
||||||
|
Run Uitvoeren
|
||||||
|
Run in Terminal In Terminal uitvoeren
|
||||||
|
Set Run Parameters... Parameter zetten...
|
||||||
|
Build Factory... Build-Factory...
|
||||||
|
Tools Werktuigen
|
||||||
|
Pattern Editor... Patroon aanmaken...
|
||||||
|
Color Selection... Kleur kiezen...
|
||||||
|
ASCII Table... ASCII lijst...
|
||||||
|
View Venster
|
||||||
|
Next File Volgend bestand
|
||||||
|
Previous File Vorig bestand
|
||||||
|
Full Screen Volledig scherm
|
||||||
|
Maximize Editor Editor maximaliseren
|
||||||
|
Auto Indent Automatisch inspringen
|
||||||
|
Auto Completion Automatisch aanvullen
|
||||||
|
Refresh Colors Kleuren verversen
|
||||||
|
Reformat Sourcecode Broncode herformateren
|
||||||
|
Undo Reformat Formatering ongedaan maken
|
||||||
|
Options... Instellingen...
|
||||||
|
Introduction to the IDE... Inleiding tot de IDE...
|
||||||
|
yab Help... yab help...
|
||||||
|
Yabasic Manual... Yabasic handboek...
|
||||||
|
Online Resources Website's online
|
||||||
|
yab Homepage... yab Homepage...
|
||||||
|
yab Forums... yab forums...
|
||||||
|
Yabasic Homepage... Yabasic Homepage...
|
||||||
|
Team Maui... Team Maui...
|
||||||
|
About... Over yab-IDE...
|
||||||
|
New Nieuw
|
||||||
|
Open Openen
|
||||||
|
Build Factory Build Factory
|
||||||
|
Pattern Editor Patroon aanmaken
|
||||||
|
Options Instellingen
|
||||||
|
yab Help yab help
|
||||||
|
Go to Line: Ga naar lijn:
|
||||||
|
Go to Line Ga naar lijn
|
||||||
|
Files Bestanden
|
||||||
|
Help Help
|
||||||
|
Filename Bestandsnaam
|
||||||
|
Command Commando
|
||||||
|
yab Output yab output
|
||||||
|
Immediate Onmiddelijk uitvoeren
|
||||||
|
Execute Uitvoeren
|
||||||
|
Find: Zoek:
|
||||||
|
Replace: Vervang:
|
||||||
|
Case Sensitive Hoofdlettergevoelig
|
||||||
|
Replace All Alles vervangen
|
||||||
|
Suspecting user input, therefore starting in a terminal. Eem gebruikers ingave wordt verwacht, de toepassing word gestart in een Terminal.
|
||||||
|
Ok Ok
|
||||||
|
File: Bestand:
|
||||||
|
(not saved) (niet opgeslagen)
|
||||||
|
Line Lijn
|
||||||
|
Please wait... Even wachten...
|
||||||
|
Loading Program Toepassing laden
|
||||||
|
Running Draait
|
||||||
|
Running Program In uitvoering
|
||||||
|
Error! Program could not be killed. Fout! Toepassing kan niet gestopt worden.
|
||||||
|
Oops Oeps
|
||||||
|
Close terminal to break program Terminal sluiten om toepassing te sluiten
|
||||||
|
yab-IDE Set Run Parameters yab-IDE parameter zetten
|
||||||
|
Set Run Parameters Parameter zetten
|
||||||
|
yab Parameters: yab Parameter:
|
||||||
|
Program Parameters: Toepassing parameter:
|
||||||
|
yab-IDE New Program yab-IDE nieuwe toepassing
|
||||||
|
New yab Program Nieuwe yab toepassing
|
||||||
|
Please select one of the available templates for your program: Gelieve een van de beschikbare sjablonen te kiezen:
|
||||||
|
Name: Naam:
|
||||||
|
Browse... Bladeren...
|
||||||
|
Advanced Options Geavanceerd
|
||||||
|
Remove Template Sjabloon wissen
|
||||||
|
Project Directory Projectmap
|
||||||
|
Could not open template: Sjabloon kon niet geladen worden:
|
||||||
|
Opening an empty file instead. Open een leeg bestand in de plaats.
|
||||||
|
Really delete template Sjabloon wissen
|
||||||
|
Yes Ja
|
||||||
|
Cancel Annuleren
|
||||||
|
This standard template can not be deleted! Dit standaard sjabloon kan niet verwijderd worden!
|
||||||
|
Template successfully removed. Sjabloon verwijderd.
|
||||||
|
Error while deleting template! Fout bij het verwijderen sjabloon!
|
||||||
|
Empty Leeg bestand
|
||||||
|
Basic Template Eenvoudig sjabloon
|
||||||
|
Editor Template Sjabloon voor een Editor
|
||||||
|
Command Line Template Sjabloon voor commandline
|
||||||
|
|
||||||
|
Create an empty file. Leeg bestand aanmaken.
|
||||||
|
Create a new program with a bare Nieuwe toepassing aanmaken
|
||||||
|
window. met een leeg venster.
|
||||||
|
Create a new program with menus Nieuwe toepassing maken met
|
||||||
|
and an editor. menu's een een editor.
|
||||||
|
Nieuwe commandline
|
||||||
|
Create a new command line program. toepassing aanmaken.
|
||||||
|
yab-IDE Save As Template yab-IDE Opslaan als sjabloon
|
||||||
|
Save As Template Als sjabloon opslaan
|
||||||
|
Save your code as a template for other programs: Broncode als sjabloon opslaan
|
||||||
|
Template Name Sjabloonnaam
|
||||||
|
Description (not more than 30 characters per line) Beschrijving (niet meer dan 30 karakters per lijn)
|
||||||
|
Drop image here Afbeelding hier slepen
|
||||||
|
Could not load image! Afbeelding kon niet geladen worden
|
||||||
|
Error while saving template! Fout bij het opslaan van sjabloon!
|
||||||
|
File could not be saved! Bestand kon niet opgeslagen worden!
|
||||||
|
Sorry, you can not open more than Opgelet je kan niet meer dan
|
||||||
|
files at once!\n\nPlease close one or more other files first. bestanden openen in een keer!\n\nGelieve eerst een of meerdere bestanden te sluiten.
|
||||||
|
File is already open. Bestand is al open.
|
||||||
|
Error while loading file:\n\n Fout bij het laden van het bestand:\n\n
|
||||||
|
File \" Bestand \"
|
||||||
|
\" not saved!\n\nSave the file now? \" is niet opgeslagen\n\nBestand nu opslaan?
|
||||||
|
Error while printing! Fout bij het afdrukken!
|
||||||
|
Some files are not saved!\n\nDo you really want to quit? Enkele bestanden zijn niet opgeslagen!\n\nWil je werkelijk afsluiten?
|
||||||
|
Program is not saved.\n\nSave it now? Toepassing is niet opgeslagen.\n\nNu opslaan?
|
||||||
|
Save Always Altijd opslaan
|
||||||
|
Save Now Nu opslaan
|
||||||
|
Reformating did not close all open loops and conditions.\nReformating currently does not support loops and conditions opened and closed by a colon (:).\nE.g. while(loop):wend\n\nYou can undo the reformating before doing any further changes. Herformateren heeft niet alle loops en condities kunnen sluiten.\nHerformateren ondersteun momenteel geen loops en conditie's tussen duppelpunten (:).\nBv. while(loop):wend\n\nJe kan de herformatering ongedaan maken zolang de tekst niet veranderd wordt.
|
||||||
|
Do not show this warning again Deze waarschuwing niet meer tonen
|
||||||
|
Changes made since reformating will be lost! Aanpassingen sinds de laatste herformatering zullen verloren gaan!
|
||||||
|
The operation \"Replace All\" can not be reverted!\n\nDo you want to continue? De operatie \"Alles vervangen\" kan niet teruggedraaid worden!\n\nToch verdergaan?
|
||||||
|
yab-IDE Build Factory yab-IDE Build-Factory
|
||||||
|
Target file name: Doelbestand:
|
||||||
|
Use the Haiku tab view instead of the ZETA native tab view Gebruik de Haiku tabview in plaats van de ZETA eigen tabvies
|
||||||
|
Create Binary Compileer bin
|
||||||
|
The compiler GCC was not found!\n\nPlease install the development tools from your ZETA CD. De GCC compiler is niet gevonden!\n\nGelieve de ontwikkel toepassingen van de ZETA CD te installeren.
|
||||||
|
The compiler GCC was not found!\n\nPlease install the development tools. De GCC compiler is niet gevonden!\n\nGelieve de ontwikkel toepassingen te installeren.
|
||||||
|
Visit Download Site GCC nu downloaden
|
||||||
|
Warning: Although you are using the BeOS yab, the resulting binary will be ZETA only! Waarschuwing: Ondanks dat je BeOS yab gebruikt, zal de toepassing enkel op ZETA draaien!
|
||||||
|
Build Factory Output\n\n Build-Factory Output\n\n
|
||||||
|
Please wait, processing... (this may take a while)\n\n Even geduld... (de bewerking kan een tijdje duren)\n\n
|
||||||
|
Build was successful Aanmaken gelukt
|
||||||
|
Build failed! Aanmaken mislukt!
|
||||||
|
yab-IDE Pattern Editor yab-IDE patroon aanmaken
|
||||||
|
Insert Pattern Patroon invoegen
|
||||||
|
yab-IDE Color Selection yab-IDE kleurkiezer
|
||||||
|
Color Selection Kleurselectie
|
||||||
|
Default Colors: Standaardkleuren:
|
||||||
|
Black Zwart
|
||||||
|
Darken 4 Donker 4
|
||||||
|
Darken 3 Donker 3
|
||||||
|
Darken 2 Donker 2
|
||||||
|
Darken 1 Donker 1
|
||||||
|
Default Background Standaard achtergrond
|
||||||
|
Lighten 1 Lichter 1
|
||||||
|
Lighten 2 Lichter 2
|
||||||
|
White Wit
|
||||||
|
Red Rood
|
||||||
|
Brown Bruin
|
||||||
|
Yellow Geel
|
||||||
|
Green Groen
|
||||||
|
Cyan Cyaan
|
||||||
|
Light Blue Licht blauw
|
||||||
|
Blue Blauw
|
||||||
|
Magenta Magenta
|
||||||
|
Light Magenta Licht Magenta
|
||||||
|
Insert Color Kleur invoegen
|
||||||
|
yab-IDE ASCII Table yab-IDE ASCII tabel
|
||||||
|
ASCII Table ASCII tabel
|
||||||
|
yab-IDE Options yab-IDE Instellingen
|
||||||
|
Editor Editor
|
||||||
|
General Algemeen
|
||||||
|
Environment Omgeving
|
||||||
|
Directories Mappen
|
||||||
|
Language Talen
|
||||||
|
Number of spaces per tab: Aantal spaties per tab:
|
||||||
|
Ask about saving before running a program Vraag naar opslaan voor het draaien van de toepassing
|
||||||
|
Show warning when reformating sourcecode did not close all loops and conditions Toon waarschuwing als herformatering niet alle loops en condities sluiten kon
|
||||||
|
Show warning before undo reformating Toon waarschuwing voor het ongedaan maken van de herformatering
|
||||||
|
Show warning before applying Replace All Toon waarschuwing voor het toepassen \"Alles vervangen\"
|
||||||
|
Select font for editor: Selecteer een font voor de editor:
|
||||||
|
Font Family Font
|
||||||
|
Font Style Stijl
|
||||||
|
Font Size Grootte
|
||||||
|
My hovercraft is full of eels. Mijn hoovercraft zit vol met vissen.
|
||||||
|
Factory Settings Standaardinstellingen
|
||||||
|
Enable auto completion Auto-aanvullen inschakelen
|
||||||
|
Number of characters for starting completion: Aantal karakters voor het starten van het aanvullen:
|
||||||
|
New Entry: Nieuwe ingang:
|
||||||
|
Add New Entry Nieuwe ingang toevoegen
|
||||||
|
Remove Entry Ingang wissen
|
||||||
|
Note: You have to restart the IDE to update the Aandacht: de IDE moet herstart worden
|
||||||
|
autocompletion when removing entries. zodat gewiste ingangen niet meer verscheinen.
|
||||||
|
Note: Only change the directories, when you know what you are doing! Aandacht: Verander enkel de mappen als je weet wat je doet!
|
||||||
|
Default yab Binary Standaard yab-Interpreter
|
||||||
|
Default yab Directory Standaard yab-map
|
||||||
|
Use the automatic localization Gebruik Haiku's taalsysteem
|
||||||
|
Supported Languages Ondersteunde talen
|
||||||
|
Entry already exists. Ingang bestaat reeds
|
||||||
|
Restart yab-IDE to change localization yab-IDE herstarten om de localisering door te voeren
|
||||||
|
Could not find yab 1.0 directory!\n\nPlease do a proper installation. Kon de map yab 1.0 niet vinden!\n\nGelieve yab goed te installeren.
|
||||||
|
Could not find yab binary!\n\nPlease do a proper installation. Kon de interpreter van yab 1.0 niet vinden!\n\nGelieve yab goed te installeren.
|
||||||
|
New yab directory set to:\n\n Nieuwe yab map gezet naar:\n\n
|
||||||
|
\n\nRestart the IDE using the new directory. \n\nyab-IDE herstarten om de localisering door te voeren.
|
||||||
|
Invalid directory:\n\n Ongeldige map:\n\n
|
||||||
|
yab binary set to:\n\n yab-Interpreter insteld naar:\n\n
|
||||||
|
Invalid file:\n\n Ongeldig bestand:\n\n
|
||||||
|
Export As HTML... Als HTML opslaan...
|
||||||
|
Open Project Folder... Projectmap openen...
|
||||||
60
yab-IDE/Programs/Examples/3D-Curve.yab
Executable file
60
yab-IDE/Programs/Examples/3D-Curve.yab
Executable file
@@ -0,0 +1,60 @@
|
|||||||
|
doc Draw some nice 3D curves
|
||||||
|
doc Original by Martin Lehmann for QBasic
|
||||||
|
doc
|
||||||
|
doc change the function func for different curves
|
||||||
|
doc try smaller values of i for a lower resolution
|
||||||
|
doc try z = 1 for less dots
|
||||||
|
doc
|
||||||
|
doc Note: this demo shows one thing: yab is slow :)
|
||||||
|
doc The cleanup of the drawing takes alot of time too,
|
||||||
|
doc you can simply break the program if you don't want to wait
|
||||||
|
doc
|
||||||
|
|
||||||
|
window open 100,100 to 739,579, "Win", "3D Curve"
|
||||||
|
|
||||||
|
bitmap 640,480, "DoubleBuffer"
|
||||||
|
canvas 0,0 to 639,479, "MyCanvas", "Win"
|
||||||
|
|
||||||
|
i = 128 // resolution
|
||||||
|
z = 0.5 // dot frequency
|
||||||
|
xk = 40
|
||||||
|
yk = 30
|
||||||
|
|
||||||
|
draw set "highcolor", 0,0,0, "DoubleBuffer"
|
||||||
|
draw rect 0,0 to 639,479, "DoubleBuffer"
|
||||||
|
draw bitmap 0,0, "DoubleBuffer", "copy", "MyCanvas"
|
||||||
|
|
||||||
|
for t = -144 to 144 step(288/i)
|
||||||
|
if(t=0) t=0.1
|
||||||
|
r = int(0.5 + sqrt(20736 - t^2))
|
||||||
|
for j = -r to r step z
|
||||||
|
p = func(sqrt(j^2 + t^2) * 0.0327) * 20
|
||||||
|
x = int(1.7 * (j + (t/2.25) + 160)) + xk
|
||||||
|
y = int(1.8 * (199 - (p - t/2.25 + 90))) + yk
|
||||||
|
draw set "highcolor", 255-r,j+r,255-p, "DoubleBuffer"
|
||||||
|
draw line x,y to x,y, "DoubleBuffer"
|
||||||
|
draw set "highcolor", 0,0,0, "DoubleBuffer"
|
||||||
|
draw line x,y+1 to x,480, "DoubleBuffer"
|
||||||
|
next j
|
||||||
|
draw bitmap 0,0, "DoubleBuffer", "copy", "MyCanvas"
|
||||||
|
next t
|
||||||
|
|
||||||
|
while(not instr(message$, "Quit"))
|
||||||
|
wend
|
||||||
|
|
||||||
|
window close "Win"
|
||||||
|
|
||||||
|
// Choose one of the functions below, comment out all others
|
||||||
|
sub func(n)
|
||||||
|
return cos(n) + cos(2*n) +cos(5*n)
|
||||||
|
// return -abs(1/n)
|
||||||
|
// return -abs(1/(n + j))
|
||||||
|
// return sin(n) + sin(2*n) +sin(5*n)
|
||||||
|
// return cos(sin(n))
|
||||||
|
// return cos(2*n) + cos((n+j)/16)
|
||||||
|
// return sqrt(abs(0.5*(16 - n^2))) + 1/(n*4)
|
||||||
|
// return cos(4*n) + 20/(n^2 + 3)
|
||||||
|
// return cos(1/n) + cos(2/n) + cos(5/n) - 3
|
||||||
|
// return cos(sin(j/n))
|
||||||
|
// return 1/sqrt(n) - 3
|
||||||
|
end sub
|
||||||
201
yab-IDE/Programs/Examples/AllInOne.yab
Executable file
201
yab-IDE/Programs/Examples/AllInOne.yab
Executable file
@@ -0,0 +1,201 @@
|
|||||||
|
// This example demonstrates all widgets
|
||||||
|
|
||||||
|
// open the window
|
||||||
|
window open 100,100 to 640,500, "Win", "yab Demo"
|
||||||
|
window set "Win", "Flags", "Not-Resizable, Not-Zoomable"
|
||||||
|
|
||||||
|
// set the title
|
||||||
|
view 10,10 to 530,50, "Title", "Win"
|
||||||
|
draw set "bgcolor", 50,50,200, "Title"
|
||||||
|
draw set "lowcolor", 50,50,200, "Title"
|
||||||
|
draw set "highcolor", 255,255,255, "Title"
|
||||||
|
if(peek$("os") = "Haiku") then
|
||||||
|
draw set "DejaVu Sans,Condensed Bold,32", "Title"
|
||||||
|
else
|
||||||
|
draw set "Zurich,Bold,32", "Title"
|
||||||
|
endif
|
||||||
|
draw text 10,32, "yab Widgets and Views", "Title"
|
||||||
|
|
||||||
|
// make the tabview
|
||||||
|
tabview 10,60 to 530,390, "Box", "top", "Win"
|
||||||
|
tabview add "Box", "Widgets"
|
||||||
|
tabview add "Box", "Views and More"
|
||||||
|
|
||||||
|
// button
|
||||||
|
button 10,10 to 100,30, "Button", "Button", "Box1"
|
||||||
|
tooltip "Button", "BUTTON"
|
||||||
|
|
||||||
|
// button image
|
||||||
|
button image 10,40, "ButtonImage", "img/button_pressed.png", "img/button_norm.png", "", "Box1"
|
||||||
|
tooltip "ButtonImage", "BUTTON IMAGE"
|
||||||
|
|
||||||
|
// checkbox
|
||||||
|
checkbox 10,70, "Check", "Checkbox", true, "Box1"
|
||||||
|
tooltip "Check", "CHECKBOX"
|
||||||
|
|
||||||
|
// checkbox image
|
||||||
|
checkbox image 10,92, "CheckImage", "img/checkbutton_enabledOn.png", "img/checkbutton_enabledOff.png", "", "", true, "Box1"
|
||||||
|
tooltip "CheckImage", "CHECKBOX IMAGE"
|
||||||
|
|
||||||
|
// radiobutton
|
||||||
|
radiobutton 10,130, "Radio1", "1. Radiobutton", true, "Box1"
|
||||||
|
tooltip "Radio1", "RADIOBUTTON"
|
||||||
|
radiobutton 10,150, "Radio2", "2. Radiobutton", false, "Box1"
|
||||||
|
tooltip "Radio2", "RADIOBUTTON"
|
||||||
|
|
||||||
|
// dropbox
|
||||||
|
dropbox 10,175 to 120,195, "Drop", "Dropbox", "Box1"
|
||||||
|
dropbox add "Drop", "Foo"
|
||||||
|
dropbox add "Drop", "Bar"
|
||||||
|
tooltip "Drop", "DROPBOX"
|
||||||
|
|
||||||
|
// listbox
|
||||||
|
listbox 10,210 to 100,290, "List", 1, "Box1"
|
||||||
|
listbox add "List", "Foo"
|
||||||
|
listbox add "List", "Bar"
|
||||||
|
tooltip "List", "LISTBOX"
|
||||||
|
|
||||||
|
// columnbox
|
||||||
|
columnbox 130,10 to 270,150, "Column", 1, "", "Box1"
|
||||||
|
columnbox column "Column", " ", 1, 30,30,30, "align-center"
|
||||||
|
columnbox column "Column", "Column", 2, 90,90,90, "align-center"
|
||||||
|
columnbox add "Column", 1,1, 20, "__Icon__=img/yab.png"
|
||||||
|
columnbox add "Column", 2,1, 20, "Foo"
|
||||||
|
columnbox add "Column", 2,2, 20, "Bar"
|
||||||
|
tooltip "Column", "COLUMNBOX"
|
||||||
|
|
||||||
|
// treebox
|
||||||
|
treebox 130,160 to 270,290, "Tree", 1, "Box1"
|
||||||
|
treebox add "Tree", "Root"
|
||||||
|
treebox add "Tree", "Root", "Foo", true
|
||||||
|
treebox add "Tree", "Root", "Bar", true
|
||||||
|
tooltip "Tree", "TREEBOX"
|
||||||
|
|
||||||
|
// text
|
||||||
|
text 300,10, "Text", "Text (cannot be flushed)", "Box1"
|
||||||
|
tooltip "Text", "TEXT"
|
||||||
|
|
||||||
|
// texturl
|
||||||
|
texturl 300,30, "TextURL", "Team MAUI", "http://www.team-maui.de", "Box1"
|
||||||
|
tooltip "TextURL", "TEXTURL"
|
||||||
|
|
||||||
|
// textcontrol
|
||||||
|
textcontrol 300,50 to 500,70, "TextCtrl", "TextControl", "", "Box1"
|
||||||
|
tooltip "TextCtrl", "TEXTCONTROL"
|
||||||
|
|
||||||
|
// spincontrol
|
||||||
|
spincontrol 300,80, "Spin", "Spincontrol", 0,100,1, "Box1"
|
||||||
|
tooltip "Spin", "SPINCONTROL"
|
||||||
|
|
||||||
|
// calendar
|
||||||
|
calendar 300,120, "Cal", "DDMMYYYY.", "01.01.1970", "Box1"
|
||||||
|
tooltip "Cal", "CALENDAR"
|
||||||
|
|
||||||
|
// textedit
|
||||||
|
textedit 300,150 to 500,215, "TextEd", 3, "Box1"
|
||||||
|
textedit add "TextEd", "Simply edit your text..."
|
||||||
|
tooltip "TextEd", "TEXTEDIT"
|
||||||
|
|
||||||
|
// slider
|
||||||
|
slider 300,225 to 500,245, "Slider", "Slider", 1, 23, "Box1"
|
||||||
|
tooltip "Slider", "SLIDER"
|
||||||
|
|
||||||
|
// statusbar
|
||||||
|
statusbar 300,265 to 500,290, "Status", "Start", "Finish", "Box1"
|
||||||
|
statusbar set "Status", "Start", "Finish", 66
|
||||||
|
tooltip "Status", "STATUSBAR"
|
||||||
|
|
||||||
|
// view
|
||||||
|
view 10,10 to 100,100, "View", "Box2"
|
||||||
|
draw set "bgcolor", "jan-favorite-color", "View"
|
||||||
|
draw text 20,35, "Plain View", "View"
|
||||||
|
tooltip "View", "VIEW"
|
||||||
|
|
||||||
|
// canvas
|
||||||
|
canvas 10,110 to 100,195, "Canvas", "Box2"
|
||||||
|
draw text 20,35, "Canvas", "Canvas"
|
||||||
|
tooltip "Canvas", "CANVAS"
|
||||||
|
|
||||||
|
// boxview
|
||||||
|
boxview 10,205 to 100,290, "Boxview", "Boxview", 2, "Box2"
|
||||||
|
tooltip "Boxview", "BOXVIEW"
|
||||||
|
|
||||||
|
// tabview
|
||||||
|
tabview 120,10 to 260,100, "Tab", "top", "Box2"
|
||||||
|
tabview add "Tab", "First"
|
||||||
|
tabview add "Tab", "Second"
|
||||||
|
tooltip "Tab", "TABVIEW"
|
||||||
|
|
||||||
|
// splitview
|
||||||
|
splitview 120,110 to 260,195, "Split", true, false, "Box2"
|
||||||
|
draw set "bgcolor", "Panel-Background-Color, Darken-1-Tint", "Split1"
|
||||||
|
draw set "bgcolor", "Panel-Background-Color, Lighten-1-Tint", "Split2"
|
||||||
|
tooltip "Split", "SPLITVIEW"
|
||||||
|
|
||||||
|
// colorcontrol
|
||||||
|
colorcontrol 120,203, "Color", "Box2"
|
||||||
|
tooltip "Color", "COLORCONTROL"
|
||||||
|
|
||||||
|
// popupmenu (only button, code in messageloop)
|
||||||
|
button 120,270 to 245,290, "Popup", "Popupmenu", "Box2"
|
||||||
|
tooltip "Popup", "POPUPMENU"
|
||||||
|
|
||||||
|
// filepanel (only button, code in messageloop)
|
||||||
|
button 255,270 to 350,290, "File", "Filepanel", "Box2"
|
||||||
|
tooltip "File", "FILEPANEL"
|
||||||
|
|
||||||
|
// menu
|
||||||
|
view 280,10 to 500,100, "Menu", "Box2"
|
||||||
|
menu "Menu", "Foo", "", "Menu"
|
||||||
|
menu "Menu", "--", "", "Menu"
|
||||||
|
menu "Menu", "Bar", "", "Menu"
|
||||||
|
draw set "bgcolor", "Panel-Background-Color, Darken-1-Tint", "Menu"
|
||||||
|
draw text 20,35, "View with menu", "Menu"
|
||||||
|
tooltip "Menu", "MENU"
|
||||||
|
|
||||||
|
// scrollbar
|
||||||
|
view 280,110 to 500-peek("scrollbarwidth"),195-peek("scrollbarwidth"), "ScrollView", "Box2"
|
||||||
|
scrollbar "Scroll", 3, "ScrollView"
|
||||||
|
scrollbar set "Scroll", "horizontal-range", 0,100
|
||||||
|
scrollbar set "Scroll", "vertical-range", 0,50
|
||||||
|
if(peek$("os") = "Haiku") then
|
||||||
|
draw set "DejaVu Sans,Condensed Bold,32", "ScrollView"
|
||||||
|
else
|
||||||
|
draw set "Zurich,Bold,32", "ScrollView"
|
||||||
|
endif
|
||||||
|
draw text 130,90, "Foobar", "ScrollView"
|
||||||
|
tooltip "Scroll", "SCROLLBAR"
|
||||||
|
|
||||||
|
// stackview
|
||||||
|
stackview 420,205 to 500,260, "StackView", 2, "Box2"
|
||||||
|
button 360,270 to 425,290, "Stack1", "Stack1", "Box2"
|
||||||
|
button 435,270 to 500,290, "Stack2", "Stack2", "Box2"
|
||||||
|
draw set "bgcolor", 200,200,255, "StackView1"
|
||||||
|
draw text 10,20, "First view", "StackView1"
|
||||||
|
draw set "bgcolor", 200,255,255, "StackView2"
|
||||||
|
draw text 10,20, "Second view", "StackView2"
|
||||||
|
tooltip "StackView", "STACKVIEW"
|
||||||
|
|
||||||
|
// messageloop
|
||||||
|
while(not quitting)
|
||||||
|
msg$ = message$
|
||||||
|
if(instr(msg$, "Popup")) then
|
||||||
|
// popupmenu
|
||||||
|
select$ = popupmenu 120,270, "Foo|--|Bar", "Box2"
|
||||||
|
elsif(instr(msg$, "File")) then
|
||||||
|
// filepanel
|
||||||
|
select$ = filepanel "Load-File", "Example Filepanel", "/boot/home"
|
||||||
|
elsif(instr(msg$, "Stack1")) then
|
||||||
|
// set stackview
|
||||||
|
stackview set "StackView", 1
|
||||||
|
elsif(instr(msg$, "Stack2")) then
|
||||||
|
// set stackview
|
||||||
|
stackview set "StackView", 2
|
||||||
|
elsif(instr(msg$, "Quit")) then
|
||||||
|
// exit
|
||||||
|
quitting = true
|
||||||
|
endif
|
||||||
|
wend
|
||||||
|
|
||||||
|
window close "Win"
|
||||||
|
|
||||||
64
yab-IDE/Programs/Examples/BoxWorld.yab
Executable file
64
yab-IDE/Programs/Examples/BoxWorld.yab
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
#!yab
|
||||||
|
|
||||||
|
window open 100,100 to 380,410,"MainView","BoxWorld.yab"
|
||||||
|
|
||||||
|
window set "MainView", "flags", "not-zoomable, not-h-resizable, not-v-resizable"
|
||||||
|
|
||||||
|
layout "none", "MainView"
|
||||||
|
|
||||||
|
view 0,0 to 110,30, "CheckboxView","MainView"
|
||||||
|
checkbox 10,10, "checkbox1", "Please select", 0, "CheckboxView"
|
||||||
|
|
||||||
|
view 0,31 to 110,120, "RadioView1","MainView"
|
||||||
|
radiobutton 10,10, "Radio11", "Radio 11", 0, "RadioView1"
|
||||||
|
radiobutton 10,30, "Radio12", "Radio 12", 0, "RadioView1"
|
||||||
|
radiobutton 10,50, "Radio13", "Radio 13", 1, "RadioView1"
|
||||||
|
|
||||||
|
view 0,130 to 110,190,"RadioView2","MainView"
|
||||||
|
radiobutton 10,10, "Radio21", "Radio 21", 1, "RadioView2"
|
||||||
|
radiobutton 10,30, "Radio22", "Radio 22", 0, "RadioView2"
|
||||||
|
|
||||||
|
view 0,195 to 110,280,"RadioView3","MainView"
|
||||||
|
radiobutton 10,5, "Radio31", "Radio 31", 0, "RadioView3"
|
||||||
|
radiobutton 10,25, "Radio32", "Radio 32", 0, "RadioView3"
|
||||||
|
radiobutton 10,45, "Radio33", "Radio 33", 1, "RadioView3"
|
||||||
|
radiobutton 10,65, "Radio34", "Radio 34", 0, "RadioView3"
|
||||||
|
|
||||||
|
view 0, 285 to 280, 310, "CommandView","MainView"
|
||||||
|
|
||||||
|
layout "leftright", "MainView"
|
||||||
|
|
||||||
|
listbox 120,10 to 255,110, "List1", 1, "MainView"
|
||||||
|
|
||||||
|
layout "standard", "MainView"
|
||||||
|
|
||||||
|
listbox 120,120 to 255,230, "List2", 3, "MainView"
|
||||||
|
|
||||||
|
listbox add "List1","Hello"
|
||||||
|
listbox add "List1","World"
|
||||||
|
|
||||||
|
for i=1 to 20
|
||||||
|
listbox add "List2","Number "+str$(i)
|
||||||
|
next i
|
||||||
|
|
||||||
|
dropbox 120,250 to 265,270, "drop1", "MyDrop:", "MainView"
|
||||||
|
dropbox add "drop1", "Hello World"
|
||||||
|
dropbox add "drop1", "Foo Bar"
|
||||||
|
dropbox add "drop1", "--"
|
||||||
|
dropbox add "drop1", "Acme Ltd"
|
||||||
|
dropbox add "drop1", "Bobejaan"
|
||||||
|
|
||||||
|
alert "BoxWorld shows how to use Radiobuttons, Checkboxes, Listboxes and Dropboxes.","Ok","idea"
|
||||||
|
|
||||||
|
inloop = true
|
||||||
|
while(inloop)
|
||||||
|
a$ = message$
|
||||||
|
if(a$<>"") then
|
||||||
|
print a$
|
||||||
|
draw flush "CommandView"
|
||||||
|
draw text 5,15, left$(a$,len(a$)-1), "CommandView"
|
||||||
|
endif
|
||||||
|
if(instr(a$,"_QuitRequested|")) inloop = false
|
||||||
|
wend
|
||||||
|
|
||||||
|
window close "MainView"
|
||||||
64
yab-IDE/Programs/Examples/ButtonWorld.yab
Executable file
64
yab-IDE/Programs/Examples/ButtonWorld.yab
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
#!yab
|
||||||
|
|
||||||
|
window open 400,400 to 550,500, "MainView1", "ButtonWorld1"
|
||||||
|
window open 600,400 to 750,500, "MainView2", "ButtonWorld2"
|
||||||
|
|
||||||
|
mainview1 = true
|
||||||
|
|
||||||
|
layout "left, right", "MainView1"
|
||||||
|
button 30,10 to 120,30, "EmptyAlert_", "Empty Alert", "MainView1"
|
||||||
|
layout "bottom, right", "MainView1"
|
||||||
|
button 30,40 to 120,60, "InfoAlert_", "Info Alert", "MainView1"
|
||||||
|
button 30,70 to 120,90, "IdeaAlert_", "Idea Alert", "MainView1"
|
||||||
|
|
||||||
|
button 30,10 to 120,30, "WarningAlert_", "Warning Alert", "MainView2"
|
||||||
|
button 30,40 to 120,60, "StopAlert_", "Stop Alert", "MainView2"
|
||||||
|
button 30,70 to 120,90, "Quit_", "Quit", "MainView2"
|
||||||
|
|
||||||
|
alert "ButtonWorld demonstrates how Buttons and Alerts can be used easily!", "Ok", "idea"
|
||||||
|
|
||||||
|
inloop = true
|
||||||
|
while(inloop)
|
||||||
|
msg$ = message$
|
||||||
|
switch msg$
|
||||||
|
case "EmptyAlert_|":
|
||||||
|
alert "This is an empty alert!", "Dooh", "none"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "InfoAlert_|"
|
||||||
|
alert "This is an info alert!", "Dooh", "info"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "IdeaAlert_|"
|
||||||
|
alert "This is an idea alert!", "Dooh", "idea"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "WarningAlert_|"
|
||||||
|
alert "This is a warning alert!", "Dooh", "warning"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "StopAlert_|"
|
||||||
|
alert "This is a stop alert!", "Dooh", "stop"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "Quit_|"
|
||||||
|
inloop = false
|
||||||
|
if (mainview1) window close "MainView1"
|
||||||
|
window close "MainView2"
|
||||||
|
break
|
||||||
|
|
||||||
|
case "MainView1:_QuitRequested|"
|
||||||
|
window close "MainView1"
|
||||||
|
mainview1 = false
|
||||||
|
break
|
||||||
|
|
||||||
|
case "MainView2:_QuitRequested|"
|
||||||
|
window close "MainView2"
|
||||||
|
break
|
||||||
|
|
||||||
|
end switch
|
||||||
|
|
||||||
|
if(window count<1) inloop = false
|
||||||
|
|
||||||
|
wend
|
||||||
|
|
||||||
202
yab-IDE/Programs/Examples/Calc.yab
Executable file
202
yab-IDE/Programs/Examples/Calc.yab
Executable file
@@ -0,0 +1,202 @@
|
|||||||
|
#!yab
|
||||||
|
sleep .01
|
||||||
|
This_dir$ = getdir$("Calc.yab")
|
||||||
|
|
||||||
|
//localize
|
||||||
|
window open 100,50 to 320,320, "Calc", "CalcView"
|
||||||
|
|
||||||
|
|
||||||
|
draw set "bgcolor", 100, 150, 220, "Calc"
|
||||||
|
draw set "lowcolor", 100, 190, 100, "Calc"
|
||||||
|
draw set "highcolor", 255, 255, 255, "Calc"
|
||||||
|
window set "Calc", "minimumto", 220, 260
|
||||||
|
window set "Calc", "maximumto", 220, 260
|
||||||
|
|
||||||
|
layout "all", "Calc"
|
||||||
|
|
||||||
|
menu "File", "Reset", "R", "Calc"
|
||||||
|
menu "File", "--", "", "Calc"
|
||||||
|
menu "File", "Quit", "Q", "Calc"
|
||||||
|
menu "Help", "Help...", "H", "Calc"
|
||||||
|
menu "Help", "--", "", "Calc"
|
||||||
|
menu "Help", "About...", "", "Calc"
|
||||||
|
|
||||||
|
button 20,70 to 55,105,"b7", "7", "Calc"
|
||||||
|
button 65,70 to 100,105,"b8", "8", "Calc"
|
||||||
|
button 110,70 to 145,105,"b9", "9", "Calc"
|
||||||
|
button 155,70 to 190,105,"b/", "/", "Calc"
|
||||||
|
button 20,115 to 55,150,"b4", "4", "Calc"
|
||||||
|
button 65,115 to 100,150,"b5", "5", "Calc"
|
||||||
|
button 110,115 to 145,150,"b6", "6", "Calc"
|
||||||
|
button 155,115 to 190,150,"b*", "*", "Calc"
|
||||||
|
button 20,160 to 55,195,"b1", "1", "Calc"
|
||||||
|
button 65,160 to 100,195,"b2", "2", "Calc"
|
||||||
|
button 110,160 to 145,195,"b3", "3", "Calc"
|
||||||
|
button 155,160 to 190,195,"b-", "-", "Calc"
|
||||||
|
button 20,205 to 55,240,"b0", "0", "Calc"
|
||||||
|
button 65,205 to 100,240,"b.", ".", "Calc"
|
||||||
|
button 110,205 to 145,240,"bC", "C", "Calc"
|
||||||
|
button 155,205 to 190,240,"b+/=", "+=", "Calc"
|
||||||
|
|
||||||
|
draw text 20,50,"0","Calc"
|
||||||
|
|
||||||
|
display$ = "0"
|
||||||
|
result = 0
|
||||||
|
type$ = "+"
|
||||||
|
|
||||||
|
dim msgbuffer$(1)
|
||||||
|
inloop = true
|
||||||
|
while(inloop)
|
||||||
|
msgnumber = split(message$, msgbuffer$(), "|")
|
||||||
|
for i=0 to msgnumber
|
||||||
|
switch msgbuffer$(i)
|
||||||
|
case "b."
|
||||||
|
case "b0"
|
||||||
|
case "b1"
|
||||||
|
case "b2"
|
||||||
|
case "b3"
|
||||||
|
case "b4"
|
||||||
|
case "b5"
|
||||||
|
case "b6"
|
||||||
|
case "b7"
|
||||||
|
case "b8"
|
||||||
|
case "b9"
|
||||||
|
if(len(display$)<10) display$ = display$ + right$(msgbuffer$(i),1)
|
||||||
|
while(left$(display$,1)="0")
|
||||||
|
display$ = right$(display$,len(display$)-1)
|
||||||
|
wend
|
||||||
|
if(display$="") display$="0"
|
||||||
|
draw rect 20,30 to 170,60, "Calc"
|
||||||
|
draw flush "Calc"
|
||||||
|
draw text 20,50, display$,"Calc"
|
||||||
|
break
|
||||||
|
case "b-"
|
||||||
|
result = calculate(result, type$, val(display$))
|
||||||
|
type$ = "-"
|
||||||
|
draw rect 20,30 to 170,60, "Calc"
|
||||||
|
draw flush "Calc"
|
||||||
|
draw text 20,50, str$(result),"Calc"
|
||||||
|
display$="0"
|
||||||
|
break
|
||||||
|
case "b+/="
|
||||||
|
result = calculate(result, type$, val(display$))
|
||||||
|
type$ = "+"
|
||||||
|
draw rect 20,30 to 170,60, "Calc"
|
||||||
|
draw flush "Calc"
|
||||||
|
draw text 20,50, str$(result),"Calc"
|
||||||
|
display$="0"
|
||||||
|
break
|
||||||
|
case "b*"
|
||||||
|
result = calculate(result, type$, val(display$))
|
||||||
|
type$ = "*"
|
||||||
|
draw rect 20,30 to 170,60, "Calc"
|
||||||
|
draw flush "Calc"
|
||||||
|
draw text 20,50, str$(result),"Calc"
|
||||||
|
display$="0"
|
||||||
|
break
|
||||||
|
case "b/"
|
||||||
|
result = calculate(result, type$, val(display$))
|
||||||
|
type$ = "/"
|
||||||
|
draw rect 20,30 to 170,60, "Calc"
|
||||||
|
draw flush "Calc"
|
||||||
|
draw text 20,50, str$(result),"Calc"
|
||||||
|
display$="0"
|
||||||
|
break
|
||||||
|
case "bC"
|
||||||
|
case "Calc:File:Reset"
|
||||||
|
result=0
|
||||||
|
draw rect 20,30 to 170,60, "Calc"
|
||||||
|
draw flush "Calc"
|
||||||
|
draw text 20,50, str$(result),"Calc"
|
||||||
|
display$="0"
|
||||||
|
type$ = "+"
|
||||||
|
break
|
||||||
|
case "Calc:File:Quit"
|
||||||
|
case "Calc:_QuitRequested"
|
||||||
|
window close "Calc"
|
||||||
|
break
|
||||||
|
case "Calc:Help:Help..."
|
||||||
|
alert "Calc demonstrates how to program\n a calculator in yab.\n\n", "Ok", "info"
|
||||||
|
break
|
||||||
|
case "Calc:Help:About..."
|
||||||
|
window open 250,100 to 570,291, "About", "About"
|
||||||
|
window set "About", "look", "bordered"
|
||||||
|
window set "About", "feel", "modal-app"
|
||||||
|
draw set "BGColor", 255,255,255, "About"
|
||||||
|
window set "About", "minimumto", 320, 191
|
||||||
|
window set "About", "maximumto", 320, 191
|
||||||
|
|
||||||
|
err = draw image 0,0, This_dir$+"img/image.png", "About"
|
||||||
|
if(err>0) then
|
||||||
|
alert "Error loading image.png!"+str$(err), "Close", "warning"
|
||||||
|
window close "About"
|
||||||
|
else
|
||||||
|
button 20,163 to 300,183,"b", "Close", "About"
|
||||||
|
endif
|
||||||
|
|
||||||
|
break
|
||||||
|
case translate$("b")
|
||||||
|
case translate$("About:_QuitRequested")
|
||||||
|
window close "About"
|
||||||
|
break
|
||||||
|
default
|
||||||
|
break
|
||||||
|
end switch
|
||||||
|
next i
|
||||||
|
|
||||||
|
if(window count = 0) inloop = false
|
||||||
|
sleep 0.1
|
||||||
|
wend
|
||||||
|
|
||||||
|
sub calculate(a,type$,b)
|
||||||
|
ret = 0
|
||||||
|
switch(type$)
|
||||||
|
case "+"
|
||||||
|
ret = a + b
|
||||||
|
break
|
||||||
|
case "-"
|
||||||
|
ret = a - b
|
||||||
|
break
|
||||||
|
case "*"
|
||||||
|
ret = a * b
|
||||||
|
break
|
||||||
|
case "/"
|
||||||
|
ret = a / b
|
||||||
|
break
|
||||||
|
end switch
|
||||||
|
return ret
|
||||||
|
end sub
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
sub getdir$( programname$)
|
||||||
|
// find out in which directory we are in
|
||||||
|
////////////////////////////////////////////////////////////////
|
||||||
|
local path$
|
||||||
|
local catch
|
||||||
|
catch=0
|
||||||
|
if (!peek("isbound")) then
|
||||||
|
path$=system$("ps")
|
||||||
|
x=instr(path$,"/"+programname$)
|
||||||
|
path$=left$(path$,x)
|
||||||
|
for x=len(path$)-1 to 1 step -1
|
||||||
|
if (instr(path$," ",x) and catch=0) catch=x+1
|
||||||
|
next
|
||||||
|
path$=right$(path$,len(path$)-catch)
|
||||||
|
path$=trim$(path$)
|
||||||
|
if path$="/" then
|
||||||
|
path$ = trim$(system$("pwd"))+"/"
|
||||||
|
else
|
||||||
|
path$="/"+path$
|
||||||
|
endif
|
||||||
|
|
||||||
|
else
|
||||||
|
path$=trim$(peek$("directory") )
|
||||||
|
path$=path$+"/"
|
||||||
|
|
||||||
|
end if
|
||||||
|
|
||||||
|
return path$
|
||||||
|
end sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
43
yab-IDE/Programs/Examples/Checkbox.yab
Executable file
43
yab-IDE/Programs/Examples/Checkbox.yab
Executable file
@@ -0,0 +1,43 @@
|
|||||||
|
#!yab
|
||||||
|
|
||||||
|
dim Part$(1)
|
||||||
|
window open 100, 100, 240, 300, "A", "Checkboxes"
|
||||||
|
window set "A", "flags", "not-h-resizable, not-v-resizable, not-zoomable"
|
||||||
|
|
||||||
|
// create the checkboxes
|
||||||
|
// with layout for left top
|
||||||
|
layout "left, top", "A"
|
||||||
|
for NP = 1 to 5
|
||||||
|
Y = Y+25
|
||||||
|
checkbox 10, Y, "CheckMe:"+str$(NP), "OFF", 0, "A"
|
||||||
|
next NP
|
||||||
|
|
||||||
|
button 10, 170 to 130, 190, "Button_", "Check them", "A"
|
||||||
|
|
||||||
|
while (not instr(msg$, "Quit"))
|
||||||
|
msg$ = message$
|
||||||
|
if (split(msg$, Part$(), ":|") < 3) dim Part$(3)
|
||||||
|
|
||||||
|
// if one of the checkboxes was used
|
||||||
|
if (msg$ = "CheckMe:"+Part$(2)+":"+Part$(3)+"|") then
|
||||||
|
option set "CheckMe:"+Part$(2), "label", Part$(3)
|
||||||
|
fi
|
||||||
|
|
||||||
|
// if the button was pressed
|
||||||
|
if (msg$ = "Button_|") then
|
||||||
|
if (check$ = "ON") then
|
||||||
|
check$ = "OFF"
|
||||||
|
option set "Button_", "label", "Check them"
|
||||||
|
else
|
||||||
|
check$ = "ON"
|
||||||
|
option set "Button_", "label", "Uncheck them"
|
||||||
|
fi
|
||||||
|
for NP = 1 to 5
|
||||||
|
checkbox set "CheckMe:"+str$(NP), (check$ = "ON")
|
||||||
|
option set "CheckMe:"+str$(NP), "label", check$
|
||||||
|
// sleep 0.05
|
||||||
|
next NP
|
||||||
|
fi
|
||||||
|
|
||||||
|
wend
|
||||||
|
exit
|
||||||
34
yab-IDE/Programs/Examples/Clock.yab
Executable file
34
yab-IDE/Programs/Examples/Clock.yab
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!yab
|
||||||
|
|
||||||
|
window open 100,100 to 200,150, "MainView", "Clock"
|
||||||
|
window set "MainView", "flags", "Not-Zoomable"
|
||||||
|
window set "MainView", "minimumto", 100,50
|
||||||
|
window set "MainView", "maximumto", 100,50
|
||||||
|
layout "left, top, right", "MainView"
|
||||||
|
view 0,0 to 100,50, "clockview", "MainView"
|
||||||
|
|
||||||
|
inloop = true
|
||||||
|
while(inloop)
|
||||||
|
msg$ = message$
|
||||||
|
if(msg$<>"") print msg$
|
||||||
|
if(instr(msg$,"_QuitRequested")) inloop = false
|
||||||
|
if(instr(msg$,"Quit")) inloop = false
|
||||||
|
draw_time_and_date()
|
||||||
|
sleep 0.01
|
||||||
|
wend
|
||||||
|
|
||||||
|
window close "MainView"
|
||||||
|
exit
|
||||||
|
|
||||||
|
sub time_and_date()
|
||||||
|
zeit$ = left$(time$,2) + ":" + mid$(time$,4,2) + ":" + mid$(time$,7,2)
|
||||||
|
datum$ = mid$(date$,14,3) + ", " + mid$(date$,6,2) + "." + mid$(date$,3,2) + "." + mid$(date$,11,2)
|
||||||
|
end sub
|
||||||
|
|
||||||
|
sub draw_time_and_date()
|
||||||
|
time_and_date()
|
||||||
|
draw flush "clockview"
|
||||||
|
draw text 10,20, datum$ ,"clockview"
|
||||||
|
draw text 10,35, zeit$ + " ","clockview"
|
||||||
|
wait 0.25
|
||||||
|
end sub
|
||||||
26
yab-IDE/Programs/Examples/ColorDemo.yab
Executable file
26
yab-IDE/Programs/Examples/ColorDemo.yab
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!yab
|
||||||
|
|
||||||
|
DOCU ColorDemo, Color select and show
|
||||||
|
DOCU by Stargater
|
||||||
|
|
||||||
|
window open 100,100 to 420,420, "MainView", "ColorDemo"
|
||||||
|
window set "MainView", "flags", "not-zoomable, not-h-resizable, not-v-resizable"
|
||||||
|
view 20,20 to 300,220, "ViewColor", "MainView"
|
||||||
|
r = 140
|
||||||
|
g = 140
|
||||||
|
b = 240
|
||||||
|
draw set "bgcolor", r,g,b, "ViewColor"
|
||||||
|
|
||||||
|
colorcontrol 10,240, "Colorcontrol", "MainView"
|
||||||
|
colorcontrol set "Colorcontrol", 140,140,240
|
||||||
|
|
||||||
|
|
||||||
|
while(not instr(message$,"_QuitRequested"))
|
||||||
|
r = colorcontrol get "Colorcontrol", "red"
|
||||||
|
g = colorcontrol get "Colorcontrol", "green"
|
||||||
|
b = colorcontrol get "Colorcontrol", "blue"
|
||||||
|
draw set "bgcolor", r,g,b, "ViewColor"
|
||||||
|
wend
|
||||||
|
|
||||||
|
window close "MainView"
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user