Lazarus
Programming => Widgetset => Cocoa => Topic started by: xinyiman on June 06, 2019, 09:29:16 am
-
Hi guys, I'm extending the dbgrid to get a smarter grid that allows me to have filters in the columns and other features. I'm at the beginning and the project is still at the beginning. But I have already encountered a problem. If you compile my project and run it you will see that it loads two lines in the grid, then if you click on the Click Me button you will notice that the grid redraw is wrong, the size of the row containing the titles and filters gets smaller. Then, if you click with the mouse on any point on the grid, it redraws correctly. I don't understand why I have to click to see right. If you look at the images I attach you will understand what I mean.
-
To simplify the problem occurs when I close and reopen the dataset that populates the grid. If you create a button2 and put the following code in it
Self.Q_Persone.Close;
Self.Q_Persone.Open;
you will see that you replicate the error. But I don't understand why. Is it a bug in the dbgrid? Or do I have a problem with my code? Do you miss anything?
-
Has anyone managed to reproduce the problem?
-
error sql query is empty
-
error sql query is empty
Impossible, I rediscovered it and it doesn't give me the error you say.
-
On Windows 10 it works fine.
-
Problem only on Mac cocoa
-
Problem only on Mac cocoa
What version of Lazarus are you using? 1.8.0?
-
Problem only on Mac cocoa
What version of Lazarus are you using? 1.8.0?
2.1.0
-
Look at the example below. Click the "click me" button and then the "click me 2" button. If you see the click me 2 performs an operation that I also perform in the click me. I don't understand why clicking on "click me 2" works.
-
I don't understand why clicking on "click me 2" works.
Because you do a whole lot more in "Click me".
So what is the problem.
Why not just step through all the things you do in "Click me" and see where the problems lies.
-
I can't understand what's wrong. First because on windows and linux it works but only on mac no, second because it seems that any subsequent iteration with the grid on click me redraws the grid itself correctly. And I don't understand what prevents him from doing it directly in the click me button.
-
Ok, I modified the program slightly. Ignore the click me button and the click me2 button. After loading, first click the Button3 button and you will see that I only do a DataSet.Close and a DataSet.Open and a DataSet.Refresh (and so far the problem presents itself). Then press the button4 button and you will see that the problem is solved. But it doesn't make sense, because in button4 I only do a DataSet.refresh. I would like to know which user writes cocoa widgets so as to ask him directly how to solve.
-
I would like to know which user writes cocoa widgets so as to ask him directly how to solve.
Not sure about DBGrid, but most likely skalogryz.
-
I would like to know which user writes cocoa widgets so as to ask him directly how to solve.
Not sure about DBGrid, but most likely skalogryz.
I do not understand what you mean. what is skalogryz?!
-
I would like to know which user writes cocoa widgets so as to ask him directly how to solve.
Not sure about DBGrid, but most likely skalogryz.
I do not understand what you mean. what is skalogryz?!
You asked for a user.
skalogryz is a forum-user.
Check his profile.
https://forum.lazarus.freepascal.org/index.php?action=profile;u=13884
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz
-
thanks a lot
-
Example done for skalogryz. See attachment
-
so what's happening is that on the initial drawing your first row height is 21 pixels. (which is a default row height).
On the consequent drawing, the desired 42-pixels height is picked up.
You don't really need to do ".Refresh" of any kind. You can just simply resize the form to see the height of the top row to change.
What you're looking into is resetting the height of the first row before (the first) drawing.
Currently, the height is adjusted in DrawCell() method, and that's too late. (as drawing is already in progress)
-
so what's happening is that on the initial drawing your first row height is 21 pixels. (which is a default row height).
On the consequent drawing, the desired 42-pixels height is picked up.
You don't really need to do ".Refresh" of any kind. You can just simply resize the form to see the height of the top row to change.
What you're looking into is resetting the height of the first row before (the first) drawing.
Currently, the height is adjusted in DrawCell() method, and that's too late. (as drawing is already in progress)
So in which event do you advise me to move the definition of the title height?
-
So in which event do you advise me to move the definition of the title height?
there are two places that can work
1) whenever you change a filter setting (as filters are the reason for the height to be different). If filter change, you'd need to review if the height needs to be any different than default height.
2) in the very most beginning of the paint. Before you pass the paint to TDBGrid, you need to adjust heights according to the current filter settings.
Approach #1 is better, than approach #2. Both of them would be doing the same thing (checking if height needs to be different).
But approach #1 would only do it when the height can actually change.
Approach #2 would do it every time the control paints. And that is a little of overhead.