33
1 Semester overview CSC 4111 Software Engineering Lab Winter 2010

Semester overview CSC 4111 Software Engineering Lab

  • Upload
    fionn

  • View
    46

  • Download
    0

Embed Size (px)

DESCRIPTION

Semester overview CSC 4111 Software Engineering Lab. Winter 2010. Schedule. Lab 1 – syllabus, tools needed Lab 2 – Technologies in NotePad++ Lab 3 – using Subversion Lab 4 – example of a software change Lab 5 – Change request 1 Lab 6 – using Visio - PowerPoint PPT Presentation

Citation preview

Page 1: Semester overview CSC 4111 Software Engineering Lab

1

Semester overviewCSC 4111 Software Engineering Lab

Winter 2010

Page 2: Semester overview CSC 4111 Software Engineering Lab

Schedule

• Lab 1 – syllabus, tools needed• Lab 2 – Technologies in NotePad++• Lab 3 – using Subversion • Lab 4 – example of a software change• Lab 5 – Change request 1• Lab 6 – using Visio• Lab 7 – group meeting. Q/A about projects

Page 3: Semester overview CSC 4111 Software Engineering Lab

Schedule

• Lab 8 – CR1 due + change request 2• Lab 9 – unit testing• Lab 10 – group meeting. Q/A about project• Lab 11 – CR 2 due + change request 3• Lab 12 – refactoring • Lab 13 – group meeting. Q/A about project• Lab 14 – CR3 due + overview

Page 4: Semester overview CSC 4111 Software Engineering Lab

4

Technologies in NotePad++CSC 4111 Software Engineering Lab

Winter 2010

Page 5: Semester overview CSC 4111 Software Engineering Lab

5

Classical Flow of a Program

• The flow is sequential from beginning to end (program executes top-bottom).

• The user is invoked by the program.• The user enters input when the program dictates

so.• The path varies depending on the input and

conditions.

Page 6: Semester overview CSC 4111 Software Engineering Lab

6

Event Driven Development (EDD)

• EDD – a new paradigm• Hollywood Principle: "Don't call us; we'll call you." • The user decides the flow of the program, by

performing a particular action• The action that the user performs is translated to an

event (keystroke, mouse click, command for windows repaint, etc.)

• The event is handled in the system by event handlers• Most common use of EDD: graphical user interfaces

(GUIs)• Windows programs: Event-driven programming

model.

Page 7: Semester overview CSC 4111 Software Engineering Lab

7

The Handlers Pattern

Page 8: Semester overview CSC 4111 Software Engineering Lab

8

Handlers Pattern:Event:• a software message that indicates something has

happened, such as a keystroke or mouse click Dispatcher: • takes each event and analyzes it to determine its

type• sends each event to a handler that can handle

events of that type.• its logic includes an event loop, as it has to process

a stream of input eventsHandler:• A procedure specialized in handling a specific type

of events

Page 9: Semester overview CSC 4111 Software Engineering Lab

9

Sequence of events

1) The application paints several user interface objects (e.g.: buttons, text areas, menus, etc.)

2) The application waits in a piece of code (event-loop) for the user to do something

3) The user does something to the objects on the screen (e.g.: clicks on a button - > the mouse click is an event)

4) The user interface object updates its appearance on the screen and calls a pre-arranged function in the system, which contains the code that implements the action for the GUI object

Page 10: Semester overview CSC 4111 Software Engineering Lab

Win32 Application• WndProc – dispatcher for each window• Standard Messages: – WM_CREATE, – WM_SIZE, – WM_COMMAND, – WM_MENUSELECT

• resource.h contains the definitions of the new user messages– IDM_FILE_NEW– IDM_FILE_OPEN– IDM_EDIT_COPY

Page 11: Semester overview CSC 4111 Software Engineering Lab

How to send and receive messages• ::SendMessage function takes 4 parameters:– LRESULT SendMessage(

HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );

– hWnd – handler to the window (mainwindow, combobox, dialogbox, checkbox, radiobutton, etc.)

– Msg – the message to send • Depending on the message the value in the window can read or

written– wParam, lParam – parameters of the message

• Variables to store the value, value to be stored• Use SendMessage when you are dealing with dialog

windows related to the menu

Page 12: Semester overview CSC 4111 Software Engineering Lab

Windows application• Hello world#include <windows.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MessageBox(NULL, "Goodbye, cruel world!", "Note", MB_OK); return 0; }

WinMain – the equivalent of the function main in Console applicationsHINSTANCE hInstance - Handle to the programs executable module

(the .exe file in memory)HINSTANCE hPrevInstance - Always NULL for Win32 programs.LPSTR lpCmdLine - The command line arguments as a single string.

NOT including the program name.int nCmdShow - An integer value which may be passed

to ShowWindow(). We'll get to this later.

Page 13: Semester overview CSC 4111 Software Engineering Lab

Task 1 – simple window

• Create an Empty project in Visual Studio 2008• Create a new cpp file in the project• Add the code from task1.cpp• Compile and run

Page 14: Semester overview CSC 4111 Software Engineering Lab

Create and register your window

• Let’s create a real window– Step 1: Register the Window Class– Step 2: Create the Window– Step 3: The Message Loop– Step 4: The Window Procedure

Page 15: Semester overview CSC 4111 Software Engineering Lab

Task 2

• Create an Empty project in Visual Studio 2008• Create a new cpp file in the project• Add the code from task2.cpp• Compile and run

Page 16: Semester overview CSC 4111 Software Engineering Lab

Windows Queue

Windows Queue

Page 17: Semester overview CSC 4111 Software Engineering Lab

Message loop• A message is an integer value. – Look for their definition in the header files#define IDM_FILE_NEW 40001

// Step 3: The Message Loop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); }

Page 18: Semester overview CSC 4111 Software Engineering Lab

Task 3 – find the message loop in NotePad++

• Which file contains the message loop in Notepad++?

Page 19: Semester overview CSC 4111 Software Engineering Lab

Receiving messages• All the messages are received using the Window

procedure// Step 4: the Window ProcedureLRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){ switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0;}

Page 20: Semester overview CSC 4111 Software Engineering Lab

Task 4 - Window Procedure• The window procedure is called for each message (CALLBACK)• Each window has its own window procedure• Task 4: add the following message in the window from task 2

case WM_LBUTTONDOWN: { char szFileName[MAX_PATH]; HINSTANCE hInstance = GetModuleHandle(NULL);

GetModuleFileName(hInstance, szFileName, MAX_PATH); MessageBox(hwnd, szFileName, "This program is:", MB_OK |

MB_ICONINFORMATION); }• Task 5: Name at least 5 files in Notepad++ where a Window

procedure is defined?

Page 21: Semester overview CSC 4111 Software Engineering Lab

Sending messages• ::SendMessage function takes 4 parameters:– LRESULT SendMessage(

HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam );

– hWnd – handler to the window (mainwindow, combobox, dialogbox, checkbox, radiobutton, etc.)

– Msg – the message to send • Depending on the message the value in the window can read or

written– wParam, lParam – parameters of the message

• Variables to store the value, value to be stored• Use SendMessage when you are dealing with dialog

windows related to the menu

Page 22: Semester overview CSC 4111 Software Engineering Lab

What parameters to use

• Select the text in a combobox:– ::SendMessage(hCombo, CB_SETCURSEL,

(WPARAM)-1, 0)– ::SendMessage(hCombo, CB_SETEDITSEL, 0,

MAKELPARAM(0, -1));

• Task 6: check in MSDN what parameters to use for the two messages above

Page 23: Semester overview CSC 4111 Software Engineering Lab

How to show a window

• After the window is created, it is not visible – Use showWindow or display to show a main window

• You can select and work with other windows in the same tim

– use doDialog to show a dialog, • The window will be displayed on top, no other window can

be selected

• ::ShowWindow(::GetDlgItem(_hSelf, IDCMARKALL), isEnable?SW_HIDE:SW_SHOW);

• _aboutDlg.doDialog();

Page 24: Semester overview CSC 4111 Software Engineering Lab

How to enable a window

• ::EnableWindow(::GetDlgItem(_hSelf, IDBOOLOR), FALSE);

• EnableWindows takes 2 parameters– The first parameter is a reference to a window– The second parameter is a boolean value

• GetDlgItem returns a reference to the window (controller) with the given id from the parent window _hself – IDBOOLOR – is a radio button created by one of you– _hself – refers to findReplaceDlg window

Page 25: Semester overview CSC 4111 Software Engineering Lab

What to submit• Task 1 – Hello World ( 20 points)• Task 2 – Simple Window (20 points )• Task 3 – find the message loop in NotePad++ (20 points)• Task 4: add the following message in the window from task 2 ( 20 points)• Task 5: Name at least 5 files in Notepad++ where a Window procedure is

defined? (10 points)• Task 6: check in MSDN what parameters to use for the two messages

above (10 points)Extra credit (20 points)• Task 7: How many parameters do you have to specify for the message

SCI_FINDCOLUMN? What is the meaning of these parameters? What does the following function call return?

Page 26: Semester overview CSC 4111 Software Engineering Lab

Submit the lab!

• Complete the tasks by January 27th – 7:30PM• Send all the answers as a zip file trough

blackboard• If you missed the class contact the instructor

Page 27: Semester overview CSC 4111 Software Engineering Lab

27

Extra slides

Winter 2010

Page 28: Semester overview CSC 4111 Software Engineering Lab

Scintilla library

• Contains functions which allow the user to avoid the usage of SendMessage function– Function “execute” from the class

ScintillaEditViewLRESULT execute(UINT Msg, WPARAM wParam=0, LPARAM lParam=0) const {

return _pScintillaFunc(_pScintillaPtr, static_cast<int>(Msg), static_cast<int>(wParam), static_cast<int>(lParam));};

– The user only need to specify the messageint caretPos = execute(SCI_GETCURRENTPOS);

Page 29: Semester overview CSC 4111 Software Engineering Lab

Demo

• A simple application that uses Scintilla library

Page 30: Semester overview CSC 4111 Software Engineering Lab

Other tips

• Menus, windows, GUI in general are defined in *.rc files

• Use search in files to grep for string in these files

• cxx and hpp are extensions of C++ files, they are equivalent with cpp and header files

• http://www.scintilla.org/ScintillaDoc.html

Page 31: Semester overview CSC 4111 Software Engineering Lab

NotePad++ example – how to find the maker type

• During concept location I found the message: SCI_INDICATORVALUEAT

• The change request was to go the next marked area

• I looked in scintilla.h and I found the message: SCI_INDICATORVALUEAT

• Question: How to use this message• Execute(SCI_INDICATORVALUEAT) always returns

the same number (1)

Page 32: Semester overview CSC 4111 Software Engineering Lab

How to find the implementation of a message in Scintilla project

• Search for SCI_INDICATORVALUEAT in SciLexer project. Found: case SCI_INDICATORVALUEAT:

return pdoc->decorations.ValueAt(wParam, lParam);• Both wParam and lParam are used– The implementation of the method ValueAtint DecorationList::ValueAt(int indicator, int position) {

Decoration *deco = DecorationFromIndicator(indicator);if (deco) {

return deco->rs.ValueAt(position);}return 0;

}

Page 33: Semester overview CSC 4111 Software Engineering Lab

Getting the value int currentposition = _pEditView->execute(SCI_GETCURRENTPOS); LRESULT style1 = _pEditView->execute(SCI_INDICATORVALUEAT,

SCE_UNIVERSAL_FOUND_STYLE_EXT1, currentposition);

• If the current position is marked with style 1 the value is of style1 is 1, otherwise it is 0

• Task 7: How many parameters do you have to specify for the message SCI_FINDCOLUMN? What is the meaning of these parameters? What does the following function call return?

(*_ppEditView)->execute(SCI_FINDCOLUMN, i, j)