[DEVELOPMENT ENVIRONMENT]

* NEW: New "Gamabs" highlight theme.
* BUG: When showing the search dialog, the search text is correctly 
  selected in all cases now.
* BUG: Importing a report (or any form that is not a GUI form) now 
  correctly imports the class file.

[EXAMPLES]
* NEW: Add a text clipping example in the 'Painting' example.

[INTERPRETER]
* OPT: Replace() is now faster when the search string and the replace
  string are both one character length strings.

[COMPILER]
* NEW: The string escape character '\v' was added.

[GB.GTK]
* BUG: Paint.Text() now works correctly when the alignment is not 
  specified.

[GB.NET]
* BUG: Correctly check system errors when using a asynchronous DnsClient.

[GB.QT4]
* BUG: Paint.Save() and Paint.Restore() take the clipping path into account 
  now.

[GB.SETTINGS]
* NEW: Use a temporary file when saving a settings file, and always make a
  backup.

[GB.WEB]
* NEW: The Session.Modify() method was replaced by a read/write Modified 
  property.


git-svn-id: svn://localhost/gambas/trunk@4273 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2011-12-11 19:14:04 +00:00
parent f173a43bba
commit 200a429afc
34 changed files with 251 additions and 59 deletions

View File

@ -1015,7 +1015,7 @@ msgstr ""
msgid "(No parent)"
msgstr ""
#: FCreateFile.class:414
#: FCreateFile.class:418
msgid "Cannot add file."
msgstr ""
@ -3093,6 +3093,10 @@ msgstr ""
msgid "Emerald"
msgstr ""
#: FOption.class:4
msgid "Gambas"
msgstr ""
#: FOption.class:4
msgid "Ruby"
msgstr ""

View File

@ -1,7 +1,7 @@
' Gambas class file
Static Private $aTheme As String[] = ["amethyst", "amber", "emerald", "ruby", "sapphire", "visual", "obsidian", "quest", "quick"]
Static Private $aThemeName As String[] = [("Amethyst"), ("Amber"), ("Emerald"), ("Ruby"), ("Sapphire"), ("Visual"), ("Obsidian"), ("Quest"), ("Quick")]
Static Private $aTheme As String[] = ["amethyst", "amber", "emerald", "gambas", "ruby", "sapphire", "visual", "obsidian", "quest", "quick"]
Static Private $aThemeName As String[] = [("Amethyst"), ("Amber"), ("Emerald"), ("Gambas"), ("Ruby"), ("Sapphire"), ("Visual"), ("Obsidian"), ("Quest"), ("Quick")]
Static Private $aBrowser As String[] = ["konqueror", "firefox", "epiphany", "seamonkey", "opera"]
Static Private $aTerminal As String[] = ["konsole", "gnome-terminal", "Terminal", "lxterminal", "xterm"]
Static Private $aImageEditor As String[] = ["gimp", "kolourpaint", "krita"]

View File

@ -1,6 +1,6 @@
' Gambas module file
Public Const DEFAULT_THEME As String = "sapphire"
Public Const DEFAULT_THEME As String = "gambas"
Public ColorKeys As String[] = ["Background", "Alternate", "Normal", "Keyword", "Datatype", "Function", "Operator", "Symbol", "Number", "String", "Comment", "Help", "Preprocessor", "Breakpoint", "Current", "Selection", "Highlight", "CurrentLine", "Error"]
Public ColorNames As String[] = [("Background"), ("Alternate background"), ("Normal text"), ("Keywords"), ("Data types"), ("Subroutines"), ("Operators"), ("Symbols"), ("Numbers"), ("Strings"), ("Comments"), ("Help"), ("Preprocessor"), ("Breakpoints"), ("Current line"), ("Selection"), ("Highlighting"), ("Editing line"), ("Errors")]

View File

@ -289,7 +289,7 @@ Private Sub CreateFile() As Boolean
End
Private Sub ImportDependencies(sName As String, sOrig As String, bLink As Boolean)
Private Sub ImportDependencies(sName As String, sExt As String, sOrig As String, bLink As Boolean)
Dim hIn As File
Dim hOut As File
@ -303,11 +303,13 @@ Private Sub ImportDependencies(sName As String, sOrig As String, bLink As Boolea
Inc Application.Busy
sForm = Project.Dir &/ sName & ".form"
sForm = Project.Dir &/ File.SetExt(sName, sExt)
sOrig = File.Dir(sOrig)
hIn = Open sForm
hOut = Open Temp$("form") For Create
hOut = Open Temp$(sExt) For Create
'TODO: Import Image.Load(*) and SvgImage.Load(*)
While Not Eof(hIn)
@ -346,7 +348,7 @@ NEXT_LINE:
If bSave Then
Kill sForm
Copy Temp$("form") To sForm
Copy Temp$(sExt) To sForm
Project.RefreshKey(sForm)
Endif
@ -362,12 +364,14 @@ Private Sub ImportFile() As Boolean
Dim sName As String
Dim sTemp As String
Dim sType As String
Dim sExt As String
sTemp = fchExisting.Value
sDir = File.Dir(fchExisting.Value)
sName = File.Name(fchExisting.Value)
Select Case File.Ext(sTemp)
sExt = File.Ext(sTemp)
Select Case sExt
Case "module"
sName = File.BaseName(Project.GetUniqueSourceName(sName))
@ -377,17 +381,17 @@ Private Sub ImportFile() As Boolean
sName = File.BaseName(Project.GetUniqueSourceName(sName))
Project.InsertSource(sName, "class", $sDir, sTemp,,, chkLink.Value)
Case "form"
Case "form", "report"
sName = File.BaseName(Project.GetUniqueSourceName(sName))
Project.InsertSource(sName, "class", $sDir, File.SetExt(sTemp, "class"), True, True, chkLink.Value)
Project.InsertSource(sName, "form", $sDir, sTemp,, True, chkLink.Value)
ImportDependencies(sName, sTemp, chkLink.Value)
Project.InsertSource(sName, sExt, $sDir, sTemp, False, True, chkLink.Value)
ImportDependencies(sName, sExt, sTemp, chkLink.Value)
Project.OpenForm(sName)
Case "webpage"
sName = File.BaseName(Project.GetUniqueSourceName(sName))
Project.InsertSource(sName, "class", $sDir, File.SetExt(sTemp, "class"), True, True, chkLink.Value)
Project.InsertSource(sName, "webpage", $sDir, sTemp,,, chkLink.Value)
Project.InsertSource(sName, "webpage", $sDir, sTemp, False, False, chkLink.Value)
Default
sName = Project.GetUniqueName($sDir, sName)

View File

@ -862,7 +862,11 @@ Public Sub WakeUp(bReplace As Boolean)
cmbSearch.SetFocus
Endif
If sFind Then cmbSearch.Text = sFind
If sFind Then
cmbSearch.Text = sFind
cmbSearch.SelectAll
Endif
ShowString
End

View File

@ -0,0 +1,21 @@
[Theme]
Background="#FFFFFF"
Alternate="#D0FFE0"
Normal="#000000"
Keyword="#000000,Bold"
Datatype="#DF6B00,Bold"
Function="#3398C3,Bold"
Operator="#000000,Bold"
Symbol="#000000"
Number="#FF0000,Bold"
String="#7F0000"
Comment="#888786,Italic"
Help="#888786,Bold,Italic"
Preprocessor="#006E28,Bold"
Breakpoint="#FF5F5F"
Current="#42C9FF"
Selection="#9BE2FF"
Highlight="#7FFF00"
CurrentLine="#E7F3FF"
Error="#BF0303,Underline"

View File

@ -52,7 +52,7 @@
Tag = "*"
Background = ReportBrush["#FFFF00"]
{ ReportLabel1 ReportLabel
#MoveScaled(0,5,46,23)
#MoveScaled(3,5,43,23)
Left = "25%"
Top = "5cm"
Width = "50%"
@ -65,6 +65,10 @@
Text = ("gambas")
Alignment = Align.Center
}
{ ReportImage1 ReportImage
#MoveScaled(8,24,14,8)
Image = Image.Load("printer1.png")
}
}
{ ReportLabel2 ReportLabel
#MoveScaled(9,47,47,5)

View File

@ -1,8 +1,8 @@
# Gambas Project File 3.0
# Compiled with Gambas 2.99.4
# Compiled with Gambas 2.99.6
Title=Gambas settings management
Startup=Main
Version=2.99.4
Version=2.99.6
VersionProgram=gbx3 -V
Authors="Benoît Minisini"
TabSize=2

View File

@ -137,7 +137,7 @@ Public Sub Save()
Sleep 0.2
Next
hFile = Open $sPath For Create
hFile = Open $sPath & "#" For Create
If $sTitle Then
Print #hFile, "# "; $sTitle
@ -155,7 +155,11 @@ Public Sub Save()
Next
Close #hFile
Try Kill $sPath & "~"
Try Move $sPath To $sPath & "~"
Try Move $sPath & "#" To $sPath
Try Kill $sPath & ".lock"
Try Kill $sPath & "~"
Unlock #hLock
'CATCH

View File

@ -184,6 +184,10 @@ Unique
P
b
Modified
P
b
_init
M
@ -204,10 +208,6 @@ _put
M
(Value)v(Key)s
Modify
M
Save
M

View File

@ -91,9 +91,7 @@ End
Private Sub ShouldCompress() As Boolean
If $sContentType = "image/jpeg" Then Return False
If $sContentType = "image/png" Then Return False
Return True
Return $sContentType Begins "text/"
End

View File

@ -17,6 +17,7 @@ Property Id As String
Property Timeout As Float
Property Prefix As String
Property Unique As Boolean
Property Modified As Boolean
Private Sub LockSession()
@ -310,12 +311,6 @@ Public Sub _put(Value As Variant, Key As String)
End
Public Sub Modify()
$bModify = True
End
Private Function Id_Read() As String
@ -381,3 +376,15 @@ Private Sub Unique_Write(Value As Boolean)
CheckUnique
End
Private Function Modified_Read() As Boolean
Return $bModify
End
Private Sub Modified_Write(Value As Boolean)
$bModify = Value
End

View File

@ -1,5 +1,5 @@
# Gambas Project File 3.0
# Compiled with Gambas 2.99.1
# Compiled with Gambas 2.99.6
Title=Anti-Aliased Drawing
Startup=FMain
Icon=icon.png

View File

@ -446,6 +446,24 @@ Public Sub Example17()
End
Public Sub Example18()
Paint.Save
Paint.Rectangle(10, 10, 200, 100)
Paint.Clip(True)
Paint.Stroke
Paint.Font.Size = 18
'Paint.Brush = Paint.Color(Color.Blue)
Paint.Text("TO BE, OR NOT TO BE: THAT IS THE QUESTION:", 10, 10, 30, 30)
Paint.Fill
Paint.Restore
'Paint.Brush = Paint.Color(Color.Blue)
Paint.Text("TO BE, OR NOT TO BE: THAT IS THE QUESTION:", 10, 40, 30, 30)
Paint.Fill
End
Public Sub Example20()
Dim eWidth As Float

View File

@ -126,9 +126,15 @@
Tag = "16"
Text = ("Text")
}
{ Exemple18 RadioButton optExample
Name = "Exemple18"
MoveScaled(0,54,31,3)
Tag = "18"
Text = ("Text clipping")
}
{ Exemple17 RadioButton optExample
Name = "Exemple17"
MoveScaled(0,54,31,3)
MoveScaled(0,57,31,3)
Tag = "17"
Text = ("Text extents")
}

View File

@ -17,6 +17,7 @@ Public Sub Example11()
Paint.Brush = hBrush
Paint.Rectangle(X, Y, W, H)
Paint.Fill
'Paint.DrawImage(hImage, X, Y, W, H)
Paint.Brush = Paint.Color(Color.RGB(255, 127, 127, 153))
Paint.Arc(X, Y, 10)

View File

@ -0,0 +1,16 @@
Public Sub Example18()
Paint.Save
Paint.Rectangle(10, 10, 200, 100)
Paint.Clip(True)
Paint.Stroke
Paint.Font.Size = 18
'Paint.Brush = Paint.Color(Color.Blue)
Paint.Text("TO BE, OR NOT TO BE: THAT IS THE QUESTION:", 10, 10, 30, 30)
Paint.Fill
Paint.Restore
'Paint.Brush = Paint.Color(Color.Blue)
Paint.Text("TO BE, OR NOT TO BE: THAT IS THE QUESTION:", 10, 40, 30, 30)
Paint.Fill
End

View File

@ -10,7 +10,8 @@ Active=2
File[2]=".src/Report1.report"
File[3]=".src/FMain.class:5.0"
File[4]=".src/Report1.class:12.16"
Count=4
File[5]=".src/Report2.report"
Count=5
[Watches]
Count=0

View File

@ -0,0 +1,19 @@
' Gambas class file
Public Sub _new()
Dim Rlbl As ReportLabel
Dim i As Integer
'Report.Debug = True
For i = 0 To 200
Rlbl = New ReportLabel(RVBCont)
Rlbl.Text = "Ligne " & i
Rlbl.Border.bottom.Width = "1px"
Rlbl.Padding.Top = "3 mm"
Rlbl.Padding.Bottom = "1mm"
Rlbl.Padding.Left = "2 mm"
Next
End

View File

@ -0,0 +1,19 @@
# Gambas Form File 3.0
{ Report Report
#MoveScaled(0,0,64,64)
Index = 0
Text = ("")
{ ReportHBox1 ReportHBox
#MoveScaled(1,1,61,8)
Height = "10cm"
Fixed = True
Expand = True
Background = ReportBrush["#007FFF"]
}
{ RVBCont ReportVBox
#MoveScaled(2,11,56,26)
Expand = True
}
Index = 0
}

View File

@ -502,8 +502,6 @@ BEGIN_METHOD(CDESKTOP_get_window_geometry, GB_INTEGER window)
GB_ARRAY array;
int *data;
Window root;
uint ignore;
if (X11_init())
return;
@ -511,7 +509,8 @@ BEGIN_METHOD(CDESKTOP_get_window_geometry, GB_INTEGER window)
GB.Array.New(&array, GB_T_INTEGER, 4);
data = (int *)GB.Array.Get(array, 0);
XGetGeometry(X11_display, VARG(window), &root, &data[0], &data[1], (uint *)&data[2], (uint *)&data[3], &ignore, &ignore);
X11_get_window_geometry(VARG(window), &data[0], &data[1], &data[2], &data[3]);
//XGetGeometry(X11_display, VARG(window), &root, &data[0], &data[1], (uint *)&data[2], (uint *)&data[3], &ignore, &ignore);
GB.ReturnObject(array);
END_METHOD

View File

@ -25,8 +25,10 @@ File[1]=".src/_Desktop_Passwords.class:0.0"
File[2]=".src/DesktopWindow.class:120.0"
File[3]=".src/Atom.class:8.14"
Active=4
File[4]=".src/Main.module:149.25"
Count=4
File[4]=".src/Main.module:149.28"
File[5]=".src/_DesktopVirtual.class:0.0"
File[6]=".src/Desktop.class:369.2"
Count=6
[Watches]
Count=0

View File

@ -142,17 +142,12 @@ End
Public Sub Main()
Dim dWindow As DesktopWindow
Dim hWindow As DesktopWindow
Print Desktop.Path
'Print Desktop.Path
For Each dWindow In Desktop.Windows
Print Hex(dWindow.Id);;
If dWindow.SkipTaskbar = True Then
Print "skip"
Else
Print dWindow.Name
Endif
For Each hWindow In Desktop.Windows
Print Hex$(hWindow.Id, 8);; Quote(hWindow.Name); ": "; hWindow.X;; hWindow.Y;; hWindow.Height;; hWindow.Width
Next
End

View File

@ -776,3 +776,23 @@ void X11_event_filter(XEvent *e)
GB.Call(&_desktop_window_func, 5, FALSE);
}
}
void X11_get_window_geometry(Window win, int *wx, int *wy, int *ww, int *wh)
{
Window p;
int transx, transy;
XWindowAttributes wattr;
*wx = *wy = *ww = *wh = 0;
if (!XTranslateCoordinates(_display, win, _root, 0, 0, &transx, &transy, &p))
return;
if (!XGetWindowAttributes(_display, win, &wattr))
return;
*wx = transx - wattr.border_width;
*wy = transy - wattr.border_width;
*ww = wattr.width + wattr.border_width * 2;
*wh = wattr.height + wattr.border_width * 2;
}

View File

@ -85,6 +85,7 @@ void X11_find_windows(Window **window_list, int *count);
void X11_get_window_title(Window window, char **result, int *length);
void X11_get_window_class(Window window, char **result, int *length);
void X11_get_window_role(Window window, char **result, int *length);
void X11_get_window_geometry(Window win, int *wx, int *wy, int *ww, int *wh);
/* Function to make a tool window */
void X11_set_window_tool(Window window, int tool, Window parent);
int X11_get_window_tool(Window window);

View File

@ -623,7 +623,7 @@ static void draw_text(GB_PAINT *d, bool rich, const char *text, int len, float w
CFONT *font;
float tw, th, offx, offy;
layout = pango_cairo_create_layout(CONTEXT(d));
layout = pango_cairo_create_layout(CONTEXT(d));
if (rich)
{
@ -638,6 +638,9 @@ static void draw_text(GB_PAINT *d, bool rich, const char *text, int len, float w
_Font(d, FALSE, (GB_FONT *)&font);
gt_add_layout_from_font(layout, font->font, d->resolutionY);
if (align == GB_DRAW_ALIGN_DEFAULT)
align = ALIGN_TOP_NORMAL;
if (w > 0 && h > 0)
{
gt_layout_alignment(layout, w, h, &tw, &th, align, &offx, &offy);

View File

@ -100,7 +100,7 @@ void dns_callback(intptr_t lParam)
mypoll.events=POLLIN;
mypoll.revents=0;
idata=poll(&mypoll,1,0);
if (!idata) break;
if (idata <= 0) break;
read_dns_pipe(&v_obj,sizeof(void*));
read_dns_pipe(&test_id,sizeof(int));
read_dns_pipe(Action,sizeof(char));

View File

@ -196,6 +196,7 @@ static int Begin(GB_PAINT *d)
static void End(GB_PAINT *d)
{
void *device = d->device;
QT_PAINT_EXTRA *dx = EXTRA(d);
if (GB.Is(device, CLASS_DrawingArea))
{
@ -216,19 +217,41 @@ static void End(GB_PAINT *d)
PAINTER(d)->end(); // ??
}
delete EXTRA(d)->path;
delete EXTRA(d)->clip;
delete EXTRA(d)->painter;
if (dx->clipStack)
{
while (!dx->clipStack->isEmpty())
delete dx->clipStack->takeLast();
delete dx->clipStack;
}
delete dx->path;
delete dx->clip;
delete dx->painter;
}
static void Save(GB_PAINT *d)
{
QT_PAINT_EXTRA *dx = EXTRA(d);
PAINTER(d)->save();
if (!dx->clipStack)
dx->clipStack = new QList<QPainterPath *>;
dx->clipStack->append(new QPainterPath(*dx->clip));
}
static void Restore(GB_PAINT *d)
{
QT_PAINT_EXTRA *dx = EXTRA(d);
PAINTER(d)->restore();
if (dx->clipStack && !dx->clipStack->isEmpty())
{
QPainterPath *path = dx->clipStack->takeLast();
delete dx->clip;
dx->clip = new QPainterPath(*path);
delete path;
}
}
static void Antialias(GB_PAINT *d, int set, int *antialias)

View File

@ -108,6 +108,7 @@ typedef
QPainterPath *path;
QPainterPath *clip;
int fillRule;
QList<QPainterPath *> *clipStack;
}
QT_PAINT_EXTRA;

View File

@ -929,6 +929,8 @@ static void add_string()
*p = '\r';
else if (car == 'b')
*p = '\b';
else if (car == 'v')
*p = '\v';
else if (car == 'f')
*p = '\f';
else if (car == 'e')

View File

@ -1064,6 +1064,7 @@ END_METHOD
BEGIN_METHOD(CARRAY_string_exist, GB_STRING value; GB_INTEGER mode)
//fprintf(stderr, "%s\n", DEBUG_get_current_position());
GB_ReturnBoolean(find_string(THIS, VARGOPT(mode, GB_COMP_BINARY), STRING(value), LENGTH(value), 0) >= 0);
END_METHOD

View File

@ -480,6 +480,7 @@ _MAIN:
_SUBR_CODE:
//fprintf(stderr, "gbx3: %02X: %s\n", (code >> 8), DEBUG_get_current_position());
(*(EXEC_FUNC_CODE)SubrTable[(code >> 8) - 0x28])(code);
//if (UNLIKELY(PCODE_is_void(code)))

View File

@ -525,7 +525,7 @@ void SUBR_replace(ushort code)
if (NPARAM == 4)
nocase = SUBR_get_integer(&PARAM[3]) == GB_COMP_NOCASE;
if (lp == 0)
if (lp == 0 || ls == 0)
{
RELEASE(&PARAM[1]);
RELEASE(&PARAM[2]);
@ -534,10 +534,26 @@ void SUBR_replace(ushort code)
return;
}
STRING_start_len(ls);
if (ls > 0 && lp > 0)
if (lp == 1 && lr == 1)
{
char cp = *pp;
char cr = *pr;
ps = STRING_new_temp(ps, ls);
for (pos = 0; pos < ls; pos++)
{
if (ps[pos] == cp)
ps[pos] = cr;
}
RETURN->_string.addr = ps;
RETURN->_string.len = ls;
}
else
{
STRING_start_len(ls);
for(;;)
{
pos = STRING_search(ps, ls, pp, lp, 1, FALSE, nocase);
@ -561,12 +577,12 @@ void SUBR_replace(ushort code)
}
STRING_make(ps, ls);
RETURN->_string.addr = STRING_end_temp();
RETURN->_string.len = STRING_length(RETURN->_string.addr);
}
RETURN->type = T_STRING;
RETURN->_string.addr = STRING_end_temp();
RETURN->_string.start = 0;
RETURN->_string.len = STRING_length(RETURN->_string.addr);
SUBR_LEAVE();
}

View File

@ -957,6 +957,8 @@ static void add_string()
*p = '\r';
else if (car == 'b')
*p = '\b';
else if (car == 'v')
*p = '\v';
else if (car == 'f')
*p = '\f';
else if (car == 'e')